()
| 100 | } |
| 101 | |
| 102 | loadStore(): AIConfigStore { |
| 103 | const store = this.storage.readJson<AIConfigStore>('llm-config') |
| 104 | if (!store) { |
| 105 | return { configs: [], defaultAssistant: null, fastModel: null } |
| 106 | } |
| 107 | |
| 108 | this.onStoreLoaded?.(store.configs) |
| 109 | |
| 110 | const resolvedConfigs = this.resolveApiKey |
| 111 | ? store.configs.map((config) => { |
| 112 | const profileKey = this.resolveApiKey!( |
| 113 | config.provider, |
| 114 | (config as unknown as Record<string, unknown>).authProfile as string | undefined |
| 115 | ) |
| 116 | return { ...config, apiKey: profileKey || config.apiKey || '' } |
| 117 | }) |
| 118 | : store.configs |
| 119 | |
| 120 | return { |
| 121 | ...store, |
| 122 | configs: resolvedConfigs, |
| 123 | defaultAssistant: resolveSlot(store.defaultAssistant, resolvedConfigs), |
| 124 | fastModel: resolveSlot(store.fastModel, resolvedConfigs), |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | saveStore(store: AIConfigStore): void { |
| 129 | this.storage.writeJson<AIConfigStore>('llm-config', { |
no test coverage detected