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
- type Capabilities
- type ClientInfo
- type ConfigOption
- type ConfigValue
- 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) Close() 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) NewSession(ctx context.Context, directory string) (Session, error)
- func (c *Connection) Notify(ctx context.Context, method string, params any) error
- func (c *Connection) Prompt(ctx context.Context, s Session, text string) (string, error)
- func (c *Connection) SetEffort(ctx context.Context, s *Session, effort string) error
- func (c *Connection) SetMode(ctx context.Context, s *Session, mode string) error
- func (c *Connection) SetModel(ctx context.Context, s *Session, model string) error
- type Content
- type Handler
- type Initialization
- type Notifications
- type RPCError
- type Session
- type Update
Constants ¶
const Version = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
type ClientInfo ¶
ClientInfo identifies the application to the agent.
type ConfigOption ¶
type ConfigOption struct {
ID string `json:"id"`
Name string `json:"name"`
Category string `json:"category,omitempty"`
Type string `json:"type"`
CurrentValue json.RawMessage `json:"currentValue"`
Options []ConfigValue `json:"options,omitempty"`
}
ConfigOption describes an agent-advertised session selector. Unknown option types and their values are preserved without requiring client support.
type ConfigValue ¶
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) Close ¶
func (c *Connection) Close() 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) NewSession ¶
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 Initialization ¶
type Initialization struct {
ProtocolVersion int `json:"protocolVersion"`
AgentCapabilities json.RawMessage `json:"agentCapabilities"`
AuthMethods []struct {
ID string `json:"id"`
Type string `json:"type"`
} `json:"authMethods"`
}
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.
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 struct {
ID string `json:"sessionId"`
ConfigOptions []ConfigOption `json:"configOptions,omitempty"`
}
type Update ¶
type Update struct {
SessionID string `json:"sessionId"`
Update struct {
Kind string `json:"sessionUpdate"`
Content json.RawMessage `json:"content"`
Title string `json:"title"`
MessageID string `json:"messageId"`
ToolCallID string `json:"toolCallId"`
Status string `json:"status"`
RawOutput json.RawMessage `json:"rawOutput"`
Meta struct {
TerminalOutput *struct {
Data string `json:"data"`
} `json:"terminal_output_delta"`
} `json:"_meta"`
} `json:"update"`
}