Skip to content

Commit b627a8b

Browse files
authored
improvement(workflow-code): clean slate for workflows and workspace as code (#10344)
1 parent 73ca568 commit b627a8b

88 files changed

Lines changed: 817 additions & 757 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/rules/sim-workflow-code.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ changed.
209209
| `.sim/base.json` (workspace) | `version: 1` | Same policy |
210210
| `workflow_source_meta` | `version: 1` | Same policy; a bump needs a data migration |
211211
| Fingerprints | `sf1:` (workflow), `rf1:` (resource) | Any change to canonicalize or a kind's `canonical()` output changes every stored fingerprint and makes every checkout stale; treat it as a format change |
212-
| SDK surface | `// @sim-sdk 1`, `SDK_MAJOR`, `OLDEST_SDK_MAJOR` | Compile refuses a newer major and reads down to the floor |
212+
| SDK surface | `// @sim-sdk 1`, `SDK_MAJOR` | Compile refuses any major but the server's |
213213
| `apps/sim/blocks/sdk-names/` | append-only | Never rename or remove a name |
214214

215215
Nothing upgrades an old version: a bump is a hard refusal until a migration exists. A lock or base

‎.cursor/rules/sim-workflow-code.mdc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ changed.
189189
| `.sim/base.json` (workspace) | `version: 1` | Same policy |
190190
| `workflow_source_meta` | `version: 1` | Same policy; a bump needs a data migration |
191191
| Fingerprints | `sf1:` (workflow), `rf1:` (resource) | Any change to canonicalize or a kind's `canonical()` output changes every stored fingerprint and makes every checkout stale; treat it as a format change |
192-
| SDK surface | `// @sim-sdk 1`, `SDK_MAJOR`, `OLDEST_SDK_MAJOR` | Compile refuses a newer major and reads down to the floor |
192+
| SDK surface | `// @sim-sdk 1`, `SDK_MAJOR` | Compile refuses any major but the server's |
193193
| `apps/sim/blocks/sdk-names/` | append-only | Never rename or remove a name |
194194

195195
Nothing upgrades an old version: a bump is a hard refusal until a migration exists. A lock or base

‎apps/docs/content/docs/cli/reference.mdx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8622,7 +8622,6 @@ sim workflows source get <workflowId> [options]
86228622
| `--function-code <value>` | No | Where function-block code goes: `files` (default) writes it to `functions/*` files referenced with `codeFile()`; `inline` prints it in tagged templates. Accepted values: `inline`, `files`. |
86238623
| `--dir <dir>` | No | Write the source, its lock and SDK type declarations into this directory instead of printing them. |
86248624
| `--force` | No | With --dir: replace another workflow's source or edits no apply has saved. |
8625-
| `--primer` | No | Also print the primer written atop .sim/AGENTS.md (a `primer` field in JSON). |
86268625

86278626
</CommandTable>
86288627

@@ -10037,7 +10036,6 @@ sim workspaces source get [options]
1003710036

1003810037
| Option | Required | Description |
1003910038
| --- | --- | --- |
10040-
| `--primer` | No | Also print the primer written atop .sim/AGENTS.md (a `primer` field in JSON). |
1004110039
| `--dir <dir>` | Yes | Directory to write the workspace source into. |
1004210040
| `--only <kinds>` | No | Read only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
1004310041
| `--force` | No | Replace files with edits no apply has saved. |

‎apps/docs/content/docs/cli/workflows.mdx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,6 @@ sim workflows source get <workflowId> [options]
13791379
| `--function-code <value>` | No | Where function-block code goes: `files` (default) writes it to `functions/*` files referenced with `codeFile()`; `inline` prints it in tagged templates. Accepted values: `inline`, `files`. |
13801380
| `--dir <dir>` | No | Write the source, its lock and SDK type declarations into this directory instead of printing them. |
13811381
| `--force` | No | With --dir: replace another workflow's source or edits no apply has saved. |
1382-
| `--primer` | No | Also print the primer written atop .sim/AGENTS.md (a `primer` field in JSON). |
13831382

13841383
</CommandTable>
13851384

‎apps/docs/content/docs/cli/workspaces.mdx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ sim workspaces source get [options]
700700

701701
| Option | Required | Description |
702702
| --- | --- | --- |
703-
| `--primer` | No | Also print the primer written atop .sim/AGENTS.md (a `primer` field in JSON). |
704703
| `--dir <dir>` | Yes | Directory to write the workspace source into. |
705704
| `--only <kinds>` | No | Read only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
706705
| `--force` | No | Replace files with edits no apply has saved. |

‎apps/docs/content/docs/workflows/blocks/human-in-the-loop.mdx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ HITL blocks are excluded from the selected-output picker because pause data is i
7676

7777
## Resume with the v2 API
7878

79-
A v2 execute call can return `data.status: "paused"`. Read `contextId` from `data.output.data._resume` and the paused run's ID from `data.runId`:
79+
A v2 execute call can return `data.status: "paused"`. Read the run to resume from `data.paused.runId`, and the `contextId` of a waiting `human` point from `data.paused.points`:
8080

8181
```bash
8282
curl -X POST 'https://www.sim.ai/api/v2/workflows/WORKFLOW_ID/runs/RUN_ID/resume' \
@@ -102,12 +102,13 @@ For an originally synchronous run, the response waits for the resumed execution
102102
"error": null,
103103
"startedAt": "2026-10-13T10:00:00.000Z",
104104
"endedAt": "2026-10-13T10:00:01.234Z",
105-
"durationMs": 1234
105+
"durationMs": 1234,
106+
"paused": null
106107
}
107108
}
108109
```
109110

110-
A later Human block can pause the resumed run again, returning new pause data. The resumed attempt has its own `runId`.
111+
A later Human block can pause the resumed run again. The response then has `status: "paused"` and new `paused.points`, and `paused.runId` names the run to resume next: the run you resumed, not the attempt's own `runId`.
111112

112113
### Asynchronous and originally streaming runs
113114

‎apps/docs/content/docs/workflows/code/coding-agents.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Claude Code, Cursor, Codex and other coding agents work from a directory that `g
77

88
## What get gives an agent
99

10-
- A **primer**, which opens `.sim/AGENTS.md`. `get` prints a short summary instead (the files written, the guide, and the `editLoop` command to run); `get --primer` also prints the primer (in JSON output, its `primer` field). It covers the edit loop, how block identity, references and renames work, failures and retries, test runs, deletes, deploy, exit codes, and the params of each builder the workflow already uses.
10+
- A **primer**, which opens `.sim/AGENTS.md`. `get` prints a short summary instead (the files written, the guide, and the `editLoop` command to run). It covers the edit loop, how block identity, references and renames work, failures and retries, test runs, deletes, deploy, exit codes, and the params of each builder the workflow already uses.
1111
- **`.sim/AGENTS.md`**: the primer followed by a reference, by task. A workspace directory also gets `.sim/GUIDE-advanced.md`.
1212
- **`.sim/examples/`**: one correct example of each common block to copy from.
1313
- **`.sim/sdk/`**: the type declarations, with `.sim/sdk/INDEX.md` listing the builders.

‎apps/docs/content/docs/workflows/code/diagnostics.mdx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Reading and writing `workflow.ts`.
2222
| `E_NUMBER_NOT_FINITE` | A number literal too large to store (`1e999` reads as `Infinity`). |
2323
| `W_NUMBER_PRECISION` | A number literal whose digits a number cannot hold; write it as a string. |
2424
| `E_SDK_HEADER` | Line 1 is not `// @sim-sdk N`. |
25-
| `E_SDK_MAJOR` | The header's major is newer than the server supports. |
26-
| `E_SDK_MAJOR_OLD` | The header's major is older than the oldest the server reads. |
25+
| `E_SDK_MAJOR` | The header's major is not the one the server reads. |
2726
| `E_UNSUPPORTED_SYNTAX` | A construct outside this grammar; the hint names the supported form. |
2827
| `E_WORKFLOW_EXPORT` | Not exactly one `export default workflow(…)`. |
2928
| `E_LIMIT_EXCEEDED` | Over the block, edge, total-byte, depth or `codeFile()` reference cap (`SOURCE_LIMITS`). Apply answers 413. |

‎apps/docs/content/docs/workflows/code/edit.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ sim workflows source status --dir ./support-triage
4646
sim workflows source diff --dir ./support-triage
4747
```
4848

49-
`status` lists the files you created, edited, or deleted, asks the server (with a dry run that saves nothing) whether the workflow changed since the `get`, and ends with the one command to run next. It exits `0` when nothing changed, `11` when only your edits are unsaved, and `12` when the workflow changed in the workflow builder since the `get` (a conflict, if you edited it too). Without a connection it shows your edits only and says so; `--offline` skips the server. `diff` prints each edit as a unified diff, and `diff --server` compares the directory with the workflow as it is saved now. Both take `--json` (or `--output json`).
49+
`status` lists the files you created, edited, or deleted, asks the server (with a plan read that saves nothing) whether the workflow changed since the `get`, and ends with the one command to run next. It exits `0` when nothing changed, `11` when only your edits are unsaved, and `12` when the workflow changed in the workflow builder since the `get` (a conflict, if you edited it too). Without a connection it shows your edits only and says so; `--offline` skips the server. `diff` prints each edit as a unified diff, and `diff --server` compares the directory with the workflow as it is saved now. Both take `--json` (or `--output json`).
5050

5151
## 4. Dry run
5252

‎apps/docs/content/docs/workflows/code/how-it-works.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Sim also stores each block's `const` name, its order in the file and its comment
5757
- the same: the apply goes ahead;
5858
- different: someone saved the workflow since you read it. The apply is refused as stale with exit `5`, on a dry run too, and nothing is written; [Troubleshooting](/workflows/code/troubleshooting#exit-5) has the steps.
5959

60-
The check is made again inside the write's transaction, so two applies that race cannot both win. `status` asks the same question with a dry run and reports it as drift (exit `12`) before you apply.
60+
The check is made again inside the write's transaction, so two applies that race cannot both win. `status` asks the same question with a plan read that saves nothing and reports it as drift (exit `12`) before you apply.
6161

6262
The base also records the block catalog you read against. When a compile fails and the catalog changed since, for example after a block gained a setting, the apply adds `W_APPLY_CATALOG_MOVED`: run `get` again to pick up the new types.
6363

0 commit comments

Comments
 (0)