agent-exec
Non-interactive agent job runner. Runs commands as background jobs and returns structured JSON on stdout.
Output Contract
- stdout: JSON only — every command prints exactly one JSON object
- stderr: Diagnostic logs (controlled by
RUST_LOGor-v/-vvflags)
This separation lets agents parse stdout reliably without filtering log noise.
Installation
Quick Start
Short-lived job (run → wait → tail)
Run a command, wait for it to finish, then read its output:
# 1. Start the job (returns immediately with a job_id)
JOB=
# 2. Wait for completion
# 3. Read output
Example output of tail:
Long-running job (run → status → tail)
Start a background job, poll its status, then read its output:
# 1. Start the job (returns immediately with a job_id)
JOB=
# 2. Check status
# 3. Stream output tail
# 4. Wait for completion
Timeout and force-kill
Run a job with a timeout; SIGTERM after 5 s, SIGKILL after 2 s more:
Commands
run — start a background job
Key options:
| Flag | Default | Description |
|---|---|---|
--snapshot-after <ms> |
10000 | Wait N ms before returning (0 = return immediately) |
--timeout <ms> |
0 (none) | Kill job after N ms |
--kill-after <ms> |
0 | ms after SIGTERM to send SIGKILL |
--tail-lines <N> |
50 | Lines of output captured in the snapshot |
--cwd <dir> |
inherited | Working directory |
--env KEY=VALUE |
— | Set environment variable (repeatable) |
--mask KEY |
— | Redact secret values from JSON output (repeatable) |
status — get job state
Returns running, exited, killed, or failed, plus exit_code when finished.
tail — read output
Returns the last N lines of stdout and stderr.
wait — block until done
Polls until the job finishes or the timeout elapses.
kill — send signal
list — list jobs
Logging
Logs go to stderr only. Use -v / -vv or RUST_LOG:
RUST_LOG=debug
Development