acp

package
v0.76.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package acp implements a preview Agent Client Protocol (ACP) version 1 companion. It speaks ACP over stdio and turns each prompt into an ordinary AMQ message. It never opens a socket, never executes tools, and never advertises ACP version 2.

Index

Constants

View Source
const (
	EnvRoot       = "AM_ROOT"
	EnvMe         = "AM_ME"
	EnvTo         = "AMQ_ACP_TO"
	EnvBaseRoot   = "AM_BASE_ROOT"
	EnvSession    = "AM_SESSION"
	EnvRootID     = "AM_ROOT_ID"
	EnvBaseRootID = "AM_BASE_ROOT_ID"
)

Environment variables that select the routing context. The pin variables are the same ones amq itself honors. This companion authenticates them and refuses on a mismatch instead of restating the CLI's routing policy.

View Source
const (
	EgressConfirmed   = "confirmed"
	EgressUncertain   = "uncertain"
	DeliveryDuplicate = "already_queued"
)
View Source
const DeliveryStateQueued = "queued_to_inbox"

DeliveryStateQueued is the honest post-delivery state. The message sits in the recipient's inbox/new; consumption is a separate, unproven event.

View Source
const PromptSubject = "ACP prompt"

PromptSubject labels prompts arriving over the ACP companion so an operator reading a mailbox can tell where the message came from.

View Source
const ProtocolVersion = 1

ProtocolVersion is the only ACP version this companion speaks. It is never negotiated upward: a client asking for a newer version still receives 1 and decides for itself whether to disconnect.

View Source
const StopReasonEndTurn = "end_turn"

StopReasonEndTurn ends a prompt turn once the message is queued. The turn is genuinely over because this companion runs no model and requests no tools.

Variables

This section is empty.

Functions

func PrepareWorkerEnv added in v0.68.0

func PrepareWorkerEnv() error

PrepareWorkerEnv enforces the Buzz remote-task policy on this process, then strips every BUZZ_* variable so secrets cannot leak into later work.

agents must be 1 and inbound must be owner-only. The gate waits for the harness to hold a Buzz NIP-PL kind:30350 lease with a quota-1 deployment-identity profile (block/buzz#5667); this companion does not treat an env string as one.

Types

type Config

type Config struct {
	Root string
	Me   string
	To   string
}

Config is the resolved routing context for one amq-acp process.

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig resolves the routing context from the environment. An absent root, an unusable handle, or a session pin that cannot be authenticated all refuse; there is no fallback to a guessed root.

type ContextError

type ContextError struct {
	Message string
}

ContextError marks a fail-closed routing refusal so the caller can report the repository's context-mismatch exit code.

func (*ContextError) Error

func (e *ContextError) Error() string

type Delivery

type Delivery struct {
	MessageID string
	To        string
	Thread    string
	EventID   string
	State     string
	Committed bool
	Drained   bool
	Started   bool
	Completed bool
	Egress    string
	Duplicate bool
}

Delivery is the durable outcome of one prompt turn. The message is queued in the recipient's inbox; nothing here proves the recipient consumed it.

func DeliverPrompt

func DeliverPrompt(cfg Config, body, eventID string) (Delivery, error)

DeliverPrompt writes the prompt text into the destination inbox using the ordinary Maildir tmp -> new delivery, so amq list and amq drain observe it exactly like any other message. Recipient and root always come from Config; prompt text, including a Buzz [Context] section, is never treated as authentication or a routing override.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a single-connection ACP v1 agent. Requests are handled one at a time in arrival order, so the session table needs no locking.

func NewServer

func NewServer(cfg Config, version string) *Server

NewServer builds a server bound to one already authenticated routing context.

func (*Server) Serve

func (s *Server) Serve(in io.Reader, out io.Writer) error

Serve reads newline-delimited JSON-RPC objects from in and writes one response line per request. Notifications produce no response. It returns once in is exhausted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL