Documentation
¶
Overview ¶
Package acp provides Agent Client Protocol support. ACP standardizes communication between code editors and coding agents.
Index ¶
- type AgentCapabilities
- type AgentInfo
- type ClientCapabilities
- type ClientInfo
- type CommandInput
- type Error
- type InitializeRequest
- type InitializeResponse
- type NewSessionRequest
- type NewSessionResponse
- type Notification
- type PromptCapabilities
- type PromptPart
- type PromptRequest
- type PromptResponse
- type Request
- type Response
- type Server
- func (s *Server) OnPrompt(handler func(ctx context.Context, req *PromptRequest) (*PromptResponse, error))
- func (s *Server) Run(ctx context.Context) error
- func (s *Server) SendMessageChunk(sessionID, role, chunk string) error
- func (s *Server) SendToolCall(sessionID string, call *ToolCallUpdate) error
- type Session
- type SessionNotification
- type SessionUpdate
- type ToolCallUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentCapabilities ¶
type AgentCapabilities struct {
LoadSession bool `json:"loadSession,omitempty"`
PromptCapabilities PromptCapabilities `json:"promptCapabilities,omitempty"`
}
AgentCapabilities advertises agent features.
type ClientCapabilities ¶
type ClientCapabilities struct {
Terminal bool `json:"terminal,omitempty"`
ReadTextFile bool `json:"fs.readTextFile,omitempty"`
WriteTextFile bool `json:"fs.writeTextFile,omitempty"`
}
ClientCapabilities describes client features.
type ClientInfo ¶
ClientInfo describes the client.
type CommandInput ¶
CommandInput is a slash command.
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
Error is a JSON-RPC error.
type InitializeRequest ¶
type InitializeRequest struct {
ProtocolVersion string `json:"protocolVersion"`
ClientInfo ClientInfo `json:"clientInfo"`
Capabilities ClientCapabilities `json:"capabilities"`
}
InitializeRequest is the initialize request params.
type InitializeResponse ¶
type InitializeResponse struct {
ProtocolVersion string `json:"protocolVersion"`
AgentInfo AgentInfo `json:"agentInfo"`
Capabilities AgentCapabilities `json:"capabilities"`
}
InitializeResponse is the initialize response.
type NewSessionRequest ¶
NewSessionRequest creates a new session.
type NewSessionResponse ¶
type NewSessionResponse struct {
Session Session `json:"session"`
}
NewSessionResponse returns the session.
type Notification ¶
type Notification struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params interface{} `json:"params,omitempty"`
}
Notification is a JSON-RPC notification.
type PromptCapabilities ¶
type PromptCapabilities struct {
Image bool `json:"image,omitempty"`
Audio bool `json:"audio,omitempty"`
EmbeddedContext bool `json:"embeddedContext,omitempty"`
}
PromptCapabilities describes what prompts can contain.
type PromptPart ¶
type PromptPart struct {
Type string `json:"type"` // "text", "image", "audio"
Text string `json:"text,omitempty"`
Data string `json:"data,omitempty"` // base64
Mime string `json:"mimeType,omitempty"`
}
PromptPart is a part of a prompt.
type PromptRequest ¶
type PromptRequest struct {
SessionID string `json:"sessionId"`
Prompt []PromptPart `json:"prompt"`
Command *CommandInput `json:"command,omitempty"`
}
PromptRequest is a prompt turn request.
type PromptResponse ¶
type PromptResponse struct {
StopReason string `json:"stopReason"` // "endTurn", "cancelled", "error"
}
PromptResponse is the response to a prompt.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
Request is a JSON-RPC request.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Result interface{} `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
Response is a JSON-RPC response.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements an ACP agent server.
func NewServer ¶
func NewServer(info AgentInfo, caps AgentCapabilities) *Server
NewServer creates a new ACP server.
func (*Server) OnPrompt ¶
func (s *Server) OnPrompt(handler func(ctx context.Context, req *PromptRequest) (*PromptResponse, error))
OnPrompt sets the prompt handler.
func (*Server) SendMessageChunk ¶
SendMessageChunk sends a message chunk to the client.
func (*Server) SendToolCall ¶
func (s *Server) SendToolCall(sessionID string, call *ToolCallUpdate) error
SendToolCall sends a tool call update to the client.
type Session ¶
type Session struct {
ID string `json:"id"`
Metadata map[string]string `json:"metadata,omitempty"`
}
Session represents an agent session.
type SessionNotification ¶
type SessionNotification struct {
SessionID string `json:"sessionId"`
Update SessionUpdate `json:"update"`
}
SessionNotification notifies about session updates.
type SessionUpdate ¶
type SessionUpdate struct {
Type string `json:"type"` // "messageChunk", "toolCall", "planUpdate"
// For messageChunk
Role string `json:"role,omitempty"`
Chunk string `json:"chunk,omitempty"`
// For toolCall
ToolCall *ToolCallUpdate `json:"toolCall,omitempty"`
}
SessionUpdate is a session state update.