@kaitranntt/ccs 5.13.0 → 5.14.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/VERSION +1 -1
- package/dist/auth/auth-commands.d.ts +8 -0
- package/dist/auth/auth-commands.d.ts.map +1 -1
- package/dist/auth/auth-commands.js +54 -14
- package/dist/auth/auth-commands.js.map +1 -1
- package/dist/auth/profile-detector.d.ts +25 -6
- package/dist/auth/profile-detector.d.ts.map +1 -1
- package/dist/auth/profile-detector.js +150 -7
- package/dist/auth/profile-detector.js.map +1 -1
- package/dist/auth/profile-registry.d.ts +35 -0
- package/dist/auth/profile-registry.d.ts.map +1 -1
- package/dist/auth/profile-registry.js +91 -0
- package/dist/auth/profile-registry.js.map +1 -1
- package/dist/ccs.js +17 -0
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/account-manager.d.ts +4 -0
- package/dist/cliproxy/account-manager.d.ts.map +1 -1
- package/dist/cliproxy/account-manager.js +25 -1
- package/dist/cliproxy/account-manager.js.map +1 -1
- package/dist/cliproxy/auth-handler.d.ts +1 -0
- package/dist/cliproxy/auth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth-handler.js +8 -5
- package/dist/cliproxy/auth-handler.js.map +1 -1
- package/dist/cliproxy/cliproxy-executor.d.ts.map +1 -1
- package/dist/cliproxy/cliproxy-executor.js +43 -3
- package/dist/cliproxy/cliproxy-executor.js.map +1 -1
- package/dist/commands/api-command.d.ts +4 -0
- package/dist/commands/api-command.d.ts.map +1 -1
- package/dist/commands/api-command.js +192 -34
- package/dist/commands/api-command.js.map +1 -1
- package/dist/commands/cliproxy-command.d.ts +4 -0
- package/dist/commands/cliproxy-command.d.ts.map +1 -1
- package/dist/commands/cliproxy-command.js +181 -55
- package/dist/commands/cliproxy-command.js.map +1 -1
- package/dist/commands/migrate-command.d.ts +17 -0
- package/dist/commands/migrate-command.d.ts.map +1 -0
- package/dist/commands/migrate-command.js +139 -0
- package/dist/commands/migrate-command.js.map +1 -0
- package/dist/config/feature-flags.d.ts +19 -0
- package/dist/config/feature-flags.d.ts.map +1 -0
- package/dist/config/feature-flags.js +31 -0
- package/dist/config/feature-flags.js.map +1 -0
- package/dist/config/index.d.ts +12 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +33 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/migration-manager.d.ts +46 -0
- package/dist/config/migration-manager.d.ts.map +1 -0
- package/dist/config/migration-manager.js +338 -0
- package/dist/config/migration-manager.js.map +1 -0
- package/dist/config/reserved-names.d.ts +19 -0
- package/dist/config/reserved-names.d.ts.map +1 -0
- package/dist/config/reserved-names.js +40 -0
- package/dist/config/reserved-names.js.map +1 -0
- package/dist/config/secrets-manager.d.ts +51 -0
- package/dist/config/secrets-manager.d.ts.map +1 -0
- package/dist/config/secrets-manager.js +194 -0
- package/dist/config/secrets-manager.js.map +1 -0
- package/dist/config/unified-config-loader.d.ts +55 -0
- package/dist/config/unified-config-loader.d.ts.map +1 -0
- package/dist/config/unified-config-loader.js +262 -0
- package/dist/config/unified-config-loader.js.map +1 -0
- package/dist/config/unified-config-types.d.ts +126 -0
- package/dist/config/unified-config-types.d.ts.map +1 -0
- package/dist/config/unified-config-types.js +75 -0
- package/dist/config/unified-config-types.js.map +1 -0
- package/dist/ui/assets/{accounts-CINaiRWK.js → accounts-CTGj9Xoy.js} +1 -1
- package/dist/ui/assets/analytics-BAilRuX-.js +64 -0
- package/dist/ui/assets/{api-CgKbdMRy.js → api-D4gcZ85I.js} +1 -1
- package/dist/ui/assets/{cliproxy-BHWpNSSw.js → cliproxy-WthWDZC_.js} +1 -1
- package/dist/ui/assets/dropdown-menu-B3eFx_YP.js +1 -0
- package/dist/ui/assets/health-BzK4Dd4z.js +1 -0
- package/dist/ui/assets/icons-CLZywnx1.js +1 -0
- package/dist/ui/assets/index-2ZBa_Kkt.css +1 -0
- package/dist/ui/assets/index-CWyYvwwn.js +10 -0
- package/dist/ui/assets/{radix-ui-DAH8Vq_G.js → radix-ui-4P1Sa1Vh.js} +1 -1
- package/dist/ui/assets/{settings-DrNBNTwT.js → settings-DKL5mcjT.js} +1 -1
- package/dist/ui/assets/shared-xuI4eAiJ.js +1 -0
- package/dist/ui/assets/{table-C7tMF2ph.js → table-CxORHSk_.js} +1 -1
- package/dist/ui/assets/{tanstack-DAI1tKxf.js → tanstack-DcowkQHo.js} +1 -1
- package/dist/ui/index.html +5 -5
- package/dist/utils/sensitive-keys.d.ts +35 -0
- package/dist/utils/sensitive-keys.d.ts.map +1 -0
- package/dist/utils/sensitive-keys.js +67 -0
- package/dist/utils/sensitive-keys.js.map +1 -0
- package/dist/utils/update-checker.d.ts.map +1 -1
- package/dist/utils/update-checker.js +4 -4
- package/dist/utils/update-checker.js.map +1 -1
- package/dist/web-server/data-aggregator.d.ts +45 -0
- package/dist/web-server/data-aggregator.d.ts.map +1 -0
- package/dist/web-server/data-aggregator.js +305 -0
- package/dist/web-server/data-aggregator.js.map +1 -0
- package/dist/web-server/jsonl-parser.d.ts +68 -0
- package/dist/web-server/jsonl-parser.d.ts.map +1 -0
- package/dist/web-server/jsonl-parser.js +212 -0
- package/dist/web-server/jsonl-parser.js.map +1 -0
- package/dist/web-server/model-pricing.d.ts +42 -0
- package/dist/web-server/model-pricing.d.ts.map +1 -0
- package/dist/web-server/model-pricing.js +642 -0
- package/dist/web-server/model-pricing.js.map +1 -0
- package/dist/web-server/routes.d.ts.map +1 -1
- package/dist/web-server/routes.js +100 -14
- package/dist/web-server/routes.js.map +1 -1
- package/dist/web-server/usage-disk-cache.d.ts +2 -3
- package/dist/web-server/usage-disk-cache.d.ts.map +1 -1
- package/dist/web-server/usage-disk-cache.js +10 -8
- package/dist/web-server/usage-disk-cache.js.map +1 -1
- package/dist/web-server/usage-routes.d.ts +1 -1
- package/dist/web-server/usage-routes.d.ts.map +1 -1
- package/dist/web-server/usage-routes.js +259 -46
- package/dist/web-server/usage-routes.js.map +1 -1
- package/dist/web-server/usage-types.d.ts +106 -0
- package/dist/web-server/usage-types.d.ts.map +1 -0
- package/dist/web-server/usage-types.js +9 -0
- package/dist/web-server/usage-types.js.map +1 -0
- package/package.json +3 -2
- package/dist/ui/assets/analytics-FGMB3Rg8.js +0 -64
- package/dist/ui/assets/dropdown-menu-B25I20Pd.js +0 -1
- package/dist/ui/assets/health-BVdxHbAV.js +0 -1
- package/dist/ui/assets/icons-DT8ZzQec.js +0 -1
- package/dist/ui/assets/index-CQlEaCI8.css +0 -1
- package/dist/ui/assets/index-CfJhTNCX.js +0 -10
- package/dist/ui/assets/shared-CsIcdSca.js +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature flags for gradual rollout of new functionality.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Check if unified config (YAML) is enabled.
|
|
6
|
+
* Set CCS_UNIFIED_CONFIG=1 to enable.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isUnifiedConfigEnabled(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Check if migration mode is active.
|
|
11
|
+
* Set CCS_MIGRATE=1 to trigger automatic migration.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isMigrationEnabled(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Check if debug mode is enabled.
|
|
16
|
+
* Set CCS_DEBUG=1 for verbose logging.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isDebugEnabled(): boolean;
|
|
19
|
+
//# sourceMappingURL=feature-flags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-flags.d.ts","sourceRoot":"","sources":["../../src/config/feature-flags.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Feature flags for gradual rollout of new functionality.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isDebugEnabled = exports.isMigrationEnabled = exports.isUnifiedConfigEnabled = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Check if unified config (YAML) is enabled.
|
|
9
|
+
* Set CCS_UNIFIED_CONFIG=1 to enable.
|
|
10
|
+
*/
|
|
11
|
+
function isUnifiedConfigEnabled() {
|
|
12
|
+
return process.env.CCS_UNIFIED_CONFIG === '1';
|
|
13
|
+
}
|
|
14
|
+
exports.isUnifiedConfigEnabled = isUnifiedConfigEnabled;
|
|
15
|
+
/**
|
|
16
|
+
* Check if migration mode is active.
|
|
17
|
+
* Set CCS_MIGRATE=1 to trigger automatic migration.
|
|
18
|
+
*/
|
|
19
|
+
function isMigrationEnabled() {
|
|
20
|
+
return process.env.CCS_MIGRATE === '1';
|
|
21
|
+
}
|
|
22
|
+
exports.isMigrationEnabled = isMigrationEnabled;
|
|
23
|
+
/**
|
|
24
|
+
* Check if debug mode is enabled.
|
|
25
|
+
* Set CCS_DEBUG=1 for verbose logging.
|
|
26
|
+
*/
|
|
27
|
+
function isDebugEnabled() {
|
|
28
|
+
return process.env.CCS_DEBUG === '1';
|
|
29
|
+
}
|
|
30
|
+
exports.isDebugEnabled = isDebugEnabled;
|
|
31
|
+
//# sourceMappingURL=feature-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../../src/config/feature-flags.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH;;;GAGG;AACH,SAAgB,sBAAsB;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,GAAG,CAAC;AAChD,CAAC;AAFD,wDAEC;AAED;;;GAGG;AACH,SAAgB,kBAAkB;IAChC,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC;AACzC,CAAC;AAFD,gDAEC;AAED;;;GAGG;AACH,SAAgB,cAAc;IAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC;AACvC,CAAC;AAFD,wCAEC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Module Exports
|
|
3
|
+
*
|
|
4
|
+
* Central export point for unified config functionality.
|
|
5
|
+
*/
|
|
6
|
+
export * from './unified-config-types';
|
|
7
|
+
export * from './feature-flags';
|
|
8
|
+
export * from './reserved-names';
|
|
9
|
+
export * from './unified-config-loader';
|
|
10
|
+
export * from './secrets-manager';
|
|
11
|
+
export * from './migration-manager';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,wBAAwB,CAAC;AAGvC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Config Module Exports
|
|
4
|
+
*
|
|
5
|
+
* Central export point for unified config functionality.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
// Types
|
|
23
|
+
__exportStar(require("./unified-config-types"), exports);
|
|
24
|
+
// Feature Flags
|
|
25
|
+
__exportStar(require("./feature-flags"), exports);
|
|
26
|
+
// Reserved Names
|
|
27
|
+
__exportStar(require("./reserved-names"), exports);
|
|
28
|
+
// Loaders
|
|
29
|
+
__exportStar(require("./unified-config-loader"), exports);
|
|
30
|
+
__exportStar(require("./secrets-manager"), exports);
|
|
31
|
+
// Migration
|
|
32
|
+
__exportStar(require("./migration-manager"), exports);
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,QAAQ;AACR,yDAAuC;AAEvC,gBAAgB;AAChB,kDAAgC;AAEhC,iBAAiB;AACjB,mDAAiC;AAEjC,UAAU;AACV,0DAAwC;AACxC,oDAAkC;AAElC,YAAY;AACZ,sDAAoC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration Manager
|
|
3
|
+
*
|
|
4
|
+
* Handles migration from legacy JSON config (v1) to unified YAML config (v2).
|
|
5
|
+
* Features:
|
|
6
|
+
* - Automatic backup before migration
|
|
7
|
+
* - Rollback support
|
|
8
|
+
* - Settings file reference preservation (*.settings.json)
|
|
9
|
+
* - Cache file restructuring
|
|
10
|
+
*
|
|
11
|
+
* Design: Settings remain in *.settings.json files (matching Claude's pattern)
|
|
12
|
+
* while config.yaml stores references to these files.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Migration result with details about what was migrated.
|
|
16
|
+
*/
|
|
17
|
+
export interface MigrationResult {
|
|
18
|
+
success: boolean;
|
|
19
|
+
backupPath?: string;
|
|
20
|
+
error?: string;
|
|
21
|
+
migratedFiles: string[];
|
|
22
|
+
warnings: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if migration from v1 to v2 is needed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function needsMigration(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Get list of backup directories.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getBackupDirectories(): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Perform migration from v1 to v2 format.
|
|
34
|
+
*/
|
|
35
|
+
export declare function migrate(dryRun?: boolean): Promise<MigrationResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Rollback migration by restoring from backup.
|
|
38
|
+
*/
|
|
39
|
+
export declare function rollback(backupPath: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Auto-migrate on first run after update.
|
|
42
|
+
* Silent if already migrated or no config exists.
|
|
43
|
+
* Shows friendly message with backup location on success.
|
|
44
|
+
*/
|
|
45
|
+
export declare function autoMigrate(): Promise<void>;
|
|
46
|
+
//# sourceMappingURL=migration-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-manager.d.ts","sourceRoot":"","sources":["../../src/config/migration-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAMxC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAU/C;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,MAAM,UAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,CAkJtE;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA2CnE;AAoED;;;;GAIG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAoCjD"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Migration Manager
|
|
4
|
+
*
|
|
5
|
+
* Handles migration from legacy JSON config (v1) to unified YAML config (v2).
|
|
6
|
+
* Features:
|
|
7
|
+
* - Automatic backup before migration
|
|
8
|
+
* - Rollback support
|
|
9
|
+
* - Settings file reference preservation (*.settings.json)
|
|
10
|
+
* - Cache file restructuring
|
|
11
|
+
*
|
|
12
|
+
* Design: Settings remain in *.settings.json files (matching Claude's pattern)
|
|
13
|
+
* while config.yaml stores references to these files.
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.autoMigrate = exports.rollback = exports.migrate = exports.getBackupDirectories = exports.needsMigration = void 0;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const config_manager_1 = require("../utils/config-manager");
|
|
43
|
+
const unified_config_types_1 = require("./unified-config-types");
|
|
44
|
+
const unified_config_loader_1 = require("./unified-config-loader");
|
|
45
|
+
const BACKUP_DIR_PREFIX = 'backup-v1-';
|
|
46
|
+
/**
|
|
47
|
+
* Check if migration from v1 to v2 is needed.
|
|
48
|
+
*/
|
|
49
|
+
function needsMigration() {
|
|
50
|
+
const ccsDir = (0, config_manager_1.getCcsDir)();
|
|
51
|
+
const hasOldConfig = fs.existsSync(path.join(ccsDir, 'config.json'));
|
|
52
|
+
const hasNewConfig = (0, unified_config_loader_1.hasUnifiedConfig)();
|
|
53
|
+
return hasOldConfig && !hasNewConfig;
|
|
54
|
+
}
|
|
55
|
+
exports.needsMigration = needsMigration;
|
|
56
|
+
/**
|
|
57
|
+
* Get list of backup directories.
|
|
58
|
+
*/
|
|
59
|
+
function getBackupDirectories() {
|
|
60
|
+
const ccsDir = (0, config_manager_1.getCcsDir)();
|
|
61
|
+
if (!fs.existsSync(ccsDir))
|
|
62
|
+
return [];
|
|
63
|
+
return fs
|
|
64
|
+
.readdirSync(ccsDir)
|
|
65
|
+
.filter((name) => name.startsWith(BACKUP_DIR_PREFIX))
|
|
66
|
+
.map((name) => path.join(ccsDir, name))
|
|
67
|
+
.sort()
|
|
68
|
+
.reverse(); // Most recent first
|
|
69
|
+
}
|
|
70
|
+
exports.getBackupDirectories = getBackupDirectories;
|
|
71
|
+
/**
|
|
72
|
+
* Perform migration from v1 to v2 format.
|
|
73
|
+
*/
|
|
74
|
+
async function migrate(dryRun = false) {
|
|
75
|
+
const ccsDir = (0, config_manager_1.getCcsDir)();
|
|
76
|
+
const migratedFiles = [];
|
|
77
|
+
const warnings = [];
|
|
78
|
+
try {
|
|
79
|
+
// 1. Create backup
|
|
80
|
+
const timestamp = new Date().toISOString().split('T')[0];
|
|
81
|
+
const backupDir = path.join(ccsDir, `${BACKUP_DIR_PREFIX}${timestamp}`);
|
|
82
|
+
if (!dryRun) {
|
|
83
|
+
await createBackup(ccsDir, backupDir);
|
|
84
|
+
}
|
|
85
|
+
// 2. Read old configs
|
|
86
|
+
const oldConfig = readJsonSafe(path.join(ccsDir, 'config.json'));
|
|
87
|
+
const oldProfiles = readJsonSafe(path.join(ccsDir, 'profiles.json'));
|
|
88
|
+
// 3. Build unified config
|
|
89
|
+
const unifiedConfig = (0, unified_config_types_1.createEmptyUnifiedConfig)();
|
|
90
|
+
// Set default if exists
|
|
91
|
+
if (oldProfiles?.default && typeof oldProfiles.default === 'string') {
|
|
92
|
+
unifiedConfig.default = oldProfiles.default;
|
|
93
|
+
}
|
|
94
|
+
// 4. Migrate accounts from profiles.json
|
|
95
|
+
if (oldProfiles?.profiles) {
|
|
96
|
+
for (const [name, meta] of Object.entries(oldProfiles.profiles)) {
|
|
97
|
+
const metadata = meta;
|
|
98
|
+
const account = {
|
|
99
|
+
created: metadata.created || new Date().toISOString(),
|
|
100
|
+
last_used: metadata.last_used || null,
|
|
101
|
+
};
|
|
102
|
+
unifiedConfig.accounts[name] = account;
|
|
103
|
+
}
|
|
104
|
+
migratedFiles.push('profiles.json → config.yaml.accounts');
|
|
105
|
+
}
|
|
106
|
+
// 5. Migrate CLIProxy variants from config.json
|
|
107
|
+
if (oldConfig?.cliproxy) {
|
|
108
|
+
for (const [name, variantData] of Object.entries(oldConfig.cliproxy)) {
|
|
109
|
+
const oldVariant = variantData;
|
|
110
|
+
const variant = {
|
|
111
|
+
provider: oldVariant.provider,
|
|
112
|
+
};
|
|
113
|
+
if (oldVariant.account) {
|
|
114
|
+
variant.account = oldVariant.account;
|
|
115
|
+
}
|
|
116
|
+
// Keep reference to existing settings file
|
|
117
|
+
if (oldVariant.settings) {
|
|
118
|
+
variant.settings = oldVariant.settings;
|
|
119
|
+
}
|
|
120
|
+
unifiedConfig.cliproxy.variants[name] = variant;
|
|
121
|
+
}
|
|
122
|
+
migratedFiles.push('config.json.cliproxy → config.yaml.cliproxy.variants');
|
|
123
|
+
}
|
|
124
|
+
// 6. Migrate API profiles from config.json
|
|
125
|
+
// Keep settings in *.settings.json files (matching Claude's ~/.claude/settings.json pattern)
|
|
126
|
+
// config.yaml only stores reference to the settings file
|
|
127
|
+
if (oldConfig?.profiles) {
|
|
128
|
+
for (const [name, settingsPath] of Object.entries(oldConfig.profiles)) {
|
|
129
|
+
const pathStr = settingsPath;
|
|
130
|
+
const expandedPath = expandPath(pathStr);
|
|
131
|
+
// Verify settings file exists
|
|
132
|
+
if (!fs.existsSync(expandedPath)) {
|
|
133
|
+
warnings.push(`Skipped ${name}: settings file not found at ${pathStr}`);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
// Store reference to settings file (keep using ~ for portability)
|
|
137
|
+
const profile = {
|
|
138
|
+
type: 'api',
|
|
139
|
+
settings: pathStr,
|
|
140
|
+
};
|
|
141
|
+
unifiedConfig.profiles[name] = profile;
|
|
142
|
+
migratedFiles.push(`config.json.profiles.${name} → config.yaml (settings: ${pathStr})`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// 6b. Migrate built-in CLIProxy OAuth profile settings (gemini, codex, agy, qwen, iflow)
|
|
146
|
+
// Keep settings in *.settings.json files - only record reference in config.yaml
|
|
147
|
+
// This matches Claude's ~/.claude/settings.json pattern for user familiarity
|
|
148
|
+
const builtInProviders = ['gemini', 'codex', 'agy', 'qwen', 'iflow'];
|
|
149
|
+
for (const provider of builtInProviders) {
|
|
150
|
+
const settingsFile = `${provider}.settings.json`;
|
|
151
|
+
const settingsPath = path.join(ccsDir, settingsFile);
|
|
152
|
+
if (fs.existsSync(settingsPath)) {
|
|
153
|
+
// Create variant with reference to settings file
|
|
154
|
+
const variant = {
|
|
155
|
+
provider: provider,
|
|
156
|
+
settings: `~/.ccs/${settingsFile}`,
|
|
157
|
+
};
|
|
158
|
+
unifiedConfig.cliproxy.variants[provider] = variant;
|
|
159
|
+
migratedFiles.push(`${settingsFile} → config.yaml.cliproxy.variants.${provider}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// 7. Migrate cache files
|
|
163
|
+
if (!dryRun) {
|
|
164
|
+
const cacheDir = path.join(ccsDir, 'cache');
|
|
165
|
+
if (!fs.existsSync(cacheDir)) {
|
|
166
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
167
|
+
}
|
|
168
|
+
if (moveIfExists(path.join(ccsDir, 'usage-cache.json'), path.join(cacheDir, 'usage.json'))) {
|
|
169
|
+
migratedFiles.push('usage-cache.json → cache/usage.json');
|
|
170
|
+
}
|
|
171
|
+
if (moveIfExists(path.join(ccsDir, 'update-check.json'), path.join(cacheDir, 'update-check.json'))) {
|
|
172
|
+
migratedFiles.push('update-check.json → cache/update-check.json');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// 8. Write new config (unless dry run)
|
|
176
|
+
// Note: Settings remain in *.settings.json files, config.yaml only stores references
|
|
177
|
+
if (!dryRun) {
|
|
178
|
+
(0, unified_config_loader_1.saveUnifiedConfig)(unifiedConfig);
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
success: true,
|
|
182
|
+
backupPath: dryRun ? undefined : backupDir,
|
|
183
|
+
migratedFiles,
|
|
184
|
+
warnings,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
return {
|
|
189
|
+
success: false,
|
|
190
|
+
error: err instanceof Error ? err.message : 'Unknown error',
|
|
191
|
+
migratedFiles,
|
|
192
|
+
warnings,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.migrate = migrate;
|
|
197
|
+
/**
|
|
198
|
+
* Rollback migration by restoring from backup.
|
|
199
|
+
*/
|
|
200
|
+
async function rollback(backupPath) {
|
|
201
|
+
const ccsDir = (0, config_manager_1.getCcsDir)();
|
|
202
|
+
if (!fs.existsSync(backupPath)) {
|
|
203
|
+
console.error(`[X] Backup not found: ${backupPath}`);
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
// Remove new config files
|
|
208
|
+
const configYaml = path.join(ccsDir, 'config.yaml');
|
|
209
|
+
const secretsYaml = path.join(ccsDir, 'secrets.yaml');
|
|
210
|
+
const cacheDir = path.join(ccsDir, 'cache');
|
|
211
|
+
if (fs.existsSync(configYaml))
|
|
212
|
+
fs.unlinkSync(configYaml);
|
|
213
|
+
if (fs.existsSync(secretsYaml))
|
|
214
|
+
fs.unlinkSync(secretsYaml);
|
|
215
|
+
// Restore cache files to original locations
|
|
216
|
+
if (fs.existsSync(cacheDir)) {
|
|
217
|
+
moveIfExists(path.join(cacheDir, 'usage.json'), path.join(ccsDir, 'usage-cache.json'));
|
|
218
|
+
moveIfExists(path.join(cacheDir, 'update-check.json'), path.join(ccsDir, 'update-check.json'));
|
|
219
|
+
// Remove cache dir if empty
|
|
220
|
+
const remaining = fs.readdirSync(cacheDir);
|
|
221
|
+
if (remaining.length === 0) {
|
|
222
|
+
fs.rmdirSync(cacheDir);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// Restore files from backup
|
|
226
|
+
const files = fs.readdirSync(backupPath);
|
|
227
|
+
for (const file of files) {
|
|
228
|
+
fs.copyFileSync(path.join(backupPath, file), path.join(ccsDir, file));
|
|
229
|
+
}
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
console.error(`[X] Rollback failed: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.rollback = rollback;
|
|
238
|
+
// --- Helper Functions ---
|
|
239
|
+
/**
|
|
240
|
+
* Read JSON file safely, returning null on error or if file doesn't exist.
|
|
241
|
+
*/
|
|
242
|
+
function readJsonSafe(filePath) {
|
|
243
|
+
if (!fs.existsSync(filePath))
|
|
244
|
+
return null;
|
|
245
|
+
try {
|
|
246
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Expand ~ to home directory in path.
|
|
254
|
+
*/
|
|
255
|
+
function expandPath(p) {
|
|
256
|
+
return p.replace(/^~/, process.env.HOME || '');
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Move file if it exists. Returns true if moved, false if source didn't exist.
|
|
260
|
+
*/
|
|
261
|
+
function moveIfExists(from, to) {
|
|
262
|
+
if (fs.existsSync(from)) {
|
|
263
|
+
fs.renameSync(from, to);
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Create backup of all v1 config files.
|
|
270
|
+
*/
|
|
271
|
+
async function createBackup(srcDir, backupDir) {
|
|
272
|
+
// Check if backup already exists (prevent overwriting)
|
|
273
|
+
if (fs.existsSync(backupDir)) {
|
|
274
|
+
// Add timestamp suffix to make unique
|
|
275
|
+
const suffix = Date.now().toString(36);
|
|
276
|
+
const uniqueBackupDir = `${backupDir}-${suffix}`;
|
|
277
|
+
fs.mkdirSync(uniqueBackupDir, { recursive: true });
|
|
278
|
+
await performBackup(srcDir, uniqueBackupDir);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
fs.mkdirSync(backupDir, { recursive: true });
|
|
282
|
+
await performBackup(srcDir, backupDir);
|
|
283
|
+
}
|
|
284
|
+
async function performBackup(srcDir, backupDir) {
|
|
285
|
+
const filesToBackup = ['config.json', 'profiles.json', 'usage-cache.json', 'update-check.json'];
|
|
286
|
+
// Also backup *.settings.json files
|
|
287
|
+
const allFiles = fs.readdirSync(srcDir);
|
|
288
|
+
const settingsFiles = allFiles.filter((f) => f.endsWith('.settings.json'));
|
|
289
|
+
filesToBackup.push(...settingsFiles);
|
|
290
|
+
for (const file of filesToBackup) {
|
|
291
|
+
const src = path.join(srcDir, file);
|
|
292
|
+
if (fs.existsSync(src)) {
|
|
293
|
+
fs.copyFileSync(src, path.join(backupDir, file));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Auto-migrate on first run after update.
|
|
299
|
+
* Silent if already migrated or no config exists.
|
|
300
|
+
* Shows friendly message with backup location on success.
|
|
301
|
+
*/
|
|
302
|
+
async function autoMigrate() {
|
|
303
|
+
// Skip in test environment
|
|
304
|
+
if (process.env.NODE_ENV === 'test' || process.env.CCS_SKIP_MIGRATION === '1') {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
// Skip if no migration needed
|
|
308
|
+
if (!needsMigration()) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const result = await migrate(false);
|
|
312
|
+
if (result.success) {
|
|
313
|
+
console.log('');
|
|
314
|
+
console.log('╭─────────────────────────────────────────────────────────╮');
|
|
315
|
+
console.log('│ [OK] Migrated to unified config (config.yaml) │');
|
|
316
|
+
console.log('╰─────────────────────────────────────────────────────────╯');
|
|
317
|
+
console.log(` Backup: ${result.backupPath}`);
|
|
318
|
+
console.log(` Items: ${result.migratedFiles.length} migrated`);
|
|
319
|
+
if (result.warnings.length > 0) {
|
|
320
|
+
for (const warning of result.warnings) {
|
|
321
|
+
console.log(` [!] ${warning}`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
console.log(` Rollback: ccs migrate --rollback ${result.backupPath}`);
|
|
325
|
+
console.log('');
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
console.log('');
|
|
329
|
+
console.log('╭─────────────────────────────────────────────────────────╮');
|
|
330
|
+
console.log('│ [!] Migration failed - using legacy config │');
|
|
331
|
+
console.log('╰─────────────────────────────────────────────────────────╯');
|
|
332
|
+
console.log(` Error: ${result.error}`);
|
|
333
|
+
console.log(' Retry: ccs migrate');
|
|
334
|
+
console.log('');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
exports.autoMigrate = autoMigrate;
|
|
338
|
+
//# sourceMappingURL=migration-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-manager.js","sourceRoot":"","sources":["../../src/config/migration-manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,4DAAoD;AAEpD,iEAAkE;AAClE,mEAA8E;AAE9E,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAavC;;GAEG;AACH,SAAgB,cAAc;IAC5B,MAAM,MAAM,GAAG,IAAA,0BAAS,GAAE,CAAC;IAC3B,MAAM,YAAY,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,IAAA,wCAAgB,GAAE,CAAC;IAExC,OAAO,YAAY,IAAI,CAAC,YAAY,CAAC;AACvC,CAAC;AAND,wCAMC;AAED;;GAEG;AACH,SAAgB,oBAAoB;IAClC,MAAM,MAAM,GAAG,IAAA,0BAAS,GAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,CA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QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACtC,OAAO,CAAC,GAAG,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,sCAAsC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QACvE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AApCD,kCAoCC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reserved profile names that cannot be used for user-defined profiles.
|
|
3
|
+
* These names are reserved for CLIProxy providers and CLI commands.
|
|
4
|
+
*/
|
|
5
|
+
export declare const RESERVED_PROFILE_NAMES: readonly ["gemini", "codex", "agy", "qwen", "iflow", "default", "config", "cliproxy"];
|
|
6
|
+
export type ReservedProfileName = (typeof RESERVED_PROFILE_NAMES)[number];
|
|
7
|
+
/**
|
|
8
|
+
* Check if a name is reserved and cannot be used for user profiles.
|
|
9
|
+
* @param name - The profile name to check
|
|
10
|
+
* @returns true if the name is reserved
|
|
11
|
+
*/
|
|
12
|
+
export declare function isReservedName(name: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Validate a profile name and throw if reserved.
|
|
15
|
+
* @param name - The profile name to validate
|
|
16
|
+
* @throws Error if the name is reserved
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateProfileName(name: string): void;
|
|
19
|
+
//# sourceMappingURL=reserved-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reserved-names.d.ts","sourceRoot":"","sources":["../../src/config/reserved-names.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,uFAWzB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMtD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateProfileName = exports.isReservedName = exports.RESERVED_PROFILE_NAMES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Reserved profile names that cannot be used for user-defined profiles.
|
|
6
|
+
* These names are reserved for CLIProxy providers and CLI commands.
|
|
7
|
+
*/
|
|
8
|
+
exports.RESERVED_PROFILE_NAMES = [
|
|
9
|
+
// CLIProxy providers (built-in OAuth)
|
|
10
|
+
'gemini',
|
|
11
|
+
'codex',
|
|
12
|
+
'agy',
|
|
13
|
+
'qwen',
|
|
14
|
+
'iflow',
|
|
15
|
+
// CLI commands and special names
|
|
16
|
+
'default',
|
|
17
|
+
'config',
|
|
18
|
+
'cliproxy',
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Check if a name is reserved and cannot be used for user profiles.
|
|
22
|
+
* @param name - The profile name to check
|
|
23
|
+
* @returns true if the name is reserved
|
|
24
|
+
*/
|
|
25
|
+
function isReservedName(name) {
|
|
26
|
+
return exports.RESERVED_PROFILE_NAMES.includes(name.toLowerCase());
|
|
27
|
+
}
|
|
28
|
+
exports.isReservedName = isReservedName;
|
|
29
|
+
/**
|
|
30
|
+
* Validate a profile name and throw if reserved.
|
|
31
|
+
* @param name - The profile name to validate
|
|
32
|
+
* @throws Error if the name is reserved
|
|
33
|
+
*/
|
|
34
|
+
function validateProfileName(name) {
|
|
35
|
+
if (isReservedName(name)) {
|
|
36
|
+
throw new Error(`Profile name '${name}' is reserved. Reserved names: ${exports.RESERVED_PROFILE_NAMES.join(', ')}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.validateProfileName = validateProfileName;
|
|
40
|
+
//# sourceMappingURL=reserved-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reserved-names.js","sourceRoot":"","sources":["../../src/config/reserved-names.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,sBAAsB,GAAG;IACpC,sCAAsC;IACtC,QAAQ;IACR,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,iCAAiC;IACjC,SAAS;IACT,QAAQ;IACR,UAAU;CACF,CAAC;AAIX;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,8BAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAyB,CAAC,CAAC;AACpF,CAAC;AAFD,wCAEC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,iBAAiB,IAAI,kCAAkC,8BAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3F,CAAC;IACJ,CAAC;AACH,CAAC;AAND,kDAMC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|