Skip to main content

Module stdio

Module stdio 

Source
Expand description

StdioRpcClient: a JSON-RPC 2.0 client speaking NDJSON over a spawned tcode serve --stdio child’s stdio pipes (#2060).

Why: the CLI needs to drive the daemon’s session.*/task.* methods without reimplementing any of their logic. Spawning an ephemeral child per invocation (rather than discovering/reusing a long-lived daemon) is the simplest robust M1 approach the ticket calls for — no discovery file, no port, no lifecycle management beyond this one process’s lifetime. What: StdioRpcClient::spawn launches the child; StdioRpcClient::call sends a request and blocks (bounded by DEFAULT_CALL_TIMEOUT) for its matching response, buffering any interleaved session.event notification lines rather than dropping them; StdioRpcClient::next_notification drains that buffer (or reads fresh lines, bounded by a caller-supplied wait) for the streaming subcommands (attach, run-task). [classify_notification]/[build_request] are pure helpers, unit tested here without spawning a real process; the full spawn+wire round trip is covered by tests/cli_e2e.rs against the real tcode binary. Test: cli_client::stdio::tests::*.

Structs§

StdioRpcClient
A JSON-RPC 2.0 client over a spawned tcode serve --stdio child.

Enums§

RpcClientError
Errors a CLI subcommand handler surfaces to the user (mapped onto a nonzero exit code by the caller — this type carries no exit-code opinion itself).

Constants§

DEFAULT_CALL_TIMEOUT
How long StdioRpcClient::call waits for a matching response before giving up.