--format jsonl --control stdio. The run prints one JSON object per line on stdout, and reads commands, one JSON object per line, on stdin. When the workflow asks something (an approval(...) step, a shell command, a coding agent to pick), the run waits for the answer instead of exiting.
codemod npm package:
What the run prints
The first line ishello. It names the run before anything happens, so a client can attach, cancel or resume it later:
--format jsonl prints without a control channel (see --format). Each has seq, which counts up through the whole run, also across resumes, and ts. Step events name their step with step, a key that stays the same across resumes ("3"; "3/0" for step 0 of the codemod that step 3 runs, whose parent is "3").
When a workflow first uses an experimental API, an experimental event names it in api. A run emits at most one notice per API, even if it resumes. This event is part of the event stream, not the workflow result.
A question looks like this:
Questions come one at a time. When one is answered, or closed because the run stops,
question_closed says how: answer is "approved", "rejected" or "later" (an agent’s id, or null, for agent questions), and by is "answer", "stop" or "eof". --approve still gives approvals up front, without asking.
Commands
approveandrejectanswer an approval.answertakes"approve","reject"or"later"(only for manual approvals and interrupted steps) for approvals, and an available agent’s id, ornullfor the built-in agent, for agent questions.questionIdis accepted forquestion_id.stopstops the run:"pause"(the default) leaves itpaused, to resume;"cancel"ends it ascanceled.- A command that cannot be followed (not JSON, not UTF-8, no such open question, a wrong answer) gets a
control_errorevent with themessageand theline; the run goes on, and so does reading commands. - Closing stdin pauses the run, as
stopdoes, and closes the open question. Keep stdin open for as long as the run should go on.
run_started. Answer "approve" to rerun that step, "reject" to skip it without rejecting the run, or "later" to leave the run as it was and exit 3. --approve does not answer these questions; use --rerun-step or --skip-step to decide up front.
How a run ends
A run paused at a question still waits for it. When you
stop or close stdin while a question is open, the run is paused, and run_finished (and workflow status --format json) keep that question’s question id and awaiting message. The approval step is awaiting-approval, not canceled. Resume it with workflow resume --id <ID> --approve <question id> to give that approval, or without --approve to be asked again.
A rejected approval ends the run. Nothing after it runs, steps running alongside stop, and what earlier steps changed stays changed. The process exits with 1, as it does for paused and canceled, and with 3 for awaiting-approval (see exit codes); run_finished has the status.
A dry run with a control channel waits at its questions like a real run, and approve lets it go on and report its diff. Without one, a dry run that reaches an approval exits with 1: it is not saved, so it cannot wait to be resumed.
Attach to a run
Every saved run keeps its events in the run store.workflow attach prints them, after a hello (with "mode":"attach" and no commands), and follows the run while another process executes it:
Read runs and workflows
workflow list --format jsonandworkflow status --id <ID> --format jsonprint runs;statushasquestion, the approval a waiting run needs. If the run pauses while a question is open (for example,stopor closed stdin), it keeps that question.- Experimental:
workflow inspect -w <file|dir> --format jsondescribes a workflow for a setup form: declared params with their types, doc comments and@defaults, imports, which declared steps reach outside the target (http,shell,agent, …), and itsstep(...)calls. Seeworkflow inspect.