Documentation
¶
Overview ¶
Package acp provides the core Agent Client Protocol app/session helpers over JSON-RPC.
It intentionally stays transport-light: use AgentApp.Connect or ClientApp.Connect with any io.ReadWriteCloser carrying newline-delimited JSON-RPC messages (acp.Stdio for stdio agents), ConnectWebSocket with anything implementing jsonrpc2.WebSocket, or ConnectAgent for in-process tests.
Index ¶
- Constants
- Variables
- func AuthenticationRequiredError(data any) error
- func Combine(r io.Reader, w io.Writer) io.ReadWriteCloser
- func InvalidParamsError(err error) error
- func RPCError(code int64, message string, data any) error
- func RequestCancelledError(data any) error
- func ResourceNotFoundError(uri string) error
- func Stdio() io.ReadWriteCloser
- type ActiveSession
- func (s *ActiveSession) Dispose()
- func (s *ActiveSession) NewSessionResponse() schema.NewSessionResponse
- func (s *ActiveSession) NextUpdate(ctx context.Context) (ActiveSessionMessage, error)
- func (s *ActiveSession) Prompt(ctx context.Context, prompt any) (schema.PromptResponse, error)
- func (s *ActiveSession) PromptAsync(ctx context.Context, prompt any) *PromptCall
- func (s *ActiveSession) PushMarker(tag string)
- func (s *ActiveSession) ReadText(ctx context.Context) (string, error)
- func (s *ActiveSession) SessionID() schema.SessionId
- type ActiveSessionMessage
- type ActiveSessionMessageKind
- type AgentApp
- func Agent(options ...AppOptions) *AgentApp
- func NewAgentApp(options ...AppOptions) *AgentApp
- func RegisterAgentNotification[P any](app *AgentApp, method schema.Method, handler AgentNotificationHandler[P]) *AgentApp
- func RegisterAgentRequest[P any, R any](app *AgentApp, method schema.Method, handler AgentRequestHandler[P, R]) *AgentApp
- func (app *AgentApp) Connect(ctx context.Context, rwc io.ReadWriteCloser) (*AgentConnection, error)
- func (app *AgentApp) ConnectWebSocket(ctx context.Context, ws jsonrpc2.WebSocket) (*AgentConnection, error)
- func (app *AgentApp) ConnectWith(ctx context.Context, rwc io.ReadWriteCloser, ...) error
- func (app *AgentApp) OnAuthenticate(...) *AgentApp
- func (app *AgentApp) OnCancel(handler AgentNotificationHandler[schema.CancelNotification]) *AgentApp
- func (app *AgentApp) OnCloseSession(...) *AgentApp
- func (app *AgentApp) OnConnect(handler func(context.Context, *AgentConnection) error) *AgentApp
- func (app *AgentApp) OnDeleteSession(...) *AgentApp
- func (app *AgentApp) OnInitialize(...) *AgentApp
- func (app *AgentApp) OnListSessions(...) *AgentApp
- func (app *AgentApp) OnLoadSession(...) *AgentApp
- func (app *AgentApp) OnLogout(handler AgentRequestHandler[schema.LogoutRequest, schema.LogoutResponse]) *AgentApp
- func (app *AgentApp) OnNewSession(...) *AgentApp
- func (app *AgentApp) OnPrompt(handler AgentRequestHandler[schema.PromptRequest, schema.PromptResponse]) *AgentApp
- func (app *AgentApp) OnResumeSession(...) *AgentApp
- func (app *AgentApp) OnSetSessionConfigOption(...) *AgentApp
- func (app *AgentApp) OnSetSessionMode(...) *AgentApp
- type AgentConnection
- type AgentNotification
- type AgentNotificationHandler
- type AgentPeer
- func (c *AgentPeer) AttachSession(id schema.SessionId) *ActiveSession
- func (c *AgentPeer) Authenticate(ctx context.Context, request schema.AuthenticateRequest) (schema.AuthenticateResponse, error)
- func (c *AgentPeer) BuildSession(cwd string) *SessionBuilder
- func (c *AgentPeer) BuildSessionRequest(request schema.NewSessionRequest) *SessionBuilder
- func (c *AgentPeer) Cancel(ctx context.Context, notification schema.CancelNotification) error
- func (c *AgentPeer) CloseSession(ctx context.Context, request schema.CloseSessionRequest) (schema.CloseSessionResponse, error)
- func (c *AgentPeer) DeleteSession(ctx context.Context, request schema.DeleteSessionRequest) (schema.DeleteSessionResponse, error)
- func (c *AgentPeer) Initialize(ctx context.Context, request schema.InitializeRequest) (schema.InitializeResponse, error)
- func (c *AgentPeer) ListSessions(ctx context.Context, request schema.ListSessionsRequest) (schema.ListSessionsResponse, error)
- func (c *AgentPeer) LoadSession(ctx context.Context, request schema.LoadSessionRequest) (schema.LoadSessionResponse, error)
- func (c *AgentPeer) Logout(ctx context.Context, request schema.LogoutRequest) (schema.LogoutResponse, error)
- func (c *AgentPeer) NewSession(ctx context.Context, request schema.NewSessionRequest) (schema.NewSessionResponse, error)
- func (c *AgentPeer) Notify(ctx context.Context, method schema.Method, params any) error
- func (c *AgentPeer) Prompt(ctx context.Context, request schema.PromptRequest) (schema.PromptResponse, error)
- func (c *AgentPeer) Request(ctx context.Context, method schema.Method, params any, result any) error
- func (c *AgentPeer) RequestID() (jsonrpc2.ID, bool)
- func (c *AgentPeer) ResumeSession(ctx context.Context, request schema.ResumeSessionRequest) (schema.ResumeSessionResponse, error)
- func (c *AgentPeer) SetSessionConfigOption(ctx context.Context, request schema.SetSessionConfigOptionRequest) (schema.SetSessionConfigOptionResponse, error)
- func (c *AgentPeer) SetSessionMode(ctx context.Context, request schema.SetSessionModeRequest) (schema.SetSessionModeResponse, error)
- type AgentRequest
- type AgentRequestHandler
- type AppOptions
- type ClientApp
- func Client(options ...AppOptions) *ClientApp
- func NewClientApp(options ...AppOptions) *ClientApp
- func RegisterClientNotification[P any](app *ClientApp, method schema.Method, handler ClientNotificationHandler[P]) *ClientApp
- func RegisterClientRequest[P any, R any](app *ClientApp, method schema.Method, handler ClientRequestHandler[P, R]) *ClientApp
- func (app *ClientApp) Connect(ctx context.Context, rwc io.ReadWriteCloser) (*ClientConnection, error)
- func (app *ClientApp) ConnectAgent(ctx context.Context, agent *AgentApp) (*ClientConnection, *AgentConnection, error)
- func (app *ClientApp) ConnectWebSocket(ctx context.Context, ws jsonrpc2.WebSocket) (*ClientConnection, error)
- func (app *ClientApp) ConnectWith(ctx context.Context, rwc io.ReadWriteCloser, ...) error
- func (app *ClientApp) ConnectWithAgent(ctx context.Context, agent *AgentApp, ...) error
- func (app *ClientApp) OnCompleteElicitation(handler ClientNotificationHandler[schema.CompleteElicitationNotification]) *ClientApp
- func (app *ClientApp) OnConnect(handler func(context.Context, *ClientConnection) error) *ClientApp
- func (app *ClientApp) OnCreateElicitation(...) *ClientApp
- func (app *ClientApp) OnCreateTerminal(...) *ClientApp
- func (app *ClientApp) OnKillTerminal(...) *ClientApp
- func (app *ClientApp) OnReadTextFile(...) *ClientApp
- func (app *ClientApp) OnReleaseTerminal(...) *ClientApp
- func (app *ClientApp) OnRequestPermission(...) *ClientApp
- func (app *ClientApp) OnSessionUpdate(handler ClientNotificationHandler[schema.SessionNotification]) *ClientApp
- func (app *ClientApp) OnTerminalOutput(...) *ClientApp
- func (app *ClientApp) OnWaitForTerminalExit(...) *ClientApp
- func (app *ClientApp) OnWriteTextFile(...) *ClientApp
- type ClientConnection
- type ClientNotification
- type ClientNotificationHandler
- type ClientPeer
- func (c *ClientPeer) CompleteElicitation(ctx context.Context, notification schema.CompleteElicitationNotification) error
- func (c *ClientPeer) CreateElicitation(ctx context.Context, request schema.CreateElicitationRequest) (schema.CreateElicitationResponse, error)
- func (c *ClientPeer) CreateTerminal(ctx context.Context, request schema.CreateTerminalRequest) (schema.CreateTerminalResponse, error)
- func (c *ClientPeer) KillTerminal(ctx context.Context, request schema.KillTerminalRequest) (schema.KillTerminalResponse, error)
- func (c *ClientPeer) Notify(ctx context.Context, method schema.Method, params any) error
- func (c *ClientPeer) ReadTextFile(ctx context.Context, request schema.ReadTextFileRequest) (schema.ReadTextFileResponse, error)
- func (c *ClientPeer) ReleaseTerminal(ctx context.Context, request schema.ReleaseTerminalRequest) (schema.ReleaseTerminalResponse, error)
- func (c *ClientPeer) Request(ctx context.Context, method schema.Method, params any, result any) error
- func (c *ClientPeer) RequestID() (jsonrpc2.ID, bool)
- func (c *ClientPeer) RequestPermission(ctx context.Context, request schema.RequestPermissionRequest) (schema.RequestPermissionResponse, error)
- func (c *ClientPeer) SessionUpdate(ctx context.Context, notification schema.SessionNotification) error
- func (c *ClientPeer) TerminalOutput(ctx context.Context, request schema.TerminalOutputRequest) (schema.TerminalOutputResponse, error)
- func (c *ClientPeer) WaitForTerminalExit(ctx context.Context, request schema.WaitForTerminalExitRequest) (schema.WaitForTerminalExitResponse, error)
- func (c *ClientPeer) WriteTextFile(ctx context.Context, request schema.WriteTextFileRequest) (schema.WriteTextFileResponse, error)
- type ClientRequest
- type ClientRequestHandler
- type PromptCall
- type SessionBuilder
- func (b *SessionBuilder) Request() schema.NewSessionRequest
- func (b *SessionBuilder) Start(ctx context.Context) (*ActiveSession, error)
- func (b *SessionBuilder) WithAdditionalDirectories(dirs ...string) *SessionBuilder
- func (b *SessionBuilder) WithMCPServer(server schema.McpServer) *SessionBuilder
- func (b *SessionBuilder) WithSession(ctx context.Context, op func(context.Context, *ActiveSession) error) error
Constants ¶
const ( CodeParseError = int64(schema.ErrorCodeParseError) CodeInvalidRequest = int64(schema.ErrorCodeInvalidRequest) CodeMethodNotFound = int64(schema.ErrorCodeMethodNotFound) CodeInvalidParams = int64(schema.ErrorCodeInvalidParams) CodeInternalError = int64(schema.ErrorCodeInternalError) CodeRequestCancelled = int64(schema.ErrorCodeRequestCancelled) CodeAuthentication = int64(schema.ErrorCodeAuthenticationRequired) CodeResourceNotFound = int64(schema.ErrorCodeResourceNotFound) )
Wire error codes, from schema.ErrorCode.
Variables ¶
var ErrActiveSessionClosed = errors.New("active ACP session closed")
var ErrSessionCancelled = errors.New("ACP session cancelled")
ErrSessionCancelled is the cancellation cause of a session/prompt handler's context once the client sends session/cancel for that session.
An agent observes cancellation through ctx alone: stop work, flush any pending SessionUpdate notifications (they are still delivered), and return. If the handler returns an error after the cancel, such as ctx.Err(), the client is answered with StopReasonCancelled as the protocol requires.
Functions ¶
func Combine ¶
Combine joins a reader and a writer into the io.ReadWriteCloser expected by AgentApp.Connect and ClientApp.Connect. Close closes whichever halves implement io.Closer.
func InvalidParamsError ¶
func RequestCancelledError ¶
func ResourceNotFoundError ¶
func Stdio ¶
func Stdio() io.ReadWriteCloser
Stdio is the standard agent transport: JSON-RPC read from stdin, written to stdout.
Types ¶
type ActiveSession ¶
type ActiveSession struct {
// contains filtered or unexported fields
}
func (*ActiveSession) Dispose ¶
func (s *ActiveSession) Dispose()
func (*ActiveSession) NewSessionResponse ¶
func (s *ActiveSession) NewSessionResponse() schema.NewSessionResponse
func (*ActiveSession) NextUpdate ¶
func (s *ActiveSession) NextUpdate(ctx context.Context) (ActiveSessionMessage, error)
func (*ActiveSession) Prompt ¶
func (s *ActiveSession) Prompt(ctx context.Context, prompt any) (schema.PromptResponse, error)
func (*ActiveSession) PromptAsync ¶
func (s *ActiveSession) PromptAsync(ctx context.Context, prompt any) *PromptCall
func (*ActiveSession) PushMarker ¶
func (s *ActiveSession) PushMarker(tag string)
PushMarker enqueues an application-defined marker delivered in order after every update already routed to this session. Because updates are routed synchronously on the read loop before any later message is read, pushing a marker right after a request (session/load, session/resume) resolves gives an in-stream barrier: everything the agent sent before responding is guaranteed to be dequeued before the marker.
func (*ActiveSession) ReadText ¶
func (s *ActiveSession) ReadText(ctx context.Context) (string, error)
func (*ActiveSession) SessionID ¶
func (s *ActiveSession) SessionID() schema.SessionId
type ActiveSessionMessage ¶
type ActiveSessionMessage struct {
Kind ActiveSessionMessageKind
Notification schema.SessionNotification
Update schema.SessionUpdate
Response schema.PromptResponse
StopReason schema.StopReason
// Err is set on a Stop message whose prompt failed. A NextUpdate error, by
// contrast, always means the stream itself terminated (disposed, connection
// closed, or ctx done).
Err error
// Marker is the tag passed to PushMarker for Marker messages.
Marker string
}
type ActiveSessionMessageKind ¶
type ActiveSessionMessageKind string
const ( ActiveSessionMessageUpdate ActiveSessionMessageKind = "session_update" ActiveSessionMessageStop ActiveSessionMessageKind = "stop" ActiveSessionMessageMarker ActiveSessionMessageKind = "marker" )
type AgentApp ¶
type AgentApp struct {
// contains filtered or unexported fields
}
func Agent ¶
func Agent(options ...AppOptions) *AgentApp
Agent creates an agent app; register handlers on it and Connect it to a client.
func NewAgentApp ¶
func NewAgentApp(options ...AppOptions) *AgentApp
func RegisterAgentNotification ¶
func RegisterAgentNotification[P any](app *AgentApp, method schema.Method, handler AgentNotificationHandler[P]) *AgentApp
RegisterAgentNotification registers a typed handler for an agent-bound notification.
func RegisterAgentRequest ¶
func RegisterAgentRequest[P any, R any](app *AgentApp, method schema.Method, handler AgentRequestHandler[P, R]) *AgentApp
RegisterAgentRequest registers a typed handler for an agent-bound request method. Free functions are used for registration because Go methods cannot introduce type parameters; the On* methods cover the stable ACP surface.
func (*AgentApp) Connect ¶
func (app *AgentApp) Connect(ctx context.Context, rwc io.ReadWriteCloser) (*AgentConnection, error)
Connect serves the app over newline-delimited JSON-RPC, e.g. acp.Stdio().
func (*AgentApp) ConnectWebSocket ¶
func (app *AgentApp) ConnectWebSocket(ctx context.Context, ws jsonrpc2.WebSocket) (*AgentConnection, error)
ConnectWebSocket serves the app over a message-oriented WebSocket, one JSON-RPC message per text frame.
func (*AgentApp) ConnectWith ¶
func (app *AgentApp) ConnectWith(ctx context.Context, rwc io.ReadWriteCloser, op func(context.Context, *AgentConnection) error) error
ConnectWith connects over rwc, runs op, and closes the connection when op returns.
func (*AgentApp) OnAuthenticate ¶
func (app *AgentApp) OnAuthenticate(handler AgentRequestHandler[schema.AuthenticateRequest, schema.AuthenticateResponse]) *AgentApp
func (*AgentApp) OnCancel ¶
func (app *AgentApp) OnCancel(handler AgentNotificationHandler[schema.CancelNotification]) *AgentApp
func (*AgentApp) OnCloseSession ¶
func (app *AgentApp) OnCloseSession(handler AgentRequestHandler[schema.CloseSessionRequest, schema.CloseSessionResponse]) *AgentApp
func (*AgentApp) OnConnect ¶
OnConnect runs handler once a connection is established, before Connect returns.
func (*AgentApp) OnDeleteSession ¶
func (app *AgentApp) OnDeleteSession(handler AgentRequestHandler[schema.DeleteSessionRequest, schema.DeleteSessionResponse]) *AgentApp
func (*AgentApp) OnInitialize ¶
func (app *AgentApp) OnInitialize(handler AgentRequestHandler[schema.InitializeRequest, schema.InitializeResponse]) *AgentApp
func (*AgentApp) OnListSessions ¶
func (app *AgentApp) OnListSessions(handler AgentRequestHandler[schema.ListSessionsRequest, schema.ListSessionsResponse]) *AgentApp
func (*AgentApp) OnLoadSession ¶
func (app *AgentApp) OnLoadSession(handler AgentRequestHandler[schema.LoadSessionRequest, schema.LoadSessionResponse]) *AgentApp
func (*AgentApp) OnLogout ¶
func (app *AgentApp) OnLogout(handler AgentRequestHandler[schema.LogoutRequest, schema.LogoutResponse]) *AgentApp
func (*AgentApp) OnNewSession ¶
func (app *AgentApp) OnNewSession(handler AgentRequestHandler[schema.NewSessionRequest, schema.NewSessionResponse]) *AgentApp
func (*AgentApp) OnPrompt ¶
func (app *AgentApp) OnPrompt(handler AgentRequestHandler[schema.PromptRequest, schema.PromptResponse]) *AgentApp
func (*AgentApp) OnResumeSession ¶
func (app *AgentApp) OnResumeSession(handler AgentRequestHandler[schema.ResumeSessionRequest, schema.ResumeSessionResponse]) *AgentApp
func (*AgentApp) OnSetSessionConfigOption ¶
func (app *AgentApp) OnSetSessionConfigOption(handler AgentRequestHandler[schema.SetSessionConfigOptionRequest, schema.SetSessionConfigOptionResponse]) *AgentApp
func (*AgentApp) OnSetSessionMode ¶
func (app *AgentApp) OnSetSessionMode(handler AgentRequestHandler[schema.SetSessionModeRequest, schema.SetSessionModeResponse]) *AgentApp
type AgentConnection ¶
type AgentConnection struct {
// contains filtered or unexported fields
}
func (*AgentConnection) Client ¶
func (c *AgentConnection) Client() *ClientPeer
Client is the handle for calling into the connected client.
type AgentNotification ¶
type AgentNotification[P any] struct { Params P Client *ClientPeer }
type AgentNotificationHandler ¶
type AgentNotificationHandler[P any] func(context.Context, AgentNotification[P]) error
type AgentPeer ¶
type AgentPeer struct {
// contains filtered or unexported fields
}
AgentPeer is the client's handle for calling into the agent.
func (*AgentPeer) AttachSession ¶
func (c *AgentPeer) AttachSession(id schema.SessionId) *ActiveSession
AttachSession attaches to an existing session by id, subscribing to its session/update stream. Use it for sessions the agent already knows about (session/load, session/resume): attach BEFORE issuing the load/resume call so notifications replayed while the call is in flight are queued in order.
func (*AgentPeer) Authenticate ¶
func (c *AgentPeer) Authenticate(ctx context.Context, request schema.AuthenticateRequest) (schema.AuthenticateResponse, error)
func (*AgentPeer) BuildSession ¶
func (c *AgentPeer) BuildSession(cwd string) *SessionBuilder
func (*AgentPeer) BuildSessionRequest ¶
func (c *AgentPeer) BuildSessionRequest(request schema.NewSessionRequest) *SessionBuilder
func (*AgentPeer) Cancel ¶
Cancel asks the agent to stop the session's current prompt turn. The agent flushes pending session/update notifications and finishes the in-flight session/prompt with StopReason "cancelled".
func (*AgentPeer) CloseSession ¶
func (c *AgentPeer) CloseSession(ctx context.Context, request schema.CloseSessionRequest) (schema.CloseSessionResponse, error)
func (*AgentPeer) DeleteSession ¶
func (c *AgentPeer) DeleteSession(ctx context.Context, request schema.DeleteSessionRequest) (schema.DeleteSessionResponse, error)
func (*AgentPeer) Initialize ¶
func (c *AgentPeer) Initialize(ctx context.Context, request schema.InitializeRequest) (schema.InitializeResponse, error)
func (*AgentPeer) ListSessions ¶
func (c *AgentPeer) ListSessions(ctx context.Context, request schema.ListSessionsRequest) (schema.ListSessionsResponse, error)
func (*AgentPeer) LoadSession ¶
func (c *AgentPeer) LoadSession(ctx context.Context, request schema.LoadSessionRequest) (schema.LoadSessionResponse, error)
func (*AgentPeer) Logout ¶
func (c *AgentPeer) Logout(ctx context.Context, request schema.LogoutRequest) (schema.LogoutResponse, error)
func (*AgentPeer) NewSession ¶
func (c *AgentPeer) NewSession(ctx context.Context, request schema.NewSessionRequest) (schema.NewSessionResponse, error)
func (*AgentPeer) Prompt ¶
func (c *AgentPeer) Prompt(ctx context.Context, request schema.PromptRequest) (schema.PromptResponse, error)
func (*AgentPeer) Request ¶
func (c *AgentPeer) Request(ctx context.Context, method schema.Method, params any, result any) error
Request sends an arbitrary agent-bound request; use it for extension or unstable methods that have no typed wrapper.
func (*AgentPeer) RequestID ¶
RequestID returns the inbound request id when this peer handle was passed to a request handler.
func (*AgentPeer) ResumeSession ¶
func (c *AgentPeer) ResumeSession(ctx context.Context, request schema.ResumeSessionRequest) (schema.ResumeSessionResponse, error)
func (*AgentPeer) SetSessionConfigOption ¶
func (c *AgentPeer) SetSessionConfigOption(ctx context.Context, request schema.SetSessionConfigOptionRequest) (schema.SetSessionConfigOptionResponse, error)
func (*AgentPeer) SetSessionMode ¶
func (c *AgentPeer) SetSessionMode(ctx context.Context, request schema.SetSessionModeRequest) (schema.SetSessionModeResponse, error)
type AgentRequest ¶
type AgentRequest[P any] struct { Params P Client *ClientPeer RequestID jsonrpc2.ID }
type AgentRequestHandler ¶
type AppOptions ¶
type AppOptions struct {
OnInternalError func(error)
OnNotificationError func(error)
// MaxMessageBytes limits the size of one incoming newline-delimited
// message. Zero means jsonrpc2.DefaultMaxMessageBytes (32 MiB); a negative
// value means no limit. WebSocket adapters enforce their own read limit.
MaxMessageBytes int
}
type ClientApp ¶
type ClientApp struct {
// contains filtered or unexported fields
}
func Client ¶
func Client(options ...AppOptions) *ClientApp
Client creates a client app; register handlers on it and Connect it to an agent.
func NewClientApp ¶
func NewClientApp(options ...AppOptions) *ClientApp
func RegisterClientNotification ¶
func RegisterClientNotification[P any](app *ClientApp, method schema.Method, handler ClientNotificationHandler[P]) *ClientApp
RegisterClientNotification registers a typed handler for a client-bound notification.
func RegisterClientRequest ¶
func RegisterClientRequest[P any, R any](app *ClientApp, method schema.Method, handler ClientRequestHandler[P, R]) *ClientApp
RegisterClientRequest registers a typed handler for a client-bound request method.
func (*ClientApp) Connect ¶
func (app *ClientApp) Connect(ctx context.Context, rwc io.ReadWriteCloser) (*ClientConnection, error)
Connect serves the app over newline-delimited JSON-RPC.
func (*ClientApp) ConnectAgent ¶
func (app *ClientApp) ConnectAgent(ctx context.Context, agent *AgentApp) (*ClientConnection, *AgentConnection, error)
ConnectAgent wires the client and agent apps together in process, useful for tests and embedding an agent in the client binary.
func (*ClientApp) ConnectWebSocket ¶
func (app *ClientApp) ConnectWebSocket(ctx context.Context, ws jsonrpc2.WebSocket) (*ClientConnection, error)
ConnectWebSocket serves the app over a message-oriented WebSocket, one JSON-RPC message per text frame.
func (*ClientApp) ConnectWith ¶
func (app *ClientApp) ConnectWith(ctx context.Context, rwc io.ReadWriteCloser, op func(context.Context, *ClientConnection) error) error
ConnectWith connects over rwc, runs op, and closes the connection when op returns.
func (*ClientApp) ConnectWithAgent ¶
func (app *ClientApp) ConnectWithAgent(ctx context.Context, agent *AgentApp, op func(context.Context, *AgentPeer) error) error
ConnectWithAgent runs op against an in-process agent and tears both ends down after.
func (*ClientApp) OnCompleteElicitation ¶
func (app *ClientApp) OnCompleteElicitation(handler ClientNotificationHandler[schema.CompleteElicitationNotification]) *ClientApp
func (*ClientApp) OnConnect ¶
OnConnect runs handler once a connection is established, before Connect returns.
func (*ClientApp) OnCreateElicitation ¶
func (app *ClientApp) OnCreateElicitation(handler ClientRequestHandler[schema.CreateElicitationRequest, schema.CreateElicitationResponse]) *ClientApp
func (*ClientApp) OnCreateTerminal ¶
func (app *ClientApp) OnCreateTerminal(handler ClientRequestHandler[schema.CreateTerminalRequest, schema.CreateTerminalResponse]) *ClientApp
func (*ClientApp) OnKillTerminal ¶
func (app *ClientApp) OnKillTerminal(handler ClientRequestHandler[schema.KillTerminalRequest, schema.KillTerminalResponse]) *ClientApp
func (*ClientApp) OnReadTextFile ¶
func (app *ClientApp) OnReadTextFile(handler ClientRequestHandler[schema.ReadTextFileRequest, schema.ReadTextFileResponse]) *ClientApp
func (*ClientApp) OnReleaseTerminal ¶
func (app *ClientApp) OnReleaseTerminal(handler ClientRequestHandler[schema.ReleaseTerminalRequest, schema.ReleaseTerminalResponse]) *ClientApp
func (*ClientApp) OnRequestPermission ¶
func (app *ClientApp) OnRequestPermission(handler ClientRequestHandler[schema.RequestPermissionRequest, schema.RequestPermissionResponse]) *ClientApp
func (*ClientApp) OnSessionUpdate ¶
func (app *ClientApp) OnSessionUpdate(handler ClientNotificationHandler[schema.SessionNotification]) *ClientApp
func (*ClientApp) OnTerminalOutput ¶
func (app *ClientApp) OnTerminalOutput(handler ClientRequestHandler[schema.TerminalOutputRequest, schema.TerminalOutputResponse]) *ClientApp
func (*ClientApp) OnWaitForTerminalExit ¶
func (app *ClientApp) OnWaitForTerminalExit(handler ClientRequestHandler[schema.WaitForTerminalExitRequest, schema.WaitForTerminalExitResponse]) *ClientApp
func (*ClientApp) OnWriteTextFile ¶
func (app *ClientApp) OnWriteTextFile(handler ClientRequestHandler[schema.WriteTextFileRequest, schema.WriteTextFileResponse]) *ClientApp
type ClientConnection ¶
type ClientConnection struct {
// contains filtered or unexported fields
}
func (*ClientConnection) Agent ¶
func (c *ClientConnection) Agent() *AgentPeer
Agent is the handle for calling into the connected agent.
type ClientNotification ¶
type ClientNotificationHandler ¶
type ClientNotificationHandler[P any] func(context.Context, ClientNotification[P]) error
type ClientPeer ¶
type ClientPeer struct {
// contains filtered or unexported fields
}
ClientPeer is the agent's handle for calling back into the client.
func (*ClientPeer) CompleteElicitation ¶
func (c *ClientPeer) CompleteElicitation(ctx context.Context, notification schema.CompleteElicitationNotification) error
CompleteElicitation tells the client a URL-mode elicitation has finished.
func (*ClientPeer) CreateElicitation ¶
func (c *ClientPeer) CreateElicitation(ctx context.Context, request schema.CreateElicitationRequest) (schema.CreateElicitationResponse, error)
CreateElicitation asks the client to collect structured input from the user, through a form or by opening a URL.
func (*ClientPeer) CreateTerminal ¶
func (c *ClientPeer) CreateTerminal(ctx context.Context, request schema.CreateTerminalRequest) (schema.CreateTerminalResponse, error)
func (*ClientPeer) KillTerminal ¶
func (c *ClientPeer) KillTerminal(ctx context.Context, request schema.KillTerminalRequest) (schema.KillTerminalResponse, error)
func (*ClientPeer) ReadTextFile ¶
func (c *ClientPeer) ReadTextFile(ctx context.Context, request schema.ReadTextFileRequest) (schema.ReadTextFileResponse, error)
func (*ClientPeer) ReleaseTerminal ¶
func (c *ClientPeer) ReleaseTerminal(ctx context.Context, request schema.ReleaseTerminalRequest) (schema.ReleaseTerminalResponse, error)
func (*ClientPeer) Request ¶
func (c *ClientPeer) Request(ctx context.Context, method schema.Method, params any, result any) error
Request sends an arbitrary client-bound request; use it for extension or unstable methods that have no typed wrapper.
func (*ClientPeer) RequestID ¶
func (c *ClientPeer) RequestID() (jsonrpc2.ID, bool)
RequestID returns the inbound request id when this peer handle was passed to a request handler.
func (*ClientPeer) RequestPermission ¶
func (c *ClientPeer) RequestPermission(ctx context.Context, request schema.RequestPermissionRequest) (schema.RequestPermissionResponse, error)
func (*ClientPeer) SessionUpdate ¶
func (c *ClientPeer) SessionUpdate(ctx context.Context, notification schema.SessionNotification) error
SessionUpdate streams an update to the client. It is sent even when ctx is already cancelled: after session/cancel the protocol expects the agent to flush pending updates before answering the prompt.
func (*ClientPeer) TerminalOutput ¶
func (c *ClientPeer) TerminalOutput(ctx context.Context, request schema.TerminalOutputRequest) (schema.TerminalOutputResponse, error)
func (*ClientPeer) WaitForTerminalExit ¶
func (c *ClientPeer) WaitForTerminalExit(ctx context.Context, request schema.WaitForTerminalExitRequest) (schema.WaitForTerminalExitResponse, error)
func (*ClientPeer) WriteTextFile ¶
func (c *ClientPeer) WriteTextFile(ctx context.Context, request schema.WriteTextFileRequest) (schema.WriteTextFileResponse, error)
type ClientRequest ¶
type ClientRequestHandler ¶
type PromptCall ¶
type PromptCall struct {
// contains filtered or unexported fields
}
func (*PromptCall) Await ¶
func (c *PromptCall) Await(ctx context.Context) (schema.PromptResponse, error)
type SessionBuilder ¶
type SessionBuilder struct {
// contains filtered or unexported fields
}
func (*SessionBuilder) Request ¶
func (b *SessionBuilder) Request() schema.NewSessionRequest
func (*SessionBuilder) Start ¶
func (b *SessionBuilder) Start(ctx context.Context) (*ActiveSession, error)
func (*SessionBuilder) WithAdditionalDirectories ¶
func (b *SessionBuilder) WithAdditionalDirectories(dirs ...string) *SessionBuilder
func (*SessionBuilder) WithMCPServer ¶
func (b *SessionBuilder) WithMCPServer(server schema.McpServer) *SessionBuilder
func (*SessionBuilder) WithSession ¶
func (b *SessionBuilder) WithSession(ctx context.Context, op func(context.Context, *ActiveSession) error) error
WithSession starts the session, runs op, and disposes the session when op returns.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
acp-schema-gen
command
|
|
|
Package schema contains generated Go representations of the Agent Client Protocol schema.
|
Package schema contains generated Go representations of the Agent Client Protocol schema. |