@kaitranntt/ccs 7.47.0 → 7.48.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 +3 -3
- package/config/base-codex.settings.json +4 -4
- package/dist/ccs.js +68 -97
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/env-builder.js +77 -15
- package/dist/cliproxy/config/env-builder.js.map +1 -1
- package/dist/cliproxy/config/extended-context-config.d.ts +1 -8
- package/dist/cliproxy/config/extended-context-config.d.ts.map +1 -1
- package/dist/cliproxy/config/extended-context-config.js +8 -24
- package/dist/cliproxy/config/extended-context-config.js.map +1 -1
- package/dist/cliproxy/config/generator.d.ts +3 -1
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.js +210 -39
- package/dist/cliproxy/config/generator.js.map +1 -1
- package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
- package/dist/cliproxy/config/thinking-config.js +15 -4
- package/dist/cliproxy/config/thinking-config.js.map +1 -1
- package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.js +38 -2
- package/dist/cliproxy/executor/env-resolver.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +7 -4
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/executor/retry-handler.d.ts +1 -1
- package/dist/cliproxy/executor/retry-handler.js +2 -2
- package/dist/cliproxy/executor/retry-handler.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 +12 -3
- package/dist/cliproxy/index.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +6 -1
- 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 +6 -6
- package/dist/cliproxy/model-config.js.map +1 -1
- package/dist/cliproxy/model-id-normalizer.d.ts +70 -0
- package/dist/cliproxy/model-id-normalizer.d.ts.map +1 -0
- package/dist/cliproxy/model-id-normalizer.js +120 -0
- package/dist/cliproxy/model-id-normalizer.js.map +1 -0
- package/dist/cliproxy/provider-capabilities.d.ts +6 -0
- package/dist/cliproxy/provider-capabilities.d.ts.map +1 -1
- package/dist/cliproxy/provider-capabilities.js +24 -2
- package/dist/cliproxy/provider-capabilities.js.map +1 -1
- package/dist/cliproxy/quota-fetcher-claude-normalizer.d.ts +18 -0
- package/dist/cliproxy/quota-fetcher-claude-normalizer.d.ts.map +1 -0
- package/dist/cliproxy/quota-fetcher-claude-normalizer.js +291 -0
- package/dist/cliproxy/quota-fetcher-claude-normalizer.js.map +1 -0
- package/dist/cliproxy/quota-fetcher-claude.d.ts +21 -0
- package/dist/cliproxy/quota-fetcher-claude.d.ts.map +1 -0
- package/dist/cliproxy/quota-fetcher-claude.js +263 -0
- package/dist/cliproxy/quota-fetcher-claude.js.map +1 -0
- package/dist/cliproxy/quota-manager.d.ts +7 -4
- package/dist/cliproxy/quota-manager.d.ts.map +1 -1
- package/dist/cliproxy/quota-manager.js +80 -21
- package/dist/cliproxy/quota-manager.js.map +1 -1
- package/dist/cliproxy/quota-types.d.ts +74 -2
- package/dist/cliproxy/quota-types.d.ts.map +1 -1
- package/dist/cliproxy/quota-types.js +1 -1
- package/dist/cliproxy/remote-proxy-client.d.ts +3 -10
- package/dist/cliproxy/remote-proxy-client.d.ts.map +1 -1
- package/dist/cliproxy/remote-proxy-client.js +32 -29
- package/dist/cliproxy/remote-proxy-client.js.map +1 -1
- package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-settings.js +12 -13
- package/dist/cliproxy/services/variant-settings.js.map +1 -1
- package/dist/cliproxy/tool-sanitization-proxy.d.ts.map +1 -1
- package/dist/cliproxy/tool-sanitization-proxy.js +15 -5
- package/dist/cliproxy/tool-sanitization-proxy.js.map +1 -1
- package/dist/cliproxy/types.d.ts +1 -1
- package/dist/cliproxy/types.d.ts.map +1 -1
- package/dist/commands/api-command.d.ts +13 -0
- package/dist/commands/api-command.d.ts.map +1 -1
- package/dist/commands/api-command.js +85 -24
- package/dist/commands/api-command.js.map +1 -1
- package/dist/commands/arg-extractor.d.ts +29 -0
- package/dist/commands/arg-extractor.d.ts.map +1 -0
- package/dist/commands/arg-extractor.js +81 -0
- package/dist/commands/arg-extractor.js.map +1 -0
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.js +3 -2
- package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/index.d.ts +13 -0
- package/dist/commands/cliproxy/index.d.ts.map +1 -1
- package/dist/commands/cliproxy/index.js +66 -126
- package/dist/commands/cliproxy/index.js.map +1 -1
- package/dist/commands/cliproxy/quota-subcommand.d.ts +2 -1
- package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/quota-subcommand.js +172 -46
- package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/config-command.js +17 -16
- package/dist/commands/config-command.js.map +1 -1
- package/dist/commands/config-image-analysis-command.d.ts.map +1 -1
- package/dist/commands/config-image-analysis-command.js +37 -27
- package/dist/commands/config-image-analysis-command.js.map +1 -1
- package/dist/commands/persist-command.d.ts.map +1 -1
- package/dist/commands/persist-command.js +455 -139
- package/dist/commands/persist-command.js.map +1 -1
- package/dist/management/checks/config-check.d.ts.map +1 -1
- package/dist/management/checks/config-check.js +2 -2
- package/dist/management/checks/config-check.js.map +1 -1
- package/dist/shared/extended-context-utils.d.ts +14 -0
- package/dist/shared/extended-context-utils.d.ts.map +1 -0
- package/dist/shared/extended-context-utils.js +35 -0
- package/dist/shared/extended-context-utils.js.map +1 -0
- package/dist/ui/assets/{accounts-BiL_RD2P.js → accounts-7x9sEJ6E.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BoSPpkH2.js → alert-dialog-CSG7wAU8.js} +1 -1
- package/dist/ui/assets/{api-BrHcZxrF.js → api-BF6fKWuJ.js} +1 -1
- package/dist/ui/assets/{auth-section-CNEQOji9.js → auth-section-BrRo7P5e.js} +1 -1
- package/dist/ui/assets/{backups-section-CYPJq2Y6.js → backups-section-BvoQ6sjn.js} +1 -1
- package/dist/ui/assets/cliproxy-Dp-l74Ht.js +3 -0
- package/dist/ui/assets/cliproxy-control-panel-D3_E45dZ.js +1 -0
- package/dist/ui/assets/{confirm-dialog-JGLPn0Pg.js → confirm-dialog-QJFlAs8u.js} +1 -1
- package/dist/ui/assets/{copilot-Bt-S8kHA.js → copilot-CRxuFhMs.js} +2 -2
- package/dist/ui/assets/{cursor-Qg3y30M0.js → cursor-Dsbkv6Oq.js} +1 -1
- package/dist/ui/assets/{globalenv-section-Dxrj87dw.js → globalenv-section-Cf_HiHep.js} +1 -1
- package/dist/ui/assets/{health-Bjnrp81E.js → health-CgHX0qCf.js} +1 -1
- package/dist/ui/assets/index-BNJ3rHVd.js +47 -0
- package/dist/ui/assets/{index-ApptKWow.js → index-BUC-Zfgc.js} +1 -1
- package/dist/ui/assets/{index-XJ9726WB.js → index-C-4XwF_5.js} +1 -1
- package/dist/ui/assets/{index-DOQkTkq-.js → index-D9YYXEsW.js} +1 -1
- package/dist/ui/assets/{index-UVFLMRYY.js → index-yfs5e5sm.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-PLX0fi09.js → proxy-status-widget-CNesfhAI.js} +1 -1
- package/dist/ui/assets/{separator-yZDNbi3M.js → separator-9gFbzNO-.js} +1 -1
- package/dist/ui/assets/{shared-DZ3QOOgF.js → shared-DfHvplPN.js} +1 -1
- package/dist/ui/assets/{switch-DsTWD8-1.js → switch-BMNi4Qdv.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/utils/claude-config-path.d.ts +11 -0
- package/dist/utils/claude-config-path.d.ts.map +1 -0
- package/dist/utils/claude-config-path.js +51 -0
- package/dist/utils/claude-config-path.js.map +1 -0
- package/dist/utils/websearch/hook-config.d.ts.map +1 -1
- package/dist/utils/websearch/hook-config.js +9 -23
- package/dist/utils/websearch/hook-config.js.map +1 -1
- package/dist/web-server/jsonl-parser.d.ts +0 -4
- package/dist/web-server/jsonl-parser.d.ts.map +1 -1
- package/dist/web-server/jsonl-parser.js +52 -29
- package/dist/web-server/jsonl-parser.js.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.js +105 -3
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
- package/dist/web-server/routes/persist-routes.d.ts.map +1 -1
- package/dist/web-server/routes/persist-routes.js +54 -44
- package/dist/web-server/routes/persist-routes.js.map +1 -1
- package/dist/web-server/routes/route-helpers.d.ts +0 -5
- package/dist/web-server/routes/route-helpers.d.ts.map +1 -1
- package/dist/web-server/routes/route-helpers.js +52 -6
- package/dist/web-server/routes/route-helpers.js.map +1 -1
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/settings-routes.js +72 -10
- package/dist/web-server/routes/settings-routes.js.map +1 -1
- package/dist/web-server/shared-routes.js +2 -2
- package/dist/web-server/shared-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/cliproxy-CDDlPp51.js +0 -3
- package/dist/ui/assets/cliproxy-control-panel-XSSdoJ3f.js +0 -1
- package/dist/ui/assets/index-Ce5AiHY_.js +0 -47
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
* This is the main entry point for all `ccs cliproxy` commands.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.handleCliproxyCommand = void 0;
|
|
9
|
+
exports.handleCliproxyCommand = exports.parseProviderArg = void 0;
|
|
10
10
|
const platform_detector_1 = require("../../cliproxy/platform-detector");
|
|
11
|
+
const provider_capabilities_1 = require("../../cliproxy/provider-capabilities");
|
|
11
12
|
const unified_config_loader_1 = require("../../config/unified-config-loader");
|
|
12
13
|
const cliproxy_sync_handler_1 = require("../cliproxy-sync-handler");
|
|
14
|
+
const arg_extractor_1 = require("../arg-extractor");
|
|
13
15
|
// Import subcommand handlers
|
|
14
16
|
const auth_subcommand_1 = require("./auth-subcommand");
|
|
15
17
|
const quota_subcommand_1 = require("./quota-subcommand");
|
|
@@ -23,30 +25,20 @@ const catalog_subcommand_1 = require("./catalog-subcommand");
|
|
|
23
25
|
* Returns the backend value and remaining args without --backend flag
|
|
24
26
|
*/
|
|
25
27
|
function parseBackendArg(args) {
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
// Also check for --backend=value format
|
|
29
|
-
const backendEqualsIdx = args.findIndex((a) => a.startsWith('--backend='));
|
|
30
|
-
if (backendEqualsIdx !== -1) {
|
|
31
|
-
const value = args[backendEqualsIdx].split('=')[1];
|
|
32
|
-
if (value !== 'original' && value !== 'plus') {
|
|
33
|
-
console.warn(`Invalid backend '${value}'. Valid options: original, plus`);
|
|
34
|
-
return { backend: undefined, remainingArgs: args };
|
|
35
|
-
}
|
|
36
|
-
const remainingArgs = [...args];
|
|
37
|
-
remainingArgs.splice(backendEqualsIdx, 1);
|
|
38
|
-
return { backend: value, remainingArgs };
|
|
39
|
-
}
|
|
28
|
+
const extracted = (0, arg_extractor_1.extractOption)(args, ['--backend']);
|
|
29
|
+
if (!extracted.found) {
|
|
40
30
|
return { backend: undefined, remainingArgs: args };
|
|
41
31
|
}
|
|
42
|
-
|
|
32
|
+
if (extracted.missingValue || !extracted.value) {
|
|
33
|
+
console.warn(`Invalid backend ''. Valid options: original, plus`);
|
|
34
|
+
return { backend: undefined, remainingArgs: extracted.remainingArgs };
|
|
35
|
+
}
|
|
36
|
+
const value = extracted.value;
|
|
43
37
|
if (value !== 'original' && value !== 'plus') {
|
|
44
38
|
console.warn(`Invalid backend '${value}'. Valid options: original, plus`);
|
|
45
|
-
return { backend: undefined, remainingArgs:
|
|
39
|
+
return { backend: undefined, remainingArgs: extracted.remainingArgs };
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
remainingArgs.splice(backendIdx, 2);
|
|
49
|
-
return { backend: value, remainingArgs };
|
|
41
|
+
return { backend: value, remainingArgs: extracted.remainingArgs };
|
|
50
42
|
}
|
|
51
43
|
/**
|
|
52
44
|
* Get effective backend (CLI flag > config.yaml > default)
|
|
@@ -57,65 +49,38 @@ function getEffectiveBackend(cliBackend) {
|
|
|
57
49
|
const config = (0, unified_config_loader_1.loadOrCreateUnifiedConfig)();
|
|
58
50
|
return config.cliproxy?.backend ?? platform_detector_1.DEFAULT_BACKEND;
|
|
59
51
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
function normalizeQuotaProvider(value) {
|
|
53
|
+
if (value === 'all') {
|
|
54
|
+
return 'all';
|
|
55
|
+
}
|
|
56
|
+
const canonicalProvider = (0, provider_capabilities_1.mapExternalProviderName)(value);
|
|
57
|
+
if (!canonicalProvider || !(0, provider_capabilities_1.isQuotaSupportedProvider)(canonicalProvider)) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return canonicalProvider;
|
|
61
|
+
}
|
|
65
62
|
function parseProviderArg(args) {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
const providerEqualsIdx = args.findIndex((a) => a.startsWith('--provider='));
|
|
70
|
-
if (providerEqualsIdx !== -1) {
|
|
71
|
-
const value = args[providerEqualsIdx].split('=')[1]?.toLowerCase() || '';
|
|
72
|
-
const remainingArgs = [...args];
|
|
73
|
-
remainingArgs.splice(providerEqualsIdx, 1);
|
|
74
|
-
// Handle empty value
|
|
75
|
-
if (!value) {
|
|
76
|
-
console.error('Warning: --provider requires a value. Valid options: agy, codex, gemini, gemini-cli, ghcp, github-copilot, all');
|
|
77
|
-
return { provider: 'all', remainingArgs };
|
|
78
|
-
}
|
|
79
|
-
// Normalize gemini-cli to gemini
|
|
80
|
-
const normalized = value === 'gemini-cli' ? 'gemini' : value === 'github-copilot' ? 'ghcp' : value;
|
|
81
|
-
if (normalized !== 'agy' &&
|
|
82
|
-
normalized !== 'codex' &&
|
|
83
|
-
normalized !== 'gemini' &&
|
|
84
|
-
normalized !== 'ghcp' &&
|
|
85
|
-
normalized !== 'all') {
|
|
86
|
-
console.error(`Invalid provider '${value}'. Valid options: agy, codex, gemini, gemini-cli, ghcp, github-copilot, all`);
|
|
87
|
-
return { provider: 'all', remainingArgs };
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
provider: normalized,
|
|
91
|
-
remainingArgs,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return { provider: 'all', remainingArgs: args };
|
|
63
|
+
const extracted = (0, arg_extractor_1.extractOption)(args, ['--provider']);
|
|
64
|
+
if (!extracted.found) {
|
|
65
|
+
return { provider: 'all', remainingArgs: args, invalid: false };
|
|
95
66
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
console.error('Warning: --provider requires a value. Valid options: agy, codex, gemini, gemini-cli, ghcp, github-copilot, all');
|
|
67
|
+
if (extracted.missingValue || !extracted.value) {
|
|
68
|
+
console.error(`Invalid provider value. --provider requires a value. Valid options: ${provider_capabilities_1.QUOTA_PROVIDER_HELP_TEXT}`);
|
|
69
|
+
return { provider: 'all', remainingArgs: extracted.remainingArgs, invalid: true };
|
|
100
70
|
}
|
|
101
|
-
const value =
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (normalized !== 'agy' &&
|
|
107
|
-
normalized !== 'codex' &&
|
|
108
|
-
normalized !== 'gemini' &&
|
|
109
|
-
normalized !== 'ghcp' &&
|
|
110
|
-
normalized !== 'all') {
|
|
111
|
-
console.error(`Invalid provider '${value}'. Valid options: agy, codex, gemini, gemini-cli, ghcp, github-copilot, all`);
|
|
112
|
-
return { provider: 'all', remainingArgs };
|
|
71
|
+
const value = extracted.value.toLowerCase();
|
|
72
|
+
const normalized = normalizeQuotaProvider(value);
|
|
73
|
+
if (!normalized) {
|
|
74
|
+
console.error(`Invalid provider '${value}'. Valid options: ${provider_capabilities_1.QUOTA_PROVIDER_HELP_TEXT}`);
|
|
75
|
+
return { provider: 'all', remainingArgs: extracted.remainingArgs, invalid: true };
|
|
113
76
|
}
|
|
114
77
|
return {
|
|
115
78
|
provider: normalized,
|
|
116
|
-
remainingArgs,
|
|
79
|
+
remainingArgs: extracted.remainingArgs,
|
|
80
|
+
invalid: false,
|
|
117
81
|
};
|
|
118
82
|
}
|
|
83
|
+
exports.parseProviderArg = parseProviderArg;
|
|
119
84
|
/**
|
|
120
85
|
* Main router for cliproxy commands
|
|
121
86
|
*/
|
|
@@ -123,29 +88,12 @@ async function handleCliproxyCommand(args) {
|
|
|
123
88
|
// Parse --backend flag first (before other processing)
|
|
124
89
|
const { backend: cliBackend, remainingArgs } = parseBackendArg(args);
|
|
125
90
|
const effectiveBackend = getEffectiveBackend(cliBackend);
|
|
126
|
-
const verbose =
|
|
91
|
+
const verbose = (0, arg_extractor_1.hasAnyFlag)(remainingArgs, ['--verbose', '-v']);
|
|
127
92
|
const command = remainingArgs[0];
|
|
128
|
-
if (
|
|
93
|
+
if ((0, arg_extractor_1.hasAnyFlag)(remainingArgs, ['--help', '-h'])) {
|
|
129
94
|
await (0, help_subcommand_1.showHelp)();
|
|
130
95
|
return;
|
|
131
96
|
}
|
|
132
|
-
// Profile commands
|
|
133
|
-
if (command === 'create') {
|
|
134
|
-
await (0, variant_subcommand_1.handleCreate)(remainingArgs.slice(1), effectiveBackend);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (command === 'edit') {
|
|
138
|
-
await (0, variant_subcommand_1.handleEdit)(remainingArgs.slice(1), effectiveBackend);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (command === 'list' || command === 'ls') {
|
|
142
|
-
await (0, auth_subcommand_1.handleList)();
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
if (command === 'remove' || command === 'delete' || command === 'rm') {
|
|
146
|
-
await (0, variant_subcommand_1.handleRemove)(remainingArgs.slice(1));
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
97
|
// Catalog commands
|
|
150
98
|
if (command === 'catalog') {
|
|
151
99
|
const subcommand = remainingArgs[1];
|
|
@@ -165,46 +113,38 @@ async function handleCliproxyCommand(args) {
|
|
|
165
113
|
await (0, cliproxy_sync_handler_1.handleSync)(remainingArgs.slice(1));
|
|
166
114
|
return;
|
|
167
115
|
}
|
|
168
|
-
// Proxy lifecycle commands
|
|
169
|
-
if (command === 'start') {
|
|
170
|
-
await (0, proxy_lifecycle_subcommand_1.handleStart)(verbose);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (command === 'stop') {
|
|
174
|
-
await (0, proxy_lifecycle_subcommand_1.handleStop)();
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (command === 'restart') {
|
|
178
|
-
await (0, proxy_lifecycle_subcommand_1.handleRestart)(verbose);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (command === 'status') {
|
|
182
|
-
await (0, proxy_lifecycle_subcommand_1.handleProxyStatus)();
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
// Diagnostics
|
|
186
|
-
if (command === 'doctor' || command === 'diag') {
|
|
187
|
-
await (0, quota_subcommand_1.handleDoctor)(verbose);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
// Quota management commands
|
|
191
|
-
if (command === 'default') {
|
|
192
|
-
await (0, quota_subcommand_1.handleSetDefault)(remainingArgs.slice(1));
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (command === 'pause') {
|
|
196
|
-
await (0, quota_subcommand_1.handlePauseAccount)(remainingArgs.slice(1));
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
if (command === 'resume') {
|
|
200
|
-
await (0, quota_subcommand_1.handleResumeAccount)(remainingArgs.slice(1));
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
116
|
if (command === 'quota') {
|
|
204
|
-
const { provider: providerFilter } = parseProviderArg(remainingArgs.slice(1));
|
|
117
|
+
const { provider: providerFilter, invalid } = parseProviderArg(remainingArgs.slice(1));
|
|
118
|
+
if (invalid) {
|
|
119
|
+
process.exitCode = 1;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
205
122
|
await (0, quota_subcommand_1.handleQuotaStatus)(verbose, providerFilter);
|
|
206
123
|
return;
|
|
207
124
|
}
|
|
125
|
+
const commandHandlers = {
|
|
126
|
+
create: async () => (0, variant_subcommand_1.handleCreate)(remainingArgs.slice(1), effectiveBackend),
|
|
127
|
+
edit: async () => (0, variant_subcommand_1.handleEdit)(remainingArgs.slice(1), effectiveBackend),
|
|
128
|
+
list: async () => (0, auth_subcommand_1.handleList)(),
|
|
129
|
+
ls: async () => (0, auth_subcommand_1.handleList)(),
|
|
130
|
+
remove: async () => (0, variant_subcommand_1.handleRemove)(remainingArgs.slice(1)),
|
|
131
|
+
delete: async () => (0, variant_subcommand_1.handleRemove)(remainingArgs.slice(1)),
|
|
132
|
+
rm: async () => (0, variant_subcommand_1.handleRemove)(remainingArgs.slice(1)),
|
|
133
|
+
start: async () => (0, proxy_lifecycle_subcommand_1.handleStart)(verbose),
|
|
134
|
+
stop: async () => (0, proxy_lifecycle_subcommand_1.handleStop)(),
|
|
135
|
+
restart: async () => (0, proxy_lifecycle_subcommand_1.handleRestart)(verbose),
|
|
136
|
+
status: async () => (0, proxy_lifecycle_subcommand_1.handleProxyStatus)(),
|
|
137
|
+
doctor: async () => (0, quota_subcommand_1.handleDoctor)(verbose),
|
|
138
|
+
diag: async () => (0, quota_subcommand_1.handleDoctor)(verbose),
|
|
139
|
+
default: async () => (0, quota_subcommand_1.handleSetDefault)(remainingArgs.slice(1)),
|
|
140
|
+
pause: async () => (0, quota_subcommand_1.handlePauseAccount)(remainingArgs.slice(1)),
|
|
141
|
+
resume: async () => (0, quota_subcommand_1.handleResumeAccount)(remainingArgs.slice(1)),
|
|
142
|
+
};
|
|
143
|
+
const commandHandler = command ? commandHandlers[command] : undefined;
|
|
144
|
+
if (commandHandler) {
|
|
145
|
+
await commandHandler();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
208
148
|
// Binary installation commands
|
|
209
149
|
const installIdx = remainingArgs.indexOf('--install');
|
|
210
150
|
if (installIdx !== -1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/cliproxy/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,wEAAmE;AACnE,8EAA+E;AAC/E,oEAAsD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/cliproxy/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,wEAAmE;AACnE,gFAK8C;AAC9C,8EAA+E;AAC/E,oEAAsD;AACtD,oDAA6D;AAE7D,6BAA6B;AAC7B,uDAA+C;AAC/C,yDAM4B;AAC5B,6DAA8E;AAC9E,6EAKsC;AACtC,6DAA6F;AAC7F,uDAA6C;AAC7C,6DAI8B;AAE9B;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAc;IAIrC,MAAM,SAAS,GAAG,IAAA,6BAAa,EAAC,IAAI,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IACrD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACrD,CAAC;IAED,IAAI,SAAS,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;QAClE,OAAO,EA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doctor
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
import { type QuotaSupportedProvider } from '../../cliproxy/provider-capabilities';
|
|
12
|
+
export declare function handleQuotaStatus(verbose?: boolean, providerFilter?: QuotaSupportedProvider | 'all'): Promise<void>;
|
|
12
13
|
export declare function handleDoctor(verbose?: boolean): Promise<void>;
|
|
13
14
|
export declare function handleSetDefault(args: string[]): Promise<void>;
|
|
14
15
|
export declare function handlePauseAccount(args: string[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-subcommand.d.ts","sourceRoot":"","sources":["../../../src/commands/cliproxy/quota-subcommand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"quota-subcommand.d.ts","sourceRoot":"","sources":["../../../src/commands/cliproxy/quota-subcommand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAuBH,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,sCAAsC,CAAC;AAwpB9C,wBAAsB,iBAAiB,CACrC,OAAO,UAAQ,EACf,cAAc,GAAE,sBAAsB,GAAG,KAAa,GACrD,OAAO,CAAC,IAAI,CAAC,CA2Cf;AAED,wBAAsB,YAAY,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAwFjE;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CpE;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCtE;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCvE"}
|
|
@@ -14,9 +14,12 @@ exports.handleResumeAccount = exports.handlePauseAccount = exports.handleSetDefa
|
|
|
14
14
|
const account_manager_1 = require("../../cliproxy/account-manager");
|
|
15
15
|
const quota_fetcher_1 = require("../../cliproxy/quota-fetcher");
|
|
16
16
|
const quota_fetcher_codex_1 = require("../../cliproxy/quota-fetcher-codex");
|
|
17
|
+
const quota_fetcher_claude_1 = require("../../cliproxy/quota-fetcher-claude");
|
|
18
|
+
const quota_fetcher_claude_normalizer_1 = require("../../cliproxy/quota-fetcher-claude-normalizer");
|
|
17
19
|
const quota_fetcher_gemini_cli_1 = require("../../cliproxy/quota-fetcher-gemini-cli");
|
|
18
20
|
const quota_fetcher_ghcp_1 = require("../../cliproxy/quota-fetcher-ghcp");
|
|
19
21
|
const quota_manager_1 = require("../../cliproxy/quota-manager");
|
|
22
|
+
const provider_capabilities_1 = require("../../cliproxy/provider-capabilities");
|
|
20
23
|
const ui_1 = require("../../utils/ui");
|
|
21
24
|
function parseProfileArgs(args) {
|
|
22
25
|
const result = {};
|
|
@@ -304,6 +307,112 @@ function displayCodexQuotaSection(results) {
|
|
|
304
307
|
console.log('');
|
|
305
308
|
}
|
|
306
309
|
}
|
|
310
|
+
function getClaudeWindowDisplayLabel(window) {
|
|
311
|
+
switch (window.rateLimitType) {
|
|
312
|
+
case 'five_hour':
|
|
313
|
+
return '5h usage limit';
|
|
314
|
+
case 'seven_day':
|
|
315
|
+
return 'Weekly usage limit';
|
|
316
|
+
case 'seven_day_opus':
|
|
317
|
+
return 'Weekly usage (Opus)';
|
|
318
|
+
case 'seven_day_sonnet':
|
|
319
|
+
return 'Weekly usage (Sonnet)';
|
|
320
|
+
case 'seven_day_oauth_apps':
|
|
321
|
+
return 'Weekly usage (OAuth apps)';
|
|
322
|
+
case 'seven_day_cowork':
|
|
323
|
+
return 'Weekly usage (Cowork)';
|
|
324
|
+
case 'overage':
|
|
325
|
+
return 'Extra usage';
|
|
326
|
+
default:
|
|
327
|
+
return window.label;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function toClaudeDisplayWindow(window) {
|
|
331
|
+
return {
|
|
332
|
+
rateLimitType: window.rateLimitType,
|
|
333
|
+
label: window.label,
|
|
334
|
+
remainingPercent: window.remainingPercent,
|
|
335
|
+
resetAt: window.resetAt,
|
|
336
|
+
status: window.status,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function toClaudeCoreDisplayWindow(window) {
|
|
340
|
+
if (!window)
|
|
341
|
+
return null;
|
|
342
|
+
return {
|
|
343
|
+
rateLimitType: window.rateLimitType,
|
|
344
|
+
label: window.label,
|
|
345
|
+
remainingPercent: window.remainingPercent,
|
|
346
|
+
resetAt: window.resetAt,
|
|
347
|
+
status: window.status,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function getClaudeCoreUsageWindows(quota) {
|
|
351
|
+
const coreUsage = quota.coreUsage;
|
|
352
|
+
const fiveHourFromCore = toClaudeCoreDisplayWindow(coreUsage?.fiveHour ?? null);
|
|
353
|
+
const weeklyFromCore = toClaudeCoreDisplayWindow(coreUsage?.weekly ?? null);
|
|
354
|
+
if (fiveHourFromCore || weeklyFromCore) {
|
|
355
|
+
return {
|
|
356
|
+
fiveHourWindow: fiveHourFromCore,
|
|
357
|
+
weeklyWindow: weeklyFromCore,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
const fiveHourPolicy = quota.windows.find((window) => window.rateLimitType === 'five_hour') ?? null;
|
|
361
|
+
const weeklyPolicy = (0, quota_fetcher_claude_normalizer_1.pickMostRestrictiveClaudeWeeklyWindow)(quota.windows);
|
|
362
|
+
return {
|
|
363
|
+
fiveHourWindow: fiveHourPolicy ? toClaudeDisplayWindow(fiveHourPolicy) : null,
|
|
364
|
+
weeklyWindow: weeklyPolicy ? toClaudeDisplayWindow(weeklyPolicy) : null,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function displayClaudeQuotaSection(results) {
|
|
368
|
+
console.log((0, ui_1.subheader)(`Claude (${results.length} account${results.length !== 1 ? 's' : ''})`));
|
|
369
|
+
console.log('');
|
|
370
|
+
for (const { account, quota } of results) {
|
|
371
|
+
const accountInfo = (0, account_manager_1.findAccountByQuery)('claude', account);
|
|
372
|
+
const defaultMark = accountInfo?.isDefault ? (0, ui_1.color)(' (default)', 'info') : '';
|
|
373
|
+
if (!quota.success) {
|
|
374
|
+
console.log(` ${(0, ui_1.fail)(account)}${defaultMark}`);
|
|
375
|
+
console.log(` ${(0, ui_1.color)(quota.error || 'Failed to fetch quota', 'error')}`);
|
|
376
|
+
console.log('');
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
const { fiveHourWindow, weeklyWindow } = getClaudeCoreUsageWindows(quota);
|
|
380
|
+
const coreWindows = [fiveHourWindow, weeklyWindow].filter((window, index, arr) => !!window && arr.indexOf(window) === index);
|
|
381
|
+
const statusWindows = coreWindows.length > 0 ? coreWindows : quota.windows.map(toClaudeDisplayWindow);
|
|
382
|
+
const minQuota = statusWindows.length > 0
|
|
383
|
+
? Math.min(...statusWindows.map((window) => window.remainingPercent))
|
|
384
|
+
: null;
|
|
385
|
+
const statusIcon = minQuota === null ? (0, ui_1.info)('') : minQuota > 50 ? (0, ui_1.ok)('') : minQuota > 10 ? (0, ui_1.warn)('') : (0, ui_1.fail)('');
|
|
386
|
+
console.log(` ${statusIcon}${account}${defaultMark}`);
|
|
387
|
+
const resetParts = [];
|
|
388
|
+
if (fiveHourWindow?.resetAt)
|
|
389
|
+
resetParts.push(`5h ${formatResetTimeISO(fiveHourWindow.resetAt)}`);
|
|
390
|
+
if (weeklyWindow?.resetAt)
|
|
391
|
+
resetParts.push(`weekly ${formatResetTimeISO(weeklyWindow.resetAt)}`);
|
|
392
|
+
if (resetParts.length > 0) {
|
|
393
|
+
console.log(` ${(0, ui_1.dim)(`Reset schedule: ${resetParts.join(' | ')}`)}`);
|
|
394
|
+
}
|
|
395
|
+
const orderedWindows = [...coreWindows, ...quota.windows.map(toClaudeDisplayWindow)].filter((window, index, arr) => arr.findIndex((candidate) => candidate.rateLimitType === window.rateLimitType &&
|
|
396
|
+
candidate.resetAt === window.resetAt &&
|
|
397
|
+
candidate.status === window.status) === index);
|
|
398
|
+
if (orderedWindows.length === 0) {
|
|
399
|
+
console.log(` ${(0, ui_1.dim)('Policy limits unavailable for this account')}`);
|
|
400
|
+
console.log('');
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
for (const window of orderedWindows) {
|
|
404
|
+
const bar = formatQuotaBar(window.remainingPercent);
|
|
405
|
+
const resetLabel = window.resetAt ? (0, ui_1.dim)(` Resets ${formatResetTimeISO(window.resetAt)}`) : '';
|
|
406
|
+
const statusLabel = window.status === 'rejected'
|
|
407
|
+
? (0, ui_1.dim)(' [blocked]')
|
|
408
|
+
: window.status === 'allowed_warning'
|
|
409
|
+
? (0, ui_1.dim)(' [warning]')
|
|
410
|
+
: '';
|
|
411
|
+
console.log(` ${getClaudeWindowDisplayLabel(window).padEnd(24)} ${bar} ${window.remainingPercent.toFixed(0)}%${statusLabel}${resetLabel}`);
|
|
412
|
+
}
|
|
413
|
+
console.log('');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
307
416
|
function displayGeminiCliQuotaSection(results) {
|
|
308
417
|
console.log((0, ui_1.subheader)(`Gemini CLI (${results.length} account${results.length !== 1 ? 's' : ''})`));
|
|
309
418
|
console.log('');
|
|
@@ -378,58 +487,75 @@ function displayGhcpQuotaSection(results) {
|
|
|
378
487
|
console.log('');
|
|
379
488
|
}
|
|
380
489
|
}
|
|
490
|
+
const QUOTA_PROVIDER_RUNTIME = {
|
|
491
|
+
agy: {
|
|
492
|
+
fetch: (verbose) => (0, quota_fetcher_1.fetchAllProviderQuotas)('agy', verbose),
|
|
493
|
+
hasData: (result) => result.accounts.length > 0,
|
|
494
|
+
render: (result) => displayAntigravityQuotaSection(result),
|
|
495
|
+
emptyTitle: 'Antigravity (0 accounts)',
|
|
496
|
+
emptyMessage: 'No Antigravity accounts configured',
|
|
497
|
+
authCommand: 'ccs agy --auth',
|
|
498
|
+
},
|
|
499
|
+
codex: {
|
|
500
|
+
fetch: (verbose) => (0, quota_fetcher_codex_1.fetchAllCodexQuotas)(verbose),
|
|
501
|
+
hasData: (result) => result.length > 0,
|
|
502
|
+
render: (result) => displayCodexQuotaSection(result),
|
|
503
|
+
emptyTitle: 'Codex (0 accounts)',
|
|
504
|
+
emptyMessage: 'No Codex accounts configured',
|
|
505
|
+
authCommand: 'ccs codex --auth',
|
|
506
|
+
},
|
|
507
|
+
claude: {
|
|
508
|
+
fetch: (verbose) => (0, quota_fetcher_claude_1.fetchAllClaudeQuotas)(verbose),
|
|
509
|
+
hasData: (result) => result.length > 0,
|
|
510
|
+
render: (result) => displayClaudeQuotaSection(result),
|
|
511
|
+
emptyTitle: 'Claude (0 accounts)',
|
|
512
|
+
emptyMessage: 'No Claude accounts configured',
|
|
513
|
+
authCommand: 'ccs claude --auth',
|
|
514
|
+
},
|
|
515
|
+
gemini: {
|
|
516
|
+
fetch: (verbose) => (0, quota_fetcher_gemini_cli_1.fetchAllGeminiCliQuotas)(verbose),
|
|
517
|
+
hasData: (result) => result.length > 0,
|
|
518
|
+
render: (result) => displayGeminiCliQuotaSection(result),
|
|
519
|
+
emptyTitle: 'Gemini CLI (0 accounts)',
|
|
520
|
+
emptyMessage: 'No Gemini CLI accounts configured',
|
|
521
|
+
authCommand: 'ccs gemini --auth',
|
|
522
|
+
},
|
|
523
|
+
ghcp: {
|
|
524
|
+
fetch: (verbose) => (0, quota_fetcher_ghcp_1.fetchAllGhcpQuotas)(verbose),
|
|
525
|
+
hasData: (result) => result.length > 0,
|
|
526
|
+
render: (result) => displayGhcpQuotaSection(result),
|
|
527
|
+
emptyTitle: 'GitHub Copilot (0 accounts)',
|
|
528
|
+
emptyMessage: 'No GitHub Copilot accounts configured',
|
|
529
|
+
authCommand: 'ccs ghcp --auth',
|
|
530
|
+
},
|
|
531
|
+
};
|
|
381
532
|
async function handleQuotaStatus(verbose = false, providerFilter = 'all') {
|
|
382
533
|
await (0, ui_1.initUI)();
|
|
383
534
|
console.log((0, ui_1.header)('Quota Status'));
|
|
384
535
|
console.log('');
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
codex: providerFilter === 'all' || providerFilter === 'codex',
|
|
388
|
-
gemini: providerFilter === 'all' || providerFilter === 'gemini',
|
|
389
|
-
ghcp: providerFilter === 'all' || providerFilter === 'ghcp',
|
|
390
|
-
};
|
|
536
|
+
const requestedProviders = new Set(providerFilter === 'all' ? provider_capabilities_1.QUOTA_SUPPORTED_PROVIDER_IDS : [providerFilter]);
|
|
537
|
+
const shouldFetch = (provider) => requestedProviders.has(provider);
|
|
391
538
|
console.log((0, ui_1.dim)('Fetching quotas...'));
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
539
|
+
const providerResults = new Map(await Promise.all(provider_capabilities_1.QUOTA_SUPPORTED_PROVIDER_IDS.map(async (provider) => {
|
|
540
|
+
if (!shouldFetch(provider)) {
|
|
541
|
+
return [provider, null];
|
|
542
|
+
}
|
|
543
|
+
return [provider, await QUOTA_PROVIDER_RUNTIME[provider].fetch(verbose)];
|
|
544
|
+
})));
|
|
398
545
|
console.log('');
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
console.log((0, ui_1.subheader)('Codex (0 accounts)'));
|
|
413
|
-
console.log((0, ui_1.info)('No Codex accounts configured'));
|
|
414
|
-
console.log(` Run: ${(0, ui_1.color)('ccs codex --auth', 'command')} to authenticate`);
|
|
415
|
-
console.log('');
|
|
416
|
-
}
|
|
417
|
-
if (geminiResults && geminiResults.length > 0) {
|
|
418
|
-
displayGeminiCliQuotaSection(geminiResults);
|
|
419
|
-
}
|
|
420
|
-
else if (shouldFetch.gemini) {
|
|
421
|
-
console.log((0, ui_1.subheader)('Gemini CLI (0 accounts)'));
|
|
422
|
-
console.log((0, ui_1.info)('No Gemini CLI accounts configured'));
|
|
423
|
-
console.log(` Run: ${(0, ui_1.color)('ccs gemini --auth', 'command')} to authenticate`);
|
|
424
|
-
console.log('');
|
|
425
|
-
}
|
|
426
|
-
if (ghcpResults && ghcpResults.length > 0) {
|
|
427
|
-
displayGhcpQuotaSection(ghcpResults);
|
|
428
|
-
}
|
|
429
|
-
else if (shouldFetch.ghcp) {
|
|
430
|
-
console.log((0, ui_1.subheader)('GitHub Copilot (0 accounts)'));
|
|
431
|
-
console.log((0, ui_1.info)('No GitHub Copilot accounts configured'));
|
|
432
|
-
console.log(` Run: ${(0, ui_1.color)('ccs ghcp --auth', 'command')} to authenticate`);
|
|
546
|
+
for (const provider of provider_capabilities_1.QUOTA_SUPPORTED_PROVIDER_IDS) {
|
|
547
|
+
if (!shouldFetch(provider)) {
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
const runtime = QUOTA_PROVIDER_RUNTIME[provider];
|
|
551
|
+
const result = providerResults.get(provider) ?? null;
|
|
552
|
+
if (result !== null && runtime.hasData(result)) {
|
|
553
|
+
runtime.render(result);
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
console.log((0, ui_1.subheader)(runtime.emptyTitle));
|
|
557
|
+
console.log((0, ui_1.info)(runtime.emptyMessage));
|
|
558
|
+
console.log(` Run: ${(0, ui_1.color)(runtime.authCommand, 'command')} to authenticate`);
|
|
433
559
|
console.log('');
|
|
434
560
|
}
|
|
435
561
|
}
|