import path from 'path';
/** Escape a path for a PowerShell double-quoted string literal. */
export function quotePathForPowerShell(filePath) {
    const escaped = filePath.replace(/`/g, '``').replace(/"/g, '`"');
    return `"${escaped}"`;
}
/** Guardian proxy wrapper script for the current platform. */
export function resolveGuardianProxyWrapper(projectRoot) {
    if (process.platform === 'win32') {
        return path.join(projectRoot, 'guardian-proxy.ps1');
    }
    return path.join(projectRoot, 'scripts', 'guardian-proxy.sh');
}
/** MCP client JSON entry for a wrapped upstream server (handles paths with spaces). */
export function buildWrappedMcpServerEntry(projectRoot, singleConfigPath, policyPath, extraEnv) {
    const wrapperScript = resolveGuardianProxyWrapper(projectRoot);
    const proxyArgs = ['--config', singleConfigPath, '--policy', policyPath];
    const env = extraEnv && Object.keys(extraEnv).length > 0 ? { env: extraEnv } : {};
    if (process.platform === 'win32') {
        return {
            command: 'powershell.exe',
            args: ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', wrapperScript, ...proxyArgs],
            transport: 'stdio',
            ...env,
        };
    }
    return {
        command: wrapperScript,
        args: proxyArgs,
        transport: 'stdio',
        ...env,
    };
}
/** Whether a server config already points at Guardian proxy. */
export function isGuardianProxyCommand(command) {
    return (command.includes('guardian-proxy') ||
        command.includes('mcp-guardian') ||
        /guardian-proxy\.ps1$/i.test(command));
}
//# sourceMappingURL=windows-paths.js.map