@kaitranntt/ccs 7.37.1 → 7.38.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/config/base-qwen.settings.json +2 -2
- package/dist/api/services/provider-presets.js +1 -1
- package/dist/api/services/provider-presets.js.map +1 -1
- package/dist/cliproxy/catalog-cache.d.ts +39 -0
- package/dist/cliproxy/catalog-cache.d.ts.map +1 -0
- package/dist/cliproxy/catalog-cache.js +246 -0
- package/dist/cliproxy/catalog-cache.js.map +1 -0
- package/dist/cliproxy/config/extended-context-config.d.ts +39 -0
- package/dist/cliproxy/config/extended-context-config.d.ts.map +1 -0
- package/dist/cliproxy/config/extended-context-config.js +114 -0
- package/dist/cliproxy/config/extended-context-config.js.map +1 -0
- package/dist/cliproxy/config/generator.d.ts +3 -2
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.js +87 -5
- package/dist/cliproxy/config/generator.js.map +1 -1
- package/dist/cliproxy/config/index.d.ts +1 -0
- package/dist/cliproxy/config/index.d.ts.map +1 -1
- package/dist/cliproxy/config/index.js +1 -0
- package/dist/cliproxy/config/index.js.map +1 -1
- package/dist/cliproxy/executor/env-resolver.d.ts +2 -0
- package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.js +5 -1
- 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 +22 -0
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/index.d.ts +2 -1
- package/dist/cliproxy/index.d.ts.map +1 -1
- package/dist/cliproxy/index.js +10 -1
- package/dist/cliproxy/index.js.map +1 -1
- package/dist/cliproxy/management-api-client.d.ts +6 -1
- package/dist/cliproxy/management-api-client.d.ts.map +1 -1
- package/dist/cliproxy/management-api-client.js +9 -0
- package/dist/cliproxy/management-api-client.js.map +1 -1
- package/dist/cliproxy/management-api-types.d.ts +30 -0
- package/dist/cliproxy/management-api-types.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts +12 -0
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +53 -3
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/platform-detector.d.ts +4 -4
- package/dist/cliproxy/platform-detector.d.ts.map +1 -1
- package/dist/cliproxy/platform-detector.js +2 -2
- package/dist/cliproxy/platform-detector.js.map +1 -1
- package/dist/commands/cliproxy/catalog-subcommand.d.ts +7 -0
- package/dist/commands/cliproxy/catalog-subcommand.d.ts.map +1 -0
- package/dist/commands/cliproxy/catalog-subcommand.js +123 -0
- package/dist/commands/cliproxy/catalog-subcommand.js.map +1 -0
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.js +8 -0
- package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/index.d.ts.map +1 -1
- package/dist/commands/cliproxy/index.js +15 -0
- package/dist/commands/cliproxy/index.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +13 -0
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/version-command.js +1 -1
- package/dist/commands/version-command.js.map +1 -1
- package/dist/ui/assets/{accounts-D0KU1a-4.js → accounts-ResKjvou.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BNRDV_Kh.js → alert-dialog-BnSvEwhd.js} +1 -1
- package/dist/ui/assets/{api-ClkFu9LY.js → api-ClPWraVr.js} +1 -1
- package/dist/ui/assets/{auth-section-CNhNN1Jp.js → auth-section-CZmgtezT.js} +1 -1
- package/dist/ui/assets/{backups-section-CZ721HIu.js → backups-section-CcQsXemH.js} +1 -1
- package/dist/ui/assets/cliproxy-C0JgtLfO.js +3 -0
- package/dist/ui/assets/{cliproxy-control-panel-T9i_Ldh0.js → cliproxy-control-panel-CBO7xTqe.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-Cy1__gRc.js → confirm-dialog-Cjs1FPCy.js} +1 -1
- package/dist/ui/assets/{copilot-Cdqs2Jbh.js → copilot-DCA0pQV3.js} +2 -2
- package/dist/ui/assets/{globalenv-section-BEKtYN6I.js → globalenv-section-D_GVHsDN.js} +1 -1
- package/dist/ui/assets/{health-BaHazGgS.js → health-riN3OSz-.js} +1 -1
- package/dist/ui/assets/{index-CiULLjNI.js → index-7gcYb5Oq.js} +3 -3
- package/dist/ui/assets/{index-PjscK1jS.js → index-BXTtPkoG.js} +1 -1
- package/dist/ui/assets/{index-BZn6kF0u.js → index-BjiZGSfI.js} +1 -1
- package/dist/ui/assets/{index-BTBpI5th.js → index-CK0URaBN.js} +1 -1
- package/dist/ui/assets/{index-C2MS84sf.js → index-sdtPg8Gr.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-BY6Lnr80.js → proxy-status-widget-B-LQxeOH.js} +1 -1
- package/dist/ui/assets/{shared-dZGNvBe9.js → shared-PuUIRrgy.js} +1 -1
- package/dist/ui/assets/{switch-BCFbehJz.js → switch-CCYYFslZ.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/utils/shell-executor.d.ts +6 -0
- package/dist/utils/shell-executor.d.ts.map +1 -1
- package/dist/utils/shell-executor.js +42 -4
- package/dist/utils/shell-executor.js.map +1 -1
- package/dist/utils/ui/init.d.ts +1 -1
- package/dist/utils/ui/init.d.ts.map +1 -1
- package/dist/utils/ui/init.js +25 -36
- package/dist/utils/ui/init.js.map +1 -1
- package/dist/web-server/routes/catalog-routes.d.ts +3 -0
- package/dist/web-server/routes/catalog-routes.d.ts.map +1 -0
- package/dist/web-server/routes/catalog-routes.js +27 -0
- package/dist/web-server/routes/catalog-routes.js.map +1 -0
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +2 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/code-reviewer.ts +1 -1
- package/dist/ui/assets/cliproxy-DeGucfVg.js +0 -3
package/dist/utils/ui/init.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/utils/ui/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/utils/ui/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH;;;GAGG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CA8B5C;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAOnC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAO7C"}
|
package/dist/utils/ui/init.js
CHANGED
|
@@ -5,54 +5,43 @@
|
|
|
5
5
|
* Handles lazy loading of ESM dependencies
|
|
6
6
|
* @module utils/ui/init
|
|
7
7
|
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
9
|
exports.isClaudeCodeContext = exports.isInteractive = exports.useColors = exports.initUI = void 0;
|
|
33
10
|
const types_1 = require("./types");
|
|
11
|
+
/**
|
|
12
|
+
* Native dynamic import that bypasses TypeScript's require() transformation.
|
|
13
|
+
* This preserves ESM import() at runtime, fixing Node 24 ESM/CJS interop issues.
|
|
14
|
+
*
|
|
15
|
+
* TypeScript compiles `import('x')` to `require('x')` when targeting CommonJS,
|
|
16
|
+
* which breaks ESM packages like ora that depend on other ESM-only modules.
|
|
17
|
+
*/
|
|
18
|
+
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
34
19
|
/**
|
|
35
20
|
* Initialize UI dependencies (call once at startup)
|
|
36
|
-
* Uses dynamic imports for ESM packages in CommonJS project
|
|
21
|
+
* Uses native dynamic imports for ESM packages in CommonJS project
|
|
37
22
|
*/
|
|
38
23
|
async function initUI() {
|
|
39
24
|
if (types_1.initialized)
|
|
40
25
|
return;
|
|
41
26
|
try {
|
|
42
|
-
//
|
|
27
|
+
// Use native dynamic import to avoid TypeScript's require() transformation
|
|
43
28
|
const [chalkImport, boxenImport, gradientImport, oraImport, listrImport] = await Promise.all([
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
dynamicImport('chalk'),
|
|
30
|
+
dynamicImport('boxen'),
|
|
31
|
+
dynamicImport('gradient-string'),
|
|
32
|
+
dynamicImport('ora'),
|
|
33
|
+
dynamicImport('listr2'),
|
|
49
34
|
]);
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
types_1.moduleCache.
|
|
54
|
-
types_1.moduleCache.
|
|
55
|
-
types_1.moduleCache.
|
|
35
|
+
// ESM modules: use .default for the actual export
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
const getDefault = (mod) => mod.default || mod;
|
|
38
|
+
types_1.moduleCache.chalk = getDefault(chalkImport);
|
|
39
|
+
types_1.moduleCache.boxen = getDefault(boxenImport);
|
|
40
|
+
types_1.moduleCache.gradient = getDefault(gradientImport);
|
|
41
|
+
types_1.moduleCache.ora = getDefault(oraImport);
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
const listr = listrImport;
|
|
44
|
+
types_1.moduleCache.listr = listr.Listr || listr.default?.Listr;
|
|
56
45
|
(0, types_1.setInitialized)(true);
|
|
57
46
|
}
|
|
58
47
|
catch (_e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/utils/ui/init.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/utils/ui/init.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAmE;AAEnE;;;;;;GAMG;AAEH,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAErD,CAAC;AAEtB;;;GAGG;AACI,KAAK,UAAU,MAAM;IAC1B,IAAI,mBAAW;QAAE,OAAO;IAExB,IAAI,CAAC;QACH,2EAA2E;QAC3E,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC3F,aAAa,CAAC,OAAO,CAAC;YACtB,aAAa,CAAC,OAAO,CAAC;YACtB,aAAa,CAAC,iBAAiB,CAAC;YAChC,aAAa,CAAC,KAAK,CAAC;YACpB,aAAa,CAAC,QAAQ,CAAC;SACxB,CAAC,CAAC;QAEH,kDAAkD;QAClD,8DAA8D;QAC9D,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC;QAEpD,mBAAW,CAAC,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QAC5C,mBAAW,CAAC,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QAC5C,mBAAW,CAAC,QAAQ,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;QAClD,mBAAW,CAAC,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QACxC,8DAA8D;QAC9D,MAAM,KAAK,GAAG,WAAkB,CAAC;QACjC,mBAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC;QACxD,IAAA,sBAAc,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,oDAAoD;QACpD,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACrE,IAAA,sBAAc,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AA9BD,wBA8BC;AAED;;;GAGG;AACH,SAAgB,SAAS;IACvB,mCAAmC;IACnC,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IACzC,2BAA2B;IAC3B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IACvC,0BAA0B;IAC1B,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;AAChC,CAAC;AAPD,8BAOC;AAED;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAC5E,CAAC;AAFD,sCAEC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB;IACjC,OAAO,CACL,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QACrB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAChB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW;QACzB,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,CAC5B,CAAC;AACJ,CAAC;AAPD,kDAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/catalog-routes.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,4CAAW,CAAC;AAsBxB,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const express_1 = require("express");
|
|
4
|
+
const catalog_cache_1 = require("../../cliproxy/catalog-cache");
|
|
5
|
+
const router = (0, express_1.Router)();
|
|
6
|
+
/**
|
|
7
|
+
* GET /api/cliproxy/catalog - Get merged model catalogs
|
|
8
|
+
* Returns resolved catalogs (cached + static merged)
|
|
9
|
+
*/
|
|
10
|
+
router.get('/', (_req, res) => {
|
|
11
|
+
try {
|
|
12
|
+
const catalogs = (0, catalog_cache_1.getAllResolvedCatalogs)();
|
|
13
|
+
const cacheAge = (0, catalog_cache_1.getCacheAge)();
|
|
14
|
+
res.json({
|
|
15
|
+
catalogs,
|
|
16
|
+
cache: {
|
|
17
|
+
synced: cacheAge !== null,
|
|
18
|
+
age: cacheAge,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
res.status(500).json({ error: error.message });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
exports.default = router;
|
|
27
|
+
//# sourceMappingURL=catalog-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-routes.js","sourceRoot":"","sources":["../../../src/web-server/routes/catalog-routes.ts"],"names":[],"mappings":";;AAAA,qCAAoD;AACpD,gEAAmF;AAEnF,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAa,EAAE,GAAa,EAAQ,EAAE;IACrD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAA,sCAAsB,GAAE,CAAC;QAC1C,MAAM,QAAQ,GAAG,IAAA,2BAAW,GAAE,CAAC;QAC/B,GAAG,CAAC,IAAI,CAAC;YACP,QAAQ;YACR,KAAK,EAAE;gBACL,MAAM,EAAE,QAAQ,KAAK,IAAI;gBACzB,GAAG,EAAE,QAAQ;aACd;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,kBAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwBH,eAAO,MAAM,SAAS,4CAAW,CAAC"}
|
|
@@ -28,6 +28,7 @@ const misc_routes_1 = __importDefault(require("./misc-routes"));
|
|
|
28
28
|
const proxy_routes_1 = __importDefault(require("./proxy-routes"));
|
|
29
29
|
const auth_routes_1 = __importDefault(require("./auth-routes"));
|
|
30
30
|
const persist_routes_1 = __importDefault(require("./persist-routes"));
|
|
31
|
+
const catalog_routes_1 = __importDefault(require("./catalog-routes"));
|
|
31
32
|
// Create the main API router
|
|
32
33
|
exports.apiRoutes = (0, express_1.Router)();
|
|
33
34
|
// ==================== Profile & Settings ====================
|
|
@@ -50,6 +51,7 @@ exports.apiRoutes.use('/cliproxy', variant_routes_1.default);
|
|
|
50
51
|
exports.apiRoutes.use('/cliproxy/auth', cliproxy_auth_routes_1.default);
|
|
51
52
|
exports.apiRoutes.use('/cliproxy', cliproxy_stats_routes_1.default);
|
|
52
53
|
exports.apiRoutes.use('/cliproxy/sync', cliproxy_sync_routes_1.default);
|
|
54
|
+
exports.apiRoutes.use('/cliproxy/catalog', catalog_routes_1.default);
|
|
53
55
|
exports.apiRoutes.use('/cliproxy/openai-compat', provider_routes_1.default);
|
|
54
56
|
// ==================== WebSearch ====================
|
|
55
57
|
exports.apiRoutes.use('/websearch', websearch_routes_1.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web-server/routes/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,qCAAiC;AAEjC,wBAAwB;AACxB,sEAA6C;AAC7C,sEAA6C;AAC7C,oEAA2C;AAC3C,oEAA2C;AAC3C,wEAA+C;AAC/C,sEAA6C;AAC7C,wEAA+C;AAC/C,0EAAiD;AACjD,kFAAwD;AACxD,oFAA0D;AAC1D,kFAAwD;AACxD,sEAA6C;AAC7C,gEAAuC;AACvC,kEAAkD;AAClD,gEAAuC;AACvC,sEAA6C;AAE7C,6BAA6B;AAChB,QAAA,SAAS,GAAG,IAAA,gBAAM,GAAE,CAAC;AAElC,+DAA+D;AAC/D,uDAAuD;AACvD,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,wBAAa,CAAC,CAAC;AAC1C,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,yBAAc,CAAC,CAAC;AAC3C,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,wBAAa,CAAC,CAAC;AAE1C,2DAA2D;AAC3D,2BAA2B;AAC3B,iBAAS,CAAC,GAAG,CAAC,SAAS,EAAE,uBAAY,CAAC,CAAC;AAEvC,0DAA0D;AAC1D,iBAAS,CAAC,GAAG,CAAC,SAAS,EAAE,uBAAY,CAAC,CAAC;AAEvC,2DAA2D;AAC3D,iBAAS,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAU,CAAC,CAAC;AAEnC,wEAAwE;AACxE,iBAAS,CAAC,GAAG,CAAC,UAAU,EAAE,wBAAa,CAAC,CAAC;AAEzC,qDAAqD;AACrD,8DAA8D;AAC9D,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,wBAAa,CAAC,CAAC;AAC1C,iBAAS,CAAC,GAAG,CAAC,gBAAgB,EAAE,8BAAkB,CAAC,CAAC;AACpD,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,+BAAmB,CAAC,CAAC;AAChD,iBAAS,CAAC,GAAG,CAAC,gBAAgB,EAAE,8BAAkB,CAAC,CAAC;AACpD,iBAAS,CAAC,GAAG,CAAC,yBAAyB,EAAE,yBAAc,CAAC,CAAC;AAEzD,sDAAsD;AACtD,iBAAS,CAAC,GAAG,CAAC,YAAY,EAAE,0BAAe,CAAC,CAAC;AAE7C,oDAAoD;AACpD,iBAAS,CAAC,GAAG,CAAC,UAAU,EAAE,wBAAa,CAAC,CAAC;AAEzC,qEAAqE;AACrE,iBAAS,CAAC,GAAG,CAAC,kBAAkB,EAAE,sBAAoB,CAAC,CAAC;AAExD,wEAAwE;AACxE,iBAAS,CAAC,GAAG,CAAC,GAAG,EAAE,qBAAU,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web-server/routes/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,qCAAiC;AAEjC,wBAAwB;AACxB,sEAA6C;AAC7C,sEAA6C;AAC7C,oEAA2C;AAC3C,oEAA2C;AAC3C,wEAA+C;AAC/C,sEAA6C;AAC7C,wEAA+C;AAC/C,0EAAiD;AACjD,kFAAwD;AACxD,oFAA0D;AAC1D,kFAAwD;AACxD,sEAA6C;AAC7C,gEAAuC;AACvC,kEAAkD;AAClD,gEAAuC;AACvC,sEAA6C;AAC7C,sEAA6C;AAE7C,6BAA6B;AAChB,QAAA,SAAS,GAAG,IAAA,gBAAM,GAAE,CAAC;AAElC,+DAA+D;AAC/D,uDAAuD;AACvD,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,wBAAa,CAAC,CAAC;AAC1C,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,yBAAc,CAAC,CAAC;AAC3C,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,wBAAa,CAAC,CAAC;AAE1C,2DAA2D;AAC3D,2BAA2B;AAC3B,iBAAS,CAAC,GAAG,CAAC,SAAS,EAAE,uBAAY,CAAC,CAAC;AAEvC,0DAA0D;AAC1D,iBAAS,CAAC,GAAG,CAAC,SAAS,EAAE,uBAAY,CAAC,CAAC;AAEvC,2DAA2D;AAC3D,iBAAS,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAU,CAAC,CAAC;AAEnC,wEAAwE;AACxE,iBAAS,CAAC,GAAG,CAAC,UAAU,EAAE,wBAAa,CAAC,CAAC;AAEzC,qDAAqD;AACrD,8DAA8D;AAC9D,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,wBAAa,CAAC,CAAC;AAC1C,iBAAS,CAAC,GAAG,CAAC,gBAAgB,EAAE,8BAAkB,CAAC,CAAC;AACpD,iBAAS,CAAC,GAAG,CAAC,WAAW,EAAE,+BAAmB,CAAC,CAAC;AAChD,iBAAS,CAAC,GAAG,CAAC,gBAAgB,EAAE,8BAAkB,CAAC,CAAC;AACpD,iBAAS,CAAC,GAAG,CAAC,mBAAmB,EAAE,wBAAa,CAAC,CAAC;AAClD,iBAAS,CAAC,GAAG,CAAC,yBAAyB,EAAE,yBAAc,CAAC,CAAC;AAEzD,sDAAsD;AACtD,iBAAS,CAAC,GAAG,CAAC,YAAY,EAAE,0BAAe,CAAC,CAAC;AAE7C,oDAAoD;AACpD,iBAAS,CAAC,GAAG,CAAC,UAAU,EAAE,wBAAa,CAAC,CAAC;AAEzC,qEAAqE;AACrE,iBAAS,CAAC,GAAG,CAAC,kBAAkB,EAAE,sBAAoB,CAAC,CAAC;AAExD,wEAAwE;AACxE,iBAAS,CAAC,GAAG,CAAC,GAAG,EAAE,qBAAU,CAAC,CAAC"}
|
package/package.json
CHANGED
package/scripts/code-reviewer.ts
CHANGED
|
@@ -26,7 +26,7 @@ interface PRContext {
|
|
|
26
26
|
// Config
|
|
27
27
|
const MAX_DIFF_LINES = 10000;
|
|
28
28
|
const CLIPROXY_URL = process.env.CLIPROXY_URL || 'http://localhost:8317';
|
|
29
|
-
const MODEL = process.env.REVIEW_MODEL || 'gemini-claude-opus-4-
|
|
29
|
+
const MODEL = process.env.REVIEW_MODEL || 'gemini-claude-opus-4-6-thinking';
|
|
30
30
|
|
|
31
31
|
// System prompt for code review - new style
|
|
32
32
|
const CODE_REVIEWER_SYSTEM_PROMPT = `You are the CCS AGY Code Reviewer, an expert AI assistant reviewing pull requests for the CCS CLI project.
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e,$ as Ns,a0 as ws}from"./radix-ui-qEZD5MMp.js";import{r as m}from"./react-vendor-CNOkPC89.js";import{a as je,u as ze,b as bs}from"./tanstack-De4wvi8X.js";import{b as y,C as Be,a as Ve,c as H,P as ce,L as se,I as ne,X as Qe,Y as Je,Z as We,_ as Xe,$ as de,a0 as Ye,a1 as ys,a2 as Cs,a3 as ks,u as Ze,a4 as ve,a5 as Ne,a6 as we,a7 as be,a8 as es,a9 as Ie,aa as Ss,ab as As,ac as Ps,ad as ss,ae as le,af as Ms,ag as _e,ah as Le,B as $,ai as Ts,q as ts,m as ye,l as Os,aj as Ds,ak as Rs,al as Es,am as X,T as Y,o as Z,p as ee,an as Is,ao as _s,ap as Ls,aq as Fe,ar as Fs,as as Us,at as Hs,au as Ks,av as Gs,aw as $s,ax as qs,H as zs,J as Bs,K as Ue,M as He,ay as Vs,az as Qs,aA as Js,aB as Ws,aC as Xs,aD as Ys,aE as Zs,aF as et,aG as st,aH as tt,aI as at,S as nt}from"./index-CiULLjNI.js";import{t as _}from"./notifications-B2HqRBj7.js";import{b as as,L as q,m as ue,y as it,j as B,l as ns,an as Ce,R as ke,n as te,a0 as re,ao as rt,ap as me,Z as xe,I as ot,f as lt,a2 as is,aq as ct,ah as dt,X as Se,$ as rs,s as os,t as he,ar as ut,T as mt,p as Ke,as as xt,ag as ls,q as pt,at as ht,k as gt,a1 as ft,ak as jt,au as cs}from"./icons-D5eAI-GR.js";import{S as Ae,C as vt}from"./confirm-dialog-Cy1__gRc.js";import{S as Nt}from"./switch-BCFbehJz.js";import{P as wt}from"./proxy-status-widget-BY6Lnr80.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BNRDV_Kh.js";const ie={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"gemini-claude-opus-4-5-thinking",models:[{id:"gemini-claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Most capable, extended thinking",presetMapping:{default:"gemini-claude-opus-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking",presetMapping:{default:"gemini-claude-sonnet-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable",presetMapping:{default:"gemini-claude-sonnet-4-5",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.2-codex",models:[{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Full reasoning support (xhigh)",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Fast, capped at high reasoning (no xhigh)",presetMapping:{default:"gpt-5-mini",opus:"gpt-5.2-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Legacy most capable Codex model",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen-coder-plus",models:[{id:"qwen-coder-plus",name:"Qwen Coder Plus",description:"Alibaba code-focused model"},{id:"qwen-max",name:"Qwen Max",description:"Most capable Qwen model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-5",models:[{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-5-20250929",models:[{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}},ge=8317,pe="ccs-internal-managed";async function bt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??pe:pe}catch{return pe}}async function fe(s,a){const t=ie[s];if(!t)return{success:!1};const i=t.models[0],r=i?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},u=await bt(),p={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${ge}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:u,ANTHROPIC_MODEL:r.default,ANTHROPIC_DEFAULT_OPUS_MODEL:r.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:r.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:r.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:p})})).ok,presetName:i?.name||t.defaultModel}}catch{return{success:!1}}}function yt({currentProgress:s,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((t,i)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=i?"bg-primary":"bg-muted"}`},t))})}function Ct({providers:s,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(as,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function kt({selectedProvider:s,providers:a,authCommand:t,isRefreshing:i,isPending:r,onBack:u,onStartAuth:c,onRefresh:p}){const[d,g]=m.useState(!1),j=async h=>{await navigator.clipboard.writeText(h),g(!0),setTimeout(()=>g(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",a.find(h=>h.id===s)?.name," to add an account"]}),e.jsx(y,{onClick:c,disabled:r,className:"w-full gap-2",size:"lg",children:r?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(Be,{children:e.jsxs(Ve,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(it,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:t}),e.jsx(y,{variant:"outline",size:"icon",onClick:()=>j(t),children:d?e.jsx(B,{className:"w-4 h-4 text-green-500"}):e.jsx(ns,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(y,{variant:"ghost",onClick:u,disabled:r,children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(y,{variant:"outline",onClick:p,disabled:i||r,children:[e.jsx(ke,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),i?"Checking...":"Refresh Status"]})]})]})}function St({accounts:s,privacyMode:a,onSelect:t,onAddNew:i,onBack:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:s.map(u=>e.jsxs("button",{type:"button",onClick:()=>t(u),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(te,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:H("font-medium",a&&ce),children:u.email||u.id}),u.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(as,{className:"w-4 h-4 text-muted-foreground"})]},u.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:i,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ue,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(y,{variant:"ghost",onClick:r,children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const Ge="__custom__";function At({selectedProvider:s,selectedAccount:a,variantName:t,modelName:i,isPending:r,privacyMode:u,onVariantNameChange:c,onModelChange:p,onBack:d,onSkip:g,onCreate:j}){const h=ie[s]?.models||[],n=i&&!h.some(x=>x.id===i),[l,f]=m.useState(n),w=x=>{x===Ge?(f(!0),p("")):(f(!1),p(x))};return e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(te,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:H(u&&ce),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ne,{id:"variant-name",value:t,onChange:x=>c(x.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Model"}),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{value:i,onChange:x=>p(x.target.value),placeholder:"e.g., gemini-2.5-pro, claude-opus-4-5"}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>f(!1),children:"Choose from presets instead"})]}):e.jsxs(Qe,{value:h.some(x=>x.id===i)?i:"",onValueChange:w,children:[e.jsx(Je,{children:e.jsx(We,{placeholder:"Select a model"})}),e.jsxs(Xe,{children:[h.map(x=>e.jsx(de,{value:x.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:x.name}),x.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",x.description]})]})},x.id)),e.jsx(de,{value:Ge,children:e.jsx("span",{className:"text-primary",children:"Custom model name..."})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l?"Enter any model name supported by CLIProxy":`Default: ${ie[s]?.defaultModel||"provider default"}`})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(y,{variant:"ghost",onClick:d,children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"ghost",onClick:g,children:"Skip"}),e.jsx(y,{onClick:j,disabled:!t||r,children:r?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]})}function Pt({variantName:s,onClose:a}){return e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(B,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(Be,{children:e.jsxs(Ve,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(y,{onClick:a,className:"w-full",children:"Done"})]})}function Mt({open:s,onClose:a}){const[t,i]=m.useState("provider"),[r,u]=m.useState(""),[c,p]=m.useState(null),[d,g]=m.useState(""),[j,h]=m.useState(""),[n,l]=m.useState(!1),[f,w]=m.useState(!1),{data:x,refetch:A}=Ye(),I=ys(),E=Cs(),O=ks(),{privacyMode:D}=Ze(),v=x?.authStatus.find(S=>S.provider===r),T=m.useMemo(()=>v?.accounts||[],[v?.accounts]);m.useEffect(()=>{if(!s){const S=setTimeout(()=>{i("provider"),u(""),p(null),g(""),h(""),w(!1)},0);return()=>clearTimeout(S)}},[s]),m.useEffect(()=>{if(t==="auth"&&T.length>0&&!f){const S=setTimeout(()=>{i("account")},0);return()=>clearTimeout(S)}},[t,T,f]);const b=async()=>{l(!0),await A(),l(!1)},N=()=>{const S=(v?.accounts?.length||0)===0;E.mutate({provider:r},{onSuccess:async C=>{if(S){const L=await fe(r);L.success&&L.presetName?_.success(`Applied "${L.presetName}" preset`):L.success||_.warning("Account added, but failed to apply default preset")}C.account&&(p(C.account),i("variant")),A()}})},R=S=>{u(S),(x?.authStatus.find(G=>G.provider===S)?.accounts||[]).length===0?i("auth"):i("account")},P=S=>{p(S),i("variant")},k=async()=>{if(!(!d||!r))try{await I.mutateAsync({name:d,provider:r,model:j||void 0,account:c?.id}),i("success")}catch(S){console.error("Failed to create variant:",S)}},F=`ccs ${r} --auth --add`,K=As(t),z=S=>{if(!S&&(E.isPending&&r&&O.mutate(r),t==="success"||t==="provider")){a();return}};return e.jsx(ve,{open:s,onOpenChange:z,children:e.jsxs(Ne,{className:"sm:max-w-lg",onPointerDownOutside:S=>{t!=="success"&&t!=="provider"&&S.preventDefault()},onEscapeKeyDown:S=>{(E.isPending||I.isPending)&&S.preventDefault()},children:[e.jsxs(we,{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(re,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(es,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx(Ct,{providers:Ie,onSelect:R}),t==="auth"&&e.jsx(kt,{selectedProvider:r,providers:Ie,authCommand:F,isRefreshing:n,isPending:E.isPending,onBack:()=>i("provider"),onStartAuth:N,onRefresh:b}),t==="account"&&e.jsx(St,{accounts:T,privacyMode:D,onSelect:P,onAddNew:()=>{w(!0),i("auth")},onBack:()=>i("provider")}),t==="variant"&&e.jsx(At,{selectedProvider:r,selectedAccount:c,variantName:d,modelName:j,isPending:I.isPending,privacyMode:D,onVariantNameChange:g,onModelChange:h,onBack:()=>T.length>0?i("account"):i("provider"),onSkip:a,onCreate:k}),t==="success"&&e.jsx(Pt,{variantName:d,onClose:a})]}),e.jsx(yt,{currentProgress:K,allSteps:Ss})]})})}const Tt=3e3,Ot=300*1e3,J={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function Dt(){const[s,a]=m.useState(J),t=m.useRef(null),i=m.useRef(null),r=m.useRef(0),u=je(),c=m.useCallback(()=>{i.current&&(clearInterval(i.current),i.current=null)},[]);m.useEffect(()=>()=>{t.current?.abort(),c()},[c]);const p=m.useCallback(async(h,n)=>{if(Date.now()-r.current>Ot){c(),a(l=>({...l,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const f=await(await fetch(`/api/cliproxy/auth/${h}/status?state=${encodeURIComponent(n)}`)).json();if(f.status==="ok")c(),u.invalidateQueries({queryKey:["cliproxy-auth"]}),u.invalidateQueries({queryKey:["account-quota"]}),_.success(`${h} authentication successful`),a(J);else if(f.status==="error"){c();const w=f.error||"Authentication failed";_.error(w),a(x=>({...x,isAuthenticating:!1,error:w}))}}catch{}},[u,c]),d=m.useCallback(async(h,n)=>{if(!Ps(h)){a({...J,error:`Unknown provider: ${h}`});return}t.current?.abort(),c();const l=new AbortController;t.current=l;const f=ss(h);a({provider:h,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:f});try{if(f)fetch(`/api/cliproxy/auth/${h}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nickname:n?.nickname}),signal:l.signal}).then(async w=>{const x=await w.json();if(w.ok&&x.success)u.invalidateQueries({queryKey:["cliproxy-auth"]}),u.invalidateQueries({queryKey:["account-quota"]}),a(J);else{const A=x.error||"Authentication failed";_.error(A),a(I=>({...I,isAuthenticating:!1,error:A}))}}).catch(w=>{if(w instanceof Error&&w.name==="AbortError")return;const x=w instanceof Error?w.message:"Authentication failed";_.error(x),a(A=>({...A,isAuthenticating:!1,error:x}))});else{const w=await fetch(`/api/cliproxy/auth/${h}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nickname:n?.nickname}),signal:l.signal}),x=await w.json();if(!w.ok||!x.success)throw new Error(x.error||"Failed to start OAuth");a(A=>({...A,authUrl:x.authUrl,oauthState:x.state})),x.authUrl&&window.open(x.authUrl,"_blank"),x.state&&(r.current=Date.now(),i.current=setInterval(()=>{p(h,x.state)},Tt))}}catch(w){if(w instanceof Error&&w.name==="AbortError"){a(J);return}const x=w instanceof Error?w.message:"Authentication failed";_.error(x),a(A=>({...A,isAuthenticating:!1,error:x}))}},[p,c,u]),g=m.useCallback(()=>{const h=s.provider;t.current?.abort(),c(),a(J),h&&le.cliproxy.auth.cancel(h).catch(()=>{})},[s.provider,c]),j=m.useCallback(async h=>{if(s.provider){a(n=>({...n,isSubmittingCallback:!0,error:null}));try{const n=await fetch(`/api/cliproxy/auth/${s.provider}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:h})}),l=await n.json();if(n.ok&&l.success)c(),u.invalidateQueries({queryKey:["cliproxy-auth"]}),u.invalidateQueries({queryKey:["account-quota"]}),_.success(`${s.provider} authentication successful`),a(J);else throw new Error(l.error||"Callback submission failed")}catch(n){const l=n instanceof Error?n.message:"Failed to submit callback";_.error(l),a(f=>({...f,isSubmittingCallback:!1,error:l}))}}},[s.provider,u,c]);return m.useMemo(()=>({...s,startAuth:d,cancelAuth:g,submitCallback:j}),[s,d,g,j])}function Rt({open:s,onClose:a,provider:t,displayName:i,isFirstAccount:r=!1}){const[u,c]=m.useState(""),[p,d]=m.useState(""),[g,j]=m.useState(!1),h=m.useRef(!1),n=Dt(),l=Ms(),f=t==="kiro",w=ss(t),x=n.isAuthenticating||l.isPending,A=()=>{c(""),d(""),j(!1),h.current=!1,a()};m.useEffect(()=>{!n.isAuthenticating&&!n.error&&n.provider===null&&s&&h.current&&(h.current=!1,(async()=>{try{const R=await fe(t);R.success&&R.presetName&&r&&_.success(`Applied "${R.presetName}" preset`)}catch{}A()})())},[n.isAuthenticating,n.error,n.provider]);const I=()=>{n.cancelAuth(),A()},E=async()=>{n.authUrl&&(await navigator.clipboard.writeText(n.authUrl),j(!0),setTimeout(()=>j(!1),2e3))},O=()=>{p.trim()&&n.submitCallback(p.trim())},D=()=>{h.current=!0,n.startAuth(t,{nickname:u.trim()||void 0})},v=()=>{h.current=!0,l.mutate(void 0,{onSuccess:async()=>{const N=await fe("kiro");N.success&&N.presetName&&r&&_.success(`Applied "${N.presetName}" preset`),A()}})},T=N=>{N||I()},b=n.isAuthenticating;return e.jsx(ve,{open:s,onOpenChange:T,children:e.jsxs(Ne,{className:"sm:max-w-md",onInteractOutside:N=>{b&&N.preventDefault()},children:[e.jsxs(we,{children:[e.jsxs(be,{children:["Add ",i," Account"]}),e.jsx(es,{children:f?"Authenticate via browser or import an existing token from Kiro IDE.":w?"Click Authenticate. A verification code will appear for you to enter on the provider website.":"Click Authenticate to get an OAuth URL. Open it in any browser to sign in."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[!b&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ne,{id:"nickname",value:u,onChange:N=>c(N.target.value),placeholder:"e.g., work, personal",disabled:x,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A friendly name to identify this account. Auto-generated from email if left empty."})]}),b&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx(q,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Waiting for authentication..."]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:n.isDeviceCodeFlow?"A verification code dialog will appear shortly. Enter the code on the provider website.":"Complete the authentication in your browser. This dialog closes automatically."})]}),n.error&&!n.authUrl&&e.jsx("p",{className:"text-xs text-center text-destructive",children:n.error}),n.authUrl&&!n.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{className:"text-xs",children:"Open this URL in any browser to sign in:"}),e.jsxs("div",{className:"p-3 bg-muted rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground break-all font-mono line-clamp-3",children:n.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:E,children:g?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-3 h-3 mr-1"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-3 h-3 mr-1"}),"Copy"]})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>{if(!n.authUrl)return;const N=window.open(n.authUrl,"_blank");(!N||N.closed||typeof N.closed>"u")&&_.warning("Popup blocked. Copy the URL above and open it manually in your browser.",{duration:5e3})},children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),"Open"]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"callback-url",className:"text-xs",children:"Redirect didn't work? Paste the callback URL:"}),e.jsx(ne,{id:"callback-url",value:p,onChange:N=>d(N.target.value),placeholder:"Paste the redirect URL here...",className:"font-mono text-xs"}),e.jsx(y,{variant:"secondary",size:"sm",onClick:O,disabled:!p.trim()||n.isSubmittingCallback,children:n.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-3 h-3 mr-1 animate-spin"}),"Submitting..."]}):"Submit Callback"})]})]})]}),l.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(q,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Importing token from Kiro IDE..."]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(y,{variant:"ghost",onClick:I,children:"Cancel"}),f&&!b&&e.jsx(y,{variant:"outline",onClick:v,disabled:x,children:l.isPending?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 mr-2 animate-spin"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"w-4 h-4 mr-2"}),"Import from IDE"]})}),!b&&e.jsxs(y,{onClick:D,disabled:x,children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),"Authenticate"]})]})]})]})})}const Et=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function It(s){const a=s?.env||{};return Et.filter(t=>!a[t]?.trim())}function _t(s){const[a,t]=m.useState(null),[i,r]=m.useState(!1),u=je(),{data:c,isLoading:p,refetch:d}=ze({queryKey:["settings",s],queryFn:async()=>{const b=await fetch(`/api/settings/${s}/raw`);return b.ok?b.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),g=c?.settings,j=m.useMemo(()=>a!==null?a:g?JSON.stringify(g,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[a,g]),h=m.useCallback(b=>{t(b)},[]),n=m.useMemo(()=>{try{return JSON.parse(j)}catch{return g||{env:{}}}},[j,g]),l=n?.env?.ANTHROPIC_MODEL,f=n?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,w=n?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,x=n?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,A=m.useCallback((b,N)=>{const R={...n?.env||{},[b]:N},P={...n,env:R};t(JSON.stringify(P,null,2))},[n]),I=m.useCallback(b=>{const N={...n?.env||{},...b},R={...n,env:N};t(JSON.stringify(R,null,2))},[n]),E=m.useMemo(()=>{try{return JSON.parse(j),!0}catch{return!1}},[j]),O=m.useMemo(()=>a===null?!1:a!==JSON.stringify(g,null,2),[a,g]),D=m.useMemo(()=>It(n),[n]),v=bs({mutationFn:async()=>{const b=JSON.parse(j),N=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:b,expectedMtime:c?.mtime})});if(N.status===409)throw new Error("CONFLICT");if(!N.ok)throw new Error("Failed to save");return N.json()},onSuccess:b=>{u.invalidateQueries({queryKey:["settings",s]}),t(null),b?.warning?_.success("Settings saved",{description:b.warning}):_.success("Settings saved")},onError:b=>{b.message==="CONFLICT"?r(!0):_.error(b.message)}}),T=async b=>{r(!1),b?(await d(),v.mutate()):t(null)};return{data:c,isLoading:p,refetch:d,rawJsonContent:j,rawJsonEdits:a,isRawJsonValid:E,hasChanges:O,currentSettings:n,currentModel:l,opusModel:f,sonnetModel:w,haikuModel:x,handleRawJsonChange:h,updateEnvValue:A,updateEnvValues:I,saveMutation:{mutate:()=>v.mutate(),isPending:v.isPending},conflictDialog:i,setConflictDialog:r,handleConflictResolve:T,missingRequiredFields:D}}function Q({label:s,description:a,value:t,onChange:i,catalog:r,allModels:u,disabled:c}){const p=new Set(r?.models.map(d=>d.id)||[]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(Qe,{value:t||"",onValueChange:i,disabled:c,children:[e.jsx(Je,{className:"h-9",children:e.jsx(We,{placeholder:"Select model",children:t&&e.jsx("span",{className:"truncate font-mono text-xs",children:t})})}),e.jsxs(Xe,{className:"max-h-[300px]",children:[r&&r.models.length>0&&e.jsxs(_e,{children:[e.jsx(Le,{className:"text-xs text-primary",children:"Recommended"}),r.models.map(d=>e.jsx(de,{value:d.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:d.id}),d.tier==="paid"&&e.jsx($,{variant:"outline",className:"text-[9px] h-4 px-1",children:"PAID"}),t===d.id&&e.jsx(B,{className:"w-3 h-3 text-primary ml-auto"})]})},d.id))]}),u.length>0&&e.jsxs(_e,{children:[e.jsxs(Le,{className:"text-xs text-muted-foreground",children:["All Models (",u.length,")"]}),u.filter(d=>!p.has(d.id)).map(d=>e.jsx(de,{value:d.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:d.id}),t===d.id&&e.jsx(B,{className:"w-3 h-3 text-primary ml-auto"})]})},d.id))]}),(!r||r.models.length===0)&&u.length===0&&e.jsx("div",{className:"py-2 px-3 text-xs text-muted-foreground",children:"No models available"})]})]})]})}function Lt({open:s,onClose:a,currentValues:t,onApply:i,onSave:r,isSaving:u,catalog:c,allModels:p}){const[d,g]=m.useState(t),[j,h]=m.useState(""),n=l=>{l?(g(t),h("")):a()};return e.jsx(ve,{open:s,onOpenChange:n,children:e.jsxs(Ne,{className:"sm:max-w-md",children:[e.jsx(we,{children:e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Custom Preset"]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"preset-name",children:"Preset Name (optional)"}),e.jsx(ne,{id:"preset-name",value:j,onChange:l=>h(l.target.value),placeholder:"e.g., My Custom Config",className:"text-sm"})]}),e.jsx(Ae,{}),e.jsx(Q,{label:"Default Model",description:"Used when no specific tier is requested",value:d.default,onChange:l=>g({...d,default:l}),catalog:c,allModels:p}),e.jsx(Q,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:d.opus,onChange:l=>g({...d,opus:l}),catalog:c,allModels:p}),e.jsx(Q,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:d.sonnet,onChange:l=>g({...d,sonnet:l}),catalog:c,allModels:p}),e.jsx(Q,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d.haiku,onChange:l=>g({...d,haiku:l}),catalog:c,allModels:p})]}),e.jsxs(Ts,{className:"gap-2 sm:gap-0",children:[e.jsx(y,{variant:"outline",onClick:a,children:"Cancel"}),r&&e.jsxs(y,{variant:"secondary",onClick:()=>r(d,j||void 0),disabled:u||!j.trim(),children:[u?e.jsx(q,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(me,{className:"w-4 h-4 mr-1"}),"Save Preset"]}),e.jsxs(y,{onClick:()=>i(d,j||void 0),children:[e.jsx(xe,{className:"w-4 h-4 mr-1"}),"Apply Preset"]})]})]})})}function oe({label:s,command:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:a}),e.jsx(ts,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function Ft({provider:s,displayName:a,data:t,authStatus:i}){return e.jsx(ye,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ot,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:a})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(ts,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(t.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),i.authenticated?e.jsxs($,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(lt,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx($,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(oe,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(oe,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(oe,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(oe,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}const Ut={gemini:"/assets/providers/gemini-color.svg",codex:"/assets/providers/openai.svg",agy:"/assets/providers/agy.png",qwen:"/assets/providers/qwen-color.svg",iflow:"/assets/providers/iflow.png",kiro:"/assets/providers/kiro.png",ghcp:"/assets/providers/copilot.svg",claude:"/assets/providers/claude.svg"},Ht={gemini:{text:"text-blue-600",letter:"G"},claude:{text:"text-orange-600",letter:"C"},codex:{text:"text-emerald-600",letter:"X"},agy:{text:"text-violet-600",letter:"A"},qwen:{text:"text-cyan-600",letter:"Q"},iflow:{text:"text-indigo-600",letter:"i"},kiro:{text:"text-teal-600",letter:"K"},ghcp:{text:"text-green-600",letter:"C"}},Kt={sm:{container:"w-6 h-6",icon:"w-4 h-4",text:"text-xs"},md:{container:"w-8 h-8",icon:"w-5 h-5",text:"text-sm"},lg:{container:"w-12 h-12",icon:"w-8 h-8",text:"text-lg"}};function Pe({provider:s,className:a,size:t="md"}){const i=s.toLowerCase(),r=Ht[i]||{text:"text-gray-600",letter:s[0]?.toUpperCase()||"?"},u=Kt[t],c=Ut[i];return e.jsx("div",{className:H("flex items-center justify-center rounded-md",c&&"bg-white p-1",u.container,a),children:c?e.jsx("img",{src:c,alt:`${s} logo`,className:H(u.icon,"object-contain")}):e.jsx("span",{className:H("font-semibold",r.text,u.text),children:r.letter})})}function Gt({displayName:s,logoProvider:a,provider:t,data:i,isLoading:r,hasChanges:u,isRawJsonValid:c,isSaving:p,isRemoteMode:d,port:g,onRefetch:j,onSave:h}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pe,{provider:a||t,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),d&&e.jsxs($,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(is,{className:"w-3 h-3"}),"Remote"]}),g&&e.jsxs($,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(ct,{className:"w-3 h-3"}),":",g]}),!d&&i?.path&&e.jsx($,{variant:"outline",className:"text-xs",children:i.path.replace(/^.*[\\/]/,"")})]}),d?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(i.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:j,disabled:r,children:e.jsx(ke,{className:`w-4 h-4 ${r?"animate-spin":""}`})}),e.jsx(y,{size:"sm",onClick:h,disabled:p||!u||!c,children:p?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(dt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function $t({catalog:s,savedPresets:a,currentModel:t,opusModel:i,sonnetModel:r,haikuModel:u,providerModels:c,onApplyPreset:p,onUpdateEnvValue:d,onOpenCustomPreset:g,onDeletePreset:j,isDeletePending:h}){const n=s&&s.models.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[n&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s?.models.slice(0,4).map(l=>e.jsxs(y,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>{const f=l.presetMapping||{default:l.id,opus:l.id,sonnet:l.id,haiku:l.id};p({ANTHROPIC_MODEL:f.default,ANTHROPIC_DEFAULT_OPUS_MODEL:f.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:f.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:f.haiku})},children:[e.jsx(xe,{className:"w-3 h-3"}),l.name]},l.id)),a.map(l=>e.jsxs("div",{className:"group relative",children:[e.jsxs(y,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{p({ANTHROPIC_MODEL:l.default,ANTHROPIC_DEFAULT_OPUS_MODEL:l.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:l.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:l.haiku})},children:[e.jsx(me,{className:"w-3 h-3 fill-current"}),l.name]}),e.jsx(y,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:f=>{f.stopPropagation(),j(l.name)},disabled:h,children:e.jsx(Se,{className:"w-3 h-3"})})]},l.name)),e.jsxs(y,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:g,children:[e.jsx(rs,{className:"w-3 h-3"}),"Custom"]})]})]}),e.jsx(Ae,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Q,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:l=>d("ANTHROPIC_MODEL",l),catalog:s,allModels:c}),e.jsx(Q,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:i,onChange:l=>d("ANTHROPIC_DEFAULT_OPUS_MODEL",l),catalog:s,allModels:c}),e.jsx(Q,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:r,onChange:l=>d("ANTHROPIC_DEFAULT_SONNET_MODEL",l),catalog:s,allModels:c}),e.jsx(Q,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:u,onChange:l=>d("ANTHROPIC_DEFAULT_HAIKU_MODEL",l),catalog:s,allModels:c})]})]})]})}function qt({className:s,...a}){return e.jsx(Ns,{"data-slot":"checkbox",className:H("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",s),...a,children:e.jsx(ws,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:e.jsx(B,{className:"size-3.5"})})})}function zt(s){const a=Math.max(0,Math.min(100,s));return a<=20?"bg-destructive":a<=50?"bg-yellow-500":"bg-green-500"}function $e(s){if(!s)return"";try{const a=new Date(s),i=new Date().getTime()-a.getTime();if(i<0)return"just now";const r=Math.floor(i/(1e3*60)),u=Math.floor(i/(1e3*60*60)),c=Math.floor(i/(1e3*60*60*24));return c>0?`${c}d ago`:u>0?`${u}h ago`:r>0?`${r}m ago`:"just now"}catch{return""}}function Bt(s){if(!s)return!1;try{const a=new Date(s);return new Date().getTime()-a.getTime()<3600*1e3}catch{return!1}}function Vt({account:s,onSetDefault:a,onRemove:t,onPauseToggle:i,isRemoving:r,isPausingAccount:u,privacyMode:c,showQuota:p,selectable:d,selected:g,onSelectChange:j}){const{data:h}=Os(p),{data:n,isLoading:l}=Ds(s.provider,s.id,p),f=h?.accountStats?.[s.email||s.id]?.lastUsedAt,w=Bt(f),x=Rs(s.provider,n),A=Es(s.provider,n);return e.jsxs("div",{className:H("flex flex-col gap-2 p-3 rounded-lg border transition-colors overflow-hidden",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",g&&"ring-2 ring-primary/50 bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[d&&e.jsx("button",{type:"button",onClick:()=>j?.(!g),className:H("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",g?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":g?"Deselect account":"Select account",children:g&&e.jsx(B,{className:"w-3 h-3"})}),i&&e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>i(!s.paused),disabled:u,children:u?e.jsx(q,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(os,{className:"w-4 h-4 text-emerald-500"}):e.jsx(he,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ee,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:H("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(te,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:H("absolute -bottom-0.5 -right-0.5 text-[7px] font-bold uppercase px-1 py-px rounded","ring-1 ring-background",s.tier==="ultra"?"bg-violet-500/20 text-violet-600 dark:bg-violet-500/30 dark:text-violet-300":"bg-yellow-500/20 text-yellow-700 dark:bg-yellow-500/25 dark:text-yellow-400"),children:s.tier==="ultra"?"U":"P"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:H("font-medium text-sm truncate",c&&ce),children:s.email||s.id}),s.isDefault&&e.jsxs($,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(me,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs($,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(he,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.provider==="agy"&&e.jsx("div",{className:"flex items-center gap-1.5 mt-1",children:s.projectId?e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ut,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:H("font-mono max-w-[180px] truncate",c&&ce),title:s.projectId,children:s.projectId})]})}),e.jsx(ee,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(mt,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(ee,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(Ke,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(Is,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(xt,{className:"w-4 h-4"})})}),e.jsxs(Ls,{align:"end",children:[!s.isDefault&&e.jsxs(Fe,{onClick:a,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Fe,{className:"text-destructive focus:text-destructive",onClick:t,disabled:r,children:[e.jsx(ls,{className:"w-4 h-4 mr-2"}),r?"Removing...":"Remove account"]})]})]})]}),p&&e.jsx("div",{className:"pl-11",children:l?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(q,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):x!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:w?e.jsxs(e.Fragment,{children:[e.jsx(pt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",$e(f)]})]}):f?e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",$e(f)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ht,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fs,{value:Math.max(0,Math.min(100,x)),className:"h-2 flex-1",indicatorClassName:zt(x)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[x,"%"]})]})}),e.jsx(ee,{side:"bottom",className:"max-w-xs",children:n&&e.jsx(Us,{quota:n,resetTime:A})})]})})]}):n?.needsReauth?e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs($,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-amber-500/50 text-amber-600 dark:text-amber-400",children:[e.jsx(gt,{className:"w-3 h-3"}),"Reauth"]})})}),e.jsx(ee,{side:"bottom",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:n.error?.includes("No refresh token")?"No refresh token available. Remove and re-add account to fix.":n.error?.includes("refresh")||n.error?.includes("Invalid")?`Auto-refresh failed: ${n.error}`:`Token issue: ${n.error||"Re-authenticate required"}`})})]})}):n?.error||n&&!n.success?e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs($,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(ft,{className:"w-3 h-3"}),"N/A"]})})}),e.jsx(ee,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:n?.error||"Quota information unavailable"})})]})}):null})]})}function Qt({selectedCount:s,onPauseSelected:a,onResumeSelected:t,onClearSelection:i,isPausing:r,isResuming:u}){if(s<1)return null;const c=r||u;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," selected"]}),e.jsx(y,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:i,disabled:c,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(y,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:c,children:[r?e.jsx(q,{className:"w-3 h-3 animate-spin"}):e.jsx(he,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(y,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:c,children:[u?e.jsx(q,{className:"w-3 h-3 animate-spin"}):e.jsx(os,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Jt({accounts:s,onAddAccount:a,onSetDefault:t,onRemoveAccount:i,onPauseToggle:r,onSoloMode:u,onBulkPause:c,onBulkResume:p,isRemovingAccount:d,isPausingAccount:g,isSoloingAccount:j,isBulkPausing:h,isBulkResuming:n,privacyMode:l,showQuota:f,isKiro:w,kiroNoIncognito:x,onKiroNoIncognitoChange:A,kiroSettingsLoading:I}){const[E,O]=m.useState(new Set),D=m.useMemo(()=>new Set(s.map(C=>C.id)),[s]),v=m.useMemo(()=>new Set([...E].filter(C=>D.has(C))),[E,D]),T=!!(c&&p),b=v.size,N=s.length>0&&v.size===s.length,R=v.size>0&&v.size<s.length,P=m.useCallback(C=>{O(L=>{const G=new Set(L);return G.has(C)?G.delete(C):G.add(C),G})},[]),k=m.useCallback(()=>{O(new Set(s.map(C=>C.id)))},[s]),F=m.useCallback(()=>{O(new Set)},[]),K=m.useCallback(()=>{N?F():k()},[N,k,F]),z=m.useCallback(()=>{c&&v.size>0&&(c(Array.from(v)),O(new Set))},[c,v]),S=m.useCallback(()=>{p&&v.size>0&&(p(Array.from(v)),O(new Set))},[p,v]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[T&&s.length>0&&e.jsx(qt,{checked:N,onCheckedChange:K,"aria-label":"Select all accounts",className:R?"data-[state=checked]:bg-primary/50":"",...R?{"data-state":"indeterminate"}:{}}),e.jsx(te,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx($,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(y,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(rs,{className:"w-3 h-3"}),"Add"]})]}),T&&b>0&&e.jsx(Qt,{selectedCount:b,onPauseSelected:z,onResumeSelected:S,onClearSelection:F,isPausing:!!h,isResuming:!!n}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(C=>e.jsx(Vt,{account:C,onSetDefault:()=>t(C.id),onRemove:()=>i(C.id),onPauseToggle:r?L=>r(C.id,L):void 0,onSoloMode:u?()=>u(C.id):void 0,isRemoving:d,isPausingAccount:g,isSoloingAccount:j,privacyMode:l,showQuota:f,selectable:T,selected:v.has(C.id),onSelectChange:()=>P(C.id)},C.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(te,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),w&&A&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(is,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Nt,{checked:!x,onCheckedChange:C=>A(!C),disabled:I,className:"scale-90"})]})})]})}function Wt({provider:s,catalog:a,savedPresets:t,currentModel:i,opusModel:r,sonnetModel:u,haikuModel:c,providerModels:p,onApplyPreset:d,onUpdateEnvValue:g,onOpenCustomPreset:j,onDeletePreset:h,isDeletePending:n,accounts:l,onAddAccount:f,onSetDefault:w,onRemoveAccount:x,onPauseToggle:A,onSoloMode:I,onBulkPause:E,onBulkResume:O,isRemovingAccount:D,isPausingAccount:v,isSoloingAccount:T,isBulkPausing:b,isBulkResuming:N,privacyMode:R,isRemoteMode:P}){const k=s==="kiro",[F,K]=m.useState(!0),[z,S]=m.useState(!0),[C,L]=m.useState(!1),G=m.useCallback(async()=>{if(k)try{S(!0);const M=(await le.config.get()).cliproxy;K(M?.kiro_no_incognito??!0)}catch{K(!0)}finally{S(!1)}},[k]),ae=m.useCallback(async o=>{K(o),L(!0);try{const M=await le.config.get(),W=M.cliproxy??{};await le.config.update({...M,cliproxy:{...W,kiro_no_incognito:o}})}catch{K(!o)}finally{L(!1)}},[]);return m.useEffect(()=>{G()},[G]),e.jsx(ye,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx($t,{catalog:a,savedPresets:t,currentModel:i,opusModel:r,sonnetModel:u,haikuModel:c,providerModels:p,onApplyPreset:d,onUpdateEnvValue:g,onOpenCustomPreset:j,onDeletePreset:h,isDeletePending:n}),e.jsx(Ae,{}),e.jsx(Jt,{accounts:l,onAddAccount:f,onSetDefault:w,onRemoveAccount:x,onPauseToggle:A,onSoloMode:I,onBulkPause:E,onBulkResume:O,isRemovingAccount:D,isPausingAccount:v,isSoloingAccount:T,isBulkPausing:b,isBulkResuming:N,privacyMode:R,showQuota:Hs.includes(s)&&!P,isKiro:k,kiroNoIncognito:F,onKiroNoIncognitoChange:ae,kiroSettingsLoading:z||C})]})})}function qe({provider:s,displayName:a,authStatus:t,catalog:i,logoProvider:r,baseProvider:u,isRemoteMode:c,port:p,onAddAccount:d,onSetDefault:g,onRemoveAccount:j,onPauseToggle:h,onSoloMode:n,onBulkPause:l,onBulkResume:f,isRemovingAccount:w,isPausingAccount:x,isSoloingAccount:A,isBulkPausing:I,isBulkResuming:E}){const[O,D]=m.useState(!1),{privacyMode:v}=Ze(),{data:T}=Ks(),{data:b}=Gs(s),N=$s(),R=qs(),P=b?.presets||[],k=u||s,F=m.useMemo(()=>{if(!T?.models)return[];const V={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"]}[k.toLowerCase()]||[k.toLowerCase()];return T.models.filter(Ee=>V.some(vs=>Ee.owned_by.toLowerCase().includes(vs)))},[T,k]),{data:K,isLoading:z,refetch:S,rawJsonContent:C,rawJsonEdits:L,isRawJsonValid:G,hasChanges:ae,currentModel:o,opusModel:M,sonnetModel:W,haikuModel:Me,handleRawJsonChange:ds,updateEnvValue:us,updateEnvValues:Te,saveMutation:Oe,conflictDialog:ms,handleConflictResolve:De,missingRequiredFields:xs}=_t(s),ps=t.accounts||[],{data:hs}=ze({queryKey:["auth-tokens-raw"],queryFn:async()=>{const U=await fetch("/api/settings/auth/tokens/raw");return U.ok?U.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),Re=hs?.apiKey?.value??"ccs-internal-managed",gs=U=>{Te({ANTHROPIC_BASE_URL:`http://127.0.0.1:${p??ge}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:Re,...U}),_.success(`Applied "${U.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},fs=(U,V)=>{Te({ANTHROPIC_BASE_URL:`http://127.0.0.1:${p??ge}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:Re,ANTHROPIC_MODEL:U.default,ANTHROPIC_DEFAULT_OPUS_MODEL:U.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:U.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:U.haiku}),_.success(`Applied ${V?`"${V}"`:"custom"} preset`),D(!1)},js=(U,V)=>{if(!V){_.error("Please enter a preset name to save");return}N.mutate({profile:s,data:{name:V,...U}}),D(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Gt,{provider:s,displayName:a,logoProvider:r,data:K,isLoading:z,hasChanges:ae,isRawJsonValid:G,isSaving:Oe.isPending,isRemoteMode:c,port:p,onRefetch:S,onSave:()=>Oe.mutate()}),z?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(q,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(zs,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Bs,{className:"w-full",children:[e.jsx(Ue,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Ue,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(He,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Wt,{provider:s,catalog:i,savedPresets:P,currentModel:o,opusModel:M,sonnetModel:W,haikuModel:Me,providerModels:F,onApplyPreset:gs,onUpdateEnvValue:us,onOpenCustomPreset:()=>D(!0),onDeletePreset:U=>R.mutate({profile:s,name:U}),isDeletePending:R.isPending,accounts:ps,onAddAccount:d,onSetDefault:g,onRemoveAccount:j,onPauseToggle:h,onSoloMode:n,onBulkPause:l,onBulkResume:f,isRemovingAccount:w,isPausingAccount:x,isSoloingAccount:A,isBulkPausing:I,isBulkResuming:E,privacyMode:v,isRemoteMode:c})}),e.jsx(He,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Ft,{provider:s,displayName:a,data:K,authStatus:t})})]})]})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(jt,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(Vs,{rawJsonContent:C,isRawJsonValid:G,rawJsonEdits:L,onRawJsonChange:ds,profileEnv:K?.settings?.env,missingRequiredFields:xs})]})]}),e.jsx(vt,{open:ms,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>De(!0),onCancel:()=>De(!1)}),e.jsx(Lt,{open:O,onClose:()=>D(!1),currentValues:{default:o||"",opus:M||"",sonnet:W||"",haiku:Me||""},onApply:fs,onSave:js,isSaving:N.isPending,catalog:i,allModels:F})]})}function Xt({status:s,isSelected:a,onSelect:t}){const i=s.accounts?.length||0;return e.jsxs("button",{className:H("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(Pe,{provider:s.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.displayName}),i>0&&e.jsx($,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function Yt({variant:s,parentAuth:a,isSelected:t,onSelect:i,onDelete:r,isDeleting:u}){return e.jsxs("button",{className:H("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:i,children:[e.jsxs("div",{className:"relative",children:[e.jsx(Pe,{provider:s.provider,size:"sm"}),e.jsx(cs,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx($,{variant:"outline",className:"text-[9px] h-4 px-1",children:"variant"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",s.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:c=>{c.stopPropagation(),r()},disabled:u,children:e.jsx(ls,{className:"w-3 h-3"})})]})}function Zt({onSetup:s}){return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(xe,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"CCS Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage OAuth authentication, account preferences, and model selection for CLIProxy providers. Configure how CCS routes requests to different AI backends."}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["For live usage stats and real-time monitoring, visit the"," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:"Control Panel"}),"."]}),e.jsxs(y,{onClick:s,className:"gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function xa(){const s=je(),{data:a,isLoading:t}=Ye(),{data:i,isFetching:r}=Qs(),{data:u}=Js(),c=Ws(),p=Xs(),d=Ys(),g=Zs(),j=et(),h=st(),n=tt(),l=at(),[f,w]=m.useState(()=>typeof window<"u"?localStorage.getItem("cliproxy-selected-provider"):null),[x,A]=m.useState(null),[I,E]=m.useState(!1),[O,D]=m.useState(null),v=m.useMemo(()=>a?.authStatus||[],[a?.authStatus]),T=a?.source==="remote",b=m.useMemo(()=>i?.variants||[],[i?.variants]),N=o=>{w(o),o&&localStorage.setItem("cliproxy-selected-provider",o)},R=m.useMemo(()=>x?null:f&&v.some(o=>o.provider===f)?f:v.length>0&&(v.find(M=>(M.accounts?.length||0)>0)?.provider||v[0]?.provider)||null,[f,x,v]),P=v.find(o=>o.provider===R),k=b.find(o=>o.name===x),F=k?v.find(o=>o.provider===k.provider):void 0,K=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]})},z=(o,M,W)=>{d.isPending||g.isPending||(W?d.mutate({provider:o,accountId:M}):g.mutate({provider:o,accountId:M}))},S=(o,M)=>{j.isPending||j.mutate({provider:o,accountId:M})},C=(o,M)=>{h.isPending||h.mutate({provider:o,accountIds:M})},L=(o,M)=>{n.isPending||n.mutate({provider:o,accountIds:M})},G=o=>{N(o),A(null)},ae=o=>{A(o),N(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:u?.backendLabel??"CLIProxy"})]}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:K,disabled:r,children:e.jsx(ke,{className:H("w-4 h-4",r&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(y,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>E(!0),children:[e.jsx(re,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(ye,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(o=>e.jsx(nt,{className:"h-14 w-full rounded-lg"},o))}):e.jsx("div",{className:"space-y-1",children:v.map(o=>e.jsx(Xt,{status:o,isSelected:R===o.provider,onSelect:()=>G(o.provider)},o.provider))}),b.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(cs,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:b.map(o=>e.jsx(Yt,{variant:o,parentAuth:v.find(M=>M.provider===o.provider),isSelected:x===o.name,onSelect:()=>ae(o.name),onDelete:()=>l.mutate(o.name),isDeleting:l.isPending},o.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(wt,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[v.length," provider",v.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3 text-green-600"}),v.filter(o=>o.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:k&&F?e.jsx(qe,{provider:k.name,displayName:`${k.name} (${k.provider} variant)`,authStatus:F,catalog:ie[k.provider],logoProvider:k.provider,baseProvider:k.provider,isRemoteMode:T,port:k.port,onAddAccount:()=>D({provider:k.provider,displayName:F.displayName,isFirstAccount:(F.accounts?.length||0)===0}),onSetDefault:o=>c.mutate({provider:k.provider,accountId:o}),onRemoveAccount:o=>p.mutate({provider:k.provider,accountId:o}),onPauseToggle:(o,M)=>z(k.provider,o,M),onSoloMode:o=>S(k.provider,o),onBulkPause:o=>C(k.provider,o),onBulkResume:o=>L(k.provider,o),isRemovingAccount:p.isPending,isPausingAccount:d.isPending||g.isPending,isSoloingAccount:j.isPending,isBulkPausing:h.isPending,isBulkResuming:n.isPending}):P?e.jsx(qe,{provider:P.provider,displayName:P.displayName,authStatus:P,catalog:ie[P.provider],isRemoteMode:T,onAddAccount:()=>D({provider:P.provider,displayName:P.displayName,isFirstAccount:(P.accounts?.length||0)===0}),onSetDefault:o=>c.mutate({provider:P.provider,accountId:o}),onRemoveAccount:o=>p.mutate({provider:P.provider,accountId:o}),onPauseToggle:(o,M)=>z(P.provider,o,M),onSoloMode:o=>S(P.provider,o),onBulkPause:o=>C(P.provider,o),onBulkResume:o=>L(P.provider,o),isRemovingAccount:p.isPending,isPausingAccount:d.isPending||g.isPending,isSoloingAccount:j.isPending,isBulkPausing:h.isPending,isBulkResuming:n.isPending}):e.jsx(Zt,{onSetup:()=>E(!0)})}),e.jsx(Mt,{open:I,onClose:()=>E(!1)}),e.jsx(Rt,{open:O!==null,onClose:()=>D(null),provider:O?.provider||"",displayName:O?.displayName||"",isFirstAccount:O?.isFirstAccount||!1})]})}export{xa as CliproxyPage};
|