acptypes

package
v0.3.20-beta Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package acptypes defines types for the Agent Client Protocol (ACP). ACP is a protocol for communication between AI coding agents and client applications (IDEs, text editors, or other UIs).

Index

Constants

View Source
const (
	ErrCodeParseError     = -32700
	ErrCodeInvalidRequest = -32600
	ErrCodeMethodNotFound = -32601
	ErrCodeInvalidParams  = -32602
	ErrCodeInternalError  = -32603
)

Standard JSON-RPC error codes

View Source
const (
	ContentTypeText         = "text"
	ContentTypeImage        = "image"
	ContentTypeAudio        = "audio"
	ContentTypeResource     = "resource"
	ContentTypeResourceLink = "resource_link"
)

ContentBlockType constants

View Source
const (
	UpdateAgentMessageChunk = "agent_message_chunk"
	UpdateUserMessageChunk  = "user_message_chunk"
	UpdateThoughtChunk      = "agent_thought_chunk"
	UpdateToolCall          = "tool_call"
	UpdateToolCallUpdate    = "tool_call_update"
	UpdatePlan              = "plan"
	UpdateAvailableCommands = "available_commands_update"
	UpdateModeChange        = "mode_change"
)

SessionUpdateType constants for session/update notifications

View Source
const ProtocolVersion = 1

ProtocolVersion is the ACP protocol version (major only)

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"`
	MCPCapabilities     *MCPCapabilities     `json:"mcpCapabilities,omitempty"`
	SessionCapabilities *SessionCapabilities `json:"sessionCapabilities,omitempty"`
	Meta                map[string]any       `json:"_meta,omitempty"`
}

AgentCapabilities advertised during initialization

type AgentMessageChunk

type AgentMessageChunk struct {
	SessionUpdate string       `json:"sessionUpdate"`
	Content       ContentBlock `json:"content"`
}

AgentMessageChunk represents an agent_message_chunk session update

type Annotations

type Annotations struct {
	Audience []string `json:"audience,omitempty"`
	Priority float64  `json:"priority,omitempty"`
}

Annotations provides metadata for content

type AuthMethod

type AuthMethod struct {
	Type string `json:"type"`
}

AuthMethod describes an authentication method

type AvailableCommand

type AvailableCommand struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Input       *AvailableCommandInput `json:"input,omitempty"`
}

AvailableCommand represents a slash command advertised to the client

type AvailableCommandInput

type AvailableCommandInput struct {
	Hint string `json:"hint,omitempty"`
}

AvailableCommandInput represents input specification for a command

type AvailableCommandsUpdate

type AvailableCommandsUpdate struct {
	SessionUpdate     string             `json:"sessionUpdate"`
	AvailableCommands []AvailableCommand `json:"availableCommands"`
}

AvailableCommandsUpdate represents an available_commands_update session update

type CancelRequest

type CancelRequest struct {
	SessionID SessionID `json:"sessionId"`
}

CancelRequest cancels an in-progress prompt

type ClientCapabilities

type ClientCapabilities struct {
	FS       *FSCapabilities `json:"fs,omitempty"`
	Terminal bool            `json:"terminal,omitempty"`
	Meta     map[string]any  `json:"_meta,omitempty"`
}

ClientCapabilities received during initialization

type ContentBlock

type ContentBlock struct {
	Type        string            `json:"type"`
	Text        string            `json:"text,omitempty"`
	Data        string            `json:"data,omitempty"`
	MimeType    string            `json:"mimeType,omitempty"`
	URI         string            `json:"uri,omitempty"`
	Name        string            `json:"name,omitempty"`
	Resource    *EmbeddedResource `json:"resource,omitempty"`
	Annotations *Annotations      `json:"annotations,omitempty"`
	Meta        map[string]any    `json:"_meta,omitempty"`
}

ContentBlock represents different content types in prompts and responses

type EmbeddedResource

type EmbeddedResource struct {
	URI      string `json:"uri"`
	MimeType string `json:"mimeType,omitempty"`
	Text     string `json:"text,omitempty"`
	Blob     string `json:"blob,omitempty"`
}

EmbeddedResource represents an embedded resource in content

type EnvMap

type EnvMap map[string]string

EnvMap is a custom type that can unmarshal from both map and array formats. It accepts either {"KEY": "VALUE"} or [{"name": "KEY", "value": "VALUE"}].

func (*EnvMap) UnmarshalJSON

func (e *EnvMap) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for EnvMap.

type FSCapabilities

type FSCapabilities struct {
	ReadTextFile  bool `json:"readTextFile,omitempty"`
	WriteTextFile bool `json:"writeTextFile,omitempty"`
}

FSCapabilities describes file system support

type Implementation

type Implementation struct {
	Name    string `json:"name"`
	Title   string `json:"title,omitempty"`
	Version string `json:"version,omitempty"`
}

Implementation provides info about a client or agent

type InitializeRequest

type InitializeRequest struct {
	ProtocolVersion    int                `json:"protocolVersion"`
	ClientCapabilities ClientCapabilities `json:"clientCapabilities"`
	ClientInfo         *Implementation    `json:"clientInfo,omitempty"`
}

InitializeRequest is sent by client to initialize the agent

type InitializeResponse

type InitializeResponse struct {
	ProtocolVersion   int               `json:"protocolVersion"`
	AgentCapabilities AgentCapabilities `json:"agentCapabilities"`
	AgentInfo         *Implementation   `json:"agentInfo,omitempty"`
	AuthMethods       []AuthMethod      `json:"authMethods"`
}

InitializeResponse is sent by agent in response to initialize

type LoadSessionRequest

type LoadSessionRequest struct {
	SessionID  SessionID      `json:"sessionId"`
	CWD        string         `json:"cwd"`
	MCPServers []MCPServer    `json:"mcpServers,omitempty"`
	Meta       map[string]any `json:"_meta,omitempty"`
}

LoadSessionRequest loads an existing session

type LoadSessionResponse

type LoadSessionResponse struct {
	Modes *SessionModeState `json:"modes,omitempty"`
	Meta  map[string]any    `json:"_meta,omitempty"`
}

LoadSessionResponse returns the loaded session info

type MCPCapabilities

type MCPCapabilities struct {
	HTTP bool `json:"http,omitempty"`
	SSE  bool `json:"sse,omitempty"`
}

MCPCapabilities describes MCP transport support

type MCPServer

type MCPServer struct {
	Name       string   `json:"name"`
	Type       string   `json:"type,omitempty"` // stdio, sse, http (streamable HTTP)
	Command    string   `json:"command,omitempty"`
	Args       []string `json:"args,omitempty"`
	Env        EnvMap   `json:"env,omitempty"`
	URL        string   `json:"url,omitempty"`
	AuthHeader string   `json:"authHeader,omitempty"`
}

MCPServer describes an MCP server provided by the client

type NewSessionRequest

type NewSessionRequest struct {
	CWD        string         `json:"cwd"`
	MCPServers []MCPServer    `json:"mcpServers,omitempty"`
	Meta       map[string]any `json:"_meta,omitempty"`
}

NewSessionRequest creates a new session

type NewSessionResponse

type NewSessionResponse struct {
	SessionID SessionID         `json:"sessionId"`
	Modes     *SessionModeState `json:"modes,omitempty"`
	Meta      map[string]any    `json:"_meta,omitempty"`
}

NewSessionResponse returns the new session ID

type Notification

type Notification struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Notification represents a JSON-RPC 2.0 notification (no ID)

type PlanEntry

type PlanEntry struct {
	Content  string            `json:"content"`
	Priority PlanEntryPriority `json:"priority"`
	Status   PlanEntryStatus   `json:"status"`
}

PlanEntry represents a single entry in an agent plan

type PlanEntryPriority

type PlanEntryPriority string

PlanEntryPriority represents the priority of a plan entry

const (
	PlanPriorityHigh   PlanEntryPriority = "high"
	PlanPriorityMedium PlanEntryPriority = "medium"
	PlanPriorityLow    PlanEntryPriority = "low"
)

PlanEntryPriority values

type PlanEntryStatus

type PlanEntryStatus string

PlanEntryStatus represents the status of a plan entry

const (
	PlanStatusPending    PlanEntryStatus = "pending"
	PlanStatusInProgress PlanEntryStatus = "in_progress"
	PlanStatusCompleted  PlanEntryStatus = "completed"
)

PlanEntryStatus values

type PlanUpdate

type PlanUpdate struct {
	SessionUpdate string      `json:"sessionUpdate"`
	Entries       []PlanEntry `json:"entries"`
}

PlanUpdate represents a plan session update

type PromptCapabilities

type PromptCapabilities struct {
	Image           bool `json:"image,omitempty"`
	Audio           bool `json:"audio,omitempty"`
	EmbeddedContext bool `json:"embeddedContext,omitempty"`
}

PromptCapabilities describes what content types the agent supports

type PromptRequest

type PromptRequest struct {
	SessionID SessionID      `json:"sessionId"`
	Prompt    []ContentBlock `json:"prompt"`
	Meta      map[string]any `json:"_meta,omitempty"`
}

PromptRequest sends a prompt to the agent

type PromptResponse

type PromptResponse struct {
	StopReason StopReason     `json:"stopReason"`
	Meta       map[string]any `json:"_meta,omitempty"`
}

PromptResponse indicates prompt completion

type RPCError

type RPCError struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

RPCError represents a JSON-RPC 2.0 error

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Request represents a JSON-RPC 2.0 request

type Response

type Response struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *RPCError       `json:"error,omitempty"`
}

Response represents a JSON-RPC 2.0 response

type SessionCapabilities

type SessionCapabilities struct {
	SetMode bool `json:"setMode,omitempty"`
}

SessionCapabilities describes session features

type SessionID

type SessionID string

SessionID uniquely identifies an ACP session

type SessionModeState

type SessionModeState struct {
	Mode    string   `json:"mode,omitempty"`
	Options []string `json:"options,omitempty"`
}

SessionModeState describes available session modes

type StopReason

type StopReason string

StopReason indicates why the agent stopped

const (
	StopReasonEndTurn         StopReason = "end_turn"
	StopReasonMaxTokens       StopReason = "max_tokens"
	StopReasonMaxTurnRequests StopReason = "max_turn_requests"
	StopReasonRefusal         StopReason = "refusal"
	StopReasonCancelled       StopReason = "cancelled"
)

StopReason values

type ThoughtChunk

type ThoughtChunk struct {
	SessionUpdate string       `json:"sessionUpdate"`
	Content       ContentBlock `json:"content"`
}

ThoughtChunk represents an agent_thought_chunk session update

type ToolCallContent

type ToolCallContent struct {
	Type    string       `json:"type"`
	Content ContentBlock `json:"content,omitempty"`
	Path    string       `json:"path,omitempty"`
	OldText string       `json:"oldText,omitempty"`
	NewText string       `json:"newText,omitempty"`
}

ToolCallContent represents content in a tool call result

type ToolCallStatus

type ToolCallStatus string

ToolCallStatus indicates the status of a tool call

const (
	ToolStatusPending    ToolCallStatus = "pending"
	ToolStatusInProgress ToolCallStatus = "in_progress"
	ToolStatusCompleted  ToolCallStatus = "completed"
	ToolStatusFailed     ToolCallStatus = "failed"
)

ToolCallStatus values

type ToolCallUpdate

type ToolCallUpdate struct {
	SessionUpdate string            `json:"sessionUpdate"`
	ToolCallID    string            `json:"toolCallId"`
	Title         string            `json:"title,omitempty"`
	Kind          ToolKind          `json:"kind,omitempty"`
	Status        ToolCallStatus    `json:"status"`
	RawInput      json.RawMessage   `json:"rawInput,omitempty"`
	Content       []ToolCallContent `json:"content,omitempty"`
}

ToolCallUpdate represents a tool_call session update

type ToolKind

type ToolKind string

ToolKind categorizes tools by their purpose

const (
	ToolKindRead    ToolKind = "read"
	ToolKindEdit    ToolKind = "edit"
	ToolKindExecute ToolKind = "execute"
	ToolKindSearch  ToolKind = "search"
	ToolKindFetch   ToolKind = "fetch"
	ToolKindThink   ToolKind = "think"
	ToolKindOther   ToolKind = "other"
)

ToolKind values

Jump to

Keyboard shortcuts

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