acp

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package acp speaks the Agent Client Protocol, which editors and agents talk to each other in: JSON-RPC 2.0 messages, one to a line, over a stream both ends read and write. It holds the connection, the messages of the protocol and the names of its methods, for an agent that serves an editor and for a client that drives an agent alike

Index

Constants

View Source
const (
	MethodInitialize             = "initialize"
	MethodAuthenticate           = "authenticate"
	MethodSessionNew             = "session/new"
	MethodSessionLoad            = "session/load"
	MethodSessionList            = "session/list"
	MethodSessionClose           = "session/close"
	MethodSessionFork            = "session/fork"
	MethodSessionResume          = "session/resume"
	MethodSessionPrompt          = "session/prompt"
	MethodSessionCancel          = "session/cancel"
	MethodSessionSetMode         = "session/set_mode"
	MethodSessionSetModel        = "session/set_model"
	MethodSessionSetConfigOption = "session/set_config_option"
)

Methods an agent answers

View Source
const (
	MethodSessionUpdate            = "session/update"
	MethodSessionRequestPermission = "session/request_permission"
	MethodElicitationCreate        = "elicitation/create"
	MethodFSReadTextFile           = "fs/read_text_file"
	MethodFSWriteTextFile          = "fs/write_text_file"
	MethodTerminalCreate           = "terminal/create"
	MethodTerminalOutput           = "terminal/output"
	MethodTerminalRelease          = "terminal/release"
	MethodTerminalWaitForExit      = "terminal/wait_for_exit"
	MethodTerminalKill             = "terminal/kill"
)

Methods a client answers

View Source
const (
	StopEndTurn         = "end_turn"
	StopMaxTokens       = "max_tokens"
	StopMaxTurnRequests = "max_turn_requests"
	StopRefusal         = "refusal"
	StopCancelled       = "cancelled"
)

Why a prompt stopped being answered

View Source
const (
	ToolPending    = "pending"
	ToolInProgress = "in_progress"
	ToolCompleted  = "completed"
	ToolFailed     = "failed"
)

How a call of a tool stands

View Source
const (
	KindRead       = "read"
	KindEdit       = "edit"
	KindDelete     = "delete"
	KindMove       = "move"
	KindSearch     = "search"
	KindExecute    = "execute"
	KindThink      = "think"
	KindFetch      = "fetch"
	KindSwitchMode = "switch_mode"
	KindOther      = "other"
)

What kind of work a call of a tool is, which decides how an editor shows it

View Source
const (
	AllowOnce    = "allow_once"
	AllowAlways  = "allow_always"
	RejectOnce   = "reject_once"
	RejectAlways = "reject_always"
)

What an answer to a request for permission does

View Source
const (
	PlanPending    = "pending"
	PlanInProgress = "in_progress"
	PlanCompleted  = "completed"
	PriorityHigh   = "high"
	PriorityMedium = "medium"
	PriorityLow    = "low"
)

How a step of a plan stands, and how much it matters

View Source
const (
	CodeParseError       = -32700
	CodeInvalidRequest   = -32600
	CodeMethodNotFound   = -32601
	CodeInvalidParams    = -32602
	CodeInternalError    = -32603
	CodeAuthRequired     = -32000
	CodeResourceNotFound = -32002
	CodeRequestCancelled = -32800
)

Codes of the failures a request is answered with: those of JSON-RPC, and the protocol's own

View Source
const (
	DefaultLineLimit = 50 << 20
)

Longest line a connection reads unless it is told another, which leaves room for the pictures a prompt may carry, and how long the requests being answered are given to finish once the other end wrote its last

View Source
const MethodCancelRequest = "$/cancel_request"

Notification either end sends to say it no longer waits for the answer to a request it made

View Source
const ProtocolVersion = 1

Version of the protocol the package speaks

Variables

View Source
var ErrClosed = errors.New("The connection to the other end closed.")

The stream ended or was closed while an answer was waited for

Functions

func RequestID

func RequestID(ctx context.Context) json.RawMessage

Id the other end gave the request a handler answers, as it wrote it. Empty outside the answer to a request

Types

type AgentCapabilities

type AgentCapabilities struct {
	Meta                Meta                 `json:"_meta,omitempty"`
	LoadSession         bool                 `json:"loadSession,omitempty"`
	PromptCapabilities  *PromptCapabilities  `json:"promptCapabilities,omitempty"`
	MCPCapabilities     *MCPCapabilities     `json:"mcpCapabilities,omitempty"`
	SessionCapabilities *SessionCapabilities `json:"sessionCapabilities,omitempty"`
}

What an agent can do: load a session it kept, what a prompt may carry, the kinds of MCP server it connects to, and what it does with sessions beside answering them

type Annotations

type Annotations struct {
	Meta         Meta     `json:"_meta,omitempty"`
	Audience     []string `json:"audience,omitempty"`
	LastModified string   `json:"lastModified,omitempty"`
	Priority     *float64 `json:"priority,omitempty"`
}

Who a block of content is for, and how much it matters

type AuthEnvVar

type AuthEnvVar struct {
	Meta     Meta   `json:"_meta,omitempty"`
	Name     string `json:"name"`
	Label    string `json:"label,omitempty"`
	Optional bool   `json:"optional,omitempty"`
	Secret   bool   `json:"secret,omitempty"`
}

A variable a way of signing in asks the user for

type AuthMethod

type AuthMethod struct {
	Meta        Meta              `json:"_meta,omitempty"`
	Type        string            `json:"type,omitempty"`
	ID          string            `json:"id"`
	Name        string            `json:"name"`
	Description string            `json:"description,omitempty"`
	Link        string            `json:"link,omitempty"`
	Vars        []AuthEnvVar      `json:"vars,omitempty"`
	Args        []string          `json:"args,omitempty"`
	Env         map[string]string `json:"env,omitempty"`
}

A way of signing in an agent offers. One with no type is the agent's own to run. env_var asks the client to set variables, and terminal has the client run the agent in a terminal with the arguments and variables given

type AuthenticateRequest

type AuthenticateRequest struct {
	Meta     Meta   `json:"_meta,omitempty"`
	MethodID string `json:"methodId"`
}

type AvailableCommand

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

type AvailableCommands

type AvailableCommands struct {
	Meta              Meta               `json:"_meta,omitempty"`
	AvailableCommands []AvailableCommand `json:"availableCommands"`
}

type ClientCapabilities

type ClientCapabilities struct {
	Meta        Meta                    `json:"_meta,omitempty"`
	FS          *FileSystemCapabilities `json:"fs,omitempty"`
	Terminal    bool                    `json:"terminal,omitempty"`
	Elicitation *ElicitationCapability  `json:"elicitation,omitempty"`
}

What a client does for the agent: reading and writing files as the editor holds them, running commands in its terminals, and asking its person questions in a form

type CommandInput

type CommandInput struct {
	Meta Meta   `json:"_meta,omitempty"`
	Hint string `json:"hint"`
}

What a command takes after its name, as a hint shown where it is typed

type ConfigChoice

type ConfigChoice struct {
	Meta        Meta   `json:"_meta,omitempty"`
	Value       string `json:"value"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

One choice of an option of a session

type ConfigGroup

type ConfigGroup struct {
	Meta    Meta           `json:"_meta,omitempty"`
	Group   string         `json:"group"`
	Name    string         `json:"name"`
	Options []ConfigChoice `json:"options"`
}

Choices of an option under a heading of their own

type ConfigOptions

type ConfigOptions struct {
	Meta          Meta                  `json:"_meta,omitempty"`
	ConfigOptions []SessionConfigOption `json:"configOptions"`
}

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

One end of a conversation in the protocol over a stream: it answers what the other end asks through its handler, and asks the other end in turn

func NewConn

func NewConn(reader io.Reader, writer io.Writer, handler Handler) *Conn

A connection that reads the other end from the reader and writes to it through the writer, answering through the handler. Nothing is read until it is served

func (*Conn) Call

func (c *Conn) Call(ctx context.Context, method string, params, result any) error

Asks the other end and waits for its answer, which is read into result unless that is nil. A failure the other end answers with is an *Error. The request is given up once the context is done, which the other end is told

func (*Conn) Close

func (c *Conn) Close() error

Ends the connection: what is being answered is stopped, and whatever waits for an answer fails. The stream is the caller's to close

func (*Conn) Done

func (c *Conn) Done() <-chan struct{}

Closed once the connection was served to its end, with everything it was answering over

func (*Conn) Limit

func (c *Conn) Limit(longest int) *Conn

Sets the longest line the connection reads, before it is served

func (*Conn) Notify

func (c *Conn) Notify(method string, params any) error

Tells the other end something it sends no answer to

func (*Conn) Serve

func (c *Conn) Serve(ctx context.Context) error

Reads the other end until its stream ends, the context is done or the connection is closed, answering what it asks. It returns nil for a stream that ended, and what went wrong otherwise. Every request still waiting for its answer fails once it returns

func (*Conn) Settle

func (c *Conn) Settle(ctx context.Context) error

Waits until every notification that had arrived by now was handed over. An answer is read as soon as it arrives, ahead of the notifications that came before it and still wait their turn, so whoever acts on an answer by what the other end told before it settles first. It returns early with the failure of a context that is done, and at once for a connection that ended. Never called from a handler of notifications, which would wait for itself

type ContentBlock

type ContentBlock struct {
	Text     *TextContent
	Image    *MediaContent
	Audio    *MediaContent
	Link     *ResourceLink
	Resource *EmbeddedResource
	// The kind of a block that is none of the above, and the block as it came
	Other string
	Raw   json.RawMessage
}

One block of content: text, a picture, a sound, a link to a resource or a resource itself. One of them is set. A block of a kind this package does not know keeps its kind and what it held

func TextBlock

func TextBlock(text string) ContentBlock

A block of text

func (ContentBlock) MarshalJSON

func (b ContentBlock) MarshalJSON() ([]byte, error)

func (*ContentBlock) UnmarshalJSON

func (b *ContentBlock) UnmarshalJSON(data []byte) error

type Cost

type Cost struct {
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`
}

type CreateTerminalRequest

type CreateTerminalRequest struct {
	Meta            Meta     `json:"_meta,omitempty"`
	SessionID       string   `json:"sessionId"`
	Command         string   `json:"command"`
	Args            []string `json:"args,omitempty"`
	Cwd             string   `json:"cwd,omitempty"`
	Env             []Named  `json:"env,omitempty"`
	OutputByteLimit *int     `json:"outputByteLimit,omitempty"`
}

type CreateTerminalResponse

type CreateTerminalResponse struct {
	Meta       Meta   `json:"_meta,omitempty"`
	TerminalID string `json:"terminalId"`
}

type CurrentMode

type CurrentMode struct {
	Meta          Meta   `json:"_meta,omitempty"`
	CurrentModeID string `json:"currentModeId"`
}

type Diff

type Diff struct {
	Meta    Meta    `json:"_meta,omitempty"`
	Path    string  `json:"path"`
	OldText *string `json:"oldText,omitempty"`
	NewText string  `json:"newText"`
}

A change to a file as a call of a tool makes it: the text it had, none for a new file, and the text it gets

type ElicitationCapability

type ElicitationCapability struct {
	Form map[string]any `json:"form,omitempty"`
	URL  map[string]any `json:"url,omitempty"`
}

The ways a client asks its person something for the agent, each present when the client has it

type ElicitationRequest

type ElicitationRequest struct {
	Meta            Meta           `json:"_meta,omitempty"`
	SessionID       string         `json:"sessionId"`
	Mode            string         `json:"mode"`
	Message         string         `json:"message"`
	RequestedSchema map[string]any `json:"requestedSchema,omitempty"`
}

Asks the user of a client something in a form whose fields a schema describes

type ElicitationResponse

type ElicitationResponse struct {
	Meta    Meta           `json:"_meta,omitempty"`
	Action  string         `json:"action"`
	Content map[string]any `json:"content,omitempty"`
}

What the user did with a form: accept with what they filled in, decline, or cancel

type EmbeddedResource

type EmbeddedResource struct {
	Meta        Meta             `json:"_meta,omitempty"`
	Annotations *Annotations     `json:"annotations,omitempty"`
	Resource    ResourceContents `json:"resource"`
}

A resource handed over whole

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data,omitempty"`
}

A failure a request is answered with

func AuthRequired

func AuthRequired(why string) *Error

The agent takes no requests of sessions until the client authenticated

func InternalError

func InternalError(why string) *Error

The request failed on this end, for the reason given

func InvalidParams

func InvalidParams(why string) *Error

What a request was sent with can't be what the method takes, for the reason given

func MethodNotFound

func MethodNotFound(method string) *Error

The other end has no such method

func NotFound

func NotFound(what string) *Error

There is no such session, file or other thing the request names

func (*Error) Error

func (e *Error) Error() string

type FileSystemCapabilities

type FileSystemCapabilities struct {
	Meta          Meta `json:"_meta,omitempty"`
	ReadTextFile  bool `json:"readTextFile,omitempty"`
	WriteTextFile bool `json:"writeTextFile,omitempty"`
}

type Handler

type Handler interface {
	// Answers a request with what is sent back, an empty object for nothing, or with the failure it is refused with. The context ends
	// once the connection does, or once the other end says it no longer waits for the answer
	Request(ctx context.Context, method string, params json.RawMessage) (any, error)
	// Takes a notification. Notifications are handed over one at a time, in the order they arrived
	Notification(ctx context.Context, method string, params json.RawMessage)
}

What answers the other end of a connection

type Implementation

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

A program that speaks the protocol, as it names itself

type InitializeRequest

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

The first request of a client: the version of the protocol it speaks and what it can do for the agent

type InitializeResponse

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

type ListSessionsRequest

type ListSessionsRequest struct {
	Meta   Meta   `json:"_meta,omitempty"`
	Cwd    string `json:"cwd,omitempty"`
	Cursor string `json:"cursor,omitempty"`
}

type ListSessionsResponse

type ListSessionsResponse struct {
	Meta       Meta          `json:"_meta,omitempty"`
	Sessions   []SessionInfo `json:"sessions"`
	NextCursor string        `json:"nextCursor,omitempty"`
}

type MCPCapabilities

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

type MCPServer

type MCPServer struct {
	Meta    Meta     `json:"_meta,omitempty"`
	Type    string   `json:"type,omitempty"`
	Name    string   `json:"name"`
	Command string   `json:"command,omitempty"`
	Args    []string `json:"args,omitempty"`
	Env     []Named  `json:"env,omitempty"`
	URL     string   `json:"url,omitempty"`
	Headers []Named  `json:"headers,omitempty"`
}

An MCP server a client hands a session: one started as a program when it has no type, or one reached over HTTP or SSE

type MediaContent

type MediaContent struct {
	Meta        Meta         `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Data        string       `json:"data"`
	MimeType    string       `json:"mimeType"`
	URI         string       `json:"uri,omitempty"`
}

A picture or a sound, its bytes in base64

type MessageChunk

type MessageChunk struct {
	Meta      Meta         `json:"_meta,omitempty"`
	Content   ContentBlock `json:"content"`
	MessageID string       `json:"messageId,omitempty"`
}

A part of a message of the user, of the agent, or of what it thought

type Meta

type Meta = map[string]any

What either end may add to a message beside what the protocol says it holds

type ModelInfo

type ModelInfo struct {
	Meta        Meta   `json:"_meta,omitempty"`
	ModelID     string `json:"modelId"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

type Named

type Named struct {
	Meta  Meta   `json:"_meta,omitempty"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

A variable or a header by its name

type PermissionOption

type PermissionOption struct {
	Meta     Meta   `json:"_meta,omitempty"`
	OptionID string `json:"optionId"`
	Name     string `json:"name"`
	Kind     string `json:"kind"`
}

One answer a user may give a request for permission

type PermissionOutcome

type PermissionOutcome struct {
	// The option picked, empty when the prompt was stopped
	OptionID  string
	Cancelled bool
}

What a user answered a request for permission with: the option they picked, or nothing, the prompt having been stopped

func (PermissionOutcome) MarshalJSON

func (o PermissionOutcome) MarshalJSON() ([]byte, error)

func (*PermissionOutcome) UnmarshalJSON

func (o *PermissionOutcome) UnmarshalJSON(data []byte) error

type Plan

type Plan struct {
	Meta    Meta        `json:"_meta,omitempty"`
	Entries []PlanEntry `json:"entries"`
}

type PlanEntry

type PlanEntry struct {
	Meta     Meta   `json:"_meta,omitempty"`
	Content  string `json:"content"`
	Priority string `json:"priority"`
	Status   string `json:"status"`
}

type PromptCapabilities

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

type PromptRequest

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

type PromptResponse

type PromptResponse struct {
	Meta          Meta   `json:"_meta,omitempty"`
	StopReason    string `json:"stopReason"`
	Usage         *Usage `json:"usage,omitempty"`
	UserMessageID string `json:"userMessageId,omitempty"`
}

type ReadTextFileRequest

type ReadTextFileRequest struct {
	Meta      Meta   `json:"_meta,omitempty"`
	SessionID string `json:"sessionId"`
	Path      string `json:"path"`
	Line      *int   `json:"line,omitempty"`
	Limit     *int   `json:"limit,omitempty"`
}

type ReadTextFileResponse

type ReadTextFileResponse struct {
	Meta    Meta   `json:"_meta,omitempty"`
	Content string `json:"content"`
}

type RequestPermissionRequest

type RequestPermissionRequest struct {
	Meta      Meta               `json:"_meta,omitempty"`
	SessionID string             `json:"sessionId"`
	ToolCall  ToolCallUpdate     `json:"toolCall"`
	Options   []PermissionOption `json:"options"`
}

type RequestPermissionResponse

type RequestPermissionResponse struct {
	Meta    Meta              `json:"_meta,omitempty"`
	Outcome PermissionOutcome `json:"outcome"`
}

type ResourceContents

type ResourceContents struct {
	Meta     Meta    `json:"_meta,omitempty"`
	URI      string  `json:"uri"`
	MimeType string  `json:"mimeType,omitempty"`
	Text     *string `json:"text,omitempty"`
	Blob     *string `json:"blob,omitempty"`
}

What a resource holds: text, or bytes in base64

type ResourceLink struct {
	Meta        Meta         `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	URI         string       `json:"uri"`
	Name        string       `json:"name"`
	Title       string       `json:"title,omitempty"`
	Description string       `json:"description,omitempty"`
	MimeType    string       `json:"mimeType,omitempty"`
	Size        *int         `json:"size,omitempty"`
}

A resource by where it is, which the agent reads itself when it can

type SessionCapabilities

type SessionCapabilities struct {
	Meta   Meta      `json:"_meta,omitempty"`
	List   *struct{} `json:"list,omitempty"`
	Fork   *struct{} `json:"fork,omitempty"`
	Resume *struct{} `json:"resume,omitempty"`
	Close  *struct{} `json:"close,omitempty"`
}

What an agent does with sessions beside answering them, each present when the agent does it

type SessionConfigOption

type SessionConfigOption struct {
	Meta        Meta
	ID          string
	Name        string
	Description string
	// What the option is of, such as mode, model or thought_level, which an editor may show in a place of its own
	Category string
	// A switch when true, whose value On is. Otherwise a choice, whose value Value is, among Choices or, when any, Groups
	Boolean bool
	On      bool
	Value   string
	Choices []ConfigChoice
	Groups  []ConfigGroup
}

Something a user sets on a session: one of several choices, plain or under headings, or a switch

func (SessionConfigOption) MarshalJSON

func (o SessionConfigOption) MarshalJSON() ([]byte, error)

func (*SessionConfigOption) UnmarshalJSON

func (o *SessionConfigOption) UnmarshalJSON(data []byte) error

type SessionInfo

type SessionInfo struct {
	Meta      Meta   `json:"_meta,omitempty"`
	SessionID string `json:"sessionId"`
	Cwd       string `json:"cwd"`
	Title     string `json:"title,omitempty"`
	UpdatedAt string `json:"updatedAt,omitempty"`
}

type SessionInfoUpdate

type SessionInfoUpdate struct {
	Meta      Meta    `json:"_meta,omitempty"`
	Title     *string `json:"title,omitempty"`
	UpdatedAt string  `json:"updatedAt,omitempty"`
}

type SessionMode

type SessionMode struct {
	Meta        Meta   `json:"_meta,omitempty"`
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

A way a session works that the user picks, such as asking before each edit

type SessionModeState

type SessionModeState struct {
	Meta           Meta          `json:"_meta,omitempty"`
	CurrentModeID  string        `json:"currentModeId"`
	AvailableModes []SessionMode `json:"availableModes"`
}

type SessionModelState

type SessionModelState struct {
	Meta            Meta        `json:"_meta,omitempty"`
	CurrentModelID  string      `json:"currentModelId"`
	AvailableModels []ModelInfo `json:"availableModels"`
}

type SessionNamed

type SessionNamed struct {
	Meta      Meta   `json:"_meta,omitempty"`
	SessionID string `json:"sessionId"`
}

A request that names a session and nothing else, such as closing it or stopping its reply

type SessionNotification

type SessionNotification struct {
	Meta      Meta          `json:"_meta,omitempty"`
	SessionID string        `json:"sessionId"`
	Update    SessionUpdate `json:"update"`
}

Tells a client what a session did

type SessionRequest

type SessionRequest struct {
	Meta       Meta        `json:"_meta,omitempty"`
	SessionID  string      `json:"sessionId,omitempty"`
	Cwd        string      `json:"cwd"`
	MCPServers []MCPServer `json:"mcpServers"`
}

A request about a session in a folder: a new one, or the one named loaded, resumed or forked there

type SessionState

type SessionState struct {
	Meta          Meta                  `json:"_meta,omitempty"`
	SessionID     string                `json:"sessionId,omitempty"`
	Modes         *SessionModeState     `json:"modes,omitempty"`
	Models        *SessionModelState    `json:"models,omitempty"`
	ConfigOptions []SessionConfigOption `json:"configOptions,omitempty"`
}

What an agent says of a session it made, loaded, resumed or forked: the id of one it made, and what the user can set on it

type SessionUpdate

type SessionUpdate struct {
	UserMessage    *MessageChunk
	AgentMessage   *MessageChunk
	AgentThought   *MessageChunk
	ToolCall       *ToolCall
	ToolCallUpdate *ToolCallUpdate
	Plan           *Plan
	Commands       *AvailableCommands
	Mode           *CurrentMode
	Config         *ConfigOptions
	Info           *SessionInfoUpdate
	Usage          *UsageUpdate
	// The kind of an update that is none of the above, and the update as it came
	Other string
	Raw   json.RawMessage
}

One thing a session did that its client is told: a part of a message, a call of a tool or what changed of one, a plan, the commands, the mode, the options, the title, or how full the window is. One of them is set. An update of a kind this package does not know keeps its kind and what it held

func (SessionUpdate) MarshalJSON

func (u SessionUpdate) MarshalJSON() ([]byte, error)

func (*SessionUpdate) UnmarshalJSON

func (u *SessionUpdate) UnmarshalJSON(data []byte) error

type SetSessionConfigOptionRequest

type SetSessionConfigOptionRequest struct {
	Meta      Meta   `json:"_meta,omitempty"`
	Type      string `json:"type,omitempty"`
	SessionID string `json:"sessionId"`
	ConfigID  string `json:"configId"`
	Value     any    `json:"value"`
}

Sets one option of a session: a choice by its value, or a switch on or off

type SetSessionConfigOptionResponse

type SetSessionConfigOptionResponse struct {
	Meta          Meta                  `json:"_meta,omitempty"`
	ConfigOptions []SessionConfigOption `json:"configOptions"`
}

type SetSessionModeRequest

type SetSessionModeRequest struct {
	Meta      Meta   `json:"_meta,omitempty"`
	SessionID string `json:"sessionId"`
	ModeID    string `json:"modeId"`
}

type SetSessionModelRequest

type SetSessionModelRequest struct {
	Meta      Meta   `json:"_meta,omitempty"`
	SessionID string `json:"sessionId"`
	ModelID   string `json:"modelId"`
}

type TerminalExitStatus

type TerminalExitStatus struct {
	Meta     Meta    `json:"_meta,omitempty"`
	ExitCode *int    `json:"exitCode,omitempty"`
	Signal   *string `json:"signal,omitempty"`
}

How the command of a terminal ended

type TerminalOutputResponse

type TerminalOutputResponse struct {
	Meta       Meta                `json:"_meta,omitempty"`
	Output     string              `json:"output"`
	Truncated  bool                `json:"truncated"`
	ExitStatus *TerminalExitStatus `json:"exitStatus,omitempty"`
}

type TerminalRef

type TerminalRef struct {
	Meta       Meta   `json:"_meta,omitempty"`
	TerminalID string `json:"terminalId"`
}

A terminal of the client a call of a tool runs in

type TerminalRequest

type TerminalRequest struct {
	Meta       Meta   `json:"_meta,omitempty"`
	SessionID  string `json:"sessionId"`
	TerminalID string `json:"terminalId"`
}

A request about a terminal of the client a session started: its output, its end, killing its command or letting it go

type TextContent

type TextContent struct {
	Meta        Meta         `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Text        string       `json:"text"`
}

type Then

type Then struct {
	Result any
	After  func()
}

An answer with something to do once it was written, such as telling the other end what it could not be told before it knew the answer

type TooLong

type TooLong struct {
	Limit int
}

A message is longer than a line may be

func (*TooLong) Error

func (e *TooLong) Error() string

type ToolCall

type ToolCall struct {
	Meta       Meta               `json:"_meta,omitempty"`
	ToolCallID string             `json:"toolCallId"`
	Title      string             `json:"title"`
	Kind       string             `json:"kind,omitempty"`
	Status     string             `json:"status,omitempty"`
	Content    []ToolCallContent  `json:"content,omitempty"`
	Locations  []ToolCallLocation `json:"locations,omitempty"`
	RawInput   any                `json:"rawInput,omitempty"`
	RawOutput  any                `json:"rawOutput,omitempty"`
}

A call of a tool as it starts

type ToolCallContent

type ToolCallContent struct {
	Content  *ContentBlock
	Diff     *Diff
	Terminal *TerminalRef
}

What a call of a tool shows: content, a change to a file, or a terminal of the client. One of them is set

func (ToolCallContent) MarshalJSON

func (c ToolCallContent) MarshalJSON() ([]byte, error)

func (*ToolCallContent) UnmarshalJSON

func (c *ToolCallContent) UnmarshalJSON(data []byte) error

type ToolCallLocation

type ToolCallLocation struct {
	Meta Meta   `json:"_meta,omitempty"`
	Path string `json:"path"`
	Line *int   `json:"line,omitempty"`
}

A file a call of a tool is about, with the line where it is at one

type ToolCallUpdate

type ToolCallUpdate struct {
	Meta       Meta               `json:"_meta,omitempty"`
	ToolCallID string             `json:"toolCallId"`
	Title      *string            `json:"title,omitempty"`
	Kind       string             `json:"kind,omitempty"`
	Status     string             `json:"status,omitempty"`
	Content    []ToolCallContent  `json:"content,omitempty"`
	Locations  []ToolCallLocation `json:"locations,omitempty"`
	RawInput   any                `json:"rawInput,omitempty"`
	RawOutput  any                `json:"rawOutput,omitempty"`
}

What changed of a call of a tool since it started: only what is set here changes

type Usage

type Usage struct {
	InputTokens       int  `json:"inputTokens"`
	OutputTokens      int  `json:"outputTokens"`
	TotalTokens       int  `json:"totalTokens"`
	CachedReadTokens  *int `json:"cachedReadTokens,omitempty"`
	CachedWriteTokens *int `json:"cachedWriteTokens,omitempty"`
	ThoughtTokens     *int `json:"thoughtTokens,omitempty"`
}

How many tokens a reply took

type UsageUpdate

type UsageUpdate struct {
	Meta Meta  `json:"_meta,omitempty"`
	Size int   `json:"size"`
	Used int   `json:"used"`
	Cost *Cost `json:"cost,omitempty"`
}

How full the window of the session's model is, and what the session cost so far

type WriteTextFileRequest

type WriteTextFileRequest struct {
	Meta      Meta   `json:"_meta,omitempty"`
	SessionID string `json:"sessionId"`
	Path      string `json:"path"`
	Content   string `json:"content"`
}

Jump to

Keyboard shortcuts

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