package acp import "encoding/json" // jsonRPCMessage is the raw JSON-RPC 2.0 envelope used over NDJSON. type jsonRPCMessage struct { JSONRPC string `json:"jsonrpc"` ID *int `json:"id,omitempty"` Method string `json:"method,omitempty"` Params json.RawMessage `json:"params,omitempty"` Result json.RawMessage `json:"result,omitempty"` Error *rpcError `json:"error,omitempty"` } // rpcError is a JSON-RPC 2.0 error object. type rpcError struct { Code int `json:"code"` Message string `json:"message"` Data any `json:"data,omitempty"` } // InitializeParams is sent once to negotiate the ACP session. type InitializeParams struct { ProtocolVersion int `json:"protocolVersion"` ClientCapabilities ClientCapabilities `json:"clientCapabilities"` ClientInfo ClientInfo `json:"clientInfo"` } // ClientCapabilities describes tools the client exposes to the agent. type ClientCapabilities struct { FS ClientFSCapabilities `json:"fs"` } // ClientFSCapabilities declares filesystem support. type ClientFSCapabilities struct { ReadTextFile bool `json:"readTextFile"` WriteTextFile bool `json:"writeTextFile"` } // ClientInfo identifies this client to the agent. type ClientInfo struct { Name string `json:"name"` Version string `json:"version"` } // InitializeResult is returned by the agent for initialize. type InitializeResult struct { ProtocolVersion int `json:"protocolVersion"` AgentCapabilities any `json:"agentCapabilities"` AgentInfo any `json:"agentInfo"` } // SessionNewParams starts a new agent session for a workspace. type SessionNewParams struct { Cwd string `json:"cwd"` MCPServers []any `json:"mcpServers"` } // SessionNewResult returns the session identifier. type SessionNewResult struct { SessionID string `json:"sessionId"` } // PromptMessage is a single user message part. type PromptMessage struct { Type string `json:"type"` Text string `json:"text"` } // SessionPromptParams sends user input to the agent. type SessionPromptParams struct { SessionID string `json:"sessionId"` Prompt []PromptMessage `json:"prompt"` } // SessionPromptResult is the final response for a prompt turn. type SessionPromptResult struct { StopReason string `json:"stopReason"` } // SessionCancelParams interrupts an in-flight turn. type SessionCancelParams struct { SessionID string `json:"sessionId"` } // SessionUpdateParams is the payload of a session/update notification. type SessionUpdateParams struct { SessionID string `json:"sessionId"` Update Update `json:"update"` } // Update carries a single streamed update from the agent. type Update struct { SessionUpdate string `json:"sessionUpdate"` MessageID string `json:"messageId,omitempty"` Content string `json:"content,omitempty"` ToolCallID string `json:"toolCallId,omitempty"` } // FSReadParams is sent by the agent to read a workspace file. type FSReadParams struct { Path string `json:"path"` SessionID string `json:"sessionId"` Line *int `json:"line,omitempty"` Limit *int `json:"limit,omitempty"` } // FSReadResult returns file contents to the agent. type FSReadResult struct { Content string `json:"content"` } // FSWriteParams is sent by the agent to write a workspace file. type FSWriteParams struct { Path string `json:"path"` SessionID string `json:"sessionId"` Content string `json:"content"` } // FSWriteResult is the empty success response for fs/write_text_file. type FSWriteResult struct{}