Skip to content

Commit 8a6bd23

Browse files
committed
fix(api): preserve workflow behavior and tighten diagnostics
1 parent 368c0e9 commit 8a6bd23

66 files changed

Lines changed: 1479 additions & 264 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.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pipelines. See [Output formats](/cli/output) for commands that emit raw content
1313
or local configuration.
1414

1515
For safe edits, compact run diagnostics, and partial retries, see
16-
[Agent workflow operations](/cli/agent-workflows).
16+
[Workflow operations](/cli/workflow-operations).
1717

1818
## Install
1919

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ sim logs get <runId> [options]
3131

3232
| Option | Required | Description |
3333
| --- | --- | --- |
34+
| `--include-workflow-state` | No | Include the saved workflow snapshot. Set false to avoid loading and returning block configuration when inspecting a run. Other run fields are unchanged. |
35+
| `--no-include-workflow-state` | No | Send --include-workflow-state as false. |
3436
| `--trace` | No | Show expanded trace spans with inputs, outputs, errors, timing, and cost. |
35-
| `--summary` | No | Show bounded run diagnostics and the explicit application outcome; omit binary content. |
37+
| `--summary` | No | Show bounded run diagnostics and final output; omit binary content and the workflow snapshot. |
3638

3739
</CommandTable>
3840

‎apps/docs/content/docs/cli/meta.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"output",
1010
"scripting",
1111
"workflow-sync",
12-
"agent-workflows",
12+
"workflow-operations",
1313
"troubleshooting",
1414
"usage-data",
1515
"---Commands---",

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,8 +2749,10 @@ sim logs get <runId> [options]
27492749

27502750
| Option | Required | Description |
27512751
| --- | --- | --- |
2752+
| `--include-workflow-state` | No | Include the saved workflow snapshot. Set false to avoid loading and returning block configuration when inspecting a run. Other run fields are unchanged. |
2753+
| `--no-include-workflow-state` | No | Send --include-workflow-state as false. |
27522754
| `--trace` | No | Show expanded trace spans with inputs, outputs, errors, timing, and cost. |
2753-
| `--summary` | No | Show bounded run diagnostics and the explicit application outcome; omit binary content. |
2755+
| `--summary` | No | Show bounded run diagnostics and final output; omit binary content and the workflow snapshot. |
27542756

27552757
</CommandTable>
27562758

@@ -5847,7 +5849,7 @@ sim tools files download <fileId> [options]
58475849

58485850
| Argument | Required | Description |
58495851
| --- | --- | --- |
5850-
| `fileId` | Yes | The returned file.id with context copilot, passed unchanged |
5852+
| `fileId` | Yes | The returned file.id whose file.context is "copilot", passed unchanged |
58515853

58525854
</CommandTable>
58535855

@@ -6120,7 +6122,7 @@ sim workflows operations apply <workflowId> [options]
61206122
| --- | --- | --- |
61216123
| `--dry-run` | No | Validate and lint without writing, auditing, or notifying collaborators. Returns the same validation, preparation warnings, lint findings, and ID-ownership conflicts (`409`) as a committed write. `needsRedeployment` describes the pre-write state. For semantic operations, `mintedBlockIds` is empty; `previewBlockIds` contains provisional IDs with a warning, since committing mints new IDs. |
61226124
| `--no-dry-run` | No | Send --dry-run as false. |
6123-
| `--operations <json\|@file>` | Yes | Edits to apply, in a single batch, keyed by operation_type: [&#123;"operation_type":"add","block_id":"my-fn","params":&#123;"type":"function","name":"My Fn","inputs":&#123;"code":"return &#123;ok:true&#125;"&#125;&#125;&#125;,&#123;"operation_type":"edit","block_id":"&lt;uuid&gt;","params":&#123;"name":"Renamed","connections":&#123;"success":"my-fn"&#125;&#125;&#125;,&#123;"operation_type":"delete","block_id":"&lt;uuid&gt;"&#125;]. Also extract_from_subflow, whose params carry &#123;"subflowId":"&lt;loop-id&gt;"&#125;, and insert_into_subflow, which creates a block and so takes an add’s params plus that subflowId (JSON, or @path / @- to read a file or stdin). |
6125+
| `--operations <json\|@file>` | No | Edits to apply, in a single batch, keyed by operation_type: [&#123;"operation_type":"add","block_id":"my-fn","params":&#123;"type":"function","name":"My Fn","inputs":&#123;"code":"return &#123;ok:true&#125;"&#125;&#125;&#125;,&#123;"operation_type":"edit","block_id":"&lt;uuid&gt;","params":&#123;"name":"Renamed","connections":&#123;"success":"my-fn"&#125;&#125;&#125;,&#123;"operation_type":"delete","block_id":"&lt;uuid&gt;"&#125;]. Also extract_from_subflow, whose params carry &#123;"subflowId":"&lt;loop-id&gt;"&#125;, and insert_into_subflow, which creates a block and so takes an add’s params plus that subflowId (JSON, or @path / @- to read a file or stdin). |
61246126
| `--atomic` | No | Fail the whole batch when any operation is declined or any block input would be dropped. The default applies what it can and reports the rest in `skipped` and `inputValidationErrors`; `true` writes nothing and answers `409` instead. |
61256127
| `--no-atomic` | No | Send --atomic as false. |
61266128
| `--layout <value>` | No | Whether to reposition blocks the batch touched. `targeted` (default) nudges only the affected subgraph; `none` leaves every position exactly as supplied. Accepted values: `targeted`, `none`. |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Download a direct tool output owned by the current user (OAuth login or personal
8888

8989
| Argument | Required | Description |
9090
| --- | --- | --- |
91-
| `fileId` | Yes | The returned file.id with context copilot, passed unchanged |
91+
| `fileId` | Yes | The returned file.id whose file.context is "copilot", passed unchanged |
9292

9393
</CommandTable>
9494

apps/docs/content/docs/cli/agent-workflows.mdx renamed to apps/docs/content/docs/cli/workflow-operations.mdx

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Agent workflow operations
2+
title: Workflow operations
33
description: Edit bindings safely, inspect compact run evidence, and track partial retries
44
---
55

@@ -18,10 +18,29 @@ sim --output json credentials get "$CREDENTIAL_ID"
1818
```
1919

2020
Use the returned tool ID and parameter schema; do not derive IDs from an English
21-
verb. For example, Slack sending uses `slack_message`. Supply the intended
22-
credential ID in the tool's documented credential parameter. A workflow can use
23-
a different credential from a direct tool call even when both are started by the
24-
same Sim user.
21+
verb. For example, Slack sending uses `slack_message`. For standalone OAuth
22+
execution, supply the intended top-level `credentialId`. Slack tools that declare
23+
`authMethod` and `botToken` also accept `input.authMethod: "bot_token"` with
24+
`input.botToken`, including an authorized `{{SECRET_NAME}}` reference. Explicit
25+
bot-token mode ignores `credentialId`; OAuth is the default and ignores an unused
26+
`botToken`. OAuth-only tools retain their credential requirement.
27+
28+
A workflow can use a different credential from a direct tool call even when both
29+
are started by the same Sim user. Changing credentials can change the Slack bot's
30+
identity and which messages it may update.
31+
32+
| Identifier | Where to read it | What it selects |
33+
| --- | --- | --- |
34+
| Tool ID | `tools list` and `tools get` | One executable operation and its standalone arguments |
35+
| Block type | `blocks list`, `blocks get`, and saved workflow state | A workflow block definition and its version |
36+
| Block operation | The returned block definition | An operation within that block; its ID may differ from the tool ID |
37+
| Block ID | Saved workflow state or a committed edit response | One particular block in that workflow |
38+
39+
For example, `serper_search` is a tool ID, while `serper` is its integration
40+
type. Keep the exact type stored in an existing workflow; a catalog lookup of an
41+
unversioned name can resolve to a newer definition. Use that version's returned
42+
fields and operation IDs when editing, and the tool's returned parameter schema
43+
when executing directly.
2544

2645
`credentials get` reports the credential type/provider, stored identity metadata,
2746
and recorded scopes with their source. `verifiedLive: false` means inspection
@@ -90,6 +109,12 @@ empty `mintedBlockIds`. Commit the edit and use that response's `mintedBlockIds`
90109
preview IDs are not reserved. Inspect the saved workflow to confirm its enabled
91110
blocks and connections before executing.
92111

112+
For enablement-only changes, send `setBlockEnabled` through the existing workflow
113+
operations endpoint; no dummy graph edit is needed. Use `atomic: true` when any
114+
declined edit or dropped input should prevent the batch from saving. Inspect
115+
`applied`, `skipped`, and `inputValidationErrors`, then read the saved state before
116+
deploying. Validation does not execute blocks or suppress external writes.
117+
93118
## Discover workflows across workspaces
94119

95120
Use `workspaces list`, then `workflows list --workspace <id>` for each relevant
@@ -125,12 +150,13 @@ sim --output json workflows runs get "$RUN_ID" --workflow "$WORKFLOW_ID" \
125150
--select-output "Verify delivery.result"
126151
```
127152

128-
`--summary` reports execution status, recorded failures (including handled
129-
errors), compact failing inputs/outputs, observed block statuses, and file
153+
`--summary` reports execution status, existing final output, recorded failures
154+
(including handled errors), compact failing inputs/outputs, observed block statuses, and file
130155
metadata. It caps trace traversal and field/text output and reports `truncated`
131-
when it omits detail. Binary fields and data URLs are omitted. This is a local
132-
projection of the authorized log response; it reduces terminal/context output,
133-
not the size of the server's log read. Use `logs get --trace` or explicit output
156+
when it omits detail. Binary fields and data URLs are omitted. The CLI asks the server to omit the saved workflow snapshot, then
157+
projects the remaining authorized log response locally. HTTP and MCP callers can
158+
set `includeWorkflowState=false`; ordinary CLI reads can use
159+
`--no-include-workflow-state`. Trace materialization is unchanged. Use `logs get --trace` or explicit output
134160
selectors when more detail is needed.
135161

136162
Selectors accept an unambiguous block name or ID followed by an optional output
@@ -140,26 +166,15 @@ Ambiguous names are rejected with candidate IDs. Missing output paths can be
140166
omitted; that does not establish that a block ran successfully.
141167

142168
A completed run can have sent a failure explanation rather than delivered a
143-
document. Have the workflow deliberately emit an `applicationOutcome` field in
144-
its final output, for example:
145-
146-
```json
147-
{
148-
"applicationOutcome": {
149-
"status": "verification_blocked",
150-
"threadId": "<provider-thread-id>",
151-
"fileIds": []
152-
}
153-
}
154-
```
169+
document. Inspect the workflow's existing `finalOutput` and recorded tool failures;
170+
`--summary` preserves the output's shape within its size limits. Execution status
171+
describes the run, not the quality of its result or an external delivery guarantee.
172+
Trace entries describe recorded work, and expired trace data may leave no
173+
block-level evidence.
155174

156-
Choose application statuses that describe the workflow's result, such as
157-
`delivered`, `clarification_requested`, or `verification_blocked`. The summary
158-
copies this field at the top level, or inside a Function block's `result` or a
159-
Response block's `data` wrapper; it does not infer it from a successful execution or a Slack
160-
message. A null outcome means the workflow did not report one. Trace entries
161-
describe observed work, and cannot prove unrecorded downstream effects or content
162-
quality. Expired trace data may leave no block-level evidence.
175+
The log's existing `cost` includes a reconciled total and itemized `fixed`, `model`,
176+
and `tool` charges when a ledger is available. Use `logs list --level error
177+
--include-handled-errors` to find recorded failures that a workflow recovered from.
163178

164179
## Track long manual runs
165180

@@ -177,6 +192,14 @@ blocks are candidates, not a promise of execution order: conditions, disabled
177192
blocks, loops, and runtime failures still affect the path. A later run uses the
178193
draft saved at that time; preview does not lock a snapshot.
179194

195+
An error connection is an alternative execution path. A consumer reached through
196+
an error bypass can run without output from the successful path's parser or
197+
transform. If that output is required, keep the consumer on the path that produces
198+
it, or explicitly handle its absence. A disabled block stops its branch; it is not
199+
a pass-through mock. Replaying from a later block can reuse recorded ancestor
200+
outputs from the selected source run, but cannot manufacture outputs that run
201+
never produced.
202+
180203
```sh
181204
sim workflows run "$WORKFLOW_ID" --from-block "$BLOCK_ID" \
182205
--source-run "$SOURCE_RUN_ID" --follow
@@ -221,9 +244,10 @@ does not disable blocks or edit the saved graph. It is unavailable with `--async
221244
If a condition skips the target, the remaining path can complete normally.
222245
If the run pauses, a later explicit resume does not inherit the stop-after limit.
223246

224-
Deployed execution uses the deployment snapshot. A workflow with only one
225-
runnable Schedule trigger can run directly. When multiple entry points are
226-
ambiguous, select the intended deployed trigger with the API's
247+
Deployed execution uses the deployment snapshot and retains the existing API
248+
trigger priority when an API-compatible entry is available. A workflow with only
249+
one runnable Schedule trigger can also run directly. When no API-compatible entry
250+
exists and multiple triggers remain, select the intended deployed trigger with the API's
227251
`run: { "source": "deployment", "entry": { "type": "trigger", "blockId": "<block-id>" } }`.
228252
Manual trigger execution remains a separate choice that uses the saved draft.
229253

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Apply Workflow Operations (OAuth login or personal API key required)
6464
| --- | --- | --- |
6565
| `--dry-run` | No | Validate and lint without writing, auditing, or notifying collaborators. Returns the same validation, preparation warnings, lint findings, and ID-ownership conflicts (`409`) as a committed write. `needsRedeployment` describes the pre-write state. For semantic operations, `mintedBlockIds` is empty; `previewBlockIds` contains provisional IDs with a warning, since committing mints new IDs. |
6666
| `--no-dry-run` | No | Send --dry-run as false. |
67-
| `--operations <json\|@file>` | Yes | Edits to apply, in a single batch, keyed by operation_type: [&#123;"operation_type":"add","block_id":"my-fn","params":&#123;"type":"function","name":"My Fn","inputs":&#123;"code":"return &#123;ok:true&#125;"&#125;&#125;&#125;,&#123;"operation_type":"edit","block_id":"&lt;uuid&gt;","params":&#123;"name":"Renamed","connections":&#123;"success":"my-fn"&#125;&#125;&#125;,&#123;"operation_type":"delete","block_id":"&lt;uuid&gt;"&#125;]. Also extract_from_subflow, whose params carry &#123;"subflowId":"&lt;loop-id&gt;"&#125;, and insert_into_subflow, which creates a block and so takes an add’s params plus that subflowId (JSON, or @path / @- to read a file or stdin). |
67+
| `--operations <json\|@file>` | No | Edits to apply, in a single batch, keyed by operation_type: [&#123;"operation_type":"add","block_id":"my-fn","params":&#123;"type":"function","name":"My Fn","inputs":&#123;"code":"return &#123;ok:true&#125;"&#125;&#125;&#125;,&#123;"operation_type":"edit","block_id":"&lt;uuid&gt;","params":&#123;"name":"Renamed","connections":&#123;"success":"my-fn"&#125;&#125;&#125;,&#123;"operation_type":"delete","block_id":"&lt;uuid&gt;"&#125;]. Also extract_from_subflow, whose params carry &#123;"subflowId":"&lt;loop-id&gt;"&#125;, and insert_into_subflow, which creates a block and so takes an add’s params plus that subflowId (JSON, or @path / @- to read a file or stdin). |
6868
| `--atomic` | No | Fail the whole batch when any operation is declined or any block input would be dropped. The default applies what it can and reports the rest in `skipped` and `inputValidationErrors`; `true` writes nothing and answers `409` instead. |
6969
| `--no-atomic` | No | Send --atomic as false. |
7070
| `--layout <value>` | No | Whether to reposition blocks the batch touched. `targeted` (default) nudges only the affected subgraph; `none` leaves every position exactly as supplied. Accepted values: `targeted`, `none`. |

‎apps/docs/content/docs/mcp/index.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ named MCP tool for every operation. Use `search_operations` and
145145
| Edit an existing workflow | [Workflow commands](/cli/workflows) | `getWorkflowState` and `replaceWorkflowState` | Invokes the deployed workflow; does not expose the workspace editing API |
146146
| Deploy a workflow | [Workflow commands](/cli/workflows) | `deployWorkflow` | Configure the deployment in Sim or through CLI/API/hosted MCP |
147147
| Invoke a workflow | [Workflow commands](/cli/workflows) | `executeWorkflow`; async execution is deployment-only, while manual runs are synchronous or streamed through CLI/API | The selected workflows appear as their own tools |
148-
| Preview a partial retry | [Agent workflow guide](/cli/agent-workflows) | `previewWorkflowRunFromBlock` reports candidate reruns and cached-output availability without executing | Not part of the deployed workflow tool interface |
148+
| Preview a partial retry | [Workflow operations guide](/cli/workflow-operations) | `previewWorkflowRunFromBlock` reports candidate reruns and cached-output availability without executing | Not part of the deployed workflow tool interface |
149149
| Inspect runs and outputs | [Workflow commands](/cli/workflows) | `listWorkflowRuns`, `getWorkflowRun`, and other discovered run operations | Returns the invoked workflow's result |
150150
| Search workspace knowledge | [Knowledge commands](/cli/knowledge) | `searchKnowledge` | Only if the workflow performs that search |
151151
| Search live organization sources | Use the dedicated [Search MCP](/search/mcp) connection | Separate endpoint with `search` and `read_document` tools | Only if the workflow performs that search |

‎apps/docs/content/docs/workflows/blocks/function.mdx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ JavaScript without imports runs in a fast local sandbox. JavaScript with `import
157157
| **HTTP requests** | `fetch()` built in | `requests` or `httpx` | `curl` or an installed CLI |
158158
| **Best for** | quick transforms and JSON | scripts, data science, charts, complex math | CLI workflows and system utilities |
159159

160+
The fast local JavaScript runtime provides standard ECMAScript values, `fetch`,
161+
`console`, and Sim helpers. It does not provide Node/browser globals such as
162+
`process`, `Buffer`, `require`, `crypto`, `TextDecoder`, `atob`, or `setTimeout`.
163+
Code that needs Node APIs or timers must use the remote JavaScript runtime with
164+
an import, for example `import { setTimeout as delay } from 'node:timers/promises'`.
165+
Use `{{SECRET_NAME}}` for selected secrets in either runtime.
166+
160167
<Callout type="info">
161168
Python and Shell require a remote sandbox. They are enabled by default on sim.ai;
162169
on a self-hosted instance, build and configure the provider's dedicated

‎apps/docs/openapi-v2-logs.json‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,16 @@
383383
"pattern": "^[A-Za-z0-9._:-]+$",
384384
"description": "Unique workflow run identifier."
385385
}
386+
},
387+
{
388+
"name": "includeWorkflowState",
389+
"in": "query",
390+
"required": false,
391+
"description": "Include the saved workflow snapshot. Set false to avoid loading and returning block configuration when inspecting a run. Other run fields are unchanged.",
392+
"schema": {
393+
"description": "Include the saved workflow snapshot. Set false to avoid loading and returning block configuration when inspecting a run. Other run fields are unchanged.",
394+
"type": "boolean"
395+
}
386396
}
387397
],
388398
"responses": {
@@ -1602,7 +1612,7 @@
16021612
"type": "null"
16031613
}
16041614
],
1605-
"description": "Workflow graph captured for the run, or null if unavailable. Sensitive values are redacted to null; environment-variable references may be preserved."
1615+
"description": "Credential-redacted workflow snapshot, or null when unavailable or includeWorkflowState=false."
16061616
},
16071617
"traceSpans": {
16081618
"type": "array",

0 commit comments

Comments
 (0)