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:
shumeiko.it
2026-10-24 16:40:39 +02:00
parent 3528a242f6
commit 2226ec1bd7
5 changed files with 65 additions and 61 deletions

View File

@@ -181,7 +181,7 @@ import { EventEmitter } from 'node:events';
import { LocalJobStore } from './job-store.js';
import { AgentRunRegistry } from './agent-run-registry.js';
import { ExecutorRegistry } from './executor-registry.js';
import { hydrateProviderEnvFromVault } from './provider-env.js';
import { copyProviderKeysToVault, hydrateProviderEnvFromVault } from './provider-env.js';
export interface LocalConfig {
port: number;
@@ -568,7 +568,7 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
const waggleConfig = new WaggleConfig(fullConfig.dataDir);
const configProviders = waggleConfig.getProviders();
if (Object.keys(configProviders).length > 0) {
const migrated = vault.migrateFromConfig({ providers: configProviders });
const migrated = copyProviderKeysToVault(vault, configProviders);
let scrubbed = 0;
for (const [name, provider] of Object.entries(configProviders)) {
if (!provider.apiKey) continue;