acpcore

package module
v0.0.0-...-76edb30 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 9 Imported by: 0

README

acp-go-core

The shared module and contract of the acp-go-* family: Go packages that give local coding-agent harnesses an ACP interface. This repository holds the code every sibling has in common, the family contract, the per-sibling registry, the lifecycle fixture battery, and the checks that keep the siblings aligned.

The Family

Repo Package Vendor key Native surface Store format
acp-go-claude claudeacp claude Claude Code stream-json and control protocol claude-transcript-jsonl-v1
acp-go-codex codexacp codex codex app-server stdio protocol codex-rollout-jsonl-v1
acp-go-hermes hermesacp hermes hermes serve WebSocket JSON-RPC and HTTP persistence hermes-session-json-v1
acp-go-opencode opencodeacp opencode opencode serve HTTP and SSE opencode-sync-events-v1
acp-go-pi piacp pi pi --mode rpc JSONL protocol pi-session-jsonl-v1
acp-go-amp ampacp amp amp threads continue stream-json with a native lifecycle plugin amp-thread-json-v1

The registry records each sibling's capabilities, options, and deviations, with native verification where a run has been recorded.

Packages

The package list and what each owns is in docs/01.

import (
    acpcore "github.com/savid/acp-go-core"
    "github.com/savid/acp-go-core/lifecycle"
    "github.com/savid/acp-go-core/process"
)

A sibling imports what it needs and re-exports nothing. A host imports the root package for the store types it implements and lifecycle for the reducer.

Shared Pins

Every sibling moves together on these pins. Values live only in this table.

Pin Value
ACP SDK github.com/coder/acp-go-sdk@v0.13.5
Go directive go 1.26.6

Every sibling MUST require one shared version of this module, a commit on its master, without a replace directive for it; make drift-check compares the siblings. Local development may use an untracked Go workspace.

A pin change covers every sibling and reruns each conformance suite. Shared direct dependencies such as OpenTelemetry and testify also move together; their versions live in go.mod files and are compared by make drift-check.

Protocol Posture
  • The family implements published ACP v1. Adopting v2 is one coordinated cutover across the family and its hosts.
  • Protocol claims come from the published spec and schema. The pinned Go SDK is evidence for its own generated types and transport bounds only.
  • The three reserved family literals are defined in docs/00.
  • Current upstream status and adoption triggers live in the watchlist.

Checks

make test          # race, shuffled
make audit         # fmt-check lint build coverage-check tidy vuln modernize-check, then go mod verify
make check         # links, skill metadata, fixture structure, script syntax
make drift-check   # family structural contract across sibling checkouts

make check validates this repo's local links and anchors, skill metadata and symlinks, lifecycle fixture structure and violation coverage, and script syntax. It runs without sibling checkouts and needs Bash, Make, and Python 3 with PyYAML.

make drift-check verifies the enumerable structural rules in docs/06 against the sibling checkouts beside this repo. It needs Bash, Git, Python 3, and rg. Missing checkouts are reported and skipped. A pass proves the enumerated structure, not behavior.

Core Principles

The family principles are stated once, in docs/00.

Documentation

Page Scope
00 · Overview Ownership, identity, reserved literals, error vocabulary
01 · Public API This module, agent surface, options, builders
02 · Wire contract Capabilities, methods, metadata, envelopes
03 · Sessions and store Persistence, commit ordering, restore, identity
04 · Behavior Config, models, images, usage, permissions, commands, delete
05 · Lifecycle Process model, cancellation, shutdown, concurrency
06 · Repository standards Layout, tooling, CI, docs
07 · Testing Unit, conformance, fixtures, integration
Registry Current per-sibling facts and deviations

The lifecycle manifest is the canonical reducer battery, embedded as lifecycle.Fixtures and run by go test ./lifecycle. Siblings validate their emitters through the reducer.

Documentation

Overview

Package acpcore holds the behavior every acp-go-* sibling shares: the session store contract and its in-memory implementation at the root, and the sessionlog, observer, storetest, lifecycle, process, wire, and image packages beneath it.

Index

Constants

View Source
const SessionStoreMainSubpath = ""

SessionStoreMainSubpath addresses a session's main record.

View Source
const SessionStoreTimeout = 10 * time.Second

SessionStoreTimeout bounds one store call a sibling makes on a host's behalf.

Variables

View Source
var ErrSessionIDRequired = errors.New("session id is required")

ErrSessionIDRequired reports a write addressed to an empty session id.

Functions

This section is empty.

Types

type InMemorySessionStore

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

InMemorySessionStore is the default store when a host provides none, and the reference implementation the store contract battery is written against.

func NewInMemorySessionStore

func NewInMemorySessionStore() *InMemorySessionStore

NewInMemorySessionStore creates an empty process-local store.

func (*InMemorySessionStore) Delete

func (s *InMemorySessionStore) Delete(ctx context.Context, key SessionKey) error

Delete removes one subrecord, or the whole session when the main key is named; a deleted session stays deleted. Deleting a key with an empty SessionID is a no-op.

func (*InMemorySessionStore) ListSessions

func (s *InMemorySessionStore) ListSessions(ctx context.Context) ([]SessionSummary, error)

ListSessions lists committed sessions, newest first.

func (*InMemorySessionStore) Load

func (s *InMemorySessionStore) Load(ctx context.Context, sessionID string) (map[string][]SessionStoreEntry, error)

Load returns one complete session generation keyed by subpath. A live empty main record is present under the empty key; a missing session returns nil.

func (*InMemorySessionStore) Replace

func (s *InMemorySessionStore) Replace(ctx context.Context, main SessionKey, replacements []SessionStoreReplacement) error

Replace atomically publishes one session's complete generation.

type SessionKey

type SessionKey struct {
	// SessionID is the ACP-visible session ID being stored.
	SessionID string
	// Subpath is empty for the main record or names a session-owned subrecord.
	Subpath string
}

SessionKey addresses one session-store record.

type SessionStore

type SessionStore interface {
	Load(ctx context.Context, sessionID string) (map[string][]SessionStoreEntry, error)
	Replace(ctx context.Context, main SessionKey, replacements []SessionStoreReplacement) error
	Delete(ctx context.Context, key SessionKey) error
	ListSessions(ctx context.Context) ([]SessionSummary, error)
}

SessionStore is the durability boundary a host provides. Replace publishes one complete generation and is durable before it returns; it copies the entries it receives, so the caller keeps them. Load atomically reads every live subpath of one session; the returned map, slices, and bytes belong to the caller.

type SessionStoreEntry

type SessionStoreEntry = json.RawMessage

SessionStoreEntry is one JSON object in a session's main record or one of its subrecords. Implementations preserve the raw bytes; the sibling validates entries before publishing them.

type SessionStoreReplacement

type SessionStoreReplacement struct {
	Key     SessionKey
	Entries []SessionStoreEntry
}

SessionStoreReplacement is one record written during an atomic replace.

type SessionSummary

type SessionSummary struct {
	SessionID          string
	UpdatedAtUnixMilli int64
}

SessionSummary is a lightweight entry returned by session-store listers.

Directories

Path Synopsis
Package image holds the family image gates: the decoded-byte limits, the media envelope, prompt image validation in both input forms, and output normalization.
Package image holds the family image gates: the decoded-byte limits, the media envelope, prompt image validation in both input forms, and output normalization.
Package lifecycle implements the acp-go.dev/lifecycle extension: the closed event vocabulary, the strict wire decoder, the projection reducer, and the ordered emitter one session incarnation writes through.
Package lifecycle implements the acp-go.dev/lifecycle extension: the closed event vocabulary, the strict wire decoder, the projection reducer, and the ordered emitter one session incarnation writes through.
Package observer centralizes the adapter's OpenTelemetry instrumentation: ACP request spans and metrics, prompt-turn GenAI metrics, permission and elicitation dialogs, session store operations, and native process exits.
Package observer centralizes the adapter's OpenTelemetry instrumentation: ACP request spans and metrics, prompt-turn GenAI metrics, permission and elicitation dialogs, session store operations, and native process exits.
exporters
Package exporters wires the OTEL_* exporter, propagator, and log-bridge configuration a sibling's command binary hands to its Agent.
Package exporters wires the OTEL_* exporter, propagator, and log-bridge configuration a sibling's command binary hands to its Agent.
Package process launches a harness as a plain child: the merged environment, the session cwd, its own process group, and three dedicated pipes.
Package process launches a harness as a plain child: the merged environment, the session cwd, its own process group, and three dedicated pipes.
Package sessionlog mirrors native JSONL rows and their session configuration as one durable store generation.
Package sessionlog mirrors native JSONL rows and their session configuration as one durable store generation.
Package storetest is the session store contract battery.
Package storetest is the session store contract battery.
Package usage supplies shared provider account readers without acquiring credentials.
Package usage supplies shared provider account readers without acquiring credentials.
anthropic
Package anthropic reads Claude subscription allowances and usage credits.
Package anthropic reads Claude subscription allowances and usage credits.
gateway
Package gateway reads the aggregate usage report a forwarding gateway publishes for the upstream accounts it brokers.
Package gateway reads the aggregate usage report a forwarding gateway publishes for the upstream accounts it brokers.
internal/usagehttp
Package usagehttp bounds authenticated provider usage reads.
Package usagehttp bounds authenticated provider usage reads.
openaicodex
Package openaicodex reads ChatGPT subscription allowance windows.
Package openaicodex reads ChatGPT subscription allowance windows.
opencodego
Package opencodego reads OpenCode Go subscription windows.
Package opencodego reads OpenCode Go subscription windows.
openrouter
Package openrouter reads OpenRouter key allowances and account credit balances.
Package openrouter reads OpenRouter key allowances and account credit balances.
Package wire holds the uniform error shapes, raw-event framing, and reserved literal rules every sibling answers with.
Package wire holds the uniform error shapes, raw-event framing, and reserved literal rules every sibling answers with.

Jump to

Keyboard shortcuts

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