@kaitranntt/ccs 7.54.0 → 7.55.0-dev.2
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/README.md +26 -4
- package/config/base-codex.settings.json +4 -4
- package/dist/auth/commands/create-command.js +1 -1
- package/dist/auth/commands/create-command.js.map +1 -1
- package/dist/auth/commands/remove-command.js +1 -1
- package/dist/auth/commands/remove-command.js.map +1 -1
- package/dist/ccs.js +70 -370
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/codex-plan-compatibility.d.ts +29 -0
- package/dist/cliproxy/codex-plan-compatibility.d.ts.map +1 -0
- package/dist/cliproxy/codex-plan-compatibility.js +130 -0
- package/dist/cliproxy/codex-plan-compatibility.js.map +1 -0
- package/dist/cliproxy/codex-reasoning-proxy.d.ts +5 -0
- package/dist/cliproxy/codex-reasoning-proxy.d.ts.map +1 -1
- package/dist/cliproxy/codex-reasoning-proxy.js +103 -20
- package/dist/cliproxy/codex-reasoning-proxy.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +8 -0
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/index.d.ts +1 -0
- package/dist/cliproxy/index.d.ts.map +1 -1
- package/dist/cliproxy/index.js +6 -2
- package/dist/cliproxy/index.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +81 -12
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/model-config.d.ts.map +1 -1
- package/dist/cliproxy/model-config.js +2 -2
- package/dist/cliproxy/model-config.js.map +1 -1
- package/dist/cliproxy/services/variant-settings.d.ts +3 -1
- package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-settings.js +5 -2
- package/dist/cliproxy/services/variant-settings.js.map +1 -1
- package/dist/commands/api-command/copy-command.d.ts +2 -0
- package/dist/commands/api-command/copy-command.d.ts.map +1 -0
- package/dist/commands/api-command/copy-command.js +41 -0
- package/dist/commands/api-command/copy-command.js.map +1 -0
- package/dist/commands/api-command/create-command.d.ts +2 -0
- package/dist/commands/api-command/create-command.d.ts.map +1 -0
- package/dist/commands/api-command/create-command.js +249 -0
- package/dist/commands/api-command/create-command.js.map +1 -0
- package/dist/commands/api-command/discover-command.d.ts +2 -0
- package/dist/commands/api-command/discover-command.d.ts.map +1 -0
- package/dist/commands/api-command/discover-command.js +69 -0
- package/dist/commands/api-command/discover-command.js.map +1 -0
- package/dist/commands/api-command/export-command.d.ts +2 -0
- package/dist/commands/api-command/export-command.d.ts.map +1 -0
- package/dist/commands/api-command/export-command.js +73 -0
- package/dist/commands/api-command/export-command.js.map +1 -0
- package/dist/commands/api-command/help.d.ts +3 -0
- package/dist/commands/api-command/help.d.ts.map +1 -0
- package/dist/commands/api-command/help.js +100 -0
- package/dist/commands/api-command/help.js.map +1 -0
- package/dist/commands/api-command/import-command.d.ts +2 -0
- package/dist/commands/api-command/import-command.d.ts.map +1 -0
- package/dist/commands/api-command/import-command.js +111 -0
- package/dist/commands/api-command/import-command.js.map +1 -0
- package/dist/commands/api-command/index.d.ts +3 -0
- package/dist/commands/api-command/index.d.ts.map +1 -0
- package/dist/commands/api-command/index.js +34 -0
- package/dist/commands/api-command/index.js.map +1 -0
- package/dist/commands/api-command/list-command.d.ts +2 -0
- package/dist/commands/api-command/list-command.d.ts.map +1 -0
- package/dist/commands/api-command/list-command.js +53 -0
- package/dist/commands/api-command/list-command.js.map +1 -0
- package/dist/commands/api-command/remove-command.d.ts +2 -0
- package/dist/commands/api-command/remove-command.d.ts.map +1 -0
- package/dist/commands/api-command/remove-command.js +63 -0
- package/dist/commands/api-command/remove-command.js.map +1 -0
- package/dist/commands/api-command/shared.d.ts +36 -0
- package/dist/commands/api-command/shared.d.ts.map +1 -0
- package/dist/commands/api-command/shared.js +164 -0
- package/dist/commands/api-command/shared.js.map +1 -0
- package/dist/commands/api-command.d.ts +1 -26
- package/dist/commands/api-command.d.ts.map +1 -1
- package/dist/commands/api-command.js +3 -807
- package/dist/commands/api-command.js.map +1 -1
- package/dist/commands/arg-extractor.d.ts +15 -0
- package/dist/commands/arg-extractor.d.ts.map +1 -1
- package/dist/commands/arg-extractor.js +48 -2
- package/dist/commands/arg-extractor.js.map +1 -1
- package/dist/commands/config-auth/index.d.ts.map +1 -1
- package/dist/commands/config-auth/index.js +35 -19
- package/dist/commands/config-auth/index.js.map +1 -1
- package/dist/commands/config-command-options.d.ts +14 -0
- package/dist/commands/config-command-options.d.ts.map +1 -0
- package/dist/commands/config-command-options.js +108 -0
- package/dist/commands/config-command-options.js.map +1 -0
- package/dist/commands/config-command.d.ts +1 -1
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/config-command.js +91 -104
- package/dist/commands/config-command.js.map +1 -1
- package/dist/commands/config-dashboard-host.d.ts +17 -0
- package/dist/commands/config-dashboard-host.d.ts.map +1 -0
- package/dist/commands/config-dashboard-host.js +99 -0
- package/dist/commands/config-dashboard-host.js.map +1 -0
- package/dist/commands/env-command.d.ts.map +1 -1
- package/dist/commands/env-command.js +5 -0
- package/dist/commands/env-command.js.map +1 -1
- package/dist/commands/help-command.js +1 -1
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/named-command-router.d.ts +17 -0
- package/dist/commands/named-command-router.d.ts.map +1 -0
- package/dist/commands/named-command-router.js +39 -0
- package/dist/commands/named-command-router.js.map +1 -0
- package/dist/commands/persist-command.js +1 -1
- package/dist/commands/persist-command.js.map +1 -1
- package/dist/commands/root-command-router.d.ts +2 -0
- package/dist/commands/root-command-router.d.ts.map +1 -0
- package/dist/commands/root-command-router.js +209 -0
- package/dist/commands/root-command-router.js.map +1 -0
- package/dist/config/unified-config-loader.js +1 -1
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/cursor/cursor-anthropic-response.d.ts +6 -0
- package/dist/cursor/cursor-anthropic-response.d.ts.map +1 -0
- package/dist/cursor/cursor-anthropic-response.js +190 -0
- package/dist/cursor/cursor-anthropic-response.js.map +1 -0
- package/dist/cursor/cursor-anthropic-translator.d.ts +11 -0
- package/dist/cursor/cursor-anthropic-translator.d.ts.map +1 -0
- package/dist/cursor/cursor-anthropic-translator.js +167 -0
- package/dist/cursor/cursor-anthropic-translator.js.map +1 -0
- package/dist/cursor/cursor-anthropic-types.d.ts +46 -0
- package/dist/cursor/cursor-anthropic-types.d.ts.map +1 -0
- package/dist/cursor/cursor-anthropic-types.js +3 -0
- package/dist/cursor/cursor-anthropic-types.js.map +1 -0
- package/dist/cursor/cursor-daemon-entry.d.ts.map +1 -1
- package/dist/cursor/cursor-daemon-entry.js +53 -24
- package/dist/cursor/cursor-daemon-entry.js.map +1 -1
- package/dist/cursor/cursor-models.d.ts.map +1 -1
- package/dist/cursor/cursor-models.js +36 -2
- package/dist/cursor/cursor-models.js.map +1 -1
- package/dist/glmt/glmt-proxy.d.ts +4 -3
- package/dist/glmt/glmt-proxy.d.ts.map +1 -1
- package/dist/glmt/glmt-proxy.js +4 -3
- package/dist/glmt/glmt-proxy.js.map +1 -1
- package/dist/glmt/sse-parser.d.ts +2 -0
- package/dist/glmt/sse-parser.d.ts.map +1 -1
- package/dist/glmt/sse-parser.js +4 -0
- package/dist/glmt/sse-parser.js.map +1 -1
- package/dist/management/instance-manager.d.ts +2 -1
- package/dist/management/instance-manager.d.ts.map +1 -1
- package/dist/management/instance-manager.js +23 -8
- package/dist/management/instance-manager.js.map +1 -1
- package/dist/management/profile-context-sync-lock.d.ts +3 -0
- package/dist/management/profile-context-sync-lock.d.ts.map +1 -1
- package/dist/management/profile-context-sync-lock.js +75 -3
- package/dist/management/profile-context-sync-lock.js.map +1 -1
- package/dist/management/recovery-manager.d.ts +2 -2
- package/dist/management/recovery-manager.js +2 -2
- package/dist/management/shared-manager.d.ts +31 -1
- package/dist/management/shared-manager.d.ts.map +1 -1
- package/dist/management/shared-manager.js +420 -23
- package/dist/management/shared-manager.js.map +1 -1
- package/dist/shared/claude-extension-setup.d.ts.map +1 -1
- package/dist/shared/claude-extension-setup.js +16 -2
- package/dist/shared/claude-extension-setup.js.map +1 -1
- package/dist/shared/provider-preset-catalog.d.ts +1 -1
- package/dist/shared/provider-preset-catalog.d.ts.map +1 -1
- package/dist/shared/provider-preset-catalog.js +34 -40
- package/dist/shared/provider-preset-catalog.js.map +1 -1
- package/dist/ui/assets/{accounts-CZEg1_PX.js → accounts-CxIwtPW5.js} +1 -1
- package/dist/ui/assets/{alert-dialog-DhwS38kc.js → alert-dialog-D0M-j0xk.js} +1 -1
- package/dist/ui/assets/{api-sWNND4wP.js → api-D_GvXEjg.js} +1 -1
- package/dist/ui/assets/{auth-section-nJIpOcnm.js → auth-section-DtxR8sof.js} +1 -1
- package/dist/ui/assets/{backups-section-D3A6hmrU.js → backups-section-DAPwVCGp.js} +1 -1
- package/dist/ui/assets/checkbox-D470Q1y9.js +1 -0
- package/dist/ui/assets/{claude-extension-BjInaILv.js → claude-extension-vRIHOe5q.js} +1 -1
- package/dist/ui/assets/cliproxy-DGsWe0cf.js +3 -0
- package/dist/ui/assets/{cliproxy-control-panel-CKO2Sn9B.js → cliproxy-control-panel-BoKpt64d.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-DTKxwrat.js → confirm-dialog-BnNUvB5u.js} +1 -1
- package/dist/ui/assets/copilot-DCkXk9mK.js +3 -0
- package/dist/ui/assets/cursor-9aQfYlGU.js +1 -0
- package/dist/ui/assets/{droid-Cl8QsJJL.js → droid-Bzp6uHqU.js} +2 -2
- package/dist/ui/assets/{globalenv-section-C3dxxoD9.js → globalenv-section-BM9oGUk_.js} +1 -1
- package/dist/ui/assets/{health-BUifaDU7.js → health-DLIgkfxF.js} +1 -1
- package/dist/ui/assets/icons-DtwH984l.js +1 -0
- package/dist/ui/assets/index-C-7tLTU2.js +47 -0
- package/dist/ui/assets/index-ClEn7Y7g.css +1 -0
- package/dist/ui/assets/{index-CPdceT1C.js → index-D9tmeP-H.js} +1 -1
- package/dist/ui/assets/{index-CYo-E5rU.js → index-DGQhzUIq.js} +1 -1
- package/dist/ui/assets/{index-BOsbrhaa.js → index-DimlYMhI.js} +1 -1
- package/dist/ui/assets/{index-xayyyR26.js → index-DykKl5b0.js} +1 -1
- package/dist/ui/assets/providers/llama-cpp.svg +5 -0
- package/dist/ui/assets/{proxy-status-widget-D94htBPb.js → proxy-status-widget-DloYg7yP.js} +1 -1
- package/dist/ui/assets/{radix-ui-BR1vy4kf.js → radix-ui-Dt3edmE5.js} +8 -8
- package/dist/ui/assets/searchable-select-CSREngvO.js +1 -0
- package/dist/ui/assets/{separator-3fBbTn-V.js → separator-DzrBeBn-.js} +1 -1
- package/dist/ui/assets/{shared-q_FNNbjD.js → shared-qRzQxB-N.js} +1 -1
- package/dist/ui/assets/{switch-5N8qBdBr.js → switch-BP9rnaI6.js} +1 -1
- package/dist/ui/assets/{tanstack-e99Cjjy2.js → tanstack-B8i0evp-.js} +1 -1
- package/dist/ui/assets/{updates-CubQ54J0.js → updates-BQvHbU9s.js} +1 -1
- package/dist/ui/icons/novita.svg +9 -0
- package/dist/ui/index.html +5 -5
- package/dist/utils/config-manager.d.ts +1 -1
- package/dist/utils/config-manager.js +1 -1
- package/dist/utils/fetch-proxy-setup.d.ts.map +1 -1
- package/dist/utils/fetch-proxy-setup.js.map +1 -1
- package/dist/utils/glmt-deprecation.d.ts +11 -0
- package/dist/utils/glmt-deprecation.d.ts.map +1 -0
- package/dist/utils/glmt-deprecation.js +64 -0
- package/dist/utils/glmt-deprecation.js.map +1 -0
- package/dist/utils/shell-executor.d.ts.map +1 -1
- package/dist/utils/shell-executor.js +12 -0
- package/dist/utils/shell-executor.js.map +1 -1
- package/dist/web-server/index.d.ts +1 -0
- package/dist/web-server/index.d.ts.map +1 -1
- package/dist/web-server/index.js +39 -3
- package/dist/web-server/index.js.map +1 -1
- package/dist/web-server/routes/account-routes.js +2 -2
- package/dist/web-server/routes/account-routes.js.map +1 -1
- package/dist/web-server/routes/profile-routes.d.ts +1 -0
- package/dist/web-server/routes/profile-routes.d.ts.map +1 -1
- package/dist/web-server/routes/profile-routes.js +3 -0
- package/dist/web-server/routes/profile-routes.js.map +1 -1
- package/dist/web-server/routes/variant-routes.d.ts +1 -0
- package/dist/web-server/routes/variant-routes.d.ts.map +1 -1
- package/dist/web-server/routes/variant-routes.js +3 -0
- package/dist/web-server/routes/variant-routes.js.map +1 -1
- package/package.json +3 -2
- package/scripts/completion/README.md +1 -1
- package/scripts/completion/ccs.fish +1 -2
- package/scripts/completion/ccs.zsh +1 -2
- package/scripts/postinstall.js +3 -3
- package/dist/ui/assets/checkbox-CZrxD1iS.js +0 -1
- package/dist/ui/assets/cliproxy-BGiSCGkl.js +0 -3
- package/dist/ui/assets/copilot-CuRngdBg.js +0 -3
- package/dist/ui/assets/cursor-Dxo0uIiU.js +0 -1
- package/dist/ui/assets/icons-DrEfTmfX.js +0 -1
- package/dist/ui/assets/index-Btf_ow2V.css +0 -1
- package/dist/ui/assets/index-Cw9Urr0S.js +0 -47
package/dist/ccs.js
CHANGED
|
@@ -25,8 +25,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
require("./utils/fetch-proxy-setup");
|
|
28
|
-
const child_process_1 = require("child_process");
|
|
29
|
-
const path = __importStar(require("path"));
|
|
30
28
|
const fs = __importStar(require("fs"));
|
|
31
29
|
const claude_detector_1 = require("./utils/claude-detector");
|
|
32
30
|
const config_manager_1 = require("./utils/config-manager");
|
|
@@ -44,17 +42,10 @@ const ui_1 = require("./utils/ui");
|
|
|
44
42
|
const constants_1 = require("./copilot/constants");
|
|
45
43
|
// Import centralized error handling
|
|
46
44
|
const errors_1 = require("./errors");
|
|
47
|
-
|
|
48
|
-
const version_command_1 = require("./commands/version-command");
|
|
49
|
-
const help_command_1 = require("./commands/help-command");
|
|
50
|
-
const install_command_1 = require("./commands/install-command");
|
|
51
|
-
const doctor_command_1 = require("./commands/doctor-command");
|
|
52
|
-
const sync_command_1 = require("./commands/sync-command");
|
|
53
|
-
const shell_completion_command_1 = require("./commands/shell-completion-command");
|
|
54
|
-
const update_command_1 = require("./commands/update-command");
|
|
45
|
+
const root_command_router_1 = require("./commands/root-command-router");
|
|
55
46
|
// Import extracted utility functions
|
|
56
47
|
const shell_executor_1 = require("./utils/shell-executor");
|
|
57
|
-
const
|
|
48
|
+
const glmt_deprecation_1 = require("./utils/glmt-deprecation");
|
|
58
49
|
// Import target adapter system
|
|
59
50
|
const targets_1 = require("./targets");
|
|
60
51
|
const target_resolver_1 = require("./targets/target-resolver");
|
|
@@ -76,177 +67,6 @@ function detectProfile(args) {
|
|
|
76
67
|
return { profile: args[0], remainingArgs: args.slice(1) };
|
|
77
68
|
}
|
|
78
69
|
}
|
|
79
|
-
// ========== GLMT Proxy Execution ==========
|
|
80
|
-
/**
|
|
81
|
-
* Execute Claude CLI with embedded proxy (for GLMT profile)
|
|
82
|
-
*/
|
|
83
|
-
async function execClaudeWithProxy(claudeCli, profileName, args, claudeConfigDir) {
|
|
84
|
-
// 1. Read settings to get API key
|
|
85
|
-
const settingsPath = (0, config_manager_1.getSettingsPath)(profileName);
|
|
86
|
-
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
87
|
-
const envData = settings.env;
|
|
88
|
-
const apiKey = envData['ANTHROPIC_AUTH_TOKEN'];
|
|
89
|
-
if (!apiKey || apiKey === 'YOUR_GLM_API_KEY_HERE') {
|
|
90
|
-
console.error((0, ui_1.fail)('GLMT profile requires Z.AI API key'));
|
|
91
|
-
console.error(` Edit ${(0, config_manager_1.getCcsDir)()}/glmt.settings.json and set ANTHROPIC_AUTH_TOKEN`);
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
// Detect verbose flag
|
|
95
|
-
const verbose = args.includes('--verbose') || args.includes('-v');
|
|
96
|
-
// 2. Spawn embedded proxy with verbose flag
|
|
97
|
-
const proxyPath = path.join(__dirname, 'glmt', 'glmt-proxy.js');
|
|
98
|
-
const proxyArgs = verbose ? ['--verbose'] : [];
|
|
99
|
-
// Use process.execPath for Windows compatibility (CVE-2024-27980)
|
|
100
|
-
// Pass environment variables to proxy subprocess (required for auth)
|
|
101
|
-
const proxy = (0, child_process_1.spawn)(process.execPath, [proxyPath, ...proxyArgs], {
|
|
102
|
-
stdio: ['ignore', 'pipe', verbose ? 'pipe' : 'inherit'],
|
|
103
|
-
env: {
|
|
104
|
-
...process.env,
|
|
105
|
-
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
106
|
-
ANTHROPIC_BASE_URL: envData['ANTHROPIC_BASE_URL'],
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
const stopProxy = () => {
|
|
110
|
-
try {
|
|
111
|
-
if (!proxy.killed) {
|
|
112
|
-
proxy.kill('SIGTERM');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
// Best-effort cleanup on process teardown.
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
// 3. Wait for proxy ready signal (with timeout)
|
|
120
|
-
const { ProgressIndicator } = await Promise.resolve().then(() => __importStar(require('./utils/progress-indicator')));
|
|
121
|
-
const spinner = new ProgressIndicator('Starting GLMT proxy');
|
|
122
|
-
spinner.start();
|
|
123
|
-
let port;
|
|
124
|
-
try {
|
|
125
|
-
port = await new Promise((resolve, reject) => {
|
|
126
|
-
const timeout = setTimeout(() => {
|
|
127
|
-
reject(new Error('Proxy startup timeout (5s)'));
|
|
128
|
-
}, 5000);
|
|
129
|
-
proxy.stdout?.on('data', (data) => {
|
|
130
|
-
const match = data.toString().match(/PROXY_READY:(\d+)/);
|
|
131
|
-
if (match) {
|
|
132
|
-
clearTimeout(timeout);
|
|
133
|
-
resolve(parseInt(match[1]));
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
proxy.on('error', (error) => {
|
|
137
|
-
clearTimeout(timeout);
|
|
138
|
-
reject(error);
|
|
139
|
-
});
|
|
140
|
-
proxy.on('exit', (code) => {
|
|
141
|
-
if (code !== 0 && code !== null) {
|
|
142
|
-
clearTimeout(timeout);
|
|
143
|
-
reject(new Error(`Proxy exited with code ${code}`));
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
spinner.succeed(`GLMT proxy ready on port ${port}`);
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
const err = error;
|
|
151
|
-
spinner.fail('Failed to start GLMT proxy');
|
|
152
|
-
console.error((0, ui_1.fail)(`Error: ${err.message}`));
|
|
153
|
-
console.error('');
|
|
154
|
-
console.error('Possible causes:');
|
|
155
|
-
console.error(' 1. Port conflict (unlikely with random port)');
|
|
156
|
-
console.error(' 2. Node.js permission issue');
|
|
157
|
-
console.error(' 3. Firewall blocking localhost');
|
|
158
|
-
console.error('');
|
|
159
|
-
console.error('Workarounds:');
|
|
160
|
-
console.error(' - Use non-thinking mode: ccs glm "prompt"');
|
|
161
|
-
console.error(' - Enable verbose logging: ccs glmt --verbose "prompt"');
|
|
162
|
-
console.error(` - Check proxy logs in ${(0, config_manager_1.getCcsDir)()}/logs/ (if debug enabled)`);
|
|
163
|
-
console.error('');
|
|
164
|
-
stopProxy();
|
|
165
|
-
(0, errors_1.runCleanup)();
|
|
166
|
-
process.exit(1);
|
|
167
|
-
}
|
|
168
|
-
// 4. Spawn Claude CLI with proxy URL
|
|
169
|
-
// Use model from user's settings (not hardcoded) - fixes issue #358
|
|
170
|
-
const configuredModel = envData['ANTHROPIC_MODEL'] || 'glm-5';
|
|
171
|
-
const envVars = {
|
|
172
|
-
ANTHROPIC_BASE_URL: `http://127.0.0.1:${port}`,
|
|
173
|
-
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
174
|
-
ANTHROPIC_MODEL: configuredModel,
|
|
175
|
-
...(claudeConfigDir ? { CLAUDE_CONFIG_DIR: claudeConfigDir } : {}),
|
|
176
|
-
};
|
|
177
|
-
const isWindows = process.platform === 'win32';
|
|
178
|
-
const isPowerShellScript = isWindows && /\.ps1$/i.test(claudeCli);
|
|
179
|
-
const needsShell = isWindows && /\.(cmd|bat)$/i.test(claudeCli);
|
|
180
|
-
const webSearchEnv = (0, websearch_manager_1.getWebSearchHookEnv)();
|
|
181
|
-
const imageAnalysisEnv = (0, hooks_1.getImageAnalysisHookEnv)(profileName);
|
|
182
|
-
const claudeLaunchEnv = (0, shell_executor_1.getClaudeLaunchEnvOverrides)();
|
|
183
|
-
const env = (0, shell_executor_1.stripClaudeCodeEnv)({
|
|
184
|
-
...process.env,
|
|
185
|
-
...claudeLaunchEnv,
|
|
186
|
-
...envVars,
|
|
187
|
-
...webSearchEnv,
|
|
188
|
-
...imageAnalysisEnv,
|
|
189
|
-
CCS_PROFILE_TYPE: 'settings', // Signal to WebSearch hook this is a third-party provider
|
|
190
|
-
});
|
|
191
|
-
let claude;
|
|
192
|
-
if (isPowerShellScript) {
|
|
193
|
-
claude = (0, child_process_1.spawn)('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', claudeCli, ...args], {
|
|
194
|
-
stdio: 'inherit',
|
|
195
|
-
windowsHide: true,
|
|
196
|
-
env,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
else if (needsShell) {
|
|
200
|
-
const cmdString = [claudeCli, ...args].map(shell_executor_1.escapeShellArg).join(' ');
|
|
201
|
-
claude = (0, child_process_1.spawn)(cmdString, {
|
|
202
|
-
stdio: 'inherit',
|
|
203
|
-
windowsHide: true,
|
|
204
|
-
shell: true,
|
|
205
|
-
env,
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
claude = (0, child_process_1.spawn)(claudeCli, args, {
|
|
210
|
-
stdio: 'inherit',
|
|
211
|
-
windowsHide: true,
|
|
212
|
-
env,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
// 5. Shared signal forwarding + proxy cleanup lifecycle
|
|
216
|
-
(0, signal_forwarder_1.wireChildProcessSignals)(claude, (err) => {
|
|
217
|
-
if (err.code === 'EACCES') {
|
|
218
|
-
console.error((0, ui_1.fail)(`Claude CLI is not executable: ${claudeCli}`));
|
|
219
|
-
console.error(' Check file permissions and executable bit.');
|
|
220
|
-
}
|
|
221
|
-
else if (err.code === 'ENOENT') {
|
|
222
|
-
if (isPowerShellScript) {
|
|
223
|
-
console.error((0, ui_1.fail)('PowerShell executable not found (required for .ps1 wrapper launch).'));
|
|
224
|
-
console.error(' Ensure powershell.exe is available in PATH.');
|
|
225
|
-
}
|
|
226
|
-
else if (needsShell) {
|
|
227
|
-
console.error((0, ui_1.fail)('Windows command shell not found for Claude wrapper launch.'));
|
|
228
|
-
console.error(' Ensure cmd.exe is available and accessible.');
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
console.error((0, ui_1.fail)(`Claude CLI not found: ${claudeCli}`));
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
console.error((0, ui_1.fail)(`Claude CLI error: ${err.message}`));
|
|
236
|
-
}
|
|
237
|
-
stopProxy();
|
|
238
|
-
(0, errors_1.runCleanup)();
|
|
239
|
-
process.exit(1);
|
|
240
|
-
}, (code, signal) => {
|
|
241
|
-
stopProxy();
|
|
242
|
-
if (signal) {
|
|
243
|
-
process.kill(process.pid, signal);
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
process.exit(code || 0);
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
70
|
/**
|
|
251
71
|
* Perform background update check (refreshes cache, no notification)
|
|
252
72
|
*/
|
|
@@ -391,110 +211,7 @@ async function main() {
|
|
|
391
211
|
// Recovery is best-effort - don't block basic CLI functionality
|
|
392
212
|
console.warn('[!] Recovery failed:', err.message);
|
|
393
213
|
}
|
|
394
|
-
|
|
395
|
-
if (firstArg === 'migrate' || firstArg === '--migrate') {
|
|
396
|
-
const { handleMigrateCommand, printMigrateHelp } = await Promise.resolve().then(() => __importStar(require('./commands/migrate-command')));
|
|
397
|
-
const migrateArgs = args.slice(1);
|
|
398
|
-
if (migrateArgs.includes('--help') || migrateArgs.includes('-h')) {
|
|
399
|
-
printMigrateHelp();
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
await handleMigrateCommand(migrateArgs);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
// Special case: update command
|
|
406
|
-
if (firstArg === 'update' || firstArg === '--update') {
|
|
407
|
-
const updateArgs = args.slice(1);
|
|
408
|
-
// Handle --help for update command
|
|
409
|
-
if (updateArgs.includes('--help') || updateArgs.includes('-h')) {
|
|
410
|
-
console.log('');
|
|
411
|
-
console.log('Usage: ccs update [options]');
|
|
412
|
-
console.log('');
|
|
413
|
-
console.log('Options:');
|
|
414
|
-
console.log(' --force Force reinstall current version');
|
|
415
|
-
console.log(' --beta, --dev Install from dev channel (unstable)');
|
|
416
|
-
console.log(' --help, -h Show this help message');
|
|
417
|
-
console.log('');
|
|
418
|
-
console.log('Examples:');
|
|
419
|
-
console.log(' ccs update Update to latest stable');
|
|
420
|
-
console.log(' ccs update --force Force reinstall');
|
|
421
|
-
console.log(' ccs update --beta Install dev channel');
|
|
422
|
-
console.log('');
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
const forceFlag = updateArgs.includes('--force');
|
|
426
|
-
const betaFlag = updateArgs.includes('--beta') || updateArgs.includes('--dev');
|
|
427
|
-
await (0, update_command_1.handleUpdateCommand)({ force: forceFlag, beta: betaFlag });
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
const commandAliases = {
|
|
431
|
-
'--version': 'version',
|
|
432
|
-
'-v': 'version',
|
|
433
|
-
'--help': 'help',
|
|
434
|
-
'-h': 'help',
|
|
435
|
-
'--doctor': 'doctor',
|
|
436
|
-
'--sync': 'sync',
|
|
437
|
-
'--cleanup': 'cleanup',
|
|
438
|
-
'--setup': 'setup',
|
|
439
|
-
};
|
|
440
|
-
const normalizedFirstArg = commandAliases[firstArg] || firstArg;
|
|
441
|
-
const earlyCommandHandlers = {
|
|
442
|
-
version: async () => (0, version_command_1.handleVersionCommand)(),
|
|
443
|
-
help: async () => (0, help_command_1.handleHelpCommand)(),
|
|
444
|
-
'--install': async () => (0, install_command_1.handleInstallCommand)(),
|
|
445
|
-
'--uninstall': async () => (0, install_command_1.handleUninstallCommand)(),
|
|
446
|
-
'--shell-completion': async () => (0, shell_completion_command_1.handleShellCompletionCommand)(args.slice(1)),
|
|
447
|
-
'-sc': async () => (0, shell_completion_command_1.handleShellCompletionCommand)(args.slice(1)),
|
|
448
|
-
doctor: async () => (0, doctor_command_1.handleDoctorCommand)(args.slice(1)),
|
|
449
|
-
sync: async () => (0, sync_command_1.handleSyncCommand)(),
|
|
450
|
-
cleanup: async () => {
|
|
451
|
-
const { handleCleanupCommand } = await Promise.resolve().then(() => __importStar(require('./commands/cleanup-command')));
|
|
452
|
-
await handleCleanupCommand(args.slice(1));
|
|
453
|
-
},
|
|
454
|
-
auth: async () => {
|
|
455
|
-
const AuthCommandsModule = await Promise.resolve().then(() => __importStar(require('./auth/auth-commands')));
|
|
456
|
-
const AuthCommands = AuthCommandsModule.default;
|
|
457
|
-
const authCommands = new AuthCommands();
|
|
458
|
-
await authCommands.route(args.slice(1));
|
|
459
|
-
},
|
|
460
|
-
api: async () => {
|
|
461
|
-
const { handleApiCommand } = await Promise.resolve().then(() => __importStar(require('./commands/api-command')));
|
|
462
|
-
await handleApiCommand(args.slice(1));
|
|
463
|
-
},
|
|
464
|
-
cliproxy: async () => {
|
|
465
|
-
const { handleCliproxyCommand } = await Promise.resolve().then(() => __importStar(require('./commands/cliproxy-command')));
|
|
466
|
-
await handleCliproxyCommand(args.slice(1));
|
|
467
|
-
},
|
|
468
|
-
config: async () => {
|
|
469
|
-
const { handleConfigCommand } = await Promise.resolve().then(() => __importStar(require('./commands/config-command')));
|
|
470
|
-
await handleConfigCommand(args.slice(1));
|
|
471
|
-
},
|
|
472
|
-
tokens: async () => {
|
|
473
|
-
const { handleTokensCommand } = await Promise.resolve().then(() => __importStar(require('./commands/tokens-command')));
|
|
474
|
-
const exitCode = await handleTokensCommand(args.slice(1));
|
|
475
|
-
process.exit(exitCode);
|
|
476
|
-
},
|
|
477
|
-
persist: async () => {
|
|
478
|
-
const { handlePersistCommand } = await Promise.resolve().then(() => __importStar(require('./commands/persist-command')));
|
|
479
|
-
await handlePersistCommand(args.slice(1));
|
|
480
|
-
},
|
|
481
|
-
env: async () => {
|
|
482
|
-
const { handleEnvCommand } = await Promise.resolve().then(() => __importStar(require('./commands/env-command')));
|
|
483
|
-
await handleEnvCommand(args.slice(1));
|
|
484
|
-
},
|
|
485
|
-
setup: async () => {
|
|
486
|
-
const { handleSetupCommand } = await Promise.resolve().then(() => __importStar(require('./commands/setup-command')));
|
|
487
|
-
await handleSetupCommand(args.slice(1));
|
|
488
|
-
},
|
|
489
|
-
cursor: async () => {
|
|
490
|
-
const { handleCursorCommand } = await Promise.resolve().then(() => __importStar(require('./commands/cursor-command')));
|
|
491
|
-
const exitCode = await handleCursorCommand(args.slice(1));
|
|
492
|
-
process.exit(exitCode);
|
|
493
|
-
},
|
|
494
|
-
};
|
|
495
|
-
const earlyCommandHandler = earlyCommandHandlers[normalizedFirstArg];
|
|
496
|
-
if (earlyCommandHandler) {
|
|
497
|
-
await earlyCommandHandler();
|
|
214
|
+
if (await (0, root_command_router_1.tryHandleRootCommand)(args)) {
|
|
498
215
|
return;
|
|
499
216
|
}
|
|
500
217
|
// Special case: copilot command (GitHub Copilot integration)
|
|
@@ -574,12 +291,6 @@ async function main() {
|
|
|
574
291
|
console.error((0, ui_1.info)('Use a settings-based profile with --target instead'));
|
|
575
292
|
process.exit(1);
|
|
576
293
|
}
|
|
577
|
-
// GLMT always requires Claude target because it depends on embedded proxy flow.
|
|
578
|
-
if (profileInfo.type === 'settings' && profileInfo.name === 'glmt') {
|
|
579
|
-
console.error((0, ui_1.fail)(`${targetAdapter.displayName} does not support GLMT proxy profiles`));
|
|
580
|
-
console.error((0, ui_1.info)('Use --target claude for glmt, or switch to a direct API profile (glm/km)'));
|
|
581
|
-
process.exit(1);
|
|
582
|
-
}
|
|
583
294
|
if (profileInfo.type === 'default') {
|
|
584
295
|
if (!targetAdapter.supportsProfileType('default')) {
|
|
585
296
|
console.error((0, ui_1.fail)(`${targetAdapter.displayName} does not support default profile mode`));
|
|
@@ -826,13 +537,26 @@ async function main() {
|
|
|
826
537
|
console.error((0, ui_1.info)(`Continuity inheritance active: profile "${profileInfo.name}" -> account "${continuityInheritance.sourceAccount}"`));
|
|
827
538
|
}
|
|
828
539
|
const inheritedClaudeConfigDir = continuityInheritance.claudeConfigDir;
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
540
|
+
const expandedSettingsPath = profileInfo.settingsPath
|
|
541
|
+
? (0, helpers_1.expandPath)(profileInfo.settingsPath)
|
|
542
|
+
: (0, config_manager_1.getSettingsPath)(profileInfo.name);
|
|
543
|
+
const settings = (0, config_manager_1.loadSettings)(expandedSettingsPath);
|
|
544
|
+
const rawSettingsEnv = profileInfo.env ?? settings.env ?? {};
|
|
545
|
+
const isDeprecatedGlmtProfile = (0, glmt_deprecation_1.isDeprecatedGlmtProfileName)(profileInfo.name);
|
|
546
|
+
const glmtNormalization = isDeprecatedGlmtProfile
|
|
547
|
+
? (0, glmt_deprecation_1.normalizeDeprecatedGlmtEnv)(rawSettingsEnv)
|
|
548
|
+
: null;
|
|
549
|
+
const settingsEnv = glmtNormalization?.env ?? rawSettingsEnv;
|
|
550
|
+
if (glmtNormalization) {
|
|
551
|
+
for (const message of glmtNormalization.warnings) {
|
|
552
|
+
console.error((0, ui_1.warn)(message));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
// Pre-flight validation for Z.AI-compatible profiles.
|
|
556
|
+
if (profileInfo.name === 'glm' || isDeprecatedGlmtProfile) {
|
|
557
|
+
const apiKey = settingsEnv['ANTHROPIC_AUTH_TOKEN'];
|
|
834
558
|
if (apiKey) {
|
|
835
|
-
const validation = await (0, api_key_validator_1.validateGlmKey)(apiKey,
|
|
559
|
+
const validation = await (0, api_key_validator_1.validateGlmKey)(apiKey, settingsEnv['ANTHROPIC_BASE_URL']);
|
|
836
560
|
if (!validation.valid) {
|
|
837
561
|
console.error('');
|
|
838
562
|
console.error((0, ui_1.fail)(validation.error || 'API key validation failed'));
|
|
@@ -847,11 +571,9 @@ async function main() {
|
|
|
847
571
|
}
|
|
848
572
|
}
|
|
849
573
|
if (profileInfo.name === 'mm') {
|
|
850
|
-
const
|
|
851
|
-
const preflightSettings = (0, config_manager_1.loadSettings)(preflightSettingsPath);
|
|
852
|
-
const apiKey = preflightSettings.env?.['ANTHROPIC_AUTH_TOKEN'];
|
|
574
|
+
const apiKey = settingsEnv['ANTHROPIC_AUTH_TOKEN'];
|
|
853
575
|
if (apiKey) {
|
|
854
|
-
const validation = await (0, api_key_validator_1.validateMiniMaxKey)(apiKey,
|
|
576
|
+
const validation = await (0, api_key_validator_1.validateMiniMaxKey)(apiKey, settingsEnv['ANTHROPIC_BASE_URL']);
|
|
855
577
|
if (!validation.valid) {
|
|
856
578
|
console.error('');
|
|
857
579
|
console.error((0, ui_1.fail)(validation.error || 'API key validation failed'));
|
|
@@ -867,10 +589,8 @@ async function main() {
|
|
|
867
589
|
}
|
|
868
590
|
// Pre-flight validation for Anthropic direct profiles (ANTHROPIC_API_KEY + no BASE_URL)
|
|
869
591
|
{
|
|
870
|
-
const
|
|
871
|
-
const
|
|
872
|
-
const anthropicApiKey = preflightSettings.env?.['ANTHROPIC_API_KEY'];
|
|
873
|
-
const hasBaseUrl = !!preflightSettings.env?.['ANTHROPIC_BASE_URL'];
|
|
592
|
+
const anthropicApiKey = settingsEnv['ANTHROPIC_API_KEY'];
|
|
593
|
+
const hasBaseUrl = !!settingsEnv['ANTHROPIC_BASE_URL'];
|
|
874
594
|
if (anthropicApiKey && !hasBaseUrl) {
|
|
875
595
|
const validation = await (0, api_key_validator_1.validateAnthropicKey)(anthropicApiKey);
|
|
876
596
|
if (!validation.valid) {
|
|
@@ -886,75 +606,55 @@ async function main() {
|
|
|
886
606
|
}
|
|
887
607
|
}
|
|
888
608
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
609
|
+
const webSearchEnv = (0, websearch_manager_1.getWebSearchHookEnv)();
|
|
610
|
+
const imageAnalysisEnv = (0, hooks_1.getImageAnalysisHookEnv)(profileInfo.name);
|
|
611
|
+
// Get global env vars (DISABLE_TELEMETRY, etc.) for third-party profiles
|
|
612
|
+
const globalEnvConfig = (0, unified_config_loader_1.getGlobalEnvConfig)();
|
|
613
|
+
const globalEnv = globalEnvConfig.enabled ? globalEnvConfig.env : {};
|
|
614
|
+
// Log global env injection for visibility (debug mode only)
|
|
615
|
+
if (globalEnvConfig.enabled && Object.keys(globalEnv).length > 0 && process.env.CCS_DEBUG) {
|
|
616
|
+
const envNames = Object.keys(globalEnv).join(', ');
|
|
617
|
+
console.error((0, ui_1.info)(`Global env: ${envNames}`));
|
|
898
618
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
console.error((0, ui_1.
|
|
619
|
+
// Explicitly inject effective settings env vars so stale ANTHROPIC_*
|
|
620
|
+
// values from prior sessions cannot leak into the active profile.
|
|
621
|
+
const envVars = {
|
|
622
|
+
...globalEnv,
|
|
623
|
+
...settingsEnv,
|
|
624
|
+
...(inheritedClaudeConfigDir ? { CLAUDE_CONFIG_DIR: inheritedClaudeConfigDir } : {}),
|
|
625
|
+
...webSearchEnv,
|
|
626
|
+
...imageAnalysisEnv,
|
|
627
|
+
CCS_PROFILE_TYPE: 'settings',
|
|
628
|
+
};
|
|
629
|
+
// Dispatch through target adapter for non-claude targets
|
|
630
|
+
if (resolvedTarget !== 'claude') {
|
|
631
|
+
const adapter = targetAdapter;
|
|
632
|
+
if (!adapter) {
|
|
633
|
+
console.error((0, ui_1.fail)(`Target adapter not found for "${resolvedTarget}"`));
|
|
634
|
+
process.exit(1);
|
|
914
635
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
...(inheritedClaudeConfigDir ? { CLAUDE_CONFIG_DIR: inheritedClaudeConfigDir } : {}),
|
|
925
|
-
...webSearchEnv,
|
|
926
|
-
...imageAnalysisEnv,
|
|
927
|
-
CCS_PROFILE_TYPE: 'settings', // Signal to WebSearch hook this is a third-party provider
|
|
928
|
-
};
|
|
929
|
-
// Dispatch through target adapter for non-claude targets
|
|
930
|
-
if (resolvedTarget !== 'claude') {
|
|
931
|
-
const adapter = targetAdapter;
|
|
932
|
-
if (!adapter) {
|
|
933
|
-
console.error((0, ui_1.fail)(`Target adapter not found for "${resolvedTarget}"`));
|
|
934
|
-
process.exit(1);
|
|
935
|
-
}
|
|
936
|
-
const directAnthropicBaseUrl = settingsEnv['ANTHROPIC_BASE_URL'] ||
|
|
937
|
-
(settingsEnv['ANTHROPIC_API_KEY'] ? 'https://api.anthropic.com' : '');
|
|
938
|
-
const creds = {
|
|
939
|
-
profile: profileInfo.name,
|
|
636
|
+
const directAnthropicBaseUrl = settingsEnv['ANTHROPIC_BASE_URL'] ||
|
|
637
|
+
(settingsEnv['ANTHROPIC_API_KEY'] ? 'https://api.anthropic.com' : '');
|
|
638
|
+
const creds = {
|
|
639
|
+
profile: profileInfo.name,
|
|
640
|
+
baseUrl: directAnthropicBaseUrl,
|
|
641
|
+
apiKey: settingsEnv['ANTHROPIC_AUTH_TOKEN'] || settingsEnv['ANTHROPIC_API_KEY'] || '',
|
|
642
|
+
model: settingsEnv['ANTHROPIC_MODEL'],
|
|
643
|
+
provider: (0, targets_1.resolveDroidProvider)({
|
|
644
|
+
provider: settingsEnv['CCS_DROID_PROVIDER'] || settingsEnv['DROID_PROVIDER'],
|
|
940
645
|
baseUrl: directAnthropicBaseUrl,
|
|
941
|
-
apiKey: settingsEnv['ANTHROPIC_AUTH_TOKEN'] || settingsEnv['ANTHROPIC_API_KEY'] || '',
|
|
942
646
|
model: settingsEnv['ANTHROPIC_MODEL'],
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
const targetEnv = adapter.buildEnv(creds, profileInfo.type);
|
|
953
|
-
adapter.exec(targetArgs, targetEnv, { binaryInfo: targetBinaryInfo || undefined });
|
|
954
|
-
return;
|
|
955
|
-
}
|
|
956
|
-
(0, shell_executor_1.execClaude)(claudeCli, ['--settings', expandedSettingsPath, ...remainingArgs], envVars);
|
|
647
|
+
}),
|
|
648
|
+
reasoningOverride: droidReasoningOverride,
|
|
649
|
+
envVars,
|
|
650
|
+
};
|
|
651
|
+
await adapter.prepareCredentials(creds);
|
|
652
|
+
const targetArgs = adapter.buildArgs(profileInfo.name, targetRemainingArgs);
|
|
653
|
+
const targetEnv = adapter.buildEnv(creds, profileInfo.type);
|
|
654
|
+
adapter.exec(targetArgs, targetEnv, { binaryInfo: targetBinaryInfo || undefined });
|
|
655
|
+
return;
|
|
957
656
|
}
|
|
657
|
+
(0, shell_executor_1.execClaude)(claudeCli, ['--settings', expandedSettingsPath, ...remainingArgs], envVars);
|
|
958
658
|
}
|
|
959
659
|
else if (profileInfo.type === 'account') {
|
|
960
660
|
// NEW FLOW: Account-based profile (work, personal)
|