Documentation
¶
Overview ¶
acp.go is the typed protocol surface over Conn: it binds the generated method-name constants in methods_gen.go to the generated request/response types in types_gen.go, one Go method per ACP RPC. It adds no behavior of its own — Conn already owns id minting, framing, concurrency, and error mapping (see conn.go) — these are thin, mechanical wrappers around Conn.Call and Conn.Notify.
AgentConn is the surface a client uses to call an agent. ClientConn is the mirror: the surface an agent uses to call a client (permission requests, file I/O, terminal operations, session update notifications). CreateTerminal returns a *TerminalHandle bundling the session and terminal id, so Output/WaitForExit/Kill/Release never need them threaded through by the caller.
conn.go implements Conn, the connection dispatcher that sits directly on top of the framing (framing.go) and envelope (jsonrpc.go) layers: it reads frames one at a time via FrameReader, classifies each via ParseEnvelope, and routes the result to the right place — a registered request handler, a registered notification handler, or the pending-call table for a correlated response. It writes outgoing requests/responses/notifications through the single-writer Writer.
Conn knows nothing about ACP's specific methods or domain types: it routes purely by the JSON-RPC method string. The typed ACP surface built on top of this is Task 1.7's concern.
Package protocol is the pure wire layer of the Agent Client Protocol bridge: JSON-RPC framing, ACP message types, and generated protocol vocabulary. It never imports github.com/looprig/harness or github.com/looprig/core, directly or transitively (see acp/CLAUDE.md).
types_gen.go and methods_gen.go are generated from the pinned schema artifacts in schema/v1/ by internal/gen. Regenerate with:
framing.go implements the raw newline-delimited (NDJSON) transport framing that sits one layer below the JSON-RPC envelope in jsonrpc.go: it knows only about lines and bytes, never about JSON-RPC shapes or ACP methods. FrameReader turns an io.Reader into a sequence of length-bounded frames; Writer turns concurrent Send calls into a single, serialized stream of newline-terminated frames on an io.Writer, so no two goroutines ever write to the underlying transport at once.
All bytes read by FrameReader are untrusted wire input (see acp/CLAUDE.md: validate at the boundary, fail closed): size and content are checked before a frame is ever handed to a caller for JSON decoding.
Package protocol's jsonrpc.go implements the raw JSON-RPC 2.0 envelope layer: request/response/notification framing, id handling, and the validation limits that guard the wire boundary. It knows nothing about ACP's specific methods or domain types (those live in types_gen.go and methods_gen.go) — it is pure JSON-RPC 2.0.
All input to ParseEnvelope is untrusted wire bytes (see acp/CLAUDE.md: validate at the boundary, fail closed). Size and nesting-depth guards run before any value is unmarshaled from the payload: MaxMessageBytes is checked against the raw byte length, and MaxNestingDepth is enforced by streaming the entire document through json.Decoder.Token, which never materializes Go values, before a single field is decoded.
Index ¶
- Constants
- Variables
- type AgentAuthCapabilities
- type AgentCapabilities
- type AgentConn
- func (a *AgentConn) Authenticate(ctx context.Context, req AuthenticateRequest) (*AuthenticateResponse, error)
- func (a *AgentConn) CallExtensionWithResult(ctx context.Context, method string, params, result any) (CallResult, error)
- func (a *AgentConn) Cancel(ctx context.Context, n CancelNotification) error
- func (a *AgentConn) CloseSession(ctx context.Context, req CloseSessionRequest) (*CloseSessionResponse, error)
- func (a *AgentConn) Conn() *Conn
- func (a *AgentConn) DeleteSession(ctx context.Context, req DeleteSessionRequest) (*DeleteSessionResponse, error)
- func (a *AgentConn) Initialize(ctx context.Context, req InitializeRequest) (*InitializeResponse, error)
- func (a *AgentConn) ListSessions(ctx context.Context, req ListSessionsRequest) (*ListSessionsResponse, error)
- func (a *AgentConn) LoadSession(ctx context.Context, req LoadSessionRequest) (*LoadSessionResponse, error)
- func (a *AgentConn) NewSession(ctx context.Context, req NewSessionRequest) (*NewSessionResponse, error)
- func (a *AgentConn) Prompt(ctx context.Context, req PromptRequest) (*PromptResponse, error)
- func (a *AgentConn) PromptWithResult(ctx context.Context, req PromptRequest) (*PromptResponse, CallResult, error)
- func (a *AgentConn) ResumeSession(ctx context.Context, req ResumeSessionRequest) (*ResumeSessionResponse, error)
- func (a *AgentConn) SetConfigOption(ctx context.Context, req SetSessionConfigOptionRequest) (*SetSessionConfigOptionResponse, error)
- func (a *AgentConn) SetMode(ctx context.Context, req SetSessionModeRequest) (*SetSessionModeResponse, error)
- func (a *AgentConn) StartExtensionCall(ctx context.Context, method string, params, result any) (*CallHandle, error)
- type Annotations
- type AsyncCallResult
- type AudioContent
- type AuthMethod
- type AuthMethodAgent
- type AuthMethodID
- type AuthenticateRequest
- type AuthenticateResponse
- type AvailableCommand
- type AvailableCommandInput
- type AvailableCommandsUpdate
- type BlobResourceContents
- type BooleanConfigOptionCapabilities
- type CallHandle
- type CallResult
- type CancelNotification
- type ClientCapabilities
- type ClientConn
- func (c *ClientConn) Conn() *Conn
- func (c *ClientConn) CreateTerminal(ctx context.Context, req CreateTerminalRequest) (*TerminalHandle, error)
- func (c *ClientConn) ReadTextFile(ctx context.Context, req ReadTextFileRequest) (*ReadTextFileResponse, error)
- func (c *ClientConn) RequestPermission(ctx context.Context, req RequestPermissionRequest) (*RequestPermissionResponse, error)
- func (c *ClientConn) SessionUpdate(ctx context.Context, n SessionNotification) error
- func (c *ClientConn) WriteTextFile(ctx context.Context, req WriteTextFileRequest) (*WriteTextFileResponse, error)
- type ClientSessionCapabilities
- type CloseSessionRequest
- type CloseSessionResponse
- type ConfigOptionUpdate
- type Conn
- func (c *Conn) Call(ctx context.Context, method string, params, result any) error
- func (c *Conn) CallWithResult(ctx context.Context, method string, params, result any) (CallResult, error)
- func (c *Conn) Close() error
- func (c *Conn) Done() <-chan struct{}
- func (c *Conn) DroppedNotifications() uint64
- func (c *Conn) Handle(method string, h HandlerFunc)
- func (c *Conn) HandleNotify(method string, h NotifyFunc)
- func (c *Conn) HandleNotifyWithSequence(method string, h NotifyWithSequenceFunc)
- func (c *Conn) HandleUnknownNotify(h NotifyFunc)
- func (c *Conn) HandleUnknownNotifyWithSequence(h NotifyWithSequenceFunc)
- func (c *Conn) HandleUnknownRequest(h HandlerFunc)
- func (c *Conn) Notify(ctx context.Context, method string, params any) error
- func (c *Conn) NotifyWithResult(ctx context.Context, method string, params any) (WriteResult, error)
- func (c *Conn) StartCall(ctx context.Context, method string, params, result any) (*CallHandle, error)
- func (c *Conn) WaitForNotifications(ctx context.Context) error
- func (c *Conn) WaitForNotificationsThrough(ctx context.Context, receiveSequence uint64) error
- func (c *Conn) WaitForReceiveSequence(ctx context.Context, receiveSequence uint64) error
- type ConnClosedError
- type ConnOptions
- type Content
- type ContentBlock
- type ContentChunk
- type Cost
- type CreateTerminalRequest
- type CreateTerminalResponse
- type CurrentModeUpdate
- type DeleteSessionRequest
- type DeleteSessionResponse
- type Diff
- type EmbeddedResource
- type EmbeddedResourceResource
- type EnvVariable
- type Envelope
- type Error
- type ErrorCode
- type Fault
- func AuthRequired(message string, cause error) *Fault
- func FromWireError(w *Error) *Fault
- func InternalError(message string, cause error) *Fault
- func InvalidParams(message string, cause error) *Fault
- func InvalidRequest(message string, cause error) *Fault
- func MethodNotFound(message string, cause error) *Fault
- func ParseError(message string, cause error) *Fault
- func ResourceNotFound(message string, cause error) *Fault
- type FileSystemCapabilities
- type FrameReader
- type FrameTooLargeError
- type HTTPHeader
- type HandlerFunc
- type ID
- type ImageContent
- type Implementation
- type InitializeRequest
- type InitializeResponse
- type InvalidFrameError
- type Issue
- type IssueKind
- type KillTerminalRequest
- type KillTerminalResponse
- type Kind
- type ListSessionsRequest
- type ListSessionsResponse
- type LoadSessionRequest
- type LoadSessionResponse
- type LogoutCapabilities
- type LogoutRequest
- type LogoutResponse
- type McpCapabilities
- type McpServer
- type McpServerHTTP
- type McpServerSse
- type McpServerStdio
- type MessageID
- type Method
- type NewSessionRequest
- type NewSessionResponse
- type Notification
- type NotifyFunc
- type NotifyWithSequenceFunc
- type PermissionOption
- type PermissionOptionID
- type PermissionOptionKind
- type Plan
- type PlanEntry
- type PlanEntryPriority
- type PlanEntryStatus
- type PromptCapabilities
- type PromptRequest
- type PromptResponse
- type ProtocolVersion
- type ReadTextFileRequest
- type ReadTextFileResponse
- type ReceiveSequenceOverflowError
- type ReleaseTerminalRequest
- type ReleaseTerminalResponse
- type Request
- type RequestPermissionOutcome
- type RequestPermissionRequest
- type RequestPermissionResponse
- type ResourceLink
- type Response
- type ResumeSessionRequest
- type ResumeSessionResponse
- type Role
- type SelectedPermissionOutcome
- type SendResult
- type SessionAdditionalDirectoriesCapabilities
- type SessionCapabilities
- type SessionCloseCapabilities
- type SessionConfigBoolean
- type SessionConfigGroupID
- type SessionConfigID
- type SessionConfigOption
- type SessionConfigOptionCategory
- type SessionConfigOptionsCapabilities
- type SessionConfigSelect
- type SessionConfigSelectGroup
- type SessionConfigSelectOption
- type SessionConfigSelectOptions
- type SessionConfigValueID
- type SessionDeleteCapabilities
- type SessionID
- type SessionInfo
- type SessionInfoUpdate
- type SessionListCapabilities
- type SessionMode
- type SessionModeID
- type SessionModeState
- type SessionNotification
- type SessionResumeCapabilities
- type SessionUpdate
- type SetSessionConfigOptionRequest
- type SetSessionConfigOptionResponse
- type SetSessionModeRequest
- type SetSessionModeResponse
- type StopReason
- type Terminal
- type TerminalExitStatus
- type TerminalHandle
- func (t *TerminalHandle) ID() TerminalID
- func (t *TerminalHandle) Kill(ctx context.Context) (*KillTerminalResponse, error)
- func (t *TerminalHandle) Output(ctx context.Context) (*TerminalOutputResponse, error)
- func (t *TerminalHandle) Release(ctx context.Context) (*ReleaseTerminalResponse, error)
- func (t *TerminalHandle) WaitForExit(ctx context.Context) (*WaitForTerminalExitResponse, error)
- type TerminalID
- type TerminalOutputRequest
- type TerminalOutputResponse
- type TextContent
- type TextResourceContents
- type ToolCall
- type ToolCallContent
- type ToolCallID
- type ToolCallLocation
- type ToolCallStatus
- type ToolCallUpdate
- type ToolKind
- type TruncatedFrameError
- type UnstructuredCommandInput
- type UsageUpdate
- type ValidationError
- type WaitForTerminalExitRequest
- type WaitForTerminalExitResponse
- type WriteResult
- type WriteTextFileRequest
- type WriteTextFileResponse
- type Writer
- type WriterClosedError
Examples ¶
Constants ¶
const MaxInFlightHandlers = 64
MaxInFlightHandlers bounds how many request/notification handler callbacks may run concurrently on one Conn. Requests and notifications beyond this bound queue (as goroutines parked on a semaphore) until a slot frees.
const MaxMessageBytes = 4 * 1024 * 1024 // 4 MiB
MaxMessageBytes is the largest JSON-RPC message this module will accept. Payloads larger than this are rejected before any parsing is attempted.
const MaxNestingDepth = 128
MaxNestingDepth is the deepest object/array nesting this module will accept in a JSON-RPC message. Payloads nested deeper than this are rejected while streaming tokens, before any value is unmarshaled.
const NotifyBufferDepth = 512
NotifyBufferDepth bounds how many notifications for one not-yet-registered method a Conn will buffer before HandleNotify is called for that method. Once the depth is exceeded, the oldest buffered notification is dropped to make room for the newest, and the drop is counted (see Conn.DroppedNotifications).
const SendQueueDepth = 256
SendQueueDepth bounds how many frames Writer will buffer between a caller's Send call and the single internal goroutine that owns the underlying io.Writer. A Send that would exceed this depth blocks until room is available or the Writer is closed.
Variables ¶
var AgentMethods = map[Method]struct{}{ MethodAuthenticate: {}, MethodInitialize: {}, MethodLogout: {}, MethodSessionCancel: {}, MethodSessionClose: {}, MethodSessionDelete: {}, MethodSessionList: {}, MethodSessionLoad: {}, MethodSessionNew: {}, MethodSessionPrompt: {}, MethodSessionResume: {}, MethodSessionSetConfigOption: {}, MethodSessionSetMode: {}, }
AgentMethods is the set of agent-bound method names.
var ClientMethods = map[Method]struct{}{ MethodFsReadTextFile: {}, MethodFsWriteTextFile: {}, MethodSessionRequestPermission: {}, MethodSessionUpdate: {}, MethodTerminalCreate: {}, MethodTerminalKill: {}, MethodTerminalOutput: {}, MethodTerminalRelease: {}, MethodTerminalWaitForExit: {}, }
ClientMethods is the set of client-bound method names.
var ProtocolMethods = map[Method]struct{}{ MethodCancelRequest: {}, }
ProtocolMethods is the set of protocol-level method names.
Functions ¶
This section is empty.
Types ¶
type AgentAuthCapabilities ¶
type AgentAuthCapabilities struct {
// Whether the agent supports the logout method.
//
// Optional. Omitted or `null` both mean the agent does not advertise support.
// Supplying `{}` means the agent supports the logout method.
Logout *LogoutCapabilities `json:"logout,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
AgentAuthCapabilities Authentication-related capabilities supported by the agent.
type AgentCapabilities ¶
type AgentCapabilities struct {
// Authentication-related capabilities supported by the agent.
Auth *AgentAuthCapabilities `json:"auth,omitempty"`
// Whether the agent supports `session/load`.
LoadSession bool `json:"loadSession,omitempty"`
// MCP capabilities supported by the agent.
McpCapabilities *McpCapabilities `json:"mcpCapabilities,omitempty"`
// Prompt capabilities supported by the agent.
PromptCapabilities *PromptCapabilities `json:"promptCapabilities,omitempty"`
// Session lifecycle and prompt capabilities advertised by the agent.
SessionCapabilities *SessionCapabilities `json:"sessionCapabilities,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
AgentCapabilities Capabilities supported by the agent.
Advertised during initialization to inform the client about available features and content types.
See protocol docs: [Agent Capabilities](https://agentclientprotocol.com/protocol/initialization#agent-capabilities)
func DefaultAgentCapabilities ¶
func DefaultAgentCapabilities() AgentCapabilities
DefaultAgentCapabilities returns AgentCapabilities with every schema-declared default applied.
type AgentConn ¶
type AgentConn struct {
// contains filtered or unexported fields
}
AgentConn is the typed surface for the methods a client calls on an agent: one method per entry in AgentMethods.
func NewAgentConn ¶
NewAgentConn wraps conn as the typed agent-served method surface.
func (*AgentConn) Authenticate ¶
func (a *AgentConn) Authenticate(ctx context.Context, req AuthenticateRequest) (*AuthenticateResponse, error)
Authenticate calls the agent's "authenticate" method.
func (*AgentConn) CallExtensionWithResult ¶
func (a *AgentConn) CallExtensionWithResult(ctx context.Context, method string, params, result any) (CallResult, error)
CallExtensionWithResult is the protocol-owned generic primitive for a vendor/extension request. It deliberately lives on AgentConn rather than in acp/client's public surface so typed client methods can use the disjoint extension id space without exposing arbitrary method probing to callers.
func (*AgentConn) Cancel ¶
func (a *AgentConn) Cancel(ctx context.Context, n CancelNotification) error
Cancel sends the "session/cancel" notification. It never blocks on a response: ACP notifications have none.
func (*AgentConn) CloseSession ¶
func (a *AgentConn) CloseSession(ctx context.Context, req CloseSessionRequest) (*CloseSessionResponse, error)
CloseSession calls the agent's "session/close" method.
func (*AgentConn) Conn ¶
Conn returns the underlying Conn, for callers that also need direct access to it (Close, Done, extension traffic, and so on).
func (*AgentConn) DeleteSession ¶
func (a *AgentConn) DeleteSession(ctx context.Context, req DeleteSessionRequest) (*DeleteSessionResponse, error)
DeleteSession calls the agent's "session/delete" method.
func (*AgentConn) Initialize ¶
func (a *AgentConn) Initialize(ctx context.Context, req InitializeRequest) (*InitializeResponse, error)
Initialize calls the agent's "initialize" method.
func (*AgentConn) ListSessions ¶
func (a *AgentConn) ListSessions(ctx context.Context, req ListSessionsRequest) (*ListSessionsResponse, error)
ListSessions calls the agent's "session/list" method.
func (*AgentConn) LoadSession ¶
func (a *AgentConn) LoadSession(ctx context.Context, req LoadSessionRequest) (*LoadSessionResponse, error)
LoadSession calls the agent's "session/load" method.
func (*AgentConn) NewSession ¶
func (a *AgentConn) NewSession(ctx context.Context, req NewSessionRequest) (*NewSessionResponse, error)
NewSession calls the agent's "session/new" method.
func (*AgentConn) Prompt ¶
func (a *AgentConn) Prompt(ctx context.Context, req PromptRequest) (*PromptResponse, error)
Prompt calls the agent's "session/prompt" method.
func (*AgentConn) PromptWithResult ¶
func (a *AgentConn) PromptWithResult(ctx context.Context, req PromptRequest) (*PromptResponse, CallResult, error)
PromptWithResult is Prompt's additive ordered form. It exposes the response receive sequence and writer-admission fact while preserving the original Prompt API for callers that do not need ordering evidence.
func (*AgentConn) ResumeSession ¶
func (a *AgentConn) ResumeSession(ctx context.Context, req ResumeSessionRequest) (*ResumeSessionResponse, error)
ResumeSession calls the agent's "session/resume" method.
func (*AgentConn) SetConfigOption ¶
func (a *AgentConn) SetConfigOption(ctx context.Context, req SetSessionConfigOptionRequest) (*SetSessionConfigOptionResponse, error)
SetConfigOption calls the agent's "session/set_config_option" method.
func (*AgentConn) SetMode ¶
func (a *AgentConn) SetMode(ctx context.Context, req SetSessionModeRequest) (*SetSessionModeResponse, error)
SetMode calls the agent's "session/set_mode" method.
func (*AgentConn) StartExtensionCall ¶
func (a *AgentConn) StartExtensionCall(ctx context.Context, method string, params, result any) (*CallHandle, error)
StartExtensionCall is the asynchronous counterpart used by fixed typed extension surfaces. The method string stays in protocol so callers above this package cannot turn the typed client API into arbitrary probing.
type Annotations ¶
type Annotations struct {
// Intended recipients for this content, such as the user or assistant.
Audience []Role `json:"audience,omitempty"`
// Timestamp indicating when the underlying resource was last modified.
LastModified *string `json:"lastModified,omitempty"`
// Relative importance of this content when clients choose what to surface.
Priority *float64 `json:"priority,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
Annotations Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
type AsyncCallResult ¶
type AsyncCallResult struct {
Facts CallResult
Err error
}
AsyncCallResult is the exactly-once completion of one asynchronous Call. Facts are retained even when Err is non-nil, including cancellation, connection closure, and peer faults.
type AudioContent ¶
type AudioContent struct {
// Optional annotations that help clients decide how to display or route this content.
Annotations *Annotations `json:"annotations,omitempty"`
// Base64-encoded media payload.
Data string `json:"data"`
// MIME type describing the encoded media payload.
MimeType string `json:"mimeType"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
AudioContent Audio provided to or from an LLM.
type AuthMethod ¶
type AuthMethod = AuthMethodAgent
AuthMethod Describes an available authentication method.
The `type` field acts as the discriminator in the serialized JSON form. When no `type` is present, the method is treated as `agent`.
type AuthMethodAgent ¶
type AuthMethodAgent struct {
// Optional description providing more details about this authentication method.
Description *string `json:"description,omitempty"`
// Unique identifier for this authentication method.
ID AuthMethodID `json:"id"`
// Human-readable name of the authentication method.
Name string `json:"name"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
AuthMethodAgent Agent handles authentication itself.
This is the default authentication method type.
type AuthMethodID ¶
type AuthMethodID string
AuthMethodID Typed identifier used for auth method values on the wire.
type AuthenticateRequest ¶
type AuthenticateRequest struct {
// The ID of the authentication method to use.
// Must be one of the methods advertised in the initialize response.
MethodID AuthMethodID `json:"methodId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
AuthenticateRequest Request parameters for the authenticate method.
Specifies which authentication method to use.
type AuthenticateResponse ¶
type AuthenticateResponse struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
AuthenticateResponse Response to the `authenticate` method.
type AvailableCommand ¶
type AvailableCommand struct {
// Human-readable description of what the command does.
Description string `json:"description"`
// Input for the command if required
Input *AvailableCommandInput `json:"input,omitempty"`
// Command name (e.g., `create_plan`, `research_codebase`).
Name string `json:"name"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
AvailableCommand Information about a command.
type AvailableCommandInput ¶
type AvailableCommandInput = UnstructuredCommandInput
AvailableCommandInput The input specification for a command.
type AvailableCommandsUpdate ¶
type AvailableCommandsUpdate struct {
// Commands the agent can execute
AvailableCommands []AvailableCommand `json:"availableCommands"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
AvailableCommandsUpdate Available commands are ready or have changed
type BlobResourceContents ¶
type BlobResourceContents struct {
// Base64-encoded bytes for a binary resource payload.
Blob string `json:"blob"`
// MIME type describing the encoded media payload.
MimeType *string `json:"mimeType,omitempty"`
// URI associated with this resource or media payload.
URI string `json:"uri"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
BlobResourceContents Binary resource contents.
type BooleanConfigOptionCapabilities ¶
type BooleanConfigOptionCapabilities struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
BooleanConfigOptionCapabilities Capabilities for boolean session configuration options.
Supplying `{}` means the client supports boolean session configuration options.
type CallHandle ¶
type CallHandle struct {
// contains filtered or unexported fields
}
CallHandle is the minimal asynchronous request primitive used by typed ACP extension calls. Admission has capacity one and receives exactly one value (true at Writer queue admission, false when the request is rejected before admission) before closing. Result has capacity one and receives exactly one AsyncCallResult before closing. Cancel is idempotent and only cancels this call's observation; a request admitted to Writer remains eligible for its raw write.
func (*CallHandle) Admission ¶
func (h *CallHandle) Admission() <-chan bool
Admission reports the one writer-admission fact for this call.
func (*CallHandle) Cancel ¶
func (h *CallHandle) Cancel()
Cancel stops waiting for this call's response. If Writer admission already happened, the resulting completion retains Facts.WriteAdmitted=true and the admitted frame is still drained by Writer.
func (*CallHandle) Result ¶
func (h *CallHandle) Result() <-chan AsyncCallResult
Result reports the one final call completion.
type CallResult ¶
CallResult contains ordered transport facts for one Conn call. The response sequence is zero only when no response was received (for example, cancellation or connection loss before the peer replied). WriteAdmitted is true once the request frame crossed Writer's admission boundary; it remains true for every later response, protocol error, timeout, or connection error.
type CancelNotification ¶
type CancelNotification struct {
// The ID of the session to cancel operations for.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
CancelNotification Notification to cancel ongoing operations for a session.
See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
type ClientCapabilities ¶
type ClientCapabilities struct {
// File system capabilities supported by the client.
// Determines which file operations the agent can request.
Fs *FileSystemCapabilities `json:"fs,omitempty"`
// Session-related capabilities supported by the client.
//
// Optional. Omitted or `null` both mean the client does not advertise any
// session-related extensions.
Session *ClientSessionCapabilities `json:"session,omitempty"`
// Whether the Client support all `terminal/*` methods.
Terminal bool `json:"terminal,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ClientCapabilities Capabilities supported by the client.
Advertised during initialization to inform the agent about available features and methods.
See protocol docs: [Client Capabilities](https://agentclientprotocol.com/protocol/initialization#client-capabilities)
func DefaultClientCapabilities ¶
func DefaultClientCapabilities() ClientCapabilities
DefaultClientCapabilities returns ClientCapabilities with every schema-declared default applied.
type ClientConn ¶
type ClientConn struct {
// contains filtered or unexported fields
}
ClientConn is the typed surface for the methods an agent calls on a client: one method per entry in ClientMethods.
func NewClientConn ¶
func NewClientConn(conn *Conn) *ClientConn
NewClientConn wraps conn as the typed client-served method surface.
func (*ClientConn) Conn ¶
func (c *ClientConn) Conn() *Conn
Conn returns the underlying Conn, for callers that also need direct access to it (Close, Done, extension traffic, and so on).
func (*ClientConn) CreateTerminal ¶
func (c *ClientConn) CreateTerminal(ctx context.Context, req CreateTerminalRequest) (*TerminalHandle, error)
CreateTerminal calls the client's "terminal/create" method and returns a *TerminalHandle bundling the session id (from req) and the terminal id (from the response), so Output/WaitForExit/Kill/Release never need to be given either again.
func (*ClientConn) ReadTextFile ¶
func (c *ClientConn) ReadTextFile(ctx context.Context, req ReadTextFileRequest) (*ReadTextFileResponse, error)
ReadTextFile calls the client's "fs/read_text_file" method.
func (*ClientConn) RequestPermission ¶
func (c *ClientConn) RequestPermission(ctx context.Context, req RequestPermissionRequest) (*RequestPermissionResponse, error)
RequestPermission calls the client's "session/request_permission" method.
func (*ClientConn) SessionUpdate ¶
func (c *ClientConn) SessionUpdate(ctx context.Context, n SessionNotification) error
SessionUpdate sends the "session/update" notification. It never blocks on a response: ACP notifications have none.
func (*ClientConn) WriteTextFile ¶
func (c *ClientConn) WriteTextFile(ctx context.Context, req WriteTextFileRequest) (*WriteTextFileResponse, error)
WriteTextFile calls the client's "fs/write_text_file" method.
type ClientSessionCapabilities ¶
type ClientSessionCapabilities struct {
// Config option capabilities supported by the client.
//
// Omitted or `null` both mean the client does not advertise support for any
// config option extensions.
ConfigOptions *SessionConfigOptionsCapabilities `json:"configOptions,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ClientSessionCapabilities Session-related capabilities supported by the client.
type CloseSessionRequest ¶
type CloseSessionRequest struct {
// The ID of the session to close.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
CloseSessionRequest Request parameters for closing an active session.
If supported, the agent **must** cancel any ongoing work related to the session (treat it as if `session/cancel` was called) and then free up any resources associated with the session.
Only available if the Agent supports the `sessionCapabilities.close` capability.
type CloseSessionResponse ¶
type CloseSessionResponse struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
CloseSessionResponse Response from closing a session.
type ConfigOptionUpdate ¶
type ConfigOptionUpdate struct {
// The full set of configuration options and their current values.
ConfigOptions []SessionConfigOption `json:"configOptions"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ConfigOptionUpdate Session configuration options have been updated.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is one bidirectional JSON-RPC connection. It routes incoming requests to registered handlers and correlates outgoing requests with their responses.
A single internal goroutine reads frames off r and dispatches them; Send calls made by that dispatch (auto-responses, and any handler's eventual response) and by callers of Call/Notify all funnel through the shared Writer, which already serializes concurrent writers onto w.
func NewConn ¶
NewConn wraps r and w as one JSON-RPC connection and starts its internal read loop. The returned Conn is ready for Handle/HandleNotify registration and for Call/Notify immediately.
func (*Conn) Call ¶
Call sends a JSON-RPC request for method with params (marshaled to JSON; may be nil), blocks until the correlated response arrives, decodes its result into result (if non-nil and the call succeeded), and returns any error. It mints the request id from Call's own id space (starting at 1<<32), disjoint from callExt's.
Call returns *ConnClosedError immediately if c is already closed, and every Call still blocked when c closes (for any reason) receives the same typed error. A canceled ctx unblocks Call with ctx.Err() and removes the pending entry; it never leaks.
func (*Conn) CallWithResult ¶
func (c *Conn) CallWithResult(ctx context.Context, method string, params, result any) (CallResult, error)
CallWithResult is Call's additive ordered form. It preserves the generic method-string primitive inside protocol while returning write-admission and inbound response sequence facts needed by typed extension callers.
func (*Conn) Close ¶
Close stops c from accepting further Call/Notify calls (which now fail fast with *ConnClosedError), fails every currently in-flight Call the same way, stops the internal writer, and closes the underlying reader and writer (whichever of them implement io.Closer) so the read loop's blocked Read unblocks and the peer observes our side going away. It waits for the read loop goroutine to fully exit before returning, but does not wait for any handler callback that is still running in user code — a slow or stuck handler cannot delay Close.
Close is idempotent and safe to call concurrently with itself or with any other Conn method.
func (*Conn) Done ¶
func (c *Conn) Done() <-chan struct{}
Done returns a channel that is closed once c has been (or is being) closed, whether by an explicit Close call or because reading from the peer failed.
func (*Conn) DroppedNotifications ¶
DroppedNotifications reports how many buffered early notifications have been dropped (oldest-first) across all methods due to NotifyBufferDepth overflow. Safe to call at any time, including after Close, and it reflects the final count once the Conn is closed.
func (*Conn) Handle ¶
func (c *Conn) Handle(method string, h HandlerFunc)
Handle registers h as the handler for incoming requests with the given method. A later call with the same method replaces the previous handler.
func (*Conn) HandleNotify ¶
func (c *Conn) HandleNotify(method string, h NotifyFunc)
HandleNotify registers h as the handler for incoming notifications with the given method, then enqueues — in arrival order — any notifications for that method that were buffered before this call (see NotifyBufferDepth) for ordered execution on the same dispatch worker that runs live notifications. HandleNotify does not block waiting for that flush to run; it only guarantees the flushed notifications are queued ahead of any live notification for method that could possibly be dispatched after this call returns.
The registration and the flush-enqueue happen under the same handlersMu critical section, which is what guarantees the ordering: dispatchNotification cannot observe the new handler (and thus cannot enqueue a live notification for method) until this call releases handlersMu, by which point every buffered notification for method has already been pushed onto the shared queue ahead of it.
func (*Conn) HandleNotifyWithSequence ¶
func (c *Conn) HandleNotifyWithSequence(method string, h NotifyWithSequenceFunc)
HandleNotifyWithSequence is HandleNotify's ordered form. The callback is invoked by the same single notification worker, with the receive sequence minted by Conn's read loop before enqueueing.
func (*Conn) HandleUnknownNotify ¶
func (c *Conn) HandleUnknownNotify(h NotifyFunc)
HandleUnknownNotify registers a catch-all handler invoked for any incoming notification whose method has no handler registered via HandleNotify. Once this hook is set, it takes priority over buffering: an unrecognized notification method is routed to it immediately rather than being held for a HandleNotify registration that (by design, once this hook exists) is presumed never coming for that method.
func (*Conn) HandleUnknownNotifyWithSequence ¶
func (c *Conn) HandleUnknownNotifyWithSequence(h NotifyWithSequenceFunc)
HandleUnknownNotifyWithSequence registers the ordered catch-all variant of HandleUnknownNotify. It is primarily useful to protocol adapters that need to observe extension notifications without opening a second reader.
func (*Conn) HandleUnknownRequest ¶
func (c *Conn) HandleUnknownRequest(h HandlerFunc)
HandleUnknownRequest registers a catch-all handler invoked for any incoming request whose method has no handler registered via Handle. This is meant for vendor/extension request methods (for example ACP's `_meta` passthrough) that this Conn does not know about by name.
func (*Conn) Notify ¶
Notify sends a JSON-RPC notification for method with params (marshaled to JSON; may be nil). It does not wait for anything: notifications have no response. Notify returns *ConnClosedError immediately if c is already closed.
func (*Conn) NotifyWithResult ¶
func (c *Conn) NotifyWithResult(ctx context.Context, method string, params any) (WriteResult, error)
NotifyWithResult is Notify's admission-aware form. Notifications have no inbound response sequence, so it returns only the writer fact.
func (*Conn) StartCall ¶
func (c *Conn) StartCall(ctx context.Context, method string, params, result any) (*CallHandle, error)
StartCall is Call's asynchronous form. It is primarily consumed by typed ACP extension wrappers that need Writer admission before the eventual response. The returned handle owns one pending entry and resolves it exactly once, even when cancellation races a response or connection shutdown.
func (*Conn) WaitForNotifications ¶
WaitForNotifications waits until all notification jobs enqueued before this call have finished executing in the Conn's ordered notification worker. It is cancellation-aware and returns *ConnClosedError if the Conn closes before the barrier reaches the worker. A caller should not invoke it from inside a notification handler, because that handler is itself ahead of the barrier.
func (*Conn) WaitForNotificationsThrough ¶
WaitForNotificationsThrough waits until Conn has observed receiveSequence and every notification at or before that sequence has completed its registered handler. It never reads from a Session.Updates channel; the client layer's session handler has already placed the update in its own queue by the time this barrier completes.
func (*Conn) WaitForReceiveSequence ¶
WaitForReceiveSequence is an additive name for WaitForNotificationsThrough. It is useful to callers that want to make clear that responses and notifications share one receive-order clock.
type ConnClosedError ¶
type ConnClosedError struct {
// contains filtered or unexported fields
}
ConnClosedError is returned by Call and Notify once a Conn has been (or is being) closed, and delivered to every Call that was still in flight at the moment of closing. Close may have been explicit (Conn.Close) or implicit (the peer went away, or a read off the transport failed); Unwrap exposes that cause for local diagnosis, but it is never sent to a peer.
func (*ConnClosedError) Error ¶
func (e *ConnClosedError) Error() string
func (*ConnClosedError) Unwrap ¶
func (e *ConnClosedError) Unwrap() error
Unwrap exposes the cause that led to closing, if any.
type ConnOptions ¶
type ConnOptions struct {
// ExtIDBase sets the starting id minted for extension-traffic calls (the
// id space used internally for outgoing calls other than the ones Call
// mints — see callExt). Zero means "use the default base of 1". This
// exists so a later typed layer can mint extension-traffic ids from a
// caller-chosen range without ever colliding with Call's id space, which
// always starts at 1<<32 regardless of this option.
ExtIDBase int64
}
ConnOptions configures a Conn constructed by NewConn.
type Content ¶
type Content struct {
// The actual content block.
Content ContentBlock `json:"content"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
Content Standard content block (text, images, resources).
type ContentBlock ¶
type ContentBlock struct {
// Text content. May be plain text or formatted with Markdown.
//
// All agents MUST support text content blocks in prompts.
// Clients SHOULD render this text as Markdown.
Text *TextContent `json:"-"`
// Images for visual context or analysis.
//
// Requires the `image` prompt capability when included in prompts.
Image *ImageContent `json:"-"`
// Audio data for transcription or analysis.
//
// Requires the `audio` prompt capability when included in prompts.
Audio *AudioContent `json:"-"`
// References to resources that the agent can access.
//
// All agents MUST support resource links in prompts.
ResourceLink *ResourceLink `json:"-"`
// Complete resource contents embedded directly in the message.
//
// Preferred for including context as it avoids extra round-trips.
//
// Requires the `embeddedContext` prompt capability when included in prompts.
Resource *EmbeddedResource `json:"-"`
}
ContentBlock Content blocks represent displayable information in the Agent Client Protocol.
They provide a structured way to handle various types of user-facing content—whether it's text from language models, images for analysis, or embedded resources for context.
Content blocks appear in: - User prompts sent via `session/prompt` - Language model output streamed through `session/update` notifications - Progress updates and results from tool calls
This structure is compatible with the Model Context Protocol (MCP), enabling agents to seamlessly forward content from MCP tool outputs without transformation.
See protocol docs: Content(https://agentclientprotocol.com/protocol/content)
func (ContentBlock) MarshalJSON ¶
func (v ContentBlock) MarshalJSON() ([]byte, error)
MarshalJSON flattens whichever ContentBlock variant is set, plus the "type" discriminator, into one JSON object. It fails if zero or more than one variant is set.
func (*ContentBlock) UnmarshalJSON ¶
func (v *ContentBlock) UnmarshalJSON(data []byte) error
UnmarshalJSON dispatches on the "type" discriminator. A missing or unrecognized value is rejected.
type ContentChunk ¶
type ContentChunk struct {
// A single item of content
Content ContentBlock `json:"content"`
// A unique identifier for the message this chunk belongs to.
//
// All chunks belonging to the same message share the same `messageId`.
// A change in `messageId` indicates a new message has started.
MessageID *MessageID `json:"messageId,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ContentChunk A streamed item of content
type Cost ¶
type Cost struct {
// Total cumulative cost for session.
Amount float64 `json:"amount"`
// ISO 4217 currency code (e.g., "USD", "EUR").
Currency string `json:"currency"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
Cost Cost information for a session.
type CreateTerminalRequest ¶
type CreateTerminalRequest struct {
// Array of command arguments.
Args []string `json:"args,omitempty"`
// The command to execute.
Command string `json:"command"`
// Working directory for the command. Must be an absolute path.
Cwd *string `json:"cwd,omitempty"`
// Environment variables for the command.
Env []EnvVariable `json:"env,omitempty"`
// Maximum number of output bytes to retain.
//
// When the limit is exceeded, the Client truncates from the beginning of the output
// to stay within the limit.
//
// The Client MUST ensure truncation happens at a character boundary to maintain valid
// string output, even if this means the retained output is slightly less than the
// specified limit.
OutputByteLimit *uint64 `json:"outputByteLimit,omitempty"`
// The session ID for this request.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
CreateTerminalRequest Request to create a new terminal and execute a command.
type CreateTerminalResponse ¶
type CreateTerminalResponse struct {
// The unique identifier for the created terminal.
TerminalID TerminalID `json:"terminalId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
CreateTerminalResponse Response containing the ID of the created terminal.
type CurrentModeUpdate ¶
type CurrentModeUpdate struct {
// The ID of the current mode
CurrentModeID SessionModeID `json:"currentModeId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
CurrentModeUpdate The current mode of the session has changed
See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
type DeleteSessionRequest ¶
type DeleteSessionRequest struct {
// The ID of the session to delete.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
DeleteSessionRequest Request parameters for deleting an existing session from `session/list`.
Only available if the Agent supports the `sessionCapabilities.delete` capability.
type DeleteSessionResponse ¶
type DeleteSessionResponse struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
DeleteSessionResponse Response from deleting a session.
type Diff ¶
type Diff struct {
// The new content after modification.
NewText string `json:"newText"`
// The original content (None for new files).
OldText *string `json:"oldText,omitempty"`
// The absolute file path being modified.
Path string `json:"path"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
Diff A diff representing file modifications.
Shows changes to files in a format suitable for display in the client UI.
See protocol docs: Content(https://agentclientprotocol.com/protocol/tool-calls#content)
type EmbeddedResource ¶
type EmbeddedResource struct {
// Optional annotations that help clients decide how to display or route this content.
Annotations *Annotations `json:"annotations,omitempty"`
// Embedded resource payload, either text or binary data.
Resource EmbeddedResourceResource `json:"resource"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
EmbeddedResource The contents of a resource, embedded into a prompt or tool call result.
type EmbeddedResourceResource ¶
type EmbeddedResourceResource struct {
// Text resource contents embedded directly in the message.
TextResourceContents *TextResourceContents `json:"-"`
// Binary resource contents embedded directly in the message.
BlobResourceContents *BlobResourceContents `json:"-"`
}
EmbeddedResourceResource Resource content that can be embedded in a message.
func (EmbeddedResourceResource) MarshalJSON ¶
func (v EmbeddedResourceResource) MarshalJSON() ([]byte, error)
MarshalJSON marshals whichever EmbeddedResourceResource variant is set. It fails if zero or more than one variant is set.
func (*EmbeddedResourceResource) UnmarshalJSON ¶
func (v *EmbeddedResourceResource) UnmarshalJSON(data []byte) error
UnmarshalJSON tells EmbeddedResourceResource's variants apart by which one's required fields are present on the wire object (this union has no discriminator tag).
type EnvVariable ¶
type EnvVariable struct {
// The name of the environment variable.
Name string `json:"name"`
// The value to set for the environment variable.
Value string `json:"value"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
EnvVariable An environment variable to set when launching an MCP server.
type Envelope ¶
type Envelope struct {
Request *Request
Response *Response
Notification *Notification
}
Envelope holds exactly one of Request, Response, or Notification, discriminated by Kind. It is the result of a successful ParseEnvelope.
func ParseEnvelope ¶
ParseEnvelope decodes untrusted wire bytes into an Envelope, or returns a *ValidationError describing every structural problem found. Size and nesting-depth guards run first, purely by streaming tokens, before any field value is unmarshaled.
type Error ¶
type Error struct {
// Code is the JSON-RPC error code. See the ErrorCode constants in
// types_gen.go (generated from the pinned schema's ErrorCode $def).
Code ErrorCode `json:"code"`
// Message is a short, single-sentence description of the error.
Message string `json:"message"`
// Data is optional, caller-whitelisted additional context. It is never
// populated automatically from an internal cause.
Data json.RawMessage `json:"data,omitempty"`
}
Error is the JSON-RPC 2.0 error object shape (the "Error" $def excluded from generation in internal/gen/model.go — it collides in spirit with Go's builtin error and is owned here instead). It is the wire representation carried in Response.Error: exactly the bytes that cross the process boundary, nothing more.
Error deliberately holds no cause chain: Data is the only channel for additional context, and it is populated exclusively by Fault.WithData, so whatever a Fault's internal cause was, it never reaches the wire unless a caller explicitly whitelists it into Data.
func ToWireError ¶
ToWireError converts a local Fault into the wire Error object sent to a peer. Only Code, Message, and whitelisted Data cross this boundary; any internal cause on f is intentionally dropped.
type ErrorCode ¶
type ErrorCode int32
ErrorCode Predefined error codes for common JSON-RPC and ACP-specific errors.
These codes follow the JSON-RPC 2.0 specification for standard errors and use the reserved range (-32000 to -32099) for protocol-specific errors.
const ( // **Parse error**: Invalid JSON was received by the server. // An error occurred on the server while parsing the JSON text. ErrorCodeParseError ErrorCode = -32700 // **Invalid request**: The JSON sent is not a valid Request object. ErrorCodeInvalidRequest ErrorCode = -32600 // **Method not found**: The method does not exist or is not available. ErrorCodeMethodNotFound ErrorCode = -32601 // **Invalid params**: Invalid method parameter(s). ErrorCodeInvalidParams ErrorCode = -32602 // **Internal error**: Internal JSON-RPC error. // Reserved for implementation-defined server errors. ErrorCodeInternalError ErrorCode = -32603 // **Request cancelled**: Execution of the method was aborted either due to a cancellation request from the caller or // because of resource constraints or shutdown. ErrorCodeRequestCancelled ErrorCode = -32800 // **Authentication required**: Authentication is required before this operation can be performed. ErrorCodeAuthenticationRequired ErrorCode = -32000 // **Resource not found**: A given resource, such as a file, was not found. ErrorCodeResourceNotFound ErrorCode = -32002 )
type Fault ¶
type Fault struct {
Code ErrorCode
Message string
Data json.RawMessage
// contains filtered or unexported fields
}
Fault is the internal, typed representation of a JSON-RPC failure. Unlike Error, it may wrap an internal cause (a filesystem error, a decode error, etc.) for local diagnosis via errors.Is/errors.As/errors.Unwrap. That cause is never sent over the wire: ToWireError only ever copies Code, Message, and whatever the caller explicitly attached via WithData.
func AuthRequired ¶
AuthRequired constructs the ACP-specific "authentication is required before this operation can be performed" fault (code -32000).
func FromWireError ¶
FromWireError reconstructs a local Fault from a wire Error object received from a peer. The result never has a local cause: the wire never carried one, so none is fabricated.
func InternalError ¶
InternalError constructs the standard JSON-RPC "internal JSON-RPC error" fault (code -32603).
func InvalidParams ¶
InvalidParams constructs the standard JSON-RPC "invalid method parameter(s)" fault (code -32602).
func InvalidRequest ¶
InvalidRequest constructs the standard JSON-RPC "the JSON sent is not a valid Request object" fault (code -32600).
func MethodNotFound ¶
MethodNotFound constructs the standard JSON-RPC "method does not exist or is not available" fault (code -32601).
func ParseError ¶
ParseError constructs the standard JSON-RPC "invalid JSON was received" fault (code -32700).
func ResourceNotFound ¶
ResourceNotFound constructs the ACP-specific "a given resource, such as a file, was not found" fault (code -32002).
func (*Fault) Error ¶
Error implements the built-in error interface. Unlike the wire Error type, this may include cause detail — it is for local logs/diagnostics, never serialized to a peer.
func (*Fault) Unwrap ¶
Unwrap exposes the typed internal cause, if any, to errors.Is/errors.As. The cause is local-only: it is never included in ToWireError's output.
func (*Fault) WithData ¶
WithData attaches caller-whitelisted, JSON-serializable context that IS safe to send to a peer. It marshals v immediately (rather than storing an `any`) so Fault only ever carries wire-safe bytes beyond this boundary call. A marshal failure is dropped silently in favor of sending no data at all, rather than failing the whole fault construction over optional context.
type FileSystemCapabilities ¶
type FileSystemCapabilities struct {
// Whether the Client supports `fs/read_text_file` requests.
ReadTextFile bool `json:"readTextFile,omitempty"`
// Whether the Client supports `fs/write_text_file` requests.
WriteTextFile bool `json:"writeTextFile,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
FileSystemCapabilities File system capabilities that a client may support.
See protocol docs: [FileSystem](https://agentclientprotocol.com/protocol/initialization#filesystem)
func DefaultFileSystemCapabilities ¶
func DefaultFileSystemCapabilities() FileSystemCapabilities
DefaultFileSystemCapabilities returns FileSystemCapabilities with every schema-declared default applied.
type FrameReader ¶
type FrameReader struct {
// contains filtered or unexported fields
}
FrameReader reads newline-delimited frames from an underlying io.Reader. Each frame is one line with its trailing "\n" (and an optional preceding "\r", tolerating CRLF line endings) removed. It is not safe for concurrent use: a FrameReader is meant to be owned by a single reader loop, mirroring how Writer is the single-writer counterpart for output.
func NewFrameReader ¶
func NewFrameReader(r io.Reader) *FrameReader
NewFrameReader wraps r for frame-at-a-time reading.
func (*FrameReader) ReadFrame ¶
func (fr *FrameReader) ReadFrame() ([]byte, error)
ReadFrame returns the next frame's content, with its line terminator stripped. It returns io.EOF (via errors.Is) when the stream ends cleanly at a frame boundary, *TruncatedFrameError when the stream ends mid-line, *FrameTooLargeError when a line exceeds MaxMessageBytes before a terminator is found, and *InvalidFrameError when the frame contains an embedded NUL byte.
type FrameTooLargeError ¶
type FrameTooLargeError struct {
// Limit is the byte limit that was exceeded (always MaxMessageBytes).
Limit int
}
FrameTooLargeError reports that a single line exceeded MaxMessageBytes before a terminating newline was found.
func (*FrameTooLargeError) Error ¶
func (e *FrameTooLargeError) Error() string
type HTTPHeader ¶
type HTTPHeader struct {
// The name of the HTTP header.
Name string `json:"name"`
// The value to set for the HTTP header.
Value string `json:"value"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
HTTPHeader An HTTP header to set when making requests to the MCP server.
type HandlerFunc ¶
HandlerFunc handles one incoming JSON-RPC request and returns the value to send back as the response result, or an error. If err is (or wraps) a *Fault, its Code/Message/Data are sent to the peer via ToWireError; any other error is reported to the peer as InternalError, with the original error kept only for local diagnosis (never sent on the wire).
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID is a JSON-RPC request id: a string-or-number sum type, never null or any other JSON type. Use NewStringID or NewNumberID to construct one, and String or Number to inspect it.
func (ID) MarshalJSON ¶
MarshalJSON encodes id as a bare JSON string or number, matching how a JSON-RPC id is carried on the wire.
type ImageContent ¶
type ImageContent struct {
// Optional annotations that help clients decide how to display or route this content.
Annotations *Annotations `json:"annotations,omitempty"`
// Base64-encoded media payload.
Data string `json:"data"`
// MIME type describing the encoded media payload.
MimeType string `json:"mimeType"`
// URI associated with this resource or media payload.
URI *string `json:"uri,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ImageContent An image provided to or from an LLM.
type Implementation ¶
type Implementation struct {
// Intended for programmatic or logical use, but can be used as a display
// name fallback if title isn’t present.
Name string `json:"name"`
// Intended for UI and end-user contexts — optimized to be human-readable
// and easily understood.
//
// If not provided, the name should be used for display.
Title *string `json:"title,omitempty"`
// Version of the implementation. Can be displayed to the user or used
// for debugging or metrics purposes. (e.g. "1.0.0").
Version string `json:"version"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
Implementation Metadata about the implementation of the client or agent. Describes the name and version of an ACP implementation, with an optional title for UI representation.
type InitializeRequest ¶
type InitializeRequest struct {
// Capabilities supported by the client.
ClientCapabilities *ClientCapabilities `json:"clientCapabilities,omitempty"`
// Information about the Client name and version sent to the Agent.
//
// Note: in future versions of the protocol, this will be required.
ClientInfo *Implementation `json:"clientInfo,omitempty"`
// The latest protocol version supported by the client.
ProtocolVersion ProtocolVersion `json:"protocolVersion"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
InitializeRequest Request parameters for the initialize method.
Sent by the client to establish connection and negotiate capabilities.
See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
type InitializeResponse ¶
type InitializeResponse struct {
// Capabilities supported by the agent.
AgentCapabilities *AgentCapabilities `json:"agentCapabilities,omitempty"`
// Information about the Agent name and version sent to the Client.
//
// Note: in future versions of the protocol, this will be required.
AgentInfo *Implementation `json:"agentInfo,omitempty"`
// Authentication methods supported by the agent.
AuthMethods []AuthMethod `json:"authMethods,omitempty"`
// The protocol version the client specified if supported by the agent,
// or the latest protocol version supported by the agent.
//
// The client should disconnect, if it doesn't support this version.
ProtocolVersion ProtocolVersion `json:"protocolVersion"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
InitializeResponse Response to the `initialize` method.
Contains the negotiated protocol version and agent capabilities.
See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
type InvalidFrameError ¶
type InvalidFrameError struct {
Reason string
}
InvalidFrameError reports a frame that violated a structural framing rule other than size or truncation. Currently the only such rule is: a frame may never contain an embedded NUL byte, since one can never appear in valid JSON text and typically indicates a desynchronized or corrupted stream.
func (*InvalidFrameError) Error ¶
func (e *InvalidFrameError) Error() string
type Issue ¶
type Issue struct {
Kind IssueKind
}
Issue is one validation problem found while decoding an envelope.
type IssueKind ¶
type IssueKind string
IssueKind names one specific way a decoded JSON-RPC envelope failed validation. Kinds are named, not free-form text, so diagnostics stay compact and never need to embed the payload that produced them.
const ( IssueOversizedPayload IssueKind = "oversized_payload" IssueExcessiveNesting IssueKind = "excessive_nesting" IssueMalformedJSON IssueKind = "malformed_json" IssueNotAnObject IssueKind = "not_an_object" IssueTrailingData IssueKind = "trailing_data" IssueDuplicateField IssueKind = "duplicate_field" IssueUnknownField IssueKind = "unknown_field" IssueWrongVersion IssueKind = "wrong_jsonrpc_version" IssueInvalidIDType IssueKind = "invalid_id_type" IssueMissingID IssueKind = "missing_id" IssueInvalidMethodType IssueKind = "invalid_method_type" IssueMalformedErrorObj IssueKind = "malformed_error_object" IssueBothResultAndError IssueKind = "result_and_error_both_set" IssueAmbiguousShape IssueKind = "ambiguous_message_shape" )
type KillTerminalRequest ¶
type KillTerminalRequest struct {
// The session ID for this request.
SessionID SessionID `json:"sessionId"`
// The ID of the terminal to kill.
TerminalID TerminalID `json:"terminalId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
KillTerminalRequest Request to kill a terminal without releasing it.
type KillTerminalResponse ¶
type KillTerminalResponse struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
KillTerminalResponse Response to `terminal/kill` method
type Kind ¶
type Kind uint8
Kind identifies which of the three JSON-RPC message shapes an Envelope holds.
type ListSessionsRequest ¶
type ListSessionsRequest struct {
// Opaque cursor token from a previous response's nextCursor field for cursor-based pagination
Cursor *string `json:"cursor,omitempty"`
// Filter sessions by working directory. Must be an absolute path.
Cwd *string `json:"cwd,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ListSessionsRequest Request parameters for listing existing sessions.
Only available if the Agent supports the `sessionCapabilities.list` capability.
type ListSessionsResponse ¶
type ListSessionsResponse struct {
// Opaque cursor token. If present, pass this in the next request's cursor parameter
// to fetch the next page. If absent, there are no more results.
NextCursor *string `json:"nextCursor,omitempty"`
// Array of session information objects
Sessions []SessionInfo `json:"sessions"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ListSessionsResponse Response from listing sessions.
type LoadSessionRequest ¶
type LoadSessionRequest struct {
// Additional workspace roots to activate for this session. Each path must be absolute.
//
// When omitted or empty, no additional roots are activated. When non-empty,
// this is the complete resulting additional-root list for the loaded
// session. It may differ from any previously used or reported list as long as
// the request `cwd` matches the session's `cwd`.
AdditionalDirectories []string `json:"additionalDirectories,omitempty"`
// The working directory for this session. Must be an absolute path.
Cwd string `json:"cwd"`
// List of MCP servers to connect to for this session.
McpServers []McpServer `json:"mcpServers"`
// The ID of the session to load.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
LoadSessionRequest Request parameters for loading an existing session.
Only available if the Agent supports the `loadSession` capability.
See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)
type LoadSessionResponse ¶
type LoadSessionResponse struct {
// Initial session configuration options if supported by the Agent.
ConfigOptions []SessionConfigOption `json:"configOptions,omitempty"`
// Initial mode state if supported by the Agent
//
// See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
Modes *SessionModeState `json:"modes,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
LoadSessionResponse Response from loading an existing session.
type LogoutCapabilities ¶
type LogoutCapabilities struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
LogoutCapabilities Logout capabilities supported by the agent.
Supplying `{}` means the agent supports the logout method.
type LogoutRequest ¶
type LogoutRequest struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
LogoutRequest Request parameters for the logout method.
Terminates the current authenticated session.
type LogoutResponse ¶
type LogoutResponse struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
LogoutResponse Response to the `logout` method.
type McpCapabilities ¶
type McpCapabilities struct {
// Agent supports [`McpServer::Http`].
HTTP bool `json:"http,omitempty"`
// Agent supports [`McpServer::Sse`].
Sse bool `json:"sse,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
McpCapabilities MCP capabilities supported by the agent
func DefaultMcpCapabilities ¶
func DefaultMcpCapabilities() McpCapabilities
DefaultMcpCapabilities returns McpCapabilities with every schema-declared default applied.
type McpServer ¶
type McpServer struct {
// HTTP transport configuration
//
// Only available when the Agent capabilities indicate `mcp_capabilities.http` is `true`.
HTTP *McpServerHTTP `json:"-"`
// SSE transport configuration
//
// Only available when the Agent capabilities indicate `mcp_capabilities.sse` is `true`.
Sse *McpServerSse `json:"-"`
// Stdio transport configuration
//
// All Agents MUST support this transport.
Stdio *McpServerStdio `json:"-"`
}
McpServer Configuration for connecting to an MCP (Model Context Protocol) server.
MCP servers provide tools and context that the agent can use when processing prompts.
See protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers)
func (McpServer) MarshalJSON ¶
MarshalJSON flattens whichever McpServer variant is set, plus the "type" discriminator, into one JSON object. It fails if zero or more than one variant is set.
func (*McpServer) UnmarshalJSON ¶
UnmarshalJSON dispatches on the "type" discriminator. A missing or unrecognized value falls back to Stdio, matching the pinned schema.
type McpServerHTTP ¶
type McpServerHTTP struct {
// HTTP headers to set when making requests to the MCP server.
Headers []HTTPHeader `json:"headers"`
// Human-readable name identifying this MCP server.
Name string `json:"name"`
// URL to the MCP server.
URL string `json:"url"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
McpServerHTTP HTTP transport configuration for MCP.
type McpServerSse ¶
type McpServerSse struct {
// HTTP headers to set when making requests to the MCP server.
Headers []HTTPHeader `json:"headers"`
// Human-readable name identifying this MCP server.
Name string `json:"name"`
// URL to the MCP server.
URL string `json:"url"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
McpServerSse SSE transport configuration for MCP.
type McpServerStdio ¶
type McpServerStdio struct {
// Command-line arguments to pass to the MCP server.
Args []string `json:"args"`
// Absolute path to the MCP server executable.
Command string `json:"command"`
// Environment variables to set when launching the MCP server.
Env []EnvVariable `json:"env"`
// Human-readable name identifying this MCP server.
Name string `json:"name"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
McpServerStdio Stdio transport configuration for MCP.
type Method ¶
type Method string
Method is a JSON-RPC method name used by the Agent Client Protocol.
const ( MethodAuthenticate Method = "authenticate" MethodInitialize Method = "initialize" MethodLogout Method = "logout" MethodSessionCancel Method = "session/cancel" MethodSessionClose Method = "session/close" MethodSessionDelete Method = "session/delete" MethodSessionList Method = "session/list" MethodSessionLoad Method = "session/load" MethodSessionNew Method = "session/new" MethodSessionPrompt Method = "session/prompt" MethodSessionResume Method = "session/resume" MethodSessionSetConfigOption Method = "session/set_config_option" MethodSessionSetMode Method = "session/set_mode" )
agent-bound (client calls, agent implements) methods.
const ( MethodFsReadTextFile Method = "fs/read_text_file" MethodFsWriteTextFile Method = "fs/write_text_file" MethodSessionRequestPermission Method = "session/request_permission" MethodSessionUpdate Method = "session/update" MethodTerminalCreate Method = "terminal/create" MethodTerminalKill Method = "terminal/kill" MethodTerminalOutput Method = "terminal/output" MethodTerminalRelease Method = "terminal/release" MethodTerminalWaitForExit Method = "terminal/wait_for_exit" )
client-bound (agent calls, client implements) methods.
const (
MethodCancelRequest Method = "$/cancel_request"
)
protocol-level (either side may send; '$/' prefixed) methods.
type NewSessionRequest ¶
type NewSessionRequest struct {
// Additional workspace roots for this session. Each path must be absolute.
//
// These expand the session's filesystem scope without changing `cwd`, which
// remains the base for relative paths. When omitted or empty, no
// additional roots are activated for the new session.
AdditionalDirectories []string `json:"additionalDirectories,omitempty"`
// The working directory for this session. Must be an absolute path.
Cwd string `json:"cwd"`
// List of MCP (Model Context Protocol) servers the agent should connect to.
McpServers []McpServer `json:"mcpServers"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
NewSessionRequest Request parameters for creating a new session.
See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)
type NewSessionResponse ¶
type NewSessionResponse struct {
// Initial session configuration options if supported by the Agent.
ConfigOptions []SessionConfigOption `json:"configOptions,omitempty"`
// Initial mode state if supported by the Agent
//
// See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
Modes *SessionModeState `json:"modes,omitempty"`
// Unique identifier for the created session.
//
// Used in all subsequent requests for this conversation.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
NewSessionResponse Response from creating a new session.
See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)
type Notification ¶
type Notification struct {
Method string
Params json.RawMessage
// ReceiveSequence is stamped only on inbound notifications by Conn's
// single read loop and is never serialized onto the wire.
ReceiveSequence uint64
}
Notification is a JSON-RPC 2.0 notification: a method call with no id. Its wire struct has no id field at all, so a Notification can never encode one — the "empty id" form is only ever something ParseEnvelope accepts and canonicalizes away on input, never something this module emits.
func (*Notification) MarshalJSON ¶
func (n *Notification) MarshalJSON() ([]byte, error)
MarshalJSON encodes n as a "jsonrpc":"2.0" notification object.
type NotifyFunc ¶
type NotifyFunc func(ctx context.Context, method string, params json.RawMessage)
NotifyFunc handles one incoming JSON-RPC notification. It has no result: notifications never receive a response.
type NotifyWithSequenceFunc ¶
type NotifyWithSequenceFunc func(ctx context.Context, method string, params json.RawMessage, receiveSequence uint64)
NotifyWithSequenceFunc is the ordered form of NotifyFunc. The receive sequence is minted by Conn's single read loop before the notification is queued, so a handler can correlate its delivery with a response without creating another reader or racing a second dispatch path.
type PermissionOption ¶
type PermissionOption struct {
// Hint about the nature of this permission option.
Kind PermissionOptionKind `json:"kind"`
// Human-readable label to display to the user.
Name string `json:"name"`
// Unique identifier for this permission option.
OptionID PermissionOptionID `json:"optionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
PermissionOption An option presented to the user when requesting permission.
type PermissionOptionID ¶
type PermissionOptionID string
PermissionOptionID Unique identifier for a permission option.
type PermissionOptionKind ¶
type PermissionOptionKind string
PermissionOptionKind The type of permission option being presented to the user.
Helps clients choose appropriate icons and UI treatment.
const ( // Allow this operation only this time. PermissionOptionKindAllowOnce PermissionOptionKind = "allow_once" // Allow this operation and remember the choice. PermissionOptionKindAllowAlways PermissionOptionKind = "allow_always" // Reject this operation only this time. PermissionOptionKindRejectOnce PermissionOptionKind = "reject_once" // Reject this operation and remember the choice. PermissionOptionKindRejectAlways PermissionOptionKind = "reject_always" )
func (*PermissionOptionKind) UnmarshalJSON ¶
func (v *PermissionOptionKind) UnmarshalJSON(data []byte) error
UnmarshalJSON rejects any PermissionOptionKind value that is not one of the named PermissionOptionKind constants: this enum is closed in the pinned schema.
type Plan ¶
type Plan struct {
// The list of tasks to be accomplished.
//
// When updating a plan, the agent must send a complete list of all entries
// with their current status. The client replaces the entire plan with each update.
Entries []PlanEntry `json:"entries"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
Plan An execution plan for accomplishing complex tasks.
Plans consist of multiple entries representing individual tasks or goals. Agents report plans to clients to provide visibility into their execution strategy. Plans can evolve during execution as the agent discovers new requirements or completes tasks.
See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)
type PlanEntry ¶
type PlanEntry struct {
// Human-readable description of what this task aims to accomplish.
Content string `json:"content"`
// The relative importance of this task.
// Used to indicate which tasks are most critical to the overall goal.
Priority PlanEntryPriority `json:"priority"`
// Current execution status of this task.
Status PlanEntryStatus `json:"status"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
PlanEntry A single entry in the execution plan.
Represents a task or goal that the assistant intends to accomplish as part of fulfilling the user's request. See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
type PlanEntryPriority ¶
type PlanEntryPriority string
PlanEntryPriority Priority levels for plan entries.
Used to indicate the relative importance or urgency of different tasks in the execution plan. See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
const ( // High priority task - critical to the overall goal. PlanEntryPriorityHigh PlanEntryPriority = "high" // Medium priority task - important but not critical. PlanEntryPriorityMedium PlanEntryPriority = "medium" // Low priority task - nice to have but not essential. PlanEntryPriorityLow PlanEntryPriority = "low" )
func (*PlanEntryPriority) UnmarshalJSON ¶
func (v *PlanEntryPriority) UnmarshalJSON(data []byte) error
UnmarshalJSON rejects any PlanEntryPriority value that is not one of the named PlanEntryPriority constants: this enum is closed in the pinned schema.
type PlanEntryStatus ¶
type PlanEntryStatus string
PlanEntryStatus Status of a plan entry in the execution flow.
Tracks the lifecycle of each task from planning through completion. See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
const ( // The task has not started yet. PlanEntryStatusPending PlanEntryStatus = "pending" // The task is currently being worked on. PlanEntryStatusInProgress PlanEntryStatus = "in_progress" // The task has been successfully completed. PlanEntryStatusCompleted PlanEntryStatus = "completed" )
func (*PlanEntryStatus) UnmarshalJSON ¶
func (v *PlanEntryStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON rejects any PlanEntryStatus value that is not one of the named PlanEntryStatus constants: this enum is closed in the pinned schema.
type PromptCapabilities ¶
type PromptCapabilities struct {
// Agent supports [`ContentBlock::Audio`].
Audio bool `json:"audio,omitempty"`
// Agent supports embedded context in `session/prompt` requests.
//
// When enabled, the Client is allowed to include [`ContentBlock::Resource`]
// in prompt requests for pieces of context that are referenced in the message.
EmbeddedContext bool `json:"embeddedContext,omitempty"`
// Agent supports [`ContentBlock::Image`].
Image bool `json:"image,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
PromptCapabilities Prompt capabilities supported by the agent in `session/prompt` requests.
Baseline agent functionality requires support for [`ContentBlock::Text`] and [`ContentBlock::ResourceLink`] in prompt requests.
Other variants must be explicitly opted in to. Capabilities for different types of content in prompt requests.
Indicates which content types beyond the baseline (text and resource links) the agent can process.
See protocol docs: [Prompt Capabilities](https://agentclientprotocol.com/protocol/initialization#prompt-capabilities)
func DefaultPromptCapabilities ¶
func DefaultPromptCapabilities() PromptCapabilities
DefaultPromptCapabilities returns PromptCapabilities with every schema-declared default applied.
type PromptRequest ¶
type PromptRequest struct {
// The blocks of content that compose the user's message.
//
// As a baseline, the Agent MUST support [`ContentBlock::Text`] and [`ContentBlock::ResourceLink`],
// while other variants are optionally enabled via [`PromptCapabilities`].
//
// The Client MUST adapt its interface according to [`PromptCapabilities`].
//
// The client MAY include referenced pieces of context as either
// [`ContentBlock::Resource`] or [`ContentBlock::ResourceLink`].
//
// When available, [`ContentBlock::Resource`] is preferred
// as it avoids extra round-trips and allows the message to include
// pieces of context from sources the agent may not have access to.
Prompt []ContentBlock `json:"prompt"`
// The ID of the session to send this user message to
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
PromptRequest Request parameters for sending a user prompt to the agent.
Contains the user's message and any additional context.
See protocol docs: [User Message](https://agentclientprotocol.com/protocol/prompt-turn#1-user-message)
type PromptResponse ¶
type PromptResponse struct {
// Indicates why the agent stopped processing the turn.
StopReason StopReason `json:"stopReason"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
PromptResponse Response from processing a user prompt.
See protocol docs: [Check for Completion](https://agentclientprotocol.com/protocol/prompt-turn#4-check-for-completion)
type ProtocolVersion ¶
type ProtocolVersion uint16
ProtocolVersion Protocol version identifier.
This version is only bumped for breaking changes. Non-breaking changes should be introduced via capabilities.
const CurrentProtocolVersion ProtocolVersion = 1
CurrentProtocolVersion is the wire protocol version this module speaks, pinned from the schema's own "version" field (see protocol/schema/v1/REVISION).
type ReadTextFileRequest ¶
type ReadTextFileRequest struct {
// Maximum number of lines to read.
Limit *uint32 `json:"limit,omitempty"`
// Line number to start reading from (1-based).
Line *uint32 `json:"line,omitempty"`
// Absolute path to the file to read.
Path string `json:"path"`
// The session ID for this request.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ReadTextFileRequest Request to read content from a text file.
Only available if the client supports the `fs.readTextFile` capability.
type ReadTextFileResponse ¶
type ReadTextFileResponse struct {
// Content payload returned by this response.
Content string `json:"content"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ReadTextFileResponse Response containing the contents of a text file.
type ReceiveSequenceOverflowError ¶
type ReceiveSequenceOverflowError struct{}
ReceiveSequenceOverflowError reports that Conn exhausted its monotonic receive-sequence space. Conn fails closed before dispatching that inbound observation, so sequence zero remains reserved as the "not observed" sentinel and is never emitted on a response or notification.
func (*ReceiveSequenceOverflowError) Error ¶
func (e *ReceiveSequenceOverflowError) Error() string
type ReleaseTerminalRequest ¶
type ReleaseTerminalRequest struct {
// The session ID for this request.
SessionID SessionID `json:"sessionId"`
// The ID of the terminal to release.
TerminalID TerminalID `json:"terminalId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ReleaseTerminalRequest Request to release a terminal and free its resources.
type ReleaseTerminalResponse ¶
type ReleaseTerminalResponse struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ReleaseTerminalResponse Response to terminal/release method
type Request ¶
type Request struct {
ID ID
Method string
Params json.RawMessage
}
Request is a JSON-RPC 2.0 request object.
func (*Request) MarshalJSON ¶
MarshalJSON encodes r as a "jsonrpc":"2.0" request object.
type RequestPermissionOutcome ¶
type RequestPermissionOutcome struct {
// The prompt turn was cancelled before the user responded.
//
// When a client sends a `session/cancel` notification to cancel an ongoing
// prompt turn, it MUST respond to all pending `session/request_permission`
// requests with this `Cancelled` outcome.
//
// See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
Cancelled *struct{} `json:"-"`
// The user selected one of the provided options.
Selected *SelectedPermissionOutcome `json:"-"`
}
RequestPermissionOutcome The outcome of a permission request.
func (RequestPermissionOutcome) MarshalJSON ¶
func (v RequestPermissionOutcome) MarshalJSON() ([]byte, error)
MarshalJSON flattens whichever RequestPermissionOutcome variant is set, plus the "outcome" discriminator, into one JSON object. It fails if zero or more than one variant is set.
func (*RequestPermissionOutcome) UnmarshalJSON ¶
func (v *RequestPermissionOutcome) UnmarshalJSON(data []byte) error
UnmarshalJSON dispatches on the "outcome" discriminator. A missing or unrecognized value is rejected.
type RequestPermissionRequest ¶
type RequestPermissionRequest struct {
// Available permission options for the user to choose from.
Options []PermissionOption `json:"options"`
// The session ID for this request.
SessionID SessionID `json:"sessionId"`
// Details about the tool call requiring permission.
ToolCall ToolCallUpdate `json:"toolCall"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
RequestPermissionRequest Request for user permission to execute a tool call.
Sent when the agent needs authorization before performing a sensitive operation.
See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)
type RequestPermissionResponse ¶
type RequestPermissionResponse struct {
// The user's decision on the permission request.
Outcome RequestPermissionOutcome `json:"outcome"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
RequestPermissionResponse Response to a permission request.
type ResourceLink ¶
type ResourceLink struct {
// Optional annotations that help clients decide how to display or route this content.
Annotations *Annotations `json:"annotations,omitempty"`
// Optional human-readable details shown with this protocol object.
Description *string `json:"description,omitempty"`
// MIME type describing the encoded media payload.
MimeType *string `json:"mimeType,omitempty"`
// Human-readable name shown for this protocol object.
Name string `json:"name"`
// Optional size of the linked resource in bytes, if known.
Size *int64 `json:"size,omitempty"`
// Optional display title for end-user UI.
Title *string `json:"title,omitempty"`
// URI associated with this resource or media payload.
URI string `json:"uri"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ResourceLink A resource that the server is capable of reading, included in a prompt or tool call result.
type Response ¶
type Response struct {
ID ID
Result json.RawMessage
Error *Error
// ReceiveSequence is stamped only on inbound responses by Conn's single
// read loop. It is intentionally omitted from JSON-RPC marshaling: this is
// a local observation fact, never wire data.
ReceiveSequence uint64
}
Response is a JSON-RPC 2.0 response object: exactly one of Result or Error is set.
func (*Response) MarshalJSON ¶
MarshalJSON encodes r as a "jsonrpc":"2.0" response object.
type ResumeSessionRequest ¶
type ResumeSessionRequest struct {
// Additional workspace roots to activate for this session. Each path must be absolute.
//
// When omitted or empty, no additional roots are activated. When non-empty,
// this is the complete resulting additional-root list for the resumed
// session. It may differ from any previously used or reported list as long as
// the request `cwd` matches the session's `cwd`.
AdditionalDirectories []string `json:"additionalDirectories,omitempty"`
// The working directory for this session. Must be an absolute path.
Cwd string `json:"cwd"`
// List of MCP servers to connect to for this session.
McpServers []McpServer `json:"mcpServers,omitempty"`
// The ID of the session to resume.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ResumeSessionRequest Request parameters for resuming an existing session.
Resumes an existing session without returning previous messages (unlike `session/load`). This is useful for agents that can resume sessions but don't implement full session loading.
Only available if the Agent supports the `sessionCapabilities.resume` capability.
type ResumeSessionResponse ¶
type ResumeSessionResponse struct {
// Initial session configuration options if supported by the Agent.
ConfigOptions []SessionConfigOption `json:"configOptions,omitempty"`
// Initial mode state if supported by the Agent
//
// See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
Modes *SessionModeState `json:"modes,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ResumeSessionResponse Response from resuming an existing session.
type Role ¶
type Role string
Role The sender or recipient of messages and data in a conversation.
func (*Role) UnmarshalJSON ¶
UnmarshalJSON rejects any Role value that is not one of the named Role constants: this enum is closed in the pinned schema.
type SelectedPermissionOutcome ¶
type SelectedPermissionOutcome struct {
// The ID of the option the user selected.
OptionID PermissionOptionID `json:"optionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SelectedPermissionOutcome The user selected one of the provided options.
type SendResult ¶
type SendResult = WriteResult
SendResult is an additive spelling for callers that think in terms of the Writer's Send operation rather than the underlying write. It is an alias so both names describe exactly the same admission fact.
type SessionAdditionalDirectoriesCapabilities ¶
type SessionAdditionalDirectoriesCapabilities struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionAdditionalDirectoriesCapabilities Capabilities for additional session directories support.
Supplying `{}` means the agent supports the `additionalDirectories` field on supported session lifecycle requests. Agents that also support `session/list` may return `SessionInfo.additionalDirectories` to report the complete ordered additional-root list associated with a listed session.
type SessionCapabilities ¶
type SessionCapabilities struct {
// Whether the agent supports `additionalDirectories` on supported session lifecycle requests.
//
// Optional. Omitted or `null` both mean the agent does not advertise support.
// Supplying `{}` means the agent supports `additionalDirectories` on
// supported session lifecycle requests.
//
// Agents that also support `session/list` may return
// `SessionInfo.additionalDirectories` to report the complete ordered
// additional-root list associated with a listed session.
AdditionalDirectories *SessionAdditionalDirectoriesCapabilities `json:"additionalDirectories,omitempty"`
// Whether the agent supports `session/close`.
//
// Optional. Omitted or `null` both mean the agent does not advertise support.
// Supplying `{}` means the agent supports closing sessions.
Close *SessionCloseCapabilities `json:"close,omitempty"`
// Whether the agent supports `session/delete`.
//
// Optional. Omitted or `null` both mean the agent does not advertise support.
// Supplying `{}` means the agent supports deleting sessions from `session/list`.
Delete *SessionDeleteCapabilities `json:"delete,omitempty"`
// Whether the agent supports `session/list`.
//
// Optional. Omitted or `null` both mean the agent does not advertise support.
// Supplying `{}` means the agent supports listing sessions.
List *SessionListCapabilities `json:"list,omitempty"`
// Whether the agent supports `session/resume`.
//
// Optional. Omitted or `null` both mean the agent does not advertise support.
// Supplying `{}` means the agent supports resuming sessions.
Resume *SessionResumeCapabilities `json:"resume,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionCapabilities Session capabilities supported by the agent.
As a baseline, all Agents **MUST** support `session/new`, `session/prompt`, `session/cancel`, and `session/update`.
Optionally, they **MAY** support other session methods and notifications by specifying additional capabilities.
Note: `session/load` is still handled by the top-level `load_session` capability. This will be unified in future versions of the protocol.
See protocol docs: [Session Capabilities](https://agentclientprotocol.com/protocol/initialization#session-capabilities)
type SessionCloseCapabilities ¶
type SessionCloseCapabilities struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionCloseCapabilities Capabilities for the `session/close` method.
Supplying `{}` means the agent supports closing sessions.
type SessionConfigBoolean ¶
type SessionConfigBoolean struct {
// The current value of the boolean option.
CurrentValue bool `json:"currentValue"`
}
SessionConfigBoolean A boolean on/off toggle session configuration option payload.
type SessionConfigGroupID ¶
type SessionConfigGroupID string
SessionConfigGroupID Unique identifier for a session configuration option value group.
type SessionConfigID ¶
type SessionConfigID string
SessionConfigID Unique identifier for a session configuration option.
type SessionConfigOption ¶
type SessionConfigOption struct {
// Optional semantic category for this option (UX only).
Category *SessionConfigOptionCategory `json:"category,omitempty"`
// Optional description for the Client to display to the user.
Description *string `json:"description,omitempty"`
// Unique identifier for the configuration option.
ID SessionConfigID `json:"id"`
// Human-readable label for the option.
Name string `json:"name"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
// Single-value selector (dropdown).
Select *SessionConfigSelect `json:"-"`
// Boolean on/off toggle.
Boolean *SessionConfigBoolean `json:"-"`
}
SessionConfigOption A session configuration option selector and its current state.
func (SessionConfigOption) MarshalJSON ¶
func (v SessionConfigOption) MarshalJSON() ([]byte, error)
MarshalJSON flattens whichever SessionConfigOption variant is set, plus the "type" discriminator, into one JSON object. It fails if zero or more than one variant is set.
func (*SessionConfigOption) UnmarshalJSON ¶
func (v *SessionConfigOption) UnmarshalJSON(data []byte) error
UnmarshalJSON dispatches on the "type" discriminator. A missing or unrecognized value is rejected.
type SessionConfigOptionCategory ¶
type SessionConfigOptionCategory string
SessionConfigOptionCategory Semantic category for a session configuration option.
This is intended to help Clients distinguish broadly common selectors (e.g. model selector vs session mode selector vs thought/reasoning level) for UX purposes (keyboard shortcuts, icons, placement). It MUST NOT be required for correctness. Clients MUST handle missing or unknown categories gracefully.
Category names beginning with `_` are free for custom use, like other ACP extension methods. Category names that do not begin with `_` are reserved for the ACP spec.
const ( // Session mode selector. SessionConfigOptionCategoryMode SessionConfigOptionCategory = "mode" // Model selector. SessionConfigOptionCategoryModel SessionConfigOptionCategory = "model" // Model-related configuration parameter. SessionConfigOptionCategoryModelConfig SessionConfigOptionCategory = "model_config" // Thought/reasoning level selector. SessionConfigOptionCategoryThoughtLevel SessionConfigOptionCategory = "thought_level" )
type SessionConfigOptionsCapabilities ¶
type SessionConfigOptionsCapabilities struct {
// Whether the client supports boolean session configuration options.
//
// Optional. Omitted or `null` both mean the client does not advertise support.
// Supplying `{}` means agents may include `type: "boolean"` entries in
// `configOptions`, and the client may send `session/set_config_option`
// requests with `type: "boolean"` and a boolean `value`.
Boolean *BooleanConfigOptionCapabilities `json:"boolean,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionConfigOptionsCapabilities Session configuration option capabilities supported by the client.
type SessionConfigSelect ¶
type SessionConfigSelect struct {
// The currently selected value.
CurrentValue SessionConfigValueID `json:"currentValue"`
// The set of selectable options.
Options SessionConfigSelectOptions `json:"options"`
}
SessionConfigSelect A single-value selector (dropdown) session configuration option payload.
type SessionConfigSelectGroup ¶
type SessionConfigSelectGroup struct {
// Unique identifier for this group.
Group SessionConfigGroupID `json:"group"`
// Human-readable label for this group.
Name string `json:"name"`
// The set of option values in this group.
Options []SessionConfigSelectOption `json:"options"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionConfigSelectGroup A group of possible values for a session configuration option.
type SessionConfigSelectOption ¶
type SessionConfigSelectOption struct {
// Optional description for this option value.
Description *string `json:"description,omitempty"`
// Human-readable label for this option value.
Name string `json:"name"`
// Unique identifier for this option value.
Value SessionConfigValueID `json:"value"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionConfigSelectOption A possible value for a session configuration option.
type SessionConfigSelectOptions ¶
type SessionConfigSelectOptions struct {
// A flat list of options with no grouping.
Ungrouped []SessionConfigSelectOption `json:"-"`
// A list of options grouped under headers.
Grouped []SessionConfigSelectGroup `json:"-"`
}
SessionConfigSelectOptions Possible values for a session configuration option.
func (SessionConfigSelectOptions) MarshalJSON ¶
func (v SessionConfigSelectOptions) MarshalJSON() ([]byte, error)
MarshalJSON marshals whichever SessionConfigSelectOptions variant is set. It fails if zero or more than one variant is set.
func (*SessionConfigSelectOptions) UnmarshalJSON ¶
func (v *SessionConfigSelectOptions) UnmarshalJSON(data []byte) error
UnmarshalJSON tells SessionConfigSelectOptions's variants apart by which one's required fields are present on the first array element (this union has no discriminator tag, and each variant is itself an array of a different element type).
type SessionConfigValueID ¶
type SessionConfigValueID string
SessionConfigValueID Unique identifier for a session configuration option value.
type SessionDeleteCapabilities ¶
type SessionDeleteCapabilities struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionDeleteCapabilities Capabilities for the `session/delete` method.
Supplying `{}` means the agent supports deleting sessions from `session/list`.
type SessionID ¶
type SessionID string
SessionID A unique identifier for a conversation session between a client and agent.
Sessions maintain their own context, conversation history, and state, allowing multiple independent interactions with the same agent.
See protocol docs: [Session ID](https://agentclientprotocol.com/protocol/session-setup#session-id)
type SessionInfo ¶
type SessionInfo struct {
// Additional workspace roots reported for this session. Each path must be absolute.
//
// When present, this is the complete ordered additional-root list reported
// by the Agent. Omitted and empty values are equivalent: the response
// reports no additional roots.
AdditionalDirectories []string `json:"additionalDirectories,omitempty"`
// The working directory for this session. Must be an absolute path.
Cwd string `json:"cwd"`
// Unique identifier for the session
SessionID SessionID `json:"sessionId"`
// Human-readable title for the session
Title *string `json:"title,omitempty"`
// ISO 8601 timestamp of last activity
UpdatedAt *string `json:"updatedAt,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionInfo Information about a session returned by session/list
type SessionInfoUpdate ¶
type SessionInfoUpdate struct {
// Human-readable title for the session. Set to null to clear.
Title *string `json:"title,omitempty"`
// ISO 8601 timestamp of last activity. Set to null to clear.
UpdatedAt *string `json:"updatedAt,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionInfoUpdate Update to session metadata. All fields are optional to support partial updates.
Agents send this notification to update session information like title or custom metadata. This allows clients to display dynamic session names and track session state changes.
type SessionListCapabilities ¶
type SessionListCapabilities struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionListCapabilities Capabilities for the `session/list` method.
Supplying `{}` means the agent supports listing sessions.
type SessionMode ¶
type SessionMode struct {
// Optional human-readable details shown with this protocol object.
Description *string `json:"description,omitempty"`
// Stable identifier used to refer to this protocol object in later messages.
ID SessionModeID `json:"id"`
// Human-readable name shown for this protocol object.
Name string `json:"name"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionMode A mode the agent can operate in.
See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
type SessionModeState ¶
type SessionModeState struct {
// The set of modes that the Agent can operate in
AvailableModes []SessionMode `json:"availableModes"`
// The current mode the Agent is in.
CurrentModeID SessionModeID `json:"currentModeId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionModeState The set of modes and the one currently active.
type SessionNotification ¶
type SessionNotification struct {
// The ID of the session this update pertains to.
SessionID SessionID `json:"sessionId"`
// The actual update content.
Update SessionUpdate `json:"update"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionNotification Notification containing a session update from the agent.
Used to stream real-time progress and results during prompt processing.
See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
type SessionResumeCapabilities ¶
type SessionResumeCapabilities struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SessionResumeCapabilities Capabilities for the `session/resume` method.
Supplying `{}` means the agent supports resuming sessions.
type SessionUpdate ¶
type SessionUpdate struct {
// A chunk of the user's message being streamed.
UserMessageChunk *ContentChunk `json:"-"`
// A chunk of the agent's response being streamed.
AgentMessageChunk *ContentChunk `json:"-"`
// A chunk of the agent's internal reasoning being streamed.
AgentThoughtChunk *ContentChunk `json:"-"`
// Notification that a new tool call has been initiated.
ToolCall *ToolCall `json:"-"`
// Update on the status or results of a tool call.
ToolCallUpdate *ToolCallUpdate `json:"-"`
// The agent's execution plan for complex tasks.
// See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)
Plan *Plan `json:"-"`
// Available commands are ready or have changed
AvailableCommandsUpdate *AvailableCommandsUpdate `json:"-"`
// The current mode of the session has changed
//
// See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
CurrentModeUpdate *CurrentModeUpdate `json:"-"`
// Session configuration options have been updated.
ConfigOptionUpdate *ConfigOptionUpdate `json:"-"`
// Session metadata has been updated (title, timestamps, custom metadata)
SessionInfoUpdate *SessionInfoUpdate `json:"-"`
// Context window and cost update for the session.
UsageUpdate *UsageUpdate `json:"-"`
}
SessionUpdate Different types of updates that can be sent during session processing.
These updates provide real-time feedback about the agent's progress.
See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
func (SessionUpdate) MarshalJSON ¶
func (v SessionUpdate) MarshalJSON() ([]byte, error)
MarshalJSON flattens whichever SessionUpdate variant is set, plus the "sessionUpdate" discriminator, into one JSON object. It fails if zero or more than one variant is set.
func (*SessionUpdate) UnmarshalJSON ¶
func (v *SessionUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON dispatches on the "sessionUpdate" discriminator. A missing or unrecognized value is rejected.
type SetSessionConfigOptionRequest ¶
type SetSessionConfigOptionRequest struct {
// The ID of the configuration option to set.
ConfigID SessionConfigID `json:"configId"`
// The ID of the session to set the configuration option for.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
// A boolean value (`type: "boolean"`).
Boolean *bool `json:"-"`
// A [`SessionConfigValueId`] string value.
//
// This is the default when `type` is absent on the wire. Unknown `type`
// values with string payloads also gracefully deserialize into this
// variant.
ValueID *SessionConfigValueID `json:"-"`
}
SetSessionConfigOptionRequest Request parameters for setting a session configuration option.
func (SetSessionConfigOptionRequest) MarshalJSON ¶
func (v SetSessionConfigOptionRequest) MarshalJSON() ([]byte, error)
MarshalJSON flattens whichever SetSessionConfigOptionRequest variant is set, plus the "type" discriminator, into one JSON object. It fails if zero or more than one variant is set.
func (*SetSessionConfigOptionRequest) UnmarshalJSON ¶
func (v *SetSessionConfigOptionRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON dispatches on the "type" discriminator. A missing or unrecognized value falls back to ValueID, matching the pinned schema.
type SetSessionConfigOptionResponse ¶
type SetSessionConfigOptionResponse struct {
// The full set of configuration options and their current values.
ConfigOptions []SessionConfigOption `json:"configOptions"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SetSessionConfigOptionResponse Response to `session/set_config_option` method.
type SetSessionModeRequest ¶
type SetSessionModeRequest struct {
// The ID of the mode to set.
ModeID SessionModeID `json:"modeId"`
// The ID of the session to set the mode for.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SetSessionModeRequest Request parameters for setting a session mode.
type SetSessionModeResponse ¶
type SetSessionModeResponse struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
SetSessionModeResponse Response to `session/set_mode` method.
type StopReason ¶
type StopReason string
StopReason Reasons why an agent stops processing a prompt turn.
See protocol docs: [Stop Reasons](https://agentclientprotocol.com/protocol/prompt-turn#stop-reasons)
const ( // The turn ended successfully. StopReasonEndTurn StopReason = "end_turn" // The turn ended because the agent reached the maximum number of tokens. StopReasonMaxTokens StopReason = "max_tokens" // The turn ended because the agent reached the maximum number of allowed // agent requests between user turns. StopReasonMaxTurnRequests StopReason = "max_turn_requests" // The turn ended because the agent refused to continue. The user prompt // and everything that comes after it won't be included in the next // prompt, so this should be reflected in the UI. StopReasonRefusal StopReason = "refusal" // The turn was cancelled by the client via `session/cancel`. // // This stop reason MUST be returned when the client sends a `session/cancel` // notification, even if the cancellation causes exceptions in underlying operations. // Agents should catch these exceptions and return this semantically meaningful // response to confirm successful cancellation. StopReasonCancelled StopReason = "cancelled" )
func (*StopReason) UnmarshalJSON ¶
func (v *StopReason) UnmarshalJSON(data []byte) error
UnmarshalJSON rejects any StopReason value that is not one of the named StopReason constants: this enum is closed in the pinned schema.
type Terminal ¶
type Terminal struct {
// Identifier of the terminal instance to embed in the content stream.
TerminalID TerminalID `json:"terminalId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
Terminal Embed a terminal created with `terminal/create` by its id.
The terminal must be added before calling `terminal/release`.
See protocol docs: Terminal(https://agentclientprotocol.com/protocol/terminals)
type TerminalExitStatus ¶
type TerminalExitStatus struct {
// The process exit code (may be null if terminated by signal).
ExitCode *uint32 `json:"exitCode,omitempty"`
// The signal that terminated the process (may be null if exited normally).
Signal *string `json:"signal,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
TerminalExitStatus Exit status of a terminal command.
type TerminalHandle ¶
type TerminalHandle struct {
// contains filtered or unexported fields
}
TerminalHandle is a bundled handle to one terminal created via ClientConn.CreateTerminal. It pre-binds the session id and terminal id so that Output, WaitForExit, Kill, and Release never require the caller to thread either back through.
func (*TerminalHandle) ID ¶
func (t *TerminalHandle) ID() TerminalID
ID returns the terminal id this handle is bound to.
func (*TerminalHandle) Kill ¶
func (t *TerminalHandle) Kill(ctx context.Context) (*KillTerminalResponse, error)
Kill calls the client's "terminal/kill" method for this terminal.
func (*TerminalHandle) Output ¶
func (t *TerminalHandle) Output(ctx context.Context) (*TerminalOutputResponse, error)
Output calls the client's "terminal/output" method for this terminal.
func (*TerminalHandle) Release ¶
func (t *TerminalHandle) Release(ctx context.Context) (*ReleaseTerminalResponse, error)
Release calls the client's "terminal/release" method for this terminal.
func (*TerminalHandle) WaitForExit ¶
func (t *TerminalHandle) WaitForExit(ctx context.Context) (*WaitForTerminalExitResponse, error)
WaitForExit calls the client's "terminal/wait_for_exit" method for this terminal.
type TerminalID ¶
type TerminalID string
TerminalID Typed identifier used for terminal values on the wire.
type TerminalOutputRequest ¶
type TerminalOutputRequest struct {
// The session ID for this request.
SessionID SessionID `json:"sessionId"`
// The ID of the terminal to get output from.
TerminalID TerminalID `json:"terminalId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
TerminalOutputRequest Request to get the current output and status of a terminal.
type TerminalOutputResponse ¶
type TerminalOutputResponse struct {
// Exit status if the command has completed.
ExitStatus *TerminalExitStatus `json:"exitStatus,omitempty"`
// The terminal output captured so far.
Output string `json:"output"`
// Whether the output was truncated due to byte limits.
Truncated bool `json:"truncated"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
TerminalOutputResponse Response containing the terminal output and exit status.
type TextContent ¶
type TextContent struct {
// Optional annotations that help clients decide how to display or route this content.
Annotations *Annotations `json:"annotations,omitempty"`
// Text payload carried by this content block.
Text string `json:"text"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
TextContent Text provided to or from an LLM.
type TextResourceContents ¶
type TextResourceContents struct {
// MIME type describing the encoded media payload.
MimeType *string `json:"mimeType,omitempty"`
// Text payload carried by this content block.
Text string `json:"text"`
// URI associated with this resource or media payload.
URI string `json:"uri"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
TextResourceContents Text-based resource contents.
type ToolCall ¶
type ToolCall struct {
// Content produced by the tool call.
Content []ToolCallContent `json:"content,omitempty"`
// The category of tool being invoked.
// Helps clients choose appropriate icons and UI treatment.
Kind *ToolKind `json:"kind,omitempty"`
// File locations affected by this tool call.
// Enables "follow-along" features in clients.
Locations []ToolCallLocation `json:"locations,omitempty"`
// Raw input parameters sent to the tool.
RawInput json.RawMessage `json:"rawInput,omitempty"`
// Raw output returned by the tool.
RawOutput json.RawMessage `json:"rawOutput,omitempty"`
// Current execution status of the tool call.
Status *ToolCallStatus `json:"status,omitempty"`
// Human-readable title describing what the tool is doing.
Title string `json:"title"`
// Unique identifier for this tool call within the session.
ToolCallID ToolCallID `json:"toolCallId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ToolCall Represents a tool call that the language model has requested.
Tool calls are actions that the agent executes on behalf of the language model, such as reading files, executing code, or fetching data from external sources.
See protocol docs: [Tool Calls](https://agentclientprotocol.com/protocol/tool-calls)
type ToolCallContent ¶
type ToolCallContent struct {
// Standard content block (text, images, resources).
Content *Content `json:"-"`
// File modification shown as a diff.
Diff *Diff `json:"-"`
// Embed a terminal created with `terminal/create` by its id.
//
// The terminal must be added before calling `terminal/release`.
//
// See protocol docs: [Terminal](https://agentclientprotocol.com/protocol/terminals)
Terminal *Terminal `json:"-"`
}
ToolCallContent Content produced by a tool call.
Tool calls can produce different types of content including standard content blocks (text, images) or file diffs.
See protocol docs: Content(https://agentclientprotocol.com/protocol/tool-calls#content)
func (ToolCallContent) MarshalJSON ¶
func (v ToolCallContent) MarshalJSON() ([]byte, error)
MarshalJSON flattens whichever ToolCallContent variant is set, plus the "type" discriminator, into one JSON object. It fails if zero or more than one variant is set.
func (*ToolCallContent) UnmarshalJSON ¶
func (v *ToolCallContent) UnmarshalJSON(data []byte) error
UnmarshalJSON dispatches on the "type" discriminator. A missing or unrecognized value is rejected.
type ToolCallID ¶
type ToolCallID string
ToolCallID Unique identifier for a tool call within a session.
type ToolCallLocation ¶
type ToolCallLocation struct {
// Optional line number within the file.
Line *uint32 `json:"line,omitempty"`
// The absolute file path being accessed or modified.
Path string `json:"path"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ToolCallLocation A file location being accessed or modified by a tool.
Enables clients to implement "follow-along" features that track which files the agent is working with in real-time.
See protocol docs: [Following the Agent](https://agentclientprotocol.com/protocol/tool-calls#following-the-agent)
type ToolCallStatus ¶
type ToolCallStatus string
ToolCallStatus Execution status of a tool call.
Tool calls progress through different statuses during their lifecycle.
See protocol docs: [Status](https://agentclientprotocol.com/protocol/tool-calls#status)
const ( // The tool call hasn't started running yet because the input is either // streaming or we're awaiting approval. ToolCallStatusPending ToolCallStatus = "pending" // The tool call is currently running. ToolCallStatusInProgress ToolCallStatus = "in_progress" // The tool call completed successfully. ToolCallStatusCompleted ToolCallStatus = "completed" // The tool call failed with an error. ToolCallStatusFailed ToolCallStatus = "failed" )
func (*ToolCallStatus) UnmarshalJSON ¶
func (v *ToolCallStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON rejects any ToolCallStatus value that is not one of the named ToolCallStatus constants: this enum is closed in the pinned schema.
type ToolCallUpdate ¶
type ToolCallUpdate struct {
// Replace the content collection.
Content []ToolCallContent `json:"content,omitempty"`
// Update the tool kind.
Kind *ToolKind `json:"kind,omitempty"`
// Replace the locations collection.
Locations []ToolCallLocation `json:"locations,omitempty"`
// Update the raw input.
RawInput json.RawMessage `json:"rawInput,omitempty"`
// Update the raw output.
RawOutput json.RawMessage `json:"rawOutput,omitempty"`
// Update the execution status.
Status *ToolCallStatus `json:"status,omitempty"`
// Update the human-readable title.
Title *string `json:"title,omitempty"`
// The ID of the tool call being updated.
ToolCallID ToolCallID `json:"toolCallId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
ToolCallUpdate An update to an existing tool call.
Used to report progress and results as tools execute. All fields except the tool call ID are optional - only changed fields need to be included.
See protocol docs: [Updating](https://agentclientprotocol.com/protocol/tool-calls#updating)
type ToolKind ¶
type ToolKind string
ToolKind Categories of tools that can be invoked.
Tool kinds help clients choose appropriate icons and optimize how they display tool execution progress.
See protocol docs: [Creating](https://agentclientprotocol.com/protocol/tool-calls#creating)
const ( // Reading files or data. ToolKindRead ToolKind = "read" // Modifying files or content. ToolKindEdit ToolKind = "edit" // Removing files or data. ToolKindDelete ToolKind = "delete" // Moving or renaming files. ToolKindMove ToolKind = "move" // Searching for information. ToolKindSearch ToolKind = "search" // Running commands or code. ToolKindExecute ToolKind = "execute" // Internal reasoning or planning. ToolKindThink ToolKind = "think" // Retrieving external data. ToolKindFetch ToolKind = "fetch" // Switching the current session mode. ToolKindSwitchMode ToolKind = "switch_mode" // Other tool types (default). ToolKindOther ToolKind = "other" )
func (*ToolKind) UnmarshalJSON ¶
UnmarshalJSON rejects any ToolKind value that is not one of the named ToolKind constants: this enum is closed in the pinned schema.
type TruncatedFrameError ¶
type TruncatedFrameError struct {
// Read is the number of content bytes read on the truncated trailing
// line before EOF.
Read int
}
TruncatedFrameError reports that the underlying reader reached EOF in the middle of a line: some bytes were read on the final line, but no terminating "\n" was ever found. A clean end of stream (EOF exactly at a frame boundary, with zero bytes read on the next attempt) is reported as plain io.EOF instead, never this type.
func (*TruncatedFrameError) Error ¶
func (e *TruncatedFrameError) Error() string
type UnstructuredCommandInput ¶
type UnstructuredCommandInput struct {
// A hint to display when the input hasn't been provided yet
Hint string `json:"hint"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
UnstructuredCommandInput All text that was typed after the command name is provided as input.
type UsageUpdate ¶
type UsageUpdate struct {
// Cumulative session cost (optional).
Cost *Cost `json:"cost,omitempty"`
// Total context window size in tokens.
Size uint64 `json:"size"`
// Tokens currently in context.
Used uint64 `json:"used"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
UsageUpdate Context window and cost update for a session.
type ValidationError ¶
type ValidationError struct {
Issues []Issue
}
ValidationError reports every structural problem found in a rejected envelope. Its Error method deliberately emits only the issue count and kinds — never any fragment of the payload that produced them, since wire input is untrusted and diagnostics must not become an exfiltration or log injection channel.
func (*ValidationError) AsFault ¶
func (e *ValidationError) AsFault() *Fault
AsFault converts a ValidationError into a Fault suitable for sending back to a peer as a JSON-RPC error response. Payloads that could not be parsed as JSON at all map to ParseError; payloads that parsed as JSON but did not form a valid JSON-RPC object map to InvalidRequest.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type WaitForTerminalExitRequest ¶
type WaitForTerminalExitRequest struct {
// The session ID for this request.
SessionID SessionID `json:"sessionId"`
// The ID of the terminal to wait for.
TerminalID TerminalID `json:"terminalId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
WaitForTerminalExitRequest Request to wait for a terminal command to exit.
type WaitForTerminalExitResponse ¶
type WaitForTerminalExitResponse struct {
// The process exit code (may be null if terminated by signal).
ExitCode *uint32 `json:"exitCode,omitempty"`
// The signal that terminated the process (may be null if exited normally).
Signal *string `json:"signal,omitempty"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
WaitForTerminalExitResponse Response containing the exit status of a terminal command.
type WriteResult ¶
type WriteResult struct {
WriteAdmitted bool
}
WriteResult records the one transport fact a caller cannot recover from an ordinary error value: whether the fully-framed message crossed Writer's admission boundary. A false value proves the frame was never eligible for the underlying io.Writer and therefore was not written by Writer. Once the frame is admitted, this remains true even when a later context cancellation or transport failure makes SendContextResult return an error.
type WriteTextFileRequest ¶
type WriteTextFileRequest struct {
// The text content to write to the file.
Content string `json:"content"`
// Absolute path to the file to write.
Path string `json:"path"`
// The session ID for this request.
SessionID SessionID `json:"sessionId"`
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
WriteTextFileRequest Request to write content to a text file.
Only available if the client supports the `fs.writeTextFile` capability.
type WriteTextFileResponse ¶
type WriteTextFileResponse struct {
// The _meta property is reserved by ACP to allow clients and agents to attach additional
// metadata to their interactions. Implementations MUST NOT make assumptions about values at
// these keys.
//
// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
Meta json.RawMessage `json:"_meta,omitempty"`
}
WriteTextFileResponse Response to `fs/write_text_file`
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer serializes concurrent Send calls into a single stream of newline-terminated JSON frames written to an underlying io.Writer. Exactly one internal goroutine ever calls the underlying Write, so Writer is safe to share across arbitrarily many goroutines even when the underlying io.Writer is not itself concurrency-safe.
Close coordinates with in-flight Send calls through an "admission" scheme rather than racing a done-channel against each Send's result wait: mu and closed gate entry so that every Send is classified, atomically, as either admitted (guaranteed a real write attempt and a result from errCh) or rejected outright (WriterClosedError, no job ever created). admitted tracks every currently-admitted Send so Close can wait for all of them to fully complete — with the writer goroutine still actively servicing the queue throughout — before it tells that goroutine no further work will ever arrive. This removes any window where a job could be silently dropped or where a sender whose write already succeeded could still observe a closed error.
Example (MarshalError) ¶
package main
import (
"bytes"
"fmt"
"github.com/looprig/acp/protocol"
)
func main() {
var buf bytes.Buffer
w := protocol.NewWriter(&buf)
defer w.Close()
// A value json.Marshal cannot encode (e.g. a channel) must surface a
// plain encode error, not a hang or a typed framing error.
err := w.Send(make(chan int))
fmt.Println(err != nil)
}
Output: true
func NewWriter ¶
NewWriter starts the internal writer goroutine over w and returns a Writer ready for concurrent Send calls.
func (*Writer) Close ¶
Close stops the Writer from accepting any further Send calls, waits for every already-admitted Send to be fully written, then stops the internal writer goroutine and waits for it to exit. Any Send that had not yet been admitted at the moment Close was called returns a *WriterClosedError immediately rather than blocking. Close is idempotent and safe to call concurrently with Send or with itself.
func (*Writer) Send ¶
Send marshals msg as JSON, appends a newline, and hands the resulting frame to the single internal writer goroutine, blocking until it has been written. Once the Writer is closed (or closing), Send fails fast with a *WriterClosedError instead of blocking. It is safe to call Send from any number of goroutines concurrently.
func (*Writer) SendContext ¶
SendContext is Send's cancellation-aware form. If ctx is canceled before a job is queued, no underlying write is attempted and SendContext returns ctx.Err(). Once the job is admitted, SendContext may still return ctx.Err() while the writer drains and attempts that admitted job; transport shutdown must release a blocked Write before Writer.Close can finish. This preserves Writer.Close's no-lost-admitted-job accounting and keeps the writer goroutine owned by the Writer rather than by the caller.
func (*Writer) SendContextResult ¶
SendContextResult is SendContext's admission-aware form. A context canceled before the frame is queued returns WriteAdmitted=false and Writer never attempts the underlying write. Once queue admission succeeds, every return carries WriteAdmitted=true, including context cancellation while the raw write or response wait is still in progress.
type WriterClosedError ¶
type WriterClosedError struct {
// contains filtered or unexported fields
}
WriterClosedError is returned by Send once the Writer has been (or is being) closed: it unblocks every sender that was not already drained, so none can hang waiting on a writer that will never make progress again.
func (*WriterClosedError) Error ¶
func (e *WriterClosedError) Error() string
func (*WriterClosedError) Unwrap ¶
func (e *WriterClosedError) Unwrap() error
Unwrap exposes the cause that led to closing, if any (for example an error surfaced from the underlying io.Writer).