Documentation
¶
Overview ¶
Package acp implements the Agent Client Protocol transport shared by native harnesses.
Index ¶
- func Capabilities() agent.Capabilities
- func Configure(ctx context.Context, c *Client, session Session, model, mode string) error
- func MCPServers(raw json.RawMessage, env map[string]string) ([]json.RawMessage, error)
- func Permission(req Message, name string) *agent.Interaction
- func PermissionReply(req Message, in agent.Inbound) (any, error)
- func Prompt(in agent.TurnInput, images bool) ([]map[string]any, error)
- func Run(ctx context.Context, f Flavor, in agent.TurnInput, emit agent.Emit) (agent.TurnResult, error)
- func RunSession(ctx context.Context, c *Client, f Flavor, in agent.TurnInput, emit agent.Emit) (agent.TurnResult, error)
- func SetModel(ctx context.Context, c *Client, session Session, model string, setup bool) error
- func Validate(in agent.TurnInput) error
- type Adapter
- func (a Adapter) Auth(store agent.CredStore) agent.AuthModule
- func (a Adapter) Capabilities() agent.Capabilities
- func (a Adapter) ConfigPath() string
- func (a Adapter) Doctor(ctx context.Context) []agent.Check
- func (a Adapter) History(q agent.HistoryQuery) ([]agent.Message, error)
- func (a Adapter) ID() string
- func (a Adapter) InstallSteps() []agent.Step
- func (a Adapter) Meta() agent.CatalogEntry
- func (a Adapter) Models(env map[string]string) ([]agent.ModelInfo, error)
- func (a Adapter) Notifications() agent.NotificationSpec
- func (a Adapter) RunStream(ctx context.Context, in agent.TurnInput, emit agent.Emit) (agent.TurnResult, error)
- func (a Adapter) Settings() agent.SettingsSchema
- func (a Adapter) Toolchain() toolchain.Spec
- func (a Adapter) VersionCommand() string
- type Client
- func (c *Client) Call(ctx context.Context, method string, params any) (json.RawMessage, error)
- func (c *Client) CallStarted(ctx context.Context, method string, params any, started chan<- struct{}) (json.RawMessage, error)
- func (c *Client) Close()
- func (c *Client) Notify(method string, params any) error
- func (c *Client) Reject(id json.RawMessage, code int, message string) error
- func (c *Client) Respond(id json.RawMessage, result any) error
- func (c *Client) Setup(ctx context.Context, method string, params any) (json.RawMessage, error)
- type ConfigOption
- type Flavor
- type Initialization
- type Message
- type Process
- type RPCError
- type Session
- type Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Capabilities ¶
func Capabilities() agent.Capabilities
func MCPServers ¶
func MCPServers(raw json.RawMessage, env map[string]string) ([]json.RawMessage, error)
MCPServers accepts the canonical named map and existing native ACP arrays.
func Permission ¶
func Permission(req Message, name string) *agent.Interaction
func RunSession ¶
Types ¶
type Adapter ¶
type Adapter struct {
Flavor Flavor
Spec toolchain.Spec
Entry agent.CatalogEntry
Caps agent.Capabilities
Schema agent.SettingsSchema
AuthFactory func(agent.CredStore) agent.AuthModule
}
Adapter is the common ACP surface. Native differences belong to Flavor, SettingsSchema and AuthFactory, never to a product or the orchestrator.
func (Adapter) Capabilities ¶
func (a Adapter) Capabilities() agent.Capabilities
func (Adapter) ConfigPath ¶
func (Adapter) InstallSteps ¶
func (Adapter) Meta ¶
func (a Adapter) Meta() agent.CatalogEntry
func (Adapter) Notifications ¶
func (a Adapter) Notifications() agent.NotificationSpec
func (Adapter) Settings ¶
func (a Adapter) Settings() agent.SettingsSchema
func (Adapter) VersionCommand ¶
type Client ¶
type Client struct {
Notifications chan Message
Requests chan Message
// contains filtered or unexported fields
}
func NewClientWithOutput ¶
NewClientWithOutput permits a provider's login process to report a URL on a non-protocol stdout line. Payloads are not logged or persisted by the transport.
func (*Client) CallStarted ¶
func (c *Client) CallStarted(ctx context.Context, method string, params any, started chan<- struct{}) (json.RawMessage, error)
CallStarted reports successful submission before the caller may send cancel. Native cancellation cannot overtake its prompt on the shared writer.
func (*Client) Setup ¶
Session setup can replay an arbitrarily long transcript before replying. Consume that replay while awaiting the response, without treating it as output from the new prompt. The reader queues notifications before delivering the response, so draining the remaining queue establishes the prompt boundary.
type ConfigOption ¶
type Flavor ¶
type Flavor struct {
ID, Name, Binary string
Args func(agent.TurnInput) []string
Validate func(agent.TurnInput) error
AuthMethod func(Initialization, agent.TurnInput) string
AuthMeta map[string]any
NewSessionMeta func(agent.TurnInput) map[string]any
ResumeMethod string
ResumeLatestMethod string
Configure func(context.Context, *Client, Session, agent.TurnInput) error
Interaction func(Message) *agent.Interaction
Reply func(Message, agent.Inbound) (any, error)
Update func(Message, *Stream)
OnOutput func(string)
PromptID func(json.RawMessage) string
Completion func(Message) (string, json.RawMessage)
PromptMeta func(agent.TurnInput) map[string]any
Capabilities func() agent.Capabilities
}
Flavor contains only provider differences. The shared runtime owns framing, process lifetime, sessions, permissions, streaming and terminal outcomes.
type Initialization ¶
type Initialization struct {
ProtocolVersion int `json:"protocolVersion"`
AgentInfo struct{ Name, Version string } `json:"agentInfo"`
AuthMethods []struct{ ID, Name string } `json:"authMethods"`
DefaultAuthMethodID string `json:"defaultAuthMethodId"`
Meta struct {
DefaultAuthMethodID string `json:"defaultAuthMethodId"`
AgentVersion string `json:"agentVersion"`
} `json:"_meta"`
AgentCapabilities struct {
LoadSession bool `json:"loadSession"`
PromptCapabilities struct{ Image, Audio, EmbeddedContext bool } `json:"promptCapabilities"`
SessionCapabilities struct{ Resume, Fork json.RawMessage } `json:"sessionCapabilities"`
MCPCapabilities struct {
HTTP bool `json:"http"`
SSE bool `json:"sse"`
} `json:"mcpCapabilities"`
} `json:"agentCapabilities"`
}
func Initialize ¶
func Initialize(ctx context.Context, c *Client) (Initialization, error)
type Message ¶
type Message struct {
JSONRPC string `json:"jsonrpc"`
ID json.RawMessage `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params"`
Result json.RawMessage `json:"result"`
Error *RPCError `json:"error"`
}
type Process ¶
type Process struct {
Client *Client
// contains filtered or unexported fields
}
Process is one owned native process. Close drains normal termination, then kills only this process group if the provider will not stop after stdin EOF.
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data,omitempty"`
}
type Session ¶
type Session struct {
ID string `json:"sessionId"`
Models struct {
Current string `json:"currentModelId"`
Available []struct {
ID string `json:"modelId"`
Name string `json:"name"`
} `json:"availableModels"`
} `json:"models"`
Modes struct {
Current string `json:"currentModeId"`
Available []struct{ ID, Name string } `json:"availableModes"`
} `json:"modes"`
ConfigOptions []ConfigOption `json:"configOptions"`
}
type Stream ¶
type Stream struct {
SessionID string
Text string
Usage *agent.Usage
Emit agent.Emit
Background agent.TaskTracker
// contains filtered or unexported fields
}
Stream keeps native tool identity and cumulative partial updates. A running tool update is not a tool result, and omitted fields do not erase earlier data.
func (*Stream) Update ¶
func (s *Stream) Update(params json.RawMessage)