Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:23blocks OS Ai maestro Export Agent Zip

From Leeroopedia
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}"`,
    },
  })
}

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment