refactor(server): move the config.json provider-key copy out of VaultStore (P1.2)
VaultStore.migrateFromConfig had two callers, both in the server. It is now copyProviderKeysToVault in provider-env.ts, next to migrateLegacyProviderKeysToVault, with the same rules: copy keys that have a value, keep keys the vault already holds, store models and baseUrl as metadata. Its tests moved from core to provider-env.test.ts.
This commit is contained in:
@@ -327,20 +327,4 @@ export class VaultStore implements SecretStore {
|
||||
const vault = this.readVault();
|
||||
return name in vault;
|
||||
}
|
||||
|
||||
/** Migrate plaintext providers from config.json to vault. Returns count migrated. */
|
||||
migrateFromConfig(config: { providers?: Record<string, { apiKey: string; models?: string[]; baseUrl?: string }> }): number {
|
||||
if (!config.providers) return 0;
|
||||
let migrated = 0;
|
||||
for (const [name, provider] of Object.entries(config.providers)) {
|
||||
if (provider.apiKey && !this.has(name)) {
|
||||
this.set(name, provider.apiKey, {
|
||||
models: provider.models,
|
||||
baseUrl: provider.baseUrl,
|
||||
});
|
||||
migrated++;
|
||||
}
|
||||
}
|
||||
return migrated;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user