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 AMP Inbox Writer

From Leeroopedia
Knowledge Sources
Domains Agent_Messaging, Persistence
Last Updated 2026-10-26 10:00 GMT

Overview

Concrete tool for writing messages to agent AMP inboxes and sent folders on disk, and initializing agent AMP home directories, provided by AI Maestro's `lib/amp-inbox-writer.ts`.

Description

The AMP inbox writer manages per-agent message storage at `~/.agent-messaging/agents/<uuid>/messages/inbox/` and `.../sent/`. writeToAMPInbox writes a signed message to the recipient's inbox, preferring UUID-based directory resolution. writeToAMPSent writes to the sender's sent folder. initAgentAMPHome creates the directory structure for a new agent — always using UUID, never the name — and creates a clean config without inheriting the machine's cryptographic identity (a deliberate guard against identity contamination).

Usage

  • Call `writeToAMPInbox` from `deliver` after content security screening.
  • Call `writeToAMPSent` from the web UI send path to record what was sent.
  • Call `initAgentAMPHome` when importing an agent or provisioning AMP for the first time.

Code Reference

Source Location

  • Repository: ai-maestro
  • File: lib/amp-inbox-writer.ts (L227-302 initAgentAMPHome, L323-402 writeToAMPInbox, L404-470 writeToAMPSent)
  • Storage: `~/.agent-messaging/agents/<uuid>/messages/inbox/<sender>/<id>.json`

Signature

export async function initAgentAMPHome(
  agentName: string,
  agentId?: string
): Promise<string>

export async function writeToAMPInbox(
  envelope: AMPEnvelope,
  payload: AMPPayload,
  recipientAgent?: string,
  senderPublicKey?: string,
  recipientAgentId?: string,
  verification?: VerificationRecord
): Promise<string | null>

export async function writeToAMPSent(
  envelope: AMPEnvelope,
  payload: AMPPayload,
  senderAgent?: string,
  senderAgentId?: string
): Promise<string | null>

Import

import { initAgentAMPHome, writeToAMPInbox, writeToAMPSent } from '@/lib/amp-inbox-writer'

I/O Contract

Inputs

Name Type Required Description
envelope AMPEnvelope Yes Signed AMP envelope
payload AMPPayload Yes Message payload
recipientAgentId string Yes (inbox) Recipient UUID for directory
senderAgentId string Yes (sent) Sender UUID for directory

Outputs

Name Type Description
initAgentAMPHome() returns Promise<string> Path to initialized AMP home
writeToAMPInbox() returns null> Path to written inbox file, or null on failure
writeToAMPSent() returns null> Path to written sent file

Usage Examples

import { initAgentAMPHome, writeToAMPInbox } from '@/lib/amp-inbox-writer'

// 1. Initialize AMP home for a new agent
const ampHome = await initAgentAMPHome('website', 'agent-uuid')

// 2. Deliver a message to its inbox
const path = await writeToAMPInbox(
  envelope,
  payload,
  'website',
  'senderPubHex...',
  'agent-uuid',
  { state: 'verified', trust: 'verified', method: 'ed25519' }
)
// => ~/.agent-messaging/agents/agent-uuid/messages/inbox/sender/msg_123.json

Related Pages

Implements Principle

Page Connections

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