@kaitranntt/ccs 7.5.1 → 7.6.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ccs.js +16 -0
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-process.js +90 -15
- package/dist/cliproxy/auth/oauth-process.js.map +1 -1
- package/dist/cliproxy/device-code-handler.d.ts +28 -0
- package/dist/cliproxy/device-code-handler.d.ts.map +1 -0
- package/dist/cliproxy/device-code-handler.js +22 -0
- package/dist/cliproxy/device-code-handler.js.map +1 -0
- package/dist/cliproxy/proxy-config-resolver.d.ts.map +1 -1
- package/dist/cliproxy/proxy-config-resolver.js +5 -2
- package/dist/cliproxy/proxy-config-resolver.js.map +1 -1
- package/dist/cliproxy/remote-proxy-client.d.ts +1 -1
- package/dist/cliproxy/remote-proxy-client.d.ts.map +1 -1
- package/dist/cliproxy/remote-proxy-client.js +15 -7
- package/dist/cliproxy/remote-proxy-client.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +6 -2
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/setup-command.d.ts +23 -0
- package/dist/commands/setup-command.d.ts.map +1 -0
- package/dist/commands/setup-command.js +382 -0
- package/dist/commands/setup-command.js.map +1 -0
- package/dist/commands/update-command.js +1 -0
- package/dist/commands/update-command.js.map +1 -1
- package/dist/config/unified-config-loader.js +1 -1
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.js +1 -1
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/management/doctor.d.ts.map +1 -1
- package/dist/management/doctor.js +4 -0
- package/dist/management/doctor.js.map +1 -1
- package/dist/management/recovery-manager.d.ts +3 -2
- package/dist/management/recovery-manager.d.ts.map +1 -1
- package/dist/management/recovery-manager.js +43 -25
- package/dist/management/recovery-manager.js.map +1 -1
- package/dist/ui/assets/{accounts-CtHoujzN.js → accounts-aD3ar9cM.js} +1 -1
- package/dist/ui/assets/{api-BgRcDdEY.js → api-Dc9JX5dn.js} +1 -1
- package/dist/ui/assets/{card-B-B2DgVt.js → card-CfbpiPgZ.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-BQdbegqA.js → cliproxy-control-panel-DqwBL_cO.js} +1 -1
- package/dist/ui/assets/{cliproxy-DSIqB4Kc.js → cliproxy-j1dekKPD.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-cDuBPIIs.js → confirm-dialog-CbU1b1dF.js} +1 -1
- package/dist/ui/assets/{copilot-6gXCaKKj.js → copilot-CV5W8I2b.js} +3 -3
- package/dist/ui/assets/{globalenv-section-CRSV4042.js → globalenv-section-BD-Z41zV.js} +1 -1
- package/dist/ui/assets/{health-xBbBsgEt.js → health-DLMVq9vP.js} +1 -1
- package/dist/ui/assets/icons-B9mnOvwW.js +1 -0
- package/dist/ui/assets/{index-_cwEsFjm.js → index-BYJzZId9.js} +1 -1
- package/dist/ui/assets/index-CMv3XJ3a.css +1 -0
- package/dist/ui/assets/{index-BlJMdTol.js → index-CRwxNrlp.js} +1 -1
- package/dist/ui/assets/{index-CzA8ALA7.js → index-DTR-v1v5.js} +1 -1
- package/dist/ui/assets/index-PsnnKb2L.js +47 -0
- package/dist/ui/assets/{shared-DjYeuzbT.js → shared-BSfovmYC.js} +1 -1
- package/dist/ui/assets/{switch-DrBe8HmQ.js → switch-I-rTblpG.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/utils/error-manager.d.ts.map +1 -1
- package/dist/utils/error-manager.js +6 -0
- package/dist/utils/error-manager.js.map +1 -1
- package/dist/web-server/websocket.d.ts.map +1 -1
- package/dist/web-server/websocket.js +44 -0
- package/dist/web-server/websocket.js.map +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +109 -67
- package/dist/ui/assets/icons-ChQ4a4K4.js +0 -1
- package/dist/ui/assets/index-DAT_KnOX.css +0 -1
- package/dist/ui/assets/index-DtFSv99a.js +0 -47
|
@@ -105,12 +105,16 @@ class Doctor {
|
|
|
105
105
|
// Final status
|
|
106
106
|
if (this.results.isHealthy() && !this.results.hasWarnings()) {
|
|
107
107
|
console.log((0, ui_1.ok)('All checks passed! Installation is healthy.'));
|
|
108
|
+
console.log('');
|
|
109
|
+
console.log((0, ui_1.info)(`Tip: Use ${(0, ui_1.color)('ccs config', 'command')} for web-based configuration`));
|
|
108
110
|
}
|
|
109
111
|
else if (this.results.hasErrors()) {
|
|
110
112
|
console.log((0, ui_1.fail)('Installation has errors. Run suggested fixes above.'));
|
|
111
113
|
}
|
|
112
114
|
else {
|
|
113
115
|
console.log((0, ui_1.ok)(`Installation healthy (${this.results.warnings.length} warning${this.results.warnings.length !== 1 ? 's' : ''})`));
|
|
116
|
+
console.log('');
|
|
117
|
+
console.log((0, ui_1.info)(`Tip: Use ${(0, ui_1.color)('ccs config', 'command')} for web-based configuration`));
|
|
114
118
|
}
|
|
115
119
|
console.log('');
|
|
116
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/management/doctor.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/management/doctor.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;AAEH,oCAAsF;AACtF,sEAA6C;AAC7C,qCASkB;AAClB,qCAAyC;AAEzC;;GAEG;AACH,MAAM,MAAM;IAIV;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,oBAAW,EAAE,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,sBAAW,CAAC,OAAO,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY;QAChB,MAAM,IAAA,WAAM,GAAE,CAAC;QAEf,kBAAkB;QAClB,OAAO,CAAC,GAAG,CAAC,IAAA,QAAG,EAAC,qBAAqB,IAAI,CAAC,UAAU,E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O,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,SAAS,CACnB;YACE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,WAAW,EAAE,OAAO,CAAC,OAAO;YAC5B,UAAU,EAAE,sBAAW,CAAC,OAAO;YAC/B,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;YAC3B,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;YAC3B,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;YAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;SAClC,EACD,IAAI,EACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,IAAA,sBAAa,GAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAClC,CAAC;CACF;AAED,kBAAe,MAAM,CAAC"}
|
|
@@ -19,9 +19,10 @@ declare class RecoveryManager {
|
|
|
19
19
|
*/
|
|
20
20
|
ensureCcsDirectory(): boolean;
|
|
21
21
|
/**
|
|
22
|
-
* Ensure ~/.ccs/config.
|
|
22
|
+
* Ensure ~/.ccs/config.yaml exists with defaults
|
|
23
|
+
* This is the primary config format (YAML unified config)
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
ensureConfigYaml(): boolean;
|
|
25
26
|
/**
|
|
26
27
|
* Ensure ~/.claude/settings.json exists
|
|
27
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery-manager.d.ts","sourceRoot":"","sources":["../../src/management/recovery-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"recovery-manager.d.ts","sourceRoot":"","sources":["../../src/management/recovery-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH;;GAEG;AACH,cAAM,eAAe;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,SAAS,CAAW;;IAW5B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAS7B;;;OAGG;IACH,gBAAgB,IAAI,OAAO;IA4C3B;;OAEG;IACH,oBAAoB,IAAI,OAAO;IAsB/B;;OAEG;IACH,uBAAuB,IAAI,OAAO;IAuBlC;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAsB5B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IA6B7B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAuB7B;;OAEG;IACH,sBAAsB,IAAI,OAAO;IA+CjC;;;;;;OAMG;IACH,UAAU,IAAI,OAAO;IAiBrB;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,iBAAiB,IAAI,IAAI;CAiC1B;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -32,6 +32,8 @@ const fs = __importStar(require("fs"));
|
|
|
32
32
|
const path = __importStar(require("path"));
|
|
33
33
|
const os = __importStar(require("os"));
|
|
34
34
|
const ui_1 = require("../utils/ui");
|
|
35
|
+
const unified_config_types_1 = require("../config/unified-config-types");
|
|
36
|
+
const unified_config_loader_1 = require("../config/unified-config-loader");
|
|
35
37
|
/**
|
|
36
38
|
* Get CCS home directory (respects CCS_HOME env for test isolation)
|
|
37
39
|
*/
|
|
@@ -62,34 +64,50 @@ class RecoveryManager {
|
|
|
62
64
|
return false;
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
65
|
-
* Ensure ~/.ccs/config.
|
|
67
|
+
* Ensure ~/.ccs/config.yaml exists with defaults
|
|
68
|
+
* This is the primary config format (YAML unified config)
|
|
66
69
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
ensureConfigYaml() {
|
|
71
|
+
// Skip if config.yaml already exists AND is valid
|
|
72
|
+
if ((0, unified_config_loader_1.hasUnifiedConfig)()) {
|
|
73
|
+
// Verify it's loadable (not corrupted)
|
|
74
|
+
const loaded = (0, unified_config_loader_1.loadUnifiedConfig)();
|
|
75
|
+
if (loaded !== null) {
|
|
76
|
+
return false; // Config exists and is valid
|
|
77
|
+
}
|
|
78
|
+
// Config exists but is corrupted - will be recreated below
|
|
79
|
+
this.recovered.push('Detected corrupted ~/.ccs/config.yaml');
|
|
80
|
+
}
|
|
81
|
+
// Check for legacy config.json - if exists, let autoMigrate handle it
|
|
82
|
+
const legacyConfigPath = path.join(this.ccsDir, 'config.json');
|
|
83
|
+
if (fs.existsSync(legacyConfigPath)) {
|
|
84
|
+
// Legacy config exists - autoMigrate() in ccs.ts will handle migration
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
// Create fresh config.yaml with defaults
|
|
88
|
+
const config = (0, unified_config_types_1.createEmptyUnifiedConfig)();
|
|
89
|
+
config.version = unified_config_types_1.UNIFIED_CONFIG_VERSION;
|
|
90
|
+
try {
|
|
91
|
+
(0, unified_config_loader_1.saveUnifiedConfig)(config);
|
|
92
|
+
this.recovered.push('Created ~/.ccs/config.yaml');
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
catch (_saveErr) {
|
|
96
|
+
// Fallback: create minimal config.json for backward compat
|
|
71
97
|
try {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
98
|
+
const fallbackConfig = { profiles: {} };
|
|
99
|
+
const tmpPath = `${legacyConfigPath}.tmp`;
|
|
100
|
+
fs.writeFileSync(tmpPath, JSON.stringify(fallbackConfig, null, 2) + '\n', 'utf8');
|
|
101
|
+
fs.renameSync(tmpPath, legacyConfigPath);
|
|
102
|
+
this.recovered.push('Created ~/.ccs/config.json (fallback)');
|
|
103
|
+
return true;
|
|
75
104
|
}
|
|
76
|
-
catch (
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.recovered.push(`Backed up corrupted config.json to ${path.basename(backupPath)}`);
|
|
105
|
+
catch (_fallbackErr) {
|
|
106
|
+
// Both writes failed - log but don't crash
|
|
107
|
+
this.recovered.push('Failed to create config file (permission issue?)');
|
|
108
|
+
return false;
|
|
81
109
|
}
|
|
82
110
|
}
|
|
83
|
-
// Create default config (matches postinstall.js)
|
|
84
|
-
// NOTE: Empty profiles - users create profiles via `ccs api create` or UI
|
|
85
|
-
const defaultConfig = {
|
|
86
|
-
profiles: {},
|
|
87
|
-
};
|
|
88
|
-
const tmpPath = `${configPath}.tmp`;
|
|
89
|
-
fs.writeFileSync(tmpPath, JSON.stringify(defaultConfig, null, 2) + '\n', 'utf8');
|
|
90
|
-
fs.renameSync(tmpPath, configPath);
|
|
91
|
-
this.recovered.push('Created ~/.ccs/config.json');
|
|
92
|
-
return true;
|
|
93
111
|
}
|
|
94
112
|
/**
|
|
95
113
|
* Ensure ~/.claude/settings.json exists
|
|
@@ -264,8 +282,8 @@ class RecoveryManager {
|
|
|
264
282
|
this.ensureCcsDirectory();
|
|
265
283
|
this.ensureSharedDirectories();
|
|
266
284
|
this.ensureClaudeSettings();
|
|
267
|
-
// Config files
|
|
268
|
-
this.
|
|
285
|
+
// Config files - use YAML as primary format
|
|
286
|
+
this.ensureConfigYaml();
|
|
269
287
|
// Shell completions
|
|
270
288
|
this.ensureShellCompletions();
|
|
271
289
|
return this.recovered.length > 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery-manager.js","sourceRoot":"","sources":["../../src/management/recovery-manager.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;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;gBACf,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;gBACtD,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;YAC1D,CAAC;YACD,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;gBACxD,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;QAED,6CAA6C;QAC7C,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,EAAE,CAAC;YAC1E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,IAAA,SAAI,EAAC,gCAAgC,CAAC,CAAC,CAAC;YACpD,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACxC,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;CACF;AAED,kBAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-CrW4rUOS.js";import{a as x,u as p,b as h,d as f,f as l,g as b}from"./tanstack-Dbfprw6o.js";import"./react-vendor-B_CU-WTZ.js";import{c as r,af as u,a as g}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-CrW4rUOS.js";import{a as x,u as p,b as h,d as f,f as l,g as b}from"./tanstack-Dbfprw6o.js";import"./react-vendor-B_CU-WTZ.js";import{c as r,af as u,a as g}from"./index-PsnnKb2L.js";import{t as d}from"./notifications-dJQY2-U6.js";import{j}from"./icons-B9mnOvwW.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function y({className:s,...t}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:r("w-full caption-bottom text-sm",s),...t})})}function N({className:s,...t}){return e.jsx("thead",{"data-slot":"table-header",className:r("[&_tr]:border-b",s),...t})}function w({className:s,...t}){return e.jsx("tbody",{"data-slot":"table-body",className:r("[&_tr:last-child]:border-0",s),...t})}function i({className:s,...t}){return e.jsx("tr",{"data-slot":"table-row",className:r("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",s),...t})}function v({className:s,...t}){return e.jsx("th",{"data-slot":"table-head",className:r("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}function C({className:s,...t}){return e.jsx("td",{"data-slot":"table-cell",className:r("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}function D(){return x({queryKey:["accounts"],queryFn:()=>u.accounts.list()})}function T(){const s=p();return h({mutationFn:t=>u.accounts.setDefault(t),onSuccess:(t,o)=>{s.invalidateQueries({queryKey:["accounts"]}),d.success(`Default account set to "${o}"`)},onError:t=>{d.error(t.message)}})}function A({data:s,defaultAccount:t}){const o=T(),c=f({data:s,columns:[{accessorKey:"name",header:"Name",size:200,cell:({row:a})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:a.original.name}),a.original.name===t&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:"default"})]})},{accessorKey:"type",header:"Type",size:100,cell:({row:a})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:a.original.type||"oauth"})},{accessorKey:"created",header:"Created",size:150,cell:({row:a})=>{const n=new Date(a.original.created);return e.jsx("span",{className:"text-muted-foreground",children:n.toLocaleDateString()})}},{accessorKey:"last_used",header:"Last Used",size:150,cell:({row:a})=>{if(!a.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const n=new Date(a.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:n.toLocaleDateString()})}},{id:"actions",header:"Actions",size:100,cell:({row:a})=>{const n=a.original.name===t;return e.jsxs(g,{variant:n?"secondary":"default",size:"sm",className:"h-8 px-2 w-full",disabled:n||o.isPending,onClick:()=>o.mutate(a.original.name),children:[e.jsx(j,{className:`w-3 h-3 mr-1.5 ${n?"opacity-50":""}`}),n?"Active":"Set Default"]})}}],getCoreRowModel:b()});return s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:["No accounts found. Use ",e.jsx("code",{className:"text-sm bg-muted px-1 rounded",children:"ccs login"})," to add accounts."]}):e.jsx("div",{className:"border rounded-md",children:e.jsxs(y,{children:[e.jsx(N,{children:c.getHeaderGroups().map(a=>e.jsx(i,{children:a.headers.map(n=>{const m={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",actions:"w-[100px]"}[n.id]||"w-auto";return e.jsx(v,{className:m,children:n.isPlaceholder?null:l(n.column.columnDef.header,n.getContext())},n.id)})},a.id))}),e.jsx(w,{children:c.getRowModel().rows.map(a=>e.jsx(i,{children:a.getVisibleCells().map(n=>e.jsx(C,{children:l(n.column.columnDef.cell,n.getContext())},n.id))},a.id))})]})})}function P(){const{data:s,isLoading:t}=D();return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage multi-account Claude sessions (profiles.json)"})]})}),t?e.jsx("div",{className:"text-muted-foreground",children:"Loading accounts..."}):e.jsx(A,{data:s?.accounts||[],defaultAccount:s?.default??null}),e.jsx("div",{className:"text-sm text-muted-foreground border-t pt-4 mt-4",children:e.jsxs("p",{children:["Accounts are isolated Claude instances with separate sessions.",e.jsx("br",{}),"Use ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs auth create <name>"})," to add new accounts via CLI."]})})]})}export{P as AccountsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-CrW4rUOS.js";import{r as c}from"./react-vendor-B_CU-WTZ.js";import{B as S,c as E,T as je,k as Ne,l as ve,a as g,I as C,i as I,L as T,m as M,n as ne,o as be,s as we,p as Ce,q as ye,S as W,r as L,t as $,v as re,w as Oe,x as Ae,y as le,z as ie,A as ce,D as Ee,E as Te,F as X,G as Z,R as ke,H as q,J as _e,K as Se,M as Pe,N as Re}from"./index-DtFSv99a.js";import{u as Le,a as Me,b as De}from"./tanstack-Dbfprw6o.js";import{C as B,S as ee}from"./confirm-dialog-cDuBPIIs.js";import{t as Q}from"./notifications-dJQY2-U6.js";import{_ as U,a8 as oe,L as G,a9 as Ie,E as Ue,d as He,J as D,I as Fe,aa as de,N as V,b as xe,ab as ze,z as Ke,ac as Je,D as me,X as $e,Z as ue,ad as Be,V as Qe,O as he,ae as qe,k as fe}from"./icons-ChQ4a4K4.js";import{C as Ge,b as Ve,c as Ye,d as We,a as Xe}from"./card-B-B2DgVt.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function Ze({className:s,showTooltip:t=!0}){const l=e.jsxs(S,{variant:"outline",className:E("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return t?e.jsxs(je,{children:[e.jsx(Ne,{asChild:!0,children:l}),e.jsx(ve,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):l}function se(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(l=>l.test(s))}function pe(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function es(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function ss(s,t){const l={...s};return t.opus?l.ANTHROPIC_DEFAULT_OPUS_MODEL=t.opus:delete l.ANTHROPIC_DEFAULT_OPUS_MODEL,t.sonnet?l.ANTHROPIC_DEFAULT_SONNET_MODEL=t.sonnet:delete l.ANTHROPIC_DEFAULT_SONNET_MODEL,t.haiku?l.ANTHROPIC_DEFAULT_HAIKU_MODEL=t.haiku:delete l.ANTHROPIC_DEFAULT_HAIKU_MODEL,l}function ts({profileName:s,data:t,settings:l,isLoading:i,isSaving:d,hasChanges:h,isRawJsonValid:x,onRefresh:n,onDelete:o,onSave:m}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),t?.path&&e.jsx(S,{variant:"outline",className:"text-xs",children:t.path.replace(/^.*\//,"")}),pe(l)&&e.jsx(Ze,{className:"ml-1"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(t.mtime).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{variant:"ghost",size:"sm",onClick:n,disabled:i,children:e.jsx(U,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),o&&e.jsx(g,{variant:"ghost",size:"sm",onClick:o,children:e.jsx(oe,{className:"w-4 h-4 text-destructive"})}),e.jsx(g,{size:"sm",onClick:m,disabled:d||!h||!x,children:d?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function ge({label:s,...t}){const[l,i]=c.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx("label",{className:"text-sm font-medium",children:s}),e.jsxs("div",{className:"relative",children:[e.jsx(C,{type:l?"text":"password",className:"pr-10 font-mono",...t}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>i(!l),tabIndex:-1,children:l?e.jsx(Ue,{className:"w-4 h-4"}):e.jsx(He,{className:"w-4 h-4"})})]})]})}function as({currentSettings:s,newEnvKey:t,newEnvValue:l,onNewEnvKeyChange:i,onNewEnvValueChange:d,onEnvValueChange:h,onAddEnvVar:x}){return e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([n,o])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(T,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[n,se(n)&&e.jsx(S,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:"sensitive"})]}),se(n)?e.jsx(ge,{value:o,onChange:m=>h(n,m.target.value),className:"font-mono text-sm h-8"}):e.jsx(C,{value:o,onChange:m=>h(n,m.target.value),className:"font-mono text-sm h-8"})]},n))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:"No environment variables configured."}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Add variables using the input below or edit the JSON directly."})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(C,{placeholder:"VARIABLE_NAME",value:t,onChange:n=>i(n.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:n=>n.key==="Enter"&&t.trim()&&x()}),e.jsx(C,{placeholder:"value",value:l,onChange:n=>d(n.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:n=>n.key==="Enter"&&t.trim()&&x()}),e.jsx(g,{variant:"outline",size:"sm",className:"h-8",onClick:x,disabled:!t.trim(),children:e.jsx(D,{className:"w-4 h-4"})})]})]})]})}function ns({profileName:s,data:t}){return e.jsx(I,{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(Fe,{className:"w-4 h-4"}),"Profile Information"]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children: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:"Profile Name"}),e.jsx("span",{className:"font-mono",children:t.profile})]}),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(M,{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",{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.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"Run with profile"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(M,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"Set as default"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(M,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function rs({value:s,onChange:t,placeholder:l="Search models...",className:i}){const[d,h]=c.useState(""),[x,n]=c.useState(null),{models:o,isLoading:m,isError:j,isFetching:y}=ne(),O=be(),N=c.useMemo(()=>we(o,d,{category:x??void 0}),[o,d,x]),b=c.useMemo(()=>Ce(o,2),[o]),_=!d.trim()&&!x,k=c.useMemo(()=>{const r={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};N.forEach(a=>{r[a.category].push(a)});for(const a of Object.keys(r))r[a]=ye(r[a]);return r},[N]),w=c.useCallback(()=>{O()},[O]),p=o.find(r=>r.id===s);return m&&o.length===0?e.jsxs("div",{className:E("space-y-2",i),children:[e.jsx(W,{className:"h-10 w-full"}),e.jsx(W,{className:"h-32 w-full"})]}):e.jsxs("div",{className:E("space-y-2 w-full min-w-0 overflow-hidden",i),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(de,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(C,{value:d,onChange:r=>h(r.target.value),placeholder:l,className:"pl-9"})]}),e.jsx(g,{variant:"outline",size:"icon",onClick:w,disabled:y,title:"Refresh models",children:y?e.jsx(G,{className:"h-4 w-4 animate-spin"}):e.jsx(U,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(S,{variant:x===null?"default":"outline",className:"cursor-pointer",onClick:()=>n(null),children:["All (",o.length,")"]}),Object.keys(L).map(r=>{const a=k[r].length;return a===0?null:e.jsxs(S,{variant:x===r?"default":"outline",className:"cursor-pointer",onClick:()=>n(r),children:[L[r]," (",a,")"]},r)})]}),p&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:p.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[$(p.pricing)," |"," ",re(p.context_length)]})]}),e.jsx(I,{className:"h-72 w-full rounded-md border",children:j?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(g,{variant:"link",onClick:w,children:"Retry"})]}):N.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',d,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[_&&b.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(V,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:b.map(r=>e.jsx(te,{model:r,isSelected:r.id===s,onClick:()=>t(r.id),showAge:!0},r.id))})]}),Object.keys(L).map(r=>{const a=k[r];return a.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:L[r]}),e.jsx("div",{className:"space-y-1",children:a.map(v=>e.jsx(te,{model:v,isSelected:v.id===s,onClick:()=>t(v.id)},v.id))})]},r)})]})})]})}function te({model:s,isSelected:t,onClick:l,showAge:i=!1}){return e.jsxs("button",{type:"button",onClick:l,className:E("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",t&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:E("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",t?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[i&&s.created&&e.jsx(S,{variant:"outline",className:E("text-[10px] px-1",t?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:Oe(s.created)}),s.isFree?e.jsx(S,{variant:"secondary",className:E("text-[10px] px-1",t?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",className:E("text-[10px] px-1 border-emerald-500/50 text-emerald-600",t?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:$(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:$(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:re(s.context_length)})]})]})}function ls({selectedModel:s,value:t,onChange:l,className:i}){const{models:d}=ne(),h=c.useMemo(()=>s?Ae(s,d):{},[s,d]),x=()=>{l(h)},n=(m,j)=>{l({...t,[m]:j||void 0})},o=s&&Object.keys(h).length>0;return e.jsxs(le,{className:E("group",i),children:[e.jsxs(ie,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(xe,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),"Model Tier Mapping",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(Advanced)"})]}),e.jsxs(ce,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Configure different models for Claude Code's opus/sonnet/haiku tiers."}),o&&e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:x,children:[e.jsx(ze,{className:"mr-1 h-4 w-4"}),"Auto-suggest based on ",s?.split("/")[0]]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(C,{id:"tier-opus",value:t.opus??"",onChange:m=>n("opus",m.target.value),placeholder:"e.g., anthropic/claude-opus-4"})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(C,{id:"tier-sonnet",value:t.sonnet??"",onChange:m=>n("sonnet",m.target.value),placeholder:"e.g., anthropic/claude-sonnet-4"})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(C,{id:"tier-haiku",value:t.haiku??"",onChange:m=>n("haiku",m.target.value),placeholder:"e.g., anthropic/claude-3.5-haiku"})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"These set ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL."})]})]})}function is({profileName:s,data:t,currentSettings:l,newEnvKey:i,newEnvValue:d,onNewEnvKeyChange:h,onNewEnvValueChange:x,onEnvValueChange:n,onAddEnvVar:o,onEnvBulkChange:m}){const j=pe(l),y=l?.env,O=c.useMemo(()=>es(y??{}),[y]),N=y??{},b=a=>{if(m){const v={...N,ANTHROPIC_MODEL:a,ANTHROPIC_DEFAULT_OPUS_MODEL:a,ANTHROPIC_DEFAULT_SONNET_MODEL:a,ANTHROPIC_DEFAULT_HAIKU_MODEL:a};m(v)}else n("ANTHROPIC_MODEL",a),n("ANTHROPIC_DEFAULT_OPUS_MODEL",a),n("ANTHROPIC_DEFAULT_SONNET_MODEL",a),n("ANTHROPIC_DEFAULT_HAIKU_MODEL",a);Q.success("Applied model to all tiers",{duration:2e3})},_=a=>{if(m){const v=ss(N,a);m(v)}else a.opus!==void 0&&n("ANTHROPIC_DEFAULT_OPUS_MODEL",a.opus||""),a.sonnet!==void 0&&n("ANTHROPIC_DEFAULT_SONNET_MODEL",a.sonnet||""),a.haiku!==void 0&&n("ANTHROPIC_DEFAULT_HAIKU_MODEL",a.haiku||"")},[k,w]=c.useState(!1),p=new Set(["ANTHROPIC_AUTH_TOKEN"]),r=Object.entries(N).filter(([a])=>!p.has(a));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(Ee,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Te,{className:"w-full",children:[e.jsx(X,{value:"env",className:"flex-1",children:j?"Configuration":"Environment Variables"}),e.jsx(X,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(Z,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:j?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(rs,{value:N.ANTHROPIC_MODEL,onChange:b,placeholder:"Search OpenRouter models..."})]}),e.jsx(ls,{selectedModel:N.ANTHROPIC_MODEL,value:O,onChange:_}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"API Key"}),e.jsx(ge,{value:N.ANTHROPIC_AUTH_TOKEN||"",onChange:a=>n("ANTHROPIC_AUTH_TOKEN",a.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),r.length>0&&e.jsxs(le,{open:k,onOpenChange:w,children:[e.jsxs(ie,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(xe,{className:E("h-4 w-4 transition-transform",k&&"rotate-90")}),e.jsx(Ke,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",r.length,")"]})]}),e.jsx(ce,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:r.map(([a,v])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:a}),e.jsx(C,{value:v,onChange:P=>n(a,P.target.value),className:"font-mono text-xs h-8"})]},a))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(C,{placeholder:"VARIABLE_NAME",value:i,onChange:a=>h(a.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:a=>a.key==="Enter"&&i.trim()&&o()}),e.jsx(C,{placeholder:"value",value:d,onChange:a=>x(a.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:a=>a.key==="Enter"&&i.trim()&&o()}),e.jsx(g,{variant:"outline",size:"sm",className:"h-8",onClick:o,disabled:!i.trim(),children:e.jsx(D,{className:"w-4 h-4"})})]})]})]}):e.jsx(as,{currentSettings:l,newEnvKey:i,newEnvValue:d,onNewEnvKeyChange:h,onNewEnvValueChange:x,onEnvValueChange:n,onAddEnvVar:o})}),e.jsx(Z,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(ns,{profileName:s,data:t})})]})]})})}function cs({profileName:s,onDelete:t,onHasChangesUpdate:l}){const[i,d]=c.useState({}),[h,x]=c.useState(!1),[n,o]=c.useState(null),[m,j]=c.useState(""),[y,O]=c.useState(""),N=Le(),{data:b,isLoading:_,isError:k,refetch:w}=Me({queryKey:["settings",s],queryFn:async()=>{const f=await fetch(`/api/settings/${s}/raw`);if(!f.ok)throw new Error(`Failed to load settings: ${f.status}`);return f.json()}}),p=b?.settings,r=c.useMemo(()=>{if(n!==null)try{return JSON.parse(n)}catch{}if(p)return{...p,env:{...p.env,...i}}},[p,i,n]),a=c.useMemo(()=>n!==null?n:p?JSON.stringify(p,null,2):"",[n,p]),v=c.useCallback(f=>{o(f)},[]),P=(f,A)=>{const R={...r?.env||{},[f]:A};d(J=>({...J,[f]:A})),o(JSON.stringify({...r,env:R},null,2))},H=f=>{const A={...r?.env||{},...f};d(R=>({...R,...f})),o(JSON.stringify({...r,env:A},null,2))},F=()=>{if(!m.trim())return;const f=m.trim(),A=y,R={...r?.env||{},[f]:A};d(J=>({...J,[f]:A})),o(JSON.stringify({...r,env:R},null,2)),j(""),O("")},u=c.useMemo(()=>{try{return JSON.parse(a),!0}catch{return!1}},[a]),z=c.useMemo(()=>n!==null?n!==JSON.stringify(p,null,2):Object.keys(i).length>0,[n,i,p]);c.useEffect(()=>{l?.(z)},[z,l]);const K=De({mutationFn:async()=>{let f;try{f=JSON.parse(a)}catch{f={...b?.settings,env:{...b?.settings?.env,...i}}}const A=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:f,expectedMtime:b?.mtime})});if(A.status===409)throw new Error("CONFLICT");if(!A.ok)throw new Error("Failed to save");return A.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["settings",s]}),N.invalidateQueries({queryKey:["profiles"]}),d({}),o(null),Q.success("Settings saved")},onError:f=>{f.message==="CONFLICT"?x(!0):Q.error(f.message)}}),Y=async f=>{x(!1),f?(await w(),K.mutate()):(d({}),o(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ts,{profileName:s,data:b,settings:r,isLoading:_,isSaving:K.isPending,hasChanges:z,isRawJsonValid:u,onRefresh:()=>w(),onDelete:t,onSave:()=>K.mutate()}),_?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(G,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):k?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>w(),children:[e.jsx(U,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):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 min-w-0",children:e.jsx(is,{profileName:s,data:b,currentSettings:r,newEnvKey:m,newEnvValue:y,onNewEnvKeyChange:j,onNewEnvValueChange:O,onEnvValueChange:P,onEnvBulkChange:H,onAddEnvVar:F})}),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(Je,{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(ke,{rawJsonContent:a,isRawJsonValid:u,rawJsonEdits:n,settings:p,onChange:v})]})]}),e.jsx(B,{open:h,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Y(!0),onCancel:()=>Y(!1)})]},s)}const ae="ccs:openrouter-banner-dismissed";function os({onCreateClick:s}){const[t,l]=c.useState(!0),{modelCount:i,isLoading:d}=q();c.useEffect(()=>{const x=localStorage.getItem(ae)==="true";l(x)},[]);const h=()=>{localStorage.setItem(ae,"true"),l(!0)};return t?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(V,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",d?"300+":`${i}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(g,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(me,{className:"w-3 h-3"})]}),e.jsxs(g,{size:"icon",variant:"ghost",onClick:h,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx($e,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ds({onOpenRouterClick:s,onCustomClick:t}){const{modelCount:l,isLoading:i}=q();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20 p-8",children:e.jsxs("div",{className:"max-w-lg w-full space-y-6",children:[e.jsxs(Ge,{className:"border-accent/30 dark:border-accent/40 bg-gradient-to-br from-accent/5 to-background dark:from-accent/10",children:[e.jsxs(Ve,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-accent/10 dark:bg-accent/20",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"w-6 h-6"})}),e.jsx(S,{variant:"secondary",className:"bg-accent/10 text-accent dark:bg-accent/20 dark:text-accent-foreground",children:"Recommended"})]}),e.jsx(Ye,{className:"text-xl",children:"Start with OpenRouter"}),e.jsxs(We,{className:"text-base",children:["Access ",i?"300+":`${l}+`," models from OpenAI, Anthropic, Google, Meta and more - all through one API."]})]}),e.jsxs(Xe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ue,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:"One API, all providers"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(V,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:"Model tier mapping"})]})]}),e.jsxs(g,{onClick:s,className:"w-full bg-accent hover:bg-accent/90 text-white",size:"lg",children:["Create OpenRouter Profile",e.jsx(Be,{className:"w-4 h-4 ml-2"})]}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Get your API key at"," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-1",children:["openrouter.ai/keys",e.jsx(me,{className:"w-3 h-3"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ee,{className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),e.jsx(ee,{className:"flex-1"})]}),e.jsx(g,{variant:"outline",onClick:t,className:"w-full",children:"Create Custom API Profile"})]})})}function xs({onCreateClick:s}){const{modelCount:t,isLoading:l}=q();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[l?"300+":`${t}+`," models available"]})]}),e.jsxs(g,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function ys(){const{data:s,isLoading:t,isError:l,refetch:i}=_e(),d=Se(),[h,x]=c.useState(null),[n,o]=c.useState(""),[m,j]=c.useState(!1),[y,O]=c.useState("normal"),[N,b]=c.useState(null),[_,k]=c.useState(!1),[w,p]=c.useState(null);Pe();const r=c.useMemo(()=>s?.profiles||[],[s?.profiles]),a=c.useMemo(()=>r.filter(u=>u.name.toLowerCase().includes(n.toLowerCase())),[r,n]),v=h?r.find(u=>u.name===h):null,P=u=>{d.mutate(u,{onSuccess:()=>{h===u&&x(null),b(null)}})},H=u=>{j(!1),_&&h!==null?p(u):x(u)},F=u=>{_&&h!==u?p(u):x(u)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:[e.jsx(os,{onCreateClick:()=>j(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0",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-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qe,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"API Profiles"})]}),e.jsxs(g,{size:"sm",onClick:()=>{j(!0)},children:[e.jsx(D,{className:"w-4 h-4 mr-1"}),"New"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(de,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(C,{placeholder:"Search profiles...",className:"pl-8 h-9",value:n,onChange:u=>o(u.target.value)})]})]}),e.jsx(I,{className:"flex-1",children:t?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading profiles..."}):l?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(he,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Failed to load profiles"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Unable to fetch API profiles. Please try again."})]}),e.jsxs(g,{size:"sm",variant:"outline",onClick:()=>i(),children:[e.jsx(U,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):a.length===0?e.jsx("div",{className:"p-4 text-center",children:r.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(qe,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"No API profiles yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Create your first profile to connect to custom API endpoints"})]}),e.jsxs(g,{size:"sm",variant:"outline",onClick:()=>{j(!0)},children:[e.jsx(D,{className:"w-4 h-4 mr-1"}),"Create Profile"]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground py-4",children:['No profiles match "',n,'"']})}):e.jsx("div",{className:"p-2 space-y-1",children:a.map(u=>e.jsx(ms,{profile:u,isSelected:h===u.name,onSelect:()=>F(u.name),onDelete:()=>b(u.name)},u.name))})}),r.length>0&&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:[r.length," profile",r.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(fe,{className:"w-3 h-3 text-green-600"}),r.filter(u=>u.configured).length," configured"]})]})}),e.jsx(xs,{onCreateClick:()=>{O("openrouter"),j(!0)}})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v?e.jsx(cs,{profileName:v.name,onDelete:()=>b(v.name),onHasChangesUpdate:k},v.name):e.jsx(ds,{onOpenRouterClick:()=>{O("openrouter"),j(!0)},onCustomClick:()=>{O("normal"),j(!0)}})})]}),e.jsx(Re,{open:m,onOpenChange:j,onSuccess:H,initialMode:y}),e.jsx(B,{open:!!N,title:"Delete Profile",description:`Are you sure you want to delete "${N}"? This will remove the settings file and cannot be undone.`,confirmText:"Delete",variant:"destructive",onConfirm:()=>N&&P(N),onCancel:()=>b(null)}),e.jsx(B,{open:!!w,title:"Unsaved Changes",description:`You have unsaved changes in "${h}". Discard and switch to "${w}"?`,confirmText:"Discard & Switch",variant:"destructive",onConfirm:()=>{k(!1),x(w),p(null)},onCancel:()=>p(null)})]})}function ms({profile:s,isSelected:t,onSelect:l,onDelete:i}){return e.jsxs("div",{className:E("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:l,children:[s.configured?e.jsx(fe,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(he,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(M,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(g,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:d=>{d.stopPropagation(),i()},children:e.jsx(oe,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{ys as ApiPage};
|
|
1
|
+
import{j as e}from"./radix-ui-CrW4rUOS.js";import{r as c}from"./react-vendor-B_CU-WTZ.js";import{B as S,c as E,T as je,k as Ne,l as ve,a as g,I as C,i as I,L as T,m as M,n as ne,o as be,s as we,p as Ce,q as ye,S as W,r as L,t as $,v as re,w as Oe,x as Ae,y as le,z as ie,A as ce,D as Ee,E as Te,F as X,G as Z,R as ke,H as q,J as _e,K as Se,M as Pe,N as Re}from"./index-PsnnKb2L.js";import{u as Le,a as Me,b as De}from"./tanstack-Dbfprw6o.js";import{C as B,S as ee}from"./confirm-dialog-CbU1b1dF.js";import{t as Q}from"./notifications-dJQY2-U6.js";import{$ as U,a9 as oe,L as G,aa as Ie,E as Ue,d as He,N as D,I as Fe,ab as de,O as Y,b as xe,ac as ze,J as Ke,ad as Je,m as me,X as $e,Z as ue,ae as Be,Y as Qe,Q as he,af as qe,n as fe}from"./icons-B9mnOvwW.js";import{C as Ge,b as Ye,c as Ve,d as We,a as Xe}from"./card-CfbpiPgZ.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function Ze({className:s,showTooltip:t=!0}){const l=e.jsxs(S,{variant:"outline",className:E("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return t?e.jsxs(je,{children:[e.jsx(Ne,{asChild:!0,children:l}),e.jsx(ve,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):l}function se(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(l=>l.test(s))}function pe(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function es(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function ss(s,t){const l={...s};return t.opus?l.ANTHROPIC_DEFAULT_OPUS_MODEL=t.opus:delete l.ANTHROPIC_DEFAULT_OPUS_MODEL,t.sonnet?l.ANTHROPIC_DEFAULT_SONNET_MODEL=t.sonnet:delete l.ANTHROPIC_DEFAULT_SONNET_MODEL,t.haiku?l.ANTHROPIC_DEFAULT_HAIKU_MODEL=t.haiku:delete l.ANTHROPIC_DEFAULT_HAIKU_MODEL,l}function ts({profileName:s,data:t,settings:l,isLoading:i,isSaving:d,hasChanges:h,isRawJsonValid:x,onRefresh:n,onDelete:o,onSave:m}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),t?.path&&e.jsx(S,{variant:"outline",className:"text-xs",children:t.path.replace(/^.*\//,"")}),pe(l)&&e.jsx(Ze,{className:"ml-1"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(t.mtime).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{variant:"ghost",size:"sm",onClick:n,disabled:i,children:e.jsx(U,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),o&&e.jsx(g,{variant:"ghost",size:"sm",onClick:o,children:e.jsx(oe,{className:"w-4 h-4 text-destructive"})}),e.jsx(g,{size:"sm",onClick:m,disabled:d||!h||!x,children:d?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function ge({label:s,...t}){const[l,i]=c.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx("label",{className:"text-sm font-medium",children:s}),e.jsxs("div",{className:"relative",children:[e.jsx(C,{type:l?"text":"password",className:"pr-10 font-mono",...t}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>i(!l),tabIndex:-1,children:l?e.jsx(Ue,{className:"w-4 h-4"}):e.jsx(He,{className:"w-4 h-4"})})]})]})}function as({currentSettings:s,newEnvKey:t,newEnvValue:l,onNewEnvKeyChange:i,onNewEnvValueChange:d,onEnvValueChange:h,onAddEnvVar:x}){return e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([n,o])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(T,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[n,se(n)&&e.jsx(S,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:"sensitive"})]}),se(n)?e.jsx(ge,{value:o,onChange:m=>h(n,m.target.value),className:"font-mono text-sm h-8"}):e.jsx(C,{value:o,onChange:m=>h(n,m.target.value),className:"font-mono text-sm h-8"})]},n))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:"No environment variables configured."}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Add variables using the input below or edit the JSON directly."})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(C,{placeholder:"VARIABLE_NAME",value:t,onChange:n=>i(n.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:n=>n.key==="Enter"&&t.trim()&&x()}),e.jsx(C,{placeholder:"value",value:l,onChange:n=>d(n.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:n=>n.key==="Enter"&&t.trim()&&x()}),e.jsx(g,{variant:"outline",size:"sm",className:"h-8",onClick:x,disabled:!t.trim(),children:e.jsx(D,{className:"w-4 h-4"})})]})]})]})}function ns({profileName:s,data:t}){return e.jsx(I,{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(Fe,{className:"w-4 h-4"}),"Profile Information"]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children: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:"Profile Name"}),e.jsx("span",{className:"font-mono",children:t.profile})]}),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(M,{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",{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.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"Run with profile"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(M,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"Set as default"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(M,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function rs({value:s,onChange:t,placeholder:l="Search models...",className:i}){const[d,h]=c.useState(""),[x,n]=c.useState(null),{models:o,isLoading:m,isError:j,isFetching:y}=ne(),O=be(),N=c.useMemo(()=>we(o,d,{category:x??void 0}),[o,d,x]),b=c.useMemo(()=>Ce(o,2),[o]),_=!d.trim()&&!x,k=c.useMemo(()=>{const r={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};N.forEach(a=>{r[a.category].push(a)});for(const a of Object.keys(r))r[a]=ye(r[a]);return r},[N]),w=c.useCallback(()=>{O()},[O]),p=o.find(r=>r.id===s);return m&&o.length===0?e.jsxs("div",{className:E("space-y-2",i),children:[e.jsx(W,{className:"h-10 w-full"}),e.jsx(W,{className:"h-32 w-full"})]}):e.jsxs("div",{className:E("space-y-2 w-full min-w-0 overflow-hidden",i),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(de,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(C,{value:d,onChange:r=>h(r.target.value),placeholder:l,className:"pl-9"})]}),e.jsx(g,{variant:"outline",size:"icon",onClick:w,disabled:y,title:"Refresh models",children:y?e.jsx(G,{className:"h-4 w-4 animate-spin"}):e.jsx(U,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(S,{variant:x===null?"default":"outline",className:"cursor-pointer",onClick:()=>n(null),children:["All (",o.length,")"]}),Object.keys(L).map(r=>{const a=k[r].length;return a===0?null:e.jsxs(S,{variant:x===r?"default":"outline",className:"cursor-pointer",onClick:()=>n(r),children:[L[r]," (",a,")"]},r)})]}),p&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:p.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[$(p.pricing)," |"," ",re(p.context_length)]})]}),e.jsx(I,{className:"h-72 w-full rounded-md border",children:j?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(g,{variant:"link",onClick:w,children:"Retry"})]}):N.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',d,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[_&&b.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(Y,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:b.map(r=>e.jsx(te,{model:r,isSelected:r.id===s,onClick:()=>t(r.id),showAge:!0},r.id))})]}),Object.keys(L).map(r=>{const a=k[r];return a.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:L[r]}),e.jsx("div",{className:"space-y-1",children:a.map(v=>e.jsx(te,{model:v,isSelected:v.id===s,onClick:()=>t(v.id)},v.id))})]},r)})]})})]})}function te({model:s,isSelected:t,onClick:l,showAge:i=!1}){return e.jsxs("button",{type:"button",onClick:l,className:E("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",t&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:E("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",t?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[i&&s.created&&e.jsx(S,{variant:"outline",className:E("text-[10px] px-1",t?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:Oe(s.created)}),s.isFree?e.jsx(S,{variant:"secondary",className:E("text-[10px] px-1",t?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",className:E("text-[10px] px-1 border-emerald-500/50 text-emerald-600",t?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:$(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:$(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:re(s.context_length)})]})]})}function ls({selectedModel:s,value:t,onChange:l,className:i}){const{models:d}=ne(),h=c.useMemo(()=>s?Ae(s,d):{},[s,d]),x=()=>{l(h)},n=(m,j)=>{l({...t,[m]:j||void 0})},o=s&&Object.keys(h).length>0;return e.jsxs(le,{className:E("group",i),children:[e.jsxs(ie,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(xe,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),"Model Tier Mapping",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(Advanced)"})]}),e.jsxs(ce,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Configure different models for Claude Code's opus/sonnet/haiku tiers."}),o&&e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:x,children:[e.jsx(ze,{className:"mr-1 h-4 w-4"}),"Auto-suggest based on ",s?.split("/")[0]]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(C,{id:"tier-opus",value:t.opus??"",onChange:m=>n("opus",m.target.value),placeholder:"e.g., anthropic/claude-opus-4"})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(C,{id:"tier-sonnet",value:t.sonnet??"",onChange:m=>n("sonnet",m.target.value),placeholder:"e.g., anthropic/claude-sonnet-4"})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(C,{id:"tier-haiku",value:t.haiku??"",onChange:m=>n("haiku",m.target.value),placeholder:"e.g., anthropic/claude-3.5-haiku"})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"These set ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL."})]})]})}function is({profileName:s,data:t,currentSettings:l,newEnvKey:i,newEnvValue:d,onNewEnvKeyChange:h,onNewEnvValueChange:x,onEnvValueChange:n,onAddEnvVar:o,onEnvBulkChange:m}){const j=pe(l),y=l?.env,O=c.useMemo(()=>es(y??{}),[y]),N=y??{},b=a=>{if(m){const v={...N,ANTHROPIC_MODEL:a,ANTHROPIC_DEFAULT_OPUS_MODEL:a,ANTHROPIC_DEFAULT_SONNET_MODEL:a,ANTHROPIC_DEFAULT_HAIKU_MODEL:a};m(v)}else n("ANTHROPIC_MODEL",a),n("ANTHROPIC_DEFAULT_OPUS_MODEL",a),n("ANTHROPIC_DEFAULT_SONNET_MODEL",a),n("ANTHROPIC_DEFAULT_HAIKU_MODEL",a);Q.success("Applied model to all tiers",{duration:2e3})},_=a=>{if(m){const v=ss(N,a);m(v)}else a.opus!==void 0&&n("ANTHROPIC_DEFAULT_OPUS_MODEL",a.opus||""),a.sonnet!==void 0&&n("ANTHROPIC_DEFAULT_SONNET_MODEL",a.sonnet||""),a.haiku!==void 0&&n("ANTHROPIC_DEFAULT_HAIKU_MODEL",a.haiku||"")},[k,w]=c.useState(!1),p=new Set(["ANTHROPIC_AUTH_TOKEN"]),r=Object.entries(N).filter(([a])=>!p.has(a));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(Ee,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Te,{className:"w-full",children:[e.jsx(X,{value:"env",className:"flex-1",children:j?"Configuration":"Environment Variables"}),e.jsx(X,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(Z,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:j?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(rs,{value:N.ANTHROPIC_MODEL,onChange:b,placeholder:"Search OpenRouter models..."})]}),e.jsx(ls,{selectedModel:N.ANTHROPIC_MODEL,value:O,onChange:_}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"API Key"}),e.jsx(ge,{value:N.ANTHROPIC_AUTH_TOKEN||"",onChange:a=>n("ANTHROPIC_AUTH_TOKEN",a.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),r.length>0&&e.jsxs(le,{open:k,onOpenChange:w,children:[e.jsxs(ie,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(xe,{className:E("h-4 w-4 transition-transform",k&&"rotate-90")}),e.jsx(Ke,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",r.length,")"]})]}),e.jsx(ce,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:r.map(([a,v])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:a}),e.jsx(C,{value:v,onChange:P=>n(a,P.target.value),className:"font-mono text-xs h-8"})]},a))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(C,{placeholder:"VARIABLE_NAME",value:i,onChange:a=>h(a.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:a=>a.key==="Enter"&&i.trim()&&o()}),e.jsx(C,{placeholder:"value",value:d,onChange:a=>x(a.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:a=>a.key==="Enter"&&i.trim()&&o()}),e.jsx(g,{variant:"outline",size:"sm",className:"h-8",onClick:o,disabled:!i.trim(),children:e.jsx(D,{className:"w-4 h-4"})})]})]})]}):e.jsx(as,{currentSettings:l,newEnvKey:i,newEnvValue:d,onNewEnvKeyChange:h,onNewEnvValueChange:x,onEnvValueChange:n,onAddEnvVar:o})}),e.jsx(Z,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(ns,{profileName:s,data:t})})]})]})})}function cs({profileName:s,onDelete:t,onHasChangesUpdate:l}){const[i,d]=c.useState({}),[h,x]=c.useState(!1),[n,o]=c.useState(null),[m,j]=c.useState(""),[y,O]=c.useState(""),N=Le(),{data:b,isLoading:_,isError:k,refetch:w}=Me({queryKey:["settings",s],queryFn:async()=>{const f=await fetch(`/api/settings/${s}/raw`);if(!f.ok)throw new Error(`Failed to load settings: ${f.status}`);return f.json()}}),p=b?.settings,r=c.useMemo(()=>{if(n!==null)try{return JSON.parse(n)}catch{}if(p)return{...p,env:{...p.env,...i}}},[p,i,n]),a=c.useMemo(()=>n!==null?n:p?JSON.stringify(p,null,2):"",[n,p]),v=c.useCallback(f=>{o(f)},[]),P=(f,A)=>{const R={...r?.env||{},[f]:A};d(J=>({...J,[f]:A})),o(JSON.stringify({...r,env:R},null,2))},H=f=>{const A={...r?.env||{},...f};d(R=>({...R,...f})),o(JSON.stringify({...r,env:A},null,2))},F=()=>{if(!m.trim())return;const f=m.trim(),A=y,R={...r?.env||{},[f]:A};d(J=>({...J,[f]:A})),o(JSON.stringify({...r,env:R},null,2)),j(""),O("")},u=c.useMemo(()=>{try{return JSON.parse(a),!0}catch{return!1}},[a]),z=c.useMemo(()=>n!==null?n!==JSON.stringify(p,null,2):Object.keys(i).length>0,[n,i,p]);c.useEffect(()=>{l?.(z)},[z,l]);const K=De({mutationFn:async()=>{let f;try{f=JSON.parse(a)}catch{f={...b?.settings,env:{...b?.settings?.env,...i}}}const A=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:f,expectedMtime:b?.mtime})});if(A.status===409)throw new Error("CONFLICT");if(!A.ok)throw new Error("Failed to save");return A.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["settings",s]}),N.invalidateQueries({queryKey:["profiles"]}),d({}),o(null),Q.success("Settings saved")},onError:f=>{f.message==="CONFLICT"?x(!0):Q.error(f.message)}}),V=async f=>{x(!1),f?(await w(),K.mutate()):(d({}),o(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ts,{profileName:s,data:b,settings:r,isLoading:_,isSaving:K.isPending,hasChanges:z,isRawJsonValid:u,onRefresh:()=>w(),onDelete:t,onSave:()=>K.mutate()}),_?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(G,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):k?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>w(),children:[e.jsx(U,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):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 min-w-0",children:e.jsx(is,{profileName:s,data:b,currentSettings:r,newEnvKey:m,newEnvValue:y,onNewEnvKeyChange:j,onNewEnvValueChange:O,onEnvValueChange:P,onEnvBulkChange:H,onAddEnvVar:F})}),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(Je,{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(ke,{rawJsonContent:a,isRawJsonValid:u,rawJsonEdits:n,settings:p,onChange:v})]})]}),e.jsx(B,{open:h,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>V(!0),onCancel:()=>V(!1)})]},s)}const ae="ccs:openrouter-banner-dismissed";function os({onCreateClick:s}){const[t,l]=c.useState(!0),{modelCount:i,isLoading:d}=q();c.useEffect(()=>{const x=localStorage.getItem(ae)==="true";l(x)},[]);const h=()=>{localStorage.setItem(ae,"true"),l(!0)};return t?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(Y,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",d?"300+":`${i}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(g,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(me,{className:"w-3 h-3"})]}),e.jsxs(g,{size:"icon",variant:"ghost",onClick:h,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx($e,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ds({onOpenRouterClick:s,onCustomClick:t}){const{modelCount:l,isLoading:i}=q();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20 p-8",children:e.jsxs("div",{className:"max-w-lg w-full space-y-6",children:[e.jsxs(Ge,{className:"border-accent/30 dark:border-accent/40 bg-gradient-to-br from-accent/5 to-background dark:from-accent/10",children:[e.jsxs(Ye,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-accent/10 dark:bg-accent/20",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"w-6 h-6"})}),e.jsx(S,{variant:"secondary",className:"bg-accent/10 text-accent dark:bg-accent/20 dark:text-accent-foreground",children:"Recommended"})]}),e.jsx(Ve,{className:"text-xl",children:"Start with OpenRouter"}),e.jsxs(We,{className:"text-base",children:["Access ",i?"300+":`${l}+`," models from OpenAI, Anthropic, Google, Meta and more - all through one API."]})]}),e.jsxs(Xe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ue,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:"One API, all providers"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Y,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:"Model tier mapping"})]})]}),e.jsxs(g,{onClick:s,className:"w-full bg-accent hover:bg-accent/90 text-white",size:"lg",children:["Create OpenRouter Profile",e.jsx(Be,{className:"w-4 h-4 ml-2"})]}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Get your API key at"," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-1",children:["openrouter.ai/keys",e.jsx(me,{className:"w-3 h-3"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ee,{className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),e.jsx(ee,{className:"flex-1"})]}),e.jsx(g,{variant:"outline",onClick:t,className:"w-full",children:"Create Custom API Profile"})]})})}function xs({onCreateClick:s}){const{modelCount:t,isLoading:l}=q();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[l?"300+":`${t}+`," models available"]})]}),e.jsxs(g,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function ys(){const{data:s,isLoading:t,isError:l,refetch:i}=_e(),d=Se(),[h,x]=c.useState(null),[n,o]=c.useState(""),[m,j]=c.useState(!1),[y,O]=c.useState("normal"),[N,b]=c.useState(null),[_,k]=c.useState(!1),[w,p]=c.useState(null);Pe();const r=c.useMemo(()=>s?.profiles||[],[s?.profiles]),a=c.useMemo(()=>r.filter(u=>u.name.toLowerCase().includes(n.toLowerCase())),[r,n]),v=h?r.find(u=>u.name===h):null,P=u=>{d.mutate(u,{onSuccess:()=>{h===u&&x(null),b(null)}})},H=u=>{j(!1),_&&h!==null?p(u):x(u)},F=u=>{_&&h!==u?p(u):x(u)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:[e.jsx(os,{onCreateClick:()=>j(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0",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-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qe,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"API Profiles"})]}),e.jsxs(g,{size:"sm",onClick:()=>{j(!0)},children:[e.jsx(D,{className:"w-4 h-4 mr-1"}),"New"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(de,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(C,{placeholder:"Search profiles...",className:"pl-8 h-9",value:n,onChange:u=>o(u.target.value)})]})]}),e.jsx(I,{className:"flex-1",children:t?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading profiles..."}):l?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(he,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Failed to load profiles"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Unable to fetch API profiles. Please try again."})]}),e.jsxs(g,{size:"sm",variant:"outline",onClick:()=>i(),children:[e.jsx(U,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):a.length===0?e.jsx("div",{className:"p-4 text-center",children:r.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(qe,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"No API profiles yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Create your first profile to connect to custom API endpoints"})]}),e.jsxs(g,{size:"sm",variant:"outline",onClick:()=>{j(!0)},children:[e.jsx(D,{className:"w-4 h-4 mr-1"}),"Create Profile"]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground py-4",children:['No profiles match "',n,'"']})}):e.jsx("div",{className:"p-2 space-y-1",children:a.map(u=>e.jsx(ms,{profile:u,isSelected:h===u.name,onSelect:()=>F(u.name),onDelete:()=>b(u.name)},u.name))})}),r.length>0&&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:[r.length," profile",r.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(fe,{className:"w-3 h-3 text-green-600"}),r.filter(u=>u.configured).length," configured"]})]})}),e.jsx(xs,{onCreateClick:()=>{O("openrouter"),j(!0)}})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v?e.jsx(cs,{profileName:v.name,onDelete:()=>b(v.name),onHasChangesUpdate:k},v.name):e.jsx(ds,{onOpenRouterClick:()=>{O("openrouter"),j(!0)},onCustomClick:()=>{O("normal"),j(!0)}})})]}),e.jsx(Re,{open:m,onOpenChange:j,onSuccess:H,initialMode:y}),e.jsx(B,{open:!!N,title:"Delete Profile",description:`Are you sure you want to delete "${N}"? This will remove the settings file and cannot be undone.`,confirmText:"Delete",variant:"destructive",onConfirm:()=>N&&P(N),onCancel:()=>b(null)}),e.jsx(B,{open:!!w,title:"Unsaved Changes",description:`You have unsaved changes in "${h}". Discard and switch to "${w}"?`,confirmText:"Discard & Switch",variant:"destructive",onConfirm:()=>{k(!1),x(w),p(null)},onCancel:()=>p(null)})]})}function ms({profile:s,isSelected:t,onSelect:l,onDelete:i}){return e.jsxs("div",{className:E("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:l,children:[s.configured?e.jsx(fe,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(he,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(M,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(g,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:d=>{d.stopPropagation(),i()},children:e.jsx(oe,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{ys as ApiPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./radix-ui-CrW4rUOS.js";import"./react-vendor-B_CU-WTZ.js";import{c as d}from"./index-
|
|
1
|
+
import{j as r}from"./radix-ui-CrW4rUOS.js";import"./react-vendor-B_CU-WTZ.js";import{c as d}from"./index-PsnnKb2L.js";function n({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:d("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...t})}function c({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:d("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-title",className:d("leading-none font-semibold",a),...t})}function l({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:d("text-muted-foreground text-sm",a),...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:d("px-6",a),...t})}export{n as C,u as a,c as b,i as c,l as d};
|
package/dist/ui/assets/{cliproxy-control-panel-BQdbegqA.js → cliproxy-control-panel-DqwBL_cO.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-CrW4rUOS.js";import{r as s}from"./react-vendor-B_CU-WTZ.js";import{a as k}from"./tanstack-Dbfprw6o.js";import{af as
|
|
1
|
+
import{j as e}from"./radix-ui-CrW4rUOS.js";import{r as s}from"./react-vendor-B_CU-WTZ.js";import{a as k}from"./tanstack-Dbfprw6o.js";import{af as $}from"./index-PsnnKb2L.js";import{G as E,$ as N,Q as R,V as I,K as S,X as T}from"./icons-B9mnOvwW.js";import"./notifications-dJQY2-U6.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";const U=8317,A="ccs";function _({port:i=U}){const n=s.useRef(null),[h,p]=s.useState(!0),[b,m]=s.useState(null),[C,d]=s.useState(!1),[v,w]=s.useState(!0),{data:g,error:f}=k({queryKey:["cliproxy-server-config"],queryFn:()=>$.cliproxyServer.get(),staleTime:3e4});s.useEffect(()=>{f&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",f)},[f]);const{managementUrl:j,checkUrl:x,authToken:r,isRemote:l,displayHost:u}=s.useMemo(()=>{const t=g?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",c=t.port||(o==="https"?443:80),a=o==="https"&&c===443||o==="http"&&c===80?"":`:${c}`,y=`${o}://${t.host}${a}`;return{managementUrl:`${y}/management.html`,checkUrl:`${y}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${a}`}}return{managementUrl:`http://localhost:${i}/management.html`,checkUrl:`http://localhost:${i}/`,authToken:A,isRemote:!1,displayHost:`localhost:${i}`}},[g,i]);s.useEffect(()=>{const t=new AbortController,o=async()=>{try{(await fetch(x,{signal:t.signal})).ok?(d(!0),m(null)):(d(!1),m(l?`Remote CLIProxy at ${u} returned an error`:"CLIProxy returned an error"))}catch(a){if(a instanceof Error&&a.name==="AbortError")return;d(!1),m(l?`Remote CLIProxy at ${u} is not reachable`:"CLIProxy is not running")}},c=setTimeout(()=>t.abort(),2e3);return o().finally(()=>clearTimeout(c)),()=>t.abort()},[x,l,u]);const P=s.useCallback(()=>{if(p(!1),n.current?.contentWindow&&r)try{const t=x.replace(/\/$/,"");if(!n.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}n.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:r},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[x,r]),L=()=>{p(!0),m(null),d(!1),n.current&&(n.current.src=j)};return!C&&b?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:L,children:[e.jsx(N,{className:"w-4 h-4"}),"Retry"]})]}),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-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(R,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:b}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[v&&!h&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-green-600 font-medium",children:"Remote"}),e.jsx("span",{className:"text-blue-300 dark:text-blue-700",children:"|"})]}),e.jsx(S,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:r&&r.length>4?`***${r.slice(-4)}`:r||"ccs"})]}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>w(!1),children:e.jsx(T,{className:"h-3.5 w-3.5"})})]})}),h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(N,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?`Loading Control Panel from ${u}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:n,src:j,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:P})]})}function Q(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(_,{})})}export{Q as CliproxyControlPanelPage};
|