Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/docs/content/docs/cli/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10150,7 +10150,7 @@ sim workspaces source apply [options]

</CommandTable>

Exit codes: 0 applied (or a clean dry run); 1 the source has errors (each printed as file:line:column with its frame and hint), or every change it would write was held back because it uses a declared secret the workspace has no value for or a declared credential key nothing binds to (nothing was written; a dry run of such an apply exits 1 too), the directory was read from another workspace than the one --workspace or SIM_WORKSPACE names (SOURCE_OTHER_WORKSPACE: drop it, or promote it with --to; without either an apply targets the workspace the directory was read from), its base records binary files no get downloaded (SOURCE_BLOBS_NOT_FETCHED: get again first), a --run test run did not complete (the apply is written; deployments/ was not applied), or the command failed; 5 a resource changed or was deleted on the server since the directory was read (SOURCE_STALE: get it again into a fresh directory, reapply the edit, retry); 6 a resource (a workflow or its folder, a table) is locked (a locked block exits 1, E_APPLY_LOCKED_BLOCK); 7 the directory is too large (apply part of it with --only); 8 the apply stopped part-way on a server failure: what was written is saved into the directory, and applying again continues. An apply a resource refused part-way (stale, locked, forbidden) saves what was written too, and exits as that refusal: 5, 6 or 1; 9 rate limited (HTTP 429) after the CLI's retries, before anything was written: wait a minute and apply again (binary files already uploaded are not sent again); 10 another apply is writing the workspace (SOURCE_BUSY), or another command is using the directory (SOURCE_DIR_BUSY): nothing was written, run the command again once the other finished; 13 not logged in, the login expired, or the server refused the credential (AUTH_REQUIRED): nothing was sent, run `sim login` (or fix or unset SIM_API_KEY when the key comes from it) and the command again; 14 without --yes and with no terminal to ask: the plan was printed with no errors and nothing was written (run the same command with --yes to apply it); 15 written in part: changes that use a declared secret the workspace has no value for, or a declared credential key nothing binds to, were held back and the rest was applied and saved (set the secret or connect the credential, then apply again); a dry run that would do so exits 15 too, having written nothing; 130 interrupted (Ctrl-C): a write already sent is finished and saved into the directory first, waiting up to 60s for its answer, and a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check.
Exit codes: 0 applied (or a clean dry run); 1 the source has errors (each printed as file:line:column with its frame and hint), or every change it would write was held back because it uses a declared secret the workspace has no value for or a declared credential key nothing binds to (nothing was written; a dry run of such an apply exits 1 too), the directory was read from another workspace than the one --workspace or SIM_WORKSPACE names (SOURCE_OTHER_WORKSPACE: drop it, or promote it with --to; without either an apply targets the workspace the directory was read from), its base records binary files no get downloaded (SOURCE_BLOBS_NOT_FETCHED: get again first), a --run test run did not complete (the apply is written; deployments/ was not applied), or the command failed; 5 a resource changed or was deleted on the server since the directory was read (SOURCE_STALE: get it again into a fresh directory, reapply the edit, retry); 6 a resource (a workflow or its folder, a table) is locked (a locked block exits 1, E_APPLY_LOCKED_BLOCK); 7 the directory is too large (apply part of it with --only); 8 the apply stopped part-way on a server failure: what was written is saved into the directory, and applying again continues. An apply a resource refused part-way (stale, locked, forbidden) saves what was written too, and exits as that refusal: 5, 6 or 1; 9 rate limited (HTTP 429) after the CLI's retries: wait a minute and apply again (binary files already uploaded are not sent again). Nothing was written, unless the apply's result printed first: then the apply was saved into the directory, and only a step --run takes after it (deployments/ or its check) was limited; 10 another apply is writing the workspace (SOURCE_BUSY), or another command is using the directory (SOURCE_DIR_BUSY): nothing was written, run the command again once the other finished; 13 not logged in, the login expired, or the server refused the credential (AUTH_REQUIRED): nothing was sent, run `sim login` (or fix or unset SIM_API_KEY when the key comes from it) and the command again; 14 without --yes and with no terminal to ask: the plan was printed with no errors and nothing was written (run the same command with --yes to apply it); 15 written in part: changes that use a declared secret the workspace has no value for, or a declared credential key nothing binds to, were held back and the rest was applied and saved (set the secret or connect the credential, then apply again); a dry run that would do so exits 15 too, having written nothing; 130 interrupted (Ctrl-C): a write already sent is finished and saved into the directory first, waiting up to 60s for its answer, and a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check.

API request and response schemas: [applyWorkspaceSource](/api-reference/workflows/applyWorkspaceSource), [findMissingWorkspaceSourceBlobs](/api-reference/workflows/findMissingWorkspaceSourceBlobs), [stageWorkspaceSourceBlobs](/api-reference/workflows/stageWorkspaceSourceBlobs), [getWorkspaceSource](/api-reference/workflows/getWorkspaceSource), [getSourceCatalog](/api-reference/catalog/getSourceCatalog), [getWorkflowDeployment](/api-reference/workflows/getWorkflowDeployment), [executeWorkflow](/api-reference/workflows/executeWorkflowV2).

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/cli/workspaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ sim workspaces source apply [options]

</CommandTable>

Exit codes: 0 applied (or a clean dry run); 1 the source has errors (each printed as file:line:column with its frame and hint), or every change it would write was held back because it uses a declared secret the workspace has no value for or a declared credential key nothing binds to (nothing was written; a dry run of such an apply exits 1 too), the directory was read from another workspace than the one --workspace or SIM_WORKSPACE names (SOURCE_OTHER_WORKSPACE: drop it, or promote it with --to; without either an apply targets the workspace the directory was read from), its base records binary files no get downloaded (SOURCE_BLOBS_NOT_FETCHED: get again first), a --run test run did not complete (the apply is written; deployments/ was not applied), or the command failed; 5 a resource changed or was deleted on the server since the directory was read (SOURCE_STALE: get it again into a fresh directory, reapply the edit, retry); 6 a resource (a workflow or its folder, a table) is locked (a locked block exits 1, E_APPLY_LOCKED_BLOCK); 7 the directory is too large (apply part of it with --only); 8 the apply stopped part-way on a server failure: what was written is saved into the directory, and applying again continues. An apply a resource refused part-way (stale, locked, forbidden) saves what was written too, and exits as that refusal: 5, 6 or 1; 9 rate limited (HTTP 429) after the CLI's retries, before anything was written: wait a minute and apply again (binary files already uploaded are not sent again); 10 another apply is writing the workspace (SOURCE_BUSY), or another command is using the directory (SOURCE_DIR_BUSY): nothing was written, run the command again once the other finished; 13 not logged in, the login expired, or the server refused the credential (AUTH_REQUIRED): nothing was sent, run `sim login` (or fix or unset SIM_API_KEY when the key comes from it) and the command again; 14 without --yes and with no terminal to ask: the plan was printed with no errors and nothing was written (run the same command with --yes to apply it); 15 written in part: changes that use a declared secret the workspace has no value for, or a declared credential key nothing binds to, were held back and the rest was applied and saved (set the secret or connect the credential, then apply again); a dry run that would do so exits 15 too, having written nothing; 130 interrupted (Ctrl-C): a write already sent is finished and saved into the directory first, waiting up to 60s for its answer, and a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check.
Exit codes: 0 applied (or a clean dry run); 1 the source has errors (each printed as file:line:column with its frame and hint), or every change it would write was held back because it uses a declared secret the workspace has no value for or a declared credential key nothing binds to (nothing was written; a dry run of such an apply exits 1 too), the directory was read from another workspace than the one --workspace or SIM_WORKSPACE names (SOURCE_OTHER_WORKSPACE: drop it, or promote it with --to; without either an apply targets the workspace the directory was read from), its base records binary files no get downloaded (SOURCE_BLOBS_NOT_FETCHED: get again first), a --run test run did not complete (the apply is written; deployments/ was not applied), or the command failed; 5 a resource changed or was deleted on the server since the directory was read (SOURCE_STALE: get it again into a fresh directory, reapply the edit, retry); 6 a resource (a workflow or its folder, a table) is locked (a locked block exits 1, E_APPLY_LOCKED_BLOCK); 7 the directory is too large (apply part of it with --only); 8 the apply stopped part-way on a server failure: what was written is saved into the directory, and applying again continues. An apply a resource refused part-way (stale, locked, forbidden) saves what was written too, and exits as that refusal: 5, 6 or 1; 9 rate limited (HTTP 429) after the CLI's retries: wait a minute and apply again (binary files already uploaded are not sent again). Nothing was written, unless the apply's result printed first: then the apply was saved into the directory, and only a step --run takes after it (deployments/ or its check) was limited; 10 another apply is writing the workspace (SOURCE_BUSY), or another command is using the directory (SOURCE_DIR_BUSY): nothing was written, run the command again once the other finished; 13 not logged in, the login expired, or the server refused the credential (AUTH_REQUIRED): nothing was sent, run `sim login` (or fix or unset SIM_API_KEY when the key comes from it) and the command again; 14 without --yes and with no terminal to ask: the plan was printed with no errors and nothing was written (run the same command with --yes to apply it); 15 written in part: changes that use a declared secret the workspace has no value for, or a declared credential key nothing binds to, were held back and the rest was applied and saved (set the secret or connect the credential, then apply again); a dry run that would do so exits 15 too, having written nothing; 130 interrupted (Ctrl-C): a write already sent is finished and saved into the directory first, waiting up to 60s for its answer, and a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check.

API request and response schemas: [applyWorkspaceSource](/api-reference/workflows/applyWorkspaceSource), [findMissingWorkspaceSourceBlobs](/api-reference/workflows/findMissingWorkspaceSourceBlobs), [stageWorkspaceSourceBlobs](/api-reference/workflows/stageWorkspaceSourceBlobs), [getWorkspaceSource](/api-reference/workflows/getWorkspaceSource), [getSourceCatalog](/api-reference/catalog/getSourceCatalog), [getWorkflowDeployment](/api-reference/workflows/getWorkflowDeployment), [executeWorkflow](/api-reference/workflows/executeWorkflowV2).

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/workflows/code/coding-agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ For a whole workspace, use `sim workspaces source` with the same steps: its chai

- `sim workflows source find <block...>` prints each named block of the workflow by name, key or identifier, from the directory without a request: its declaration with line numbers, its function file, its incoming and outgoing wiring and every block that reads its outputs, each as `file:line`. A part of a name prints every block it matches. Name every block a change touches in one call; a name that matches no block exits `1` after the others print.
- `sim workflows source params <builder>` prints a builder in brief (an example call, the required params with types, the optional ones by name and the outputs) from the cached block catalog without a request. `--full` prints every param with its type, options, default and doc. A legacy builder names the one that replaces it, and a namespace such as `gmail` lists its builders.
- `sim workflows source resources` lists the tables, knowledge bases, credentials, workflows, skills, custom tools, MCP servers and environment variable names the file can name.
- `sim workflows source resources` lists the tables, knowledge bases, credentials, workflows, skills, custom tools, MCP servers, files (by the path `file()` takes) and environment variable names the file can name.
- `sim workflows source catalog` shows the block catalog the source is checked against.

## Exit codes and retries
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/workflows/code/diagnostics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ Workspace source reports every workflow code above for the files of `workflows/<
| `W_SERVER_DELETED` | The server deleted a resource the directory leaves as it was; it is not created again. |
| `W_SERVER_MOVED` | The server moved a resource the directory leaves as it was; it is not created again. |
| `I_KEY_REBOUND` | A key bound to a deleted resource was bound to the one this apply wrote. |
| `E_KEY_RENAMED` | A declaration under a new key for a resource the base read under another: keys never move. |
| `E_KEY_RENAMED` | A declaration under a new key for a resource the base read under another: keys never move, except a renamed workflow folder's. |

#### Shared with workflow source

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/workflows/code/how-it-works.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The base also records the block catalog you read against. When a compile fails a

## Workspaces: one rule per resource

A workspace directory adds tables, knowledge bases, files, custom tools, skills, MCP servers, secret names, credential keys and deployments. Each resource has a key, its file or folder name, which Sim stores and never changes: a rename in Sim keeps the key, and a workflow names the resource by it, as in `table('orders')`.
A workspace directory adds tables, knowledge bases, files, custom tools, skills, MCP servers, secret names, credential keys and deployments. Each resource but a file has a key, its file or folder name, which Sim stores and never changes: a rename in Sim keeps the key, and a workflow names the resource by it, as in `table('orders')`. A deployment's key is its workflow's, so renaming a workflow folder moves both. A file has no stored key: a workflow names it by its path under `files/`, as in `file('docs/report.pdf')`, so after a rename or move in Sim, source names it by its new path.

`.sim/base.json` at the root records each resource's ID and fingerprint as the last `get` or apply saw it. An apply decides each declared resource by comparing three fingerprints: your file (local), the base, and what Sim holds now (server):

Expand Down
6 changes: 5 additions & 1 deletion apps/docs/content/docs/workflows/code/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ A declaration in a workspace directory matches a resource Sim holds that the dir

### `E_KEY_RENAMED` [#e-key-renamed]

A resource file or folder in a workspace directory was renamed. Keys never change: move it back to its key, and change the resource's `name` inside the file instead.
A resource file or folder in a workspace directory was renamed. Only a workflow folder's key moves when you rename it; every other key stays: move the file or folder back to its key, and change the resource's `name` inside the file instead.

### `E_WORKFLOW_RENAMED_IN_USE` [#e-workflow-renamed-in-use]

Renaming `workflows/<key>/` moves the workflow's key, and its deployment's with it, but something in the directory still names the old key. The finding names the file and the rename to make: rename `deployments/<old key>.ts` to the new key, or change `childWorkflow('<old key>')` to the new key in the workflow that calls it. Then apply again.

### `E_APPLY_FORBIDDEN` [#e-apply-forbidden]

Expand Down
7 changes: 5 additions & 2 deletions apps/sim/blocks/blocks/guardrails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ The regex should be:
- Valid RE2 syntax: no lookahead ((?=...), (?!...)), no lookbehind ((?<=...), (?<!...)),
no backreferences (\\1), and no \\uXXXX escapes (use \\x41 or the literal character).
Patterns are matched by a linear-time engine that does not implement these, and one
that uses them fails every check. To express "must NOT contain X", match X and invert
the result downstream with a Condition block instead of using negative lookahead.
that uses them fails every check. For "must NOT contain X", return the pattern for X:
content without X then fails the check and leaves through the error port, so the allowed
path continues from the error port, never from a Condition after this block (a failed
check never reaches it). A Condition or Function block checking the content directly is
the other way.
- Properly escaped for special characters
- Optimized for the use case

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export function sourceExitCodeRows(prefix: SourceCommandGroup): SourceExitCodeRo
'workflows source status':
"rate limited (HTTP 429) after the CLI's retries: wait a minute and run it again",
'workspaces source apply':
"rate limited (HTTP 429) after the CLI's retries, before anything was written: wait a minute and apply again (binary files already uploaded are not sent again)",
"rate limited (HTTP 429) after the CLI's retries: wait a minute and apply again (binary files already uploaded are not sent again). Nothing was written, unless the apply's result printed first: then the apply was saved into the directory, and only a step --run takes after it (deployments/ or its check) was limited",
'workspaces source get':
"rate limited (HTTP 429) after the CLI's retries: nothing was written, the binary files already downloaded are kept in .sim/downloads, and running the get again downloads only the rest",
'workspaces source status':
Expand Down
3 changes: 2 additions & 1 deletion packages/workflow-code/src/compile/SYNTAX.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ round-trip such a block but never introduce one; renaming the block retires the
| `env.X` | `{{X}}` |
| `block(…)`, `edge(…)` | A generic block; a raw edge (see "Wiring") |

Keys are the workspace's persisted resource keys; `.sim/sdk/workspace.d.ts` lists them. A key with
Keys are the workspace's persisted resource keys, except `file()`, which takes the file's folder
path and name; `.sim/sdk/workspace.d.ts` lists them. A key with
no live resource is `E_MAT_UNKNOWN_RESOURCE` on apply.

### `stored()`
Expand Down
5 changes: 4 additions & 1 deletion packages/workspace-code/src/diagnostics/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ const PLAN_CODES = [
'W_SERVER_MOVED',
/** A key bound to a deleted resource was bound to the one this apply wrote. */
'I_KEY_REBOUND',
/** A declaration under a new key for a resource the base read under another: keys never move. */
/**
* A declaration under a new key for a resource the base read under another: keys never move,
* except a renamed workflow folder's.
*/
'E_KEY_RENAMED',
] as const

Expand Down
Loading