@kaitranntt/ccs 7.37.0 → 7.37.1-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.
Files changed (143) hide show
  1. package/dist/cliproxy/account-manager.d.ts +5 -207
  2. package/dist/cliproxy/account-manager.d.ts.map +1 -1
  3. package/dist/cliproxy/account-manager.js +35 -795
  4. package/dist/cliproxy/account-manager.js.map +1 -1
  5. package/dist/cliproxy/accounts/bulk-ops.d.ts +22 -0
  6. package/dist/cliproxy/accounts/bulk-ops.d.ts.map +1 -0
  7. package/dist/cliproxy/accounts/bulk-ops.js +88 -0
  8. package/dist/cliproxy/accounts/bulk-ops.js.map +1 -0
  9. package/dist/cliproxy/accounts/index.d.ts +19 -0
  10. package/dist/cliproxy/accounts/index.d.ts.map +1 -0
  11. package/dist/cliproxy/accounts/index.js +54 -0
  12. package/dist/cliproxy/accounts/index.js.map +1 -0
  13. package/dist/cliproxy/accounts/query.d.ts +36 -0
  14. package/dist/cliproxy/accounts/query.d.ts.map +1 -0
  15. package/dist/cliproxy/accounts/query.js +94 -0
  16. package/dist/cliproxy/accounts/query.js.map +1 -0
  17. package/dist/cliproxy/accounts/registry.d.ts +74 -0
  18. package/dist/cliproxy/accounts/registry.d.ts.map +1 -0
  19. package/dist/cliproxy/accounts/registry.js +510 -0
  20. package/dist/cliproxy/accounts/registry.js.map +1 -0
  21. package/dist/cliproxy/accounts/token-file-ops.d.ts +64 -0
  22. package/dist/cliproxy/accounts/token-file-ops.d.ts.map +1 -0
  23. package/dist/cliproxy/accounts/token-file-ops.js +206 -0
  24. package/dist/cliproxy/accounts/token-file-ops.js.map +1 -0
  25. package/dist/cliproxy/accounts/types.d.ts +66 -0
  26. package/dist/cliproxy/accounts/types.d.ts.map +1 -0
  27. package/dist/cliproxy/accounts/types.js +12 -0
  28. package/dist/cliproxy/accounts/types.js.map +1 -0
  29. package/dist/cliproxy/auth/token-expiry-checker.d.ts.map +1 -1
  30. package/dist/cliproxy/auth/token-expiry-checker.js +5 -1
  31. package/dist/cliproxy/auth/token-expiry-checker.js.map +1 -1
  32. package/dist/cliproxy/cliproxy-executor.d.ts +11 -28
  33. package/dist/cliproxy/cliproxy-executor.d.ts.map +1 -1
  34. package/dist/cliproxy/cliproxy-executor.js +20 -1028
  35. package/dist/cliproxy/cliproxy-executor.js.map +1 -1
  36. package/dist/cliproxy/config/env-builder.d.ts +60 -0
  37. package/dist/cliproxy/config/env-builder.d.ts.map +1 -0
  38. package/dist/cliproxy/config/env-builder.js +311 -0
  39. package/dist/cliproxy/config/env-builder.js.map +1 -0
  40. package/dist/cliproxy/config/generator.d.ts +63 -0
  41. package/dist/cliproxy/config/generator.d.ts.map +1 -0
  42. package/dist/cliproxy/config/generator.js +336 -0
  43. package/dist/cliproxy/config/generator.js.map +1 -0
  44. package/dist/cliproxy/config/index.d.ts +10 -0
  45. package/dist/cliproxy/config/index.d.ts.map +1 -0
  46. package/dist/cliproxy/config/index.js +26 -0
  47. package/dist/cliproxy/config/index.js.map +1 -0
  48. package/dist/cliproxy/config/path-resolver.d.ts +47 -0
  49. package/dist/cliproxy/config/path-resolver.d.ts.map +1 -0
  50. package/dist/cliproxy/config/path-resolver.js +104 -0
  51. package/dist/cliproxy/config/path-resolver.js.map +1 -0
  52. package/dist/cliproxy/config/port-manager.d.ts +33 -0
  53. package/dist/cliproxy/config/port-manager.d.ts.map +1 -0
  54. package/dist/cliproxy/config/port-manager.js +68 -0
  55. package/dist/cliproxy/config/port-manager.js.map +1 -0
  56. package/dist/cliproxy/config/thinking-config.d.ts +39 -0
  57. package/dist/cliproxy/config/thinking-config.d.ts.map +1 -0
  58. package/dist/cliproxy/config/thinking-config.js +143 -0
  59. package/dist/cliproxy/config/thinking-config.js.map +1 -0
  60. package/dist/cliproxy/config-generator.d.ts +9 -221
  61. package/dist/cliproxy/config-generator.d.ts.map +1 -1
  62. package/dist/cliproxy/config-generator.js +12 -856
  63. package/dist/cliproxy/config-generator.js.map +1 -1
  64. package/dist/cliproxy/executor/env-resolver.d.ts +45 -0
  65. package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -0
  66. package/dist/cliproxy/executor/env-resolver.js +106 -0
  67. package/dist/cliproxy/executor/env-resolver.js.map +1 -0
  68. package/dist/cliproxy/executor/index.d.ts +24 -0
  69. package/dist/cliproxy/executor/index.d.ts.map +1 -0
  70. package/dist/cliproxy/executor/index.js +669 -0
  71. package/dist/cliproxy/executor/index.js.map +1 -0
  72. package/dist/cliproxy/executor/lifecycle-manager.d.ts +33 -0
  73. package/dist/cliproxy/executor/lifecycle-manager.d.ts.map +1 -0
  74. package/dist/cliproxy/executor/lifecycle-manager.js +161 -0
  75. package/dist/cliproxy/executor/lifecycle-manager.js.map +1 -0
  76. package/dist/cliproxy/executor/retry-handler.d.ts +27 -0
  77. package/dist/cliproxy/executor/retry-handler.d.ts.map +1 -0
  78. package/dist/cliproxy/executor/retry-handler.js +109 -0
  79. package/dist/cliproxy/executor/retry-handler.js.map +1 -0
  80. package/dist/cliproxy/executor/session-bridge.d.ts +30 -0
  81. package/dist/cliproxy/executor/session-bridge.d.ts.map +1 -0
  82. package/dist/cliproxy/executor/session-bridge.js +232 -0
  83. package/dist/cliproxy/executor/session-bridge.js.map +1 -0
  84. package/dist/commands/cliproxy/auth-subcommand.d.ts +10 -0
  85. package/dist/commands/cliproxy/auth-subcommand.d.ts.map +1 -0
  86. package/dist/commands/cliproxy/auth-subcommand.js +55 -0
  87. package/dist/commands/cliproxy/auth-subcommand.js.map +1 -0
  88. package/dist/commands/cliproxy/help-subcommand.d.ts +8 -0
  89. package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -0
  90. package/dist/commands/cliproxy/help-subcommand.js +87 -0
  91. package/dist/commands/cliproxy/help-subcommand.js.map +1 -0
  92. package/dist/commands/cliproxy/index.d.ts +11 -0
  93. package/dist/commands/cliproxy/index.d.ts.map +1 -0
  94. package/dist/commands/cliproxy/index.js +196 -0
  95. package/dist/commands/cliproxy/index.js.map +1 -0
  96. package/dist/commands/cliproxy/install-subcommand.d.ts +14 -0
  97. package/dist/commands/cliproxy/install-subcommand.d.ts.map +1 -0
  98. package/dist/commands/cliproxy/install-subcommand.js +112 -0
  99. package/dist/commands/cliproxy/install-subcommand.js.map +1 -0
  100. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts +10 -0
  101. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts.map +1 -0
  102. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js +54 -0
  103. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js.map +1 -0
  104. package/dist/commands/cliproxy/quota-subcommand.d.ts +16 -0
  105. package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -0
  106. package/dist/commands/cliproxy/quota-subcommand.js +383 -0
  107. package/dist/commands/cliproxy/quota-subcommand.js.map +1 -0
  108. package/dist/commands/cliproxy/variant-subcommand.d.ts +11 -0
  109. package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -0
  110. package/dist/commands/cliproxy/variant-subcommand.js +292 -0
  111. package/dist/commands/cliproxy/variant-subcommand.js.map +1 -0
  112. package/dist/commands/cliproxy-command.d.ts +4 -15
  113. package/dist/commands/cliproxy-command.d.ts.map +1 -1
  114. package/dist/commands/cliproxy-command.js +5 -1090
  115. package/dist/commands/cliproxy-command.js.map +1 -1
  116. package/dist/commands/version-command.js +1 -1
  117. package/dist/commands/version-command.js.map +1 -1
  118. package/dist/ui/assets/{accounts-DmKrgrCj.js → accounts-D0KU1a-4.js} +1 -1
  119. package/dist/ui/assets/{alert-dialog-CHcjWgRn.js → alert-dialog-BNRDV_Kh.js} +1 -1
  120. package/dist/ui/assets/{api-BFHZ3RKb.js → api-ClkFu9LY.js} +1 -1
  121. package/dist/ui/assets/{auth-section-DAI6Q5vU.js → auth-section-CNhNN1Jp.js} +1 -1
  122. package/dist/ui/assets/{backups-section-B1O8i4FM.js → backups-section-CZ721HIu.js} +1 -1
  123. package/dist/ui/assets/cliproxy-DeGucfVg.js +3 -0
  124. package/dist/ui/assets/{cliproxy-control-panel-3zVE7jZH.js → cliproxy-control-panel-T9i_Ldh0.js} +1 -1
  125. package/dist/ui/assets/{confirm-dialog-DV0JzL4A.js → confirm-dialog-Cy1__gRc.js} +1 -1
  126. package/dist/ui/assets/{copilot-BX8vT5RR.js → copilot-Cdqs2Jbh.js} +3 -3
  127. package/dist/ui/assets/{globalenv-section-BAft0m9b.js → globalenv-section-BEKtYN6I.js} +1 -1
  128. package/dist/ui/assets/{health-ct5TpFUE.js → health-BaHazGgS.js} +1 -1
  129. package/dist/ui/assets/{index-BOsGipAU.js → index-BTBpI5th.js} +1 -1
  130. package/dist/ui/assets/{index-CU3zgD6n.js → index-BZn6kF0u.js} +1 -1
  131. package/dist/ui/assets/{index-B8-K01HW.js → index-C2MS84sf.js} +1 -1
  132. package/dist/ui/assets/{index-gfWiPznS.js → index-CiULLjNI.js} +8 -8
  133. package/dist/ui/assets/{index-RZ6b7YTz.js → index-PjscK1jS.js} +1 -1
  134. package/dist/ui/assets/{proxy-status-widget-Ng9oZdrw.js → proxy-status-widget-BY6Lnr80.js} +1 -1
  135. package/dist/ui/assets/{shared-DpInRmag.js → shared-dZGNvBe9.js} +1 -1
  136. package/dist/ui/assets/{switch-DkRSlAu-.js → switch-BCFbehJz.js} +1 -1
  137. package/dist/ui/index.html +1 -1
  138. package/dist/utils/ui/init.d.ts +1 -1
  139. package/dist/utils/ui/init.d.ts.map +1 -1
  140. package/dist/utils/ui/init.js +25 -36
  141. package/dist/utils/ui/init.js.map +1 -1
  142. package/package.json +1 -1
  143. package/dist/ui/assets/cliproxy-BsSI8qFW.js +0 -3
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Thinking configuration and suffix handling
3
+ * Manages thinking budget suffixes for CLIProxyAPIPlus
4
+ */
5
+ /// <reference types="node" />
6
+ import { CLIProxyProvider } from '../types';
7
+ import { ThinkingConfig } from '../../config/unified-config-types';
8
+ /** Model tier types for thinking budget defaults */
9
+ export type ModelTier = 'opus' | 'sonnet' | 'haiku';
10
+ /**
11
+ * Detect tier from model name.
12
+ * Returns 'sonnet' as default if unclear.
13
+ */
14
+ export declare function detectTierFromModel(modelName: string): ModelTier;
15
+ /**
16
+ * Apply thinking suffix to model name.
17
+ * CLIProxyAPIPlus parses suffixes like model(level) or model(budget).
18
+ *
19
+ * @param model - Base model name
20
+ * @param thinkingValue - Level name (e.g., 'high') or numeric budget
21
+ * @returns Model name with thinking suffix, e.g., "gemini-3-pro-preview(high)"
22
+ */
23
+ export declare function applyThinkingSuffix(model: string, thinkingValue: string | number): string;
24
+ /**
25
+ * Get thinking value for tier based on config.
26
+ * Respects provider-specific overrides if configured.
27
+ */
28
+ export declare function getThinkingValueForTier(tier: ModelTier, provider: CLIProxyProvider, thinkingConfig: ThinkingConfig): string;
29
+ /**
30
+ * Apply thinking configuration to env vars.
31
+ * Modifies ANTHROPIC_MODEL and tier models with thinking suffixes.
32
+ *
33
+ * @param envVars - Environment variables to modify
34
+ * @param provider - CLIProxy provider
35
+ * @param thinkingOverride - Optional CLI override (takes priority over config)
36
+ * @returns Modified env vars with thinking suffixes applied
37
+ */
38
+ export declare function applyThinkingConfig(envVars: NodeJS.ProcessEnv, provider: CLIProxyProvider, thinkingOverride?: string | number): NodeJS.ProcessEnv;
39
+ //# sourceMappingURL=thinking-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinking-config.d.ts","sourceRoot":"","sources":["../../../src/cliproxy/config/thinking-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAkC,MAAM,mCAAmC,CAAC;AAMnG,oDAAoD;AACpD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAUpD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAKhE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAOzF;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,gBAAgB,EAC1B,cAAc,EAAE,cAAc,GAC7B,MAAM,CAQR;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,CAAC,UAAU,EAC1B,QAAQ,EAAE,gBAAgB,EAC1B,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,GACjC,MAAM,CAAC,UAAU,CAgFnB"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ /**
3
+ * Thinking configuration and suffix handling
4
+ * Manages thinking budget suffixes for CLIProxyAPIPlus
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.applyThinkingConfig = exports.getThinkingValueForTier = exports.applyThinkingSuffix = exports.detectTierFromModel = void 0;
8
+ const unified_config_types_1 = require("../../config/unified-config-types");
9
+ const unified_config_loader_1 = require("../../config/unified-config-loader");
10
+ const model_catalog_1 = require("../model-catalog");
11
+ const thinking_validator_1 = require("../thinking-validator");
12
+ const ui_1 = require("../../utils/ui");
13
+ /**
14
+ * Check if warnings should be shown based on thinking config.
15
+ * Defaults to true if show_warnings is not explicitly false.
16
+ */
17
+ function shouldShowWarnings(thinkingConfig) {
18
+ return thinkingConfig.show_warnings !== false;
19
+ }
20
+ /**
21
+ * Detect tier from model name.
22
+ * Returns 'sonnet' as default if unclear.
23
+ */
24
+ function detectTierFromModel(modelName) {
25
+ const lower = modelName.toLowerCase();
26
+ if (lower.includes('opus'))
27
+ return 'opus';
28
+ if (lower.includes('haiku'))
29
+ return 'haiku';
30
+ return 'sonnet'; // Default to sonnet (most common)
31
+ }
32
+ exports.detectTierFromModel = detectTierFromModel;
33
+ /**
34
+ * Apply thinking suffix to model name.
35
+ * CLIProxyAPIPlus parses suffixes like model(level) or model(budget).
36
+ *
37
+ * @param model - Base model name
38
+ * @param thinkingValue - Level name (e.g., 'high') or numeric budget
39
+ * @returns Model name with thinking suffix, e.g., "gemini-3-pro-preview(high)"
40
+ */
41
+ function applyThinkingSuffix(model, thinkingValue) {
42
+ // Don't apply if model already ends with a parenthesized suffix (e.g., "model(high)" or "model(8192)")
43
+ // Matches: ends with "(...)" where content is non-empty
44
+ if (/\([^)]+\)$/.test(model)) {
45
+ return model;
46
+ }
47
+ return `${model}(${thinkingValue})`;
48
+ }
49
+ exports.applyThinkingSuffix = applyThinkingSuffix;
50
+ /**
51
+ * Get thinking value for tier based on config.
52
+ * Respects provider-specific overrides if configured.
53
+ */
54
+ function getThinkingValueForTier(tier, provider, thinkingConfig) {
55
+ // Check provider-specific override first
56
+ const providerOverride = thinkingConfig.provider_overrides?.[provider]?.[tier];
57
+ if (providerOverride) {
58
+ return providerOverride;
59
+ }
60
+ // Fall back to global tier default (with null guard, uses centralized defaults)
61
+ return thinkingConfig.tier_defaults?.[tier] ?? unified_config_types_1.DEFAULT_THINKING_TIER_DEFAULTS[tier];
62
+ }
63
+ exports.getThinkingValueForTier = getThinkingValueForTier;
64
+ /**
65
+ * Apply thinking configuration to env vars.
66
+ * Modifies ANTHROPIC_MODEL and tier models with thinking suffixes.
67
+ *
68
+ * @param envVars - Environment variables to modify
69
+ * @param provider - CLIProxy provider
70
+ * @param thinkingOverride - Optional CLI override (takes priority over config)
71
+ * @returns Modified env vars with thinking suffixes applied
72
+ */
73
+ function applyThinkingConfig(envVars, provider, thinkingOverride) {
74
+ const thinkingConfig = (0, unified_config_loader_1.getThinkingConfig)();
75
+ const result = { ...envVars };
76
+ // Check if thinking is off
77
+ if (thinkingConfig.mode === 'off' && thinkingOverride === undefined) {
78
+ return result;
79
+ }
80
+ // Get base model to check thinking support
81
+ const baseModel = result.ANTHROPIC_MODEL || '';
82
+ if (!(0, model_catalog_1.supportsThinking)(provider, baseModel)) {
83
+ // U2: Warn user if they explicitly provided --thinking but model doesn't support it
84
+ if (thinkingOverride !== undefined && shouldShowWarnings(thinkingConfig)) {
85
+ console.warn((0, ui_1.warn)(`Model ${baseModel || 'unknown'} (provider: ${provider}) does not support thinking budget. --thinking flag ignored.`));
86
+ }
87
+ return result;
88
+ }
89
+ // Determine thinking value to use
90
+ let thinkingValue;
91
+ if (thinkingOverride !== undefined) {
92
+ // CLI override takes priority
93
+ thinkingValue = thinkingOverride;
94
+ }
95
+ else if (thinkingConfig.mode === 'manual' && thinkingConfig.override !== undefined) {
96
+ // Config manual mode with override
97
+ thinkingValue = thinkingConfig.override;
98
+ }
99
+ else if (thinkingConfig.mode === 'auto') {
100
+ // Auto mode: detect tier and apply default
101
+ const tier = detectTierFromModel(baseModel);
102
+ thinkingValue = getThinkingValueForTier(tier, provider, thinkingConfig);
103
+ }
104
+ else {
105
+ return result; // No thinking to apply
106
+ }
107
+ // Validate thinking value against model capabilities
108
+ const validation = (0, thinking_validator_1.validateThinking)(provider, baseModel, thinkingValue);
109
+ if (validation.warning && shouldShowWarnings(thinkingConfig)) {
110
+ console.warn((0, ui_1.warn)(validation.warning));
111
+ }
112
+ thinkingValue = validation.value;
113
+ // If validation says off, don't apply suffix
114
+ if (thinkingValue === 'off') {
115
+ return result;
116
+ }
117
+ // Apply thinking suffix to main model
118
+ if (result.ANTHROPIC_MODEL) {
119
+ result.ANTHROPIC_MODEL = applyThinkingSuffix(result.ANTHROPIC_MODEL, thinkingValue);
120
+ }
121
+ // Apply to tier models if they support thinking
122
+ const tierModels = [
123
+ 'ANTHROPIC_DEFAULT_OPUS_MODEL',
124
+ 'ANTHROPIC_DEFAULT_SONNET_MODEL',
125
+ 'ANTHROPIC_DEFAULT_HAIKU_MODEL',
126
+ ];
127
+ for (const tierVar of tierModels) {
128
+ const model = result[tierVar];
129
+ if (model && (0, model_catalog_1.supportsThinking)(provider, model)) {
130
+ // Get tier-specific thinking value
131
+ const tier = tierVar.includes('OPUS')
132
+ ? 'opus'
133
+ : tierVar.includes('SONNET')
134
+ ? 'sonnet'
135
+ : 'haiku';
136
+ const tierThinkingValue = thinkingOverride ?? getThinkingValueForTier(tier, provider, thinkingConfig);
137
+ result[tierVar] = applyThinkingSuffix(model, tierThinkingValue);
138
+ }
139
+ }
140
+ return result;
141
+ }
142
+ exports.applyThinkingConfig = applyThinkingConfig;
143
+ //# sourceMappingURL=thinking-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinking-config.js","sourceRoot":"","sources":["../../../src/cliproxy/config/thinking-config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,4EAAmG;AACnG,8EAAuE;AACvE,oDAAoD;AACpD,8DAAyD;AACzD,uCAAsC;AAKtC;;;GAGG;AACH,SAAS,kBAAkB,CAAC,cAA8B;IACxD,OAAO,cAAc,CAAC,aAAa,KAAK,KAAK,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,SAAiB;IACnD,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IACtC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC1C,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IAC5C,OAAO,QAAQ,CAAC,CAAC,kCAAkC;AACrD,CAAC;AALD,kDAKC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,KAAa,EAAE,aAA8B;IAC/E,uGAAuG;IACvG,wDAAwD;IACxD,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,GAAG,KAAK,IAAI,aAAa,GAAG,CAAC;AACtC,CAAC;AAPD,kDAOC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,IAAe,EACf,QAA0B,EAC1B,cAA8B;IAE9B,yCAAyC;IACzC,MAA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C;YACnC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACnC,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;oBAC1B,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,OAAO,CAAC;YACd,MAAM,iBAAiB,GACrB,gBAAgB,IAAI,uBAAuB,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;YAC9E,MAAM,CAAC,OAAO,CAAC,GAAG,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AApFD,kDAoFC"}
@@ -1,227 +1,15 @@
1
1
  /**
2
2
  * Config Generator for CLIProxyAPI
3
3
  *
4
- * Generates config.yaml for CLIProxyAPI based on provider.
5
- * Handles OAuth token paths and provider-specific settings.
4
+ * @deprecated This file is a re-export shim for backwards compatibility.
5
+ * New code should import from './config/' module instead.
6
6
  *
7
- * Model mappings are loaded from config/base-{provider}.settings.json files
8
- * to allow easy updates without code changes.
7
+ * Refactored into modular structure:
8
+ * - config/generator.ts - Core config generation
9
+ * - config/port-manager.ts - Port validation
10
+ * - config/env-builder.ts - Environment variables
11
+ * - config/thinking-config.ts - Thinking suffix logic
12
+ * - config/path-resolver.ts - Path utilities
9
13
  */
10
- /// <reference types="node" />
11
- import { CLIProxyProvider, ProviderConfig, ProviderModelMapping } from './types';
12
- import { ThinkingConfig } from '../config/unified-config-types';
13
- /**
14
- * Detect current tier from model name.
15
- * Looks at ANTHROPIC_MODEL to determine if using opus/sonnet/haiku tier.
16
- */
17
- export type ModelTier = 'opus' | 'sonnet' | 'haiku';
18
- /**
19
- * Detect tier from model name.
20
- * Returns 'sonnet' as default if unclear.
21
- */
22
- export declare function detectTierFromModel(modelName: string): ModelTier;
23
- /**
24
- * Apply thinking suffix to model name.
25
- * CLIProxyAPIPlus parses suffixes like model(level) or model(budget).
26
- *
27
- * @param model - Base model name
28
- * @param thinkingValue - Level name (e.g., 'high') or numeric budget
29
- * @returns Model name with thinking suffix, e.g., "gemini-3-pro-preview(high)"
30
- */
31
- export declare function applyThinkingSuffix(model: string, thinkingValue: string | number): string;
32
- /**
33
- * Get thinking value for tier based on config.
34
- * Respects provider-specific overrides if configured.
35
- */
36
- export declare function getThinkingValueForTier(tier: ModelTier, provider: CLIProxyProvider, thinkingConfig: ThinkingConfig): string;
37
- /**
38
- * Apply thinking configuration to env vars.
39
- * Modifies ANTHROPIC_MODEL and tier models with thinking suffixes.
40
- *
41
- * @param envVars - Environment variables to modify
42
- * @param provider - CLIProxy provider
43
- * @param thinkingOverride - Optional CLI override (takes priority over config)
44
- * @returns Modified env vars with thinking suffixes applied
45
- */
46
- export declare function applyThinkingConfig(envVars: NodeJS.ProcessEnv, provider: CLIProxyProvider, thinkingOverride?: string | number): NodeJS.ProcessEnv;
47
- /**
48
- * Validate port is a valid positive integer (1-65535).
49
- * Returns default port if invalid.
50
- *
51
- * @param port - Port number to validate
52
- * @returns Valid port or CLIPROXY_DEFAULT_PORT (8317) if invalid
53
- */
54
- export declare function validatePort(port: number | undefined): number;
55
- /** Default CLIProxy port */
56
- export declare const CLIPROXY_DEFAULT_PORT = 8317;
57
- /**
58
- * Normalize protocol to lowercase and validate.
59
- * Handles runtime case sensitivity (e.g., 'HTTPS' → 'https').
60
- * Defaults to 'http' for invalid values.
61
- */
62
- export declare function normalizeProtocol(protocol: string | undefined): 'http' | 'https';
63
- /**
64
- * Validate and sanitize port number for remote connections.
65
- * Returns undefined for invalid ports (letting caller use default).
66
- * Valid range: 1-65535, must be integer.
67
- */
68
- export declare function validateRemotePort(port: number | undefined): number | undefined;
69
- /**
70
- * Get default port for remote CLIProxyAPI based on protocol.
71
- * - HTTP: 8317 (CLIProxyAPI default)
72
- * - HTTPS: 443 (standard SSL port)
73
- */
74
- export declare function getRemoteDefaultPort(protocol: 'http' | 'https'): number;
75
- /** Internal API key for CCS-managed requests */
76
- export declare const CCS_INTERNAL_API_KEY = "ccs-internal-managed";
77
- /** Simple secret key for Control Panel login (user-facing) */
78
- export declare const CCS_CONTROL_PANEL_SECRET = "ccs";
79
- /**
80
- * Get CLIProxy writable directory for logs and runtime files.
81
- * This directory is set as WRITABLE_PATH env var when spawning CLIProxy.
82
- * Logs will be stored in ~/.ccs/cliproxy/logs/
83
- */
84
- export declare function getCliproxyWritablePath(): string;
85
- /**
86
- * Config version - bump when config format changes to trigger regeneration
87
- * v1: Initial config (port, auth-dir, api-keys only)
88
- * v2: Full-featured config with dashboard, quota mgmt, simplified key
89
- * v3: Logging disabled by default (user opt-in via ~/.ccs/config.yaml)
90
- * v4: Added Kiro (AWS) and GitHub Copilot providers
91
- * v5: Added disable-cooling: true for stability
92
- */
93
- export declare const CLIPROXY_CONFIG_VERSION = 5;
94
- /**
95
- * Get provider configuration
96
- * Model mappings are loaded from config/base-{provider}.settings.json
97
- */
98
- export declare function getProviderConfig(provider: CLIProxyProvider): ProviderConfig;
99
- /**
100
- * Get model mapping for provider
101
- * Loads from config/base-{provider}.settings.json
102
- */
103
- export declare function getModelMapping(provider: CLIProxyProvider): ProviderModelMapping;
104
- /**
105
- * Get CLIProxy base directory
106
- * All CLIProxy-related files are stored under ~/.ccs/cliproxy/
107
- */
108
- export declare function getCliproxyDir(): string;
109
- /**
110
- * Get auth directory for provider
111
- * All providers use a FLAT auth directory structure for unified config.
112
- * CLIProxyAPI stores OAuth tokens directly in auth/ (not subdirectories).
113
- * This enables all providers to be discovered and used concurrently.
114
- */
115
- export declare function getProviderAuthDir(_provider: CLIProxyProvider): string;
116
- /**
117
- * Get base auth directory for CLIProxyAPI
118
- */
119
- export declare function getAuthDir(): string;
120
- /**
121
- * Get config file path for a specific port.
122
- * Default port uses config.yaml, others use config-{port}.yaml.
123
- */
124
- export declare function getConfigPathForPort(port: number): string;
125
- /**
126
- * Get CLIProxy config file path (default port)
127
- * Named distinctly from config-manager's getConfigPath to avoid confusion.
128
- */
129
- export declare function getCliproxyConfigPath(): string;
130
- /**
131
- * Get binary directory path
132
- */
133
- export declare function getBinDir(): string;
134
- /**
135
- * Generate unified config.yaml file (supports all providers concurrently)
136
- * Only regenerates if config doesn't exist.
137
- * @returns Path to config file
138
- */
139
- export declare function generateConfig(provider: CLIProxyProvider, port?: number): string;
140
- /**
141
- * Parse user-added API keys from existing config content.
142
- * Extracts all keys except the internal CCS key for preservation.
143
- *
144
- * @param content - Existing config.yaml content
145
- * @returns Array of user-added API keys (excludes CCS_INTERNAL_API_KEY)
146
- */
147
- export declare function parseUserApiKeys(content: string): string[];
148
- /**
149
- * Force regenerate config.yaml with latest settings.
150
- * Preserves user-added API keys and port settings.
151
- *
152
- * @param port - Default port to use if not found in existing config
153
- * @returns Path to new config file
154
- */
155
- export declare function regenerateConfig(port?: number): string;
156
- /**
157
- * Check if config needs regeneration (version mismatch)
158
- * @returns true if config should be regenerated
159
- */
160
- export declare function configNeedsRegeneration(): boolean;
161
- /**
162
- * Check if config exists for port
163
- */
164
- export declare function configExists(port?: number): boolean;
165
- /**
166
- * Delete config file for specific port
167
- */
168
- export declare function deleteConfigForPort(port: number): void;
169
- /**
170
- * Delete config file (default port)
171
- */
172
- export declare function deleteConfig(): void;
173
- /**
174
- * Get path to user settings file for provider
175
- * Example: ~/.ccs/gemini.settings.json
176
- */
177
- export declare function getProviderSettingsPath(provider: CLIProxyProvider): string;
178
- /**
179
- * Get environment variables for Claude CLI (bundled defaults)
180
- * Uses provider-specific endpoint (e.g., /api/provider/gemini) for explicit routing.
181
- * This enables concurrent gemini/codex usage - each session routes to its provider via URL path.
182
- */
183
- export declare function getClaudeEnvVars(provider: CLIProxyProvider, port?: number): NodeJS.ProcessEnv;
184
- /** Remote proxy configuration for URL rewriting */
185
- interface RemoteProxyRewriteConfig {
186
- host: string;
187
- port?: number;
188
- protocol: 'http' | 'https';
189
- authToken?: string;
190
- }
191
- /**
192
- * Get effective environment variables for provider
193
- *
194
- * Priority order:
195
- * 1. Custom settings path (for user-defined CLIProxy variants)
196
- * 2. User settings file (~/.ccs/{provider}.settings.json) if exists
197
- * 3. Bundled defaults from PROVIDER_CONFIGS
198
- *
199
- * All results are merged with global_env vars (telemetry/reporting disables).
200
- * User takes full responsibility for custom settings.
201
- *
202
- * If remoteRewriteConfig is provided, localhost URLs are rewritten to remote server.
203
- */
204
- export declare function getEffectiveEnvVars(provider: CLIProxyProvider, port?: number, customSettingsPath?: string, remoteRewriteConfig?: RemoteProxyRewriteConfig): NodeJS.ProcessEnv;
205
- /**
206
- * Copy bundled settings template to user directory if not exists
207
- * Called during installation/first run
208
- */
209
- export declare function ensureProviderSettings(provider: CLIProxyProvider): void;
210
- /**
211
- * Get environment variables for remote proxy mode.
212
- * Uses the remote proxy's provider endpoint as the base URL.
213
- * Respects user model settings from custom settings path or provider settings file.
214
- *
215
- * @param provider CLIProxy provider (gemini, codex, agy, qwen, iflow)
216
- * @param remoteConfig Remote proxy connection details
217
- * @param customSettingsPath Optional path to user's custom settings file
218
- * @returns Environment variables for Claude CLI
219
- */
220
- export declare function getRemoteEnvVars(provider: CLIProxyProvider, remoteConfig: {
221
- host: string;
222
- port?: number;
223
- protocol: 'http' | 'https';
224
- authToken?: string;
225
- }, customSettingsPath?: string): Record<string, string>;
226
- export {};
14
+ export * from './config';
227
15
  //# sourceMappingURL=config-generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-generator.d.ts","sourceRoot":"","sources":["../../src/cliproxy/config-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;AAOH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AASjF,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAgBhE;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EA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