(raw: unknown)
| 9 | export type { AgentAiDefaults, AgentAiDefaultsEntry }; |
| 10 | |
| 11 | export function normalizeAgentAiDefaults(raw: unknown): AgentAiDefaults { |
| 12 | const record = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : ({} as const); |
| 13 | |
| 14 | const result: AgentAiDefaults = {}; |
| 15 | |
| 16 | for (const [agentIdRaw, entryRaw] of Object.entries(record)) { |
| 17 | const agentId = normalizeAgentId(agentIdRaw, ""); |
| 18 | if (!agentId) continue; |
| 19 | if (!AgentIdSchema.safeParse(agentId).success) continue; |
| 20 | if (!entryRaw || typeof entryRaw !== "object") continue; |
| 21 | |
| 22 | const entry = entryRaw as Record<string, unknown>; |
| 23 | |
| 24 | const modelString = |
| 25 | typeof entry.modelString === "string" && entry.modelString.trim().length > 0 |
| 26 | ? entry.modelString.trim() |
| 27 | : undefined; |
| 28 | |
| 29 | const thinkingLevel: ThinkingLevel | undefined = coerceThinkingLevel(entry.thinkingLevel); |
| 30 | |
| 31 | const enabled = typeof entry.enabled === "boolean" ? entry.enabled : undefined; |
| 32 | const advisorEnabled = |
| 33 | typeof entry.advisorEnabled === "boolean" ? entry.advisorEnabled : undefined; |
| 34 | |
| 35 | if (!modelString && !thinkingLevel && enabled === undefined && advisorEnabled === undefined) { |
| 36 | continue; |
| 37 | } |
| 38 | |
| 39 | result[agentId] = { modelString, thinkingLevel, enabled, advisorEnabled }; |
| 40 | } |
| 41 | |
| 42 | return result; |
| 43 | } |
no test coverage detected