Raw: https://promptreports.ai/docs/workflow-schema.md

# Workflow schema

A workflow is one JSON manifest. Its JSON Schema is at https://promptreports.ai/schemas/workflow/v2.json; set it as `$schema` and an editor or an agent can check the manifest before saving.

## The top level

| Field | What it holds |
|---|---|
| `$schema` | Always https://promptreports.ai/schemas/workflow/v2.json |
| `id, version, title` | A lowercase id, a semver version you choose, and a title. Each save also stores the manifest's digest. |
| `inputs` | A JSON Schema for the run's input; it describes an object. |
| `steps` | The list of steps. Any step may be a block that holds more steps. |
| `limits` | max_steps (capped by the plan: 100 or 500), a timeout as an ISO 8601 duration, max_call_depth. |

## Steps and blocks

| Block | What it does |
|---|---|
| **action (use)** | One connector call, such as `repoops.build_fix@1`, with its inputs in `with`. An `approval` makes a person approve it first; the step then runs with the approved final_args. |
| **approval step** | A person's decision recorded with its final_args. It calls nothing. |
| **if, switch** | Run one branch by an expression. |
| **for_each** | One iteration per item of a list, read as `{{ loop.item }}`. Needs max_iterations. |
| **repeat, while, until** | Loops by count or by a condition. Each needs max_iterations; on_limit says what happens when it is reached. |
| **parallel** | Branches that run at once. |
| **wait** | Wait for a duration, a time or an event. |
| **call** | Run another workflow as a child run, up to max_call_depth. |

Double braces hold a JSONata expression. A field that is exactly one expression keeps its JSON type; text around it makes a string. A path to a step that has not run yet is refused at save.

## Worked example: a while inside a for_each, on a timer

For each account, poll its status until it is done, at most 10 times. A timer trigger starts it every 15 minutes, and a run that is still going when the next one is due is skipped.

```
{
  "$schema": "https://promptreports.ai/schemas/workflow/v2.json",
  "id": "account-status",
  "version": "1.0.0",
  "title": "Account status",
  "inputs": { "type": "object", "properties": { "accounts": { "type": "array", "items": { "type": "string" } } } },
  "steps": [
    {
      "id": "accounts",
      "for_each": "{{ input.accounts }}",
      "max_iterations": 50,
      "steps": [
        {
          "id": "poll",
          "while": "{{ $not(steps.check.output.status = 'done') }}",
          "max_iterations": 10,
          "steps": [
            { "id": "check", "use": "repoops.get_status@1", "with": { "account": "{{ loop.item }}" } }
          ]
        }
      ]
    }
  ],
  "limits": { "max_steps": 100, "timeout": "PT1H" }
}
```

Save it, then set the timer from the agent with `set_trigger`, or from the CLI:

```
promptreports workflows validate account-status.json
promptreports workflows save account-status.json
promptreports workflows triggers set account-status --kind timer --every PT15M --overlap skip
```

The tool name `repoops.get_status@1` is an example; `list_connectors` lists the tools your org can call. When the org's policy gates trigger changes, a person approves the timer first and it stays off until then.
