Containarium icon indicating copy to clipboard operation
Containarium copied to clipboard

code run --workdir and MCP code_run workdir: the CLI counterpart of StartBoxRun's workdir

Open hsinatfootprintai opened this issue 3 weeks ago • 1 comments

Problem

#3551 adds StartBoxRunRequest.workdir on the daemon API. The CLI counterpart of StartBoxRun's run options is containarium code run (the SSH path, as docs/BOX-RUN-API.md notes for --command), and the platform MCP code_run tool runs over the same path. Neither can choose the directory a run starts in today: both call agent-box's process_start with an empty cwd, and session discovery assumes the home.

Proposal

  • containarium code run <box> --workdir <dir> (prompt and --command runs) and a workdir argument on MCP code_run, the MCP tool a thin wrapper over the same client function.
  • Same rule as #3551: canonical home-relative path (the WriteBoxFile rule, moved to internal/coderun so the CLI can share it), and the directory must exist before anything on the box changes (agent-box's process_start rotates a finished run and truncates its log before it fails on a bad cwd, so the check comes first). Never created, no fallback.
  • Session discovery (CLI snapshotSessionDirectory / startSessionDiscovery, and the MCP twins) uses the workdir as the cwd.

Acceptance

  • code run <box> --command pwd --workdir project prints ~/project; a missing directory, a file, and .. or absolute values are refused before a run starts.
  • MCP code_run with workdir behaves the same through the same function.

Found while implementing #3551 (split out to keep that PR to the daemon API the issue's acceptance names).

Blocked by: #3551

hsinatfootprintai avatar Nov 10 '26 16:11 hsinatfootprintai

Starting on this: code run --workdir (prompt and --command runs, SSH and --run-token-file paths) and a workdir argument on MCP code_run, with the path rule and the existence check shared from internal/coderun.

NopeCharon avatar Nov 11 '26 10:11 NopeCharon