acp

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package acp is the Agent Client Protocol built into the server.

JSON-RPC lives here because ACP is JSON-RPC. Another protocol does not import this package. The program on the other end of the connection is the caller's. This package asks that program for permission, a selection, and file credentials. It does not implement that program.

Index

Constants

View Source
const (
	CodeInvalidRequest = -32600
	CodeMethodNotFound = -32601
	CodeInternal       = -32603
	CodeApplication    = -32000
	CodeCancelled      = -32800
)

JSON-RPC 2.0 error codes. Cancelled follows the ACP / LSP convention.

View Source
const (
	// HeaderConnectionID is set on the WebSocket 101 response.
	HeaderConnectionID = "Acp-Connection-Id"
)

Variables

This section is empty.

Functions

func ElicitationResultToSelectionPayload

func ElicitationResultToSelectionPayload(raw json.RawMessage, opts []tacklr.UserChoice) (action string, resolution []byte, err error)

ElicitationResultToSelectionPayload maps an accept response to the harness interrupt resolution payload. Returns action and optional selection JSON.

func ErrorBody

func ErrorBody(id json.RawMessage, err error) map[string]any

ErrorBody is one JSON-RPC error envelope.

func ErrorCode

func ErrorCode(err error) int

ErrorCode maps err to a JSON-RPC 2.0 code.

func HTTPWriter

HTTPWriter writes JSON-RPC over an HTTP response.

func InitializeResult

func InitializeResult(agent tacklr.AgentOptions, clientProtocolVersion int, methods []ACPAuthMethod, logout bool) map[string]any

Prompt baseline (no capability bits): Text + ResourceLink are always accepted. Optional: image (model-gated), audio (off), embeddedContext (Resource text/blob).

func New

New returns the native ACP server.Protocol. Nil wire uses an in-memory store.

func NewWithAuth

func NewWithAuth(wire server.ProtocolWireStore, methods []ACPAuthMethod, logout bool) server.Protocol

NewWithAuth configures the ACP v1 presentation for a generic host security service. It does not implement credential verification itself.

func PermissionToACPParams

func PermissionToACPParams(sessionID, toolCallID string, perm tacklr.ToolPermissionInterrupt) map[string]any

PermissionToACPParams builds session/request_permission params.

func RequestPermissionResultToPayload

func RequestPermissionResultToPayload(raw json.RawMessage) (resolution []byte, cancelled bool, err error)

RequestPermissionResultToPayload maps a client permission response to the harness resolution payload. cancelled yields a non-nil err suitable for ending the turn.

func SelectionToElicitationParams

func SelectionToElicitationParams(sessionID, toolCallID, question string, opts []tacklr.UserChoice) map[string]any

SelectionToElicitationParams builds form-mode elicitation/create params from a user-selection interrupt. ask_user_choice already requires ≥2 titled options.

Types

type ACPAuthMethod

type ACPAuthMethod struct {
	ID          string
	Name        string
	Description string
	Scheme      string
}

ACPAuthMethod presents one host security scheme through the ACP v1 agent authentication flow. Scheme is the protocol-neutral Authenticator identifier.

type ClientBridge

type ClientBridge struct {

	// Caps is protected by mu; use GetCaps/SetCaps from concurrent handlers.
	Caps ClientCapabilities
	// contains filtered or unexported fields
}

ClientBridge sends JSON-RPC requests to the Client and demuxes responses by id. Safe for concurrent Call from tool/turn goroutines; one bridge per connection.

func NewClientBridge

func NewClientBridge(w server.MessageWriter) *ClientBridge

NewClientBridge creates a bridge that writes requests through w.

func (*ClientBridge) Call

func (b *ClientBridge) Call(ctx context.Context, method string, params any) (json.RawMessage, error)

func (*ClientBridge) Elicit

func (b *ClientBridge) Elicit(ctx context.Context, sessionID, messageID, question string, opts []tacklr.UserChoice) (string, []byte, error)

Elicit asks the peer to answer one selection.

func (*ClientBridge) FormSupported

func (b *ClientBridge) FormSupported() bool

FormSupported reports whether the peer advertised form elicitation.

func (*ClientBridge) GetCaps

func (b *ClientBridge) GetCaps() ClientCapabilities

GetCaps returns a snapshot of client capabilities (safe for concurrent use).

func (*ClientBridge) MarkInitialized

func (b *ClientBridge) MarkInitialized()

MarkInitialized records that initialize completed on this connection.

func (*ClientBridge) NoteHello

func (b *ClientBridge) NoteHello(params json.RawMessage)

NoteHello records initialize params and marks the connection ready.

func (*ClientBridge) Permission

func (b *ClientBridge) Permission(ctx context.Context, sessionID, messageID string, perm tacklr.ToolPermissionInterrupt) ([]byte, bool, error)

Permission asks the peer to allow or deny one tool call.

func (*ClientBridge) Ready

func (b *ClientBridge) Ready(ctx context.Context) error

Call sends a JSON-RPC request and waits for the matching response or ctx cancel. Ready waits until initialize has been seen on this connection.

func (*ClientBridge) SetCaps

func (b *ClientBridge) SetCaps(c ClientCapabilities)

SetCaps stores client capabilities (safe for concurrent use).

func (*ClientBridge) TryCompleteResponse

func (b *ClientBridge) TryCompleteResponse(body []byte) bool

TryCompleteResponse returns true if body is a JSON-RPC response that completed a waiter.

func (*ClientBridge) WaitInitialized

func (b *ClientBridge) WaitInitialized(ctx context.Context) error

WaitInitialized blocks until initialize has run or ctx is done. If initialize already completed, that wins even when ctx is also ready.

type ClientCapabilities

type ClientCapabilities struct {
	ElicitationForm bool
	ElicitationURL  bool
	VFSTokenRefresh bool
}

ClientCapabilities captures client features from initialize.

func ParseClientCapabilities

func ParseClientCapabilities(params json.RawMessage) ClientCapabilities

ParseClientCapabilities extracts elicitation mode support and Tacklr VFS token refresh from initialize params.

type ConfigOption

type ConfigOption struct {
	ID           string              `json:"id"`
	Name         string              `json:"name"`
	Description  string              `json:"description,omitempty"`
	Category     string              `json:"category"`
	Type         string              `json:"type"`
	CurrentValue string              `json:"currentValue"`
	Options      []ConfigOptionValue `json:"options"`
}

ConfigOption describes a selectable session configuration option returned by session/new and session/load.

type ConfigOptionValue

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

ConfigOptionValue is one choice within a select-type ConfigOption.

type ElicitationResult

type ElicitationResult struct {
	Action  string         `json:"action"`
	Content map[string]any `json:"content"`
}

ElicitationResult is the Client response to elicitation/create.

type InterruptEventEnvelope

type InterruptEventEnvelope struct {
	InterruptId string          `json:"interruptId"`
	Type        string          `json:"type"`
	Data        json.RawMessage `json:"data"`
}

InterruptEventEnvelope is the harness StreamEventInterrupt Data shape.

type RequestPermissionResult

type RequestPermissionResult struct {
	Outcome struct {
		Outcome  string `json:"outcome"`
		OptionID string `json:"optionId,omitempty"`
	} `json:"outcome"`
}

RequestPermissionResult is the Client response to session/request_permission.

Jump to

Keyboard shortcuts

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