Documentation
¶
Index ¶
- Variables
- type ControlServer
- func (s *ControlServer) AnswerPendingPermission(scope, requestID, optionID string) bool
- func (s *ControlServer) BeginPermissionClaim(scope, requestID string) (<-chan PermissionAnswer, bool)
- func (s *ControlServer) ClearPermissionClaims(scope string)
- func (s *ControlServer) ConsumeInterrupt() string
- func (s *ControlServer) DeliverPendingPermission(scope, requestID, optionID string) PermissionAnswerDelivery
- func (s *ControlServer) DequeuePrompt() string
- func (s *ControlServer) EndPermissionClaim(scope, requestID string)
- func (s *ControlServer) HandoffPermissionClaim(scope, requestID string, next PermissionResolverState) (PermissionAnswer, bool)
- func (s *ControlServer) HasClients() bool
- func (s *ControlServer) HasPendingPermission() bool
- func (s *ControlServer) InterruptChan() <-chan struct{}
- func (s *ControlServer) InterruptPrompt(text string, keepQueue bool)
- func (s *ControlServer) PermissionResolverState(scope, requestID string) PermissionResolverState
- func (s *ControlServer) PreparePermissionClaim(scope, requestID string, state PermissionResolverState) bool
- func (s *ControlServer) PublishEvent(event events.Event)
- func (s *ControlServer) QueuePrompt(text string)
- func (s *ControlServer) ResetInterrupt()
- func (s *ControlServer) RetryDirectPermissionDelivery(scope, requestID string) bool
- func (s *ControlServer) SetCancelFunc(fn func())
- func (s *ControlServer) SetPermissionResolverState(scope, requestID string, state PermissionResolverState)
- func (s *ControlServer) SetStableHandler(h StableHandler)
- func (s *ControlServer) Start(socketPath string) error
- func (s *ControlServer) Stop()
- func (s *ControlServer) SubscribeEvents(ctx context.Context) <-chan events.Event
- type ControlState
- type HTTPDebugServer
- type Notification
- type PermissionAnswer
- type PermissionAnswerDelivery
- type PermissionResolverState
- type Request
- type RespError
- type Response
- type Snapshot
- type StableAdapter
- type StableHandler
Constants ¶
This section is empty.
Variables ¶
var ErrRuntimeNotFound = errors.New("runtime not found")
Functions ¶
This section is empty.
Types ¶
type ControlServer ¶
type ControlServer struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(state *ControlState) *ControlServer
func (*ControlServer) AnswerPendingPermission ¶ added in v0.19.4
func (s *ControlServer) AnswerPendingPermission(scope, requestID, optionID string) bool
AnswerPendingPermission delivers an answer to the active permission claim. The bool reports whether the answer was actually delivered.
func (*ControlServer) BeginPermissionClaim ¶
func (s *ControlServer) BeginPermissionClaim(scope, requestID string) (<-chan PermissionAnswer, bool)
BeginPermissionClaim registers a permission claim within scope and returns its answer channel. Request IDs are only unique within an ACP session, so stable runtimes must use distinct scopes.
func (*ControlServer) ClearPermissionClaims ¶ added in v0.19.4
func (s *ControlServer) ClearPermissionClaims(scope string)
func (*ControlServer) ConsumeInterrupt ¶
func (s *ControlServer) ConsumeInterrupt() string
func (*ControlServer) DeliverPendingPermission ¶ added in v0.19.4
func (s *ControlServer) DeliverPendingPermission(scope, requestID, optionID string) PermissionAnswerDelivery
DeliverPendingPermission distinguishes a missing claim from a claim that has already accepted an answer. answerQueued remains set after the resolver drains answerCh, making delivery single-use until the claim is ended.
func (*ControlServer) DequeuePrompt ¶
func (s *ControlServer) DequeuePrompt() string
func (*ControlServer) EndPermissionClaim ¶
func (s *ControlServer) EndPermissionClaim(scope, requestID string)
func (*ControlServer) HandoffPermissionClaim ¶ added in v0.19.4
func (s *ControlServer) HandoffPermissionClaim(scope, requestID string, next PermissionResolverState) (PermissionAnswer, bool)
HandoffPermissionClaim atomically consumes an answer already queued for the control resolver or closes control ownership by transitioning to next. Once it returns without an answer, later control deliveries are rejected.
func (*ControlServer) HasClients ¶
func (s *ControlServer) HasClients() bool
HasClients reports whether the control plane has at least one connected client capable of answering control RPCs. Returns false when no socket is bound (e.g. --http-debug without --control-socket) or when no client has dialed in yet. Used to gate features that should defer to fallbacks (file-handler permissions) when nothing on the socket can answer.
func (*ControlServer) HasPendingPermission ¶
func (s *ControlServer) HasPendingPermission() bool
HasPendingPermission reports whether a permission claim is currently registered. Used by tests to verify claims are cleaned up after timeout.
func (*ControlServer) InterruptChan ¶
func (s *ControlServer) InterruptChan() <-chan struct{}
InterruptChan returns the channel that closes when an interrupt fires. Idempotent: returns the same channel until ResetInterrupt is called.
func (*ControlServer) InterruptPrompt ¶
func (s *ControlServer) InterruptPrompt(text string, keepQueue bool)
func (*ControlServer) PermissionResolverState ¶ added in v0.19.4
func (s *ControlServer) PermissionResolverState(scope, requestID string) PermissionResolverState
func (*ControlServer) PreparePermissionClaim ¶ added in v0.19.4
func (s *ControlServer) PreparePermissionClaim(scope, requestID string, state PermissionResolverState) bool
PreparePermissionClaim records resolver ownership before permission.request is published. Terminal entries may be replaced when an ACP session reuses a request ID for a later request.
func (*ControlServer) PublishEvent ¶
func (s *ControlServer) PublishEvent(event events.Event)
func (*ControlServer) QueuePrompt ¶
func (s *ControlServer) QueuePrompt(text string)
func (*ControlServer) ResetInterrupt ¶
func (s *ControlServer) ResetInterrupt()
ResetInterrupt closes the current interrupt channel (if any) and creates a fresh one. Call this between turns to re-arm the interrupt signal.
func (*ControlServer) RetryDirectPermissionDelivery ¶ added in v0.19.4
func (s *ControlServer) RetryDirectPermissionDelivery(scope, requestID string) bool
RetryDirectPermissionDelivery returns a failed direct delivery to the unowned state. It only changes the exact in-flight claim, so cleanup or a replacement claim cannot be overwritten by a late failure.
func (*ControlServer) SetCancelFunc ¶
func (s *ControlServer) SetCancelFunc(fn func())
func (*ControlServer) SetPermissionResolverState ¶ added in v0.19.4
func (s *ControlServer) SetPermissionResolverState(scope, requestID string, state PermissionResolverState)
func (*ControlServer) SetStableHandler ¶
func (s *ControlServer) SetStableHandler(h StableHandler)
func (*ControlServer) Start ¶
func (s *ControlServer) Start(socketPath string) error
func (*ControlServer) Stop ¶
func (s *ControlServer) Stop()
func (*ControlServer) SubscribeEvents ¶
func (s *ControlServer) SubscribeEvents(ctx context.Context) <-chan events.Event
type ControlState ¶
type ControlState struct {
// contains filtered or unexported fields
}
func NewState ¶
func NewState(runID, runLabel string, maxRetries int) *ControlState
func (*ControlState) Snapshot ¶
func (s *ControlState) Snapshot() Snapshot
func (*ControlState) Update ¶
func (s *ControlState) Update(fn func(*Snapshot))
type HTTPDebugServer ¶
type HTTPDebugServer struct {
// contains filtered or unexported fields
}
func NewHTTPDebugServer ¶
func NewHTTPDebugServer(addr string, control *ControlServer) (*HTTPDebugServer, error)
func (*HTTPDebugServer) SetStableAdapter ¶
func (h *HTTPDebugServer) SetStableAdapter(a StableAdapter)
SetStableAdapter wires a StableAdapter into the debug server so that per-runtime endpoints are active. The supervisor calls this immediately after NewHTTPDebugServer; CLI mode never calls it. Passing nil is a no-op.
func (*HTTPDebugServer) Start ¶
func (h *HTTPDebugServer) Start() error
type Notification ¶
type PermissionAnswer ¶
type PermissionAnswerDelivery ¶ added in v0.19.4
type PermissionAnswerDelivery uint8
const ( PermissionAnswerNotFound PermissionAnswerDelivery = iota PermissionAnswerDelivered PermissionAnswerChannelFull PermissionAnswerResolverOwned PermissionAnswerNoResolver )
type PermissionResolverState ¶ added in v0.19.4
type PermissionResolverState uint8
const ( PermissionResolverUnknown PermissionResolverState = iota PermissionResolverReserved PermissionResolverControl PermissionResolverAutomatic PermissionResolverFile PermissionResolverNoResolver PermissionResolverDirectDelivery PermissionResolverResolved )
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type Snapshot ¶
type Snapshot struct {
SessionID string `json:"session_id,omitempty"`
RunID string `json:"run_id,omitempty"`
RunLabel string `json:"run_label,omitempty"`
Phase string `json:"phase,omitempty"`
PhaseLabel string `json:"phase_label,omitempty"`
LastEvent string `json:"last_event,omitempty"`
RetryAttempt int `json:"retry_attempt,omitempty"`
MaxRetries int `json:"max_retries,omitempty"`
PendingPermission bool `json:"pending_permission"`
Permission map[string]any `json:"permission,omitempty"`
StartedAt int64 `json:"started_at"`
UpdatedAt int64 `json:"updated_at"`
TurnState string `json:"turn_state,omitempty"`
}
type StableAdapter ¶
type StableAdapter interface {
// HTTPRuntimeStatus returns the runtime snapshot for the given runtimeID.
// Returns ErrRuntimeNotFound if the runtime ID does not exist. Other
// errors indicate operational failures and should map to 500.
HTTPRuntimeStatus(runtimeID string) (any, error)
// HTTPCancelRuntime cancels the named runtime. Returns ErrRuntimeNotFound
// if the runtime ID does not exist. Other errors indicate operational
// failures and should map to 500.
HTTPCancelRuntime(runtimeID string) error
}
StableAdapter is the minimal interface that HTTPDebugServer needs to serve per-runtime endpoints in stable mode. The supervisor implements this; CLI mode passes nil (no adapter wired).
Method names are prefixed with HTTP to avoid shadowing the StableHandler methods on *Supervisor which carry the same logical names but different signatures (e.g. RuntimeStatus returns (any, error) there).
type StableHandler ¶
type StableHandler interface {
Spawn(params json.RawMessage) (any, error)
List() any
Shutdown(mode string) error
RuntimeStatus(runtimeID string) (any, error)
RuntimeCancel(runtimeID string) error
RuntimePrompt(runtimeID, text, requestID string) error
RuntimeAnswerPermission(runtimeID, requestID, optionID string) error
RuntimeInterruptAndPrompt(runtimeID, text string, keepQueue bool) error
RuntimeSendToParent(runtimeID, message string) error
}