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. -
git-credential <op>andgithub-token -- <gh args>— GitHub tokens for an agent’sgitandgh, from srv. Seegithub.rs. -
github-container -- <gh args>— a container’sgh pr merge(srv does it) and the rawgh apiwrites its token cannot make (refused, with the command that does the job). Seecontainer_verbs.rs. -
git-hook <name>,git-env -- <git args>andgithub-owner-tag -- <gh args>— the guards and attribution on an agent’s pushes and commits. Seegit_hooks.rs,secret_scan.rs. -
github-text-guard -- <gh args>— the scan of the text an agent’sghsends (PR, issue and comment text) for credentials. Seegithub_text.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). - aws 🔒
- AWS credentials for a container agent’s SDK or CLI, as AWS’s standard
credential_process. Spec: docs/specs/SPEC_CONTAINER_AGENT_AWS_CREDENTIALS_2026_10_31.md §12. - bash_
timeout 🔒 - The timeout of a Bash call, set by the
PreToolUsehook so the agent is free after 30 seconds. - bash_
wrap 🔒 execsubcommand — runs the user’s bash command and streams chunks.- container_
verbs 🔒 - The
ghcommands a container agent cannot run with its own token, and what it does instead. - cwd_
state 🔒 - Where an agent’s Bash calls start: the working directory a call ends in is
kept for the next one, per instance and, for a Claude Code subagent, per
subagent (docs/specs/SPEC_BASHWRAP_PER_AGENT_CWD_2026_10_18.md). Moved out
of
bash_wrap.rs, which runs the calls. - exec_
args 🔒 - The arguments of
agentmux-bashwrap exec, also built by prefix mode for a call it runs (prefix.rs). Moved out ofbash_wrap.rs, which runs the call. - gh_shim 🔒
ghas a program, for the callers theghshell function never reaches.- git_
hooks 🔒 - What runs around an agent’s
git commitandgit pushwhen its GitHub access goes through AgentMux. - github 🔒
- GitHub tokens for an agent’s
gitandgh. - github_
text 🔒 - The text scan: what an agent’s
ghis refused for when the text it sends holds a credential. - hook 🔒
hooksubcommand.- idle_
gate 🔒 - Is a command that has printed nothing for the idle timeout stuck, or busy?
- 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. - publish_
scan 🔒 - A container agent’s push, judged by the host’s publish guard.
- secret_
scan 🔒 - The push scan: what an agent’s
git pushis refused for. - 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).- shim_
functions 🔒 - Makes the build-slot shims win in the shells this wrapper starts.
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 🔒