( defaults: Record<string, WorkspaceCredentialDefault>, )
| 990 | * `credentialSlug` are dropped (the UI's "don't seed this agent" choice). |
| 991 | */ |
| 992 | export async function writeWorkspaceCredentialDefaults( |
| 993 | defaults: Record<string, WorkspaceCredentialDefault>, |
| 994 | ): Promise<void> { |
| 995 | const config = await readAIProviderConfig() |
| 996 | const cleaned: Record<string, WorkspaceCredentialDefault> = {} |
| 997 | for (const [agentId, def] of Object.entries(defaults)) { |
| 998 | const parsed = workspaceCredentialDefaultSchema.parse(def) |
| 999 | if (parsed.credentialSlug) cleaned[agentId] = parsed |
| 1000 | } |
| 1001 | config.workspaceCredentialDefaults = cleaned |
| 1002 | await mkdir(CONFIG_DIR, { recursive: true }) |
| 1003 | await writeFile(resolve(CONFIG_DIR, 'ai-provider-manager.json'), JSON.stringify(config, null, 2) + '\n') |
| 1004 | } |
| 1005 | |
| 1006 | export async function readWorkspaceDefaultAgent(): Promise<string | null> { |
| 1007 | const config = await readAIProviderConfig() |
no test coverage detected