MCPcopy Create free account
hub / github.com/Roy3838/Observer / downloadAgent

Function downloadAgent

app/src/utils/agent_database.ts:568–610  ·  view source on GitHub ↗
(agentId: string)

Source from the content-addressed store, hash-verified

566}
567
568export async function downloadAgent(agentId: string): Promise<void> {
569 try {
570 const agent = await getAgent(agentId);
571 if (!agent) throw new Error(`Agent ${agentId} not found`);
572
573 const code = await getAgentCode(agentId);
574 if (code === null) throw new Error(`Code for agent ${agentId} not found`);
575
576 const memory = await getAgentMemory(agentId);
577
578 // Create YAML-formatted string directly
579 const yamlContent = [
580 `id: ${agent.id}`,
581 `name: ${agent.name}`,
582 `description: ${agent.description}`,
583 `model_name: ${agent.model_name}`,
584 `loop_interval_seconds: ${agent.loop_interval_seconds}`,
585 `system_prompt: |`,
586 ` ${agent.system_prompt.replace(/\n/g, '\n ')}`,
587 `code: |`,
588 ` ${code.replace(/\n/g, '\n ')}`,
589 memory ? `memory: |` : 'memory: ""',
590 memory ? ` ${memory.replace(/\n/g, '\n ')}` : '',
591 ].join('\n');
592
593 const blob = new Blob([yamlContent], { type: 'application/x-yaml' });
594 const url = URL.createObjectURL(blob);
595 const a = document.createElement('a');
596 a.href = url;
597 a.download = `agent-${agentId}.yaml`;
598
599 document.body.appendChild(a);
600 a.click();
601
602 setTimeout(() => {
603 document.body.removeChild(a);
604 URL.revokeObjectURL(url);
605 }, 0);
606 } catch (error) {
607 console.error('Failed to download agent:', error);
608 throw error;
609 }
610}

Callers 1

handleExportFunction · 0.90

Calls 4

getAgentFunction · 0.85
getAgentCodeFunction · 0.85
getAgentMemoryFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected