Implementation:23blocks OS Ai maestro Export Agent Zip
| Knowledge Sources | |
|---|---|
| Domains | Agent_Transfer, Serialization |
| Last Updated | 2026-10-26 10:00 GMT |
Overview
Concrete tool for exporting an agent's full state to a ZIP archive, provided by AI Maestro's `services/agents-transfer-service.ts`.
Description
The exportAgentZip function packages an agent's complete state — registry entry, CozoDB database, inbox/sent messages, skills, hooks, and cryptographic keys — into a ZIP buffer. It stamps an export manifest with the AI Maestro version (`getAIMaestroVersion`). The result includes the ZIP buffer, a filename, and agent metadata for the API route to set response headers.
Usage
Call `exportAgentZip` from the export API route or the transfer flow (move/clone).
Code Reference
Source Location
- Repository: ai-maestro
- File: services/agents-transfer-service.ts (L66 getAIMaestroVersion, L323-595 exportAgentZip)
- Supporting: lib/agent-registry.ts, lib/amp-keys.ts, archiver (npm)
Signature
export async function exportAgentZip(
agentIdOrName: string
): Promise<ServiceResult<ExportZipResult>>
function getAIMaestroVersion(): string
interface ExportZipResult {
buffer: Buffer // ZIP data
filename: string // e.g. 'website-agent-2026-10-26.zip'
metadata: {
agentName: string
agentId: string
version: string
exportedAt: string
}
}
Import
import { exportAgentZip } from '@/services/agents-transfer-service'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| agentIdOrName | string | Yes | Agent UUID or name to export |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | ServiceResult<ExportZipResult> | ZIP buffer, filename, metadata; error if agent not found |
Usage Examples
import { exportAgentZip } from '@/services/agents-transfer-service'
const result = await exportAgentZip('website')
if (result.data) {
// Send as download response
return new Response(result.data.buffer, {
headers: {
'Content-Type': 'application/zip',
'Content-Disposition': `attachment; filename="${result.data.filename}"`,
},
})
}