Skip to main content

Wait

cmd/crewship/cmd_wait.go polls a run’s status until it transitions to a final state, then exits with a status-aware code so scripts can act on the outcome without re-parsing JSON. The run id may be an agent run or a routine (pipeline) run — the agent-run endpoint is probed first, and a 404 falls through to the routine-run endpoint, so callers don’t have to know which subsystem produced the id.

crewship wait <run-id>

FlagTypeDefaultEffect
--timeout <dur>duration30mHard ceiling on the wait. 0 = forever.
--interval <dur>duration2sPoll cadence. Values ≤ 0 fall back to 2s.
-q, --quietboolfalsePrint only the terminal status string (no [wait] log lines, no [done] banner).
--routineboolfalseTreat <run-id> as a routine run id and skip the agent-run probe.
A routine run parked on a human approval (status waiting) is not terminal — wait keeps polling until the waitpoint is approved/rejected and the run finishes, or --timeout fires. When neither --quiet nor a structured --format (json/yaml/ndjson) is set, status transitions are logged to stderr as [wait] <run> status=<S> elapsed=<dur> and the final state lands on stdout as [done] <run> status=COMPLETED elapsed=12s.

Exit codes

CodeMeaning
0COMPLETED (or a routine dry_run)
1FAILED (or a routine interrupted by a server restart)
2CANCELLED
3TIMEOUT — server-reported, or --timeout reached
4Network/auth error before any status could be read, or the id matched neither run kind

Examples

RUN=$(crewship ask --no-stream -q "do X" | jq -r .id)
crewship wait "$RUN" && echo "done" || echo "broke"

crewship wait r_abc --interval 500ms --timeout 5m
crewship wait r_abc --quiet                       # prints "COMPLETED" or similar
crewship wait r_abc --format json                 # full RunDetail on completion

# Routine runs work too — e.g. the run_id from `crewship routine run`
crewship wait prun_xyz --routine --timeout 10m

See also