Documentation
¶
Overview ¶
Package acp implements the client side of Agent Client Protocol v1.
Index ¶
- Constants
- Variables
- type AgentCapabilities
- type AuthMethod
- type AuthenticateRequest
- type CancelSessionRequest
- type Client
- func (c *Client) Authenticate(ctx context.Context, request AuthenticateRequest) error
- func (c *Client) CancelSession(ctx context.Context, sessionID string) error
- func (c *Client) CloseSession(ctx context.Context, request CloseSessionRequest) error
- func (c *Client) Connection() *Connection
- func (c *Client) Initialize(ctx context.Context, request InitializeRequest) (InitializeResponse, error)
- func (c *Client) LoadSession(ctx context.Context, request LoadSessionRequest) (LoadSessionResponse, error)
- func (c *Client) NewSession(ctx context.Context, request NewSessionRequest) (NewSessionResponse, error)
- func (c *Client) Prompt(ctx context.Context, request PromptRequest) (PromptResponse, error)
- func (c *Client) ResumeSession(ctx context.Context, request ResumeSessionRequest) (ResumeSessionResponse, error)
- type ClientCapabilities
- type CloseSessionRequest
- type Connection
- type ContentBlock
- type EnvVariable
- type FileSystemCapabilities
- type Handler
- type Header
- type Implementation
- type InitializeRequest
- type InitializeResponse
- type LoadSessionRequest
- type LoadSessionResponse
- type MCPCapabilities
- type MCPServer
- type NewSessionRequest
- type NewSessionResponse
- type Options
- type PromptCapabilities
- type PromptRequest
- type PromptResponse
- type RPCError
- type ResumeSessionRequest
- type ResumeSessionResponse
- type SessionCapabilities
Constants ¶
const ProtocolVersion1 = 1
Variables ¶
var ErrFrameTooLarge = errors.New("ACP frame exceeds maximum size")
Functions ¶
This section is empty.
Types ¶
type AgentCapabilities ¶
type AgentCapabilities struct {
LoadSession bool `json:"loadSession"`
PromptCapabilities PromptCapabilities `json:"promptCapabilities"`
MCPCapabilities MCPCapabilities `json:"mcpCapabilities"`
SessionCapabilities SessionCapabilities `json:"sessionCapabilities"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type AuthMethod ¶
type AuthenticateRequest ¶
type AuthenticateRequest struct {
MethodID string `json:"methodId"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type CancelSessionRequest ¶
type CancelSessionRequest struct {
SessionID string `json:"sessionId"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides typed ACP v1 client operations over a Connection.
func NewClient ¶
func NewClient(conn *Connection) *Client
func (*Client) Authenticate ¶
func (c *Client) Authenticate(ctx context.Context, request AuthenticateRequest) error
func (*Client) CancelSession ¶
func (*Client) CloseSession ¶
func (c *Client) CloseSession(ctx context.Context, request CloseSessionRequest) error
func (*Client) Connection ¶
func (c *Client) Connection() *Connection
func (*Client) Initialize ¶
func (c *Client) Initialize(ctx context.Context, request InitializeRequest) (InitializeResponse, error)
func (*Client) LoadSession ¶
func (c *Client) LoadSession(ctx context.Context, request LoadSessionRequest) (LoadSessionResponse, error)
func (*Client) NewSession ¶
func (c *Client) NewSession(ctx context.Context, request NewSessionRequest) (NewSessionResponse, error)
func (*Client) Prompt ¶
func (c *Client) Prompt(ctx context.Context, request PromptRequest) (PromptResponse, error)
func (*Client) ResumeSession ¶
func (c *Client) ResumeSession(ctx context.Context, request ResumeSessionRequest) (ResumeSessionResponse, error)
type ClientCapabilities ¶
type ClientCapabilities struct {
FileSystem FileSystemCapabilities `json:"fs"`
Terminal bool `json:"terminal"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type CloseSessionRequest ¶
type CloseSessionRequest struct {
SessionID string `json:"sessionId"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a bidirectional ACP v1 JSON-RPC connection. It does not own or close the supplied streams; subprocess owners remain responsible for doing so.
func NewConnection ¶
func NewConnection(reader io.Reader, writer io.Writer, handler Handler, options Options) *Connection
NewConnection starts an ACP connection over newline-delimited JSON streams.
func (*Connection) Call ¶
Call invokes an ACP method and decodes its result. Calls may run concurrently.
func (*Connection) Done ¶
func (c *Connection) Done() <-chan struct{}
Done closes when the transport can no longer process messages.
func (*Connection) Err ¶
func (c *Connection) Err() error
Err returns the terminal transport or protocol error, if any.
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Data string `json:"data,omitempty"`
MimeType string `json:"mimeType,omitempty"`
URI string `json:"uri,omitempty"`
Name string `json:"name,omitempty"`
Resource json.RawMessage `json:"resource,omitempty"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type EnvVariable ¶
type FileSystemCapabilities ¶
type Handler ¶
type Handler interface {
HandleNotification(ctx context.Context, method string, params json.RawMessage)
HandleRequest(ctx context.Context, method string, params json.RawMessage) (any, *RPCError)
}
Handler receives requests and notifications initiated by the ACP agent.
type Implementation ¶
type InitializeRequest ¶
type InitializeRequest struct {
ProtocolVersion int `json:"protocolVersion"`
ClientCapabilities ClientCapabilities `json:"clientCapabilities"`
ClientInfo *Implementation `json:"clientInfo,omitempty"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type InitializeResponse ¶
type InitializeResponse struct {
ProtocolVersion int `json:"protocolVersion"`
AgentCapabilities AgentCapabilities `json:"agentCapabilities"`
AuthMethods []AuthMethod `json:"authMethods"`
AgentInfo *Implementation `json:"agentInfo,omitempty"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type LoadSessionRequest ¶
type LoadSessionResponse ¶
type LoadSessionResponse struct {
Modes json.RawMessage `json:"modes,omitempty"`
ConfigOptions json.RawMessage `json:"configOptions,omitempty"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type MCPCapabilities ¶
type MCPServer ¶
type MCPServer struct {
Type string `json:"type,omitempty"`
Name string `json:"name"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env []EnvVariable `json:"env,omitempty"`
URL string `json:"url,omitempty"`
Headers []Header `json:"headers,omitempty"`
}
MCPServer represents either the baseline stdio transport or a capability- gated HTTP/SSE transport.
type NewSessionRequest ¶
type NewSessionRequest struct {
CWD string `json:"cwd"`
MCPServers []MCPServer `json:"mcpServers"`
AdditionalDirectories []string `json:"additionalDirectories,omitempty"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type NewSessionResponse ¶
type NewSessionResponse struct {
SessionID string `json:"sessionId"`
Modes json.RawMessage `json:"modes,omitempty"`
ConfigOptions json.RawMessage `json:"configOptions,omitempty"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type PromptCapabilities ¶
type PromptRequest ¶
type PromptRequest struct {
SessionID string `json:"sessionId"`
Prompt []ContentBlock `json:"prompt"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type PromptResponse ¶
type PromptResponse struct {
StopReason string `json:"stopReason"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data,omitempty"`
}
RPCError is a JSON-RPC error returned by either ACP endpoint.
func MethodNotFound ¶
MethodNotFound creates the standard JSON-RPC method-not-found response.
type ResumeSessionRequest ¶
type ResumeSessionRequest = LoadSessionRequest
type ResumeSessionResponse ¶
type ResumeSessionResponse = LoadSessionResponse
type SessionCapabilities ¶
type SessionCapabilities struct {
Resume json.RawMessage `json:"resume,omitempty"`
Close json.RawMessage `json:"close,omitempty"`
List json.RawMessage `json:"list,omitempty"`
Delete json.RawMessage `json:"delete,omitempty"`
AdditionalDirectories json.RawMessage `json:"additionalDirectories,omitempty"`
}
func (SessionCapabilities) SupportsClose ¶
func (c SessionCapabilities) SupportsClose() bool
func (SessionCapabilities) SupportsResume ¶
func (c SessionCapabilities) SupportsResume() bool