Skip to main content

Module shell

Module shell 

Source
Expand description

Network (fetch) and Shell / terminal methods + supporting types.

Ported from packages/core/src/agent-os.ts (fetch + shell methods) and runtime-compat.ts (ShellHandle, OpenShellOptions, ConnectTerminalOptions).

Id-vs-PID is load-bearing: open_shell returns a synthetic shell-N id; connect_terminal returns a PID and is NOT tracked in the shells map.

The native wire protocol has no PTY/winsize request, so a shell is modeled as a guest process spawned via [ExecuteRequest]: its process_id is what write_shell/close_shell address on the wire, while the public boundary keeps the synthetic shell-N id.

Stream routing mirrors the TS real-process spawn path exactly: the public data stream (on_shell_data) carries stdout ONLY, because TS wires only the kernel handle’s onData (fed exclusively by stdoutHandlers) into the data handlers. stderr is delivered on a SEPARATE channel (on_shell_stderr + the OpenShellOptions::on_stderr callback), matching TS where stderr reaches the host only through stderrHandlers / the onStderr option. Fanning stderr into the data stream is only correct for the synthetic-prompt PTY path, which this native real-process path does not implement.

Structs§

ConnectTerminalOptions
Options for connect_terminal (extends OpenShellOptions).
OpenShellOptions
Options for open_shell.
ShellHandle
The synthetic shell id returned by open_shell (shell-N, NOT a pid).