Documentation
¶
Overview ¶
Package controller manages the lifecycle of a single cliwrap-agent subprocess and its managed child. Each Controller owns one agent connection, tracks state transitions, and translates inbound IPC messages into observable state changes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller manages exactly one agent subprocess and its child.
func NewController ¶
func NewController(opts ControllerOptions) (*Controller, error)
NewController constructs a Controller.
func (*Controller) ChildPID ¶
func (c *Controller) ChildPID() int
ChildPID returns the PID of the running child (0 if none).
func (*Controller) Close ¶
func (c *Controller) Close(ctx context.Context) error
Close tears everything down. Idempotent.
func (*Controller) Start ¶
func (c *Controller) Start(ctx context.Context) error
Start spawns the agent and issues START_CHILD.
func (*Controller) State ¶
func (c *Controller) State() cwtypes.State
State returns the current state.
type ControllerOptions ¶
ControllerOptions configures a Controller.
type CrashInfo ¶
type CrashInfo struct {
Source CrashSource
AgentExit int
AgentSig int
ChildExit int
ChildSig int
Reason string
DetectedAt time.Time
}
CrashInfo unifies information from all four crash-detection layers. The earliest-arriving source wins for the "primary" fields; Layer 4 (OS wait) augments but does not overwrite.
func (*CrashInfo) Record ¶
func (c *CrashInfo) Record(src CrashSource, data CrashInfo)
Record merges data from a detection source. The first call wins for Source/Reason/ChildExit/ChildSig; OS wait data is always merged in.
type CrashSource ¶
type CrashSource int
CrashSource identifies which of the 4 crash-detection layers fired first.
const ( CrashSourceNone CrashSource = iota CrashSourceExplicit CrashSourceConnectionLost CrashSourceHeartbeat CrashSourceOSWait )
func (CrashSource) String ¶
func (s CrashSource) String() string
String returns the lowercase name of the crash source.
type Heartbeat ¶
type Heartbeat struct {
// contains filtered or unexported fields
}
Heartbeat sends periodic PINGs and fires OnMiss after the configured number of consecutive missing PONGs.
func NewHeartbeat ¶
func NewHeartbeat(opts HeartbeatOptions) *Heartbeat
NewHeartbeat returns a Heartbeat.
func (*Heartbeat) RecordPong ¶
func (h *Heartbeat) RecordPong()
RecordPong resets the miss counter to zero.
type HeartbeatOptions ¶
type HeartbeatOptions struct {
Sender PingSender
Interval time.Duration
Timeout time.Duration
MissThreshold int
OnMiss func(consecutiveMisses int)
}
HeartbeatOptions configures a Heartbeat.
type PingSender ¶
type PingSender interface {
SendPing() error
}
PingSender is any object that can emit a PING message.