acp

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSessionCapabilities

func AddSessionCapabilities(line []byte) []byte

AddSessionCapabilities adds standard fields missing from SDK v0.13.5's client capability type.

func InitializeRequest

func InitializeRequest() sdkacp.InitializeRequest

InitializeRequest advertises the client capabilities agentpack implements on the worker.

func NewClientConnection

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

NewClientConnection connects client to an agent with backpressure on notification floods. Pass the outermost client so its overrides are the handlers that release the gate.

func ReadWorkspaceFile

func ReadWorkspaceFile(root string, extra []string, path string, line, limit *int) (string, error)

ReadWorkspaceFile reads a text file confined to the workspace roots.

func ResolveWorkspacePath

func ResolveWorkspacePath(root string, extra []string, path string) (string, error)

ResolveWorkspacePath follows symlinks and ensures path stays under root or extra dirs.

func StripControls

func StripControls(s string) string

StripControls removes terminal controls from agent text while retaining newlines.

func WriteWorkspaceFile

func WriteWorkspaceFile(root string, extra []string, path, content string) error

WriteWorkspaceFile atomically replaces a text file confined to the workspace roots.

Types

type Broker

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

Broker forwards conversation control and coordinates per-request answers.

func NewBroker

func NewBroker(
	prompt func(context.Context, PromptInput) error,
	cancel func(context.Context) error,
	answer func(context.Context, string, string) error,
	setConfig func(context.Context, string, string) error,
) *Broker

func (*Broker) Answer

func (b *Broker) Answer(requestID, optionID string) bool

Answer records the first option ID for an active request.

func (*Broker) AnswerPermission

func (b *Broker) AnswerPermission(ctx context.Context, requestID, optionID string) error

AnswerPermission forwards and records the first answer for an active request.

func (*Broker) Begin

func (b *Broker) Begin(requestID string) error

Begin starts a request lifecycle. Active IDs cannot be reused.

func (*Broker) Cancel

func (b *Broker) Cancel(ctx context.Context) error

func (*Broker) End

func (b *Broker) End(requestID string)

End consumes the result and permits a later request to reuse the ID.

func (*Broker) Prompt

func (b *Broker) Prompt(ctx context.Context, input PromptInput) error

func (*Broker) SetConfig

func (b *Broker) SetConfig(ctx context.Context, key, value string) error

func (*Broker) Wait

func (b *Broker) Wait(ctx context.Context, requestID string) (string, error)

Wait blocks until the active request is answered or ctx is done.

type EventLog

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

EventLog stores bounded session events for replay and coalesced retention.

func NewEventLog

func NewEventLog(limitBytes int) *EventLog

func (*EventLog) Append

func (log *EventLog) Append(kind string, ts int64, payload json.RawMessage) LogEntry

func (*EventLog) Close

func (log *EventLog) Close() error

func (*EventLog) EnablePersistence

func (log *EventLog) EnablePersistence(path string) error

func (*EventLog) MarkTruncated

func (log *EventLog) MarkTruncated()

MarkTruncated records that an event could not be retained, such as an oversized wire frame.

func (*EventLog) ReadSince

func (log *EventLog) ReadSince(since int64) (out []LogEntry, truncated bool)

func (*EventLog) SetOnAppend

func (log *EventLog) SetOnAppend(onAppend func(LogEntry)) []LogEntry

func (*EventLog) Snapshot

func (log *EventLog) Snapshot() []LogEntry

func (*EventLog) Truncated

func (log *EventLog) Truncated() bool

type HarnessClient

type HarnessClient struct {
	Root      string
	Extra     []string
	Log       *EventLog
	Broker    *Broker
	Terminals *TerminalPool
	// contains filtered or unexported fields
}

HarnessClient is the agentpack ACP client: permissions via Broker, updates to EventLog, fs confined to workspace.

func NewHarnessClient

func NewHarnessClient(root string, extra []string, log *EventLog, broker *Broker) *HarnessClient

NewHarnessClient wires a client implementation for ClientSideConnection.

func (*HarnessClient) CreateTerminal

func (*HarnessClient) HandleExtensionMethod

func (c *HarnessClient) HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error)

func (*HarnessClient) KillTerminal

func (*HarnessClient) NewClientSideConnection

func (c *HarnessClient) NewClientSideConnection(peerInput io.Writer, peerOutput io.Reader) *sdkacp.ClientSideConnection

NewClientSideConnection returns an SDK client connection over the given transport.

func (*HarnessClient) ReadTextFile

func (*HarnessClient) SessionUpdate

func (c *HarnessClient) SessionUpdate(ctx context.Context, n sdkacp.SessionNotification) error

func (*HarnessClient) TerminalOutput

func (*HarnessClient) UnstableCompleteElicitation

func (*HarnessClient) WriteTextFile

type LogEntry

type LogEntry struct {
	Seq     int64           `json:"seq"`
	TS      int64           `json:"ts"`
	Kind    string          `json:"kind"`
	Payload json.RawMessage `json:"payload"`
}

LogEntry is one append-only row in a session event log. Payload is the ACP sessionUpdate body or a synthetic envelope for prompt, permission, and turn events.

type PromptImage

type PromptImage struct {
	Sha           string
	Name          string
	Mime          string
	Kind          string
	Width, Height int
}

PromptImage references an image blob stored under the worker session directory.

type PromptInput

type PromptInput struct {
	Text         string
	Image        *PromptImage
	Images       []PromptImage
	ResourceLink *PromptResourceLink
}

PromptInput is a user message sent to the agent.

type PromptResourceLink struct {
	Sha  string
	Name string
}

PromptResourceLink references a stored file that an agent can read by URI.

type TerminalPool

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

TerminalPool runs ACP terminal/create commands with a bounded output buffer.

func NewTerminalPool

func NewTerminalPool() *TerminalPool

NewTerminalPool returns an empty terminal pool.

func (*TerminalPool) Close

func (p *TerminalPool) Close() error

Close prevents new terminals and terminates every managed process group.

type ThreadItem

type ThreadItem struct {
	Kind string          `json:"kind"`
	Data json.RawMessage `json:"data,omitempty"`
}

ThreadItem is the reduced view shared by the gateway UI and ap hub TUI.

type ThreadReducer

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

ThreadReducer applies conversation entries without rescanning the full log.

func (*ThreadReducer) Apply

func (reducer *ThreadReducer) Apply(entry LogEntry) ThreadState

type ThreadState

type ThreadState struct {
	Items         []ThreadItem `json:"items"`
	NeedsYou      bool         `json:"needs_you"`
	Working       bool         `json:"working"`
	PlanKind      string       `json:"plan_kind,omitempty"`
	ContextTokens int          `json:"context_tokens,omitempty"`
	ContextLimit  int          `json:"context_limit,omitempty"`
	CostUSD       float64      `json:"cost_usd,omitempty"`
}

ThreadState tracks composer-adjacent session UI state.

func ReduceLog

func ReduceLog(entries []LogEntry) ThreadState

ReduceLog folds append-only log entries into a thread view.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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