@kaitranntt/ccs 7.37.0-dev.2 → 7.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/account-manager.d.ts +207 -5
- package/dist/cliproxy/account-manager.d.ts.map +1 -1
- package/dist/cliproxy/account-manager.js +795 -35
- package/dist/cliproxy/account-manager.js.map +1 -1
- package/dist/cliproxy/auth/token-expiry-checker.d.ts.map +1 -1
- package/dist/cliproxy/auth/token-expiry-checker.js +1 -5
- package/dist/cliproxy/auth/token-expiry-checker.js.map +1 -1
- package/dist/cliproxy/cliproxy-executor.d.ts +28 -11
- package/dist/cliproxy/cliproxy-executor.d.ts.map +1 -1
- package/dist/cliproxy/cliproxy-executor.js +1028 -20
- package/dist/cliproxy/cliproxy-executor.js.map +1 -1
- package/dist/cliproxy/config-generator.d.ts +221 -9
- package/dist/cliproxy/config-generator.d.ts.map +1 -1
- package/dist/cliproxy/config-generator.js +856 -12
- package/dist/cliproxy/config-generator.js.map +1 -1
- package/dist/commands/cliproxy-command.d.ts +15 -4
- package/dist/commands/cliproxy-command.d.ts.map +1 -1
- package/dist/commands/cliproxy-command.js +1090 -5
- package/dist/commands/cliproxy-command.js.map +1 -1
- package/dist/ui/assets/{accounts-D0KU1a-4.js → accounts-DmKrgrCj.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BNRDV_Kh.js → alert-dialog-CHcjWgRn.js} +1 -1
- package/dist/ui/assets/{api-ClkFu9LY.js → api-BFHZ3RKb.js} +1 -1
- package/dist/ui/assets/{auth-section-CNhNN1Jp.js → auth-section-DAI6Q5vU.js} +1 -1
- package/dist/ui/assets/{backups-section-CZ721HIu.js → backups-section-B1O8i4FM.js} +1 -1
- package/dist/ui/assets/cliproxy-BsSI8qFW.js +3 -0
- package/dist/ui/assets/{cliproxy-control-panel-T9i_Ldh0.js → cliproxy-control-panel-3zVE7jZH.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-Cy1__gRc.js → confirm-dialog-DV0JzL4A.js} +1 -1
- package/dist/ui/assets/{copilot-Cdqs2Jbh.js → copilot-BX8vT5RR.js} +3 -3
- package/dist/ui/assets/{globalenv-section-BEKtYN6I.js → globalenv-section-BAft0m9b.js} +1 -1
- package/dist/ui/assets/{health-BaHazGgS.js → health-ct5TpFUE.js} +1 -1
- package/dist/ui/assets/{index-C2MS84sf.js → index-B8-K01HW.js} +1 -1
- package/dist/ui/assets/{index-BTBpI5th.js → index-BOsGipAU.js} +1 -1
- package/dist/ui/assets/{index-BZn6kF0u.js → index-CU3zgD6n.js} +1 -1
- package/dist/ui/assets/{index-PjscK1jS.js → index-RZ6b7YTz.js} +1 -1
- package/dist/ui/assets/{index-CiULLjNI.js → index-gfWiPznS.js} +8 -8
- package/dist/ui/assets/{proxy-status-widget-BY6Lnr80.js → proxy-status-widget-Ng9oZdrw.js} +1 -1
- package/dist/ui/assets/{shared-dZGNvBe9.js → shared-DpInRmag.js} +1 -1
- package/dist/ui/assets/{switch-BCFbehJz.js → switch-DkRSlAu-.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/cliproxy/accounts/bulk-ops.d.ts +0 -22
- package/dist/cliproxy/accounts/bulk-ops.d.ts.map +0 -1
- package/dist/cliproxy/accounts/bulk-ops.js +0 -88
- package/dist/cliproxy/accounts/bulk-ops.js.map +0 -1
- package/dist/cliproxy/accounts/index.d.ts +0 -19
- package/dist/cliproxy/accounts/index.d.ts.map +0 -1
- package/dist/cliproxy/accounts/index.js +0 -54
- package/dist/cliproxy/accounts/index.js.map +0 -1
- package/dist/cliproxy/accounts/query.d.ts +0 -36
- package/dist/cliproxy/accounts/query.d.ts.map +0 -1
- package/dist/cliproxy/accounts/query.js +0 -94
- package/dist/cliproxy/accounts/query.js.map +0 -1
- package/dist/cliproxy/accounts/registry.d.ts +0 -74
- package/dist/cliproxy/accounts/registry.d.ts.map +0 -1
- package/dist/cliproxy/accounts/registry.js +0 -510
- package/dist/cliproxy/accounts/registry.js.map +0 -1
- package/dist/cliproxy/accounts/token-file-ops.d.ts +0 -64
- package/dist/cliproxy/accounts/token-file-ops.d.ts.map +0 -1
- package/dist/cliproxy/accounts/token-file-ops.js +0 -206
- package/dist/cliproxy/accounts/token-file-ops.js.map +0 -1
- package/dist/cliproxy/accounts/types.d.ts +0 -66
- package/dist/cliproxy/accounts/types.d.ts.map +0 -1
- package/dist/cliproxy/accounts/types.js +0 -12
- package/dist/cliproxy/accounts/types.js.map +0 -1
- package/dist/cliproxy/config/env-builder.d.ts +0 -60
- package/dist/cliproxy/config/env-builder.d.ts.map +0 -1
- package/dist/cliproxy/config/env-builder.js +0 -311
- package/dist/cliproxy/config/env-builder.js.map +0 -1
- package/dist/cliproxy/config/generator.d.ts +0 -63
- package/dist/cliproxy/config/generator.d.ts.map +0 -1
- package/dist/cliproxy/config/generator.js +0 -336
- package/dist/cliproxy/config/generator.js.map +0 -1
- package/dist/cliproxy/config/index.d.ts +0 -10
- package/dist/cliproxy/config/index.d.ts.map +0 -1
- package/dist/cliproxy/config/index.js +0 -26
- package/dist/cliproxy/config/index.js.map +0 -1
- package/dist/cliproxy/config/path-resolver.d.ts +0 -47
- package/dist/cliproxy/config/path-resolver.d.ts.map +0 -1
- package/dist/cliproxy/config/path-resolver.js +0 -104
- package/dist/cliproxy/config/path-resolver.js.map +0 -1
- package/dist/cliproxy/config/port-manager.d.ts +0 -33
- package/dist/cliproxy/config/port-manager.d.ts.map +0 -1
- package/dist/cliproxy/config/port-manager.js +0 -68
- package/dist/cliproxy/config/port-manager.js.map +0 -1
- package/dist/cliproxy/config/thinking-config.d.ts +0 -39
- package/dist/cliproxy/config/thinking-config.d.ts.map +0 -1
- package/dist/cliproxy/config/thinking-config.js +0 -143
- package/dist/cliproxy/config/thinking-config.js.map +0 -1
- package/dist/cliproxy/executor/env-resolver.d.ts +0 -45
- package/dist/cliproxy/executor/env-resolver.d.ts.map +0 -1
- package/dist/cliproxy/executor/env-resolver.js +0 -106
- package/dist/cliproxy/executor/env-resolver.js.map +0 -1
- package/dist/cliproxy/executor/index.d.ts +0 -24
- package/dist/cliproxy/executor/index.d.ts.map +0 -1
- package/dist/cliproxy/executor/index.js +0 -669
- package/dist/cliproxy/executor/index.js.map +0 -1
- package/dist/cliproxy/executor/lifecycle-manager.d.ts +0 -33
- package/dist/cliproxy/executor/lifecycle-manager.d.ts.map +0 -1
- package/dist/cliproxy/executor/lifecycle-manager.js +0 -161
- package/dist/cliproxy/executor/lifecycle-manager.js.map +0 -1
- package/dist/cliproxy/executor/retry-handler.d.ts +0 -27
- package/dist/cliproxy/executor/retry-handler.d.ts.map +0 -1
- package/dist/cliproxy/executor/retry-handler.js +0 -109
- package/dist/cliproxy/executor/retry-handler.js.map +0 -1
- package/dist/cliproxy/executor/session-bridge.d.ts +0 -30
- package/dist/cliproxy/executor/session-bridge.d.ts.map +0 -1
- package/dist/cliproxy/executor/session-bridge.js +0 -232
- package/dist/cliproxy/executor/session-bridge.js.map +0 -1
- package/dist/commands/cliproxy/auth-subcommand.d.ts +0 -10
- package/dist/commands/cliproxy/auth-subcommand.d.ts.map +0 -1
- package/dist/commands/cliproxy/auth-subcommand.js +0 -55
- package/dist/commands/cliproxy/auth-subcommand.js.map +0 -1
- package/dist/commands/cliproxy/help-subcommand.d.ts +0 -8
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +0 -1
- package/dist/commands/cliproxy/help-subcommand.js +0 -87
- package/dist/commands/cliproxy/help-subcommand.js.map +0 -1
- package/dist/commands/cliproxy/index.d.ts +0 -11
- package/dist/commands/cliproxy/index.d.ts.map +0 -1
- package/dist/commands/cliproxy/index.js +0 -196
- package/dist/commands/cliproxy/index.js.map +0 -1
- package/dist/commands/cliproxy/install-subcommand.d.ts +0 -14
- package/dist/commands/cliproxy/install-subcommand.d.ts.map +0 -1
- package/dist/commands/cliproxy/install-subcommand.js +0 -112
- package/dist/commands/cliproxy/install-subcommand.js.map +0 -1
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts +0 -10
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts.map +0 -1
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js +0 -54
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js.map +0 -1
- package/dist/commands/cliproxy/quota-subcommand.d.ts +0 -16
- package/dist/commands/cliproxy/quota-subcommand.d.ts.map +0 -1
- package/dist/commands/cliproxy/quota-subcommand.js +0 -383
- package/dist/commands/cliproxy/quota-subcommand.js.map +0 -1
- package/dist/commands/cliproxy/variant-subcommand.d.ts +0 -11
- package/dist/commands/cliproxy/variant-subcommand.d.ts.map +0 -1
- package/dist/commands/cliproxy/variant-subcommand.js +0 -292
- package/dist/commands/cliproxy/variant-subcommand.js.map +0 -1
- package/dist/ui/assets/cliproxy-DeGucfVg.js +0 -3
|
@@ -1,669 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* CLIProxy Executor - Main Orchestrator
|
|
4
|
-
*
|
|
5
|
-
* Coordinates the full execution flow:
|
|
6
|
-
* 1. Configuration resolution and validation
|
|
7
|
-
* 2. Binary management and remote proxy checks
|
|
8
|
-
* 3. Authentication and account management
|
|
9
|
-
* 4. Proxy lifecycle (spawn/detect/join)
|
|
10
|
-
* 5. Environment setup and proxy chains
|
|
11
|
-
* 6. Claude CLI execution with cleanup handlers
|
|
12
|
-
*/
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.findAvailablePort = exports.isPortAvailable = exports.execClaudeWithCLIProxy = void 0;
|
|
38
|
-
const child_process_1 = require("child_process");
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const os = __importStar(require("os"));
|
|
41
|
-
const progress_indicator_1 = require("../../utils/progress-indicator");
|
|
42
|
-
const ui_1 = require("../../utils/ui");
|
|
43
|
-
const shell_executor_1 = require("../../utils/shell-executor");
|
|
44
|
-
const binary_manager_1 = require("../binary-manager");
|
|
45
|
-
const config_generator_1 = require("../config-generator");
|
|
46
|
-
const remote_proxy_client_1 = require("../remote-proxy-client");
|
|
47
|
-
const auth_handler_1 = require("../auth-handler");
|
|
48
|
-
const types_1 = require("../types");
|
|
49
|
-
const platform_detector_1 = require("../platform-detector");
|
|
50
|
-
const model_config_1 = require("../model-config");
|
|
51
|
-
const proxy_config_resolver_1 = require("../proxy-config-resolver");
|
|
52
|
-
const model_catalog_1 = require("../model-catalog");
|
|
53
|
-
const codex_reasoning_proxy_1 = require("../codex-reasoning-proxy");
|
|
54
|
-
const tool_sanitization_proxy_1 = require("../tool-sanitization-proxy");
|
|
55
|
-
const account_manager_1 = require("../account-manager");
|
|
56
|
-
const websearch_manager_1 = require("../../utils/websearch-manager");
|
|
57
|
-
const unified_config_loader_1 = require("../../config/unified-config-loader");
|
|
58
|
-
const https_tunnel_proxy_1 = require("../https-tunnel-proxy");
|
|
59
|
-
// Import modular components
|
|
60
|
-
const lifecycle_manager_1 = require("./lifecycle-manager");
|
|
61
|
-
const env_resolver_1 = require("./env-resolver");
|
|
62
|
-
const retry_handler_1 = require("./retry-handler");
|
|
63
|
-
const session_bridge_1 = require("./session-bridge");
|
|
64
|
-
const websearch_manager_2 = require("../../utils/websearch-manager");
|
|
65
|
-
/** Default executor configuration */
|
|
66
|
-
const DEFAULT_CONFIG = {
|
|
67
|
-
port: config_generator_1.CLIPROXY_DEFAULT_PORT,
|
|
68
|
-
timeout: 5000,
|
|
69
|
-
verbose: false,
|
|
70
|
-
pollInterval: 100,
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Execute Claude CLI with CLIProxy (main entry point)
|
|
74
|
-
*
|
|
75
|
-
* @param claudeCli Path to Claude CLI executable
|
|
76
|
-
* @param provider CLIProxy provider (gemini, codex, agy, qwen)
|
|
77
|
-
* @param args Arguments to pass to Claude CLI
|
|
78
|
-
* @param config Optional executor configuration
|
|
79
|
-
*/
|
|
80
|
-
async function execClaudeWithCLIProxy(claudeCli, provider, args, config = {}) {
|
|
81
|
-
// Filter out undefined values to prevent overwriting defaults
|
|
82
|
-
const filteredConfig = Object.fromEntries(Object.entries(config).filter(([, v]) => v !== undefined));
|
|
83
|
-
const cfg = { ...DEFAULT_CONFIG, ...filteredConfig };
|
|
84
|
-
const verbose = cfg.verbose || args.includes('--verbose') || args.includes('-v');
|
|
85
|
-
// Validate Claude CLI exists before proceeding
|
|
86
|
-
if (!fs.existsSync(claudeCli)) {
|
|
87
|
-
console.error((0, ui_1.fail)(`Claude CLI not found at: ${claudeCli}`));
|
|
88
|
-
console.error(' Run "ccs doctor --fix" to reinstall or check your PATH');
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
const log = (msg) => {
|
|
92
|
-
if (verbose) {
|
|
93
|
-
console.error(`[cliproxy] ${msg}`);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
// 0. Resolve proxy configuration (CLI > ENV > config.yaml > defaults)
|
|
97
|
-
const unifiedConfig = (0, unified_config_loader_1.loadOrCreateUnifiedConfig)();
|
|
98
|
-
// 0a. Runtime backend/provider validation
|
|
99
|
-
const backend = unifiedConfig.cliproxy?.backend ?? platform_detector_1.DEFAULT_BACKEND;
|
|
100
|
-
if (backend === 'original' && types_1.PLUS_ONLY_PROVIDERS.includes(provider)) {
|
|
101
|
-
console.error('');
|
|
102
|
-
console.error((0, ui_1.fail)(`${provider} requires CLIProxyAPIPlus backend`));
|
|
103
|
-
console.error('');
|
|
104
|
-
console.error('To use this provider, either:');
|
|
105
|
-
console.error(' 1. Set `cliproxy.backend: plus` in ~/.ccs/config.yaml');
|
|
106
|
-
console.error(' 2. Use --backend=plus flag: ccs ' + provider + ' --backend=plus');
|
|
107
|
-
console.error('');
|
|
108
|
-
throw new Error(`Provider ${provider} requires Plus backend`);
|
|
109
|
-
}
|
|
110
|
-
const cliproxyServerConfig = unifiedConfig.cliproxy_server;
|
|
111
|
-
const { config: proxyConfig, remainingArgs: argsWithoutProxy } = (0, proxy_config_resolver_1.resolveProxyConfig)(args, {
|
|
112
|
-
remote: cliproxyServerConfig?.remote
|
|
113
|
-
? {
|
|
114
|
-
enabled: cliproxyServerConfig.remote.enabled,
|
|
115
|
-
host: cliproxyServerConfig.remote.host,
|
|
116
|
-
port: cliproxyServerConfig.remote.port,
|
|
117
|
-
protocol: cliproxyServerConfig.remote.protocol,
|
|
118
|
-
auth_token: cliproxyServerConfig.remote.auth_token,
|
|
119
|
-
timeout: cliproxyServerConfig.remote.timeout,
|
|
120
|
-
}
|
|
121
|
-
: undefined,
|
|
122
|
-
local: cliproxyServerConfig?.local
|
|
123
|
-
? {
|
|
124
|
-
port: cliproxyServerConfig.local.port,
|
|
125
|
-
auto_start: cliproxyServerConfig.local.auto_start,
|
|
126
|
-
}
|
|
127
|
-
: undefined,
|
|
128
|
-
});
|
|
129
|
-
// Port resolution and validation
|
|
130
|
-
if (cfg.port && cfg.port !== config_generator_1.CLIPROXY_DEFAULT_PORT) {
|
|
131
|
-
if (proxyConfig.port !== config_generator_1.CLIPROXY_DEFAULT_PORT) {
|
|
132
|
-
cfg.port = proxyConfig.port;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else if (proxyConfig.port !== config_generator_1.CLIPROXY_DEFAULT_PORT) {
|
|
136
|
-
cfg.port = proxyConfig.port;
|
|
137
|
-
}
|
|
138
|
-
cfg.port = (0, config_generator_1.validatePort)(cfg.port);
|
|
139
|
-
log(`Proxy mode: ${proxyConfig.mode}`);
|
|
140
|
-
if (proxyConfig.mode === 'remote') {
|
|
141
|
-
log(`Remote host: ${proxyConfig.host}:${proxyConfig.port} (${proxyConfig.protocol})`);
|
|
142
|
-
}
|
|
143
|
-
// Setup WebSearch hooks
|
|
144
|
-
(0, websearch_manager_1.ensureMcpWebSearch)();
|
|
145
|
-
(0, websearch_manager_1.installWebSearchHook)();
|
|
146
|
-
(0, websearch_manager_1.displayWebSearchStatus)();
|
|
147
|
-
const providerConfig = (0, config_generator_1.getProviderConfig)(provider);
|
|
148
|
-
log(`Provider: ${providerConfig.displayName}`);
|
|
149
|
-
// Check remote proxy if configured
|
|
150
|
-
let useRemoteProxy = false;
|
|
151
|
-
if (proxyConfig.mode === 'remote' && proxyConfig.host) {
|
|
152
|
-
const status = await (0, remote_proxy_client_1.checkRemoteProxy)({
|
|
153
|
-
host: proxyConfig.host,
|
|
154
|
-
port: proxyConfig.port,
|
|
155
|
-
protocol: proxyConfig.protocol,
|
|
156
|
-
authToken: proxyConfig.authToken,
|
|
157
|
-
timeout: proxyConfig.timeout ?? 2000,
|
|
158
|
-
allowSelfSigned: proxyConfig.allowSelfSigned ?? false,
|
|
159
|
-
});
|
|
160
|
-
if (status.reachable) {
|
|
161
|
-
useRemoteProxy = true;
|
|
162
|
-
console.log((0, ui_1.ok)(`Connected to remote proxy at ${proxyConfig.host}:${proxyConfig.port} (${status.latencyMs}ms)`));
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
console.error((0, ui_1.warn)(`Remote proxy unreachable: ${status.error}`));
|
|
166
|
-
if (proxyConfig.remoteOnly) {
|
|
167
|
-
throw new Error('Remote proxy unreachable and --remote-only specified');
|
|
168
|
-
}
|
|
169
|
-
if (proxyConfig.fallbackEnabled) {
|
|
170
|
-
if (proxyConfig.autoStartLocal) {
|
|
171
|
-
console.log((0, ui_1.info)('Falling back to local proxy...'));
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
if (process.stdin.isTTY) {
|
|
175
|
-
const readline = await Promise.resolve().then(() => __importStar(require('readline')));
|
|
176
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
177
|
-
const answer = await new Promise((resolve) => {
|
|
178
|
-
rl.question('Start local proxy instead? [Y/n] ', resolve);
|
|
179
|
-
});
|
|
180
|
-
rl.close();
|
|
181
|
-
if (answer.toLowerCase() === 'n') {
|
|
182
|
-
throw new Error('Remote proxy unreachable and user declined fallback');
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
console.log((0, ui_1.info)('Starting local proxy...'));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
throw new Error('Remote proxy unreachable and fallback disabled');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// Variables for local proxy mode
|
|
194
|
-
let binaryPath;
|
|
195
|
-
let sessionId;
|
|
196
|
-
// 1. Ensure binary exists (downloads if needed) - SKIP for remote mode
|
|
197
|
-
if (!useRemoteProxy) {
|
|
198
|
-
const spinner = new progress_indicator_1.ProgressIndicator('Preparing CLIProxy');
|
|
199
|
-
spinner.start();
|
|
200
|
-
try {
|
|
201
|
-
binaryPath = await (0, binary_manager_1.ensureCLIProxyBinary)(verbose);
|
|
202
|
-
spinner.succeed('CLIProxy binary ready');
|
|
203
|
-
}
|
|
204
|
-
catch (error) {
|
|
205
|
-
spinner.fail('Failed to prepare CLIProxy');
|
|
206
|
-
const err = error;
|
|
207
|
-
if ((0, retry_handler_1.isNetworkError)(err)) {
|
|
208
|
-
(0, retry_handler_1.handleNetworkError)(err);
|
|
209
|
-
}
|
|
210
|
-
throw error;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
// 2. Handle special flags (simplified flag parsing - full implementation continues below)
|
|
214
|
-
const forceAuth = argsWithoutProxy.includes('--auth');
|
|
215
|
-
const pasteCallback = argsWithoutProxy.includes('--paste-callback');
|
|
216
|
-
const portForward = argsWithoutProxy.includes('--port-forward');
|
|
217
|
-
const forceHeadless = argsWithoutProxy.includes('--headless');
|
|
218
|
-
if (pasteCallback && portForward) {
|
|
219
|
-
console.error((0, ui_1.fail)('Cannot use --paste-callback with --port-forward'));
|
|
220
|
-
console.error(' --paste-callback: Manually paste OAuth redirect URL');
|
|
221
|
-
console.error(' --port-forward: Use SSH port forwarding for callback');
|
|
222
|
-
process.exit(1);
|
|
223
|
-
}
|
|
224
|
-
const forceLogout = argsWithoutProxy.includes('--logout');
|
|
225
|
-
const forceConfig = argsWithoutProxy.includes('--config');
|
|
226
|
-
const addAccount = argsWithoutProxy.includes('--add');
|
|
227
|
-
const showAccounts = argsWithoutProxy.includes('--accounts');
|
|
228
|
-
const forceImport = argsWithoutProxy.includes('--import');
|
|
229
|
-
const incognitoFlag = argsWithoutProxy.includes('--incognito');
|
|
230
|
-
const noIncognitoFlag = argsWithoutProxy.includes('--no-incognito');
|
|
231
|
-
const kiroNoIncognitoConfig = provider === 'kiro' ? (unifiedConfig.cliproxy?.kiro_no_incognito ?? true) : false;
|
|
232
|
-
const noIncognito = incognitoFlag ? false : noIncognitoFlag || kiroNoIncognitoConfig;
|
|
233
|
-
// Parse --use flag
|
|
234
|
-
let useAccount;
|
|
235
|
-
const useIdx = argsWithoutProxy.indexOf('--use');
|
|
236
|
-
if (useIdx !== -1 &&
|
|
237
|
-
argsWithoutProxy[useIdx + 1] &&
|
|
238
|
-
!argsWithoutProxy[useIdx + 1].startsWith('-')) {
|
|
239
|
-
useAccount = argsWithoutProxy[useIdx + 1];
|
|
240
|
-
}
|
|
241
|
-
// Parse --nickname flag
|
|
242
|
-
let setNickname;
|
|
243
|
-
const nicknameIdx = argsWithoutProxy.indexOf('--nickname');
|
|
244
|
-
if (nicknameIdx !== -1 &&
|
|
245
|
-
argsWithoutProxy[nicknameIdx + 1] &&
|
|
246
|
-
!argsWithoutProxy[nicknameIdx + 1].startsWith('-')) {
|
|
247
|
-
setNickname = argsWithoutProxy[nicknameIdx + 1];
|
|
248
|
-
}
|
|
249
|
-
// Parse --thinking flag
|
|
250
|
-
let thinkingOverride;
|
|
251
|
-
const thinkingEqArg = argsWithoutProxy.find((arg) => arg.startsWith('--thinking='));
|
|
252
|
-
if (thinkingEqArg) {
|
|
253
|
-
const val = thinkingEqArg.substring('--thinking='.length);
|
|
254
|
-
if (!val || val.trim() === '') {
|
|
255
|
-
console.error((0, ui_1.fail)('--thinking requires a value'));
|
|
256
|
-
console.error(' Examples: --thinking=low, --thinking=8192, --thinking=off');
|
|
257
|
-
console.error(' Levels: minimal, low, medium, high, xhigh, auto');
|
|
258
|
-
process.exit(1);
|
|
259
|
-
}
|
|
260
|
-
const numVal = parseInt(val, 10);
|
|
261
|
-
thinkingOverride = !isNaN(numVal) ? numVal : val;
|
|
262
|
-
const allThinkingFlags = argsWithoutProxy.filter((arg) => arg === '--thinking' || arg.startsWith('--thinking='));
|
|
263
|
-
if (allThinkingFlags.length > 1) {
|
|
264
|
-
console.warn(`[!] Multiple --thinking flags detected. Using first occurrence: ${thinkingEqArg}`);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
const thinkingIdx = argsWithoutProxy.indexOf('--thinking');
|
|
269
|
-
if (thinkingIdx !== -1) {
|
|
270
|
-
const nextArg = argsWithoutProxy[thinkingIdx + 1];
|
|
271
|
-
if (!nextArg || nextArg.startsWith('-')) {
|
|
272
|
-
console.error((0, ui_1.fail)('--thinking requires a value'));
|
|
273
|
-
console.error(' Examples: --thinking low, --thinking 8192, --thinking off');
|
|
274
|
-
console.error(' Levels: minimal, low, medium, high, xhigh, auto');
|
|
275
|
-
process.exit(1);
|
|
276
|
-
}
|
|
277
|
-
const numVal = parseInt(nextArg, 10);
|
|
278
|
-
thinkingOverride = !isNaN(numVal) ? numVal : nextArg;
|
|
279
|
-
const allThinkingFlags = argsWithoutProxy.filter((arg) => arg === '--thinking' || arg.startsWith('--thinking='));
|
|
280
|
-
if (allThinkingFlags.length > 1) {
|
|
281
|
-
console.warn(`[!] Multiple --thinking flags detected. Using first occurrence: --thinking ${nextArg}`);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
// Handle --accounts
|
|
286
|
-
if (showAccounts) {
|
|
287
|
-
const accounts = (0, account_manager_1.getProviderAccounts)(provider);
|
|
288
|
-
if (accounts.length === 0) {
|
|
289
|
-
console.log((0, ui_1.info)(`No accounts registered for ${providerConfig.displayName}`));
|
|
290
|
-
console.log(` Run "ccs ${provider} --auth" to add an account`);
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
console.log(`\n${providerConfig.displayName} Accounts:\n`);
|
|
294
|
-
for (const acct of accounts) {
|
|
295
|
-
const defaultMark = acct.isDefault ? ' (default)' : '';
|
|
296
|
-
const nickname = acct.nickname ? `[${acct.nickname}]` : '';
|
|
297
|
-
console.log(` ${nickname.padEnd(12)} ${acct.email || acct.id}${defaultMark}`);
|
|
298
|
-
}
|
|
299
|
-
console.log(`\n Use "ccs ${provider} --use <nickname>" to switch accounts`);
|
|
300
|
-
}
|
|
301
|
-
process.exit(0);
|
|
302
|
-
}
|
|
303
|
-
// Handle --use
|
|
304
|
-
if (useAccount) {
|
|
305
|
-
const account = (0, account_manager_1.findAccountByQuery)(provider, useAccount);
|
|
306
|
-
if (!account) {
|
|
307
|
-
console.error((0, ui_1.fail)(`Account not found: "${useAccount}"`));
|
|
308
|
-
const accounts = (0, account_manager_1.getProviderAccounts)(provider);
|
|
309
|
-
if (accounts.length > 0) {
|
|
310
|
-
console.error(` Available accounts:`);
|
|
311
|
-
for (const acct of accounts) {
|
|
312
|
-
console.error(` - ${acct.nickname || acct.id} (${acct.email || 'no email'})`);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
process.exit(1);
|
|
316
|
-
}
|
|
317
|
-
(0, account_manager_1.setDefaultAccount)(provider, account.id);
|
|
318
|
-
(0, account_manager_1.touchAccount)(provider, account.id);
|
|
319
|
-
console.log((0, ui_1.ok)(`Switched to account: ${account.nickname || account.email || account.id}`));
|
|
320
|
-
}
|
|
321
|
-
// Handle --nickname (rename account)
|
|
322
|
-
if (setNickname && !addAccount) {
|
|
323
|
-
const defaultAccount = (0, account_manager_1.getDefaultAccount)(provider);
|
|
324
|
-
if (!defaultAccount) {
|
|
325
|
-
console.error((0, ui_1.fail)(`No account found for ${providerConfig.displayName}`));
|
|
326
|
-
console.error(` Run "ccs ${provider} --auth" to add an account first`);
|
|
327
|
-
process.exit(1);
|
|
328
|
-
}
|
|
329
|
-
try {
|
|
330
|
-
const success = (0, account_manager_1.renameAccount)(provider, defaultAccount.id, setNickname);
|
|
331
|
-
if (success) {
|
|
332
|
-
console.log((0, ui_1.ok)(`Renamed account to: ${setNickname}`));
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
console.error((0, ui_1.fail)('Failed to rename account'));
|
|
336
|
-
process.exit(1);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
catch (err) {
|
|
340
|
-
console.error((0, ui_1.fail)(err instanceof Error ? err.message : 'Failed to rename account'));
|
|
341
|
-
process.exit(1);
|
|
342
|
-
}
|
|
343
|
-
process.exit(0);
|
|
344
|
-
}
|
|
345
|
-
// Handle --config
|
|
346
|
-
if (forceConfig && (0, model_catalog_1.supportsModelConfig)(provider)) {
|
|
347
|
-
await (0, model_config_1.configureProviderModel)(provider, true, cfg.customSettingsPath);
|
|
348
|
-
process.exit(0);
|
|
349
|
-
}
|
|
350
|
-
// Handle --logout
|
|
351
|
-
if (forceLogout) {
|
|
352
|
-
const { clearAuth } = await Promise.resolve().then(() => __importStar(require('../auth-handler')));
|
|
353
|
-
if (clearAuth(provider)) {
|
|
354
|
-
console.log((0, ui_1.ok)(`Logged out from ${providerConfig.displayName}`));
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
console.log((0, ui_1.info)(`No authentication found for ${providerConfig.displayName}`));
|
|
358
|
-
}
|
|
359
|
-
process.exit(0);
|
|
360
|
-
}
|
|
361
|
-
// Handle --import (Kiro only)
|
|
362
|
-
if (forceImport) {
|
|
363
|
-
if (provider !== 'kiro') {
|
|
364
|
-
console.error((0, ui_1.fail)('--import is only available for Kiro'));
|
|
365
|
-
console.error(` Run "ccs ${provider} --auth" to authenticate`);
|
|
366
|
-
process.exit(1);
|
|
367
|
-
}
|
|
368
|
-
if (forceAuth) {
|
|
369
|
-
console.error((0, ui_1.fail)('Cannot use --import with --auth'));
|
|
370
|
-
console.error(' --import: Import existing token from Kiro IDE');
|
|
371
|
-
console.error(' --auth: Trigger new OAuth flow in browser');
|
|
372
|
-
process.exit(1);
|
|
373
|
-
}
|
|
374
|
-
if (forceLogout) {
|
|
375
|
-
console.error((0, ui_1.fail)('Cannot use --import with --logout'));
|
|
376
|
-
process.exit(1);
|
|
377
|
-
}
|
|
378
|
-
const { triggerOAuth } = await Promise.resolve().then(() => __importStar(require('../auth-handler')));
|
|
379
|
-
const authSuccess = await triggerOAuth(provider, {
|
|
380
|
-
verbose,
|
|
381
|
-
import: true,
|
|
382
|
-
...(setNickname ? { nickname: setNickname } : {}),
|
|
383
|
-
});
|
|
384
|
-
if (!authSuccess) {
|
|
385
|
-
console.error((0, ui_1.fail)('Failed to import Kiro token from IDE'));
|
|
386
|
-
console.error(' Make sure you are logged into Kiro IDE first');
|
|
387
|
-
process.exit(1);
|
|
388
|
-
}
|
|
389
|
-
process.exit(0);
|
|
390
|
-
}
|
|
391
|
-
// 3. Ensure OAuth completed (if provider requires it)
|
|
392
|
-
const remoteAuthToken = proxyConfig.authToken?.trim();
|
|
393
|
-
const skipLocalAuth = useRemoteProxy && !!remoteAuthToken;
|
|
394
|
-
if (skipLocalAuth) {
|
|
395
|
-
log(`Using remote proxy authentication (skipping local OAuth)`);
|
|
396
|
-
}
|
|
397
|
-
if (providerConfig.requiresOAuth && !skipLocalAuth) {
|
|
398
|
-
log(`Checking authentication for ${provider}`);
|
|
399
|
-
if (forceAuth || !(0, auth_handler_1.isAuthenticated)(provider)) {
|
|
400
|
-
const { triggerOAuth } = await Promise.resolve().then(() => __importStar(require('../auth-handler')));
|
|
401
|
-
const authSuccess = await triggerOAuth(provider, {
|
|
402
|
-
verbose,
|
|
403
|
-
add: addAccount,
|
|
404
|
-
...(forceHeadless ? { headless: true } : {}),
|
|
405
|
-
...(setNickname ? { nickname: setNickname } : {}),
|
|
406
|
-
...(noIncognito ? { noIncognito: true } : {}),
|
|
407
|
-
...(pasteCallback ? { pasteCallback: true } : {}),
|
|
408
|
-
...(portForward ? { portForward: true } : {}),
|
|
409
|
-
});
|
|
410
|
-
if (!authSuccess) {
|
|
411
|
-
throw new Error(`Authentication required for ${providerConfig.displayName}`);
|
|
412
|
-
}
|
|
413
|
-
if (forceAuth) {
|
|
414
|
-
process.exit(0);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
else {
|
|
418
|
-
log(`${provider} already authenticated`);
|
|
419
|
-
}
|
|
420
|
-
// 3a. Proactive token refresh
|
|
421
|
-
await (0, retry_handler_1.handleTokenExpiration)(provider, verbose);
|
|
422
|
-
// 3a-1. Update lastUsedAt
|
|
423
|
-
const usedAccount = (0, account_manager_1.getDefaultAccount)(provider);
|
|
424
|
-
if (usedAccount) {
|
|
425
|
-
(0, account_manager_1.touchAccount)(provider, usedAccount.id);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
// 3b. Preflight quota check (Antigravity only)
|
|
429
|
-
if (!skipLocalAuth) {
|
|
430
|
-
await (0, retry_handler_1.handleQuotaCheck)(provider);
|
|
431
|
-
}
|
|
432
|
-
// 4. First-run model configuration
|
|
433
|
-
if ((0, model_catalog_1.supportsModelConfig)(provider) && !skipLocalAuth) {
|
|
434
|
-
await (0, model_config_1.configureProviderModel)(provider, false, cfg.customSettingsPath);
|
|
435
|
-
}
|
|
436
|
-
// 5. Check for broken models
|
|
437
|
-
const currentModel = (0, model_config_1.getCurrentModel)(provider, cfg.customSettingsPath);
|
|
438
|
-
if (currentModel && (0, model_catalog_1.isModelBroken)(provider, currentModel)) {
|
|
439
|
-
const modelEntry = (0, model_catalog_1.findModel)(provider, currentModel);
|
|
440
|
-
const issueUrl = (0, model_catalog_1.getModelIssueUrl)(provider, currentModel);
|
|
441
|
-
console.error('');
|
|
442
|
-
console.error((0, ui_1.warn)(`${modelEntry?.name || currentModel} has known issues with Claude Code`));
|
|
443
|
-
console.error(' Tool calls will fail. Use "gemini-3-pro-preview" instead.');
|
|
444
|
-
if (issueUrl) {
|
|
445
|
-
console.error(` Tracking: ${issueUrl}`);
|
|
446
|
-
}
|
|
447
|
-
if (skipLocalAuth) {
|
|
448
|
-
console.error(' Note: Model may be overridden by remote proxy configuration.');
|
|
449
|
-
}
|
|
450
|
-
else {
|
|
451
|
-
console.error(` Run "ccs ${provider} --config" to change model.`);
|
|
452
|
-
}
|
|
453
|
-
console.error('');
|
|
454
|
-
}
|
|
455
|
-
// 6. Ensure user settings file exists
|
|
456
|
-
(0, config_generator_1.ensureProviderSettings)(provider);
|
|
457
|
-
// Local proxy mode: generate config, spawn/join proxy, track session
|
|
458
|
-
let proxy = null;
|
|
459
|
-
let configPath;
|
|
460
|
-
if (!useRemoteProxy) {
|
|
461
|
-
log(`Generating config for ${provider}`);
|
|
462
|
-
configPath = (0, config_generator_1.generateConfig)(provider, cfg.port);
|
|
463
|
-
log(`Config written: ${configPath}`);
|
|
464
|
-
// 6a. Check or join existing proxy
|
|
465
|
-
const { sessionId: existingSessionId, shouldSpawn } = await (0, session_bridge_1.checkOrJoinProxy)(cfg.port, cfg.timeout, verbose);
|
|
466
|
-
sessionId = existingSessionId;
|
|
467
|
-
// 6b. Spawn new proxy if needed
|
|
468
|
-
if (shouldSpawn && binaryPath) {
|
|
469
|
-
proxy = (0, lifecycle_manager_1.spawnProxy)(binaryPath, configPath, verbose);
|
|
470
|
-
// 7. Wait for proxy readiness
|
|
471
|
-
await (0, lifecycle_manager_1.waitForProxyReadyWithSpinner)(cfg.port, cfg.timeout, cfg.pollInterval, backend, configPath);
|
|
472
|
-
// Register session
|
|
473
|
-
if (proxy.pid) {
|
|
474
|
-
sessionId = (0, session_bridge_1.registerProxySession)(cfg.port, proxy.pid, backend, verbose);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
// 8. Setup HTTPS tunnel if needed
|
|
479
|
-
let httpsTunnel = null;
|
|
480
|
-
let tunnelPort = null;
|
|
481
|
-
if (useRemoteProxy && proxyConfig.protocol === 'https' && proxyConfig.host) {
|
|
482
|
-
try {
|
|
483
|
-
httpsTunnel = new https_tunnel_proxy_1.HttpsTunnelProxy({
|
|
484
|
-
remoteHost: proxyConfig.host,
|
|
485
|
-
remotePort: proxyConfig.port,
|
|
486
|
-
authToken: proxyConfig.authToken,
|
|
487
|
-
verbose,
|
|
488
|
-
allowSelfSigned: proxyConfig.allowSelfSigned ?? false,
|
|
489
|
-
});
|
|
490
|
-
tunnelPort = await httpsTunnel.start();
|
|
491
|
-
log(`HTTPS tunnel started on port ${tunnelPort} → https://${proxyConfig.host}:${proxyConfig.port}`);
|
|
492
|
-
}
|
|
493
|
-
catch (error) {
|
|
494
|
-
const err = error;
|
|
495
|
-
console.error((0, ui_1.warn)(`Failed to start HTTPS tunnel: ${err.message}`));
|
|
496
|
-
throw new Error(`HTTPS tunnel startup failed: ${err.message}`);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
// 9. Setup tool sanitization proxy
|
|
500
|
-
let toolSanitizationProxy = null;
|
|
501
|
-
let toolSanitizationPort = null;
|
|
502
|
-
// Build initial env vars to get ANTHROPIC_BASE_URL
|
|
503
|
-
const initialEnvVars = (0, env_resolver_1.buildClaudeEnvironment)({
|
|
504
|
-
provider,
|
|
505
|
-
useRemoteProxy,
|
|
506
|
-
remoteConfig: proxyConfig.host
|
|
507
|
-
? {
|
|
508
|
-
host: proxyConfig.host,
|
|
509
|
-
port: proxyConfig.port,
|
|
510
|
-
protocol: proxyConfig.protocol,
|
|
511
|
-
authToken: proxyConfig.authToken,
|
|
512
|
-
}
|
|
513
|
-
: undefined,
|
|
514
|
-
httpsTunnel: httpsTunnel ?? undefined,
|
|
515
|
-
tunnelPort: tunnelPort ?? undefined,
|
|
516
|
-
localPort: cfg.port,
|
|
517
|
-
customSettingsPath: cfg.customSettingsPath,
|
|
518
|
-
thinkingOverride,
|
|
519
|
-
verbose,
|
|
520
|
-
});
|
|
521
|
-
if (initialEnvVars.ANTHROPIC_BASE_URL) {
|
|
522
|
-
try {
|
|
523
|
-
toolSanitizationProxy = new tool_sanitization_proxy_1.ToolSanitizationProxy({
|
|
524
|
-
upstreamBaseUrl: initialEnvVars.ANTHROPIC_BASE_URL,
|
|
525
|
-
verbose,
|
|
526
|
-
warnOnSanitize: true,
|
|
527
|
-
});
|
|
528
|
-
toolSanitizationPort = await toolSanitizationProxy.start();
|
|
529
|
-
log(`Tool sanitization proxy active on port ${toolSanitizationPort}`);
|
|
530
|
-
}
|
|
531
|
-
catch (error) {
|
|
532
|
-
const err = error;
|
|
533
|
-
toolSanitizationProxy = null;
|
|
534
|
-
toolSanitizationPort = null;
|
|
535
|
-
if (verbose) {
|
|
536
|
-
console.error((0, ui_1.warn)(`Tool sanitization proxy disabled: ${err.message}`));
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
const postSanitizationBaseUrl = toolSanitizationPort
|
|
541
|
-
? `http://127.0.0.1:${toolSanitizationPort}`
|
|
542
|
-
: initialEnvVars.ANTHROPIC_BASE_URL;
|
|
543
|
-
// 10. Setup Codex reasoning proxy (Codex only)
|
|
544
|
-
let codexReasoningProxy = null;
|
|
545
|
-
let codexReasoningPort = null;
|
|
546
|
-
if (provider === 'codex') {
|
|
547
|
-
if (!postSanitizationBaseUrl) {
|
|
548
|
-
log('ANTHROPIC_BASE_URL not set for Codex, reasoning proxy disabled');
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
551
|
-
try {
|
|
552
|
-
const traceEnabled = process.env.CCS_CODEX_REASONING_TRACE === '1' ||
|
|
553
|
-
process.env.CCS_CODEX_REASONING_TRACE === 'true';
|
|
554
|
-
const stripPathPrefix = useRemoteProxy ? '/api/provider/codex' : undefined;
|
|
555
|
-
codexReasoningProxy = new codex_reasoning_proxy_1.CodexReasoningProxy({
|
|
556
|
-
upstreamBaseUrl: postSanitizationBaseUrl,
|
|
557
|
-
verbose,
|
|
558
|
-
defaultEffort: 'medium',
|
|
559
|
-
traceFilePath: traceEnabled ? `${os.homedir()}/.ccs/codex-reasoning-proxy.log` : '',
|
|
560
|
-
modelMap: {
|
|
561
|
-
defaultModel: initialEnvVars.ANTHROPIC_MODEL,
|
|
562
|
-
opusModel: initialEnvVars.ANTHROPIC_DEFAULT_OPUS_MODEL,
|
|
563
|
-
sonnetModel: initialEnvVars.ANTHROPIC_DEFAULT_SONNET_MODEL,
|
|
564
|
-
haikuModel: initialEnvVars.ANTHROPIC_DEFAULT_HAIKU_MODEL,
|
|
565
|
-
},
|
|
566
|
-
stripPathPrefix,
|
|
567
|
-
});
|
|
568
|
-
codexReasoningPort = await codexReasoningProxy.start();
|
|
569
|
-
log(`Codex reasoning proxy active: http://127.0.0.1:${codexReasoningPort}/api/provider/codex`);
|
|
570
|
-
}
|
|
571
|
-
catch (error) {
|
|
572
|
-
const err = error;
|
|
573
|
-
codexReasoningProxy = null;
|
|
574
|
-
codexReasoningPort = null;
|
|
575
|
-
if (verbose) {
|
|
576
|
-
console.error((0, ui_1.warn)(`Codex reasoning proxy disabled: ${err.message}`));
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
// 11. Build final environment with all proxy chains
|
|
582
|
-
const env = (0, env_resolver_1.buildClaudeEnvironment)({
|
|
583
|
-
provider,
|
|
584
|
-
useRemoteProxy,
|
|
585
|
-
remoteConfig: proxyConfig.host
|
|
586
|
-
? {
|
|
587
|
-
host: proxyConfig.host,
|
|
588
|
-
port: proxyConfig.port,
|
|
589
|
-
protocol: proxyConfig.protocol,
|
|
590
|
-
authToken: proxyConfig.authToken,
|
|
591
|
-
}
|
|
592
|
-
: undefined,
|
|
593
|
-
httpsTunnel: httpsTunnel ?? undefined,
|
|
594
|
-
tunnelPort: tunnelPort ?? undefined,
|
|
595
|
-
codexReasoningProxy: codexReasoningProxy ?? undefined,
|
|
596
|
-
codexReasoningPort: codexReasoningPort ?? undefined,
|
|
597
|
-
toolSanitizationProxy: toolSanitizationProxy ?? undefined,
|
|
598
|
-
toolSanitizationPort: toolSanitizationPort ?? undefined,
|
|
599
|
-
localPort: cfg.port,
|
|
600
|
-
customSettingsPath: cfg.customSettingsPath,
|
|
601
|
-
thinkingOverride,
|
|
602
|
-
verbose,
|
|
603
|
-
});
|
|
604
|
-
const webSearchEnv = (0, websearch_manager_2.getWebSearchHookEnv)();
|
|
605
|
-
(0, env_resolver_1.logEnvironment)(env, webSearchEnv, verbose);
|
|
606
|
-
// 12. Filter CCS-specific flags before passing to Claude CLI
|
|
607
|
-
const ccsFlags = [
|
|
608
|
-
'--auth',
|
|
609
|
-
'--paste-callback',
|
|
610
|
-
'--port-forward',
|
|
611
|
-
'--headless',
|
|
612
|
-
'--logout',
|
|
613
|
-
'--config',
|
|
614
|
-
'--add',
|
|
615
|
-
'--accounts',
|
|
616
|
-
'--use',
|
|
617
|
-
'--nickname',
|
|
618
|
-
'--thinking',
|
|
619
|
-
'--incognito',
|
|
620
|
-
'--no-incognito',
|
|
621
|
-
'--import',
|
|
622
|
-
'--settings',
|
|
623
|
-
...proxy_config_resolver_1.PROXY_CLI_FLAGS,
|
|
624
|
-
];
|
|
625
|
-
const claudeArgs = argsWithoutProxy.filter((arg, idx) => {
|
|
626
|
-
if (ccsFlags.includes(arg))
|
|
627
|
-
return false;
|
|
628
|
-
if (arg.startsWith('--thinking='))
|
|
629
|
-
return false;
|
|
630
|
-
if (argsWithoutProxy[idx - 1] === '--use' ||
|
|
631
|
-
argsWithoutProxy[idx - 1] === '--nickname' ||
|
|
632
|
-
argsWithoutProxy[idx - 1] === '--thinking')
|
|
633
|
-
return false;
|
|
634
|
-
return true;
|
|
635
|
-
});
|
|
636
|
-
const isWindows = process.platform === 'win32';
|
|
637
|
-
const needsShell = isWindows && /\.(cmd|bat|ps1)$/i.test(claudeCli);
|
|
638
|
-
const settingsPath = cfg.customSettingsPath
|
|
639
|
-
? cfg.customSettingsPath.replace(/^~/, os.homedir())
|
|
640
|
-
: (0, config_generator_1.getProviderSettingsPath)(provider);
|
|
641
|
-
let claude;
|
|
642
|
-
if (needsShell) {
|
|
643
|
-
const cmdString = [claudeCli, '--settings', settingsPath, ...claudeArgs]
|
|
644
|
-
.map(shell_executor_1.escapeShellArg)
|
|
645
|
-
.join(' ');
|
|
646
|
-
claude = (0, child_process_1.spawn)(cmdString, {
|
|
647
|
-
stdio: 'inherit',
|
|
648
|
-
windowsHide: true,
|
|
649
|
-
shell: true,
|
|
650
|
-
env,
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
claude = (0, child_process_1.spawn)(claudeCli, ['--settings', settingsPath, ...claudeArgs], {
|
|
655
|
-
stdio: 'inherit',
|
|
656
|
-
windowsHide: true,
|
|
657
|
-
env,
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
// 13. Setup cleanup handlers
|
|
661
|
-
(0, session_bridge_1.setupCleanupHandlers)(claude, sessionId, cfg.port, codexReasoningProxy, toolSanitizationProxy, httpsTunnel, verbose);
|
|
662
|
-
}
|
|
663
|
-
exports.execClaudeWithCLIProxy = execClaudeWithCLIProxy;
|
|
664
|
-
// Re-export utility functions for backwards compatibility
|
|
665
|
-
var lifecycle_manager_2 = require("./lifecycle-manager");
|
|
666
|
-
Object.defineProperty(exports, "isPortAvailable", { enumerable: true, get: function () { return lifecycle_manager_2.isPortAvailable; } });
|
|
667
|
-
Object.defineProperty(exports, "findAvailablePort", { enumerable: true, get: function () { return lifecycle_manager_2.findAvailablePort; } });
|
|
668
|
-
exports.default = execClaudeWithCLIProxy;
|
|
669
|
-
//# sourceMappingURL=index.js.map
|