acp

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 59 Imported by: 1 module, 0 packages

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

Documentation

Index

Constants

View Source
const (
	ElicitationMethod = "elicitation/create"
	SkipOption        = "skip"
)
View Source
const (
	DefaultMode                = "default"
	DefaultEditApprovalPolicy  = "ask"
	EditApprovalPolicyConfigID = "edit_approval_policy"
)
View Source
const ACPAdapterModuleEntry = "__icebath_acp_adapter__"

Entry word the binary runs the ACP adapter module under

View Source
const ReasoningConfigID = "reasoning_effort"

Config option id of the reasoning effort picker

View Source
const TerminalSetupAuthMethodID = "icebath-setup"

Variables

View Source
var (
	NewPreparedMutations   func() PreparedMutations
	SlashMutation          func(command, arg string) (string, *pyjson.Object, error)
	ModelRefusalText       func(refusal map[string]any, confirmed bool) string
	ConfirmationTitle      func(refusal map[string]any) string
	CommandRefusal         func(command string) string
	RewindTo               func(turnsBack int64, retry bool) MutationDerive
	ReplayGapOwedReply     func(shown, final string) string
	ReplayGapPendingStatus func(pending []any, admission any) any
	ReplayGapSettled       func(receipt map[string]any) *bool
	EnvLaunchFlags         func() *pyjson.Object
	ResolveCommand         func(name string) (string, bool)
	RunModelSetup          func(ctx context.Context) int
)

Wiring of the core gateway client modules, bound by wiring.go init, RunModelSetup by cmd/icebath where the CLI runs

View Source
var EditApprovalPolicyToMode = map[string]string{
	"ask":               "default",
	"workspace_session": "accept_edits",
	"session":           "dont_ask",
}

Edit approval policy to mode id

View Source
var ModeOrder = []string{"default", "accept_edits", "dont_ask"}

Mode ids in table order

View Source
var ModeToEditApprovalPolicy = map[string]string{
	"default":      "ask",
	"accept_edits": "workspace_session",
	"dont_ask":     "session",
}

Mode id to edit approval policy

View Source
var Modes = map[string]ModeSpec{
	"default":      {"ask", "Default", "Ask before edits."},
	"accept_edits": {"workspace_session", "Accept Edits", "Auto-allow workspace and temp-dir edits; still asks for sensitive paths."},
	"dont_ask":     {"session", "Don't Ask", "Auto-allow file edits for this session except sensitive paths."},
}

Mode id to its edit approval policy, display name and description

View Source
var NewSurfaceLabelReader func(db *state.SessionDB) RichSessionLister

Gateway session store reader over a state database, assigned in cmd/icebath/wiring.go

View Source
var ToolKindMap = func() map[string]string {
	m := map[string]string{}
	for kind, names := range map[string][]string{
		"read":   {"read_file", "skill_view", "skills_list", "browser_snapshot", "browser_vision", "browser_get_images", "vision_analyze"},
		"edit":   {"write_file", "patch", "skill_manage"},
		"search": {"search_files"},
		"execute": {"terminal", "process", "execute_code", "browser_click", "browser_type", "browser_scroll",
			"browser_press", "browser_back", "delegate_task", "image_generate", "text_to_speech"},
		"fetch": {"web_search", "web_extract", "browser_navigate"},
		"other": {"todo"},
		"think": {"_thinking"},
	} {
		for _, n := range names {
			m[n] = kind
		}
	}
	return m
}()

Tool name to ACP tool kind, unlisted tools are other

Functions

func BuildACPEditToolCall

func BuildACPEditToolCall(proposal *tools.EditProposal) *pyacp.ToolCallProgress

Pending edit tool call update shown with the proposal's diff in a permission request

func BuildAuthMethods

func BuildAuthMethods(ctx context.Context) []pyacp.AuthMethod

Registry compatible auth methods, the detected provider first and terminal setup always

func BuildClarifyElicitation

func BuildClarifyElicitation(sessionID string, prompt *pyjson.Object) (*pyjson.Object, error)

Elicitation form params asking the clarify question, an enum or multi select array when choices exist

func BuildClarifyPermission

func BuildClarifyPermission(prompt *pyjson.Object) (*pyacp.ToolCallProgress, []pyacp.PermissionOption, map[string]string, error)

Permission card for a clarify prompt, one option per choice plus Skip and each option's answer

func BuildModelState

func BuildModelState(ctx context.Context, model, prov, baseURL string) (*pyacp.SessionModelState, error)

Picker state from the inventory and named endpoints, nil when nothing is listable, an error when the inventory fails

func BuildSessionProvenance

func BuildSessionProvenance(ctx context.Context, db SessionGetter, acpSessionID, currentID, previousID string) *pyjson.Object

Session provenance of an ACP session walked from the compression chain, nil when unreadable

func BuildToolAbandoned

func BuildToolAbandoned(toolCallID, toolName string) *pyacp.ToolCallProgress

Failed tool call progress for a call that ended without a result

func BuildToolComplete

func BuildToolComplete(toolCallID, toolName string, result *string, functionArgs *pyjson.Object, snapshot *tools.LocalEditSnapshot, isError bool) *pyacp.ToolCallProgress

Tool call progress closing a completed call with its formatted result and status

func BuildToolStart

func BuildToolStart(toolCallID, toolName string, arguments *pyjson.Object, editDiff *tools.EditProposal) *pyacp.ToolCallStart

Tool call start for a tool, a minimal start when rendering the arguments fails

func BuildToolTitle

func BuildToolTitle(toolName string, args *pyjson.Object) string

Tool name and its shared preview, the bare name when the arguments give none

func CatalogSessions

func CatalogSessions(ctx context.Context, path, cwd string) ([]*pyjson.Object, error)

Historical ACP sessions with messages, optionally under one cwd, one row per logical owner newest first

func ClientSupportsFormElicitation

func ClientSupportsFormElicitation(initializeParams any) bool

Reports whether raw initialize params advertise form elicitation under either capability key

func CmdACP

func CmdACP(ctx context.Context, ns map[string]any, w io.Writer) (int, error)

Launches Icebath Agent as an ACP server, the launch flags exported as their env equivalents first

func CoerceToolArgs

func CoerceToolArgs(raw any) *pyjson.Object

Tool call arguments as a dict, JSON text decoded or wrapped under raw, other values empty

func ContentBlocksToOpenAIUserContent

func ContentBlocksToOpenAIUserContent(prompt []pyacp.ContentBlock) (any, error)

User content of ACP prompt blocks, a string for pure text and parts when media is present

func DetectProvider

func DetectProvider(ctx context.Context) string

Lowercased active runtime provider when it has a key or token source, empty otherwise

func DispatchModuleEntry

func DispatchModuleEntry(ctx context.Context, exit func(int))

Runs the adapter module entry and exits when argv carries its entry word

func ElicitedAnswer

func ElicitedAnswer(response any) (string, bool)

Answer of an elicitation response, empty for decline or cancel, false when not answered

func EncodeModelChoice

func EncodeModelChoice(prov, model string) string

Provider and model joined by a colon so clients keep the provider, the bare model without one

func ExtractLocations

func ExtractLocations(arguments *pyjson.Object) ([]pyacp.ToolCallLocation, error)

File system locations of tool arguments, a path with its offset or line

func ExtractText

func ExtractText(prompt []pyacp.ContentBlock) string

Plain text of the prompt blocks that carry text, newline joined

func GetToolKind

func GetToolKind(toolName string) string

ACP tool kind of a tool, other when unlisted

func LogicalSessionID

func LogicalSessionID(ctx context.Context, path, sessionID string) (string, error)

Logical session id of an id an editor holds, the compression root mapped through its local owner

func Main

func Main(ctx context.Context, argv []string, stdout, stderr io.Writer) int

Entry point of the ACP adapter, its exit status

func NewAgent

func NewAgent() any

Agent serving ACP, the projection of the profile gateway that never owns a session itself

func ReadCatalogRows

func ReadCatalogRows(ctx context.Context, path string) (map[string]*pyjson.Object, []string, error)

ACP session rows of a state database keyed by id, empty when the database is absent

func ReadLocalOwners

func ReadLocalOwners(ctx context.Context, path string) (map[string]string, error)

Local creation receipt owners of a state database, empty when it is absent

func SessionProvenanceMeta

func SessionProvenanceMeta(ctx context.Context, db SessionGetter, acpSessionID, currentID, previousID string) *pyjson.Object

Meta payload wrapping the provenance under icebath.sessionProvenance, nil when unreadable

Types

type AssistantMessageIDAllocator

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

Stable uuid per streamed assistant message, a new id after each close

func (*AssistantMessageIDAllocator) Close

func (a *AssistantMessageIDAllocator) Close()

Ends the active message so the next chunk starts a new id

func (*AssistantMessageIDAllocator) Current

func (a *AssistantMessageIDAllocator) Current() string

Active message id, allocating one when none is open

func (*AssistantMessageIDAllocator) Last

Most recently allocated id, empty before the first

type Client

type Client interface {
	SessionUpdater
	RequestPermission(ctx context.Context, options []pyacp.PermissionOption, sessionID string, toolCall *pyacp.ToolCallUpdate, meta *pyjson.Object) (*pyacp.RequestPermissionResponse, error)
}

Client side calls the agent makes over its connection

type CommandRefused

type CommandRefused struct{ Msg string }

Refusal the editor shows as the command's reply while the prompt itself ends normally

func (*CommandRefused) As

func (e *CommandRefused) As(target any) bool

Lets a refusal match a gateway client error target like the Python subclass

func (*CommandRefused) Error

func (e *CommandRefused) Error() string

type GatewayACPAgent

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

ACP projection of the profile gateway, it never constructs an execution owner

func NewGatewayACPAgent

func NewGatewayACPAgent() *GatewayACPAgent

Gateway projection attached to the profile the launch home's gateway serves

func (*GatewayACPAgent) Authenticate

Answers authenticate for the detected provider or the terminal setup method

func (*GatewayACPAgent) Cancel

Cancels the editor's prompt on a session, a submit still in flight cancelled once it is acked

func (*GatewayACPAgent) Close

func (a *GatewayACPAgent) Close()

Cancels the background notices and open cards, then drops the owner connection

func (*GatewayACPAgent) ForkSession

Forks a session through the owner's branch mutation and attaches the child

func (*GatewayACPAgent) Initialize

Answers initialize with the protocol version, agent info, capabilities and auth methods

func (*GatewayACPAgent) ListSessions

Lists the profile's ACP sessions after the cursor, fifty per page

func (*GatewayACPAgent) LoadSession

Loads a session, replaying its transcript

func (*GatewayACPAgent) NewSession

Creates an owner session for the editor with its MCP servers and launch flags frozen into its policy

func (*GatewayACPAgent) OnConnect

func (a *GatewayACPAgent) OnConnect(conn *pyacp.AgentSideConnection)

Stores the editor connection and observes its raw initialize message

func (*GatewayACPAgent) Prompt

Submits the editor's prompt to the owner and waits for its turn to settle

func (*GatewayACPAgent) ResumeSession

Resumes a session, replaying its transcript

func (*GatewayACPAgent) SetConfigOption

Applies one of the advertised pickers and answers the full option list read back from the owner

func (*GatewayACPAgent) SetSessionMode

Sets the session's edit approval policy on the owner from the editor's mode

func (*GatewayACPAgent) SetSessionModel

Picks the session's model through the owner's model mutation

type ModeSpec

type ModeSpec struct {
	Policy      string
	Name        string
	Description string
}

Edit approval policy, display name and description of one ACP mode

type MutationConfirm

type MutationConfirm = func(ctx context.Context, refusal map[string]any) (bool, error)

Asks the editor to confirm a guarded mutation the owner refused

type MutationDerive

type MutationDerive = func(snapshot map[string]any) (map[string]any, error)

Payload of a mutation derived from the snapshot its fence is read from, nil for nothing to do

type MutationRPC

type MutationRPC = func(ctx context.Context, method string, params map[string]any, timeout time.Duration) (map[string]any, error)

One owner request answered as a plain map within a budget, zero the default

type PreparedMutations

type PreparedMutations interface {
	Apply(ctx context.Context, rpc MutationRPC, sessionID, operation string, payload any, confirm MutationConfirm) (map[string]any, error)
	Acknowledge(sessionID, operation string, payload any)
	Retire(sessionID string)
}

Prepared owner mutations retaining their identity across ambiguous replies

type ReasoningCallbackSetter

type ReasoningCallbackSetter interface {
	SetReasoningCallback(cb any)
}

Agent seam that takes the callback fed with reasoning text during a prompt

type RequestPermissionFunc

type RequestPermissionFunc func(ctx context.Context, sessionID string, toolCall *pyacp.ToolCallProgress, options []pyacp.PermissionOption) (*pyacp.RequestPermissionResponse, error)

Client permission request the ACP connection sends

type RichSessionLister

type RichSessionLister interface {
	ListSessionsRich(ctx context.Context, o state.ListSessionsRichOptions) ([]*pyjson.Object, error)
}

Rich session rows the gateway session store reader lists

type SessionGetter

type SessionGetter interface {
	GetSession(ctx context.Context, sessionID string) (*pyjson.Object, error)
}

Session row reader the provenance walk needs

type SessionUpdater

type SessionUpdater interface {
	SessionUpdate(ctx context.Context, sessionID string, update pyacp.SessionUpdate, meta *pyjson.Object) error
}

Client side of the connection that receives session updates

type StagedAttachment

type StagedAttachment struct {
	Path string
	Mime string
}

Staged image attachment of a prompt, its cache path and sniffed type

Jump to

Keyboard shortcuts

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