Expand description
Thin HTTP client for publishing MPS events to the AgentMux sidecar.
Reads AGENTMUX_LOCAL_URL and AGENTMUX_AUTH_KEY from the
process environment (inherited from the agentmux-srv → claude →
bash subprocess chain). Attaches X-AuthKey per PR #801 to
authenticate against the auth_middleware-gated publish endpoint.
Designed to silently degrade: if env vars are absent or the
sidecar is unreachable, publishes fail-fast and the caller emits
a kind: "system" chunk that surfaces the degradation to the
user without aborting the command itself.
Structs§
- WpsClient
- Per-launch sidecar config + reusable HTTP client. Cheap to clone
(the inner
reqwest::Clientuses Arc internally).
Constants§
- COMPACTION_
STARTED_ 🔒EVENT - Event name for the
PreCompact-hook-sourced “compaction started” signal. Seedocs/specs/SPEC_COMPACTION_DETECTION_AND_HANDLING_2026_07_31.md§4.2 / Tier 1. - COMPACTION_
STARTED_ 🔒PERSIST persist: 0— never retained/replayed. A late/reconnecting subscriber must NOT see a past “compaction started” ping: there is no matching completion tombstone (compact_boundaryarrives over the separate NDJSON stream, not MPS), so replaying a retained start indistinguishably resurrects “Compacting…” for a compaction that may have finished seconds after the ping — a timestamp-age guard alone can’t tell “recently finished” apart from “still running” (Codex P1, PR #2378 round 2). Only a currently-live subscriber should ever see this event; a disconnected pane already clears its owncompactingflag onStreamUnsubscribe(reducer.ts), so there is nothing worth replaying on reconnect regardless.- COMPACTION_
STARTED_ 🔒TIMEOUT - Fail-fast timeout for
publish_compaction_startedspecifically — much shorter than the 5s client-wide default used fortool_chunkstreaming (from_env). That default is fine forexec’s own async runtime, butprecompactis invoked as Claude Code’s SYNCHRONOUSPreCompacthook: the CLI blocks compaction on this process’s exit, so inheriting the 5s default means a wedged (but TCP-accepting) backend delays the user’s actual compaction by up to 5 real seconds — directly contradicting this hook’s own “never block/delay the operation for observability” contract (seeprecompact.rs’s module doc comment). Codex P2, PR #2378 round 4. 500ms comfortably covers a normal same-host round trip while keeping the worst case imperceptible. - PUBLISH_
PATH 🔒 - TOOL_
CHUNK_ 🔒EVENT - Event name for streaming bash chunks. Held constant across every publish so the frontend can subscribe once per block on mount.
- TOOL_
CHUNK_ 🔒PERSIST - How many
tool_chunkevents the broker keeps perblock:<id>scope. Sized for npm-install class output (~1000 lines is typical; 1024 covers all but heavy CI builds). Each event is ~200–500 bytes, so the steady-state ceiling is ~512 KB per actively-streaming block.