runtime

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCapacityExceeded = errors.New("acp instance capacity exceeded")
View Source
var ErrInvalidRequest = errors.New("invalid acp request")

ErrInvalidRequest marks a client-correctable problem with a session or transcript request (a disabled service, a cwd outside allowed_roots, or a missing session id). Callers map it to HTTP 400; service-not-found maps to 404 and unwrapped agent/transport failures map to 502.

View Source
var ErrPermissionNotFound = fmt.Errorf("acp permission request not found")

ErrPermissionNotFound reports a decision for a permission request that is unknown, already answered, or expired (the in-agent wait timed out and failed closed).

Functions

func ScopeServiceID added in v0.4.0

func ScopeServiceID(scope string) string

ScopeServiceID extracts the service id encoded as the first segment of a pooled-instance scope, or "" if the scope is malformed. It lets callers map a PooledInstanceInfo / InFlightTurn back to its owning service without exposing the scope-encoding format.

Types

type ActivityTracker

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

func NewActivityTracker

func NewActivityTracker() *ActivityTracker

func (*ActivityTracker) Begin

func (t *ActivityTracker) Begin(scope string) (func(), error)

func (*ActivityTracker) IsActive

func (t *ActivityTracker) IsActive(scope string) bool

func (*ActivityTracker) List

func (t *ActivityTracker) List() []InFlightTurn

type EventSink

type EventSink func(TurnEvent) error

type InFlightTurn

type InFlightTurn struct {
	Scope string `json:"scope"`
}

type ListSessionsRequest

type ListSessionsRequest struct {
	CWD    string `json:"cwd,omitempty"`
	Cursor string `json:"cursor,omitempty"`
}

type ListSessionsResponse

type ListSessionsResponse struct {
	Sessions   []SessionInfo `json:"sessions"`
	NextCursor string        `json:"next_cursor,omitempty"`
}

type Manager

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

func NewManager

func NewManager(services *acpservice.Manager) *Manager

func (*Manager) Close

func (m *Manager) Close()

Close stops the janitor and tears down every pooled instance, killing the underlying agent subprocesses. It is safe to call more than once.

func (*Manager) CloseScope

func (m *Manager) CloseScope(scope string) bool

CloseScope tears down the pooled instance for an exact scope, returning whether one was closed. An in-flight turn on that scope will fail on its next request.

func (*Manager) CloseService

func (m *Manager) CloseService(serviceID string) int

CloseService tears down every pooled instance for a service and returns the count closed. This is used after process-affecting service config changes so the next turn starts an agent with the latest launch environment.

func (*Manager) CloseThread

func (m *Manager) CloseThread(serviceID, threadID string) int

CloseThread tears down every pooled instance for a service+thread and returns the count closed. Intended as an operator escape hatch for a wedged thread.

func (*Manager) ListInFlight

func (m *Manager) ListInFlight() []InFlightTurn

func (*Manager) ListInstances

func (m *Manager) ListInstances() []PooledInstanceInfo

ListInstances returns an operator-facing snapshot of the pooled instances, including each instance's cached session metadata, sorted by scope.

func (*Manager) ListPendingPermissions

func (m *Manager) ListPendingPermissions() []PendingPermissionInfo

ListPendingPermissions returns the in-flight interactive permission requests awaiting a decision.

func (*Manager) ListSessions

func (m *Manager) ListSessions(ctx context.Context, serviceID string, req ListSessionsRequest) (ListSessionsResponse, error)

func (*Manager) LoadTranscript

func (m *Manager) LoadTranscript(ctx context.Context, serviceID string, req TranscriptRequest) (TranscriptResponse, error)

func (*Manager) ResolvePermission

func (m *Manager) ResolvePermission(decision PermissionDecision) error

ResolvePermission answers one pending interactive permission request. The outcome must be the ACP discriminator "selected" (with the chosen option id exactly as offered by the agent) or "cancelled".

func (*Manager) ServeTurn

func (m *Manager) ServeTurn(ctx context.Context, serviceID string, req TurnRequest, emit EventSink) error

type PendingPermissionInfo

type PendingPermissionInfo struct {
	RequestID string          `json:"request_id"`
	ServiceID string          `json:"service_id"`
	SessionID string          `json:"session_id,omitempty"`
	CreatedAt time.Time       `json:"created_at"`
	Data      json.RawMessage `json:"data,omitempty"`
}

PendingPermissionInfo describes one in-flight interactive permission request. Data carries the raw ACP session/request_permission params (tool call context plus the agent's permission options and their exact ids).

type PermissionDecision

type PermissionDecision struct {
	RequestID string `json:"request_id"`
	Outcome   string `json:"outcome"`
	OptionID  string `json:"option_id,omitempty"`
}

PermissionDecision is the north-side answer to a pending interactive permission request. Outcome follows the ACP RequestPermissionOutcome discriminators: "selected" (with the chosen option id) or "cancelled".

type PooledInstanceInfo

type PooledInstanceInfo struct {
	Scope     string          `json:"scope"`
	SessionID string          `json:"session_id,omitempty"`
	Alive     bool            `json:"alive"`
	Active    bool            `json:"active"`
	LastUsed  time.Time       `json:"last_used"`
	IdleTTL   time.Duration   `json:"idle_ttl,omitempty"`
	Metadata  SessionMetadata `json:"metadata"`
}

PooledInstanceInfo is the operator-facing view of one pooled agent instance.

type SessionInfo

type SessionInfo struct {
	SessionID string          `json:"session_id"`
	CWD       string          `json:"cwd"`
	Title     string          `json:"title,omitempty"`
	UpdatedAt *time.Time      `json:"updated_at,omitempty"`
	Meta      json.RawMessage `json:"_meta,omitempty"`
}

type SessionMetadata

type SessionMetadata struct {
	ConfigOptions     json.RawMessage `json:"config_options,omitempty"`
	AvailableCommands json.RawMessage `json:"available_commands,omitempty"`
	SessionInfo       json.RawMessage `json:"session_info,omitempty"`
	Mode              json.RawMessage `json:"mode,omitempty"`
	Usage             json.RawMessage `json:"usage,omitempty"`
}

SessionMetadata is the cached structured state of one pooled session. Every field carries the raw ACP update object of its kind (config_option_update, available_commands_update, session_info_update, current_mode_update, usage_update).

type TranscriptMessage

type TranscriptMessage struct {
	Role string `json:"role"`
	Text string `json:"text"`
}

TranscriptMessage is one coalesced replayed message. Role is one of user, assistant, or reasoning.

type TranscriptRequest

type TranscriptRequest struct {
	SessionID string `json:"session_id"`
	CWD       string `json:"cwd,omitempty"`
}

type TranscriptResponse

type TranscriptResponse struct {
	SessionID string              `json:"session_id"`
	Messages  []TranscriptMessage `json:"messages"`
}

type TurnEvent

type TurnEvent struct {
	Event      string          `json:"-"`
	SessionID  string          `json:"session_id,omitempty"`
	RequestID  string          `json:"request_id,omitempty"`
	Text       string          `json:"text,omitempty"`
	StopReason string          `json:"stop_reason,omitempty"`
	Message    string          `json:"message,omitempty"`
	Data       json.RawMessage `json:"data,omitempty"`
}

type TurnRequest

type TurnRequest struct {
	ThreadID        string            `json:"thread_id"`
	SessionID       string            `json:"session_id,omitempty"`
	Input           string            `json:"input"`
	CWD             string            `json:"cwd,omitempty"`
	Model           string            `json:"model,omitempty"`
	FreshSession    bool              `json:"fresh_session,omitempty"`
	ConfigOverrides map[string]string `json:"config_overrides,omitempty"`
}

Directories

Path Synopsis
Package acpupdate parses ACP session/update notifications into a small set of neutral events the runtime driver forwards to the gateway north side.
Package acpupdate parses ACP session/update notifications into a small set of neutral events the runtime driver forwards to the gateway north side.

Jump to

Keyboard shortcuts

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