Documentation
¶
Overview ¶
Package acp implements the ACP v1 stdio client protocol using only Go's standard library. Specification: https://agentclientprotocol.com/protocol/v1/overview
Index ¶
- Constants
- func AcceptElicitation(content map[string]schema.ElicitationContentValue) schema.CreateElicitationResponse
- func CancelElicitation() schema.CreateElicitationResponse
- func ConfigOptionsClientCapabilities(boolean bool) *schema.ClientSessionCapabilities
- func DeclineElicitation() schema.CreateElicitationResponse
- func ElicitationClientCapabilities(form, url bool) *schema.ElicitationCapabilities
- func IsAuthRequired(err error) bool
- func IsResourceNotFound(err error) bool
- func NewHTTPMCPServer(name, url string, headers ...schema.HttpHeader) schema.McpServer
- func NewSSEMCPServer(name, url string, headers ...schema.HttpHeader) schema.McpServer
- func NewStdioMCPServer(name, command string, args []string, env map[string]string) schema.McpServer
- type BatchCall
- type Capabilities
- type ClientInfo
- type Connection
- func (c *Connection) Authenticate(ctx context.Context, init Initialization, method string) error
- func (c *Connection) Call(ctx context.Context, method string, params, result any) error
- func (c *Connection) CallBatch(ctx context.Context, calls []BatchCall) []error
- func (c *Connection) CancelSession(ctx context.Context, sessionID SessionID) error
- func (c *Connection) Close() error
- func (c *Connection) CloseSession(ctx context.Context, init Initialization, sessionID SessionID) error
- func (c *Connection) DeleteSession(ctx context.Context, init Initialization, sessionID SessionID) error
- func (c *Connection) Done() <-chan struct{}
- func (c *Connection) Err() error
- func (c *Connection) Initialize(ctx context.Context, caps Capabilities) (Initialization, error)
- func (c *Connection) InitializeWithInfo(ctx context.Context, caps Capabilities, info ClientInfo) (Initialization, error)
- func (c *Connection) ListSessions(ctx context.Context, init Initialization, request schema.ListSessionsRequest) (schema.ListSessionsResponse, error)
- func (c *Connection) LoadSession(ctx context.Context, init Initialization, request schema.LoadSessionRequest) (schema.LoadSessionResponse, error)
- func (c *Connection) Logout(ctx context.Context, init Initialization) error
- func (c *Connection) NewSession(ctx context.Context, directory string) (Session, error)
- func (c *Connection) NewSessionWithOptions(ctx context.Context, init Initialization, directory string, ...) (Session, error)
- func (c *Connection) Notify(ctx context.Context, method string, params any) error
- func (c *Connection) Prompt(ctx context.Context, session Session, text string) (schema.StopReason, error)
- func (c *Connection) PromptContent(ctx context.Context, init Initialization, session Session, prompt []Content) (schema.StopReason, error)
- func (c *Connection) ResumeSession(ctx context.Context, init Initialization, request schema.ResumeSessionRequest) (schema.ResumeSessionResponse, error)
- func (c *Connection) SetBooleanConfig(ctx context.Context, session *Session, configID string, value bool) error
- func (c *Connection) SetEffort(ctx context.Context, session *Session, effort string) error
- func (c *Connection) SetMode(ctx context.Context, session *Session, mode string) error
- func (c *Connection) SetModel(ctx context.Context, session *Session, model string) error
- type Content
- func NewAudioContent(mimeType, base64Data string) Content
- func NewBlobResourceContent(uri, base64Data string) Content
- func NewImageContent(mimeType, base64Data string) Content
- func NewResourceLinkContent(name, uri string) Content
- func NewTextContent(text string) Content
- func NewTextResourceContent(uri, text string) Content
- type ElicitationHandler
- type Handler
- type Initialization
- type NewSessionOptions
- type Notifications
- type RPCError
- type Session
- type SessionID
- type Update
- func NewAgentMessageChunkUpdate(sessionID SessionID, chunk schema.ContentChunk) Update
- func NewAgentThoughtChunkUpdate(sessionID SessionID, chunk schema.ContentChunk) Update
- func NewAvailableCommandsUpdate(sessionID SessionID, commands []schema.AvailableCommand) Update
- func NewConfigOptionUpdate(sessionID SessionID, options []schema.SessionConfigOption) Update
- func NewCurrentModeUpdate(sessionID SessionID, modeID schema.SessionModeId) Update
- func NewPlanUpdate(sessionID SessionID, plan schema.Plan) Update
- func NewSessionInfoUpdate(sessionID SessionID, info schema.SessionInfoUpdate) Update
- func NewToolCallChangedUpdate(sessionID SessionID, update schema.ToolCallUpdate) Update
- func NewToolCallUpdate(sessionID SessionID, call schema.ToolCall) Update
- func NewUsageUpdate(sessionID SessionID, used, size uint64) Update
- func NewUserMessageChunkUpdate(sessionID SessionID, chunk schema.ContentChunk) Update
Constants ¶
const ( ErrorCodeAuthRequired = -32000 ErrorCodeResourceNotFound = -32002 )
ACP-specific JSON-RPC error codes.
const Version = schema.ProtocolVersion(1)
Version is the ACP protocol version implemented by this module.
Variables ¶
This section is empty.
Functions ¶
func AcceptElicitation ¶ added in v0.2.0
func AcceptElicitation(content map[string]schema.ElicitationContentValue) schema.CreateElicitationResponse
func CancelElicitation ¶ added in v0.2.0
func CancelElicitation() schema.CreateElicitationResponse
func ConfigOptionsClientCapabilities ¶ added in v0.2.0
func ConfigOptionsClientCapabilities(boolean bool) *schema.ClientSessionCapabilities
ConfigOptionsClientCapabilities advertises support for session config options. Boolean support is an extension beyond flat selectors.
func DeclineElicitation ¶ added in v0.2.0
func DeclineElicitation() schema.CreateElicitationResponse
func ElicitationClientCapabilities ¶ added in v0.2.0
func ElicitationClientCapabilities(form, url bool) *schema.ElicitationCapabilities
ElicitationClientCapabilities advertises support for form and URL modes.
func IsAuthRequired ¶ added in v0.2.0
func IsResourceNotFound ¶ added in v0.2.0
func NewHTTPMCPServer ¶ added in v0.2.0
func NewHTTPMCPServer(name, url string, headers ...schema.HttpHeader) schema.McpServer
func NewSSEMCPServer ¶ added in v0.2.0
func NewSSEMCPServer(name, url string, headers ...schema.HttpHeader) schema.McpServer
Types ¶
type Capabilities ¶
type Capabilities = schema.ClientCapabilities
The exported names below are intentional aliases into the generated schema package. Client code can use the small acp facade without losing access to fields introduced by future pinned schema releases.
func WorkspaceCapabilities ¶ added in v0.2.0
func WorkspaceCapabilities(readFiles, writeFiles, terminal bool) Capabilities
WorkspaceCapabilities advertises the filesystem and terminal host methods used by unattended clients. Every argument defaults to disabled when false.
type ClientInfo ¶
type ClientInfo = schema.Implementation
The exported names below are intentional aliases into the generated schema package. Client code can use the small acp facade without losing access to fields introduced by future pinned schema releases.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func Connect ¶
func Connect(in io.ReadCloser, out io.WriteCloser, h Handler, n Notifications) *Connection
Connect owns both streams until Close. Frames are limited to 8 MiB; at most 32 incoming requests run concurrently. Unknown notifications can be ignored.
func (*Connection) Authenticate ¶
func (c *Connection) Authenticate(ctx context.Context, init Initialization, method string) error
func (*Connection) CallBatch ¶ added in v0.6.0
func (c *Connection) CallBatch(ctx context.Context, calls []BatchCall) []error
CallBatch sends requests as one JSON-RPC array and waits for their matching responses. Responses may be returned individually or in a response batch.
func (*Connection) CancelSession ¶ added in v0.2.0
func (c *Connection) CancelSession(ctx context.Context, sessionID SessionID) error
func (*Connection) Close ¶
func (c *Connection) Close() error
func (*Connection) CloseSession ¶ added in v0.2.0
func (c *Connection) CloseSession(ctx context.Context, init Initialization, sessionID SessionID) error
func (*Connection) DeleteSession ¶ added in v0.2.0
func (c *Connection) DeleteSession(ctx context.Context, init Initialization, sessionID SessionID) error
func (*Connection) Done ¶
func (c *Connection) Done() <-chan struct{}
func (*Connection) Err ¶
func (c *Connection) Err() error
func (*Connection) Initialize ¶
func (c *Connection) Initialize(ctx context.Context, caps Capabilities) (Initialization, error)
func (*Connection) InitializeWithInfo ¶
func (c *Connection) InitializeWithInfo(ctx context.Context, caps Capabilities, info ClientInfo) (Initialization, error)
InitializeWithInfo negotiates ACP v1 with the calling application's identity.
func (*Connection) ListSessions ¶ added in v0.2.0
func (c *Connection) ListSessions(ctx context.Context, init Initialization, request schema.ListSessionsRequest) (schema.ListSessionsResponse, error)
func (*Connection) LoadSession ¶ added in v0.2.0
func (c *Connection) LoadSession(ctx context.Context, init Initialization, request schema.LoadSessionRequest) (schema.LoadSessionResponse, error)
func (*Connection) Logout ¶ added in v0.2.0
func (c *Connection) Logout(ctx context.Context, init Initialization) error
func (*Connection) NewSession ¶
func (*Connection) NewSessionWithOptions ¶ added in v0.2.0
func (c *Connection) NewSessionWithOptions(ctx context.Context, init Initialization, directory string, options NewSessionOptions) (Session, error)
func (*Connection) Prompt ¶
func (c *Connection) Prompt(ctx context.Context, session Session, text string) (schema.StopReason, error)
func (*Connection) PromptContent ¶ added in v0.2.0
func (c *Connection) PromptContent(ctx context.Context, init Initialization, session Session, prompt []Content) (schema.StopReason, error)
func (*Connection) ResumeSession ¶ added in v0.2.0
func (c *Connection) ResumeSession(ctx context.Context, init Initialization, request schema.ResumeSessionRequest) (schema.ResumeSessionResponse, error)
func (*Connection) SetBooleanConfig ¶ added in v0.2.0
func (c *Connection) SetBooleanConfig(ctx context.Context, session *Session, configID string, value bool) error
SetBooleanConfig sets an advertised boolean session configuration option and verifies the agent's returned current value.
func (*Connection) SetEffort ¶
SetEffort uses the current model's advertised reasoning levels. Call after SetModel because model selection may replace the available effort options.
type Content ¶
type Content = schema.ContentBlock
The exported names below are intentional aliases into the generated schema package. Client code can use the small acp facade without losing access to fields introduced by future pinned schema releases.
func NewAudioContent ¶ added in v0.2.0
func NewBlobResourceContent ¶ added in v0.2.0
func NewImageContent ¶ added in v0.2.0
func NewResourceLinkContent ¶ added in v0.2.0
func NewTextContent ¶ added in v0.2.0
func NewTextResourceContent ¶ added in v0.2.0
type ElicitationHandler ¶ added in v0.2.0
type ElicitationHandler func(context.Context, schema.CreateElicitationRequest) (schema.CreateElicitationResponse, error)
ElicitationHandler serves typed elicitation/create requests.
type Handler ¶
Handler serves agent-to-client requests. It must honor cancellation.
func HandleElicitation ¶ added in v0.2.0
func HandleElicitation(next Handler, elicitation ElicitationHandler) Handler
HandleElicitation composes typed elicitation support with another agent-to-client request handler. Pass nil for next when elicitation is the only hosted method.
type Initialization ¶
type Initialization = schema.InitializeResponse
The exported names below are intentional aliases into the generated schema package. Client code can use the small acp facade without losing access to fields introduced by future pinned schema releases.
type NewSessionOptions ¶ added in v0.2.0
NewSessionOptions carries optional fields for session/new.
type Notifications ¶
type Notifications func(string, json.RawMessage) error
Notifications run in wire order, before a subsequent response is delivered. They must return promptly and must not call back into this Connection.
func CombineNotifications ¶ added in v0.2.0
func CombineNotifications(callbacks ...Notifications) Notifications
CombineNotifications fans an incoming notification out to typed adapters in order. The first error terminates the connection, matching Connection semantics.
func ElicitationComplete ¶ added in v0.2.0
func ElicitationComplete(handler func(schema.CompleteElicitationNotification) error) Notifications
ElicitationComplete adapts the agent's elicitation/complete notification to the generated notification type. Other notifications are ignored.
func SessionUpdates ¶ added in v0.2.0
func SessionUpdates(handler func(Update) error) Notifications
SessionUpdates adapts the raw connection notification callback to the generated, discriminated-union SessionNotification type. Other ACP notifications are ignored, as required by the transport layer.
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data,omitempty"`
}
RPCError preserves the peer's JSON-RPC error, including extension data.
type Session ¶
type Session = schema.NewSessionResponse
The exported names below are intentional aliases into the generated schema package. Client code can use the small acp facade without losing access to fields introduced by future pinned schema releases.
type SessionID ¶ added in v0.2.0
The exported names below are intentional aliases into the generated schema package. Client code can use the small acp facade without losing access to fields introduced by future pinned schema releases.
type Update ¶
type Update = schema.SessionNotification
The exported names below are intentional aliases into the generated schema package. Client code can use the small acp facade without losing access to fields introduced by future pinned schema releases.
func NewAgentMessageChunkUpdate ¶ added in v0.2.0
func NewAgentMessageChunkUpdate(sessionID SessionID, chunk schema.ContentChunk) Update
func NewAgentThoughtChunkUpdate ¶ added in v0.2.0
func NewAgentThoughtChunkUpdate(sessionID SessionID, chunk schema.ContentChunk) Update
func NewAvailableCommandsUpdate ¶ added in v0.2.0
func NewAvailableCommandsUpdate(sessionID SessionID, commands []schema.AvailableCommand) Update
func NewConfigOptionUpdate ¶ added in v0.2.0
func NewConfigOptionUpdate(sessionID SessionID, options []schema.SessionConfigOption) Update
func NewCurrentModeUpdate ¶ added in v0.2.0
func NewCurrentModeUpdate(sessionID SessionID, modeID schema.SessionModeId) Update
func NewPlanUpdate ¶ added in v0.2.0
func NewSessionInfoUpdate ¶ added in v0.2.0
func NewSessionInfoUpdate(sessionID SessionID, info schema.SessionInfoUpdate) Update
func NewToolCallChangedUpdate ¶ added in v0.2.0
func NewToolCallChangedUpdate(sessionID SessionID, update schema.ToolCallUpdate) Update
func NewToolCallUpdate ¶ added in v0.2.0
func NewUsageUpdate ¶ added in v0.2.0
func NewUserMessageChunkUpdate ¶ added in v0.2.0
func NewUserMessageChunkUpdate(sessionID SessionID, chunk schema.ContentChunk) Update
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent serves ACP agents over stdio while giving them typed access to editor-provided client capabilities.
|
Package agent serves ACP agents over stdio while giving them typed access to editor-provided client capabilities. |
|
Package agentrouter selects an explicit ACP v1 or draft-v2 agent implementation from the first initialize request.
|
Package agentrouter selects an explicit ACP v1 or draft-v2 agent implementation from the first initialize request. |
|
Package clienthost provides the SDK's reference implementation of the host capabilities that an ACP agent may invoke in a client.
|
Package clienthost provides the SDK's reference implementation of the host capabilities that an ACP agent may invoke in a client. |
|
cmd
|
|
|
acpgen
command
Command acpgen generates the schema package from a pinned ACP JSON Schema release.
|
Command acpgen generates the schema package from a pinned ACP JSON Schema release. |
|
examples
|
|
|
drive-cli
command
Command drive-cli runs one unattended prompt through an external ACP CLI.
|
Command drive-cli runs one unattended prompt through an external ACP CLI. |
|
minimal-agent
command
Command minimal-agent is the smallest useful ACP agent.
|
Command minimal-agent is the smallest useful ACP agent. |
|
minimal-agent-v2
command
Command minimal-agent-v2 demonstrates the baseline draft ACP v2 agent surface over stdio.
|
Command minimal-agent-v2 demonstrates the baseline draft ACP v2 agent surface over stdio. |
|
minimal-client
command
Command minimal-client launches an ACP agent command, sends one prompt, and streams agent message chunks to stdout.
|
Command minimal-client launches an ACP agent command, sends one prompt, and streams agent message chunks to stdout. |
|
v2-one-shot-client
command
Command v2-one-shot-client sends one ACP v2 prompt and waits for idle.
|
Command v2-one-shot-client sends one ACP v2 prompt and waits for idle. |
|
internal
|
|
|
osrun
Package osrun supplies bounded command output for the Unix daemon.
|
Package osrun supplies bounded command output for the Unix daemon. |
|
Package schema provides Go types for every message in Agent Client Protocol v1, generated from the official JSON Schema release.
|
Package schema provides Go types for every message in Agent Client Protocol v1, generated from the official JSON Schema release. |
|
v2
Package v2 provides Go types for every message in the draft Agent Client Protocol v2 schema, generated from the official JSON Schema artifacts.
|
Package v2 provides Go types for every message in the draft Agent Client Protocol v2 schema, generated from the official JSON Schema artifacts. |
|
Package v2 is an explicit, draft-quality Go client for Agent Client Protocol v2.
|
Package v2 is an explicit, draft-quality Go client for Agent Client Protocol v2. |
|
agent
Package agent serves draft ACP v2 agents over stdio and gives them typed access to editor-provided client methods.
|
Package agent serves draft ACP v2 agents over stdio and gives them typed access to editor-provided client methods. |
|
mcp
Package mcp provides the draft MCP-over-ACP session options.
|
Package mcp provides the draft MCP-over-ACP session options. |
|
runner
Package runner runs one draft ACP v2 agent process, submits a prompt, and waits for that session's foreground work to become idle.
|
Package runner runs one draft ACP v2 agent process, submits a prompt, and waits for that session's foreground work to become idle. |