Constant BASH_SCRIPT
Source const BASH_SCRIPT: &str = "# AgentMux shell integration for bash\n# Deployed to: ~/.agentmux/shell/bash/.bashrc\n# Loaded via: bash --rcfile <this-file>\n\n# Source /etc/profile for system-wide settings\nif [ -f /etc/profile ]; then\n . /etc/profile\nfi\n\n# wsh has been retired \u{2014} AGENTMUX is now a plain \"1\" sentinel.\n# See docs/specs/archive/SPEC_RETIRE_WSH_2026_04_12.md.\n\n# Source the first of ~/.bash_profile, ~/.bash_login, or ~/.profile that exists\nif [ -f ~/.bash_profile ]; then\n . ~/.bash_profile\nelif [ -f ~/.bash_login ]; then\n . ~/.bash_login\nelif [ -f ~/.profile ]; then\n . ~/.profile\nfi\n\n# \u{2500}\u{2500}\u{2500} Shell Integration \u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\n\n_agentmux_si_blocked() {\n [[ -n \"$TMUX\" || -n \"$STY\" || \"$TERM\" == tmux* || \"$TERM\" == screen* ]]\n}\n\n_agentmux_si_urlencode() {\n local s=\"$1\"\n s=\"${s//%/%25}\"\n s=\"${s// /%20}\"\n s=\"${s//#/%23}\"\n s=\"${s//\\?/%3F}\"\n s=\"${s//&/%26}\"\n s=\"${s//;/%3B}\"\n s=\"${s//+/%2B}\"\n printf \'%s\' \"$s\"\n}\n\n_agentmux_si_osc7() {\n _agentmux_si_blocked && return\n local encoded_pwd\n encoded_pwd=$(_agentmux_si_urlencode \"$PWD\")\n printf \'\\033]7;file://%s%s\\007\' \"$HOSTNAME\" \"$encoded_pwd\"\n}\n\n_agentmux_si_json_escape() {\n local s=\"$1\"\n s=\"${s//\\\\/\\\\\\\\}\"\n s=\"${s//\\\"/\\\\\\\"}\"\n printf \'%s\' \"$s\"\n}\n\n_AGENTMUX_SI_LAST_AGENT=\"\"\n\n# Send AGENTMUX_AGENT_ID via OSC 16162;E on every prompt (only when changed)\n_agentmux_si_agent_env() {\n _agentmux_si_blocked && return\n local current_agent=\"\"\n if [[ -n \"$AGENTMUX_AGENT_ID\" ]]; then\n current_agent=\"AGENTMUX_AGENT_ID:$AGENTMUX_AGENT_ID\"\n fi\n if [[ \"$current_agent\" != \"$_AGENTMUX_SI_LAST_AGENT\" ]]; then\n _AGENTMUX_SI_LAST_AGENT=\"$current_agent\"\n if [[ -n \"$AGENTMUX_AGENT_ID\" ]]; then\n local escaped\n escaped=$(_agentmux_si_json_escape \"$AGENTMUX_AGENT_ID\")\n local payload=\"{\\\"AGENTMUX_AGENT_ID\\\":\\\"$escaped\\\"\"\n payload=\"$payload}\"\n printf \'\\033]16162;E;%s\\007\' \"$payload\"\n else\n printf \'\\033]16162;E;{}\\007\'\n fi\n fi\n}\n\n_agentmux_si_prompt_command() {\n _agentmux_si_osc7\n _agentmux_si_agent_env\n}\n\n# \u{2500}\u{2500}\u{2500} muxlog \u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\n# Discover, render & follow AgentMux logs across every running instance.\n# Delegates to the shared Node core (muxlog.mjs, deployed next to this rcfile).\n# muxlog tail the most-recently-active host log (follow)\n# muxlog ls list every instance\'s logs (newest first)\n# muxlog srv grep <re> search the active sidecar log (transcript excluded)\n# muxlog bridge startup-handshake trace (debug reconnect loops)\n# muxlog help full usage\n# Resolve muxlog.mjs once, at source time (BASH_SOURCE = this rcfile).\n_AGENTMUX_MUXLOG_JS=\"$(cd \"$(dirname \"${BASH_SOURCE[0]:-$0}\")/..\" 2>/dev/null && pwd)/muxlog.mjs\"\nmuxlog() {\n if command -v node >/dev/null 2>&1 && [ -f \"$_AGENTMUX_MUXLOG_JS\" ]; then\n node \"$_AGENTMUX_MUXLOG_JS\" \"$@\"\n return\n fi\n # Fallback (no node / core missing): legacy pointer-based tail, so logs are\n # never wholly inaccessible.\n local target=\"${1:-host}\" action=\"${2:-tail}\"\n [ -z \"$AGENTMUX_LOG_DIR\" ] && { echo \"AGENTMUX_LOG_DIR not set \u{2014} run inside an AgentMux terminal\" >&2; return 1; }\n local ptr=\"$AGENTMUX_LOG_DIR/current-${target}-v${AGENTMUX_VERSION}.path\"\n [ -f \"$ptr\" ] || { echo \"muxlog: Node core unavailable and no pointer for \'$target\'\" >&2; return 1; }\n local pc logfile; pc=\"$(cat \"$ptr\")\"\n case \"$pc\" in /* | ?:[/\\\\]*) logfile=\"$pc\" ;; *) logfile=\"$AGENTMUX_LOG_DIR/$pc\" ;; esac\n case \"$action\" in tail) tail -f \"$logfile\" ;; cat) cat \"$logfile\" ;; *) grep \"$action\" \"$logfile\" ;; esac\n}\n\n# \u{2500}\u{2500}\u{2500} muxspect \u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\n# Live process/turn-state introspection for the CURRENT instance (muxlog\'s\n# live-state sibling \u{2014} muxlog answers \"what happened\", muxspect answers\n# \"what\'s happening right now\"). Delegates to the shared Node core\n# (muxspect.mjs, deployed next to this rcfile). `muxspect help` for usage.\n# No non-Node fallback: introspection needs a real authenticated HTTP call.\n_AGENTMUX_MUXSPECT_JS=\"$(cd \"$(dirname \"${BASH_SOURCE[0]:-$0}\")/..\" 2>/dev/null && pwd)/muxspect.mjs\"\nmuxspect() {\n if command -v node >/dev/null 2>&1 && [ -f \"$_AGENTMUX_MUXSPECT_JS\" ]; then\n node \"$_AGENTMUX_MUXSPECT_JS\" \"$@\"\n return\n fi\n echo \"muxspect: Node unavailable or core missing at $_AGENTMUX_MUXSPECT_JS\" >&2\n return 1\n}\n\n# \u{2500}\u{2500}\u{2500} muxopen \u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\n# Launch an agent into a pane from the terminal (no GUI). Constructive\n# sibling of the stop verbs. Delegates to the shared Node core (muxopen.mjs,\n# deployed next to this rcfile). `muxopen help` for usage.\n_AGENTMUX_MUXOPEN_JS=\"$(cd \"$(dirname \"${BASH_SOURCE[0]:-$0}\")/..\" 2>/dev/null && pwd)/muxopen.mjs\"\nmuxopen() {\n if command -v node >/dev/null 2>&1 && [ -f \"$_AGENTMUX_MUXOPEN_JS\" ]; then\n node \"$_AGENTMUX_MUXOPEN_JS\" \"$@\"\n return\n fi\n echo \"muxopen: Node unavailable or core missing at $_AGENTMUX_MUXOPEN_JS\" >&2\n return 1\n}\n\n# \u{2500}\u{2500}\u{2500} muxsh \u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\u{2500}\n# Open editor/browser panes from the terminal (no GUI). AgentMux\'s own\n# successor to Wave Terminal\'s `wsh`, scoped to the one gap that\'s real\n# (docs/reports/REPORT_WSH_STYLE_CLI_FOR_AGENT_APP_API_2026_09_16.md).\n# Delegates to the shared Node core (muxsh.mjs, deployed next to this\n# rcfile). `muxsh help` for usage.\n_AGENTMUX_MUXSH_JS=\"$(cd \"$(dirname \"${BASH_SOURCE[0]:-$0}\")/..\" 2>/dev/null && pwd)/muxsh.mjs\"\nmuxsh() {\n if command -v node >/dev/null 2>&1 && [ -f \"$_AGENTMUX_MUXSH_JS\" ]; then\n node \"$_AGENTMUX_MUXSH_JS\" \"$@\"\n return\n fi\n echo \"muxsh: Node unavailable or core missing at $_AGENTMUX_MUXSH_JS\" >&2\n return 1\n}\n\n# Append to PROMPT_COMMAND (array-safe)\nif [[ $(declare -p PROMPT_COMMAND 2>/dev/null) == \"declare -a\"* ]]; then\n PROMPT_COMMAND+=(_agentmux_si_prompt_command)\nelse\n PROMPT_COMMAND=\"${PROMPT_COMMAND:+$PROMPT_COMMAND$\'\\n\'}_agentmux_si_prompt_command\"\nfi\n";