acp

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package acp provides Agent Client Protocol support. ACP standardizes communication between code editors and coding agents.

Index

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 AgentInfo

type AgentInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

AgentInfo describes the agent.

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

type ClientInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

ClientInfo describes the client.

type CommandInput

type CommandInput struct {
	Name  string `json:"name"`
	Input string `json:"input,omitempty"`
}

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

type NewSessionRequest struct {
	Metadata map[string]string `json:"metadata,omitempty"`
}

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) Run

func (s *Server) Run(ctx context.Context) error

Run starts the server loop.

func (*Server) SendMessageChunk

func (s *Server) SendMessageChunk(sessionID, role, chunk string) error

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.

type ToolCallUpdate

type ToolCallUpdate struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"` // "running", "completed", "error"
	Input  string `json:"input,omitempty"`
	Output string `json:"output,omitempty"`
}

ToolCallUpdate is a tool call notification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL