Agent pane: read the agent a shell call starts (codex exec, claude -p, acpmux run)

Merged
TE
12d ago
+804-0

Leo, 2026-10-24, word for word, looking at a codex exec review that renders as a plain "Command" row:

"this is mildly interesting i think being able to do it like a cmux-next natively rendered thing of subsession/non-same-model-family subagent would be a cool depiction"

"plus supporting the situation better in acpmux"

This is the first of two PRs. It adds the part that reads which agent a shell call starts. The next PR uses it to render such a call as a Subagent: the same card and Session Info row that sub-sessions and subagents get. It's split to stay under the ~800-line limit.

What changes

webviews/src/agent-session/acpmux/subagents/agentRuns.ts (new, not wired in yet):

  • agentRun(command) returns the agent a shell command starts: its harness, model, effort, prompt, acpmux session name and host. It returns undefined when the command starts no agent.
  • It reads the command with a real shell tokenizer, not a search of the text. The tokenizer handles quotes, $'…', escapes, ;/&&/||/|, { … } and ( … ), comments, $(…)/backquotes (kept as one word), fd redirections like 2>&1, and <, <</<<- heredocs and <<< here-strings as standard input.
  • It looks through wrappers that just run the next words: VAR=x, env, nohup, exec, time, nice, caffeinate, timeout/gtimeout, sr, and perl -e 'alarm N; exec @ARGV'. It also re-parses the command strings that reach HOST '…', ssh HOST '…' and sh|bash|zsh -c '…' run. reach and ssh give the host, and the outer stdin is passed into the inner command.
  • Each agent CLI's grammar is one declarative table entry: what starts a non-interactive run (codex exec, claude -p, acpmux run|new|exec), which options take a value, and where the model, effort, session name and prompt are. That covers Codex's -m and -c model_reasoning_effort=…/-c model=…, Claude's --model/--effort, and acpmux's -m HARNESS[/MODEL], -e, -n, --host and --prompt-file. --help/--version start nothing, and neither does another subcommand (acpmux send). A bare acpmux new -n x with no prompt starts nothing either.
  • Helpers for the card: promptTitle (the first line of the prompt that says something), runModel ("gpt-6-astra xhigh"), harnessFamily/harnessLabel, runReply (Codex's final message after its tokens used log, with Claude Code's "Shell cwd was reset" trailer removed), and backgroundOutputPath.

Risk

None at runtime: nothing imports the module yet. The next PR wires it into the subagent fold.

Tests

agentRuns.test.ts uses commands Claude Code recorded on 2026-10-24, with the paths scrubbed: a Codex review through reach with its prompt on stdin, the perl alarm wrapper, a heredoc prompt, a nohup sh -c inside reach behind a pipe, and acpmux new/run, sr codex and claude -p. Negatives from the same recordings: grep "codex exec", codex exec --help, pgrep -fl 'codex exec|…', a heredoc whose text mentions codex exec, acpmux send, a bare acpmux new, claude mcp list. The webview CI jobs run the suite: huge-blue is out of memory right now, so it wasn't run locally. An independent Codex review comes before landing.

Agent session: cosmic-gray

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.