Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Agent Control Plane (ACP)

Canonical reference: docs/api-reference.md (generated endpoint directory) — this page is a task-oriented summary.

The Agent Control Plane provides TCP-based bidirectional control over agent workers. ACP enables CLI and tooling to discover, route to, and control individual Luna workers.

Overview

ACP is a TCP listener protocol (separate from HTTP). Clients connect via TCP, send msgpack-encoded control messages, and receive responses over the same connection. The ACP router maintains a registry of connected workers and can forward commands to specific workers or broadcast to all.

Protocol

TCP Listener

tcp://host:9120

The ACP listener (sol_acp_listener, default port 9120, configured via acp_listener_port / SOL_ACP_LISTENER_PORT) accepts TCP connections, wraps them in sessions (sol_acp_session), and routes messages to registered workers. Connections authenticate with a shared-secret HMAC (the listener refuses unauthenticated frames fail-closed; Added replay protection, superseded by the enforced global digest cache + per-type freshness of — a captured frame replayed over a fresh connection is refused). Frame sizes are capped (acp_packet_size, clamped at 16 MiB); a non-loopback bind requires the explicit acp_listener_plaintext_ack acknowledgement.

Message Format

Messages are msgpack-encoded maps keyed by an acp_type field:

{
  "acp_type": "request",
  "id": "req-uuid",
  "from": "client",
  "to": "worker-uuid",
  "payload": { "action": "execute" },
  "timestamp": 1745600000000,
  "ttl": 30
}

Message Types

acp_typeDirectionDescription
capabilityWorker → RouterAnnounce worker identity and capabilities
requestClient → Router → WorkerSend a command to a specific worker (TTL 30)
notifyClient → Router → WorkerFire-and-forget command (no reply expected)
broadcastClient → RouterSend command to all registered workers (to: "*")
discoverClient → RouterFind up to n agents matching capabilities (TTL 10)
responseWorker → Router → ClientWorker response to a request (reply_to names the request id)

Discovery Response

{
  "acp_type": "response",
  "agents": [
    {
      "id": "worker-uuid",
      "capabilities": ["chat", "tools", "memory"],
      "status": "idle"
    }
  ]
}

Endpoints (HTTP Bridge)

List Connected Agents

GET /api/v1/acp/agents

Returns registered agents, paginated. Each entry is {id, capabilities, status, last_seen}.

{
  "items": [
    {"id": "worker-uuid", "capabilities": ["chat", "tools", "memory"], "status": "idle", "last_seen": 1745600000000}
  ],
  "total": 1,
  "limit": 50,
  "offset": 0,
  "page": 1,
  "total_pages": 1,
  "has_more": false
}

Discover Agents by Capability

GET /api/v1/acp/agents/discover

Find up to n agents (default 5) whose capabilities satisfy the request. The spec pins GET; there is no method gate in the handler, so the JSON body is read whichever verb the client uses.

{
  "capabilities": ["tools", "memory"],
  "n": 5
}

Response:

{
  "agents": [
    {"id": "worker-uuid", "capabilities": ["chat", "tools", "memory"], "status": "idle"}
  ]
}

400 (Zerg envelope) when the capabilities field is missing.

All Capabilities

GET /api/v1/acp/agents/capabilities

Returns the union of capabilities advertised by all registered agents.

{
  "capabilities": ["chat", "tools", "memory", "streaming"]
}

Agent Detail

GET /api/v1/acp/agents/:agent_id

Returns one agent’s registry entry. 404 if the agent is not registered.

{
  "id": "worker-uuid",
  "capabilities": ["chat", "tools", "memory"],
  "status": "idle",
  "last_seen": 1745600000000
}

Send Message to Agent

POST /api/v1/acp/agents/:agent_id/message

Forwards a message to a specific agent via the ACP router. The authenticated caller’s user_uuid and permissions are injected into the payload. 404 if the agent is not registered.

{
  "action": "execute",
  "payload": { }
}

Response:

{
  "status": "dispatched",
  "id": "req-123"
}

Error Codes:

CodeDescription
400Missing capabilities / invalid body (Zerg envelope)
401Authentication required
404Agent not found
502/503Dispatch failure (classified via the shared error classifier)

Examples:

# HTTP bridge
curl http://127.0.0.1:21434/api/v1/acp/agents \
  -H "Authorization: Bearer $TOKEN"

curl -X POST http://127.0.0.1:21434/api/v1/acp/agents/worker-uuid/message \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"action": "execute", "payload": {}}'

The TCP listener is a raw msgpack protocol (frame = HMAC-SHA256 prefix + msgpack body, {packet, 4} length framing) — there is no zerg acp CLI surface; use the HTTP bridge above for ad-hoc calls.