Expand description
ShellController: manages lifecycle of shell and command blocks. Port of Go’s pkg/blockcontroller/shellcontroller.go.
State machine: INIT ─(start)─> RUNNING ─(exit/stop)─> DONE DONE ─(resync+force)─> RUNNING
I/O model (3 async tasks when running):
- PTY read loop: process stdout → FileStore + WPS event
- Input loop: input channel → process stdin
- Wait loop: monitor process exit, update status
Structs§
- Shell
Controller - ShellController manages one shell or command block.
- Shell
Controller 🔒Inner
Constants§
- AGENT_
LINE_ 🔒BUFFER_ CAP - Append data to a block’s terminal output file, publish a WPS event, Maximum size of the per-block line buffer used by the agent-event translation path. Past this, the buffer is reset (a producer that never emits a newline can’t grow it unboundedly). 1 MiB is far beyond any plausible stream-json frame size.
- KILL_
GRACE_ 🔒SECS - Inner state protected by mutex. Grace period (seconds) between SIGTERM and SIGKILL during stop().
- PTY_
READ_ 🔒BUF_ SIZE - PTY read buffer size (matches Go’s 4096).
- SHELL_
INPUT_ 🔒CH_ SIZE - Channel buffer size for shell input (matches Go’s 32).
Functions§
- accumulate_
and_ 🔒translate - Publish the events
extract_agent_eventsproduced on the WPS scopeagent_event:<block_id>. Phase 1.5 PR 1 hook for agent panes. Called only whenis_agentis true at spawn time (see read-task closure instart()). - detect_
local_ 🔒shell_ path_ windows - Detect the best available interactive shell on Windows.
- extract_
agent_ 🔒events - Append
chunktoline_buf, drain complete lines, JSON-parse each, and run successful parses throughtranslator. Returns the events the translator emitted. Caller is responsible for publishing them. - handle_
append_ block_ file - and write-through to FileStore (if provided).
- handle_
truncate_ block_ file - Truncate a block’s terminal output file and publish a WPS event.
Port of Go’s
HandleTruncateBlockFile.
Type Aliases§
- Conn
Factory - Factory function type for creating ConnInterface instances. This allows dependency injection for testing.