Expand description
Streaming subprocess control: spawn a child, pipe its stdout/stderr
line-by-line through a callback as Events, and hand back a
ProcessHandle for cancellation (SIGTERM → SIGKILL).
The environment is the caller’s: this spawns what it is told to spawn, with
the PATH it is given. Finding a CLI a user installed — resolving a bare
name, locating the node it was installed under — is a different question,
and one only a caller driving such a CLI needs answered.
Cancellation is the wrinkle: a run needs to be stoppable mid-stream
when the user closes the tab or hits “stop”. ProcessHandle::cancel()
sends SIGTERM (with a SIGKILL fallback) and flips an atomic
cancelled flag the reader threads use to short-circuit.
Structs§
- Command
- What to spawn. Named fields rather than six positional arguments, so a call site says which string is the program and which is the run id, and a new knob is a field with a default instead of a break.
- Process
Handle - Handle to an in-flight streaming run. Caller stores it (e.g. in a
runId-keyed map) so a later
cancel()can find it.
Enums§
- Event
- Raw events emitted to the caller’s callback during a streaming run.
JSON-tagged so axum SSE and Tauri Channel render identical payloads
on the wire. Harness-neutral: a process-backed adapter parses the
Stdoutlines into a normalized event vocabulary (e.g.agent-harness’sRunEvent). - Stderr
- What happens to the child’s stderr.
- Stdin
- What the child’s stdin is connected to.
Functions§
- hidden_
command - needs_
terminal - Compose a PATH for the spawned process that always includes the
directory containing the program — where
node,npm, and friends usually live in an nvm install. The user’s existing PATH stays as a fallback after our prepended directory. ACommandthat never opens a console window on Windows.