Documentation
¶
Index ¶
- Constants
- Variables
- func AfterResponse(ctx context.Context, fn func())
- func Dump(v any, o DumpOptions) any
- func IsModel(v any) bool
- func IsNil(v any) bool
- func NormalizeResult(payload any) any
- func Ptr[T any](v T) *T
- func RunAgent(agent any, input io.Writer, output io.Reader, useUnstableProtocol bool, ...) error
- func StdioStreams() (io.Reader, io.Writer)
- func Validate[T any](input any) (*T, error)
- func WithResponseScope(ctx context.Context) (context.Context, func())
- type AgentCapabilities
- type AgentMessageChunk
- type AgentPlanUpdate
- type AgentSideConnection
- func (c *AgentSideConnection) Close() error
- func (c *AgentSideConnection) Conn() *Connection
- func (c *AgentSideConnection) CreateTerminal(ctx context.Context, req *CreateTerminalRequest) (*CreateTerminalResponse, error)
- func (c *AgentSideConnection) ExtMethod(ctx context.Context, method string, params *pyjson.Object) (any, error)
- func (c *AgentSideConnection) ExtNotification(ctx context.Context, method string, params *pyjson.Object) error
- func (c *AgentSideConnection) KillTerminal(ctx context.Context, sessionID, terminalID string, meta *pyjson.Object) (*KillTerminalResponse, error)
- func (c *AgentSideConnection) Listen() error
- func (c *AgentSideConnection) ReadTextFile(ctx context.Context, path, sessionID string, limit, line *int, ...) (*ReadTextFileResponse, error)
- func (c *AgentSideConnection) ReleaseTerminal(ctx context.Context, sessionID, terminalID string, meta *pyjson.Object) (*ReleaseTerminalResponse, error)
- func (c *AgentSideConnection) RequestPermission(ctx context.Context, options []PermissionOption, sessionID string, ...) (*RequestPermissionResponse, error)
- func (c *AgentSideConnection) SessionUpdate(ctx context.Context, sessionID string, update SessionUpdate, ...) error
- func (c *AgentSideConnection) TerminalOutput(ctx context.Context, sessionID, terminalID string, meta *pyjson.Object) (*TerminalOutputResponse, error)
- func (c *AgentSideConnection) WaitForTerminalExit(ctx context.Context, sessionID, terminalID string, meta *pyjson.Object) (*WaitForTerminalExitResponse, error)
- func (c *AgentSideConnection) WriteTextFile(ctx context.Context, content, path, sessionID string, meta *pyjson.Object) (*WriteTextFileResponse, error)
- type AgentThoughtChunk
- type AllowedOutcome
- type Annotations
- type AudioContentBlock
- type AuthCapabilities
- type AuthEnvVar
- type AuthMethod
- type AuthMethodAgent
- type AuthenticateRequest
- type AuthenticateResponse
- type Authenticator
- type AvailableCommand
- type AvailableCommandsUpdate
- type BlobResourceContents
- type CancelNotification
- type Canceller
- type ClientCapabilities
- type CloseSessionRequest
- type CloseSessionResponse
- type ConfigOptionSetter
- type ConfigOptionUpdate
- type Connection
- func (c *Connection) AddObserver(observer StreamObserver)
- func (c *Connection) Close() error
- func (c *Connection) MainLoop() error
- func (c *Connection) SendNotification(ctx context.Context, method string, params any) error
- func (c *Connection) SendRequest(ctx context.Context, method string, params any) (any, error)
- type Connector
- type ContentBlock
- type ContentToolCallContent
- type Cost
- type CreateTerminalRequest
- type CreateTerminalResponse
- type CurrentModeUpdate
- type DeniedOutcome
- type DumpOptions
- type EmbeddedResourceContentBlock
- type EnvVarAuthMethod
- type EnvVariable
- type ExtMethoder
- type ExtNotifier
- type ExtensionHandler
- type FileEditToolCallContent
- type FileSystemCapabilities
- type ForkSessionRequest
- type ForkSessionResponse
- type HttpHeader
- type HttpMcpServer
- type ImageContentBlock
- type Implementation
- type InitializeRequest
- type InitializeResponse
- type Initializer
- type KillTerminalRequest
- type KillTerminalResponse
- type ListSessionsRequest
- type ListSessionsResponse
- type LoadSessionRequest
- type LoadSessionResponse
- type McpCapabilities
- type McpServer
- type McpServerStdio
- type MessageRouter
- func (m *MessageRouter) AddRoute(r *Route)
- func (m *MessageRouter) Call(ctx context.Context, method string, params any, isNotification bool) (any, error)
- func (m *MessageRouter) HandleExtensionNotification(h ExtensionHandler)
- func (m *MessageRouter) HandleExtensionRequest(h ExtensionHandler)
- func (m *MessageRouter) RouteNotification(method string, fn RouteFunc, unstable bool) *Route
- func (m *MessageRouter) RouteRequest(method string, fn RouteFunc, adapt func(any) any, unstable bool) *Route
- type MethodHandler
- type ModelInfo
- type NewSessionRequest
- type NewSessionResponse
- type PermissionOption
- type PermissionOutcome
- type PlanEntry
- type PromptCapabilities
- type PromptRequest
- type PromptResponse
- type Prompter
- type ReadTextFileRequest
- type ReadTextFileResponse
- type ReleaseTerminalRequest
- type ReleaseTerminalResponse
- type RequestError
- type RequestPermissionRequest
- type RequestPermissionResponse
- type ResourceContentBlock
- type ResourceContents
- type ResumeSessionRequest
- type ResumeSessionResponse
- type Route
- type RouteFunc
- type SessionCapabilities
- type SessionCloseCapabilities
- type SessionCloser
- type SessionConfigOption
- type SessionConfigOptionBoolean
- type SessionConfigOptionSelect
- type SessionConfigSelectGroup
- type SessionConfigSelectOption
- type SessionCreator
- type SessionForkCapabilities
- type SessionForker
- type SessionInfo
- type SessionInfoUpdate
- type SessionListCapabilities
- type SessionLister
- type SessionLoader
- type SessionMode
- type SessionModeSetter
- type SessionModeState
- type SessionModelSetter
- type SessionModelState
- type SessionNotification
- type SessionResumeCapabilities
- type SessionResumer
- type SessionUpdate
- type SetConfigOptionParams
- type SetSessionConfigOptionBooleanRequest
- type SetSessionConfigOptionResponse
- type SetSessionConfigOptionSelectRequest
- type SetSessionModeRequest
- type SetSessionModeResponse
- type SetSessionModelRequest
- type SetSessionModelResponse
- type SseMcpServer
- type StreamDirection
- type StreamEvent
- type StreamObserver
- type TerminalAuthMethod
- type TerminalExitStatus
- type TerminalOutputRequest
- type TerminalOutputResponse
- type TerminalToolCallContent
- type TextContentBlock
- type TextResourceContents
- type ToolCallContent
- type ToolCallFields
- type ToolCallLocation
- type ToolCallProgress
- type ToolCallStart
- type ToolCallUpdate
- type UnstructuredCommandInput
- type Usage
- type UsageUpdate
- type UserMessageChunk
- type ValidationError
- type WaitForTerminalExitRequest
- type WaitForTerminalExitResponse
- type WriteTextFileRequest
- type WriteTextFileResponse
Constants ¶
const DefaultStdioBufferLimitBytes = 50 * 1024 * 1024
Default per line limit of the stdio reader, 50 MB for multimodal frames
const ProtocolVersion = 1
Protocol version the library speaks
Variables ¶
var AgentMethods = map[string]string{
"authenticate": "authenticate",
"initialize": "initialize",
"session_cancel": "session/cancel",
"session_close": "session/close",
"session_fork": "session/fork",
"session_list": "session/list",
"session_load": "session/load",
"session_new": "session/new",
"session_prompt": "session/prompt",
"session_resume": "session/resume",
"session_set_config_option": "session/set_config_option",
"session_set_mode": "session/set_mode",
"session_set_model": "session/set_model",
}
Wire names of the methods an agent serves
var ClientMethods = map[string]string{
"fs_read_text_file": "fs/read_text_file",
"fs_write_text_file": "fs/write_text_file",
"session_request_permission": "session/request_permission",
"session_update": "session/update",
"terminal_create": "terminal/create",
"terminal_kill": "terminal/kill",
"terminal_output": "terminal/output",
"terminal_release": "terminal/release",
"terminal_wait_for_exit": "terminal/wait_for_exit",
}
Wire names of the methods a client serves
var ErrConnectionClosed = errors.New("Connection closed")
ConnectionError rejecting outgoing requests when the connection closes
var ResultDump = DumpOptions{ByAlias: true, ExcludeNone: true, ExcludeUnset: true}
Options the connection uses for a model returned as a request result
var SerializeParams = DumpOptions{ByAlias: true, ExcludeNone: true, ExcludeDefaults: true}
Options of serialize_params, by alias excluding None and defaults
Functions ¶
func AfterResponse ¶
Runs fn on its own goroutine once the response of the request is written, at once outside one
func Dump ¶
func Dump(v any, o DumpOptions) any
Python model_dump of a schema model as ordered JSON values, other values converted recursively
func NormalizeResult ¶
Empty object for nil, serialized params for a model, the payload otherwise
func RunAgent ¶
func RunAgent(agent any, input io.Writer, output io.Reader, useUnstableProtocol bool, limit int) error
Serves agent over the streams, stdin and stdout when both are nil, until the client disconnects
func StdioStreams ¶
Reader of stdin and writer of stdout for a stdio connection
Types ¶
type AgentCapabilities ¶
type AgentCapabilities struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
LoadSession *bool `acp:"loadSession,py=load_session,def=false"`
MCPCapabilities *McpCapabilities `acp:"mcpCapabilities,py=mcp_capabilities,def=model"`
PromptCapabilities *PromptCapabilities `acp:"promptCapabilities,py=prompt_capabilities,def=model"`
SessionCapabilities *SessionCapabilities `acp:"sessionCapabilities,py=session_capabilities,def=model"`
}
type AgentMessageChunk ¶
type AgentMessageChunk struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Content ContentBlock `` /* 137-byte string literal not displayed */
MessageID *string `acp:"messageId,py=message_id"`
// contains filtered or unexported fields
}
func UpdateAgentMessage ¶
func UpdateAgentMessage(content ContentBlock) *AgentMessageChunk
Agent message chunk update
func UpdateAgentMessageText ¶
func UpdateAgentMessageText(text string) *AgentMessageChunk
Agent message chunk update of plain text
type AgentPlanUpdate ¶
type AgentPlanUpdate struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Entries []PlanEntry `acp:"entries,py=entries,req"`
// contains filtered or unexported fields
}
func UpdatePlan ¶
func UpdatePlan(entries []PlanEntry) *AgentPlanUpdate
Plan update of the given entries
type AgentSideConnection ¶
type AgentSideConnection struct {
// contains filtered or unexported fields
}
Agent side of an ACP connection, the client facing calls an agent makes
func NewAgentSideConnection ¶
func NewAgentSideConnection(agent any, writer io.Writer, reader io.Reader, listening, useUnstableProtocol bool, limit int) *AgentSideConnection
Connection serving agent over the given streams, calling its connect hook when present
func (*AgentSideConnection) Close ¶
func (c *AgentSideConnection) Close() error
Closes the underlying connection
func (*AgentSideConnection) Conn ¶
func (c *AgentSideConnection) Conn() *Connection
Underlying JSON-RPC connection
func (*AgentSideConnection) CreateTerminal ¶
func (c *AgentSideConnection) CreateTerminal(ctx context.Context, req *CreateTerminalRequest) (*CreateTerminalResponse, error)
Creates a client terminal running command
func (*AgentSideConnection) ExtMethod ¶
func (c *AgentSideConnection) ExtMethod(ctx context.Context, method string, params *pyjson.Object) (any, error)
Sends an underscore prefixed extension request
func (*AgentSideConnection) ExtNotification ¶
func (c *AgentSideConnection) ExtNotification(ctx context.Context, method string, params *pyjson.Object) error
Sends an underscore prefixed extension notification
func (*AgentSideConnection) KillTerminal ¶
func (c *AgentSideConnection) KillTerminal(ctx context.Context, sessionID, terminalID string, meta *pyjson.Object) (*KillTerminalResponse, error)
Kills a client terminal
func (*AgentSideConnection) Listen ¶
func (c *AgentSideConnection) Listen() error
Receives frames until the client closes its side
func (*AgentSideConnection) ReadTextFile ¶
func (c *AgentSideConnection) ReadTextFile(ctx context.Context, path, sessionID string, limit, line *int, meta *pyjson.Object) (*ReadTextFileResponse, error)
Reads a text file through the client
func (*AgentSideConnection) ReleaseTerminal ¶
func (c *AgentSideConnection) ReleaseTerminal(ctx context.Context, sessionID, terminalID string, meta *pyjson.Object) (*ReleaseTerminalResponse, error)
Releases a client terminal
func (*AgentSideConnection) RequestPermission ¶
func (c *AgentSideConnection) RequestPermission(ctx context.Context, options []PermissionOption, sessionID string, toolCall *ToolCallUpdate, meta *pyjson.Object) (*RequestPermissionResponse, error)
Asks the client to pick one of the permission options for a tool call
func (*AgentSideConnection) SessionUpdate ¶
func (c *AgentSideConnection) SessionUpdate(ctx context.Context, sessionID string, update SessionUpdate, meta *pyjson.Object) error
Sends a session/update notification
func (*AgentSideConnection) TerminalOutput ¶
func (c *AgentSideConnection) TerminalOutput(ctx context.Context, sessionID, terminalID string, meta *pyjson.Object) (*TerminalOutputResponse, error)
Current output of a client terminal
func (*AgentSideConnection) WaitForTerminalExit ¶
func (c *AgentSideConnection) WaitForTerminalExit(ctx context.Context, sessionID, terminalID string, meta *pyjson.Object) (*WaitForTerminalExitResponse, error)
Waits for a client terminal to exit
func (*AgentSideConnection) WriteTextFile ¶
func (c *AgentSideConnection) WriteTextFile(ctx context.Context, content, path, sessionID string, meta *pyjson.Object) (*WriteTextFileResponse, error)
Writes a text file through the client
type AgentThoughtChunk ¶
type AgentThoughtChunk struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Content ContentBlock `` /* 137-byte string literal not displayed */
MessageID *string `acp:"messageId,py=message_id"`
// contains filtered or unexported fields
}
func UpdateAgentThought ¶
func UpdateAgentThought(content ContentBlock) *AgentThoughtChunk
Agent thought chunk update
func UpdateAgentThoughtText ¶
func UpdateAgentThoughtText(text string) *AgentThoughtChunk
Agent thought chunk update of plain text
type AllowedOutcome ¶
type Annotations ¶
type AudioContentBlock ¶
type AudioContentBlock struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Annotations *Annotations `acp:"annotations,py=annotations"`
Data string `acp:"data,py=data,req"`
MimeType string `acp:"mimeType,py=mime_type,req"`
// contains filtered or unexported fields
}
type AuthCapabilities ¶
type AuthEnvVar ¶
type AuthMethod ¶
type AuthMethod interface {
// contains filtered or unexported methods
}
type AuthMethodAgent ¶
type AuthenticateRequest ¶
type AuthenticateResponse ¶
type Authenticator ¶
type Authenticator interface {
Authenticate(ctx context.Context, req *AuthenticateRequest) (*AuthenticateResponse, error)
}
Agent method answering authenticate
type AvailableCommand ¶
type AvailableCommand struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Description string `acp:"description,py=description,req"`
Input *UnstructuredCommandInput `acp:"input,py=input"`
Name string `acp:"name,py=name,req"`
}
type AvailableCommandsUpdate ¶
type AvailableCommandsUpdate struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
AvailableCommands []AvailableCommand `acp:"availableCommands,py=available_commands,req"`
// contains filtered or unexported fields
}
type BlobResourceContents ¶
type CancelNotification ¶
type Canceller ¶
type Canceller interface {
Cancel(ctx context.Context, req *CancelNotification) error
}
Agent method receiving session/cancel
type ClientCapabilities ¶
type ClientCapabilities struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Auth *AuthCapabilities `acp:"auth,py=auth,def=dict"`
Fs *FileSystemCapabilities `acp:"fs,py=fs,def=model"`
Terminal *bool `acp:"terminal,py=terminal,def=false"`
}
type CloseSessionRequest ¶
type CloseSessionResponse ¶
type ConfigOptionSetter ¶
type ConfigOptionSetter interface {
SetConfigOption(ctx context.Context, req *SetConfigOptionParams) (*SetSessionConfigOptionResponse, error)
}
Agent method answering session/set_config_option
type ConfigOptionUpdate ¶
type ConfigOptionUpdate struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
ConfigOptions []SessionConfigOption `acp:"configOptions,py=config_options,req,union=SessionConfigOptionSelect|SessionConfigOptionBoolean"`
// contains filtered or unexported fields
}
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Minimal JSON-RPC 2.0 connection over newline delimited JSON frames
func NewConnection ¶
func NewConnection(handler MethodHandler, writer io.Writer, reader io.Reader, listening bool, limit int) *Connection
Connection reading frames from reader and writing to writer, receiving in the background when listening
func (*Connection) AddObserver ¶
func (c *Connection) AddObserver(observer StreamObserver)
Registers a callback that receives every raw JSON-RPC message
func (*Connection) Close ¶
func (c *Connection) Close() error
Stops receiving, waits for in flight handlers and rejects pending outgoing requests
func (*Connection) MainLoop ¶
func (c *Connection) MainLoop() error
Receives frames until end of input, logging and returning a failure of the loop
func (*Connection) SendNotification ¶
Sends a notification frame
func (*Connection) SendRequest ¶
Sends a request and waits for its result or error response
type Connector ¶
type Connector interface {
OnConnect(conn *AgentSideConnection)
}
Agent hook receiving the connection it is served on
type ContentBlock ¶
type ContentBlock interface {
// contains filtered or unexported methods
}
type ContentToolCallContent ¶
type ContentToolCallContent struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Content ContentBlock `` /* 137-byte string literal not displayed */
// contains filtered or unexported fields
}
func ToolContent ¶
func ToolContent(block ContentBlock) *ContentToolCallContent
Tool call content wrapping a content block
type CreateTerminalRequest ¶
type CreateTerminalRequest struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Args []string `acp:"args,py=args"`
Command string `acp:"command,py=command,req"`
Cwd *string `acp:"cwd,py=cwd"`
Env []EnvVariable `acp:"env,py=env"`
OutputByteLimit *int `acp:"outputByteLimit,py=output_byte_limit"`
SessionID string `acp:"sessionId,py=session_id,req"`
}
type CreateTerminalResponse ¶
type CurrentModeUpdate ¶
type DeniedOutcome ¶
type DeniedOutcome struct {
// contains filtered or unexported fields
}
type DumpOptions ¶
Flags of pydantic model_dump
type EmbeddedResourceContentBlock ¶
type EmbeddedResourceContentBlock struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Annotations *Annotations `acp:"annotations,py=annotations"`
Resource ResourceContents `acp:"resource,py=resource,req,union=TextResourceContents|BlobResourceContents"`
// contains filtered or unexported fields
}
type EnvVarAuthMethod ¶
type EnvVarAuthMethod struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Description *string `acp:"description,py=description"`
ID string `acp:"id,py=id,req"`
Link *string `acp:"link,py=link"`
Name string `acp:"name,py=name,req"`
Vars []AuthEnvVar `acp:"vars,py=vars,req"`
// contains filtered or unexported fields
}
type EnvVariable ¶
type ExtMethoder ¶
type ExtMethoder interface {
ExtMethod(ctx context.Context, name string, params *pyjson.Object) (any, error)
}
Agent method answering underscore extension requests
type ExtNotifier ¶
type ExtNotifier interface {
ExtNotification(ctx context.Context, name string, params *pyjson.Object) error
}
Agent method receiving underscore extension notifications
type ExtensionHandler ¶
Handler of extension methods whose name lost its leading underscore
type FileEditToolCallContent ¶
type FileEditToolCallContent struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
NewText string `acp:"newText,py=new_text,req"`
OldText *string `acp:"oldText,py=old_text"`
Path string `acp:"path,py=path,req"`
// contains filtered or unexported fields
}
func ToolDiffContent ¶
func ToolDiffContent(path, newText string, oldText *string) *FileEditToolCallContent
Diff tool call content, old text omitted when nil
type FileSystemCapabilities ¶
type ForkSessionRequest ¶
type ForkSessionResponse ¶
type ForkSessionResponse struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
ConfigOptions []SessionConfigOption `acp:"configOptions,py=config_options,union=SessionConfigOptionSelect|SessionConfigOptionBoolean"`
Models *SessionModelState `acp:"models,py=models"`
Modes *SessionModeState `acp:"modes,py=modes"`
SessionID string `acp:"sessionId,py=session_id,req"`
}
type HttpHeader ¶
type HttpMcpServer ¶
type HttpMcpServer struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Headers []HttpHeader `acp:"headers,py=headers,req"`
Name string `acp:"name,py=name,req"`
URL string `acp:"url,py=url,req"`
// contains filtered or unexported fields
}
type ImageContentBlock ¶
type ImageContentBlock struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Annotations *Annotations `acp:"annotations,py=annotations"`
Data string `acp:"data,py=data,req"`
MimeType string `acp:"mimeType,py=mime_type,req"`
URI *string `acp:"uri,py=uri"`
// contains filtered or unexported fields
}
type Implementation ¶
type InitializeRequest ¶
type InitializeRequest struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
ClientCapabilities *ClientCapabilities `acp:"clientCapabilities,py=client_capabilities,def=model"`
ClientInfo *Implementation `acp:"clientInfo,py=client_info"`
ProtocolVersion int `acp:"protocolVersion,py=protocol_version,req"`
}
type InitializeResponse ¶
type InitializeResponse struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
AgentCapabilities *AgentCapabilities `acp:"agentCapabilities,py=agent_capabilities,def=model"`
AgentInfo *Implementation `acp:"agentInfo,py=agent_info"`
AuthMethods []AuthMethod `acp:"authMethods,py=auth_methods,def=[],union=EnvVarAuthMethod|TerminalAuthMethod|AuthMethodAgent"`
ProtocolVersion int `acp:"protocolVersion,py=protocol_version,req"`
}
type Initializer ¶
type Initializer interface {
Initialize(ctx context.Context, req *InitializeRequest) (*InitializeResponse, error)
}
Agent method answering initialize
type KillTerminalRequest ¶
type KillTerminalResponse ¶
type ListSessionsRequest ¶
type ListSessionsResponse ¶
type ListSessionsResponse struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
NextCursor *string `acp:"nextCursor,py=next_cursor"`
Sessions []SessionInfo `acp:"sessions,py=sessions,req"`
}
type LoadSessionRequest ¶
type LoadSessionResponse ¶
type LoadSessionResponse struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
ConfigOptions []SessionConfigOption `acp:"configOptions,py=config_options,union=SessionConfigOptionSelect|SessionConfigOptionBoolean"`
Models *SessionModelState `acp:"models,py=models"`
Modes *SessionModeState `acp:"modes,py=modes"`
}
type McpCapabilities ¶
type McpServerStdio ¶
type MessageRouter ¶
type MessageRouter struct {
// contains filtered or unexported fields
}
Method name router for requests, notifications and underscore extensions
func BuildAgentRouter ¶
func BuildAgentRouter(agent any, useUnstableProtocol bool) *MessageRouter
Router of every agent method, routes absent from the agent answering method not found
func NewMessageRouter ¶
func NewMessageRouter(useUnstableProtocol bool) *MessageRouter
Empty router, unstable routes refused unless enabled
func (*MessageRouter) AddRoute ¶
func (m *MessageRouter) AddRoute(r *Route)
Registers a route under its method and kind
func (*MessageRouter) Call ¶
func (m *MessageRouter) Call(ctx context.Context, method string, params any, isNotification bool) (any, error)
Dispatches one incoming message to its route or extension handler
func (*MessageRouter) HandleExtensionNotification ¶
func (m *MessageRouter) HandleExtensionNotification(h ExtensionHandler)
Sets the handler of underscore prefixed notifications
func (*MessageRouter) HandleExtensionRequest ¶
func (m *MessageRouter) HandleExtensionRequest(h ExtensionHandler)
Sets the handler of underscore prefixed requests
func (*MessageRouter) RouteNotification ¶
func (m *MessageRouter) RouteNotification(method string, fn RouteFunc, unstable bool) *Route
Registers a notification route
func (*MessageRouter) RouteRequest ¶
func (m *MessageRouter) RouteRequest(method string, fn RouteFunc, adapt func(any) any, unstable bool) *Route
Registers a request route, unstable routes warning when the protocol flag is off
type MethodHandler ¶
type MethodHandler func(ctx context.Context, method string, params any, isNotification bool) (any, error)
Handler the connection calls for every incoming request or notification
type NewSessionRequest ¶
type NewSessionResponse ¶
type NewSessionResponse struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
ConfigOptions []SessionConfigOption `acp:"configOptions,py=config_options,union=SessionConfigOptionSelect|SessionConfigOptionBoolean"`
Models *SessionModelState `acp:"models,py=models"`
Modes *SessionModeState `acp:"modes,py=modes"`
SessionID string `acp:"sessionId,py=session_id,req"`
}
type PermissionOption ¶
type PermissionOutcome ¶
type PermissionOutcome interface {
// contains filtered or unexported methods
}
type PlanEntry ¶
type PlanEntry struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Content string `acp:"content,py=content,req"`
Priority string `acp:"priority,py=priority,req,enum=high|medium|low"`
Status string `acp:"status,py=status,req,enum=pending|in_progress|completed"`
}
func NewPlanEntry ¶
Plan entry with content, priority and status
type PromptCapabilities ¶
type PromptRequest ¶
type PromptRequest struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
MessageID *string `acp:"messageId,py=message_id"`
Prompt []ContentBlock `` /* 135-byte string literal not displayed */
SessionID string `acp:"sessionId,py=session_id,req"`
}
type PromptResponse ¶
type Prompter ¶
type Prompter interface {
Prompt(ctx context.Context, req *PromptRequest) (*PromptResponse, error)
}
Agent method answering session/prompt
type ReadTextFileRequest ¶
type ReadTextFileResponse ¶
type ReleaseTerminalRequest ¶
type ReleaseTerminalResponse ¶
type RequestError ¶
JSON-RPC error raised by a handler or received for an outgoing request
func InvalidParams ¶
func InvalidParams(data *pyjson.Object) *RequestError
Code -32602 Invalid params
func MethodNotFound ¶
func MethodNotFound(method string) *RequestError
Code -32601 Method not found carrying the method name
func NewRequestError ¶
func NewRequestError(code int, message string, data any) *RequestError
Error with the given code, message and data
func (*RequestError) Error ¶
func (e *RequestError) Error() string
Message text, the str form of the Python exception
func (*RequestError) ToErrorObj ¶
func (e *RequestError) ToErrorObj() *pyjson.Object
Error object with code, message and data in wire order
type RequestPermissionRequest ¶
type RequestPermissionRequest struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Options []PermissionOption `acp:"options,py=options,req"`
SessionID string `acp:"sessionId,py=session_id,req"`
ToolCall ToolCallUpdate `acp:"toolCall,py=tool_call,req"`
}
type RequestPermissionResponse ¶
type RequestPermissionResponse struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Outcome PermissionOutcome `acp:"outcome,py=outcome,req,union=DeniedOutcome|AllowedOutcome"`
}
type ResourceContentBlock ¶
type ResourceContentBlock struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Annotations *Annotations `acp:"annotations,py=annotations"`
Description *string `acp:"description,py=description"`
MimeType *string `acp:"mimeType,py=mime_type"`
Name string `acp:"name,py=name,req"`
Size *int `acp:"size,py=size"`
Title *string `acp:"title,py=title"`
URI string `acp:"uri,py=uri,req"`
// contains filtered or unexported fields
}
type ResourceContents ¶
type ResourceContents interface {
// contains filtered or unexported methods
}
type ResumeSessionRequest ¶
type ResumeSessionResponse ¶
type ResumeSessionResponse struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
ConfigOptions []SessionConfigOption `acp:"configOptions,py=config_options,union=SessionConfigOptionSelect|SessionConfigOptionBoolean"`
Models *SessionModelState `acp:"models,py=models"`
Modes *SessionModeState `acp:"modes,py=modes"`
}
type Route ¶
type Route struct {
Method string
Func RouteFunc
Kind string
Optional bool
DefaultResult any
AdaptResult func(any) any
WarnUnstable bool
}
One request or notification route of a message router
type SessionCapabilities ¶
type SessionCapabilities struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Close *SessionCloseCapabilities `acp:"close,py=close"`
Fork *SessionForkCapabilities `acp:"fork,py=fork"`
List *SessionListCapabilities `acp:"list,py=list"`
Resume *SessionResumeCapabilities `acp:"resume,py=resume"`
}
type SessionCloser ¶
type SessionCloser interface {
CloseSession(ctx context.Context, req *CloseSessionRequest) (*CloseSessionResponse, error)
}
Agent method answering session/close
type SessionConfigOption ¶
type SessionConfigOption interface {
// contains filtered or unexported methods
}
type SessionConfigOptionBoolean ¶
type SessionConfigOptionBoolean struct {
CurrentValue bool `acp:"currentValue,py=current_value,req"`
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Category *string `acp:"category,py=category"`
Description *string `acp:"description,py=description"`
ID string `acp:"id,py=id,req"`
Name string `acp:"name,py=name,req"`
// contains filtered or unexported fields
}
type SessionConfigOptionSelect ¶
type SessionConfigOptionSelect struct {
CurrentValue string `acp:"currentValue,py=current_value,req"`
Options any `acp:"options,py=options,req,union=list:SessionConfigSelectOption|list:SessionConfigSelectGroup"`
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Category *string `acp:"category,py=category"`
Description *string `acp:"description,py=description"`
ID string `acp:"id,py=id,req"`
Name string `acp:"name,py=name,req"`
// contains filtered or unexported fields
}
type SessionConfigSelectGroup ¶
type SessionConfigSelectGroup struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Group string `acp:"group,py=group,req"`
Name string `acp:"name,py=name,req"`
Options []SessionConfigSelectOption `acp:"options,py=options,req"`
}
type SessionCreator ¶
type SessionCreator interface {
NewSession(ctx context.Context, req *NewSessionRequest) (*NewSessionResponse, error)
}
Agent method answering session/new
type SessionForkCapabilities ¶
type SessionForker ¶
type SessionForker interface {
ForkSession(ctx context.Context, req *ForkSessionRequest) (*ForkSessionResponse, error)
}
Agent method answering session/fork
type SessionInfo ¶
type SessionInfoUpdate ¶
type SessionListCapabilities ¶
type SessionLister ¶
type SessionLister interface {
ListSessions(ctx context.Context, req *ListSessionsRequest) (*ListSessionsResponse, error)
}
Agent method answering session/list
type SessionLoader ¶
type SessionLoader interface {
LoadSession(ctx context.Context, req *LoadSessionRequest) (*LoadSessionResponse, error)
}
Agent method answering session/load
type SessionMode ¶
type SessionModeSetter ¶
type SessionModeSetter interface {
SetSessionMode(ctx context.Context, req *SetSessionModeRequest) (*SetSessionModeResponse, error)
}
Agent method answering session/set_mode
type SessionModeState ¶
type SessionModeState struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
AvailableModes []SessionMode `acp:"availableModes,py=available_modes,req"`
CurrentModeID string `acp:"currentModeId,py=current_mode_id,req"`
}
type SessionModelSetter ¶
type SessionModelSetter interface {
SetSessionModel(ctx context.Context, req *SetSessionModelRequest) (*SetSessionModelResponse, error)
}
Agent method answering session/set_model
type SessionModelState ¶
type SessionNotification ¶
type SessionNotification struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
SessionID string `acp:"sessionId,py=session_id,req"`
Update SessionUpdate `` /* 223-byte string literal not displayed */
}
type SessionResumer ¶
type SessionResumer interface {
ResumeSession(ctx context.Context, req *ResumeSessionRequest) (*ResumeSessionResponse, error)
}
Agent method answering session/resume
type SessionUpdate ¶
type SessionUpdate interface {
// contains filtered or unexported methods
}
type SetConfigOptionParams ¶
type SetConfigOptionParams struct {
Meta *pyjson.Object
ConfigID string
SessionID string
Value any
}
Shared fields of the boolean and select set config option requests
type SetSessionConfigOptionResponse ¶
type SetSessionConfigOptionResponse struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
ConfigOptions []SessionConfigOption `acp:"configOptions,py=config_options,req,union=SessionConfigOptionSelect|SessionConfigOptionBoolean"`
}
type SetSessionModeRequest ¶
type SetSessionModeResponse ¶
type SetSessionModelRequest ¶
type SetSessionModelResponse ¶
type SseMcpServer ¶
type SseMcpServer struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Headers []HttpHeader `acp:"headers,py=headers,req"`
Name string `acp:"name,py=name,req"`
URL string `acp:"url,py=url,req"`
// contains filtered or unexported fields
}
type StreamDirection ¶
type StreamDirection string
Direction of a raw JSON-RPC message seen by a stream observer
const ( StreamIncoming StreamDirection = "incoming" StreamOutgoing StreamDirection = "outgoing" )
type StreamEvent ¶
type StreamEvent struct {
Direction StreamDirection
Message any
}
One raw JSON-RPC message with its direction, a deep copy of the frame
type StreamObserver ¶
type StreamObserver func(event StreamEvent)
Callback receiving every raw JSON-RPC message of a connection
type TerminalAuthMethod ¶
type TerminalAuthMethod struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Args []string `acp:"args,py=args"`
Description *string `acp:"description,py=description"`
Env *pyjson.Object `acp:"env,py=env"`
ID string `acp:"id,py=id,req"`
Name string `acp:"name,py=name,req"`
// contains filtered or unexported fields
}
type TerminalExitStatus ¶
type TerminalOutputRequest ¶
type TerminalOutputResponse ¶
type TerminalOutputResponse struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
ExitStatus *TerminalExitStatus `acp:"exitStatus,py=exit_status"`
Output string `acp:"output,py=output,req"`
Truncated bool `acp:"truncated,py=truncated,req"`
}
type TerminalToolCallContent ¶
type TextContentBlock ¶
type TextContentBlock struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Annotations *Annotations `acp:"annotations,py=annotations"`
Text string `acp:"text,py=text,req"`
// contains filtered or unexported fields
}
type TextResourceContents ¶
type ToolCallContent ¶
type ToolCallContent interface {
// contains filtered or unexported methods
}
type ToolCallFields ¶
type ToolCallFields struct {
Title *string
Kind *string
Status *string
Content []ToolCallContent
Locations []ToolCallLocation
RawInput any
RawOutput any
}
Optional fields of a tool call start or progress update
type ToolCallLocation ¶
type ToolCallProgress ¶
type ToolCallProgress struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Content []ToolCallContent `acp:"content,py=content,union=ContentToolCallContent|FileEditToolCallContent|TerminalToolCallContent"`
Kind *string `acp:"kind,py=kind,enum=read|edit|delete|move|search|execute|think|fetch|switch_mode|other"`
Locations []ToolCallLocation `acp:"locations,py=locations"`
RawInput any `acp:"rawInput,py=raw_input"`
RawOutput any `acp:"rawOutput,py=raw_output"`
Status *string `acp:"status,py=status,enum=pending|in_progress|completed|failed"`
Title *string `acp:"title,py=title"`
ToolCallID string `acp:"toolCallId,py=tool_call_id,req"`
// contains filtered or unexported fields
}
func UpdateToolCall ¶
func UpdateToolCall(toolCallID string, f ToolCallFields) *ToolCallProgress
Tool call progress update
type ToolCallStart ¶
type ToolCallStart struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Content []ToolCallContent `acp:"content,py=content,union=ContentToolCallContent|FileEditToolCallContent|TerminalToolCallContent"`
Kind *string `acp:"kind,py=kind,enum=read|edit|delete|move|search|execute|think|fetch|switch_mode|other"`
Locations []ToolCallLocation `acp:"locations,py=locations"`
RawInput any `acp:"rawInput,py=raw_input"`
RawOutput any `acp:"rawOutput,py=raw_output"`
Status *string `acp:"status,py=status,enum=pending|in_progress|completed|failed"`
Title string `acp:"title,py=title,req"`
ToolCallID string `acp:"toolCallId,py=tool_call_id,req"`
// contains filtered or unexported fields
}
func StartToolCall ¶
func StartToolCall(toolCallID, title string, f ToolCallFields) *ToolCallStart
Tool call start update
type ToolCallUpdate ¶
type ToolCallUpdate struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Content []ToolCallContent `acp:"content,py=content,union=ContentToolCallContent|FileEditToolCallContent|TerminalToolCallContent"`
Kind *string `acp:"kind,py=kind,enum=read|edit|delete|move|search|execute|think|fetch|switch_mode|other"`
Locations []ToolCallLocation `acp:"locations,py=locations"`
RawInput any `acp:"rawInput,py=raw_input"`
RawOutput any `acp:"rawOutput,py=raw_output"`
Status *string `acp:"status,py=status,enum=pending|in_progress|completed|failed"`
Title *string `acp:"title,py=title"`
ToolCallID string `acp:"toolCallId,py=tool_call_id,req"`
}
type Usage ¶
type Usage struct {
CachedReadTokens *int `acp:"cachedReadTokens,py=cached_read_tokens"`
CachedWriteTokens *int `acp:"cachedWriteTokens,py=cached_write_tokens"`
InputTokens int `acp:"inputTokens,py=input_tokens,req"`
OutputTokens int `acp:"outputTokens,py=output_tokens,req"`
ThoughtTokens *int `acp:"thoughtTokens,py=thought_tokens"`
TotalTokens int `acp:"totalTokens,py=total_tokens,req"`
}
type UsageUpdate ¶
type UserMessageChunk ¶
type UserMessageChunk struct {
Meta *pyjson.Object `acp:"_meta,py=field_meta"`
Content ContentBlock `` /* 137-byte string literal not displayed */
MessageID *string `acp:"messageId,py=message_id"`
// contains filtered or unexported fields
}
func UpdateUserMessage ¶
func UpdateUserMessage(content ContentBlock) *UserMessageChunk
User message chunk update
func UpdateUserMessageText ¶
func UpdateUserMessageText(text string) *UserMessageChunk
User message chunk update of plain text
type ValidationError ¶
Pydantic ValidationError carrying the errors() list of a failed model_validate
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Pydantic str form listing each error with its location, message and input
func (*ValidationError) Errors ¶
func (e *ValidationError) Errors() []any
The errors() list as JSON values