Add fold exec — run a command in a running machine - #3
Merged
Conversation
There was no way to get a shell into a deployed machine to inspect it —
a major DX gap for an agent runtime. This adds one-shot command exec.
- Runtime gains Exec; the docker runtime implements it via `docker exec`
(stdin forwarded, exit code surfaced). wasm/microVM/firecracker return
ErrExecUnsupported (no shell / vsock-or-ssh exec is roadmap).
- The host agent admin API serves POST /v1/machines/{id}/exec alongside
the existing logs route, bounded by a per-command timeout.
- Control resolves the target machine (named, or the first running one),
proxies to the host agent, and records an exec event + audit entry.
- API exposes POST /v1/apps/{app}/exec gated by the deploy scope.
- `fold exec [-a app] [--machine id] -- <cmd>` prints combined output,
forwards piped stdin, and exits with the command's exit code.
Interactive TTY sessions and long-lived streams (tail -f) are out of
scope for this first version (one-shot, bounded by --timeout).
Tests: machine-target resolution (auto-pick running, reject unscheduled/
unknown), exec scope+validation (viewer 403, missing cmd 400, no running
machine 502), and the wasm-unsupported contract. Verified end-to-end with
a local deploy: output, env/hostname, stdin pipe, and exit-code 7.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 18, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Next operability gap after central logs (#2): there was no way to get into a deployed machine to inspect it — no
exec, nossh. For an agent runtime, "run a command inside my agent's machine" (ps, env, cat /data, curl localhost) is a core debugging primitive. This adds one-shot command exec.What changed
Exec. The docker runtime implements it viadocker exec(forwards stdin, surfaces the command's exit code). wasm (no shell), microVM, and firecracker returnErrExecUnsupported— microVM exec over vsock/ssh is roadmap.POST /v1/machines/{id}/execalongside the existing logs route, with a per-command timeout.POST /v1/apps/{app}/exec, gated by the deploy scope.fold exec [-a app] [--machine id] -- <cmd>prints combined output, forwards piped stdin, and exits with the command's exit code.Scope
One-shot, buffered exec bounded by
--timeout(default 60s). Interactive TTY sessions and long-lived streams (tail -f) are out of scope for this first version — they need bidirectional streaming (websocket/hijack) and can follow.Tests
cmd→ 400, valid request with no running machine → 502ExecreturnsErrExecUnsupportedVerification
gofmt -lclean ·go vet ./...clean ·go test ./...all pass ·go build -tags firecracker ./...compileshello-go):echooutput,env/hostname(PORT=8080, m-0), stdin pipe (cat), and exit-code propagation (exit 7→ CLI exits 7) all verified🤖 Generated with Claude Code