Created
May 9, 2026 07:15
-
-
Save jtianling/6c2769f76ffb8fbff8856f90dc7f9554 to your computer and use it in GitHub Desktop.
free-xats-codex: zsh launcher for codex --remote with cross-agent-teams (xats) tmux pane auto-bind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # free-xats-codex: launch codex with cross-agent-teams (xats) integration. | |
| # | |
| # What it does: | |
| # - Generates a per-launch agent_id (UUID) and registers the tmux pane | |
| # with the xats daemon via `pre-register-codex-pane`, so cross-agent | |
| # wake events can be injected directly into this codex thread instead | |
| # of falling back to tmux paste. | |
| # - Walks up from $PWD looking for a project-local .codex/config.toml. | |
| # If found, sets CODEX_HOME so the app-server loads the right MCP set. | |
| # Under `codex --remote`, MCP servers are loaded by the *app-server*, | |
| # not the TUI, so this matters. | |
| # - Launches the codex TUI in --remote mode against a long-lived | |
| # app-server at ws://127.0.0.1:8799. Start the app-server separately | |
| # in its own terminal: | |
| # codex app-server --listen ws://127.0.0.1:8799 | |
| # | |
| # Prereqs: | |
| # - cross-agent-teams-mcp daemon running: | |
| # npx -y cross-agent-teams-mcp@latest daemon --port 9100 | |
| # - codex app-server running on ws://127.0.0.1:8799 (see above). | |
| # - ~/.codex/config.toml has `experimental_use_rmcp_client = true` at | |
| # the top level, plus a [mcp_servers.cross-agent-teams-mcp] | |
| # streamable-http entry pointing at the daemon. | |
| # | |
| # Note on --dangerously-bypass-approvals-and-sandbox: | |
| # This is my personal preference for fully-unattended cross-agent runs. | |
| # Drop it if you want codex to keep prompting for approvals normally. | |
| unalias free-xats-codex 2>/dev/null | |
| free-xats-codex() { | |
| local xats_agent_id codex_home search_dir | |
| xats_agent_id="$(uuidgen)" | |
| search_dir="$PWD" | |
| while [[ "$search_dir" != "/" ]]; do | |
| if [[ -f "$search_dir/.codex/config.toml" ]]; then | |
| codex_home="$search_dir/.codex" | |
| break | |
| fi | |
| search_dir="${search_dir:h}" | |
| done | |
| if [[ -n "$TMUX_PANE" ]]; then | |
| npx -y cross-agent-teams-mcp pre-register-codex-pane \ | |
| --pane "$TMUX_PANE" \ | |
| --agent-id "$xats_agent_id" \ | |
| >/dev/null 2>&1 \ | |
| || echo "[xats] pre-register failed (continuing without pane claim)" >&2 | |
| fi | |
| if [[ -n "$codex_home" ]]; then | |
| CODEX_HOME="$codex_home" exec codex \ | |
| --dangerously-bypass-approvals-and-sandbox \ | |
| --remote ws://127.0.0.1:8799 \ | |
| -c xats.agent_id="\"$xats_agent_id\"" "$@" | |
| else | |
| exec codex \ | |
| --dangerously-bypass-approvals-and-sandbox \ | |
| --remote ws://127.0.0.1:8799 \ | |
| -c xats.agent_id="\"$xats_agent_id\"" "$@" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment