acp

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

README

Agent Client Protocol

ACP Go SDK

Go library for the Agent Client Protocol (ACP) - a standardized communication protocol between code editors and AI‑powered coding agents.

Learn more about the protocol itself at https://agentclientprotocol.com.

Installation

go get github.com/coder/acp-go-sdk@v0.4.3

Get Started

Understand the Protocol

Start by reading the official ACP documentation to understand the core concepts and protocol specification.

Try the Examples

The examples directory contains simple implementations of both Agents and Clients in Go. You can run them from your terminal or connect to external ACP agents.

  • go run ./example/agent starts a minimal ACP agent over stdio.
  • go run ./example/claude-code demonstrates bridging to Claude Code.
  • go run ./example/client connects to a running agent and streams a sample turn.
  • go run ./example/gemini bridges to the Gemini CLI in ACP mode (flags: -model, -sandbox, -debug, -gemini /path/to/gemini).

You can watch the interaction by running go run ./example/client locally.

Explore the API

Browse the Go package docs on pkg.go.dev for detailed API documentation:

If you're building an Agent:

  • Implement the acp.Agent interface (and optionally acp.AgentLoader for session/load).
  • Create a connection with acp.NewAgentSideConnection(agent, os.Stdout, os.Stdin).
  • Send updates and make client requests using the returned connection.

If you're building a Client:

  • Implement the acp.Client interface (and optionally acp.ClientTerminal for terminal features).
  • Launch or connect to your Agent process (stdio), then create a connection with acp.NewClientSideConnection(client, stdin, stdout).
  • Call Initialize, NewSession, and Prompt to run a turn and stream updates.

Helper constructors are provided to reduce boilerplate when working with union types:

  • Content blocks: acp.TextBlock, acp.ImageBlock, acp.AudioBlock, acp.ResourceLinkBlock, acp.ResourceBlock.
  • Tool content: acp.ToolContent, acp.ToolDiffContent, acp.ToolTerminalRef.
  • Utility: acp.Ptr[T] for pointer fields in request/update structs.
Study a Production Implementation

For a complete, production‑ready integration, see the Gemini CLI Agent which exposes an ACP interface. The Go example client example/gemini demonstrates connecting to it via stdio.

Resources

License

Apache 2.0. See LICENSE.

Documentation

Overview

Package acp provides Go types and connection plumbing for the Agent Client Protocol (ACP). It contains generated dispatchers, outbound helpers, shared request/response types, and related utilities used by agents and clients to communicate over ACP.

Example (Agent)

Example_agent wires the Agent to stdio so an external client can connect via this process' stdin/stdout.

package main

import (
	"context"
	"os"
)

// agentExample mirrors the go/example/agent flow in a compact form.
// It streams a short message, demonstrates a tool call + permission,
// then ends the turn.
type agentExample struct{ conn *AgentSideConnection }

var _ Agent = (*agentExample)(nil)

// SetSessionMode implements Agent.
func (a *agentExample) SetSessionMode(ctx context.Context, params SetSessionModeRequest) (SetSessionModeResponse, error) {
	return SetSessionModeResponse{}, nil
}

func (a *agentExample) SetAgentConnection(c *AgentSideConnection) { a.conn = c }

func (agentExample) Authenticate(ctx context.Context, _ AuthenticateRequest) (AuthenticateResponse, error) {
	return AuthenticateResponse{}, nil
}

func (agentExample) Initialize(ctx context.Context, _ InitializeRequest) (InitializeResponse, error) {
	return InitializeResponse{
		ProtocolVersion:   ProtocolVersionNumber,
		AgentCapabilities: AgentCapabilities{LoadSession: false},
	}, nil
}
func (agentExample) Cancel(ctx context.Context, _ CancelNotification) error { return nil }
func (agentExample) NewSession(ctx context.Context, _ NewSessionRequest) (NewSessionResponse, error) {
	return NewSessionResponse{SessionId: SessionId("sess_demo")}, nil
}

func (a *agentExample) Prompt(ctx context.Context, p PromptRequest) (PromptResponse, error) {
	// Stream an initial agent message.
	_ = a.conn.SessionUpdate(ctx, SessionNotification{
		SessionId: p.SessionId,
		Update:    UpdateAgentMessageText("I'll help you with that."),
	})

	// Announce a tool call.
	_ = a.conn.SessionUpdate(ctx, SessionNotification{
		SessionId: p.SessionId,
		Update: StartToolCall(
			ToolCallId("call_1"),
			"Modifying configuration",
			WithStartKind(ToolKindEdit),
			WithStartStatus(ToolCallStatusPending),
			WithStartLocations([]ToolCallLocation{{Path: "/project/config.json"}}),
			WithStartRawInput(map[string]any{"path": "/project/config.json"}),
		),
	})

	// Ask the client for permission to proceed with the change.
	resp, _ := a.conn.RequestPermission(ctx, RequestPermissionRequest{
		SessionId: p.SessionId,
		ToolCall: ToolCallUpdate{
			ToolCallId: ToolCallId("call_1"),
			Title:      Ptr("Modifying configuration"),
			Kind:       Ptr(ToolKindEdit),
			Status:     Ptr(ToolCallStatusPending),
			Locations:  []ToolCallLocation{{Path: "/project/config.json"}},
			RawInput:   map[string]any{"path": "/project/config.json"},
		},
		Options: []PermissionOption{
			{Kind: PermissionOptionKindAllowOnce, Name: "Allow", OptionId: PermissionOptionId("allow")},
			{Kind: PermissionOptionKindRejectOnce, Name: "Reject", OptionId: PermissionOptionId("reject")},
		},
	})

	if resp.Outcome.Selected != nil && string(resp.Outcome.Selected.OptionId) == "allow" {
		// Mark tool call completed and stream a final message.
		_ = a.conn.SessionUpdate(ctx, SessionNotification{
			SessionId: p.SessionId,
			Update: UpdateToolCall(
				ToolCallId("call_1"),
				WithUpdateStatus(ToolCallStatusCompleted),
				WithUpdateRawOutput(map[string]any{"success": true}),
			),
		})
		_ = a.conn.SessionUpdate(ctx, SessionNotification{
			SessionId: p.SessionId,
			Update:    UpdateAgentMessageText("Done."),
		})
	}

	return PromptResponse{StopReason: StopReasonEndTurn}, nil
}

// Example_agent wires the Agent to stdio so an external client
// can connect via this process' stdin/stdout.
func main() {
	ag := &agentExample{}
	asc := NewAgentSideConnection(ag, os.Stdout, os.Stdin)
	ag.SetAgentConnection(asc)
	// In a real program, block until the peer disconnects:
	// <-asc.Done()
}
Example (Client)

Example_client launches the Go agent example, negotiates protocol, opens a session, and sends a simple prompt.

package main

import (
	"context"
	"fmt"
	"os"
	"os/exec"
	"path/filepath"
	"strings"
)

// clientExample mirrors go/example/client in a compact form: prints
// streamed updates, handles simple file ops, and picks the first
// permission option.
type clientExample struct{}

var _ Client = (*clientExample)(nil)

func (clientExample) RequestPermission(ctx context.Context, p RequestPermissionRequest) (RequestPermissionResponse, error) {
	if len(p.Options) == 0 {
		return RequestPermissionResponse{
			Outcome: RequestPermissionOutcome{
				Cancelled: &RequestPermissionOutcomeCancelled{},
			},
		}, nil
	}
	return RequestPermissionResponse{
		Outcome: RequestPermissionOutcome{
			Selected: &RequestPermissionOutcomeSelected{OptionId: p.Options[0].OptionId},
		},
	}, nil
}

func (clientExample) SessionUpdate(ctx context.Context, n SessionNotification) error {
	u := n.Update
	switch {
	case u.AgentMessageChunk != nil:
		c := u.AgentMessageChunk.Content
		if c.Text != nil {
			fmt.Print(c.Text.Text)
		}
	case u.ToolCall != nil:
		title := u.ToolCall.Title
		fmt.Printf("\n[tool] %s (%s)\n", title, u.ToolCall.Status)
	case u.ToolCallUpdate != nil:
		fmt.Printf("\n[tool] %s -> %v\n", u.ToolCallUpdate.ToolCallId, u.ToolCallUpdate.Status)
	}
	return nil
}

func (clientExample) WriteTextFile(ctx context.Context, p WriteTextFileRequest) (WriteTextFileResponse, error) {
	if !filepath.IsAbs(p.Path) {
		return WriteTextFileResponse{}, fmt.Errorf("path must be absolute: %s", p.Path)
	}
	if dir := filepath.Dir(p.Path); dir != "" {
		_ = os.MkdirAll(dir, 0o755)
	}
	return WriteTextFileResponse{}, os.WriteFile(p.Path, []byte(p.Content), 0o644)
}

func (clientExample) ReadTextFile(ctx context.Context, p ReadTextFileRequest) (ReadTextFileResponse, error) {
	if !filepath.IsAbs(p.Path) {
		return ReadTextFileResponse{}, fmt.Errorf("path must be absolute: %s", p.Path)
	}
	b, err := os.ReadFile(p.Path)
	if err != nil {
		return ReadTextFileResponse{}, err
	}
	content := string(b)
	if p.Line != nil || p.Limit != nil {
		lines := strings.Split(content, "\n")
		start := 0
		if p.Line != nil && *p.Line > 0 {
			if *p.Line-1 > 0 {
				start = *p.Line - 1
			}
			if start > len(lines) {
				start = len(lines)
			}
		}
		end := len(lines)
		if p.Limit != nil && *p.Limit > 0 && start+*p.Limit < end {
			end = start + *p.Limit
		}
		content = strings.Join(lines[start:end], "\n")
	}
	return ReadTextFileResponse{Content: content}, nil
}

// Terminal interface implementations (minimal stubs for examples)
func (clientExample) CreateTerminal(ctx context.Context, p CreateTerminalRequest) (CreateTerminalResponse, error) {
	// Return a dummy terminal id
	return CreateTerminalResponse{TerminalId: "t-1"}, nil
}

func (clientExample) KillTerminalCommand(ctx context.Context, p KillTerminalCommandRequest) (KillTerminalCommandResponse, error) {
	return KillTerminalCommandResponse{}, nil
}

func (clientExample) ReleaseTerminal(ctx context.Context, p ReleaseTerminalRequest) (ReleaseTerminalResponse, error) {
	return ReleaseTerminalResponse{}, nil
}

func (clientExample) TerminalOutput(ctx context.Context, p TerminalOutputRequest) (TerminalOutputResponse, error) {
	// Provide non-empty output to satisfy validation
	return TerminalOutputResponse{Output: "ok", Truncated: false}, nil
}

func (clientExample) WaitForTerminalExit(ctx context.Context, p WaitForTerminalExitRequest) (WaitForTerminalExitResponse, error) {
	return WaitForTerminalExitResponse{}, nil
}

// Example_client launches the Go agent example, negotiates protocol,
// opens a session, and sends a simple prompt.
func main() {
	ctx := context.Background()
	cmd := exec.Command("go", "run", "./example/agent")
	stdin, _ := cmd.StdinPipe()
	stdout, _ := cmd.StdoutPipe()
	_ = cmd.Start()

	conn := NewClientSideConnection(clientExample{}, stdin, stdout)
	_, _ = conn.Initialize(ctx, InitializeRequest{
		ProtocolVersion: ProtocolVersionNumber,
		ClientCapabilities: ClientCapabilities{
			Fs: FileSystemCapability{
				ReadTextFile:  true,
				WriteTextFile: true,
			},
			Terminal: true,
		},
	})
	sess, _ := conn.NewSession(ctx, NewSessionRequest{
		Cwd:        "/",
		McpServers: []McpServer{},
	})
	_, _ = conn.Prompt(ctx, PromptRequest{
		SessionId: sess.SessionId,
		Prompt:    []ContentBlock{TextBlock("Hello, agent!")},
	})

	_ = cmd.Process.Kill()
}
Example (Gemini)

Example_gemini connects to a Gemini CLI speaking ACP over stdio, then initializes, opens a session, and sends a prompt.

package main

import (
	"context"
	"fmt"
	"os/exec"
)

// geminiClient mirrors go/example/gemini in brief: prints text chunks and
// selects the first permission option. File ops are no-ops here.
type geminiClient struct{}

var _ Client = (*geminiClient)(nil)

func (geminiClient) RequestPermission(ctx context.Context, p RequestPermissionRequest) (RequestPermissionResponse, error) {
	if len(p.Options) == 0 {
		return RequestPermissionResponse{Outcome: RequestPermissionOutcome{Cancelled: &RequestPermissionOutcomeCancelled{}}}, nil
	}
	return RequestPermissionResponse{Outcome: RequestPermissionOutcome{Selected: &RequestPermissionOutcomeSelected{OptionId: p.Options[0].OptionId}}}, nil
}

func (geminiClient) SessionUpdate(ctx context.Context, n SessionNotification) error {
	if n.Update.AgentMessageChunk != nil {
		c := n.Update.AgentMessageChunk.Content
		if c.Text != nil {
			fmt.Print(c.Text.Text)
		}
	}
	return nil
}

func (geminiClient) ReadTextFile(ctx context.Context, _ ReadTextFileRequest) (ReadTextFileResponse, error) {
	return ReadTextFileResponse{}, nil
}

func (geminiClient) WriteTextFile(ctx context.Context, _ WriteTextFileRequest) (WriteTextFileResponse, error) {
	return WriteTextFileResponse{}, nil
}

// Terminal interface implementations (minimal stubs for examples)
func (geminiClient) CreateTerminal(ctx context.Context, p CreateTerminalRequest) (CreateTerminalResponse, error) {
	return CreateTerminalResponse{TerminalId: "t-1"}, nil
}

func (geminiClient) KillTerminalCommand(ctx context.Context, p KillTerminalCommandRequest) (KillTerminalCommandResponse, error) {
	return KillTerminalCommandResponse{}, nil
}

func (geminiClient) ReleaseTerminal(ctx context.Context, p ReleaseTerminalRequest) (ReleaseTerminalResponse, error) {
	return ReleaseTerminalResponse{}, nil
}

func (geminiClient) TerminalOutput(ctx context.Context, p TerminalOutputRequest) (TerminalOutputResponse, error) {
	return TerminalOutputResponse{Output: "ok", Truncated: false}, nil
}

func (geminiClient) WaitForTerminalExit(ctx context.Context, p WaitForTerminalExitRequest) (WaitForTerminalExitResponse, error) {
	return WaitForTerminalExitResponse{}, nil
}

// Example_gemini connects to a Gemini CLI speaking ACP over stdio,
// then initializes, opens a session, and sends a prompt.
func main() {
	ctx := context.Background()
	cmd := exec.Command("gemini", "--experimental-acp")
	stdin, _ := cmd.StdinPipe()
	stdout, _ := cmd.StdoutPipe()
	_ = cmd.Start()

	conn := NewClientSideConnection(geminiClient{}, stdin, stdout)
	_, _ = conn.Initialize(ctx, InitializeRequest{
		ProtocolVersion: ProtocolVersionNumber,
		ClientCapabilities: ClientCapabilities{
			Fs: FileSystemCapability{
				ReadTextFile:  true,
				WriteTextFile: true,
			},
			Terminal: true,
		},
	})
	sess, _ := conn.NewSession(ctx, NewSessionRequest{
		Cwd:        "/",
		McpServers: []McpServer{},
	})
	_, _ = conn.Prompt(ctx, PromptRequest{
		SessionId: sess.SessionId,
		Prompt:    []ContentBlock{TextBlock("list files")},
	})
}

Index

Examples

Constants

View Source
const (
	AgentMethodAuthenticate   = "authenticate"
	AgentMethodInitialize     = "initialize"
	AgentMethodModelSelect    = "session/set_model"
	AgentMethodSessionCancel  = "session/cancel"
	AgentMethodSessionLoad    = "session/load"
	AgentMethodSessionNew     = "session/new"
	AgentMethodSessionPrompt  = "session/prompt"
	AgentMethodSessionSetMode = "session/set_mode"
)

Agent method names

View Source
const (
	ClientMethodFsReadTextFile           = "fs/read_text_file"
	ClientMethodFsWriteTextFile          = "fs/write_text_file"
	ClientMethodSessionRequestPermission = "session/request_permission"
	ClientMethodSessionUpdate            = "session/update"
	ClientMethodTerminalCreate           = "terminal/create"
	ClientMethodTerminalKill             = "terminal/kill"
	ClientMethodTerminalOutput           = "terminal/output"
	ClientMethodTerminalRelease          = "terminal/release"
	ClientMethodTerminalWaitForExit      = "terminal/wait_for_exit"
)

Client method names

View Source
const ProtocolVersionNumber = 1

ProtocolVersionNumber is the ACP protocol version supported by this SDK.

Variables

This section is empty.

Functions

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to v.

func SendRequest

func SendRequest[T any](c *Connection, ctx context.Context, method string, params any) (T, error)

SendRequest sends a JSON-RPC request and returns a typed result. For methods that do not return a result, use SendRequestNoResult instead.

Types

type Agent

type Agent interface {
	Authenticate(ctx context.Context, params AuthenticateRequest) (AuthenticateResponse, error)
	Initialize(ctx context.Context, params InitializeRequest) (InitializeResponse, error)
	Cancel(ctx context.Context, params CancelNotification) error
	NewSession(ctx context.Context, params NewSessionRequest) (NewSessionResponse, error)
	Prompt(ctx context.Context, params PromptRequest) (PromptResponse, error)
	SetSessionMode(ctx context.Context, params SetSessionModeRequest) (SetSessionModeResponse, error)
}

type AgentCapabilities

type AgentCapabilities struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Whether the agent supports 'session/load'.
	//
	// Defaults to false if unset.
	LoadSession bool `json:"loadSession,omitempty"`
	// MCP capabilities supported by the agent.
	//
	// Defaults to {"http":false,"sse":false} if unset.
	McpCapabilities McpCapabilities `json:"mcpCapabilities,omitempty"`
	// Prompt capabilities supported by the agent.
	//
	// Defaults to {"audio":false,"embeddedContext":false,"image":false} if unset.
	PromptCapabilities PromptCapabilities `json:"promptCapabilities,omitempty"`
}

Capabilities supported by the agent. Advertised during initialization to inform the client about available features and content types. See protocol docs: [Agent Capabilities](https://agentclientprotocol.com/protocol/initialization#agent-capabilities)

func (AgentCapabilities) MarshalJSON

func (v AgentCapabilities) MarshalJSON() ([]byte, error)

func (*AgentCapabilities) UnmarshalJSON

func (v *AgentCapabilities) UnmarshalJSON(b []byte) error

type AgentExperimental

type AgentExperimental interface {
	SetSessionModel(ctx context.Context, params SetSessionModelRequest) (SetSessionModelResponse, error)
}

AgentExperimental defines unstable methods that are not part of the official spec. These may change or be removed without notice.

type AgentLoader

type AgentLoader interface {
	LoadSession(ctx context.Context, params LoadSessionRequest) (LoadSessionResponse, error)
}

AgentLoader defines optional support for loading sessions. Implement and advertise the capability to enable 'session/load'.

type AgentNotification

type AgentNotification struct {
	SessionNotification *SessionNotification `json:"-"`
}

All possible notifications that an agent can send to a client. This enum is used internally for routing RPC notifications. You typically won't need to use this directly - use the notification methods on the ['Client'] trait instead. Notifications do not expect a response.

func (AgentNotification) MarshalJSON

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

func (*AgentNotification) UnmarshalJSON

func (u *AgentNotification) UnmarshalJSON(b []byte) error

type AgentRequest

type AgentRequest struct {
	WriteTextFileRequest       *WriteTextFileRequest       `json:"-"`
	ReadTextFileRequest        *ReadTextFileRequest        `json:"-"`
	RequestPermissionRequest   *RequestPermissionRequest   `json:"-"`
	CreateTerminalRequest      *CreateTerminalRequest      `json:"-"`
	TerminalOutputRequest      *TerminalOutputRequest      `json:"-"`
	ReleaseTerminalRequest     *ReleaseTerminalRequest     `json:"-"`
	WaitForTerminalExitRequest *WaitForTerminalExitRequest `json:"-"`
	KillTerminalCommandRequest *KillTerminalCommandRequest `json:"-"`
}

All possible requests that an agent can send to a client. This enum is used internally for routing RPC requests. You typically won't need to use this directly - instead, use the methods on the ['Client'] trait. This enum encompasses all method calls from agent to client.

func (AgentRequest) MarshalJSON

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

func (*AgentRequest) UnmarshalJSON

func (u *AgentRequest) UnmarshalJSON(b []byte) error

type AgentResponse

type AgentResponse struct {
	InitializeResponse      *InitializeResponse      `json:"-"`
	AuthenticateResponse    *AuthenticateResponse    `json:"-"`
	NewSessionResponse      *NewSessionResponse      `json:"-"`
	LoadSessionResponse     *LoadSessionResponse     `json:"-"`
	SetSessionModeResponse  *SetSessionModeResponse  `json:"-"`
	PromptResponse          *PromptResponse          `json:"-"`
	SetSessionModelResponse *SetSessionModelResponse `json:"-"`
}

All possible responses that an agent can send to a client. This enum is used internally for routing RPC responses. You typically won't need to use this directly - the responses are handled automatically by the connection. These are responses to the corresponding 'ClientRequest' variants.

func (AgentResponse) MarshalJSON

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

func (*AgentResponse) UnmarshalJSON

func (u *AgentResponse) UnmarshalJSON(b []byte) error

type AgentSideConnection

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

AgentSideConnection represents the agent's view of a connection to a client.

func NewAgentSideConnection

func NewAgentSideConnection(agent Agent, peerInput io.Writer, peerOutput io.Reader) *AgentSideConnection

NewAgentSideConnection creates a new agent-side connection bound to the provided Agent implementation.

func (*AgentSideConnection) CreateTerminal

func (*AgentSideConnection) Done

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

Done exposes a channel that closes when the peer disconnects.

func (*AgentSideConnection) KillTerminalCommand

func (*AgentSideConnection) ReadTextFile

func (*AgentSideConnection) ReleaseTerminal

func (*AgentSideConnection) RequestPermission

func (*AgentSideConnection) SessionUpdate

func (c *AgentSideConnection) SessionUpdate(ctx context.Context, params SessionNotification) error

func (*AgentSideConnection) SetLogger

func (c *AgentSideConnection) SetLogger(l *slog.Logger)

SetLogger directs connection diagnostics to the provided logger.

func (*AgentSideConnection) TerminalOutput

func (*AgentSideConnection) WaitForTerminalExit

func (*AgentSideConnection) WriteTextFile

type Annotations

type Annotations struct {
	// Extension point for implementations
	Meta         any      `json:"_meta,omitempty"`
	Audience     []Role   `json:"audience,omitempty"`
	LastModified *string  `json:"lastModified,omitempty"`
	Priority     *float64 `json:"priority,omitempty"`
}

Optional annotations for the client. The client can use annotations to inform how objects are used or displayed

type AudioContent

type AudioContent struct {
	// Extension point for implementations
	Meta        any          `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Data        string       `json:"data"`
	MimeType    string       `json:"mimeType"`
}

Audio provided to or from an LLM.

type AuthMethod

type AuthMethod struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Optional description providing more details about this authentication method.
	Description *string `json:"description,omitempty"`
	// Unique identifier for this authentication method.
	Id AuthMethodId `json:"id"`
	// Human-readable name of the authentication method.
	Name string `json:"name"`
}

Describes an available authentication method.

type AuthMethodId

type AuthMethodId string

Unique identifier for an authentication method.

type AuthenticateRequest

type AuthenticateRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The ID of the authentication method to use. Must be one of the methods advertised in the initialize response.
	MethodId AuthMethodId `json:"methodId"`
}

Request parameters for the authenticate method. Specifies which authentication method to use.

func (*AuthenticateRequest) Validate

func (v *AuthenticateRequest) Validate() error

type AuthenticateResponse

type AuthenticateResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
}

Response to authenticate method

func (*AuthenticateResponse) Validate

func (v *AuthenticateResponse) Validate() error

type AvailableCommand

type AvailableCommand struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Human-readable description of what the command does.
	Description string `json:"description"`
	// Input for the command if required
	Input *AvailableCommandInput `json:"input,omitempty"`
	// Command name (e.g., 'create_plan', 'research_codebase').
	Name string `json:"name"`
}

Information about a command.

type AvailableCommandInput

type AvailableCommandInput struct {
	UnstructuredCommandInput *UnstructuredCommandInput `json:"-"`
}

func (AvailableCommandInput) MarshalJSON

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

func (*AvailableCommandInput) UnmarshalJSON

func (u *AvailableCommandInput) UnmarshalJSON(b []byte) error

type BlobResourceContents

type BlobResourceContents struct {
	// Extension point for implementations
	Meta     any     `json:"_meta,omitempty"`
	Blob     string  `json:"blob"`
	MimeType *string `json:"mimeType,omitempty"`
	Uri      string  `json:"uri"`
}

Binary resource contents.

type CancelNotification

type CancelNotification struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The ID of the session to cancel operations for.
	SessionId SessionId `json:"sessionId"`
}

Notification to cancel ongoing operations for a session. See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)

func (*CancelNotification) Validate

func (v *CancelNotification) Validate() error

type ClientCapabilities

type ClientCapabilities struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// File system capabilities supported by the client. Determines which file operations the agent can request.
	//
	// Defaults to {"readTextFile":false,"writeTextFile":false} if unset.
	Fs FileSystemCapability `json:"fs,omitempty"`
	// Whether the Client support all 'terminal/*' methods.
	//
	// Defaults to false if unset.
	Terminal bool `json:"terminal,omitempty"`
}

Capabilities supported by the client. Advertised during initialization to inform the agent about available features and methods. See protocol docs: [Client Capabilities](https://agentclientprotocol.com/protocol/initialization#client-capabilities)

func (ClientCapabilities) MarshalJSON

func (v ClientCapabilities) MarshalJSON() ([]byte, error)

func (*ClientCapabilities) UnmarshalJSON

func (v *ClientCapabilities) UnmarshalJSON(b []byte) error

type ClientExperimental

type ClientExperimental interface{}

ClientExperimental defines unstable methods that are not part of the official spec. These may change or be removed without notice.

type ClientNotification

type ClientNotification struct {
	CancelNotification *CancelNotification `json:"-"`
}

All possible notifications that a client can send to an agent. This enum is used internally for routing RPC notifications. You typically won't need to use this directly - use the notification methods on the ['Agent'] trait instead. Notifications do not expect a response.

func (ClientNotification) MarshalJSON

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

func (*ClientNotification) UnmarshalJSON

func (u *ClientNotification) UnmarshalJSON(b []byte) error

type ClientRequest

type ClientRequest struct {
	InitializeRequest      *InitializeRequest      `json:"-"`
	AuthenticateRequest    *AuthenticateRequest    `json:"-"`
	NewSessionRequest      *NewSessionRequest      `json:"-"`
	LoadSessionRequest     *LoadSessionRequest     `json:"-"`
	SetSessionModeRequest  *SetSessionModeRequest  `json:"-"`
	PromptRequest          *PromptRequest          `json:"-"`
	SetSessionModelRequest *SetSessionModelRequest `json:"-"`
}

All possible requests that a client can send to an agent. This enum is used internally for routing RPC requests. You typically won't need to use this directly - instead, use the methods on the ['Agent'] trait. This enum encompasses all method calls from client to agent.

func (ClientRequest) MarshalJSON

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

func (*ClientRequest) UnmarshalJSON

func (u *ClientRequest) UnmarshalJSON(b []byte) error

type ClientResponse

type ClientResponse struct {
	WriteTextFileResponse       *WriteTextFileResponse       `json:"-"`
	ReadTextFileResponse        *ReadTextFileResponse        `json:"-"`
	RequestPermissionResponse   *RequestPermissionResponse   `json:"-"`
	CreateTerminalResponse      *CreateTerminalResponse      `json:"-"`
	TerminalOutputResponse      *TerminalOutputResponse      `json:"-"`
	ReleaseTerminalResponse     *ReleaseTerminalResponse     `json:"-"`
	WaitForTerminalExitResponse *WaitForTerminalExitResponse `json:"-"`
	KillTerminalCommandResponse *KillTerminalCommandResponse `json:"-"`
}

All possible responses that a client can send to an agent. This enum is used internally for routing RPC responses. You typically won't need to use this directly - the responses are handled automatically by the connection. These are responses to the corresponding 'AgentRequest' variants.

func (ClientResponse) MarshalJSON

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

func (*ClientResponse) UnmarshalJSON

func (u *ClientResponse) UnmarshalJSON(b []byte) error

type ClientSideConnection

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

ClientSideConnection provides the client's view of the connection and implements Agent calls.

func NewClientSideConnection

func NewClientSideConnection(client Client, peerInput io.Writer, peerOutput io.Reader) *ClientSideConnection

NewClientSideConnection creates a new client-side connection bound to the provided Client implementation.

func (*ClientSideConnection) Authenticate

func (*ClientSideConnection) Cancel

func (*ClientSideConnection) Done

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

Done exposes a channel that closes when the peer disconnects.

func (*ClientSideConnection) Initialize

func (*ClientSideConnection) LoadSession

func (*ClientSideConnection) NewSession

func (*ClientSideConnection) Prompt

func (*ClientSideConnection) SetLogger

func (c *ClientSideConnection) SetLogger(l *slog.Logger)

SetLogger directs connection diagnostics to the provided logger.

func (*ClientSideConnection) SetSessionMode

func (*ClientSideConnection) SetSessionModel

type Connection

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

Connection is a simple JSON-RPC 2.0 connection over line-delimited JSON.

func NewConnection

func NewConnection(handler MethodHandler, peerInput io.Writer, peerOutput io.Reader) *Connection

func (*Connection) Done

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

Done returns a channel that is closed when the underlying reader loop exits (typically when the peer disconnects or the input stream is closed).

func (*Connection) SendNotification

func (c *Connection) SendNotification(ctx context.Context, method string, params any) error

func (*Connection) SendRequestNoResult

func (c *Connection) SendRequestNoResult(ctx context.Context, method string, params any) error

SendRequestNoResult sends a JSON-RPC request that returns no result payload.

func (*Connection) SetLogger

func (c *Connection) SetLogger(l *slog.Logger)

SetLogger installs a logger used for internal connection diagnostics. If unset, logs are written via the default logger.

type ContentBlock

type ContentBlock struct {
	Text         *ContentBlockText         `json:"-"`
	Image        *ContentBlockImage        `json:"-"`
	Audio        *ContentBlockAudio        `json:"-"`
	ResourceLink *ContentBlockResourceLink `json:"-"`
	Resource     *ContentBlockResource     `json:"-"`
}

func AudioBlock

func AudioBlock(data string, mimeType string) ContentBlock

AudioBlock constructs an inline audio content block with base64-encoded data.

func ImageBlock

func ImageBlock(data string, mimeType string) ContentBlock

ImageBlock constructs an inline image content block with base64-encoded data.

func ResourceBlock

func ResourceBlock(res EmbeddedResource) ContentBlock

ResourceBlock wraps an embedded resource as a content block.

func ResourceLinkBlock

func ResourceLinkBlock(name string, uri string) ContentBlock

ResourceLinkBlock constructs a resource_link content block with a name and URI.

func TextBlock

func TextBlock(text string) ContentBlock

TextBlock constructs a text content block.

func (ContentBlock) MarshalJSON

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

func (*ContentBlock) UnmarshalJSON

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

func (*ContentBlock) Validate

func (u *ContentBlock) Validate() error

type ContentBlockAudio

type ContentBlockAudio struct {
	// Extension point for implementations
	Meta        any          `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Data        string       `json:"data"`
	MimeType    string       `json:"mimeType"`
	Type        string       `json:"type"`
}

Audio data for transcription or analysis. Requires the 'audio' prompt capability when included in prompts.

type ContentBlockImage

type ContentBlockImage struct {
	// Extension point for implementations
	Meta        any          `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Data        string       `json:"data"`
	MimeType    string       `json:"mimeType"`
	Type        string       `json:"type"`
	Uri         *string      `json:"uri,omitempty"`
}

Images for visual context or analysis. Requires the 'image' prompt capability when included in prompts.

type ContentBlockResource

type ContentBlockResource struct {
	// Extension point for implementations
	Meta        any                      `json:"_meta,omitempty"`
	Annotations *Annotations             `json:"annotations,omitempty"`
	Resource    EmbeddedResourceResource `json:"resource"`
	Type        string                   `json:"type"`
}

Complete resource contents embedded directly in the message. Preferred for including context as it avoids extra round-trips. Requires the 'embeddedContext' prompt capability when included in prompts.

type ContentBlockResourceLink struct {
	// Extension point for implementations
	Meta        any          `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Description *string      `json:"description,omitempty"`
	MimeType    *string      `json:"mimeType,omitempty"`
	Name        string       `json:"name"`
	Size        *int         `json:"size,omitempty"`
	Title       *string      `json:"title,omitempty"`
	Type        string       `json:"type"`
	Uri         string       `json:"uri"`
}

References to resources that the agent can access. All agents MUST support resource links in prompts.

type ContentBlockText

type ContentBlockText struct {
	// Extension point for implementations
	Meta        any          `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Text        string       `json:"text"`
	Type        string       `json:"type"`
}

Content blocks represent displayable information in the Agent Client Protocol. They provide a structured way to handle various types of user-facing content—whether it's text from language models, images for analysis, or embedded resources for context. Content blocks appear in: - User prompts sent via 'session/prompt' - Language model output streamed through 'session/update' notifications - Progress updates and results from tool calls This structure is compatible with the Model Context Protocol (MCP), enabling agents to seamlessly forward content from MCP tool outputs without transformation. See protocol docs: [Content](https://agentclientprotocol.com/protocol/content) Plain text content All agents MUST support text content blocks in prompts.

type CreateTerminalRequest

type CreateTerminalRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Array of command arguments.
	Args []string `json:"args,omitempty"`
	// The command to execute.
	Command string `json:"command"`
	// Working directory for the command (absolute path).
	Cwd *string `json:"cwd,omitempty"`
	// Environment variables for the command.
	Env []EnvVariable `json:"env,omitempty"`
	// Maximum number of output bytes to retain.  When the limit is exceeded, the Client truncates from the beginning of the output to stay within the limit.  The Client MUST ensure truncation happens at a character boundary to maintain valid string output, even if this means the retained output is slightly less than the specified limit.
	OutputByteLimit *int `json:"outputByteLimit,omitempty"`
	// The session ID for this request.
	SessionId SessionId `json:"sessionId"`
}

Request to create a new terminal and execute a command.

func (*CreateTerminalRequest) Validate

func (v *CreateTerminalRequest) Validate() error

type CreateTerminalResponse

type CreateTerminalResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The unique identifier for the created terminal.
	TerminalId string `json:"terminalId"`
}

Response containing the ID of the created terminal.

func (*CreateTerminalResponse) Validate

func (v *CreateTerminalResponse) Validate() error

type EmbeddedResource

type EmbeddedResource struct {
	// Extension point for implementations
	Meta        any                      `json:"_meta,omitempty"`
	Annotations *Annotations             `json:"annotations,omitempty"`
	Resource    EmbeddedResourceResource `json:"resource"`
}

The contents of a resource, embedded into a prompt or tool call result.

type EmbeddedResourceResource

type EmbeddedResourceResource struct {
	TextResourceContents *TextResourceContents `json:"-"`
	BlobResourceContents *BlobResourceContents `json:"-"`
}

Resource content that can be embedded in a message.

func (EmbeddedResourceResource) MarshalJSON

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

func (*EmbeddedResourceResource) UnmarshalJSON

func (u *EmbeddedResourceResource) UnmarshalJSON(b []byte) error

type EnvVariable

type EnvVariable struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The name of the environment variable.
	Name string `json:"name"`
	// The value to set for the environment variable.
	Value string `json:"value"`
}

An environment variable to set when launching an MCP server.

type FileSystemCapability

type FileSystemCapability struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Whether the Client supports 'fs/read_text_file' requests.
	//
	// Defaults to false if unset.
	ReadTextFile bool `json:"readTextFile,omitempty"`
	// Whether the Client supports 'fs/write_text_file' requests.
	//
	// Defaults to false if unset.
	WriteTextFile bool `json:"writeTextFile,omitempty"`
}

File system capabilities that a client may support. See protocol docs: [FileSystem](https://agentclientprotocol.com/protocol/initialization#filesystem)

func (FileSystemCapability) MarshalJSON

func (v FileSystemCapability) MarshalJSON() ([]byte, error)

func (*FileSystemCapability) UnmarshalJSON

func (v *FileSystemCapability) UnmarshalJSON(b []byte) error

type HttpHeader

type HttpHeader struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The name of the HTTP header.
	Name string `json:"name"`
	// The value to set for the HTTP header.
	Value string `json:"value"`
}

An HTTP header to set when making requests to the MCP server.

type ImageContent

type ImageContent struct {
	// Extension point for implementations
	Meta        any          `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Data        string       `json:"data"`
	MimeType    string       `json:"mimeType"`
	Uri         *string      `json:"uri,omitempty"`
}

An image provided to or from an LLM.

type InitializeRequest

type InitializeRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Capabilities supported by the client.
	//
	// Defaults to {"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false} if unset.
	ClientCapabilities ClientCapabilities `json:"clientCapabilities,omitempty"`
	// The latest protocol version supported by the client.
	ProtocolVersion ProtocolVersion `json:"protocolVersion"`
}

Request parameters for the initialize method. Sent by the client to establish connection and negotiate capabilities. See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)

func (InitializeRequest) MarshalJSON

func (v InitializeRequest) MarshalJSON() ([]byte, error)

func (*InitializeRequest) UnmarshalJSON

func (v *InitializeRequest) UnmarshalJSON(b []byte) error

func (*InitializeRequest) Validate

func (v *InitializeRequest) Validate() error

type InitializeResponse

type InitializeResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Capabilities supported by the agent.
	//
	// Defaults to {"loadSession":false,"mcpCapabilities":{"http":false,"sse":false},"promptCapabilities":{"audio":false,"embeddedContext":false,"image":false}} if unset.
	AgentCapabilities AgentCapabilities `json:"agentCapabilities,omitempty"`
	// Authentication methods supported by the agent.
	//
	// Defaults to [] if unset.
	AuthMethods []AuthMethod `json:"authMethods"`
	// The protocol version the client specified if supported by the agent, or the latest protocol version supported by the agent.  The client should disconnect, if it doesn't support this version.
	ProtocolVersion ProtocolVersion `json:"protocolVersion"`
}

Response from the initialize method. Contains the negotiated protocol version and agent capabilities. See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)

func (InitializeResponse) MarshalJSON

func (v InitializeResponse) MarshalJSON() ([]byte, error)

func (*InitializeResponse) UnmarshalJSON

func (v *InitializeResponse) UnmarshalJSON(b []byte) error

func (*InitializeResponse) Validate

func (v *InitializeResponse) Validate() error

type KillTerminalCommandRequest

type KillTerminalCommandRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The session ID for this request.
	SessionId SessionId `json:"sessionId"`
	// The ID of the terminal to kill.
	TerminalId string `json:"terminalId"`
}

Request to kill a terminal command without releasing the terminal.

func (*KillTerminalCommandRequest) Validate

func (v *KillTerminalCommandRequest) Validate() error

type KillTerminalCommandResponse

type KillTerminalCommandResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
}

Response to terminal/kill command method

func (*KillTerminalCommandResponse) Validate

func (v *KillTerminalCommandResponse) Validate() error

type LoadSessionRequest

type LoadSessionRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The working directory for this session.
	Cwd string `json:"cwd"`
	// List of MCP servers to connect to for this session.
	McpServers []McpServer `json:"mcpServers"`
	// The ID of the session to load.
	SessionId SessionId `json:"sessionId"`
}

Request parameters for loading an existing session. Only available if the Agent supports the 'loadSession' capability. See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)

func (*LoadSessionRequest) Validate

func (v *LoadSessionRequest) Validate() error

type LoadSessionResponse

type LoadSessionResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// **UNSTABLE**  This capability is not part of the spec yet, and may be removed or changed at any point.  Initial model state if supported by the Agent
	Models *SessionModelState `json:"models,omitempty"`
	// Initial mode state if supported by the Agent  See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
	Modes *SessionModeState `json:"modes,omitempty"`
}

Response from loading an existing session.

func (*LoadSessionResponse) Validate

func (v *LoadSessionResponse) Validate() error

type McpCapabilities

type McpCapabilities struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Agent supports ['McpServer::Http'].
	//
	// Defaults to false if unset.
	Http bool `json:"http,omitempty"`
	// Agent supports ['McpServer::Sse'].
	//
	// Defaults to false if unset.
	Sse bool `json:"sse,omitempty"`
}

MCP capabilities supported by the agent

func (McpCapabilities) MarshalJSON

func (v McpCapabilities) MarshalJSON() ([]byte, error)

func (*McpCapabilities) UnmarshalJSON

func (v *McpCapabilities) UnmarshalJSON(b []byte) error

type McpServer

type McpServer struct {
	Http  *McpServerHttp `json:"-"`
	Sse   *McpServerSse  `json:"-"`
	Stdio *Stdio         `json:"-"`
}

func (McpServer) MarshalJSON

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

func (*McpServer) UnmarshalJSON

func (u *McpServer) UnmarshalJSON(b []byte) error

type McpServerHttp

type McpServerHttp struct {
	// HTTP headers to set when making requests to the MCP server.
	Headers []HttpHeader `json:"headers"`
	// Human-readable name identifying this MCP server.
	Name string `json:"name"`
	Type string `json:"type"`
	// URL to the MCP server.
	Url string `json:"url"`
}

Configuration for connecting to an MCP (Model Context Protocol) server. MCP servers provide tools and context that the agent can use when processing prompts. See protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers) HTTP transport configuration Only available when the Agent capabilities indicate 'mcp_capabilities.http' is 'true'.

type McpServerSse

type McpServerSse struct {
	// HTTP headers to set when making requests to the MCP server.
	Headers []HttpHeader `json:"headers"`
	// Human-readable name identifying this MCP server.
	Name string `json:"name"`
	Type string `json:"type"`
	// URL to the MCP server.
	Url string `json:"url"`
}

SSE transport configuration Only available when the Agent capabilities indicate 'mcp_capabilities.sse' is 'true'.

type MethodHandler

type MethodHandler func(ctx context.Context, method string, params json.RawMessage) (any, *RequestError)

type ModelId

type ModelId string

**UNSTABLE** This capability is not part of the spec yet, and may be removed or changed at any point. A unique identifier for a model.

type ModelInfo

type ModelInfo struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Optional description of the model.
	Description *string `json:"description,omitempty"`
	// Unique identifier for the model.
	ModelId ModelId `json:"modelId"`
	// Human-readable name of the model.
	Name string `json:"name"`
}

**UNSTABLE** This capability is not part of the spec yet, and may be removed or changed at any point. Information about a selectable model.

type NewSessionRequest

type NewSessionRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The working directory for this session. Must be an absolute path.
	Cwd string `json:"cwd"`
	// List of MCP (Model Context Protocol) servers the agent should connect to.
	McpServers []McpServer `json:"mcpServers"`
}

Request parameters for creating a new session. See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)

func (*NewSessionRequest) Validate

func (v *NewSessionRequest) Validate() error

type NewSessionResponse

type NewSessionResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// **UNSTABLE**  This capability is not part of the spec yet, and may be removed or changed at any point.  Initial model state if supported by the Agent
	Models *SessionModelState `json:"models,omitempty"`
	// Initial mode state if supported by the Agent  See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
	Modes *SessionModeState `json:"modes,omitempty"`
	// Unique identifier for the created session.  Used in all subsequent requests for this conversation.
	SessionId SessionId `json:"sessionId"`
}

Response from creating a new session. See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)

func (*NewSessionResponse) Validate

func (v *NewSessionResponse) Validate() error

type PermissionOption

type PermissionOption struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Hint about the nature of this permission option.
	Kind PermissionOptionKind `json:"kind"`
	// Human-readable label to display to the user.
	Name string `json:"name"`
	// Unique identifier for this permission option.
	OptionId PermissionOptionId `json:"optionId"`
}

An option presented to the user when requesting permission.

type PermissionOptionId

type PermissionOptionId string

Unique identifier for a permission option.

type PermissionOptionKind

type PermissionOptionKind string

The type of permission option being presented to the user. Helps clients choose appropriate icons and UI treatment.

const (
	PermissionOptionKindAllowOnce    PermissionOptionKind = "allow_once"
	PermissionOptionKindAllowAlways  PermissionOptionKind = "allow_always"
	PermissionOptionKindRejectOnce   PermissionOptionKind = "reject_once"
	PermissionOptionKindRejectAlways PermissionOptionKind = "reject_always"
)

type Plan

type Plan struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The list of tasks to be accomplished.  When updating a plan, the agent must send a complete list of all entries with their current status. The client replaces the entire plan with each update.
	Entries []PlanEntry `json:"entries"`
}

An execution plan for accomplishing complex tasks. Plans consist of multiple entries representing individual tasks or goals. Agents report plans to clients to provide visibility into their execution strategy. Plans can evolve during execution as the agent discovers new requirements or completes tasks. See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)

type PlanEntry

type PlanEntry struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Human-readable description of what this task aims to accomplish.
	Content string `json:"content"`
	// The relative importance of this task. Used to indicate which tasks are most critical to the overall goal.
	Priority PlanEntryPriority `json:"priority"`
	// Current execution status of this task.
	Status PlanEntryStatus `json:"status"`
}

A single entry in the execution plan. Represents a task or goal that the assistant intends to accomplish as part of fulfilling the user's request. See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)

type PlanEntryPriority

type PlanEntryPriority string

Priority levels for plan entries. Used to indicate the relative importance or urgency of different tasks in the execution plan. See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)

const (
	PlanEntryPriorityHigh   PlanEntryPriority = "high"
	PlanEntryPriorityMedium PlanEntryPriority = "medium"
	PlanEntryPriorityLow    PlanEntryPriority = "low"
)

type PlanEntryStatus

type PlanEntryStatus string

Status of a plan entry in the execution flow. Tracks the lifecycle of each task from planning through completion. See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)

const (
	PlanEntryStatusPending    PlanEntryStatus = "pending"
	PlanEntryStatusInProgress PlanEntryStatus = "in_progress"
	PlanEntryStatusCompleted  PlanEntryStatus = "completed"
)

type PromptCapabilities

type PromptCapabilities struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Agent supports ['ContentBlock::Audio'].
	//
	// Defaults to false if unset.
	Audio bool `json:"audio,omitempty"`
	// Agent supports embedded context in 'session/prompt' requests.  When enabled, the Client is allowed to include ['ContentBlock::Resource'] in prompt requests for pieces of context that are referenced in the message.
	//
	// Defaults to false if unset.
	EmbeddedContext bool `json:"embeddedContext,omitempty"`
	// Agent supports ['ContentBlock::Image'].
	//
	// Defaults to false if unset.
	Image bool `json:"image,omitempty"`
}

Prompt capabilities supported by the agent in 'session/prompt' requests. Baseline agent functionality requires support for ['ContentBlock::Text'] and ['ContentBlock::ResourceLink'] in prompt requests. Other variants must be explicitly opted in to. Capabilities for different types of content in prompt requests. Indicates which content types beyond the baseline (text and resource links) the agent can process. See protocol docs: [Prompt Capabilities](https://agentclientprotocol.com/protocol/initialization#prompt-capabilities)

func (PromptCapabilities) MarshalJSON

func (v PromptCapabilities) MarshalJSON() ([]byte, error)

func (*PromptCapabilities) UnmarshalJSON

func (v *PromptCapabilities) UnmarshalJSON(b []byte) error

type PromptRequest

type PromptRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The blocks of content that compose the user's message.  As a baseline, the Agent MUST support ['ContentBlock::Text'] and ['ContentBlock::ResourceLink'], while other variants are optionally enabled via ['PromptCapabilities'].  The Client MUST adapt its interface according to ['PromptCapabilities'].  The client MAY include referenced pieces of context as either ['ContentBlock::Resource'] or ['ContentBlock::ResourceLink'].  When available, ['ContentBlock::Resource'] is preferred as it avoids extra round-trips and allows the message to include pieces of context from sources the agent may not have access to.
	Prompt []ContentBlock `json:"prompt"`
	// The ID of the session to send this user message to
	SessionId SessionId `json:"sessionId"`
}

Request parameters for sending a user prompt to the agent. Contains the user's message and any additional context. See protocol docs: [User Message](https://agentclientprotocol.com/protocol/prompt-turn#1-user-message)

func (*PromptRequest) Validate

func (v *PromptRequest) Validate() error

type PromptResponse

type PromptResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Indicates why the agent stopped processing the turn.
	StopReason StopReason `json:"stopReason"`
}

Response from processing a user prompt. See protocol docs: [Check for Completion](https://agentclientprotocol.com/protocol/prompt-turn#4-check-for-completion)

func (*PromptResponse) Validate

func (v *PromptResponse) Validate() error

type ProtocolVersion

type ProtocolVersion int

Protocol version identifier. This version is only bumped for breaking changes. Non-breaking changes should be introduced via capabilities.

type ReadTextFileRequest

type ReadTextFileRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Maximum number of lines to read.
	Limit *int `json:"limit,omitempty"`
	// Line number to start reading from (1-based).
	Line *int `json:"line,omitempty"`
	// Absolute path to the file to read.
	Path string `json:"path"`
	// The session ID for this request.
	SessionId SessionId `json:"sessionId"`
}

Request to read content from a text file. Only available if the client supports the 'fs.readTextFile' capability.

func (*ReadTextFileRequest) Validate

func (v *ReadTextFileRequest) Validate() error

type ReadTextFileResponse

type ReadTextFileResponse struct {
	// Extension point for implementations
	Meta    any    `json:"_meta,omitempty"`
	Content string `json:"content"`
}

Response containing the contents of a text file.

func (*ReadTextFileResponse) Validate

func (v *ReadTextFileResponse) Validate() error

type ReleaseTerminalRequest

type ReleaseTerminalRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The session ID for this request.
	SessionId SessionId `json:"sessionId"`
	// The ID of the terminal to release.
	TerminalId string `json:"terminalId"`
}

Request to release a terminal and free its resources.

func (*ReleaseTerminalRequest) Validate

func (v *ReleaseTerminalRequest) Validate() error

type ReleaseTerminalResponse

type ReleaseTerminalResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
}

Response to terminal/release method

func (*ReleaseTerminalResponse) Validate

func (v *ReleaseTerminalResponse) Validate() error

type RequestError

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

RequestError represents a JSON-RPC error response.

func NewAuthRequired

func NewAuthRequired(data any) *RequestError

func NewInternalError

func NewInternalError(data any) *RequestError

func NewInvalidParams

func NewInvalidParams(data any) *RequestError

func NewInvalidRequest

func NewInvalidRequest(data any) *RequestError

func NewMethodNotFound

func NewMethodNotFound(method string) *RequestError

func NewParseError

func NewParseError(data any) *RequestError

func (*RequestError) Error

func (e *RequestError) Error() string

type RequestPermissionOutcome

type RequestPermissionOutcome struct {
	Cancelled *RequestPermissionOutcomeCancelled `json:"-"`
	Selected  *RequestPermissionOutcomeSelected  `json:"-"`
}

func NewRequestPermissionOutcomeCancelled

func NewRequestPermissionOutcomeCancelled() RequestPermissionOutcome

NewRequestPermissionOutcomeCancelled constructs a RequestPermissionOutcome using the 'cancelled' variant.

func NewRequestPermissionOutcomeSelected

func NewRequestPermissionOutcomeSelected(optionId PermissionOptionId) RequestPermissionOutcome

NewRequestPermissionOutcomeSelected constructs a RequestPermissionOutcome using the 'selected' variant.

func (RequestPermissionOutcome) MarshalJSON

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

func (*RequestPermissionOutcome) UnmarshalJSON

func (u *RequestPermissionOutcome) UnmarshalJSON(b []byte) error

func (*RequestPermissionOutcome) Validate

func (u *RequestPermissionOutcome) Validate() error

type RequestPermissionOutcomeCancelled

type RequestPermissionOutcomeCancelled struct {
	Outcome string `json:"outcome"`
}

The outcome of a permission request. The prompt turn was cancelled before the user responded. When a client sends a 'session/cancel' notification to cancel an ongoing prompt turn, it MUST respond to all pending 'session/request_permission' requests with this 'Cancelled' outcome. See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)

type RequestPermissionOutcomeSelected

type RequestPermissionOutcomeSelected struct {
	// The ID of the option the user selected.
	OptionId PermissionOptionId `json:"optionId"`
	Outcome  string             `json:"outcome"`
}

The user selected one of the provided options.

type RequestPermissionRequest

type RequestPermissionRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Available permission options for the user to choose from.
	Options []PermissionOption `json:"options"`
	// The session ID for this request.
	SessionId SessionId `json:"sessionId"`
	// Details about the tool call requiring permission.
	ToolCall ToolCallUpdate `json:"toolCall"`
}

Request for user permission to execute a tool call. Sent when the agent needs authorization before performing a sensitive operation. See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)

func (*RequestPermissionRequest) Validate

func (v *RequestPermissionRequest) Validate() error

type RequestPermissionResponse

type RequestPermissionResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The user's decision on the permission request.
	Outcome RequestPermissionOutcome `json:"outcome"`
}

Response to a permission request.

func (*RequestPermissionResponse) Validate

func (v *RequestPermissionResponse) Validate() error
type ResourceLink struct {
	// Extension point for implementations
	Meta        any          `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Description *string      `json:"description,omitempty"`
	MimeType    *string      `json:"mimeType,omitempty"`
	Name        string       `json:"name"`
	Size        *int         `json:"size,omitempty"`
	Title       *string      `json:"title,omitempty"`
	Uri         string       `json:"uri"`
}

A resource that the server is capable of reading, included in a prompt or tool call result.

type Role

type Role string

The sender or recipient of messages and data in a conversation.

const (
	RoleAssistant Role = "assistant"
	RoleUser      Role = "user"
)

type SessionId

type SessionId string

A unique identifier for a conversation session between a client and agent. Sessions maintain their own context, conversation history, and state, allowing multiple independent interactions with the same agent. # Example ”' use agent_client_protocol::SessionId; use std::sync::Arc; let session_id = SessionId(Arc::from("sess_abc123def456")); ”' See protocol docs: [Session ID](https://agentclientprotocol.com/protocol/session-setup#session-id)

type SessionMode

type SessionMode struct {
	// Extension point for implementations
	Meta        any           `json:"_meta,omitempty"`
	Description *string       `json:"description,omitempty"`
	Id          SessionModeId `json:"id"`
	Name        string        `json:"name"`
}

A mode the agent can operate in. See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)

type SessionModeId

type SessionModeId string

Unique identifier for a Session Mode.

type SessionModeState

type SessionModeState struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The set of modes that the Agent can operate in
	AvailableModes []SessionMode `json:"availableModes"`
	// The current mode the Agent is in.
	CurrentModeId SessionModeId `json:"currentModeId"`
}

The set of modes and the one currently active.

type SessionModelState

type SessionModelState struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The set of models that the Agent can use
	AvailableModels []ModelInfo `json:"availableModels"`
	// The current model the Agent is in.
	CurrentModelId ModelId `json:"currentModelId"`
}

**UNSTABLE** This capability is not part of the spec yet, and may be removed or changed at any point. The set of models and the one currently active.

type SessionNotification

type SessionNotification struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The ID of the session this update pertains to.
	SessionId SessionId `json:"sessionId"`
	// The actual update content.
	Update SessionUpdate `json:"update"`
}

Notification containing a session update from the agent. Used to stream real-time progress and results during prompt processing. See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)

func (*SessionNotification) Validate

func (v *SessionNotification) Validate() error

type SessionUpdate

type SessionUpdate struct {
	UserMessageChunk        *SessionUpdateUserMessageChunk        `json:"-"`
	AgentMessageChunk       *SessionUpdateAgentMessageChunk       `json:"-"`
	AgentThoughtChunk       *SessionUpdateAgentThoughtChunk       `json:"-"`
	ToolCall                *SessionUpdateToolCall                `json:"-"`
	ToolCallUpdate          *SessionUpdateToolCallUpdate          `json:"-"`
	Plan                    *SessionUpdatePlan                    `json:"-"`
	AvailableCommandsUpdate *SessionUpdateAvailableCommandsUpdate `json:"-"`
	CurrentModeUpdate       *SessionUpdateCurrentModeUpdate       `json:"-"`
}

func StartEditToolCall

func StartEditToolCall(id ToolCallId, title string, path string, content any, opts ...ToolCallStartOpt) SessionUpdate

StartEditToolCall constructs a 'tool_call' update for editing content: kind=edit, status=pending, locations=[{path}], rawInput={path, content}.

func StartReadToolCall

func StartReadToolCall(id ToolCallId, title string, path string, opts ...ToolCallStartOpt) SessionUpdate

StartReadToolCall constructs a 'tool_call' update for reading a file: kind=read, status=pending, locations=[{path}], rawInput={path}.

func StartToolCall

func StartToolCall(id ToolCallId, title string, opts ...ToolCallStartOpt) SessionUpdate

StartToolCall constructs a tool_call update with required fields and applies optional modifiers.

func UpdateAgentMessage

func UpdateAgentMessage(content ContentBlock) SessionUpdate

UpdateAgentMessage constructs an agent_message_chunk update with the given content.

func UpdateAgentMessageText

func UpdateAgentMessageText(text string) SessionUpdate

UpdateAgentMessageText constructs an agent_message_chunk update from text.

func UpdateAgentThought

func UpdateAgentThought(content ContentBlock) SessionUpdate

UpdateAgentThought constructs an agent_thought_chunk update with the given content.

func UpdateAgentThoughtText

func UpdateAgentThoughtText(text string) SessionUpdate

UpdateAgentThoughtText constructs an agent_thought_chunk update from text.

func UpdatePlan

func UpdatePlan(entries ...PlanEntry) SessionUpdate

UpdatePlan constructs a plan update with the provided entries.

func UpdateToolCall

func UpdateToolCall(id ToolCallId, opts ...ToolCallUpdateOpt) SessionUpdate

UpdateToolCall constructs a tool_call_update with the given ID and applies optional modifiers.

func UpdateUserMessage

func UpdateUserMessage(content ContentBlock) SessionUpdate

UpdateUserMessage constructs a user_message_chunk update with the given content.

func UpdateUserMessageText

func UpdateUserMessageText(text string) SessionUpdate

UpdateUserMessageText constructs a user_message_chunk update from text.

func (SessionUpdate) MarshalJSON

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

func (*SessionUpdate) UnmarshalJSON

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

func (*SessionUpdate) Validate

func (u *SessionUpdate) Validate() error

type SessionUpdateAgentMessageChunk

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

A chunk of the agent's response being streamed.

type SessionUpdateAgentThoughtChunk

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

A chunk of the agent's internal reasoning being streamed.

type SessionUpdateAvailableCommandsUpdate

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

Available commands are ready or have changed

type SessionUpdateCurrentModeUpdate

type SessionUpdateCurrentModeUpdate struct {
	CurrentModeId SessionModeId `json:"currentModeId"`
	SessionUpdate string        `json:"sessionUpdate"`
}

The current mode of the session has changed See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)

type SessionUpdatePlan

type SessionUpdatePlan struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The list of tasks to be accomplished.  When updating a plan, the agent must send a complete list of all entries with their current status. The client replaces the entire plan with each update.
	Entries       []PlanEntry `json:"entries"`
	SessionUpdate string      `json:"sessionUpdate"`
}

The agent's execution plan for complex tasks. See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)

type SessionUpdateToolCall

type SessionUpdateToolCall struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Content produced by the tool call.
	Content []ToolCallContent `json:"content,omitempty"`
	// The category of tool being invoked. Helps clients choose appropriate icons and UI treatment.
	Kind ToolKind `json:"kind,omitempty"`
	// File locations affected by this tool call. Enables "follow-along" features in clients.
	Locations []ToolCallLocation `json:"locations,omitempty"`
	// Raw input parameters sent to the tool.
	RawInput any `json:"rawInput,omitempty"`
	// Raw output returned by the tool.
	RawOutput     any    `json:"rawOutput,omitempty"`
	SessionUpdate string `json:"sessionUpdate"`
	// Current execution status of the tool call.
	Status ToolCallStatus `json:"status,omitempty"`
	// Human-readable title describing what the tool is doing.
	Title string `json:"title"`
	// Unique identifier for this tool call within the session.
	ToolCallId ToolCallId `json:"toolCallId"`
}

Notification that a new tool call has been initiated.

type SessionUpdateToolCallUpdate

type SessionUpdateToolCallUpdate struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Replace the content collection.
	Content []ToolCallContent `json:"content,omitempty"`
	// Update the tool kind.
	Kind *ToolKind `json:"kind,omitempty"`
	// Replace the locations collection.
	Locations []ToolCallLocation `json:"locations,omitempty"`
	// Update the raw input.
	RawInput any `json:"rawInput,omitempty"`
	// Update the raw output.
	RawOutput     any    `json:"rawOutput,omitempty"`
	SessionUpdate string `json:"sessionUpdate"`
	// Update the execution status.
	Status *ToolCallStatus `json:"status,omitempty"`
	// Update the human-readable title.
	Title *string `json:"title,omitempty"`
	// The ID of the tool call being updated.
	ToolCallId ToolCallId `json:"toolCallId"`
}

Update on the status or results of a tool call.

type SessionUpdateUserMessageChunk

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

Different types of updates that can be sent during session processing. These updates provide real-time feedback about the agent's progress. See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output) A chunk of the user's message being streamed.

type SetSessionModeRequest

type SetSessionModeRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The ID of the mode to set.
	ModeId SessionModeId `json:"modeId"`
	// The ID of the session to set the mode for.
	SessionId SessionId `json:"sessionId"`
}

Request parameters for setting a session mode.

func (*SetSessionModeRequest) Validate

func (v *SetSessionModeRequest) Validate() error

type SetSessionModeResponse

type SetSessionModeResponse struct {
	Meta any `json:"meta,omitempty"`
}

Response to 'session/set_mode' method.

func (*SetSessionModeResponse) Validate

func (v *SetSessionModeResponse) Validate() error

type SetSessionModelRequest

type SetSessionModelRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The ID of the model to set.
	ModelId ModelId `json:"modelId"`
	// The ID of the session to set the model for.
	SessionId SessionId `json:"sessionId"`
}

**UNSTABLE** This capability is not part of the spec yet, and may be removed or changed at any point. Request parameters for setting a session model.

func (*SetSessionModelRequest) Validate

func (v *SetSessionModelRequest) Validate() error

type SetSessionModelResponse

type SetSessionModelResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
}

**UNSTABLE** This capability is not part of the spec yet, and may be removed or changed at any point. Response to 'session/set_model' method.

func (*SetSessionModelResponse) Validate

func (v *SetSessionModelResponse) Validate() error

type Stdio

type Stdio struct {
	// Command-line arguments to pass to the MCP server.
	Args []string `json:"args"`
	// Path to the MCP server executable.
	Command string `json:"command"`
	// Environment variables to set when launching the MCP server.
	Env []EnvVariable `json:"env"`
	// Human-readable name identifying this MCP server.
	Name string `json:"name"`
}

Stdio transport configuration All Agents MUST support this transport.

type StopReason

type StopReason string

Reasons why an agent stops processing a prompt turn. See protocol docs: [Stop Reasons](https://agentclientprotocol.com/protocol/prompt-turn#stop-reasons)

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

type TerminalExitStatus

type TerminalExitStatus struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The process exit code (may be null if terminated by signal).
	ExitCode *int `json:"exitCode,omitempty"`
	// The signal that terminated the process (may be null if exited normally).
	Signal *string `json:"signal,omitempty"`
}

Exit status of a terminal command.

type TerminalOutputRequest

type TerminalOutputRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The session ID for this request.
	SessionId SessionId `json:"sessionId"`
	// The ID of the terminal to get output from.
	TerminalId string `json:"terminalId"`
}

Request to get the current output and status of a terminal.

func (*TerminalOutputRequest) Validate

func (v *TerminalOutputRequest) Validate() error

type TerminalOutputResponse

type TerminalOutputResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Exit status if the command has completed.
	ExitStatus *TerminalExitStatus `json:"exitStatus,omitempty"`
	// The terminal output captured so far.
	Output string `json:"output"`
	// Whether the output was truncated due to byte limits.
	Truncated bool `json:"truncated"`
}

Response containing the terminal output and exit status.

func (*TerminalOutputResponse) Validate

func (v *TerminalOutputResponse) Validate() error

type TextContent

type TextContent struct {
	// Extension point for implementations
	Meta        any          `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Text        string       `json:"text"`
}

Text provided to or from an LLM.

type TextResourceContents

type TextResourceContents struct {
	// Extension point for implementations
	Meta     any     `json:"_meta,omitempty"`
	MimeType *string `json:"mimeType,omitempty"`
	Text     string  `json:"text"`
	Uri      string  `json:"uri"`
}

Text-based resource contents.

type ToolCall

type ToolCall struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Content produced by the tool call.
	Content []ToolCallContent `json:"content,omitempty"`
	// The category of tool being invoked. Helps clients choose appropriate icons and UI treatment.
	Kind ToolKind `json:"kind,omitempty"`
	// File locations affected by this tool call. Enables "follow-along" features in clients.
	Locations []ToolCallLocation `json:"locations,omitempty"`
	// Raw input parameters sent to the tool.
	RawInput any `json:"rawInput,omitempty"`
	// Raw output returned by the tool.
	RawOutput any `json:"rawOutput,omitempty"`
	// Current execution status of the tool call.
	Status ToolCallStatus `json:"status,omitempty"`
	// Human-readable title describing what the tool is doing.
	Title string `json:"title"`
	// Unique identifier for this tool call within the session.
	ToolCallId ToolCallId `json:"toolCallId"`
}

Represents a tool call that the language model has requested. Tool calls are actions that the agent executes on behalf of the language model, such as reading files, executing code, or fetching data from external sources. See protocol docs: [Tool Calls](https://agentclientprotocol.com/protocol/tool-calls)

type ToolCallContent

type ToolCallContent struct {
	Content  *ToolCallContentContent  `json:"-"`
	Diff     *ToolCallContentDiff     `json:"-"`
	Terminal *ToolCallContentTerminal `json:"-"`
}

func ToolContent

func ToolContent(block ContentBlock) ToolCallContent

ToolContent wraps a content block as tool-call content.

func ToolDiffContent

func ToolDiffContent(path string, newText string, oldText ...string) ToolCallContent

ToolDiffContent constructs a diff tool-call content. If oldText is omitted, the field is left empty.

func ToolTerminalRef

func ToolTerminalRef(terminalID string) ToolCallContent

ToolTerminalRef constructs a terminal reference tool-call content.

func (ToolCallContent) MarshalJSON

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

func (*ToolCallContent) UnmarshalJSON

func (u *ToolCallContent) UnmarshalJSON(b []byte) error

func (*ToolCallContent) Validate

func (u *ToolCallContent) Validate() error

type ToolCallContentContent

type ToolCallContentContent struct {
	// The actual content block.
	Content ContentBlock `json:"content"`
	Type    string       `json:"type"`
}

Content produced by a tool call. Tool calls can produce different types of content including standard content blocks (text, images) or file diffs. See protocol docs: [Content](https://agentclientprotocol.com/protocol/tool-calls#content) Standard content block (text, images, resources).

type ToolCallContentDiff

type ToolCallContentDiff struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The new content after modification.
	NewText string `json:"newText"`
	// The original content (None for new files).
	OldText *string `json:"oldText,omitempty"`
	// The file path being modified.
	Path string `json:"path"`
	Type string `json:"type"`
}

File modification shown as a diff.

type ToolCallContentTerminal

type ToolCallContentTerminal struct {
	TerminalId string `json:"terminalId"`
	Type       string `json:"type"`
}

Embed a terminal created with 'terminal/create' by its id. The terminal must be added before calling 'terminal/release'. See protocol docs: [Terminal](https://agentclientprotocol.com/protocol/terminal)

type ToolCallId

type ToolCallId string

Unique identifier for a tool call within a session.

type ToolCallLocation

type ToolCallLocation struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Optional line number within the file.
	Line *int `json:"line,omitempty"`
	// The file path being accessed or modified.
	Path string `json:"path"`
}

A file location being accessed or modified by a tool. Enables clients to implement "follow-along" features that track which files the agent is working with in real-time. See protocol docs: [Following the Agent](https://agentclientprotocol.com/protocol/tool-calls#following-the-agent)

type ToolCallStartOpt

type ToolCallStartOpt func(tc *SessionUpdateToolCall)

func WithStartContent

func WithStartContent(c []ToolCallContent) ToolCallStartOpt

WithStartContent sets the initial content for a tool_call start update.

func WithStartKind

func WithStartKind(k ToolKind) ToolCallStartOpt

WithStartKind sets the kind for a tool_call start update.

func WithStartLocations

func WithStartLocations(l []ToolCallLocation) ToolCallStartOpt

WithStartLocations sets file locations and, if a single path is provided and rawInput is empty, mirrors it as rawInput.path.

func WithStartRawInput

func WithStartRawInput(v any) ToolCallStartOpt

WithStartRawInput sets rawInput for a tool_call start update.

func WithStartRawOutput

func WithStartRawOutput(v any) ToolCallStartOpt

WithStartRawOutput sets rawOutput for a tool_call start update.

func WithStartStatus

func WithStartStatus(s ToolCallStatus) ToolCallStartOpt

WithStartStatus sets the status for a tool_call start update.

type ToolCallStatus

type ToolCallStatus string

Execution status of a tool call. Tool calls progress through different statuses during their lifecycle. See protocol docs: [Status](https://agentclientprotocol.com/protocol/tool-calls#status)

const (
	ToolCallStatusPending    ToolCallStatus = "pending"
	ToolCallStatusInProgress ToolCallStatus = "in_progress"
	ToolCallStatusCompleted  ToolCallStatus = "completed"
	ToolCallStatusFailed     ToolCallStatus = "failed"
)

type ToolCallUpdate

type ToolCallUpdate struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// Replace the content collection.
	Content []ToolCallContent `json:"content,omitempty"`
	// Update the tool kind.
	Kind *ToolKind `json:"kind,omitempty"`
	// Replace the locations collection.
	Locations []ToolCallLocation `json:"locations,omitempty"`
	// Update the raw input.
	RawInput any `json:"rawInput,omitempty"`
	// Update the raw output.
	RawOutput any `json:"rawOutput,omitempty"`
	// Update the execution status.
	Status *ToolCallStatus `json:"status,omitempty"`
	// Update the human-readable title.
	Title *string `json:"title,omitempty"`
	// The ID of the tool call being updated.
	ToolCallId ToolCallId `json:"toolCallId"`
}

An update to an existing tool call. Used to report progress and results as tools execute. All fields except the tool call ID are optional - only changed fields need to be included. See protocol docs: [Updating](https://agentclientprotocol.com/protocol/tool-calls#updating)

func (*ToolCallUpdate) Validate

func (t *ToolCallUpdate) Validate() error

type ToolCallUpdateOpt

type ToolCallUpdateOpt func(tu *SessionUpdateToolCallUpdate)

func WithUpdateContent

func WithUpdateContent(c []ToolCallContent) ToolCallUpdateOpt

WithUpdateContent replaces the content collection for a tool_call_update.

func WithUpdateKind

func WithUpdateKind(k ToolKind) ToolCallUpdateOpt

WithUpdateKind sets the kind for a tool_call_update.

func WithUpdateLocations

func WithUpdateLocations(l []ToolCallLocation) ToolCallUpdateOpt

WithUpdateLocations replaces the locations collection for a tool_call_update.

func WithUpdateRawInput

func WithUpdateRawInput(v any) ToolCallUpdateOpt

WithUpdateRawInput sets rawInput for a tool_call_update.

func WithUpdateRawOutput

func WithUpdateRawOutput(v any) ToolCallUpdateOpt

WithUpdateRawOutput sets rawOutput for a tool_call_update.

func WithUpdateStatus

func WithUpdateStatus(s ToolCallStatus) ToolCallUpdateOpt

WithUpdateStatus sets the status for a tool_call_update.

func WithUpdateTitle

func WithUpdateTitle(t string) ToolCallUpdateOpt

WithUpdateTitle sets the title for a tool_call_update.

type ToolKind

type ToolKind string

Categories of tools that can be invoked. Tool kinds help clients choose appropriate icons and optimize how they display tool execution progress. See protocol docs: [Creating](https://agentclientprotocol.com/protocol/tool-calls#creating)

const (
	ToolKindRead       ToolKind = "read"
	ToolKindEdit       ToolKind = "edit"
	ToolKindDelete     ToolKind = "delete"
	ToolKindMove       ToolKind = "move"
	ToolKindSearch     ToolKind = "search"
	ToolKindExecute    ToolKind = "execute"
	ToolKindThink      ToolKind = "think"
	ToolKindFetch      ToolKind = "fetch"
	ToolKindSwitchMode ToolKind = "switch_mode"
	ToolKindOther      ToolKind = "other"
)

type UnstructuredCommandInput

type UnstructuredCommandInput struct {
	// A hint to display when the input hasn't been provided yet
	Hint string `json:"hint"`
}

The input specification for a command. All text that was typed after the command name is provided as input.

type WaitForTerminalExitRequest

type WaitForTerminalExitRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The session ID for this request.
	SessionId SessionId `json:"sessionId"`
	// The ID of the terminal to wait for.
	TerminalId string `json:"terminalId"`
}

Request to wait for a terminal command to exit.

func (*WaitForTerminalExitRequest) Validate

func (v *WaitForTerminalExitRequest) Validate() error

type WaitForTerminalExitResponse

type WaitForTerminalExitResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The process exit code (may be null if terminated by signal).
	ExitCode *int `json:"exitCode,omitempty"`
	// The signal that terminated the process (may be null if exited normally).
	Signal *string `json:"signal,omitempty"`
}

Response containing the exit status of a terminal command.

func (*WaitForTerminalExitResponse) Validate

func (v *WaitForTerminalExitResponse) Validate() error

type WriteTextFileRequest

type WriteTextFileRequest struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
	// The text content to write to the file.
	Content string `json:"content"`
	// Absolute path to the file to write.
	Path string `json:"path"`
	// The session ID for this request.
	SessionId SessionId `json:"sessionId"`
}

Request to write content to a text file. Only available if the client supports the 'fs.writeTextFile' capability.

func (*WriteTextFileRequest) Validate

func (v *WriteTextFileRequest) Validate() error

type WriteTextFileResponse

type WriteTextFileResponse struct {
	// Extension point for implementations
	Meta any `json:"_meta,omitempty"`
}

Response to 'fs/write_text_file'

func (*WriteTextFileResponse) Validate

func (v *WriteTextFileResponse) Validate() error

Directories

Path Synopsis
example
agent command
claude-code command
client command
gemini command

Jump to

Keyboard shortcuts

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