( agentsJson: unknown, source: SettingSource = 'flagSettings', )
| 519 | * Parses multiple agents from a JSON object |
| 520 | */ |
| 521 | export function parseAgentsFromJson( |
| 522 | agentsJson: unknown, |
| 523 | source: SettingSource = 'flagSettings', |
| 524 | ): AgentDefinition[] { |
| 525 | try { |
| 526 | const parsed = AgentsJsonSchema().parse(agentsJson) |
| 527 | return Object.entries(parsed) |
| 528 | .map(([name, def]) => parseAgentFromJson(name, def, source)) |
| 529 | .filter((agent): agent is CustomAgentDefinition => agent !== null) |
| 530 | } catch (error) { |
| 531 | const errorMessage = error instanceof Error ? error.message : String(error) |
| 532 | logForDebugging(`Error parsing agents from JSON: ${errorMessage}`) |
| 533 | logError(error) |
| 534 | return [] |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | /** |
| 539 | * Parses agent definition from markdown file data |
no test coverage detected