Expand description
RpcHttpClient: a pooled JSON-RPC 2.0 client speaking POST {base}/rpc
against a long-lived tcode serve --http daemon (issue #3415).
Why: mirrors crate::cli_client::stdio::StdioRpcClient’s role over
STDIO — one place that builds the wire request, sends it, and unwraps the
envelope — but over HTTP against an ALREADY-RUNNING daemon instead of a
per-call spawned child. Reuses the exact same wire types
(trusty_mcp::{Request, Response}) StdioRpcClient and
crate::serve::http::rpc_handler already use, so there is exactly one
Request/Response shape in this crate regardless of transport.
What: RpcHttpClient::call mints a monotonic request id, POSTs the
envelope, and unwraps the response into either Ok(result) or an
EngineError::Rpc/EngineError::Transport. Holds one
reqwest::Client for its whole lifetime (pooled keep-alive connections,
DOC-50 §3.4 point 5) — callers needing the SSE routes (sse.rs) reuse
the SAME client via RpcHttpClient::http rather than building a second
one.
Test: rpc_tests::* against a wiremock mock server.
Structs§
- RpcHttp
Client - See module docs.
Constants§
- DEFAULT_
CALL_ TIMEOUT - How long a single
POST /rpccall waits for a response before giving up. Every method this client calls today (session.*,task.run,workstream.*) is a fast, synchronous handler —task.runreserves its execution slot and returns immediately rather than blocking on the LLM run (mirrorscrate::cli_client::stdio::DEFAULT_CALL_TIMEOUT’s docs) — so a real hang here means a genuine daemon-side regression, not a slow but legitimate call.