Expand description
agentmux-bashwrap — streaming bash wrapper for AgentMux agents.
Two subcommands:
-
exec— runs a user-supplied command inside an owned PTY, streams stdout/stderr line-by-line to the AgentMux sidecar’s MPS broker (HTTP), and prints the aggregated output on its own stdout for Claude’s native Bash tool to capture astool_result. -
hook— reads a PreToolUse JSON payload on stdin. When the CLI’s shell prefix is this binary, it records the call for the prefix process and changes nothing. Otherwise it emits a hook response that rewrites the command so Claude’s native Bash invokesagentmux-bashwrap execinstead, the command base64-encoded into the rewrite argv so quoting + multi-line bodies survive. -
prefix mode (one argument: the CLI’s script) — Claude Code’s
CLAUDE_CODE_SHELL_PREFIX. Runs the script the wayexecruns a command, for the call the hook recorded. Seeprefix.rsanddocs/specs/SPEC_BASH_STREAMING_VIA_SHELL_PREFIX_2026_10_10.md. -
precompact— registered as Claude Code’sPreCompacthook. Fires the instant compaction begins; pings the sidecar’s MPS broker with acompaction_startedevent so the UI can show live status instead of a silent gap. Seeprecompact.rsanddocs/specs/SPEC_COMPACTION_DETECTION_AND_HANDLING_2026_07_31.md. -
askpass mode (no subcommand) —
ssh’sSSH_ASKPASSwhen AgentMux runs ssh for an agent: shows ssh’s prompt to the user through srv and prints the answer. Seeaskpass.rs. -
sessionstart --part N— registered as Claude Code’sSessionStarthook, once per part. Delivers part N of the agent’s memory as the hook’sadditionalContext. Seesessionstart.rsanddocs/specs/SPEC_GLOBAL_MEMORY_DELIVERY_2026_09_27.md§7 P2.
See docs/specs/SPEC_STREAMING_BASH_RUNNER_2026_05_11.md for the
full design rationale (why command rewrite vs. MCP deny-redirect,
why a separate binary vs. extending an MCP server, channel
correlation by tool_use_id, etc).
Modules§
- askpass 🔒
- askpass mode:
sshruns$SSH_ASKPASS "<prompt>"and reads the answer on stdout. When AgentMux runssshfor an agent it pointsSSH_ASKPASShere and setsAGENTMUX_ASKPASS_SECRETon thatsshonly; this asks srv (POST /api/v1/askpass), which shows the prompt to the user, and prints their answer. The secret, not anything here, decides whose prompt it is (srv’sbackend::remote::askpass). - bash_
wrap 🔒 execsubcommand — runs the user’s bash command and streams chunks.- hook 🔒
hooksubcommand.- mps_
client 🔒 - Thin HTTP client for publishing MPS events to the AgentMux sidecar.
- precompact 🔒
precompactsubcommand.- prefix 🔒
- Prefix mode:
agentmux-bashwrap '<script>'as Claude Code’sCLAUDE_CODE_SHELL_PREFIX. - sessionstart 🔒
sessionstartsubcommand — registered as Claude Code’sSessionStarthook, once per part (--part 1…--part 8). Delivers the agent’s memory (docs/specs/SPEC_GLOBAL_MEMORY_DELIVERY_2026_09_27.md §7 P2).
Structs§
- Cli 🔒
Enums§
- Command 🔒
Functions§
- init_
tracing 🔒 - Initialize tracing to write to
~/.agentmux/logs/bashwrap-debug.logat INFO by default. Writing to a file instead of stderr means: - main 🔒