Documentation
¶
Index ¶
- Constants
- Variables
- type AgentCapabilities
- type AgentDef
- type AgentLoop
- func (al *AgentLoop) ExecutePrompt(ctx context.Context, prompt []ContentBlock) error
- func (al *AgentLoop) ReadFile(ctx context.Context, path string) (string, error)
- func (al *AgentLoop) RequestPermission(ctx context.Context, permType string, toolCall ToolCallUpdate) (bool, error)
- func (al *AgentLoop) RestoreConversation(messages []Message)
- func (al *AgentLoop) SetMode(mode string)
- func (al *AgentLoop) Stop()
- func (al *AgentLoop) WriteFile(ctx context.Context, path, content string) error
- type Annotations
- type ApprovalHandler
- type AuthEnvVar
- type AuthHandler
- type AuthMethod
- type AuthenticateParams
- type AuthenticateRequest
- type AuthenticateResponse
- type AuthenticateResult
- type AvailableCommand
- type AvailableCommandsUpdate
- type BlobResourceContents
- type CancelNotification
- type Client
- func (c *Client) Capabilities() AgentCapabilities
- func (c *Client) Close() error
- func (c *Client) Description() string
- func (c *Client) EnsureReady(ctx context.Context) error
- func (c *Client) Name() string
- func (c *Client) NewSession(ctx context.Context, cwd string) error
- func (c *Client) Prompt(ctx context.Context, prompt string) (*tool.ACPPromptResult, error)
- func (c *Client) PromptStream(ctx context.Context, prompt string, onEvent func(tool.ACPPromptEvent)) (*tool.ACPPromptResult, error)
- func (c *Client) SetApprovalHandler(h ApprovalHandler)
- func (c *Client) SetPermissionHandler(h PermissionHandler)
- func (c *Client) SetWorkingDir(dir string)
- func (c *Client) Start(ctx context.Context) error
- func (c *Client) Title() string
- type ClientCapabilities
- type ClientManager
- func (m *ClientManager) AgentInfo(name string) (title, description string, ok bool)
- func (m *ClientManager) Available() []string
- func (m *ClientManager) CloseAll()
- func (m *ClientManager) Get(ctx context.Context, name string) (tool.ACPAgentClient, error)
- func (m *ClientManager) SetApprovalHandler(h ApprovalHandler)
- func (m *ClientManager) SetPermissionHandler(h PermissionHandler)
- func (m *ClientManager) SetWorkingDir(dir string)
- type CloseSessionRequest
- type CloseSessionResponse
- type ConfigOptionUpdate
- type ContentBlock
- type CreateTerminalRequest
- type CreateTerminalResponse
- type CurrentModeUpdate
- type DeviceCodeResponse
- type DeviceTokenResponse
- type Diff
- type DiscoveredAgent
- type EmbeddedResource
- type EnvVariable
- type ErrAgentNotFound
- type ExtNotification
- type ExtRequest
- type ExtResponse
- type FSCapability
- type FSReadTextFileParams
- type FSReadTextFileResult
- type FSWriteTextFileParams
- type FSWriteTextFileResult
- type HTTPHeader
- type Handler
- type ImplementationInfo
- type InitializeParams
- type InitializeRequest
- type InitializeResponse
- type InitializeResult
- type JSONRPCError
- type JSONRPCNotification
- type JSONRPCRequest
- type JSONRPCResponse
- type KillTerminalRequest
- type KillTerminalResponse
- type ListSessionsRequest
- type ListSessionsResponse
- type LoadSessionRequest
- type LoadSessionResponse
- type MCPCapabilities
- type MCPManager
- type MCPServer
- type Message
- type NewSessionRequest
- type NewSessionResponse
- type PermissionHandler
- type PermissionOption
- type PermissionOptionId
- type PermissionOptionKind
- type PermissionRequest
- type PermissionRequestParams
- type PermissionResponseParams
- type Plan
- type PlanEntry
- type PlanEntryPriority
- type PlanEntryStatus
- type PromptCapabilities
- type PromptCompleteNotification
- type PromptRequest
- type PromptResponse
- type PromptResult
- type ReadTextFileRequest
- type ReadTextFileResponse
- type ReleaseTerminalRequest
- type ReleaseTerminalResponse
- type RequestID
- type RequestPermissionOutcome
- type RequestPermissionRequest
- type RequestPermissionResponse
- type ResumeSessionRequest
- type ResumeSessionResponse
- type SelectedPermissionOutcome
- type Session
- func (s *Session) AddMessage(role string, content []ContentBlock)
- func (s *Session) DoCancel()
- func (s *Session) HasMessages() bool
- func (s *Session) Messages() []Message
- func (s *Session) ReplaceConversation(msgs []Message)
- func (s *Session) Save(dir string) error
- func (s *Session) SaveDir() string
- func (s *Session) SetCancel(cancel func())
- func (s *Session) SetSaveDir(dir string)
- type SessionCancelParams
- type SessionCapabilities
- type SessionCloseCapabilities
- type SessionConfigGroupId
- type SessionConfigId
- type SessionConfigOption
- type SessionConfigSelectGroup
- type SessionConfigSelectOption
- type SessionConfigSelectOptions
- type SessionConfigValueId
- type SessionData
- type SessionInfo
- type SessionInfoUpdate
- type SessionListCapabilities
- type SessionLoadParams
- type SessionLoadResult
- type SessionMode
- type SessionModeId
- type SessionModeState
- type SessionNewParams
- type SessionNewResult
- type SessionNotification
- type SessionPromptParams
- type SessionPromptResult
- type SessionResumeCapabilities
- type SessionSetModeParams
- type SessionSetModeResult
- type SessionUpdate
- type SessionUpdateParams
- type SetSessionConfigOptionRequest
- type SetSessionConfigOptionResponse
- type SetSessionModeRequest
- type SetSessionModeResponse
- type StopReason
- type TerminalCreateParams
- type TerminalCreateResult
- type TerminalExitStatus
- type TerminalOutputParams
- type TerminalOutputRequest
- type TerminalOutputResponse
- type TextResourceContents
- type ToolCallContent
- type ToolCallContentEntry
- type ToolCallId
- type ToolCallLocation
- type ToolCallStatus
- type ToolCallSummary
- type ToolCallUpdate
- type ToolKind
- type Transport
- func (t *Transport) CloseWriter() error
- func (t *Transport) DeliverResponse(resp *JSONRPCResponse)
- func (t *Transport) ReadAnyMessage() (*JSONRPCRequest, *JSONRPCResponse, error)
- func (t *Transport) ReadMessage() (*JSONRPCRequest, error)
- func (t *Transport) ReadRaw() ([]byte, error)
- func (t *Transport) SendRequest(method string, params interface{}, timeout time.Duration) (json.RawMessage, error)
- func (t *Transport) WriteError(id RequestID, code int, msg string) error
- func (t *Transport) WriteErrorNilID(code int, msg string) error
- func (t *Transport) WriteNotification(method string, params interface{}) error
- func (t *Transport) WriteRaw(data []byte) error
- func (t *Transport) WriteResponse(id RequestID, result interface{}) error
- type WaitForTerminalExitRequest
- type WaitForTerminalExitResponse
- type WriteTextFileRequest
- type WriteTextFileResponse
Constants ¶
const ( ErrCodeParseError = -32700 ErrCodeInvalidRequest = -32600 ErrCodeMethodNotFound = -32601 ErrCodeInvalidParams = -32602 ErrCodeInternalError = -32603 )
JSON-RPC 2.0 error codes
const ( UpdateAgentMessageChunk = "agent_message_chunk" UpdateUserMessageChunk = "user_message_chunk" UpdateToolCall = "tool_call" UpdateToolCallUpdate = "tool_call_update" UpdatePlan = "plan" )
Session update type constants.
const ProtocolVersion = 1
Variables ¶
var KnownAgents = []AgentDef{ { Name: "copilot", Title: "GitHub Copilot", Binaries: []string{"copilot"}, ACPCommand: []string{"--acp"}, Description: "GitHub Copilot coding assistant — strong at GitHub workflows, code explanation, and refactoring", }, { Name: "droid", Title: "Droid (Factory)", Binaries: []string{"droid"}, ACPCommand: []string{"--acp"}, Description: "Droid AI coding agent by Factory — excels at autonomous code generation and multi-file refactoring", }, { Name: "opencode", Title: "OpenCode", Binaries: []string{"opencode"}, ACPCommand: []string{"acp"}, Description: "OpenCode terminal-based coding agent — lightweight agent with multi-provider LLM support", }, }
KnownAgents is the built-in registry of known ACP agents.
Functions ¶
This section is empty.
Types ¶
type AgentCapabilities ¶
type AgentCapabilities struct {
Meta json.RawMessage `json:"_meta,omitempty"`
LoadSession bool `json:"loadSession"`
PromptCapabilities *PromptCapabilities `json:"promptCapabilities,omitempty"`
MCPCapabilities *MCPCapabilities `json:"mcpCapabilities,omitempty"`
SessionCapabilities *SessionCapabilities `json:"sessionCapabilities,omitempty"`
}
type AgentDef ¶ added in v1.3.56
type AgentDef struct {
Name string // canonical name: "copilot", "droid", "opencode"
Title string // display name: "GitHub Copilot", "Droid"
Binaries []string // candidate binary names to search in $PATH
ACPCommand []string // args to start ACP mode, e.g. ["--acp"] or ["acp"]
Description string // short description for the tool registry
}
AgentDef describes a known ACP-compatible CLI tool.
type AgentLoop ¶
type AgentLoop struct {
// contains filtered or unexported fields
}
AgentLoop runs the headless agent loop for ACP sessions. It reuses ggcode's existing Agent.RunStreamWithContent and converts provider.StreamEvents into ACP session/update notifications.
func NewAgentLoop ¶
func NewAgentLoop( cfg *config.Config, registry *tool.Registry, transport *Transport, session *Session, clientCaps ClientCapabilities, prov provider.Provider, ) *AgentLoop
NewAgentLoop creates a new AgentLoop for the given session. It configures the agent identically to the TUI/daemon path:
- Project memory (GGCODE.md, AGENTS.md, etc.)
- Hook config (pre/post tool hooks)
- Auto compaction (via contextManager)
- Usage tracking
- Checkpoint support
- Vision support
func (*AgentLoop) ExecutePrompt ¶
func (al *AgentLoop) ExecutePrompt(ctx context.Context, prompt []ContentBlock) error
ExecutePrompt runs a single prompt through the agent loop. Stream events are converted to ACP session/update notifications.
func (*AgentLoop) RequestPermission ¶
func (al *AgentLoop) RequestPermission(ctx context.Context, permType string, toolCall ToolCallUpdate) (bool, error)
RequestPermission sends a permission request to the Client and waits for response.
func (*AgentLoop) RestoreConversation ¶ added in v1.1.49
RestoreConversation restores previously saved messages into the agent's context. Used by session/resume to rebuild the conversation history.
type Annotations ¶ added in v1.1.49
type Annotations struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Audience []string `json:"audience,omitempty"` // "user", "assistant"
Priority float64 `json:"priority,omitempty"`
LastModified string `json:"lastModified,omitempty"`
}
Annotations for content blocks.
type ApprovalHandler ¶ added in v1.3.56
ApprovalHandler is the host-side interactive approval bridge used when ACP requests need to flow through ggcode's existing approval UX.
type AuthEnvVar ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
AuthHandler manages ACP authentication.
func NewAuthHandler ¶
func NewAuthHandler(transport *Transport, sessionID string) *AuthHandler
NewAuthHandler creates a new auth handler.
func (*AuthHandler) HandleAgentAuth ¶
func (ah *AuthHandler) HandleAgentAuth(ctx context.Context) error
HandleAgentAuth performs GitHub Device Flow authentication. It sends the user_code and verification_uri to the Client via session/update notifications, then polls GitHub for the token.
func (*AuthHandler) HandleEnvVarAuth ¶
func (ah *AuthHandler) HandleEnvVarAuth(vars []AuthEnvVar) error
HandleEnvVarAuth validates that required environment variables are set.
type AuthMethod ¶
type AuthMethod struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"` // "agent" | "env_var" | "terminal"
Vars []AuthEnvVar `json:"vars,omitempty"`
Link string `json:"link,omitempty"`
Args []string `json:"args,omitempty"`
Env []EnvVariable `json:"env,omitempty"`
}
type AuthenticateParams ¶
type AuthenticateParams = AuthenticateRequest
Aliases so handler.go/agent_loop.go compile with minimal changes
type AuthenticateRequest ¶ added in v1.1.49
type AuthenticateRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
AuthMethodID string `json:"authMethodId"`
}
AuthenticateRequest for the authenticate method.
type AuthenticateResponse ¶ added in v1.1.49
type AuthenticateResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
}
AuthenticateResponse for the authenticate method response.
type AuthenticateResult ¶
type AuthenticateResult = AuthenticateResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type AvailableCommand ¶ added in v1.1.49
type AvailableCommand struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Input interface{} `json:"input,omitempty"` // AvailableCommandInput
}
AvailableCommand describes a slash command.
type AvailableCommandsUpdate ¶ added in v1.1.49
type AvailableCommandsUpdate struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
AvailableCommands []AvailableCommand `json:"availableCommands"`
}
AvailableCommandsUpdate notifies about slash command changes.
type BlobResourceContents ¶ added in v1.1.49
type BlobResourceContents struct {
Meta json.RawMessage `json:"_meta,omitempty"`
URI string `json:"uri"`
Blob string `json:"blob"` // base64
MIMEType string `json:"mimeType,omitempty"`
}
BlobResourceContents for binary resources.
type CancelNotification ¶ added in v1.1.49
type CancelNotification struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
}
CancelNotification cancels ongoing session work.
type Client ¶ added in v1.3.56
type Client struct {
// contains filtered or unexported fields
}
Client manages a single ACP agent process. It handles lifecycle (start/stop), session management, and prompt execution.
func NewClient ¶ added in v1.3.56
func NewClient(agent DiscoveredAgent, workingDir string, policy permission.PermissionPolicy, mcpServers []MCPServer) *Client
NewClient creates a new ACP client for the given discovered agent.
func (*Client) Capabilities ¶ added in v1.3.56
func (c *Client) Capabilities() AgentCapabilities
Capabilities returns the agent's declared capabilities (after initialize).
func (*Client) Close ¶ added in v1.3.56
Close sends session/close (if session exists) and kills the process.
func (*Client) Description ¶ added in v1.3.56
Description returns the agent description.
func (*Client) EnsureReady ¶ added in v1.3.56
func (*Client) NewSession ¶ added in v1.3.56
NewSession creates a new session on the agent.
func (*Client) Prompt ¶ added in v1.3.56
Prompt sends a prompt and collects the full response. Satisfies tool.ACPAgentClient by converting to tool types.
func (*Client) PromptStream ¶ added in v1.3.57
func (c *Client) PromptStream( ctx context.Context, prompt string, onEvent func(tool.ACPPromptEvent), ) (*tool.ACPPromptResult, error)
func (*Client) SetApprovalHandler ¶ added in v1.3.56
func (c *Client) SetApprovalHandler(h ApprovalHandler)
func (*Client) SetPermissionHandler ¶ added in v1.3.56
func (c *Client) SetPermissionHandler(h PermissionHandler)
SetPermissionHandler sets the handler for agent permission requests.
func (*Client) SetWorkingDir ¶ added in v1.3.56
type ClientCapabilities ¶
type ClientCapabilities struct {
Meta json.RawMessage `json:"_meta,omitempty"`
FS *FSCapability `json:"fs,omitempty"`
Terminal bool `json:"terminal,omitempty"`
}
type ClientManager ¶ added in v1.3.56
type ClientManager struct {
// contains filtered or unexported fields
}
ClientManager manages the lifecycle of all ACP agent clients.
func NewClientManager ¶ added in v1.3.56
func NewClientManager(workingDir string, policy permission.PermissionPolicy) *ClientManager
NewClientManager discovers ACP agents and stores their shared startup config. ACP delegates intentionally send an empty mcpServers array because MCP passthrough is disabled for stability.
func (*ClientManager) AgentInfo ¶ added in v1.3.56
func (m *ClientManager) AgentInfo(name string) (title, description string, ok bool)
AgentInfo returns display information for an agent.
func (*ClientManager) Available ¶ added in v1.3.56
func (m *ClientManager) Available() []string
Available returns the list of available agent names.
func (*ClientManager) CloseAll ¶ added in v1.3.56
func (m *ClientManager) CloseAll()
CloseAll shuts down all running agent processes.
func (*ClientManager) Get ¶ added in v1.3.56
func (m *ClientManager) Get(ctx context.Context, name string) (tool.ACPAgentClient, error)
Get returns a running client by name, starting it lazily if needed. Satisfies tool.ACPAgentRegistry.
func (*ClientManager) SetApprovalHandler ¶ added in v1.3.56
func (m *ClientManager) SetApprovalHandler(h ApprovalHandler)
func (*ClientManager) SetPermissionHandler ¶ added in v1.3.56
func (m *ClientManager) SetPermissionHandler(h PermissionHandler)
func (*ClientManager) SetWorkingDir ¶ added in v1.3.56
func (m *ClientManager) SetWorkingDir(dir string)
type CloseSessionRequest ¶ added in v1.1.49
type CloseSessionRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
}
CloseSessionRequest closes an active session.
type CloseSessionResponse ¶ added in v1.1.49
type CloseSessionResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
}
CloseSessionResponse is the response from closing a session.
type ConfigOptionUpdate ¶ added in v1.1.49
type ConfigOptionUpdate struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
ConfigOptions []SessionConfigOption `json:"configOptions"`
}
ConfigOptionUpdate notifies that config options changed.
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"` // "text", "image", "audio", "resource", "resource_link", "tool_use", "tool_result"
Meta json.RawMessage `json:"_meta,omitempty"`
Text string `json:"text,omitempty"`
ImageURL string `json:"imageUrl,omitempty"`
ImageMIME string `json:"imageMime,omitempty"`
ImageData string `json:"imageData,omitempty"`
AudioURL string `json:"audioUrl,omitempty"`
AudioMIME string `json:"audioMime,omitempty"`
AudioData string `json:"audioData,omitempty"`
Resource *EmbeddedResource `json:"resource,omitempty"`
URI string `json:"uri,omitempty"` // for resource_link
ToolName string `json:"toolName,omitempty"`
ToolID string `json:"toolId,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
Output string `json:"output,omitempty"`
IsError bool `json:"isError,omitempty"`
}
ContentBlock represents displayable information.
type CreateTerminalRequest ¶ added in v1.1.49
type CreateTerminalRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Command string `json:"command"`
Env []EnvVariable `json:"env,omitempty"`
CWD string `json:"cwd,omitempty"`
}
CreateTerminalRequest asks the client to create a terminal and run a command.
type CreateTerminalResponse ¶ added in v1.1.49
type CreateTerminalResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
TerminalID string `json:"terminalId"`
}
CreateTerminalResponse returns the terminal ID.
type CurrentModeUpdate ¶ added in v1.1.49
type CurrentModeUpdate struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
Mode SessionModeId `json:"mode"`
}
CurrentModeUpdate notifies that the session mode changed.
type DeviceCodeResponse ¶
type DeviceCodeResponse struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
DeviceCodeResponse represents GitHub's device code response.
type DeviceTokenResponse ¶
type DeviceTokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
Error string `json:"error,omitempty"`
}
DeviceTokenResponse represents GitHub's token polling response.
type Diff ¶ added in v1.1.49
type Diff struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Path string `json:"path"`
OldText string `json:"oldText,omitempty"`
NewText string `json:"newText,omitempty"`
}
Diff represents file modifications.
type DiscoveredAgent ¶ added in v1.3.56
DiscoveredAgent represents an agent found on the system.
func Discover ¶ added in v1.3.56
func Discover() []DiscoveredAgent
Discover scans $PATH for known ACP agents. Returns only agents whose binary is found and is executable.
type EmbeddedResource ¶ added in v1.1.49
type EmbeddedResource struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Text *TextResourceContents `json:"text,omitempty"`
Blob *BlobResourceContents `json:"blob,omitempty"`
}
EmbeddedResource contains resource content that can be embedded.
type EnvVariable ¶
type EnvVariable struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Name string `json:"name"`
Value string `json:"value"`
}
type ErrAgentNotFound ¶ added in v1.3.56
type ErrAgentNotFound struct {
// contains filtered or unexported fields
}
ErrAgentNotFound is returned when the requested agent is not installed.
func (ErrAgentNotFound) Error ¶ added in v1.3.56
func (e ErrAgentNotFound) Error() string
type ExtNotification ¶ added in v1.1.49
type ExtNotification struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
ExtNotification sends a custom notification not in spec.
type ExtRequest ¶ added in v1.1.49
type ExtRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ID RequestID `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
ExtRequest sends a custom request not in spec.
type ExtResponse ¶ added in v1.1.49
type ExtResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Result interface{} `json:"result,omitempty"`
}
ExtResponse responds to an ExtRequest.
type FSCapability ¶
type FSReadTextFileResult ¶
type FSReadTextFileResult = ReadTextFileResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type FSWriteTextFileParams ¶
type FSWriteTextFileParams = WriteTextFileRequest
Aliases so handler.go/agent_loop.go compile with minimal changes
type FSWriteTextFileResult ¶
type FSWriteTextFileResult = WriteTextFileResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type HTTPHeader ¶
type HTTPHeader struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Name string `json:"name"`
Value string `json:"value"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler processes ACP JSON-RPC requests and dispatches to appropriate methods.
func NewHandler ¶
func NewHandler(cfg *config.Config, registry *tool.Registry, transport *Transport, prov provider.Provider) *Handler
NewHandler creates a new ACP handler.
func (*Handler) Run ¶
Run starts the main ACP message loop. It reads messages from the transport and dispatches them to the appropriate handler methods. Supports bi-directional communication: Client requests are dispatched to handlers, and Client responses (to our Agent→Client requests) are delivered to pending callers.
type ImplementationInfo ¶
type ImplementationInfo struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Name string `json:"name"`
Title string `json:"title,omitempty"`
Version string `json:"version"`
}
type InitializeParams ¶
type InitializeParams = InitializeRequest
Old type names → new canonical names
type InitializeRequest ¶ added in v1.1.49
type InitializeRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ProtocolVersion int `json:"protocolVersion"`
ClientCapabilities ClientCapabilities `json:"clientCapabilities"`
ClientInfo *ImplementationInfo `json:"clientInfo,omitempty"`
}
InitializeRequest is sent by the client to establish connection.
type InitializeResponse ¶ added in v1.1.49
type InitializeResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ProtocolVersion int `json:"protocolVersion"`
AgentCapabilities AgentCapabilities `json:"agentCapabilities"`
AgentInfo ImplementationInfo `json:"agentInfo"`
AuthMethods []AuthMethod `json:"authMethods"`
}
InitializeResponse is the agent's response to initialize.
type InitializeResult ¶
type InitializeResult = InitializeResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type JSONRPCError ¶
type JSONRPCNotification ¶
type JSONRPCNotification struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"` // always "2.0"
ID RequestID `json:"id"` // nil for notifications
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID RequestID `json:"id"`
Result interface{} `json:"result,omitempty"`
RawResult json.RawMessage `json:"-"` // populated by ReadAnyMessage for SendRequest
Error *JSONRPCError `json:"error,omitempty"`
}
type KillTerminalRequest ¶ added in v1.1.49
type KillTerminalRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
TerminalID string `json:"terminalId"`
}
KillTerminalRequest kills a terminal without releasing it.
type KillTerminalResponse ¶ added in v1.1.49
type KillTerminalResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
}
KillTerminalResponse confirms the kill.
type ListSessionsRequest ¶ added in v1.1.49
type ListSessionsRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Cursor string `json:"cursor,omitempty"`
CWD string `json:"cwd,omitempty"`
}
ListSessionsRequest lists existing sessions.
type ListSessionsResponse ¶ added in v1.1.49
type ListSessionsResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Sessions []SessionInfo `json:"sessions"`
NextCursor string `json:"nextCursor,omitempty"`
}
ListSessionsResponse returns session info list.
type LoadSessionRequest ¶ added in v1.1.49
type LoadSessionRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
}
LoadSessionRequest loads a saved session.
type LoadSessionResponse ¶ added in v1.1.49
type LoadSessionResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
Messages []Message `json:"messages"`
}
LoadSessionResponse returns session data.
type MCPCapabilities ¶
type MCPCapabilities struct {
Meta json.RawMessage `json:"_meta,omitempty"`
HTTP bool `json:"http"`
SSE bool `json:"sse"`
}
type MCPManager ¶
type MCPManager struct {
// contains filtered or unexported fields
}
MCPManager manages dynamically connected MCP servers for ACP sessions. It connects servers, discovers their tools, registers them in the tool registry, and provides cleanup on Close().
func NewMCPManager ¶
func NewMCPManager(registry *tool.Registry) *MCPManager
NewMCPManager creates a new MCP manager.
func (*MCPManager) Close ¶
func (m *MCPManager) Close() error
Close shuts down all connected MCP servers.
func (*MCPManager) ConnectServers ¶
func (m *MCPManager) ConnectServers(ctx context.Context, servers []MCPServer) error
ConnectServers starts and connects the given MCP servers. Each server is initialized, its tools are discovered via tools/list, and registered in the tool registry with "mcp__" prefix.
type MCPServer ¶
type MCPServer struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Name string `json:"name"`
Type string `json:"type,omitempty"` // "http", "sse", "stdio" (default)
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env []EnvVariable `json:"env,omitempty"`
URL string `json:"url,omitempty"`
Headers []HTTPHeader `json:"headers,omitempty"`
}
MCPServer describes how to connect to an MCP server.
type Message ¶
type Message struct {
Role string // "user" or "assistant"
Content []ContentBlock
}
Message represents a single conversation message within a session.
type NewSessionRequest ¶ added in v1.1.49
type NewSessionRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
CWD string `json:"cwd"`
MCPServers []MCPServer `json:"mcpServers"`
}
NewSessionRequest creates a new conversation session.
func (NewSessionRequest) MarshalJSON ¶ added in v1.3.56
func (r NewSessionRequest) MarshalJSON() ([]byte, error)
type NewSessionResponse ¶ added in v1.1.49
type NewSessionResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
Modes *SessionModeState `json:"modes,omitempty"`
ConfigOptions []SessionConfigOption `json:"configOptions,omitempty"`
}
NewSessionResponse returns session info including available modes and config.
type PermissionHandler ¶ added in v1.3.56
type PermissionHandler func(ctx context.Context, req RequestPermissionRequest) (RequestPermissionResponse, error)
PermissionHandler is called when the agent requests permission. Return the response to send back to the agent.
type PermissionOption ¶ added in v1.1.49
type PermissionOption struct {
Meta json.RawMessage `json:"_meta,omitempty"`
OptionID PermissionOptionId `json:"optionId"`
Name string `json:"name"`
Kind PermissionOptionKind `json:"kind,omitempty"`
}
PermissionOption is an option presented to the user.
type PermissionOptionId ¶ added in v1.1.49
type PermissionOptionId = string
PermissionOptionId uniquely identifies a permission option.
type PermissionOptionKind ¶ added in v1.1.49
type PermissionOptionKind string
PermissionOptionKind categorizes the permission option.
const ( PermissionOptionAllowOnce PermissionOptionKind = "allow_once" PermissionOptionAllowAlways PermissionOptionKind = "allow_always" PermissionOptionRejectOnce PermissionOptionKind = "reject_once" PermissionOptionRejectAlways PermissionOptionKind = "reject_always" )
type PermissionRequest ¶
type PermissionRequest = ToolCallUpdate
PermissionRequest is the old name for the tool call being authorized
type PermissionRequestParams ¶
type PermissionRequestParams = RequestPermissionRequest
Permission request/response (old handler code)
type PermissionResponseParams ¶
type PermissionResponseParams = RequestPermissionResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type Plan ¶ added in v1.1.49
type Plan struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Entries []PlanEntry `json:"entries"`
}
Plan represents an agent's execution plan.
type PlanEntry ¶ added in v1.1.49
type PlanEntry struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Content string `json:"content"`
Priority PlanEntryPriority `json:"priority,omitempty"`
Status PlanEntryStatus `json:"status,omitempty"`
}
PlanEntry is a single task in the execution plan.
type PlanEntryPriority ¶ added in v1.1.49
type PlanEntryPriority string
const ( PlanEntryPriorityHigh PlanEntryPriority = "high" PlanEntryPriorityMedium PlanEntryPriority = "medium" PlanEntryPriorityLow PlanEntryPriority = "low" )
type PlanEntryStatus ¶ added in v1.1.49
type PlanEntryStatus string
const ( PlanEntryStatusPending PlanEntryStatus = "pending" PlanEntryStatusInProgress PlanEntryStatus = "in_progress" PlanEntryStatusCompleted PlanEntryStatus = "completed" PlanEntryStatusFailed PlanEntryStatus = "failed" )
type PromptCapabilities ¶
type PromptCapabilities struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Image bool `json:"image"`
Audio bool `json:"audio"`
EmbeddedContext bool `json:"embeddedContext"`
}
type PromptCompleteNotification ¶ added in v1.3.56
type PromptCompleteNotification struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
Response PromptResponse `json:"response"`
}
PromptCompleteNotification is emitted after the asynchronous ACP prompt loop actually finishes. The session/prompt RPC still returns immediately.
type PromptRequest ¶ added in v1.1.49
type PromptRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
Prompt []ContentBlock `json:"prompt"`
}
PromptRequest sends a user prompt to the agent.
type PromptResponse ¶ added in v1.1.49
type PromptResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
StopReason StopReason `json:"stopReason"`
}
PromptResponse contains the stop reason.
type PromptResult ¶ added in v1.3.56
type PromptResult struct {
Text string // agent's text response
StopReason StopReason // why the agent stopped
ToolCalls []ToolCallSummary // summary of tool calls made
}
PromptResult is the aggregated result of a prompt execution.
type ReadTextFileRequest ¶ added in v1.1.49
type ReadTextFileRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Path string `json:"path"`
}
ReadTextFileRequest asks the client to read a file.
type ReadTextFileResponse ¶ added in v1.1.49
type ReadTextFileResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Content string `json:"content"`
}
ReadTextFileResponse returns file contents.
type ReleaseTerminalRequest ¶ added in v1.1.49
type ReleaseTerminalRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
TerminalID string `json:"terminalId"`
}
ReleaseTerminalRequest releases terminal resources.
type ReleaseTerminalResponse ¶ added in v1.1.49
type ReleaseTerminalResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
}
ReleaseTerminalResponse confirms the release.
type RequestID ¶ added in v1.1.49
type RequestID = interface{} // string | int
RequestId is a JSON-RPC request identifier (string or integer).
type RequestPermissionOutcome ¶ added in v1.1.49
type RequestPermissionOutcome struct {
Outcome string `json:"outcome"` // "cancelled", "selected", "rejected"
SelectedOption *SelectedPermissionOutcome `json:"-"`
}
RequestPermissionOutcome is a discriminated union. ACP encodes the selected variant as {"outcome":"selected","optionId":"..."} rather than nesting the selected option in a child object. We keep the internal SelectedOption helper but flatten it on the wire, while still accepting the legacy nested form during unmarshal for compatibility.
func (RequestPermissionOutcome) MarshalJSON ¶ added in v1.3.57
func (o RequestPermissionOutcome) MarshalJSON() ([]byte, error)
func (*RequestPermissionOutcome) UnmarshalJSON ¶ added in v1.3.57
func (o *RequestPermissionOutcome) UnmarshalJSON(data []byte) error
type RequestPermissionRequest ¶ added in v1.1.49
type RequestPermissionRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
ToolCall *ToolCallUpdate `json:"toolCall,omitempty"`
Options []PermissionOption `json:"options"`
}
RequestPermissionRequest asks the client for user authorization.
type RequestPermissionResponse ¶ added in v1.1.49
type RequestPermissionResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Outcome RequestPermissionOutcome `json:"outcome"`
}
RequestPermissionResponse is the client's response to a permission request.
type ResumeSessionRequest ¶ added in v1.1.49
type ResumeSessionRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
CWD string `json:"cwd,omitempty"`
MCPServers []MCPServer `json:"mcpServers,omitempty"`
}
ResumeSessionRequest resumes an existing session.
type ResumeSessionResponse ¶ added in v1.1.49
type ResumeSessionResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Modes *SessionModeState `json:"modes,omitempty"`
ConfigOptions []SessionConfigOption `json:"configOptions,omitempty"`
}
ResumeSessionResponse returns session info after resume.
type SelectedPermissionOutcome ¶ added in v1.1.49
type SelectedPermissionOutcome struct {
Meta json.RawMessage `json:"_meta,omitempty"`
OptionID PermissionOptionId `json:"optionId"`
}
SelectedPermissionOutcome when user selected an option.
type Session ¶
type Session struct {
ID string
CWD string
MCPServers []MCPServer
CreatedAt time.Time
Cancel func()
// contains filtered or unexported fields
}
Session represents an active ACP session.
func LoadSession ¶
LoadSession loads a session from disk.
func NewSession ¶
NewSession creates a new session with a unique ID.
func (*Session) AddMessage ¶
func (s *Session) AddMessage(role string, content []ContentBlock)
AddMessage appends a message to the session conversation.
func (*Session) DoCancel ¶
func (s *Session) DoCancel()
DoCancel cancels the current operation for this session.
func (*Session) HasMessages ¶ added in v1.1.50
HasMessages returns true if the session has any conversation history.
func (*Session) ReplaceConversation ¶ added in v1.1.50
ReplaceConversation replaces the entire conversation history. Used after context compaction to store the compressed messages.
func (*Session) Save ¶
Save persists the session to disk. If the session has no conversation history, the file is deleted (or not created).
func (*Session) SetCancel ¶
func (s *Session) SetCancel(cancel func())
SetCancel sets the cancellation function for this session.
func (*Session) SetSaveDir ¶ added in v1.1.49
SetSaveDir sets the directory where session files are persisted.
type SessionCancelParams ¶
type SessionCancelParams = CancelNotification
Aliases so handler.go/agent_loop.go compile with minimal changes
type SessionCapabilities ¶ added in v1.1.49
type SessionCapabilities struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Close *SessionCloseCapabilities `json:"close,omitempty"`
List *SessionListCapabilities `json:"list,omitempty"`
Resume *SessionResumeCapabilities `json:"resume,omitempty"`
}
SessionCapabilities describes which optional session methods the agent supports.
type SessionCloseCapabilities ¶ added in v1.1.49
type SessionCloseCapabilities struct {
Meta json.RawMessage `json:"_meta,omitempty"`
}
type SessionConfigGroupId ¶ added in v1.1.49
type SessionConfigGroupId = string
SessionConfigGroupId identifies a group of config values.
type SessionConfigId ¶ added in v1.1.49
type SessionConfigId = string
SessionConfigId identifies a configuration option.
type SessionConfigOption ¶ added in v1.1.49
type SessionConfigOption struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Type string `json:"type"` // "select"
ID SessionConfigId `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Category string `json:"category,omitempty"` // "mode", "model", "thought_level", or other string
CurrentValue SessionConfigValueId `json:"currentValue"`
Options SessionConfigSelectOptions `json:"options"`
}
SessionConfigOption is a session configuration selector. Type discriminator: currently only "select" is defined.
type SessionConfigSelectGroup ¶ added in v1.1.49
type SessionConfigSelectGroup struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ID SessionConfigGroupId `json:"id"`
Name string `json:"name"`
Options []SessionConfigSelectOption `json:"options"`
}
SessionConfigSelectGroup is a named group of options.
type SessionConfigSelectOption ¶ added in v1.1.49
type SessionConfigSelectOption struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ID SessionConfigValueId `json:"id"`
Name string `json:"name"`
GroupID SessionConfigGroupId `json:"groupId,omitempty"`
}
SessionConfigSelectOption is a single selectable value.
type SessionConfigSelectOptions ¶ added in v1.1.49
type SessionConfigSelectOptions []interface{} // SessionConfigSelectOption | SessionConfigSelectGroup
SessionConfigSelectOptions is either a flat list or grouped list.
type SessionConfigValueId ¶ added in v1.1.49
type SessionConfigValueId = string
SessionConfigValueId identifies a value within a config option.
type SessionData ¶
type SessionData struct {
ID string `json:"id"`
CWD string `json:"cwd"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Messages []Message `json:"messages"`
MCPServers []MCPServer `json:"mcpServers,omitempty"`
}
SessionData is the JSON-serializable form of a session for persistence.
type SessionInfo ¶ added in v1.1.49
type SessionInfo struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
CWD string `json:"cwd,omitempty"`
Title string `json:"title,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
}
SessionInfo is summary info about a session.
type SessionInfoUpdate ¶ added in v1.1.49
type SessionInfoUpdate struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
Title string `json:"title,omitempty"`
}
SessionInfoUpdate notifies about session metadata changes.
type SessionListCapabilities ¶ added in v1.1.49
type SessionListCapabilities struct {
Meta json.RawMessage `json:"_meta,omitempty"`
}
type SessionLoadParams ¶
type SessionLoadParams = LoadSessionRequest
Aliases so handler.go/agent_loop.go compile with minimal changes
type SessionLoadResult ¶
type SessionLoadResult = LoadSessionResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type SessionMode ¶ added in v1.1.49
type SessionMode struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ID SessionModeId `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
}
SessionMode describes an available operating mode.
type SessionModeId ¶ added in v1.1.49
type SessionModeId = string
SessionModeId identifies a session mode.
type SessionModeState ¶ added in v1.1.49
type SessionModeState struct {
Modes []SessionMode `json:"modes"`
Current SessionModeId `json:"current"`
}
SessionModeState contains the list of available modes and the active one.
type SessionNewParams ¶
type SessionNewParams = NewSessionRequest
Aliases so handler.go/agent_loop.go compile with minimal changes
type SessionNewResult ¶
type SessionNewResult = NewSessionResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type SessionNotification ¶ added in v1.1.49
type SessionNotification struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
Update SessionUpdate `json:"update"`
}
SessionNotification is a session/update notification.
type SessionPromptParams ¶
type SessionPromptParams = PromptRequest
Aliases so handler.go/agent_loop.go compile with minimal changes
type SessionPromptResult ¶
type SessionPromptResult = PromptResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type SessionResumeCapabilities ¶ added in v1.1.49
type SessionResumeCapabilities struct {
Meta json.RawMessage `json:"_meta,omitempty"`
}
type SessionSetModeParams ¶
type SessionSetModeParams = SetSessionModeRequest
Aliases so handler.go/agent_loop.go compile with minimal changes
type SessionSetModeResult ¶
type SessionSetModeResult = SetSessionModeResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type SessionUpdate ¶
type SessionUpdate struct {
Type string `json:"sessionUpdate"` // discriminator: agent_message_chunk, tool_call, tool_call_update, plan, etc.
Meta json.RawMessage `json:"_meta,omitempty"`
// Content: polymorphic — single ContentBlock for messages, or []ToolCallContentEntry for tool_call_update.
// Using interface{} because ACP spec reuses the "content" key for both shapes.
Content interface{} `json:"content,omitempty"`
// Tool call fields (tool_call, tool_call_update) — flattened, not nested
ToolCallID string `json:"toolCallId,omitempty"`
Title string `json:"title,omitempty"`
Kind ToolKind `json:"kind,omitempty"`
Status ToolCallStatus `json:"status,omitempty"`
Locations []ToolCallLocation `json:"locations,omitempty"`
RawInput json.RawMessage `json:"rawInput,omitempty"`
RawOutput json.RawMessage `json:"rawOutput,omitempty"`
// Plan fields
Plan *Plan `json:"plan,omitempty"`
}
SessionUpdate is a flattened discriminated union for session/update notifications. Per ACP spec, all fields are direct children of the update object — no nesting.
type SessionUpdateParams ¶
type SessionUpdateParams = SessionNotification
Session update params (old notification wrapper)
type SetSessionConfigOptionRequest ¶ added in v1.1.49
type SetSessionConfigOptionRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
ConfigID SessionConfigId `json:"configId"`
Value SessionConfigValueId `json:"value"`
}
SetSessionConfigOptionRequest sets a config option value.
type SetSessionConfigOptionResponse ¶ added in v1.1.49
type SetSessionConfigOptionResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ConfigOptions []SessionConfigOption `json:"configOptions"`
}
SetSessionConfigOptionResponse returns updated config options.
type SetSessionModeRequest ¶ added in v1.1.49
type SetSessionModeRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
SessionID string `json:"sessionId"`
Mode SessionModeId `json:"mode"`
}
SetSessionModeRequest changes the active session mode.
type SetSessionModeResponse ¶ added in v1.1.49
type SetSessionModeResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
}
SetSessionModeResponse is the response for set_mode.
type StopReason ¶ added in v1.1.49
type StopReason string
StopReason describes why the agent stopped processing.
const ( StopReasonEndTurn StopReason = "end_turn" StopReasonMaxTokens StopReason = "max_tokens" StopReasonMaxTurns StopReason = "max_turns" StopReasonCancelled StopReason = "cancelled" StopReasonError StopReason = "error" StopReasonToolUse StopReason = "tool_use" )
type TerminalCreateParams ¶
type TerminalCreateParams = CreateTerminalRequest
Terminal (old types kept for compilation)
type TerminalCreateResult ¶
type TerminalCreateResult = CreateTerminalResponse
Aliases so handler.go/agent_loop.go compile with minimal changes
type TerminalExitStatus ¶ added in v1.1.49
type TerminalExitStatus struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ExitCode *int `json:"exitCode,omitempty"`
Signal string `json:"signal,omitempty"`
}
TerminalExitStatus describes how a terminal command exited.
type TerminalOutputParams ¶
type TerminalOutputParams = TerminalOutputRequest
Aliases so handler.go/agent_loop.go compile with minimal changes
type TerminalOutputRequest ¶ added in v1.1.49
type TerminalOutputRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
TerminalID string `json:"terminalId"`
}
TerminalOutputRequest asks for current terminal output.
type TerminalOutputResponse ¶ added in v1.1.49
type TerminalOutputResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Output string `json:"output"`
ExitStatus *TerminalExitStatus `json:"exitStatus,omitempty"`
Truncated bool `json:"truncated,omitempty"`
}
TerminalOutputResponse returns terminal output.
type TextResourceContents ¶ added in v1.1.49
type TextResourceContents struct {
Meta json.RawMessage `json:"_meta,omitempty"`
URI string `json:"uri"`
Text string `json:"text"`
}
TextResourceContents for text-based resources.
type ToolCallContent ¶ added in v1.1.49
type ToolCallContent struct {
Meta json.RawMessage `json:"_meta,omitempty"`
// Standard content fields
Type string `json:"type"` // "text", "image", "diff", "terminal"
Text string `json:"text,omitempty"`
// Diff fields
Diff *Diff `json:"diff,omitempty"`
// Terminal fields
TerminalID string `json:"terminalId,omitempty"`
}
ToolCallContent wraps tool call output content (standard content or diff).
type ToolCallContentEntry ¶ added in v1.1.49
type ToolCallContentEntry struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Type string `json:"type"` // "content", "diff", "terminal"
Content *ContentBlock `json:"content,omitempty"` // for type="content"
// Diff fields (type="diff")
Path string `json:"path,omitempty"`
OldText string `json:"oldText,omitempty"`
NewText string `json:"newText,omitempty"`
// Terminal fields (type="terminal")
TerminalID string `json:"terminalId,omitempty"`
}
ToolCallContentEntry is a content item within a tool call update.
type ToolCallId ¶ added in v1.1.49
type ToolCallId = string
ToolCallId identifies a tool call within a session.
type ToolCallLocation ¶ added in v1.1.49
type ToolCallLocation struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Path string `json:"path"`
Line *int `json:"line,omitempty"`
}
ToolCallLocation tracks file locations accessed by tools.
type ToolCallStatus ¶ added in v1.1.49
type ToolCallStatus string
ToolCallStatus tracks tool call lifecycle.
const ( ToolCallStatusPending ToolCallStatus = "pending" ToolCallStatusInProgress ToolCallStatus = "in_progress" ToolCallStatusCompleted ToolCallStatus = "completed" ToolCallStatusFailed ToolCallStatus = "failed" )
type ToolCallSummary ¶ added in v1.3.56
ToolCallSummary is a simplified view of a tool call for display.
type ToolCallUpdate ¶
type ToolCallUpdate struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ToolCallID ToolCallId `json:"toolCallId"`
Title string `json:"title,omitempty"`
Kind ToolKind `json:"kind,omitempty"`
Status ToolCallStatus `json:"status,omitempty"`
Content *ToolCallContent `json:"content,omitempty"`
RawInput json.RawMessage `json:"rawInput,omitempty"`
RawOutput json.RawMessage `json:"rawOutput,omitempty"`
Locations []ToolCallLocation `json:"locations,omitempty"`
}
ToolCallUpdate reports progress on a tool call.
type Transport ¶
type Transport struct {
Scanner *bufio.Scanner
Writer io.Writer
// contains filtered or unexported fields
}
Transport manages JSON-RPC 2.0 communication over stdio. All writes to the writer are protected by a mutex to ensure atomic messages. Supports bi-directional communication: both responding to Client requests and sending Agent→Client requests (e.g. session/request_permission, fs/read_text_file).
func NewTransport ¶
NewTransport creates a new Transport reading from r and writing to w.
func (*Transport) CloseWriter ¶
CloseWriter closes the underlying writer if it implements io.Closer.
func (*Transport) DeliverResponse ¶
func (t *Transport) DeliverResponse(resp *JSONRPCResponse)
DeliverResponse delivers a response from the Client to a pending SendRequest caller. Called by the Handler's message loop when it receives a JSON-RPC response.
func (*Transport) ReadAnyMessage ¶
func (t *Transport) ReadAnyMessage() (*JSONRPCRequest, *JSONRPCResponse, error)
ReadAnyMessage reads the next JSON-RPC message, which can be either a request (from Client) or a response (to a pending Agent→Client request). Returns (request, nil, nil) for Client requests, (nil, response, nil) for responses to our pending requests, (nil, nil, nil) for empty lines (skip), (nil, nil, io.EOF) when stream ends.
func (*Transport) ReadMessage ¶
func (t *Transport) ReadMessage() (*JSONRPCRequest, error)
ReadMessage reads and parses the next JSON-RPC request from stdin. Returns io.EOF when the input stream is closed.
func (*Transport) ReadRaw ¶
ReadRaw reads the next raw line from the transport. Returns the bytes without parsing. Returns io.EOF when the input stream is closed. This is primarily useful for testing.
func (*Transport) SendRequest ¶
func (t *Transport) SendRequest(method string, params interface{}, timeout time.Duration) (json.RawMessage, error)
SendRequest sends a JSON-RPC request to the Client and waits for the response. This is used for Agent→Client requests like session/request_permission and fs/read_text_file. Returns the raw response result or an error.
func (*Transport) WriteError ¶
WriteError writes a JSON-RPC error response.
func (*Transport) WriteErrorNilID ¶
WriteErrorNilID writes a JSON-RPC error response with a nil ID.
func (*Transport) WriteNotification ¶
WriteNotification writes a JSON-RPC notification (no ID).
func (*Transport) WriteRaw ¶
WriteRaw writes a raw byte slice to the transport followed by a newline. This is primarily useful for testing — production code should use SendMessage or SendNotification.
func (*Transport) WriteResponse ¶
WriteResponse writes a JSON-RPC response with the given result.
type WaitForTerminalExitRequest ¶ added in v1.1.49
type WaitForTerminalExitRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
TerminalID string `json:"terminalId"`
}
WaitForTerminalExitRequest waits for terminal command to exit.
type WaitForTerminalExitResponse ¶ added in v1.1.49
type WaitForTerminalExitResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
ExitStatus TerminalExitStatus `json:"exitStatus"`
}
WaitForTerminalExitResponse returns the exit status.
type WriteTextFileRequest ¶ added in v1.1.49
type WriteTextFileRequest struct {
Meta json.RawMessage `json:"_meta,omitempty"`
Path string `json:"path"`
Content string `json:"content"`
}
WriteTextFileRequest asks the client to write a file.
type WriteTextFileResponse ¶ added in v1.1.49
type WriteTextFileResponse struct {
Meta json.RawMessage `json:"_meta,omitempty"`
}
WriteTextFileResponse confirms the write.