(agentId: string)
| 548 | * @returns A promise that resolves to a Blob containing the agent data |
| 549 | */ |
| 550 | export async function exportAgentToFile(agentId: string): Promise<Blob> { |
| 551 | const agent = await getAgent(agentId); |
| 552 | if (!agent) throw new Error(`Agent ${agentId} not found`); |
| 553 | |
| 554 | const code = await getAgentCode(agentId); |
| 555 | if (code === null) throw new Error(`Code for agent ${agentId} not found`); |
| 556 | |
| 557 | const memory = await getAgentMemory(agentId); |
| 558 | |
| 559 | const exportData: AgentExport = { |
| 560 | id: agent.id, |
| 561 | name: agent.name, |
| 562 | description: agent.description, |
| 563 | model_name: agent.model_name, |
| 564 | system_prompt: agent.system_prompt, |
| 565 | loop_interval_seconds: agent.loop_interval_seconds, |
| 566 | only_on_significant_change: agent.only_on_significant_change, |
| 567 | ...(agent.classification ? { classification: agent.classification } : {}), // js-yaml can't dump undefined |
| 568 | code, |
| 569 | memory |
| 570 | }; |
| 571 | |
| 572 | const yamlStr = yaml.dump(exportData); |
| 573 | return new Blob([yamlStr], { type: 'application/x-yaml' }); |
| 574 | } |
| 575 | |
| 576 | export async function downloadAgent(agentId: string): Promise<void> { |
| 577 | try { |
nothing calls this directly
no test coverage detected