Skip to main content

Crate agentmux_bashwrap

Crate agentmux_bashwrap 

Source
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 as tool_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 invokes agentmux-bashwrap exec instead, 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 way exec runs a command, for the call the hook recorded. See prefix.rs and docs/specs/SPEC_BASH_STREAMING_VIA_SHELL_PREFIX_2026_10_10.md.

  • precompact — registered as Claude Code’s PreCompact hook. Fires the instant compaction begins; pings the sidecar’s MPS broker with a compaction_started event so the UI can show live status instead of a silent gap. See precompact.rs and docs/specs/SPEC_COMPACTION_DETECTION_AND_HANDLING_2026_07_31.md.

  • askpass mode (no subcommand) — ssh’s SSH_ASKPASS when AgentMux runs ssh for an agent: shows ssh’s prompt to the user through srv and prints the answer. See askpass.rs.

  • sessionstart --part N — registered as Claude Code’s SessionStart hook, once per part. Delivers part N of the agent’s memory as the hook’s additionalContext. See sessionstart.rs and docs/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: ssh runs $SSH_ASKPASS "<prompt>" and reads the answer on stdout. When AgentMux runs ssh for an agent it points SSH_ASKPASS here and sets AGENTMUX_ASKPASS_SECRET on that ssh only; 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’s backend::remote::askpass).
bash_wrap 🔒
exec subcommand — runs the user’s bash command and streams chunks.
hook 🔒
hook subcommand.
mps_client 🔒
Thin HTTP client for publishing MPS events to the AgentMux sidecar.
precompact 🔒
precompact subcommand.
prefix 🔒
Prefix mode: agentmux-bashwrap '<script>' as Claude Code’s CLAUDE_CODE_SHELL_PREFIX.
sessionstart 🔒
sessionstart subcommand — registered as Claude Code’s SessionStart hook, 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.log at INFO by default. Writing to a file instead of stderr means:
main 🔒