@kaitranntt/ccs 6.7.2-dev.1 → 7.0.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/README.md +5 -0
- package/dist/api/services/index.d.ts +3 -0
- package/dist/api/services/index.d.ts.map +1 -1
- package/dist/api/services/index.js +14 -1
- package/dist/api/services/index.js.map +1 -1
- package/dist/api/services/openrouter-catalog.d.ts +30 -0
- package/dist/api/services/openrouter-catalog.d.ts.map +1 -0
- package/dist/api/services/openrouter-catalog.js +130 -0
- package/dist/api/services/openrouter-catalog.js.map +1 -0
- package/dist/api/services/openrouter-picker.d.ts +15 -0
- package/dist/api/services/openrouter-picker.d.ts.map +1 -0
- package/dist/api/services/openrouter-picker.js +113 -0
- package/dist/api/services/openrouter-picker.js.map +1 -0
- package/dist/api/services/profile-reader.d.ts +3 -0
- package/dist/api/services/profile-reader.d.ts.map +1 -1
- package/dist/api/services/profile-reader.js +14 -9
- package/dist/api/services/profile-reader.js.map +1 -1
- package/dist/api/services/profile-writer.d.ts.map +1 -1
- package/dist/api/services/profile-writer.js +8 -3
- package/dist/api/services/profile-writer.js.map +1 -1
- package/dist/api/services/provider-presets.d.ts +36 -0
- package/dist/api/services/provider-presets.d.ts.map +1 -0
- package/dist/api/services/provider-presets.js +89 -0
- package/dist/api/services/provider-presets.js.map +1 -0
- package/dist/auth/profile-detector.d.ts.map +1 -1
- package/dist/auth/profile-detector.js +1 -4
- package/dist/auth/profile-detector.js.map +1 -1
- package/dist/cliproxy/remote-proxy-client.d.ts +4 -1
- package/dist/cliproxy/remote-proxy-client.d.ts.map +1 -1
- package/dist/cliproxy/remote-proxy-client.js +59 -13
- package/dist/cliproxy/remote-proxy-client.js.map +1 -1
- package/dist/commands/api-command.d.ts.map +1 -1
- package/dist/commands/api-command.js +82 -30
- package/dist/commands/api-command.js.map +1 -1
- package/dist/config/index.d.ts +0 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +0 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/migration-manager.d.ts.map +1 -1
- package/dist/config/migration-manager.js +0 -3
- package/dist/config/migration-manager.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +15 -0
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +1 -20
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +2 -22
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/management/recovery-manager.d.ts +3 -0
- package/dist/management/recovery-manager.d.ts.map +1 -1
- package/dist/management/recovery-manager.js +6 -11
- package/dist/management/recovery-manager.js.map +1 -1
- package/dist/ui/assets/{accounts-TAL2C0kS.js → accounts-DQwh-CP_.js} +1 -1
- package/dist/ui/assets/{analytics-RfudvP3F.js → analytics-BR435WpH.js} +1 -1
- package/dist/ui/assets/api-ALobfD8T.js +1 -0
- package/dist/ui/assets/card-ByK9DlE_.js +1 -0
- package/dist/ui/assets/{cliproxy-DZZM3xwH.js → cliproxy-BlkTmqj-.js} +2 -2
- package/dist/ui/assets/{cliproxy-control-panel-CJ2CfYod.js → cliproxy-control-panel-CvVI3tSn.js} +1 -1
- package/dist/ui/assets/{code-editor-DHMiWzkZ.js → code-editor-Bm8H1Oot.js} +2 -2
- package/dist/ui/assets/{confirm-dialog-B6derovv.js → confirm-dialog-DQeTgOVm.js} +1 -1
- package/dist/ui/assets/copilot-_EhQN_rN.js +4 -0
- package/dist/ui/assets/health-CApaflOt.js +1 -0
- package/dist/ui/assets/icons-DvvDkxaF.js +1 -0
- package/dist/ui/assets/index-DDxKFig1.js +46 -0
- package/dist/ui/assets/index-Dfyx0piD.css +1 -0
- package/dist/ui/assets/settings-ByVm4JFM.js +1 -0
- package/dist/ui/assets/{shared-CckeTo0F.js → shared-C9bG-pqJ.js} +1 -1
- package/dist/ui/assets/{switch-BjiEIbUJ.js → switch-CasTIVeB.js} +1 -1
- package/dist/ui/icons/openrouter.svg +1 -0
- package/dist/ui/index.html +3 -3
- package/dist/utils/config-manager.d.ts +3 -1
- package/dist/utils/config-manager.d.ts.map +1 -1
- package/dist/utils/config-manager.js +41 -5
- package/dist/utils/config-manager.js.map +1 -1
- package/dist/utils/update-checker.d.ts +4 -0
- package/dist/utils/update-checker.d.ts.map +1 -1
- package/dist/utils/update-checker.js +7 -3
- package/dist/utils/update-checker.js.map +1 -1
- package/dist/web-server/routes/config-routes.d.ts.map +1 -1
- package/dist/web-server/routes/config-routes.js +0 -30
- package/dist/web-server/routes/config-routes.js.map +1 -1
- package/dist/web-server/routes/index.js +1 -2
- package/dist/web-server/routes/index.js.map +1 -1
- package/dist/web-server/routes/profile-routes.d.ts +2 -0
- package/dist/web-server/routes/profile-routes.d.ts.map +1 -1
- package/dist/web-server/routes/profile-routes.js +32 -32
- package/dist/web-server/routes/profile-routes.js.map +1 -1
- package/package.json +1 -1
- package/scripts/dev-release.sh +113 -0
- package/scripts/postinstall.js +11 -220
- package/dist/config/secrets-manager.d.ts +0 -51
- package/dist/config/secrets-manager.d.ts.map +0 -1
- package/dist/config/secrets-manager.js +0 -194
- package/dist/config/secrets-manager.js.map +0 -1
- package/dist/ui/assets/api-Cex9ZMma.js +0 -1
- package/dist/ui/assets/card-DwS_SvaO.js +0 -1
- package/dist/ui/assets/copilot-gkSTJLsi.js +0 -4
- package/dist/ui/assets/health-BImNWHxF.js +0 -1
- package/dist/ui/assets/icons-ZmwVoUeR.js +0 -1
- package/dist/ui/assets/index-It66SkKf.css +0 -1
- package/dist/ui/assets/index-Z0MOeRTp.js +0 -46
- package/dist/ui/assets/settings-B6JyNGoT.js +0 -1
package/scripts/postinstall.js
CHANGED
|
@@ -68,12 +68,9 @@ function validateConfiguration() {
|
|
|
68
68
|
errors.push('~/.ccs/ directory not found');
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// Check required files
|
|
71
|
+
// Check required files (GLM/GLMT/Kimi are now optional - created via presets)
|
|
72
72
|
const requiredFiles = [
|
|
73
|
-
{ path: path.join(ccsDir, 'config.json'), name: 'config.json' }
|
|
74
|
-
{ path: path.join(ccsDir, 'glm.settings.json'), name: 'glm.settings.json' },
|
|
75
|
-
{ path: path.join(ccsDir, 'glmt.settings.json'), name: 'glmt.settings.json' },
|
|
76
|
-
{ path: path.join(ccsDir, 'kimi.settings.json'), name: 'kimi.settings.json' }
|
|
73
|
+
{ path: path.join(ccsDir, 'config.json'), name: 'config.json' }
|
|
77
74
|
];
|
|
78
75
|
|
|
79
76
|
for (const file of requiredFiles) {
|
|
@@ -156,17 +153,15 @@ function createConfigFiles() {
|
|
|
156
153
|
// Create config.json if missing
|
|
157
154
|
// NOTE: gemini/codex profiles NOT included - they are added on-demand when user
|
|
158
155
|
// runs `ccs gemini` or `ccs codex` for first time (requires OAuth auth first)
|
|
156
|
+
// NOTE: GLM/GLMT/Kimi profiles are now created via UI/CLI presets, not auto-created
|
|
159
157
|
const configPath = path.join(ccsDir, 'config.json');
|
|
160
158
|
if (!fs.existsSync(configPath)) {
|
|
161
159
|
// NOTE: No 'default' entry - when no profile specified, CCS passes through
|
|
162
160
|
// to Claude's native auth without --settings flag. This prevents env var
|
|
163
161
|
// pollution from affecting the default profile.
|
|
162
|
+
// Profiles are empty by default - users create via `ccs api create --preset` or UI
|
|
164
163
|
const config = {
|
|
165
|
-
profiles: {
|
|
166
|
-
glm: '~/.ccs/glm.settings.json',
|
|
167
|
-
glmt: '~/.ccs/glmt.settings.json',
|
|
168
|
-
kimi: '~/.ccs/kimi.settings.json'
|
|
169
|
-
}
|
|
164
|
+
profiles: {}
|
|
170
165
|
};
|
|
171
166
|
|
|
172
167
|
// Atomic write: temp file → rename
|
|
@@ -213,216 +208,12 @@ function createConfigFiles() {
|
|
|
213
208
|
}
|
|
214
209
|
}
|
|
215
210
|
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
ANTHROPIC_AUTH_TOKEN: 'YOUR_GLM_API_KEY_HERE',
|
|
223
|
-
ANTHROPIC_MODEL: 'glm-4.6',
|
|
224
|
-
ANTHROPIC_DEFAULT_OPUS_MODEL: 'glm-4.6',
|
|
225
|
-
ANTHROPIC_DEFAULT_SONNET_MODEL: 'glm-4.6',
|
|
226
|
-
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'glm-4.6'
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
// Atomic write
|
|
231
|
-
const tmpPath = `${glmSettingsPath}.tmp`;
|
|
232
|
-
fs.writeFileSync(tmpPath, JSON.stringify(glmSettings, null, 2) + '\n', 'utf8');
|
|
233
|
-
fs.renameSync(tmpPath, glmSettingsPath);
|
|
234
|
-
|
|
235
|
-
console.log('[OK] Created GLM profile: ~/.ccs/glm.settings.json');
|
|
236
|
-
console.log('');
|
|
237
|
-
console.log(' [!] Configure GLM API key:');
|
|
238
|
-
console.log(' 1. Get key from: https://api.z.ai');
|
|
239
|
-
console.log(' 2. Edit: ~/.ccs/glm.settings.json');
|
|
240
|
-
console.log(' 3. Replace: YOUR_GLM_API_KEY_HERE');
|
|
241
|
-
} else {
|
|
242
|
-
console.log('[OK] GLM profile exists: ~/.ccs/glm.settings.json (preserved)');
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Create glmt.settings.json if missing
|
|
246
|
-
const glmtSettingsPath = path.join(ccsDir, 'glmt.settings.json');
|
|
247
|
-
if (!fs.existsSync(glmtSettingsPath)) {
|
|
248
|
-
const glmtSettings = {
|
|
249
|
-
env: {
|
|
250
|
-
ANTHROPIC_BASE_URL: 'https://api.z.ai/api/coding/paas/v4/chat/completions',
|
|
251
|
-
ANTHROPIC_AUTH_TOKEN: 'YOUR_GLM_API_KEY_HERE',
|
|
252
|
-
ANTHROPIC_MODEL: 'glm-4.6',
|
|
253
|
-
ANTHROPIC_DEFAULT_OPUS_MODEL: 'glm-4.6',
|
|
254
|
-
ANTHROPIC_DEFAULT_SONNET_MODEL: 'glm-4.6',
|
|
255
|
-
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'glm-4.6',
|
|
256
|
-
ANTHROPIC_TEMPERATURE: '0.2',
|
|
257
|
-
ANTHROPIC_MAX_TOKENS: '65536',
|
|
258
|
-
MAX_THINKING_TOKENS: '32768',
|
|
259
|
-
ENABLE_STREAMING: 'true',
|
|
260
|
-
ANTHROPIC_SAFE_MODE: 'false',
|
|
261
|
-
API_TIMEOUT_MS: '3000000'
|
|
262
|
-
},
|
|
263
|
-
alwaysThinkingEnabled: true
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
// Atomic write
|
|
267
|
-
const tmpPath = `${glmtSettingsPath}.tmp`;
|
|
268
|
-
fs.writeFileSync(tmpPath, JSON.stringify(glmtSettings, null, 2) + '\n', 'utf8');
|
|
269
|
-
fs.renameSync(tmpPath, glmtSettingsPath);
|
|
270
|
-
|
|
271
|
-
console.log('[OK] Created GLMT profile: ~/.ccs/glmt.settings.json');
|
|
272
|
-
console.log('');
|
|
273
|
-
console.log(' [!] Configure GLMT API key:');
|
|
274
|
-
console.log(' 1. Get key from: https://api.z.ai');
|
|
275
|
-
console.log(' 2. Edit: ~/.ccs/glmt.settings.json');
|
|
276
|
-
console.log(' 3. Replace: YOUR_GLM_API_KEY_HERE');
|
|
277
|
-
console.log(' Note: GLMT enables GLM thinking mode (reasoning)');
|
|
278
|
-
console.log(' Defaults: Temperature 0.2, thinking enabled, 50min timeout');
|
|
279
|
-
} else {
|
|
280
|
-
console.log('[OK] GLMT profile exists: ~/.ccs/glmt.settings.json (preserved)');
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Migrate existing GLMT configs to include new defaults (v3.3.0)
|
|
284
|
-
if (fs.existsSync(glmtSettingsPath)) {
|
|
285
|
-
try {
|
|
286
|
-
const existing = JSON.parse(fs.readFileSync(glmtSettingsPath, 'utf8'));
|
|
287
|
-
let updated = false;
|
|
288
|
-
|
|
289
|
-
// Ensure env object exists
|
|
290
|
-
if (!existing.env) {
|
|
291
|
-
existing.env = {};
|
|
292
|
-
updated = true;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Add missing env vars (preserve existing values)
|
|
296
|
-
const envDefaults = {
|
|
297
|
-
ANTHROPIC_TEMPERATURE: '0.2',
|
|
298
|
-
ANTHROPIC_MAX_TOKENS: '65536',
|
|
299
|
-
MAX_THINKING_TOKENS: '32768',
|
|
300
|
-
ENABLE_STREAMING: 'true',
|
|
301
|
-
ANTHROPIC_SAFE_MODE: 'false',
|
|
302
|
-
API_TIMEOUT_MS: '3000000'
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
for (const [key, value] of Object.entries(envDefaults)) {
|
|
306
|
-
if (existing.env[key] === undefined) {
|
|
307
|
-
existing.env[key] = value;
|
|
308
|
-
updated = true;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Add alwaysThinkingEnabled if missing
|
|
313
|
-
if (existing.alwaysThinkingEnabled === undefined) {
|
|
314
|
-
existing.alwaysThinkingEnabled = true;
|
|
315
|
-
updated = true;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Write back if updated
|
|
319
|
-
if (updated) {
|
|
320
|
-
const tmpPath = `${glmtSettingsPath}.tmp`;
|
|
321
|
-
fs.writeFileSync(tmpPath, JSON.stringify(existing, null, 2) + '\n', 'utf8');
|
|
322
|
-
fs.renameSync(tmpPath, glmtSettingsPath);
|
|
323
|
-
console.log('[OK] Migrated GLMT config with new defaults (v3.3.0)');
|
|
324
|
-
console.log(' Added: temperature, max_tokens, thinking settings, alwaysThinkingEnabled');
|
|
325
|
-
}
|
|
326
|
-
} catch (err) {
|
|
327
|
-
console.warn('[!] GLMT config migration failed:', err.message);
|
|
328
|
-
console.warn(' Existing config preserved, may be missing new defaults');
|
|
329
|
-
console.warn(' You can manually add fields or delete file to regenerate');
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Create kimi.settings.json if missing
|
|
334
|
-
const kimiSettingsPath = path.join(ccsDir, 'kimi.settings.json');
|
|
335
|
-
if (!fs.existsSync(kimiSettingsPath)) {
|
|
336
|
-
const kimiSettings = {
|
|
337
|
-
env: {
|
|
338
|
-
ANTHROPIC_BASE_URL: 'https://api.kimi.com/coding/',
|
|
339
|
-
ANTHROPIC_AUTH_TOKEN: 'YOUR_KIMI_API_KEY_HERE',
|
|
340
|
-
ANTHROPIC_MODEL: 'kimi-k2-thinking-turbo',
|
|
341
|
-
ANTHROPIC_DEFAULT_OPUS_MODEL: 'kimi-k2-thinking-turbo',
|
|
342
|
-
ANTHROPIC_DEFAULT_SONNET_MODEL: 'kimi-k2-thinking-turbo',
|
|
343
|
-
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'kimi-k2-thinking-turbo'
|
|
344
|
-
},
|
|
345
|
-
alwaysThinkingEnabled: true
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
// Atomic write
|
|
349
|
-
const tmpPath = `${kimiSettingsPath}.tmp`;
|
|
350
|
-
fs.writeFileSync(tmpPath, JSON.stringify(kimiSettings, null, 2) + '\n', 'utf8');
|
|
351
|
-
fs.renameSync(tmpPath, kimiSettingsPath);
|
|
352
|
-
|
|
353
|
-
console.log('[OK] Created Kimi profile: ~/.ccs/kimi.settings.json');
|
|
354
|
-
console.log('');
|
|
355
|
-
console.log(' [!] Configure Kimi API key:');
|
|
356
|
-
console.log(' 1. Get key from: https://www.kimi.com/coding (membership page)');
|
|
357
|
-
console.log(' 2. Edit: ~/.ccs/kimi.settings.json');
|
|
358
|
-
console.log(' 3. Replace: YOUR_KIMI_API_KEY_HERE');
|
|
359
|
-
} else {
|
|
360
|
-
console.log('[OK] Kimi profile exists: ~/.ccs/kimi.settings.json (preserved)');
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// NOTE: gemini.settings.json and codex.settings.json are NOT created during install
|
|
364
|
-
// They are created on-demand when user runs `ccs gemini` or `ccs codex` for the first time
|
|
365
|
-
// This prevents confusion - users need to run `--auth` first anyway
|
|
366
|
-
|
|
367
|
-
// Migrate existing Kimi configs to use kimi-k2-thinking-turbo model (v5.5.0)
|
|
368
|
-
// Kimi API now supports model specification with thinking models
|
|
369
|
-
if (fs.existsSync(kimiSettingsPath)) {
|
|
370
|
-
try {
|
|
371
|
-
const existing = JSON.parse(fs.readFileSync(kimiSettingsPath, 'utf8'));
|
|
372
|
-
let updated = false;
|
|
373
|
-
const defaultModel = 'kimi-k2-thinking-turbo';
|
|
374
|
-
|
|
375
|
-
// Ensure env object exists
|
|
376
|
-
if (!existing.env) {
|
|
377
|
-
existing.env = {};
|
|
378
|
-
updated = true;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Add/update model fields to use kimi-k2-thinking-turbo
|
|
382
|
-
const modelFields = {
|
|
383
|
-
ANTHROPIC_MODEL: defaultModel,
|
|
384
|
-
ANTHROPIC_DEFAULT_OPUS_MODEL: defaultModel,
|
|
385
|
-
ANTHROPIC_DEFAULT_SONNET_MODEL: defaultModel,
|
|
386
|
-
ANTHROPIC_DEFAULT_HAIKU_MODEL: defaultModel
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
for (const [field, value] of Object.entries(modelFields)) {
|
|
390
|
-
if (existing.env[field] !== value) {
|
|
391
|
-
existing.env[field] = value;
|
|
392
|
-
updated = true;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// Remove deprecated ANTHROPIC_SMALL_FAST_MODEL if present
|
|
397
|
-
if (existing.env.ANTHROPIC_SMALL_FAST_MODEL !== undefined) {
|
|
398
|
-
delete existing.env.ANTHROPIC_SMALL_FAST_MODEL;
|
|
399
|
-
updated = true;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// Ensure required fields exist
|
|
403
|
-
if (!existing.env.ANTHROPIC_BASE_URL) {
|
|
404
|
-
existing.env.ANTHROPIC_BASE_URL = 'https://api.kimi.com/coding/';
|
|
405
|
-
updated = true;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// Add alwaysThinkingEnabled if missing
|
|
409
|
-
if (existing.alwaysThinkingEnabled === undefined) {
|
|
410
|
-
existing.alwaysThinkingEnabled = true;
|
|
411
|
-
updated = true;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Write back if updated
|
|
415
|
-
if (updated) {
|
|
416
|
-
const tmpPath = `${kimiSettingsPath}.tmp`;
|
|
417
|
-
fs.writeFileSync(tmpPath, JSON.stringify(existing, null, 2) + '\n', 'utf8');
|
|
418
|
-
fs.renameSync(tmpPath, kimiSettingsPath);
|
|
419
|
-
console.log('[OK] Migrated Kimi config (v5.5.0): updated to kimi-k2-thinking-turbo model');
|
|
420
|
-
}
|
|
421
|
-
} catch (err) {
|
|
422
|
-
console.warn('[!] Kimi config migration failed:', err.message);
|
|
423
|
-
console.warn(' Existing config preserved');
|
|
424
|
-
}
|
|
425
|
-
}
|
|
211
|
+
// NOTE: GLM, GLMT, and Kimi profiles are NO LONGER auto-created during install
|
|
212
|
+
// Users can create these via:
|
|
213
|
+
// - UI: Profile Create Dialog → Provider Presets
|
|
214
|
+
// - CLI: ccs api create --preset glm|glmt|kimi
|
|
215
|
+
// This gives users control over which providers they want to use
|
|
216
|
+
// Existing profiles are preserved for backward compatibility
|
|
426
217
|
|
|
427
218
|
// Copy shell completion files to ~/.ccs/completions/
|
|
428
219
|
const completionsDir = path.join(ccsDir, 'completions');
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Secrets Manager
|
|
3
|
-
*
|
|
4
|
-
* Handles loading and saving secrets (API keys, tokens) in a separate file
|
|
5
|
-
* with restricted permissions (chmod 600).
|
|
6
|
-
*/
|
|
7
|
-
import { SecretsConfig } from './unified-config-types';
|
|
8
|
-
export { isSensitiveKey as isSecretKey } from '../utils/sensitive-keys';
|
|
9
|
-
/**
|
|
10
|
-
* Get path to secrets.yaml
|
|
11
|
-
*/
|
|
12
|
-
export declare function getSecretsPath(): string;
|
|
13
|
-
/**
|
|
14
|
-
* Check if secrets.yaml exists
|
|
15
|
-
*/
|
|
16
|
-
export declare function hasSecrets(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Load secrets from YAML file.
|
|
19
|
-
* Returns empty secrets config if file doesn't exist.
|
|
20
|
-
*/
|
|
21
|
-
export declare function loadSecrets(): SecretsConfig;
|
|
22
|
-
/**
|
|
23
|
-
* Save secrets to YAML file with restricted permissions.
|
|
24
|
-
* Uses atomic write (temp file + rename) to prevent corruption.
|
|
25
|
-
*/
|
|
26
|
-
export declare function saveSecrets(secrets: SecretsConfig): void;
|
|
27
|
-
/**
|
|
28
|
-
* Get a secret value for a specific profile.
|
|
29
|
-
*/
|
|
30
|
-
export declare function getProfileSecret(profileName: string, key: string): string | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* Set a secret value for a specific profile.
|
|
33
|
-
*/
|
|
34
|
-
export declare function setProfileSecret(profileName: string, key: string, value: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* Delete a secret value for a specific profile.
|
|
37
|
-
*/
|
|
38
|
-
export declare function deleteProfileSecret(profileName: string, key: string): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Get all secrets for a profile.
|
|
41
|
-
*/
|
|
42
|
-
export declare function getProfileSecrets(profileName: string): Record<string, string>;
|
|
43
|
-
/**
|
|
44
|
-
* Set all secrets for a profile (replaces existing).
|
|
45
|
-
*/
|
|
46
|
-
export declare function setProfileSecrets(profileName: string, profileSecrets: Record<string, string>): void;
|
|
47
|
-
/**
|
|
48
|
-
* Delete all secrets for a profile.
|
|
49
|
-
*/
|
|
50
|
-
export declare function deleteAllProfileSecrets(profileName: string): boolean;
|
|
51
|
-
//# sourceMappingURL=secrets-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secrets-manager.d.ts","sourceRoot":"","sources":["../../src/config/secrets-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,aAAa,EAA6C,MAAM,wBAAwB,CAAC;AAGlG,OAAO,EAAE,cAAc,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAKxE;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,aAAa,CAsB3C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAqCxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGrF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAStF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAgB7E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAG7E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,IAAI,CAUN;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAUpE"}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Secrets Manager
|
|
4
|
-
*
|
|
5
|
-
* Handles loading and saving secrets (API keys, tokens) in a separate file
|
|
6
|
-
* with restricted permissions (chmod 600).
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.deleteAllProfileSecrets = exports.setProfileSecrets = exports.getProfileSecrets = exports.deleteProfileSecret = exports.setProfileSecret = exports.getProfileSecret = exports.saveSecrets = exports.loadSecrets = exports.hasSecrets = exports.getSecretsPath = exports.isSecretKey = void 0;
|
|
33
|
-
const fs = __importStar(require("fs"));
|
|
34
|
-
const path = __importStar(require("path"));
|
|
35
|
-
const yaml = __importStar(require("js-yaml"));
|
|
36
|
-
const config_manager_1 = require("../utils/config-manager");
|
|
37
|
-
const unified_config_types_1 = require("./unified-config-types");
|
|
38
|
-
// Re-export from shared utility for backward compatibility
|
|
39
|
-
var sensitive_keys_1 = require("../utils/sensitive-keys");
|
|
40
|
-
Object.defineProperty(exports, "isSecretKey", { enumerable: true, get: function () { return sensitive_keys_1.isSensitiveKey; } });
|
|
41
|
-
const SECRETS_FILE = 'secrets.yaml';
|
|
42
|
-
const SECRETS_FILE_MODE = 0o600; // Owner read/write only
|
|
43
|
-
/**
|
|
44
|
-
* Get path to secrets.yaml
|
|
45
|
-
*/
|
|
46
|
-
function getSecretsPath() {
|
|
47
|
-
return path.join((0, config_manager_1.getCcsDir)(), SECRETS_FILE);
|
|
48
|
-
}
|
|
49
|
-
exports.getSecretsPath = getSecretsPath;
|
|
50
|
-
/**
|
|
51
|
-
* Check if secrets.yaml exists
|
|
52
|
-
*/
|
|
53
|
-
function hasSecrets() {
|
|
54
|
-
return fs.existsSync(getSecretsPath());
|
|
55
|
-
}
|
|
56
|
-
exports.hasSecrets = hasSecrets;
|
|
57
|
-
/**
|
|
58
|
-
* Load secrets from YAML file.
|
|
59
|
-
* Returns empty secrets config if file doesn't exist.
|
|
60
|
-
*/
|
|
61
|
-
function loadSecrets() {
|
|
62
|
-
const secretsPath = getSecretsPath();
|
|
63
|
-
if (!fs.existsSync(secretsPath)) {
|
|
64
|
-
return (0, unified_config_types_1.createEmptySecretsConfig)();
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
const content = fs.readFileSync(secretsPath, 'utf8');
|
|
68
|
-
const parsed = yaml.load(content);
|
|
69
|
-
if (!(0, unified_config_types_1.isSecretsConfig)(parsed)) {
|
|
70
|
-
console.error(`[!] Invalid secrets format in ${secretsPath}`);
|
|
71
|
-
return (0, unified_config_types_1.createEmptySecretsConfig)();
|
|
72
|
-
}
|
|
73
|
-
return parsed;
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
const error = err instanceof Error ? err.message : 'Unknown error';
|
|
77
|
-
console.error(`[X] Failed to load secrets: ${error}`);
|
|
78
|
-
return (0, unified_config_types_1.createEmptySecretsConfig)();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.loadSecrets = loadSecrets;
|
|
82
|
-
/**
|
|
83
|
-
* Save secrets to YAML file with restricted permissions.
|
|
84
|
-
* Uses atomic write (temp file + rename) to prevent corruption.
|
|
85
|
-
*/
|
|
86
|
-
function saveSecrets(secrets) {
|
|
87
|
-
const secretsPath = getSecretsPath();
|
|
88
|
-
const dir = path.dirname(secretsPath);
|
|
89
|
-
// Ensure directory exists
|
|
90
|
-
if (!fs.existsSync(dir)) {
|
|
91
|
-
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
92
|
-
}
|
|
93
|
-
// Convert to YAML
|
|
94
|
-
const content = yaml.dump(secrets, {
|
|
95
|
-
indent: 2,
|
|
96
|
-
lineWidth: -1,
|
|
97
|
-
quotingType: '"',
|
|
98
|
-
noRefs: true,
|
|
99
|
-
});
|
|
100
|
-
// Atomic write: write to temp file, then rename
|
|
101
|
-
const tempPath = `${secretsPath}.tmp.${process.pid}`;
|
|
102
|
-
try {
|
|
103
|
-
fs.writeFileSync(tempPath, content, { mode: SECRETS_FILE_MODE });
|
|
104
|
-
fs.renameSync(tempPath, secretsPath);
|
|
105
|
-
// Ensure correct permissions after rename (some systems may not preserve)
|
|
106
|
-
fs.chmodSync(secretsPath, SECRETS_FILE_MODE);
|
|
107
|
-
}
|
|
108
|
-
catch (err) {
|
|
109
|
-
// Clean up temp file on error
|
|
110
|
-
if (fs.existsSync(tempPath)) {
|
|
111
|
-
try {
|
|
112
|
-
fs.unlinkSync(tempPath);
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
// Ignore cleanup errors
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
throw err;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
exports.saveSecrets = saveSecrets;
|
|
122
|
-
/**
|
|
123
|
-
* Get a secret value for a specific profile.
|
|
124
|
-
*/
|
|
125
|
-
function getProfileSecret(profileName, key) {
|
|
126
|
-
const secrets = loadSecrets();
|
|
127
|
-
return secrets.profiles[profileName]?.[key];
|
|
128
|
-
}
|
|
129
|
-
exports.getProfileSecret = getProfileSecret;
|
|
130
|
-
/**
|
|
131
|
-
* Set a secret value for a specific profile.
|
|
132
|
-
*/
|
|
133
|
-
function setProfileSecret(profileName, key, value) {
|
|
134
|
-
const secrets = loadSecrets();
|
|
135
|
-
if (!secrets.profiles[profileName]) {
|
|
136
|
-
secrets.profiles[profileName] = {};
|
|
137
|
-
}
|
|
138
|
-
secrets.profiles[profileName][key] = value;
|
|
139
|
-
saveSecrets(secrets);
|
|
140
|
-
}
|
|
141
|
-
exports.setProfileSecret = setProfileSecret;
|
|
142
|
-
/**
|
|
143
|
-
* Delete a secret value for a specific profile.
|
|
144
|
-
*/
|
|
145
|
-
function deleteProfileSecret(profileName, key) {
|
|
146
|
-
const secrets = loadSecrets();
|
|
147
|
-
if (!secrets.profiles[profileName]?.[key]) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
delete secrets.profiles[profileName][key];
|
|
151
|
-
// Clean up empty profile object
|
|
152
|
-
if (Object.keys(secrets.profiles[profileName]).length === 0) {
|
|
153
|
-
delete secrets.profiles[profileName];
|
|
154
|
-
}
|
|
155
|
-
saveSecrets(secrets);
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
exports.deleteProfileSecret = deleteProfileSecret;
|
|
159
|
-
/**
|
|
160
|
-
* Get all secrets for a profile.
|
|
161
|
-
*/
|
|
162
|
-
function getProfileSecrets(profileName) {
|
|
163
|
-
const secrets = loadSecrets();
|
|
164
|
-
return secrets.profiles[profileName] || {};
|
|
165
|
-
}
|
|
166
|
-
exports.getProfileSecrets = getProfileSecrets;
|
|
167
|
-
/**
|
|
168
|
-
* Set all secrets for a profile (replaces existing).
|
|
169
|
-
*/
|
|
170
|
-
function setProfileSecrets(profileName, profileSecrets) {
|
|
171
|
-
const secrets = loadSecrets();
|
|
172
|
-
if (Object.keys(profileSecrets).length === 0) {
|
|
173
|
-
delete secrets.profiles[profileName];
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
secrets.profiles[profileName] = profileSecrets;
|
|
177
|
-
}
|
|
178
|
-
saveSecrets(secrets);
|
|
179
|
-
}
|
|
180
|
-
exports.setProfileSecrets = setProfileSecrets;
|
|
181
|
-
/**
|
|
182
|
-
* Delete all secrets for a profile.
|
|
183
|
-
*/
|
|
184
|
-
function deleteAllProfileSecrets(profileName) {
|
|
185
|
-
const secrets = loadSecrets();
|
|
186
|
-
if (!secrets.profiles[profileName]) {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
delete secrets.profiles[profileName];
|
|
190
|
-
saveSecrets(secrets);
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
|
-
exports.deleteAllProfileSecrets = deleteAllProfileSecrets;
|
|
194
|
-
//# sourceMappingURL=secrets-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secrets-manager.js","sourceRoot":"","sources":["../../src/config/secrets-manager.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,8CAAgC;AAChC,4DAAoD;AACpD,iEAAkG;AAElG,2DAA2D;AAC3D,0DAAwE;AAA/D,6GAAA,cAAc,OAAe;AAEtC,MAAM,YAAY,GAAG,cAAc,CAAC;AACpC,MAAM,iBAAiB,GAAG,KAAK,CAAC,CAAC,wBAAwB;AAEzD;;GAEG;AACH,SAAgB,cAAc;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAA,0BAAS,GAAE,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AAFD,wCAEC;AAED;;GAEG;AACH,SAAgB,UAAU;IACxB,OAAO,EAAE,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;AACzC,CAAC;AAFD,gCAEC;AAED;;;GAGG;AACH,SAAgB,WAAW;IACzB,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,OAAO,IAAA,+CAAwB,GAAE,CAAC;IACpC,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAElC,IAAI,CAAC,IAAA,sCAAe,EAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,iCAAiC,WAAW,EAAE,CAAC,CAAC;YAC9D,OAAO,IAAA,+CAAwB,GAAE,CAAC;QACpC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACnE,OAAO,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;QACtD,OAAO,IAAA,+CAAwB,GAAE,CAAC;IACpC,CAAC;AACH,CAAC;AAtBD,kCAsBC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,OAAsB;IAChD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAEtC,0BAA0B;IAC1B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,kBAAkB;IAClB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjC,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC,CAAC;QACb,WAAW,EAAE,GAAG;QAChB,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;IAEH,gDAAgD;IAChD,MAAM,QAAQ,GAAG,GAAG,WAAW,QAAQ,OAAO,CAAC,GAAG,EAAE,CAAC;IAErD,IAAI,CAAC;QACH,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACjE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAErC,0EAA0E;QAC1E,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,8BAA8B;QAC9B,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACH,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;QACH,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AArCD,kCAqCC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,WAAmB,EAAE,GAAW;IAC/D,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC;AAHD,4CAGC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,WAAmB,EAAE,GAAW,EAAE,KAAa;IAC9E,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAE9B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;IAED,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC3C,WAAW,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC;AATD,4CASC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,WAAmB,EAAE,GAAW;IAClE,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAE9B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC;IAE1C,gCAAgC;IAChC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5D,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAED,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC;AACd,CAAC;AAhBD,kDAgBC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,WAAmB;IACnD,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;AAC7C,CAAC;AAHD,8CAGC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAC/B,WAAmB,EACnB,cAAsC;IAEtC,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAE9B,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7C,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC;IACjD,CAAC;IAED,WAAW,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC;AAbD,8CAaC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,WAAmB;IACzD,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAE9B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACrC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC;AACd,CAAC;AAVD,0DAUC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-CV3R9pD6.js";import{r as d}from"./react-vendor-FspHSO0w.js";import{e as C,B as f,I as E,i as L,L as P,k,T as B,l as Y,m as F,n as M,R as W,o as X,p as G,q as Z,c as ee}from"./index-Z0MOeRTp.js";import{C as _,S as se}from"./confirm-dialog-B6derovv.js";import{u as te,a as ae,b as ne}from"./tanstack-Df9bCj5R.js";import{t as D}from"./notifications-B2Pz7lik.js";import{a2 as T,a5 as $,L as K,a6 as re,E as ie,d as le,J as I,I as ce,a7 as oe,$ as de,a8 as me,a9 as U,aa as xe,k as V,z as ue,D as he}from"./icons-ZmwVoUeR.js";import"./utils-CzKF5WmX.js";import"./form-utils-DP6ILe7Z.js";import"./code-highlight-BoHWVYut.js";function fe({profileName:s,data:t,isLoading:n,isSaving:c,hasChanges:u,isRawJsonValid:a,onRefresh:i,onDelete:o,onSave:g}){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(C,{variant:"outline",className:"text-xs",children:t.path.replace(/^.*\//,"")})]}),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(f,{variant:"ghost",size:"sm",onClick:i,disabled:n,children:e.jsx(T,{className:`w-4 h-4 ${n?"animate-spin":""}`})}),o&&e.jsx(f,{variant:"ghost",size:"sm",onClick:o,children:e.jsx($,{className:"w-4 h-4 text-destructive"})}),e.jsx(f,{size:"sm",onClick:g,disabled:c||!u||!a,children:c?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function pe({label:s,...t}){const[n,c]=d.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(E,{type:n?"text":"password",className:"pr-10 font-mono",...t}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>c(!n),tabIndex:-1,children:n?e.jsx(ie,{className:"w-4 h-4"}):e.jsx(le,{className:"w-4 h-4"})})]})]})}function z(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function je({currentSettings:s,newEnvKey:t,onNewEnvKeyChange:n,onEnvValueChange:c,onAddEnvVar:u}){return e.jsxs(e.Fragment,{children:[e.jsx(L,{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(([a,i])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(P,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[a,z(a)&&e.jsx(C,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:"sensitive"})]}),z(a)?e.jsx(pe,{value:i,onChange:o=>c(a,o.target.value),className:"font-mono text-sm h-8"}):e.jsx(E,{value:i,onChange:o=>c(a,o.target.value),className:"font-mono text-sm h-8"})]},a))}):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(P,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(E,{placeholder:"VARIABLE_NAME",value:t,onChange:a=>n(a.target.value.toUpperCase()),className:"font-mono text-sm h-8",onKeyDown:a=>a.key==="Enter"&&u()}),e.jsx(f,{variant:"outline",size:"sm",className:"h-8",onClick:u,disabled:!t.trim(),children:e.jsx(I,{className:"w-4 h-4"})})]})]})]})}function ge({profileName:s,data:t}){return e.jsx(L,{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(ce,{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(k,{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(P,{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(k,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(P,{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(k,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Ne({profileName:s,data:t,currentSettings:n,newEnvKey:c,onNewEnvKeyChange:u,onEnvValueChange:a,onAddEnvVar:i}){return e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(B,{defaultValue:"env",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Y,{className:"w-full",children:[e.jsx(F,{value:"env",className:"flex-1",children:"Environment Variables"}),e.jsx(F,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(M,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(je,{currentSettings:n,newEnvKey:c,onNewEnvKeyChange:u,onEnvValueChange:a,onAddEnvVar:i})}),e.jsx(M,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(ge,{profileName:s,data:t})})]})]})})}function ve({profileName:s,onDelete:t}){const[n,c]=d.useState({}),[u,a]=d.useState(!1),[i,o]=d.useState(null),[g,S]=d.useState(""),p=te(),{data:h,isLoading:N,isError:m,refetch:w}=ae({queryKey:["settings",s],queryFn:async()=>{const l=await fetch(`/api/settings/${s}/raw`);if(!l.ok)throw new Error(`Failed to load settings: ${l.status}`);return l.json()}}),x=h?.settings,v=d.useMemo(()=>{if(i!==null)try{return JSON.parse(i)}catch{}if(x)return{...x,env:{...x.env,...n}}},[x,n,i]),y=d.useMemo(()=>i!==null?i:x?JSON.stringify(x,null,2):"",[i,x]),b=d.useCallback(l=>{o(l)},[]),r=(l,j)=>{const A={...v?.env||{},[l]:j};c(q=>({...q,[l]:j})),o(JSON.stringify({...v,env:A},null,2))},H=()=>{if(!g.trim())return;const l=g.trim(),j={...v?.env||{},[l]:""};c(A=>({...A,[l]:""})),o(JSON.stringify({...v,env:j},null,2)),S("")},R=d.useMemo(()=>{try{return JSON.parse(y),!0}catch{return!1}},[y]),Q=d.useMemo(()=>i!==null?i!==JSON.stringify(x,null,2):Object.keys(n).length>0,[i,n,x]),O=ne({mutationFn:async()=>{let l;try{l=JSON.parse(y)}catch{l={...h?.settings,env:{...h?.settings?.env,...n}}}const j=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:l,expectedMtime:h?.mtime})});if(j.status===409)throw new Error("CONFLICT");if(!j.ok)throw new Error("Failed to save");return j.json()},onSuccess:()=>{p.invalidateQueries({queryKey:["settings",s]}),p.invalidateQueries({queryKey:["profiles"]}),c({}),o(null),D.success("Settings saved")},onError:l=>{l.message==="CONFLICT"?a(!0):D.error(l.message)}}),J=async l=>{a(!1),l?(await w(),O.mutate()):(c({}),o(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(fe,{profileName:s,data:h,isLoading:N,isSaving:O.isPending,hasChanges:Q,isRawJsonValid:R,onRefresh:()=>w(),onDelete:t,onSave:()=>O.mutate()}),N?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(K,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):m?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(f,{variant:"outline",size:"sm",onClick:()=>w(),children:[e.jsx(T,{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",children:e.jsx(Ne,{profileName:s,data:h,currentSettings:v,newEnvKey:g,onNewEnvKeyChange:S,onEnvValueChange:r,onAddEnvVar:H})}),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(oe,{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(W,{rawJsonContent:y,isRawJsonValid:R,rawJsonEdits:i,settings:x,onChange:b})]})]}),e.jsx(_,{open:u,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>J(!0),onCancel:()=>J(!1)})]},s)}function Te(){const{data:s,isLoading:t,isError:n,refetch:c}=X(),u=G(),[a,i]=d.useState(null),[o,g]=d.useState(""),[S,p]=d.useState(!1),[h,N]=d.useState(null),m=d.useMemo(()=>s?.profiles||[],[s?.profiles]),w=d.useMemo(()=>m.filter(r=>r.name.toLowerCase().includes(o.toLowerCase())),[m,o]),x=d.useMemo(()=>a&&m.some(r=>r.name===a)?a:m.length>0?m[0].name:null,[a,m]),v=r=>{u.mutate(r,{onSuccess:()=>{a===r&&i(null),N(null)}})},y=r=>{p(!1),i(r)},b=m.find(r=>r.name===x);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-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"API Profiles"})]}),e.jsxs(f,{size:"sm",onClick:()=>{p(!0)},children:[e.jsx(I,{className:"w-4 h-4 mr-1"}),"New"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(me,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(E,{placeholder:"Search profiles...",className:"pl-8 h-9",value:o,onChange:r=>g(r.target.value)})]})]}),e.jsx(L,{className:"flex-1",children:t?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading profiles..."}):n?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(U,{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(f,{size:"sm",variant:"outline",onClick:()=>c(),children:[e.jsx(T,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):w.length===0?e.jsx("div",{className:"p-4 text-center",children:m.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(xe,{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(f,{size:"sm",variant:"outline",onClick:()=>{p(!0)},children:[e.jsx(I,{className:"w-4 h-4 mr-1"}),"Create Profile"]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground py-4",children:['No profiles match "',o,'"']})}):e.jsx("div",{className:"p-2 space-y-1",children:w.map(r=>e.jsx(we,{profile:r,isSelected:x===r.name,onSelect:()=>{i(r.name)},onDelete:()=>N(r.name)},r.name))})}),m.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:[m.length," profile",m.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(V,{className:"w-3 h-3 text-green-600"}),m.filter(r=>r.configured).length," configured"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:b?e.jsx(ve,{profileName:b.name,onDelete:()=>N(b.name)}):e.jsx(ye,{onCreateClick:()=>{p(!0)}})}),e.jsx(Z,{open:S,onOpenChange:p,onSuccess:y}),e.jsx(_,{open:!!h,title:"Delete Profile",description:`Are you sure you want to delete "${h}"? This will remove the settings file and cannot be undone.`,confirmText:"Delete",variant:"destructive",onConfirm:()=>h&&v(h),onCancel:()=>N(null)})]})}function we({profile:s,isSelected:t,onSelect:n,onDelete:c}){return e.jsxs("div",{className:ee("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:n,children:[s.configured?e.jsx(V,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(U,{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(k,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:u=>{u.stopPropagation(),c()},children:e.jsx($,{className:"w-3.5 h-3.5 text-destructive"})})]})}function ye({onCreateClick: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(ue,{className:"w-16 h-16 mx-auto text-muted-foreground/30 mb-6"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"API Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Configure custom API endpoints for Claude CLI. Connect to proxy services like copilot-api, OpenRouter, or your own API backend."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(f,{onClick:s,className:"w-full",children:[e.jsx(I,{className:"w-4 h-4 mr-2"}),"Create Your First Profile"]}),e.jsx(se,{className:"my-4"}),e.jsxs("div",{className:"text-left space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"What you can configure:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1.5",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(C,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"URL"}),e.jsx("span",{children:"Custom API base URL endpoint"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(C,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"Auth"}),e.jsx("span",{children:"API key or authentication token"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(C,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"Models"}),e.jsx("span",{children:"Model mapping for Opus/Sonnet/Haiku"})]})]})]}),e.jsx("div",{className:"pt-4",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs#api-profiles",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-xs text-primary hover:underline",children:["Learn more about API profiles",e.jsx(he,{className:"w-3 h-3 ml-1"})]})})]})]})})}export{Te as ApiPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./radix-ui-CV3R9pD6.js";import"./react-vendor-FspHSO0w.js";import{c as o}from"./index-Z0MOeRTp.js";function n({className:a,...r}){return t.jsx("div",{"data-slot":"card",className:o("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...r})}function c({className:a,...r}){return t.jsx("div",{"data-slot":"card-header",className:o("@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),...r})}function i({className:a,...r}){return t.jsx("div",{"data-slot":"card-title",className:o("leading-none font-semibold",a),...r})}function l({className:a,...r}){return t.jsx("div",{"data-slot":"card-content",className:o("px-6",a),...r})}export{n as C,l as a,c as b,i as c};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/code-editor-DHMiWzkZ.js","assets/radix-ui-CV3R9pD6.js","assets/react-vendor-FspHSO0w.js","assets/index-Z0MOeRTp.js","assets/tanstack-Df9bCj5R.js","assets/notifications-B2Pz7lik.js","assets/utils-CzKF5WmX.js","assets/icons-ZmwVoUeR.js","assets/form-utils-DP6ILe7Z.js","assets/code-highlight-BoHWVYut.js","assets/index-It66SkKf.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{j as e}from"./radix-ui-CV3R9pD6.js";import{e as y,B as N,r as le,s as oe,t as re,v as ce,H as je,J as ve,w as Q,n as Y,i as $,L as b,I as te,k as de,a1 as Ne,a2 as we,S as w,T as ye,l as be,m as z,c as W}from"./index-Z0MOeRTp.js";import{u as Ce,a as M,b as C}from"./tanstack-Df9bCj5R.js";import{S as X,C as Se}from"./confirm-dialog-B6derovv.js";import{a2 as me,L as Z,a6 as ke,j as Fe,_ as Pe,Z as ae,I as Me,X as Le,a7 as Te,a as Ae,u as Ee,$ as Re,ak as _e,ag as ne,K as Oe,a1 as Ie,al as qe,k as ue,l as xe}from"./icons-ZmwVoUeR.js";import{S as B}from"./switch-BjiEIbUJ.js";import{r as v}from"./react-vendor-FspHSO0w.js";import{t as H}from"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-DP6ILe7Z.js";import"./code-highlight-BoHWVYut.js";const f="/api";async function De(){const s=await fetch(`${f}/copilot/status`);if(!s.ok)throw new Error("Failed to fetch copilot status");return s.json()}async function Ue(){const s=await fetch(`${f}/copilot/config`);if(!s.ok)throw new Error("Failed to fetch copilot config");return s.json()}async function Je(){const s=await fetch(`${f}/copilot/models`);if(!s.ok)throw new Error("Failed to fetch copilot models");return s.json()}async function Qe(){const s=await fetch(`${f}/copilot/settings/raw`);if(!s.ok)throw new Error("Failed to fetch copilot raw settings");return s.json()}async function $e(s){const t=await fetch(`${f}/copilot/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update copilot config");return t.json()}async function Ke(s){const t=await fetch(`${f}/copilot/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Error("CONFLICT");if(!t.ok)throw new Error("Failed to save copilot raw settings");return t.json()}async function Ge(){const s=await fetch(`${f}/copilot/auth/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start auth");return s.json()}async function ze(){const s=await fetch(`${f}/copilot/daemon/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start daemon");return s.json()}async function Be(){const s=await fetch(`${f}/copilot/daemon/stop`,{method:"POST"});if(!s.ok)throw new Error("Failed to stop daemon");return s.json()}async function He(){const s=await fetch(`${f}/copilot/info`);if(!s.ok)throw new Error("Failed to fetch copilot info");return s.json()}async function Ve(s){const t=await fetch(`${f}/copilot/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{version:s}:{})});if(!t.ok)throw new Error("Failed to install copilot-api");return t.json()}function he(){const s=Ce(),t=M({queryKey:["copilot-status"],queryFn:De,refetchInterval:5e3}),l=M({queryKey:["copilot-config"],queryFn:Ue}),o=M({queryKey:["copilot-models"],queryFn:Je}),a=M({queryKey:["copilot-raw-settings"],queryFn:Qe}),d=M({queryKey:["copilot-info"],queryFn:He}),r=C({mutationFn:$e,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=C({mutationFn:Ke,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=C({mutationFn:Ge,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),p=C({mutationFn:ze,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),x=C({mutationFn:Be,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),n=C({mutationFn:Ve,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-info"]})}});return{status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:l.data,configLoading:l.isLoading,models:o.data?.models??[],currentModel:o.data?.current,modelsLoading:o.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending,startAuth:u.mutate,startAuthAsync:u.mutateAsync,isAuthenticating:u.isPending,authResult:u.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:x.mutate,isStoppingDaemon:x.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}}function We({rawSettings:s,rawSettingsLoading:t,isUpdating:l,isSavingRawSettings:o,hasChanges:a,isRawJsonValid:d,onRefresh:r,onSave:i}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),s&&e.jsx(y,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",s.exists?new Date(s.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:t,children:e.jsx(me,{className:`w-4 h-4 ${t?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:i,disabled:l||o||!a||!d,children:l||o?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const Xe=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],Ye=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ie(s){switch(s){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function Ze(s){return s==null?null:s===0?"Free":s<1?`${s}x`:s===1?"1x":`${s}x`}function D({label:s,description:t,value:l,onChange:o,models:a,disabled:d}){const r=a.find(i=>i.id===l);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsxs(le,{value:l||"",onValueChange:o,disabled:d,children:[e.jsx(oe,{className:"h-9",children:e.jsx(re,{placeholder:"Select model",children:l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:l}),r?.minPlan&&e.jsx(y,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(r.minPlan)}`,children:r.minPlan})]})})}),e.jsx(ce,{className:"max-h-[300px]",children:e.jsxs(je,{children:[e.jsxs(ve,{className:"text-xs text-muted-foreground",children:["Available Models (",a.length,")"]}),a.map(i=>e.jsx(Q,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(y,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:Ze(i.multiplier)}),i.preview&&e.jsx(y,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:"Preview"}),l===i.id&&e.jsx(Fe,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function es({currentModel:s,opusModel:t,sonnetModel:l,haikuModel:o,models:a,modelsLoading:d,onApplyPreset:r,onUpdateModel:i,onUpdateOpusModel:u,onUpdateSonnetModel:p,onUpdateHaikuModel:x}){return e.jsx(Y,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx($,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Pe,{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:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(y,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Xe.map(n=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(y,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ye.map(n=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(X,{}),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(D,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:i,models:a,disabled:d}),e.jsx(D,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:t||s,onChange:u,models:a,disabled:d}),e.jsx(D,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||s,onChange:p,models:a,disabled:d}),e.jsx(D,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:o||s,onChange:x,models:a,disabled:d})]})]})]})})})}function ss({enabled:s,autoStart:t,port:l,accountType:o,rateLimit:a,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:i,onUpdatePort:u,onUpdateAccountType:p,onUpdateRateLimit:x,onUpdateWaitOnLimit:n}){return e.jsx(Y,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx($,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{htmlFor:"enabled",className:"text-sm font-medium",children:"Enable Copilot"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow using GitHub Copilot subscription"})]}),e.jsx(B,{id:"enabled",checked:s,onCheckedChange:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Basic Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"port",className:"text-xs",children:"Port"}),e.jsx(te,{id:"port",type:"number",value:l,onChange:j=>u(parseInt(j.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"account-type",className:"text-xs",children:"Account Type"}),e.jsxs(le,{value:o,onValueChange:p,children:[e.jsx(oe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(re,{})}),e.jsxs(ce,{children:[e.jsx(Q,{value:"individual",children:"Individual"}),e.jsx(Q,{value:"business",children:"Business"}),e.jsx(Q,{value:"enterprise",children:"Enterprise"})]})]})]})]}),e.jsx(X,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Rate Limiting"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"rate-limit",className:"text-xs",children:"Rate Limit (seconds)"}),e.jsx(te,{id:"rate-limit",type:"number",value:a,onChange:j=>x(j.target.value),placeholder:"No limit",min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{htmlFor:"wait-on-limit",className:"text-xs",children:"Wait on Rate Limit"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Wait instead of error when limit hit"})]}),e.jsx(B,{id:"wait-on-limit",checked:d,onCheckedChange:n})]})]}),e.jsx(X,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Daemon Settings"}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{htmlFor:"auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start copilot-api when using profile"})]}),e.jsx(B,{id:"auto-start",checked:t,onCheckedChange:i})]})]})]})})})}function U({label:s,command:t}){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:t}),e.jsx(de,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function ts({rawSettings:s}){return e.jsx(Y,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx($,{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(Me,{className:"w-4 h-4"}),"Configuration Info"]}),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:"GitHub Copilot"})]}),s&&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:s.path}),e.jsx(de,{value:s.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:"Status"}),e.jsx(y,{variant:"outline",className:s.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:s.exists?"File exists":"Using defaults"})]})]})]})]}),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(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const as=v.lazy(()=>we(()=>import("./code-editor-DHMiWzkZ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(s=>({default:s.CodeEditor})));function ns({rawJsonContent:s,isRawJsonValid:t,rawJsonEdits:l,rawSettingsEnv:o,onChange:a}){return e.jsx(v.Suspense,{fallback:e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(Z,{className:"w-6 h-6 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:e.jsxs("div",{className:"h-full flex flex-col",children:[!t&&l!==null&&e.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[e.jsx(Le,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),e.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:e.jsx(as,{value:s,onChange:a,language:"json",minHeight:"100%"})})}),e.jsx("div",{className:"mx-6 mb-4",children:e.jsx("div",{className:"border rounded-md overflow-hidden",children:e.jsx(Ne,{profileEnv:o})})})]})})}function is(){const{config:s,configLoading:t,models:l,modelsLoading:o,rawSettings:a,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:i,saveRawSettingsAsync:u,isSavingRawSettings:p,refetchRawSettings:x}=he(),[n,j]=v.useState({}),[g,S]=v.useState(null),[K,L]=v.useState(!1),T=n.enabled??s?.enabled??!1,A=n.autoStart??s?.auto_start??!1,k=n.port??s?.port??4141,E=n.accountType??s?.account_type??"individual",R=n.model??s?.model??"claude-opus-4-5-20250514",h=n.rateLimit??s?.rate_limit?.toString()??"",_=n.waitOnLimit??s?.wait_on_limit??!0,O=n.opusModel??s?.opus_model??"",I=n.sonnetModel??s?.sonnet_model??"",F=n.haikuModel??s?.haiku_model??"",G=(m,P)=>{j(ge=>({...ge,[m]:P}))},c=m=>{j(P=>({...P,model:m.default,opusModel:m.opus,sonnetModel:m.sonnet,haikuModel:m.haiku})),H.success(`Applied "${m.name}" preset`)},q=v.useMemo(()=>g!==null?g:a?.settings?JSON.stringify(a.settings,null,2):`{
|
|
3
|
-
"env": {}
|
|
4
|
-
}`,[g,a]),pe=v.useCallback(m=>{S(m)},[]),ee=v.useMemo(()=>{try{return JSON.parse(q),!0}catch{return!1}},[q]),fe=v.useMemo(()=>{const m=Object.keys(n).length>0,P=g!==null&&g!==JSON.stringify(a?.settings,null,2);return m||P},[n,g,a]),se=async()=>{try{if(Object.keys(n).length>0&&await r({enabled:T,auto_start:A,port:k,account_type:E,model:R,rate_limit:h?parseInt(h,10):null,wait_on_limit:_,opus_model:O||void 0,sonnet_model:I||void 0,haiku_model:F||void 0}),g!==null&&ee){const m=JSON.parse(q);await u({settings:m,expectedMtime:a?.mtime})}j({}),S(null),H.success("Copilot configuration saved")}catch(m){m.message==="CONFLICT"?L(!0):H.error("Failed to save settings")}};return{configLoading:t,rawSettingsLoading:d,modelsLoading:o,isUpdating:i,isSavingRawSettings:p,models:l,rawSettings:a,rawJsonContent:q,rawJsonEdits:g,enabled:T,autoStart:A,port:k,accountType:E,currentModel:R,rateLimit:h,waitOnLimit:_,opusModel:O,sonnetModel:I,haikuModel:F,isRawJsonValid:ee,hasChanges:fe,conflictDialog:K,updateField:G,applyPreset:c,handleRawJsonChange:pe,handleSave:se,handleConflictResolve:async m=>{L(!1),m?(await x(),se()):S(null)},refetchRawSettings:x}}function ls(){const{configLoading:s,rawSettingsLoading:t,modelsLoading:l,isUpdating:o,isSavingRawSettings:a,models:d,rawSettings:r,rawJsonContent:i,rawJsonEdits:u,enabled:p,autoStart:x,port:n,accountType:j,currentModel:g,rateLimit:S,waitOnLimit:K,opusModel:L,sonnetModel:T,haikuModel:A,isRawJsonValid:k,hasChanges:E,conflictDialog:R,updateField:h,applyPreset:_,handleRawJsonChange:O,handleSave:I,handleConflictResolve:F,refetchRawSettings:G}=is();return s||t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(w,{className:"h-10 w-full"}),e.jsx(w,{className:"h-10 w-full"}),e.jsx(w,{className:"h-10 w-full"}),e.jsx(w,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(We,{rawSettings:r,rawSettingsLoading:t,isUpdating:o,isSavingRawSettings:a,hasChanges:E,isRawJsonValid:k,onRefresh:()=>G(),onSave:I}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(ye,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(be,{className:"w-full",children:[e.jsx(z,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(z,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(z,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(es,{currentModel:g,opusModel:L,sonnetModel:T,haikuModel:A,models:d,modelsLoading:l,onApplyPreset:_,onUpdateModel:c=>h("model",c),onUpdateOpusModel:c=>h("opusModel",c),onUpdateSonnetModel:c=>h("sonnetModel",c),onUpdateHaikuModel:c=>h("haikuModel",c)}),e.jsx(ss,{enabled:p,autoStart:x,port:n,accountType:j,rateLimit:S,waitOnLimit:K,onUpdateEnabled:c=>h("enabled",c),onUpdateAutoStart:c=>h("autoStart",c),onUpdatePort:c=>h("port",c),onUpdateAccountType:c=>h("accountType",c),onUpdateRateLimit:c=>h("rateLimit",c),onUpdateWaitOnLimit:c=>h("waitOnLimit",c)}),e.jsx(ts,{rawSettings:r})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 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(Te,{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(ns,{rawJsonContent:i,isRawJsonValid:k,rawJsonEdits:u,rawSettingsEnv:r?.settings?.env,onChange:O})]})]}),e.jsx(Se,{open:R,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>F(!0),onCancel:()=>F(!1)})]})}function V({title:s,children:t}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:s}),e.jsx("div",{className:"space-y-1",children:t})]})}function J({icon:s,label:t,status:l,statusText:o,variant:a="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(s,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:t})}),e.jsx("div",{className:"flex items-center gap-1.5",children:l?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:W("w-4 h-4",a==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:W("text-xs",a==="warning"?"text-yellow-500":"text-green-500"),children:o||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:o||"No"})]})})]})}function os(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(w,{className:"h-8 w-full"}),e.jsx(w,{className:"h-12 w-full"}),e.jsx(w,{className:"h-12 w-full"}),e.jsx(w,{className:"h-12 w-full"})]})}function Ns(){const{status:s,statusLoading:t,refetchStatus:l,startAuth:o,isAuthenticating:a,startDaemon:d,isStartingDaemon:r,stopDaemon:i,isStoppingDaemon:u,install:p,isInstalling:x}=he();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 shrink-0",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(Ae,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"Copilot"})]}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(),disabled:t,children:e.jsx(me,{className:W("w-4 h-4",t&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"GitHub Copilot proxy"})]}),e.jsx($,{className:"flex-1",children:t?e.jsx(os,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:"Unofficial API - Use at Your Own Risk"})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:"Reverse-engineered API - may break anytime"}),e.jsx("li",{children:"Excessive use may trigger account restrictions"}),e.jsx("li",{children:"No warranty, no responsibility from CCS"})]})]}),e.jsxs(V,{title:"Setup",children:[e.jsx(J,{icon:Re,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:"Installed":"Missing"}),!s?.installed&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>p(void 0),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Installing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"w-3.5 h-3.5 mr-1.5"}),"Install copilot-api"]})}),s?.installed&&e.jsx(J,{icon:ne,label:"Integration",status:s?.enabled??!1,statusText:s?.enabled?"Enabled":"Disabled"})]}),s?.installed&&e.jsxs(V,{title:"Auth",children:[e.jsx(J,{icon:Oe,label:"GitHub",status:s?.authenticated??!1,statusText:s?.authenticated?"Connected":"Not Connected"}),!s?.authenticated&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>o(),disabled:a,children:a?"Authenticating...":"Authenticate"})]}),s?.authenticated&&e.jsxs(V,{title:"Daemon",children:[e.jsx(J,{icon:Ie,label:"Status",status:s?.daemon_running??!1,statusText:s?.daemon_running?"Running":"Stopped"}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:["Port: ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>i(),disabled:u,children:[e.jsx(qe,{className:"w-3.5 h-3.5 mr-1.5"}),u?"Stopping...":"Stop"]}):e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>d(),disabled:r,children:[e.jsx(ne,{className:"w-3.5 h-3.5 mr-1.5"}),r?"Starting...":"Start"]})})]})]})}),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.jsx("span",{children:"Proxy"}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ue,{className:"w-3 h-3 text-green-500"}),"Active"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xe,{className:"w-3 h-3 text-muted-foreground"}),"Inactive"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(ls,{})})]})}export{Ns as CopilotPage};
|