sim 2.3.0-preview.328.1 → 2.3.0-preview.329.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/protocol/source-check.d.ts +10 -4
- package/dist/commands/protocol/source-status.d.ts +5 -6
- package/dist/commands/protocol/source-write.d.ts +5 -0
- package/dist/commands/protocol/workflow-dir.d.ts +5 -0
- package/dist/commands/protocol/workflow-run-get.d.ts +19 -0
- package/dist/commands/protocol/workspace-source-dir.d.ts +5 -0
- package/dist/generated/v2-api.d.ts +14 -12
- package/dist/index.js +580 -194
- package/dist/program.d.ts +1 -1
- package/dist/runtime.js +580 -194
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -35216,7 +35216,34 @@ Source handles:
|
|
|
35216
35216
|
parallel-start-source, parallel-end-source the same for a parallel
|
|
35217
35217
|
Renames:
|
|
35218
35218
|
An edit's {"name":"New name"} also rewrites every <old key.field> reference to the block, in
|
|
35219
|
-
other blocks' inputs and in a loop's or parallel's collection and condition
|
|
35219
|
+
other blocks' inputs and in a loop's or parallel's collection and condition.
|
|
35220
|
+
Inputs:
|
|
35221
|
+
inputs takes the field ids \`sim blocks get <type>\` lists (inputSchema, operationInputSchema),
|
|
35222
|
+
or the name a pair of them shares (inputDefinitions: tableId for tableSelector and
|
|
35223
|
+
manualTableId; a string goes to the typed field). Add the type it answers with: \`blocks get
|
|
35224
|
+
table\` answers table_v2, and an add of legacy table is refused.
|
|
35225
|
+
conditions (condition): [{"title":"if","value":"<start.n> > 3"},{"title":"else if","value":"…"},
|
|
35226
|
+
{"title":"else","value":""}]; the last entry is the else, and ids are assigned.
|
|
35227
|
+
inputFormat (Start): [{"name":"email","type":"string"}]; types string, number, boolean,
|
|
35228
|
+
object, array, file[]; an optional default "value" as text.
|
|
35229
|
+
Block settings, beside inputs in an add's or edit's params:
|
|
35230
|
+
"retry":{"enabled":true,"maxTries":3,"waitBetweenTriesMs":1000} retries a failed block; null
|
|
35231
|
+
clears it.
|
|
35232
|
+
Outputs:
|
|
35233
|
+
A block that fails outputs {"error":"<message>"}: connect its error handle and read
|
|
35234
|
+
<name.error> there (without one, the run fails). A Workflow block's result is the child's
|
|
35235
|
+
output; a child ending in a Response block gives {data, status, headers}, so read
|
|
35236
|
+
<call.result.data.x>.`;
|
|
35237
|
+
var BLOCK_DETAIL_GUIDE = `
|
|
35238
|
+
Reading it for \`sim workflows operations apply\`:
|
|
35239
|
+
id the type to add: \`blocks get table\` answers table_v2 (an add of legacy
|
|
35240
|
+
table is refused)
|
|
35241
|
+
inputSchema the field ids inputs takes; operationInputSchema, an operation's own
|
|
35242
|
+
inputDefinitions the block's inputs by name; one a pair of fields shares (tableId for
|
|
35243
|
+
tableSelector and manualTableId) is accepted in place of the pair
|
|
35244
|
+
outputs what it outputs on success; a failed block outputs {"error":"…"}
|
|
35245
|
+
instead, read on its error path as <name.error>
|
|
35246
|
+
Block settings such as retry are not fields: \`sim workflows operations apply --help\`.`;
|
|
35220
35247
|
var WORKFLOW_SET_BLOCK_ENABLED_HELP = 'Blocks to enable or disable, applied after --operations: [{"block_id":"<uuid>","enabled":false}]. Disabling a loop or parallel cascades to its unlocked descendants; enabling a block whose container is disabled is declined';
|
|
35221
35248
|
var WORKFLOW_VARIABLE_OPERATIONS_HELP = 'Variable changes to apply in order, keyed by operation: [{"operation":"add","name":"my_var","type":"string","value":"hello"},{"operation":"edit","name":"my_var","value":"updated"},{"operation":"delete","name":"my_var"}]';
|
|
35222
35249
|
var MCP_PARAMETER_DESCRIPTIONS_HELP = 'Per-field description overrides applied to the schema generated from the deployed workflow inputs, as [{"name":"email","description":"Customer email address"}]. A name matching no input field is ignored';
|
|
@@ -35663,6 +35690,7 @@ var CLI_CONTRACT = {
|
|
|
35663
35690
|
command: "workflows state replace",
|
|
35664
35691
|
confirm: "This replaces the entire draft graph and cannot be undone."
|
|
35665
35692
|
},
|
|
35693
|
+
getBlock: { helpText: BLOCK_DETAIL_GUIDE },
|
|
35666
35694
|
applyWorkflowOperations: {
|
|
35667
35695
|
command: "workflows operations apply",
|
|
35668
35696
|
describe: "Edit a workflow’s blocks, connections and settings with a batch of operations",
|
|
@@ -35883,6 +35911,9 @@ var CLI_CONTRACT = {
|
|
|
35883
35911
|
flags: { folderPath: FOLDER_PATH_FLAG }
|
|
35884
35912
|
},
|
|
35885
35913
|
createWorkflow: {
|
|
35914
|
+
helpText: `
|
|
35915
|
+
The new workflow's draft holds one Start block (start_trigger, named Start): connect the
|
|
35916
|
+
blocks you add from it.`,
|
|
35886
35917
|
flags: {
|
|
35887
35918
|
folderPath: {
|
|
35888
35919
|
...FOLDER_PATH_FLAG,
|
|
@@ -37005,6 +37036,10 @@ var CLI_CONTRACT = {
|
|
|
37005
37036
|
},
|
|
37006
37037
|
exportWorkflow: {
|
|
37007
37038
|
describe: "Print a workflow as a portable JSON document",
|
|
37039
|
+
helpText: `
|
|
37040
|
+
Workspace bindings (a table, a child workflow, a knowledge base) print as null unless
|
|
37041
|
+
--include-workspace-bindings, and credentials always do: to read what a block is set to, use
|
|
37042
|
+
\`sim workflows state get\`.`,
|
|
37008
37043
|
flags: {
|
|
37009
37044
|
includeReferences: {
|
|
37010
37045
|
boolean: true,
|
|
@@ -40751,15 +40786,19 @@ export default workflow('Cookbook', { description: 'One example of each common b
|
|
|
40751
40786
|
code: js\`return { id: \${start.orderId}, cents: Math.round(\${start.amount} * 100) }\`,
|
|
40752
40787
|
})
|
|
40753
40788
|
|
|
40754
|
-
// Tables: query rows (each row is { id, data: { column } }) and
|
|
40789
|
+
// Tables: query rows (each row is { id, data: { column } }) and write one.
|
|
40755
40790
|
const recent = table.queryRows('Recent Orders', {
|
|
40756
40791
|
tableId: table('orders'),
|
|
40757
40792
|
filterInput: { all: [{ field: 'status', op: 'eq', value: 'open' }] },
|
|
40758
40793
|
limit: 50,
|
|
40759
40794
|
})
|
|
40760
|
-
|
|
40795
|
+
// Upsert: updates the row whose conflictColumn (a unique column, by name) matches data, else
|
|
40796
|
+
// inserts one, so a second run for the same order updates it. table.insertRow takes the same
|
|
40797
|
+
// data without conflictColumn and adds a row every run.
|
|
40798
|
+
const save = table.upsertRow('Save Order', {
|
|
40761
40799
|
tableId: table('orders'),
|
|
40762
|
-
data: { orderId: start.orderId, status: 'open'
|
|
40800
|
+
data: { orderId: start.orderId, status: 'open' },
|
|
40801
|
+
conflictColumn: 'orderId',
|
|
40763
40802
|
})
|
|
40764
40803
|
|
|
40765
40804
|
// Knowledge base search: results is the list of matching chunks.
|
|
@@ -40814,8 +40853,12 @@ export default workflow('Cookbook', { description: 'One example of each common b
|
|
|
40814
40853
|
})
|
|
40815
40854
|
|
|
40816
40855
|
// Response: the API reply body. Wrap an untyped value (fn.result.x) in t\`\` when it is text.
|
|
40856
|
+
// body is the short form of the editor's JSON mode: { dataMode: 'json', data } as below.
|
|
40817
40857
|
const reply = response('Respond', { body: { risk: check.risk, id: t\`\${shape.result.id}\` } })
|
|
40818
|
-
const rejected = response('Respond Rejected', {
|
|
40858
|
+
const rejected = response('Respond Rejected', {
|
|
40859
|
+
dataMode: 'json',
|
|
40860
|
+
data: { status: 'rejected' },
|
|
40861
|
+
})
|
|
40819
40862
|
|
|
40820
40863
|
// Wiring: a.to(b) chains; a block can fan out to several targets.
|
|
40821
40864
|
start.to(check)
|
|
@@ -40926,7 +40969,7 @@ export default workflow(
|
|
|
40926
40969
|
)
|
|
40927
40970
|
` };
|
|
40928
40971
|
// ../workflow-sdk/src/codegen/core-text.generated.ts
|
|
40929
|
-
var CORE_DTS = "/**\n * The authoring surface for Sim workflows written as TypeScript.\n *\n * Nothing declared here runs. `@sim/workflow-code` compiles a workflow file statically, and every\n * runtime export of this package throws `SimSdkNotExecutable`. These declarations exist so an\n * editor, `tsc` (the type-check command `sim` prints) or an agent can check a workflow file before\n * the compiler sees it.\n *\n * Block builders (`slack.sendMessage`, `agent`, `trigger.gmail.poller`, ...) are not declared here:\n * they are generated from the block catalog into `blocks/{type}.d.ts`, which augment this module.\n * The generic `block(type, name, params)` covers any stored type without a builder.\n *\n * Every workflow file starts with the SDK header line, before any import:\n *\n * ```ts\n * // @sim-sdk 1\n * import { agent, trigger, workflow } from '@sim/workflow-sdk'\n * ```\n *\n * The number is the SDK major version the file is written against. A file without the header is\n * refused with `E_SDK_HEADER`, and one written for a newer major than the server supports with\n * `E_SDK_MAJOR`.\n */\n\n/** Plain JSON. */\nexport type Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\ndeclare const REF: unique symbol\ndeclare const TEMPLATE: unique symbol\ndeclare const ENV: unique symbol\ndeclare const RESOURCE: unique symbol\ndeclare const TOOL: unique symbol\ndeclare const NODE: unique symbol\ndeclare const CODE_FILE: unique symbol\ndeclare const RAW: unique symbol\ndeclare const UNTYPED: unique symbol\n\n/** Any reference, whatever it points at. */\nexport interface AnyRef {\n readonly [REF]: unknown\n}\n\n/** Marks a reference into untyped JSON, which any param accepts: its value is known only at run time. */\ninterface Untyped {\n readonly [UNTYPED]: true\n}\n\n/**\n * A reference into untyped JSON, where any path is allowed at any depth. An interface rather than\n * `Ref<Json>`, which TypeScript stops resolving after one step (`a.b.c` failed at `c`).\n */\ninterface UntypedRef extends Untyped {\n readonly [REF]: Json\n readonly [key: string]: UntypedRef\n}\n\ntype RefPaths<T> = [Json] extends [T]\n ? Untyped & { readonly [key: string]: UntypedRef }\n : T extends readonly (infer E)[]\n ? { readonly [index: number]: Ref<E>; readonly length: Ref<number> }\n : T extends object\n ? { readonly [K in keyof T]-?: Ref<T[K]> }\n : unknown\n\n/**\n * A typed reference to a block output, compiled to `<blockkey.path>`.\n * Paths map exactly: `.seg`, `['seg']` and `[n]`. Untyped JSON allows any path.\n */\nexport type Ref<T> = { readonly [REF]: T } & RefPaths<T>\n\n/** Text with references in it, written with one of the tags below. */\nexport type Template = string & { readonly [TEMPLATE]: true }\n\n/** A workspace environment variable, compiled to `{{NAME}}`. */\nexport interface EnvRef {\n readonly [ENV]: string\n}\n\n/**\n * What a reference must hold to fill a param of type `T`. A param taking some strings takes any\n * string (an option id computed at run time); `null` (an output a step left empty) fits anywhere.\n */\ntype RefValue<T> = [Extract<T, string>] extends [never] ? T | null : T | string | null\n\n/**\n * A reference that fits a param of type `T`: one whose value has that type, or one into untyped\n * JSON. A whole block is not a value: reference one of its outputs.\n */\nexport type RefTo<T> = ({ readonly [REF]: RefValue<T> } | (AnyRef & Untyped)) & {\n readonly [NODE]?: never\n}\n\n/** A param value: a literal, a reference of a fitting type, a template or an environment variable. */\nexport type Value<T> = T | RefTo<T> | Template | EnvRef\n\n/** JSON whose leaves may be references, templates or environment variables. */\nexport type JsonWithRefs =\n | null\n | boolean\n | number\n | string\n | AnyRef\n | Template\n | EnvRef\n | JsonWithRefs[]\n | { [key: string]: JsonWithRefs }\n\n/** A literal union that still accepts any other string (option ids read from values). */\nexport type LiteralUnion<T extends string> = T | (string & {})\n\n/** A `time-input` value, `HH:MM`. */\nexport type TimeString = `${number}:${number}`\n\n/** A reference written into text: any output or variable, but not a whole block. */\ntype InterpolatedRef = AnyRef & { readonly [NODE]?: never }\n\ntype Interpolation = InterpolatedRef | EnvRef | VarRef | string | number | boolean\n\n/** Text with interpolated references: `` t`New ${cls.category} ticket` ``. */\nexport declare function t(strings: TemplateStringsArray, ...values: Interpolation[]): Template\n/** JavaScript code (condition expressions, inline function code). */\nexport declare const js: typeof t\n/** Python code. */\nexport declare const py: typeof t\n/** Shell code. */\nexport declare const sh: typeof t\n/**\n * JSON text kept verbatim, for bodies an object literal cannot reproduce byte for byte. In a JSON\n * field an object literal is the usual form: a bare reference keeps its value's type (`n: score.value`\n * is a number), and a template is text.\n */\nexport declare const json: typeof t\n/** Markdown text (note content). */\nexport declare const md: typeof t\n\n/** A reference with a non-canonical spelling, such as `ref('Classify.content')`. */\nexport declare function ref(path: string): Ref<Json>\n\n/** A stored value outside the generated type (a legacy option id, say), kept verbatim. */\nexport declare function raw<T = never>(value: unknown): T & { readonly [RAW]: true }\n\n/** A required value that is still missing; compiles to absent, so canvas drafts type-check. */\nexport declare function todo(): never\n\n/**\n * Keeps the value the stored workflow holds for this param, without showing it: the printer writes\n * it for a secret pasted into a password field. Valid only on a param of a block the stored\n * workflow already has (same name and type) and holds a value for; anything else is\n * `E_STORED_VALUE_MISSING`.\n */\nexport declare function stored(): never\n\n/** Function code kept in a file next to the workflow (`.js`, `.py` or `.sh`), stored verbatim. */\nexport interface CodeFileRef {\n readonly [CODE_FILE]: string\n}\nexport declare function codeFile(path: `./${string}`): CodeFileRef\n\n/**\n * Environment variable names known to the workspace. `workspace.d.ts` adds one member per name;\n * until it exists `env` accepts any name.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceEnv {}\n\nexport declare const env: keyof WorkspaceEnv extends never\n ? { readonly [name: string]: EnvRef }\n : { readonly [K in keyof WorkspaceEnv]: EnvRef }\n\n/**\n * Workspace resources by stable key, filled in by the generated `workspace.d.ts`. Each map's\n * values describe the resource: a table's row type, a credential's provider, a workflow's inputs.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceTables {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceKnowledgeBases {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceCredentials {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceWorkflows {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceSkills {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceCustomTools {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceMcpServers {}\n\ntype KeyOf<M> = keyof M extends never ? string : Extract<keyof M, string>\n\nexport type TableKey = KeyOf<WorkspaceTables>\nexport type KnowledgeBaseKey = KeyOf<WorkspaceKnowledgeBases>\nexport type CredentialKey = KeyOf<WorkspaceCredentials>\nexport type WorkflowKey = KeyOf<WorkspaceWorkflows>\nexport type SkillKey = KeyOf<WorkspaceSkills>\nexport type CustomToolKey = KeyOf<WorkspaceCustomTools>\nexport type McpServerKey = KeyOf<WorkspaceMcpServers>\n/**\n * The tool names of MCP server `K`, as `workspace.d.ts` records them from the server's last\n * listing; any name for a server it could not list or does not know.\n */\nexport type McpToolName<K extends string> = K extends keyof WorkspaceMcpServers\n ? WorkspaceMcpServers[K] extends { tools: infer T extends string }\n ? T\n : string\n : string\n\n/** A workspace resource by stable key, compiled to the resource's internal id. */\nexport interface ResourceRef<Kind extends string, Key extends string = string> {\n readonly [RESOURCE]: Kind\n readonly key: Key\n}\n\n/** A saved credential: `credential('support-slack')`. */\nexport type CredentialRef<Key extends string = string> = ResourceRef<'credential', Key>\n\n/**\n * Keys of the saved credentials for one of `Providers`, as `workspace.d.ts` records each\n * credential's provider; any key until it exists.\n */\nexport type CredentialKeyFor<Providers extends string> = keyof WorkspaceCredentials extends never\n ? string\n : {\n [K in Extract<keyof WorkspaceCredentials, string>]: WorkspaceCredentials[K] extends {\n provider: Providers\n }\n ? K\n : never\n }[Extract<keyof WorkspaceCredentials, string>]\nexport declare function credential<K extends CredentialKey>(key: K): CredentialRef<K>\n\n/**\n * The other form a credential field takes beside `credential('key')`: a credential id produced at\n * run time by a reference, a template or an environment variable, stored in the field's advanced\n * twin (`manualCredential`). Literal text is not one, so a pasted token never type-checks; a\n * literal id the stored workflow already holds prints as `raw('…')`.\n */\nexport type CredentialIdValue = RefTo<string> | Template | EnvRef\n\n/** The columns of a workspace table, or loose JSON when `workspace.d.ts` does not know it. */\nexport type TableColumns<K extends string> = K extends keyof WorkspaceTables\n ? WorkspaceTables[K]\n : { [column: string]: Json }\n/**\n * One row as the table blocks output it: the row id, and its cells keyed by column name under\n * `data` (`row.data.status`). Times are ISO strings.\n */\nexport interface TableRow<K extends string> {\n id: string\n data: TableColumns<K>\n position: number\n createdAt: string\n updatedAt: string\n}\n/**\n * A value written to a field of type `T` (a table cell, a child workflow input): a JSON or JSON\n * array field takes JSON with references in it, and `null` leaves the field empty.\n */\ntype FieldValue<T> = [Json] extends [T]\n ? JsonWithRefs\n : [Json[]] extends [T]\n ? JsonWithRefs\n : Value<T> | null\n\n/** The columns of table `K` every row must hold: those whose cell type does not admit `null`. */\ntype RequiredColumns<K extends keyof WorkspaceTables> = {\n [C in keyof WorkspaceTables[K]]-?: null extends WorkspaceTables[K][C] ? never : C\n}[keyof WorkspaceTables[K]]\n\n/**\n * A whole row, as an insert, an upsert or a batch insert writes it, each value checked against\n * its column's type. A required column must be present and not `null`: the table refuses a row\n * without it (`Missing required field`), and an upsert checks the whole row before it looks for a\n * match.\n */\nexport type TableData<K extends string> = K extends keyof WorkspaceTables\n ? { [C in RequiredColumns<K>]-?: Exclude<FieldValue<WorkspaceTables[K][C]>, null> } & {\n [C in Exclude<keyof WorkspaceTables[K], RequiredColumns<K>>]?: FieldValue<\n WorkspaceTables[K][C]\n >\n }\n : { [column: string]: JsonWithRefs }\n\n/**\n * The cells an update writes, each checked against its column's type. Every column is optional:\n * an update merges these cells over the stored row.\n */\nexport type TableDataPatch<K extends string> = K extends keyof WorkspaceTables\n ? { [C in keyof WorkspaceTables[K]]?: FieldValue<WorkspaceTables[K][C]> }\n : { [column: string]: JsonWithRefs }\n\n/** A workspace table: `table('leads')`. Table block operations live on `table.*`. */\nexport type TableRef<Key extends string = string> = ResourceRef<'table', Key>\nexport declare function table<K extends TableKey>(key: K): TableRef<K>\n\n/** A knowledge base: `knowledgeBase('docs')`. */\nexport type KnowledgeBaseRef<Key extends string = string> = ResourceRef<'knowledge-base', Key>\nexport declare function knowledgeBase<K extends KnowledgeBaseKey>(key: K): KnowledgeBaseRef<K>\n\n/** A workspace skill: `skill('triage')`. */\nexport type SkillRef<Key extends string = string> = ResourceRef<'skill', Key>\nexport declare function skill<K extends SkillKey>(key: K): SkillRef<K>\n\n/** A workspace folder: `folder('reports')`. */\nexport type FolderRef = ResourceRef<'file-folder'>\nexport declare function folder(key: string): FolderRef\n\n/** A workspace file: `file('contracts/acme.pdf')`. File block operations live on `file.*`. */\nexport type FileRef = ResourceRef<'file'>\nexport declare function file(path: string): FileRef\n\n/**\n * A file a file-upload field holds, as the editor stores it: one uploaded in place, or a workspace\n * file chosen by `key` (written `file('path')` when the workspace resolves it).\n */\nexport interface UploadedFile {\n name: string\n path: string\n size?: number\n type?: string\n key?: string | FileRef\n id?: string\n folderPath?: string\n}\n\n/** A file produced at run time (`file` / `file[]` outputs). */\nexport interface SimFile {\n id: string\n name: string\n url: string\n size: number\n type: string\n key: string\n}\n\n// Agent tools\n\n/** One entry of an agent's `tools` list. */\nexport interface Tool {\n readonly [TOOL]: true\n}\n\n/** How the model may use a tool, and the stored tool fields a print carries. */\nexport interface ToolOpts {\n usageControl?: 'auto' | 'force' | 'none'\n usageControlExpression?: string\n title?: string\n /** The stored operation, when the method does not pin it. */\n operation?: string\n toolId?: string\n /** Pair modes of the tool's params, which pick the member the agent reads. */\n modes?: Record<string, 'basic' | 'advanced'>\n customTool?: JsonWithRefs\n operationPolicy?: Json\n /** Unknown stored tool keys, kept verbatim. */\n extra?: Json\n}\n\n/**\n * A workspace custom tool by key, as an agent tool: `customTool('lookup-order')`. A stored tool\n * whose definition was copied into the workflow (and may have drifted from the workspace tool)\n * prints as `raw(tool)` instead.\n */\nexport declare function customTool<K extends CustomToolKey>(key: K, options?: ToolUsage): Tool\n\n/** How the model may use a tool the SDK writes by name (`customTool`, `mcp().tool`, `asTool`). */\nexport type ToolUsage = Pick<ToolOpts, 'usageControl' | 'usageControlExpression'>\n\n/** An MCP tool's arguments and the editor's snapshot of its server. */\nexport interface McpToolOpts extends ToolUsage {\n /** Argument values the workflow fixes; the model fills in the rest. */\n args?: Record<string, JsonWithRefs>\n /**\n * What the editor saved about the server and the tool's input schema when the tool was picked.\n * Shown in the editor; never run.\n */\n snapshot?: { serverName?: string; serverUrl?: string; schema?: Json }\n}\n\n/** An MCP server by key: `mcp('linear')`. */\nexport interface McpServerRef<Key extends string = string> extends ResourceRef<'mcp-server', Key> {\n /** One of the server's tools, as an agent tool: `mcp('linear').tool('create_issue')`. */\n tool(name: McpToolName<Key>, options?: McpToolOpts): Tool\n}\nexport declare function mcp<K extends McpServerKey>(key: K): McpServerRef<K>\n\n// Graph\n\n/** Block-level fields (`BlockState`), written as the third builder argument. */\nexport interface BlockMeta {\n /**\n * A legacy key the display name cannot carry (a `name~n` collision key or a reserved name such\n * as `Loop`). Printed only for such a stored block; apply accepts it only for a key the stored\n * workflow already has, so it can never introduce one.\n */\n key?: string\n /** Stored as `enabled: false`. */\n disabled?: true\n /** Locked: apply refuses any change to this block. */\n locked?: true\n /** Exposes the error port without an `onError` edge. */\n errorPort?: boolean\n /** The block-level advanced toggle (`advancedMode`). */\n advancedMode?: boolean\n /**\n * Runs the block as its trigger (`triggerMode`). Trigger builders (`trigger.gmail.poller`) set\n * it themselves; write it on any other builder only for a block stored in trigger mode.\n */\n triggerMode?: boolean\n /** The stored retry policy, written whole. */\n retry?: BlockRetryConfig\n /**\n * Per branch key of a condition or router, the row's display `title` and any stored fields the\n * SDK has no syntax for (`extra`, plain JSON). `title: null` keeps a row stored with no title,\n * which the executor never takes for `else`.\n */\n branches?: Record<string, { title?: string | null; extra?: Record<string, Json> }>\n /**\n * Stored params that run but have no SDK syntax: a schema-agnostic custom block's inputs, the\n * agent's legacy prompt fields, a container's stored params. Values the block keeps but never\n * runs are not written; apply keeps them from the stored workflow.\n */\n extra?: Record<string, unknown>\n /**\n * A loop or parallel's `block.data` subflow keys the loader could not read as config, kept\n * verbatim (plain JSON).\n */\n subflowData?: Record<string, Json>\n}\n\n/** A block's retry policy, field for field the stored `BlockRetryConfig`. */\nexport interface BlockRetryConfig {\n /** Absent config and `false` mean the same thing: the block runs once. */\n enabled: boolean\n /** Total tries including the first. */\n maxTries: number\n /** Delay between tries. */\n waitBetweenTriesMs: number\n}\n\n/** Anything an edge can point at. */\nexport type Target = Node | Group\n\n/** A block or container in the graph. */\nexport interface Node {\n readonly [NODE]: true\n /** Wires this node's default port to each target. Returns the target, or a group of them. */\n to<const T extends Target[]>(...targets: T): T extends [infer One] ? One : Group\n /** Wires this node's error port to each target. */\n onError(...targets: Target[]): void\n}\n\n/** Several nodes; `.to()` wires every member (fan-in). */\nexport interface Group {\n to(...targets: Target[]): Group\n}\n\n/**\n * The failure message a block outputs when an error edge leaves it (`x.onError(y)` runs `y` with\n * `x.error`); a check refuses `x.error` on a block without one, which fails the run instead.\n */\ntype ErrorOutput<O> = [O] extends [{ error: unknown }] ? unknown : { readonly error: Ref<string> }\n\n/** A block: a node whose outputs can be referenced, and `error` after an `onError` edge. */\nexport type Block<O> = Node & Ref<O> & ErrorOutput<O>\n\n/** The named ports of a condition or router. */\nexport type Branches<K extends string> = { readonly [P in K]: Node }\n\n/** Trigger builders (`trigger.start`, `trigger.gmail.poller`, ...), generated from the catalog. */\nexport declare namespace trigger {}\n\n/** Builders for hidden legacy block versions (`legacy.slack.send`), generated from the catalog. */\nexport declare namespace legacy {}\n\n/** A raw edge from a handle the SDK has no name for (a legacy or unknown port). */\nexport declare function edge(from: Node, handle: string, to: Target): void\n\n/** Any stored block type without a builder (legacy, unknown or custom), with untyped outputs. */\nexport declare function block(\n type: string,\n name: string,\n params: Record<string, unknown>,\n meta?: BlockMeta\n): Block<Json>\n\n// Workflow and variables\n\nexport type VariableType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'plain'\n\n/** A workflow variable declared in `workflow(name, { variables })`: its type and initial value. */\nexport interface VariableDeclaration {\n /**\n * The display name, written only when it differs from the key. It must normalize to the key\n * (lowercased, spaces and dots removed), as `'Total Count'` does to `totalcount`.\n */\n name?: string\n type: VariableType\n value: Json\n}\n\n/** The variables a workflow declares, by name. */\nexport type VariableDeclarations = Record<string, VariableDeclaration>\n\ndeclare const VAR: unique symbol\n\n/** A workflow variable, compiled to `<variable.name>`. */\nexport interface VarRef {\n readonly [VAR]: string\n}\n\ntype VariableValue<T extends VariableType> = T extends 'number'\n ? number\n : T extends 'boolean'\n ? boolean\n : T extends 'string' | 'plain'\n ? string\n : Json\n\n/** `vars` in the workflow body: one typed reference per declared variable. */\nexport type VarRefs<V extends VariableDeclarations> = {\n readonly [K in keyof V]: VarRef & Ref<VariableValue<V[K]['type']>>\n}\n\n/**\n * Workflow variables by name, untyped. Prefer the `vars` the `workflow()` body receives, which is\n * typed from the declared variables.\n */\nexport declare const vars: { readonly [name: string]: VarRef & Ref<Json> }\n\ndeclare const WORKFLOW_DEF: unique symbol\n\n/** The default export of a workflow file. */\nexport interface WorkflowDef {\n readonly [WORKFLOW_DEF]: true\n}\n\n/** A child workflow by key, for `runWorkflow` or as an agent tool. */\nexport interface WorkflowRef<Key extends string = string> extends ResourceRef<'workflow', Key> {\n /**\n * The workflow as an agent tool, as the editor's tool picker adds it:\n * `childWorkflow('enrich-lead').asTool()`. A tool with fixed inputs is written `raw(tool)`.\n */\n asTool(options?: ToolUsage): Tool\n}\n\n/**\n * Declares a workflow. The body wires blocks; it never runs. With no description or variables the\n * options may be left out: `workflow('Name', () => { ... })`.\n */\nexport declare function workflow<const V extends VariableDeclarations = Record<never, never>>(\n name: string,\n options: { description?: string; variables?: V },\n body: (scope: { vars: VarRefs<V> }) => void\n): WorkflowDef\nexport declare function workflow(\n name: string,\n body: (scope: { vars: VarRefs<Record<never, never>> }) => void\n): WorkflowDef\n/** A child workflow by key: `childWorkflow('enrich-lead')`. */\nexport declare function childWorkflow<K extends WorkflowKey>(key: K): WorkflowRef<K>\n\n// Containers\n\ntype ItemOf<C> = C extends { readonly [REF]: readonly (infer E)[] }\n ? E\n : C extends readonly (infer E)[]\n ? E\n : Json\n\n/** Inside a loop or parallel body. As a node it is the container's start port: `p.to(first)`. */\nexport interface SubflowScope<Item> extends Node {\n readonly index: Ref<number>\n readonly currentItem: Ref<Item>\n readonly items: Ref<Item[]>\n}\n\n/**\n * A container's outputs, plus its iteration fields by name (`outer.index`), which a block inside\n * the container reads (in a nested container too: an outer loop's index or item). Outside the\n * container only `results` resolves: check reports `W_REF_OUT_OF_SCOPE` on `outer.index` there.\n */\nexport interface SubflowOutput {\n results: Json[]\n index: number\n currentItem: Json\n items: Json[]\n}\n\n/** A loop or parallel container. Its `.to()` wires the port taken after it finishes. */\nexport type Container = Block<SubflowOutput>\n\ntype Collection = AnyRef | Template | Json[] | string\n\nexport declare const loop: {\n for(\n name: string,\n params: { count?: number },\n body: (scope: SubflowScope<never>) => void,\n meta?: BlockMeta\n ): Container\n forEach<const C extends Collection>(\n name: string,\n params: { collection: C },\n body: (scope: SubflowScope<ItemOf<C>>) => void,\n meta?: BlockMeta\n ): Container\n while(\n name: string,\n params: { condition: Template | string },\n body: (scope: SubflowScope<never>) => void,\n meta?: BlockMeta\n ): Container\n doWhile(\n name: string,\n params: { condition?: Template | string; count?: number },\n body: (scope: SubflowScope<never>) => void,\n meta?: BlockMeta\n ): Container\n}\n\nexport declare const parallel: {\n /** A parallel with no stored type, which the loader runs as `count`. */\n (\n name: string,\n params: { count?: number; collection?: Collection; batchSize?: number },\n body: (scope: SubflowScope<Json>) => void,\n meta?: BlockMeta\n ): Container\n count(\n name: string,\n params: { count: number; batchSize?: number },\n body: (scope: SubflowScope<never>) => void,\n meta?: BlockMeta\n ): Container\n collection<const C extends Collection>(\n name: string,\n params: { collection: C; batchSize?: number },\n body: (scope: SubflowScope<ItemOf<C>>) => void,\n meta?: BlockMeta\n ): Container\n}\n\n// Blocks with a source form of their own\n\n/**\n * Params and outputs of the blocks below, generated from the catalog. Each entry is\n * `{ params; output }`; without generated types the params are loose.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface SpecialBuilderTypes {}\n\ntype SpecialParams<K extends string> = K extends keyof SpecialBuilderTypes\n ? SpecialBuilderTypes[K] extends { params: infer P }\n ? P\n : never\n : Record<string, unknown>\n\ntype SpecialOutput<K extends string> = K extends keyof SpecialBuilderTypes\n ? SpecialBuilderTypes[K] extends { output: infer O }\n ? O\n : never\n : Json\n\n/** A condition expression, or `true` for the `else` branch. */\nexport type BranchExpression = Template | string | true\n\ndeclare const ONLY_ELSE: unique symbol\n\n/** What a branch other than `else` written as `true` must be, which no value is: the error names it. */\ninterface OnlyElseMayBeTrue {\n readonly [ONLY_ELSE]: true\n}\n\n/**\n * A condition's branches: every key holds an expression, and only `else` may be `true`. Another\n * branch written as `true` is checked against {@link OnlyElseMayBeTrue}, so the error names that\n * branch alone.\n */\ntype ConditionBranches<B> = {\n [K in keyof B]: K extends 'else'\n ? BranchExpression\n : B[K] extends true\n ? OnlyElseMayBeTrue\n : Template | string\n}\n\n/**\n * Keys of a condition written with no rows (`condition('Name', {})`, the source form of rows\n * that were never persisted): the implicit `if` and `else` ports stay addressable.\n */\ntype ConditionKeys<B> = keyof B extends never ? 'if' | 'else' : Extract<keyof B, string>\ntype RouterKeys<R> = keyof R extends never ? 'route0' : Extract<keyof R, string>\n\n/** A condition: named branches, the last one `else` when there are two or more. */\nexport declare function condition<const B extends Record<string, BranchExpression>>(\n name: string,\n branches: B & ConditionBranches<B>,\n meta?: BlockMeta\n): Block<SpecialOutput<'condition'>> & Branches<ConditionKeys<B>>\n\n/** A router: named routes described for the model. */\nexport declare function router<const R extends Record<string, string | Template>>(\n name: string,\n params: SpecialParams<'router'> & { routes: R },\n meta?: BlockMeta\n): Block<SpecialOutput<'router'>> & Branches<RouterKeys<R>>\n\n/** A function block. `code` is inline (`` js`...` ``) or a code file (`codeFile('./functions/x.js')`). */\nexport declare function fn(\n name: string,\n params: SpecialParams<'fn'> & { code: Template | CodeFileRef | string },\n meta?: BlockMeta\n): Block<SpecialOutput<'fn'>>\n\n/**\n * The inputs of a child workflow by key, each checked against the input its start block\n * declares when `workspace.d.ts` knows the workflow; loose JSON otherwise.\n */\nexport type WorkflowInputMapping<K extends string> = K extends keyof WorkspaceWorkflows\n ? WorkspaceWorkflows[K] extends { inputs: infer I }\n ? { [N in keyof I]?: FieldValue<I[N]> }\n : InputMapping\n : InputMapping\n\n/**\n * Runs a child workflow. A `childWorkflow('key')` checks `inputMapping` against its inputs. Its\n * `result` is the child's output: its first response block's `{ data, status, headers }` (a body\n * field is `result.data.field`), else the output of the last block it ran.\n */\nexport declare function runWorkflow<K extends string = string>(\n name: string,\n params: Omit<SpecialParams<'runWorkflow'>, 'workflowId' | 'inputMapping'> & {\n workflowId: WorkflowRef<K> | Exclude<SpecialParams<'runWorkflow'>['workflowId'], WorkflowRef>\n inputMapping?: WorkflowInputMapping<K>\n },\n meta?: BlockMeta\n): Block<SpecialOutput<'runWorkflow'>>\n\n/**\n * Pauses for a person; the form in `inputFormat` types `submission`. A resumed block also holds\n * each form field at its top level (the runtime copies the submission up, over any output of the\n * same name), so `approval.approved` and `approval.submission.approved` both read it.\n */\nexport declare function human<const F extends InputFields = Record<never, never>>(\n name: string,\n params: SpecialParams<'human'> & { inputFormat?: F },\n meta?: BlockMeta\n): Block<\n Omit<SpecialOutput<'human'>, 'submission' | keyof F> & {\n submission: InputFieldsOutput<F>\n } & InputFieldsOutput<F>\n>\n\n/**\n * A response's body, status and headers: the editor's JSON mode. An object or array `body` is\n * JSON whose references keep their types; a template or reference is the body text as written.\n */\nexport interface ResponseBody {\n body: JsonWithRefs\n /** HTTP status; 200 when omitted. A template or reference must produce a number. */\n status?: number | RefTo<number> | Template | EnvRef\n /** Response headers by name. */\n headers?: Record<string, Value<string>>\n}\n\n/**\n * Ends the workflow with an API response: `response('Reply', { body: { ok: true }, status: 201 })`,\n * or the block's own params (`dataMode`, `builderData`, ...) when the body is built field by field.\n */\nexport declare function response(\n name: string,\n params: ResponseBody,\n meta?: BlockMeta\n): Block<SpecialOutput<'response'>>\nexport declare function response(\n name: string,\n params: SpecialParams<'response'>,\n meta?: BlockMeta\n): Block<SpecialOutput<'response'>>\n\n/** Assigns workflow variables. */\nexport declare function setVariables(\n name: string,\n params: SpecialParams<'setVariables'>,\n meta?: BlockMeta\n): Block<SpecialOutput<'setVariables'>>\n\ndeclare const ANNOTATION: unique symbol\n\n/** A canvas note: no edges, no outputs. */\nexport interface Annotation {\n readonly [ANNOTATION]: true\n}\nexport declare function note(\n name: string,\n params: SpecialParams<'note'>,\n meta?: BlockMeta\n): Annotation\n\n// Structured param shapes\n\n/** Type names an input-format field may declare. */\nexport type InputFieldType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'file[]'\n\n/** A structured input field: its type plus a default value, description or required flag. */\nexport interface InputFieldSpec {\n type: InputFieldType\n value?: JsonWithRefs\n description?: string\n required?: boolean\n}\n\n/** `input-format` fields by name: `{ subject: 'string', amount: { type: 'number', value: 0 } }`. */\nexport type InputFields = Record<string, InputFieldType | InputFieldSpec>\n\ntype InputFieldValue<T> = T extends 'string'\n ? string\n : T extends 'number'\n ? number\n : T extends 'boolean'\n ? boolean\n : T extends 'array'\n ? Json[]\n : T extends 'file[]'\n ? SimFile[]\n : Json\n\n/** The outputs an `input-format` declares. */\nexport type InputFieldsOutput<F> = {\n [K in keyof F]: F[K] extends { type: infer T } ? InputFieldValue<T> : InputFieldValue<F[K]>\n}\n\n/**\n * One `response-format` field as the editor's builder stores it. An `object` or `array` field's\n * `value` may hold nested fields. A response is usually written with `body` instead.\n */\nexport interface ResponseField {\n id?: string\n name: string\n type: string\n value?: JsonWithRefs\n collapsed?: boolean\n}\n\n/** `response-format` fields: `[{ name: 'ok', type: 'boolean', value: true }]`. */\nexport type ResponseFields = ResponseField[]\n\n/** An agent message. */\nexport interface Message {\n role: 'system' | 'user' | 'assistant'\n content: Value<string>\n}\n\n/** One `variables-input` assignment, with any other stored keys kept. */\nexport interface VariableAssignment {\n variableId: VarRef\n value?: JsonWithRefs\n [key: string]: JsonWithRefs | VarRef | undefined\n}\n\n/** Child workflow inputs by name (`input-mapping`, `workflow-input-mapper`). */\nexport type InputMapping = Record<string, JsonWithRefs>\n\n/** An operator a table filter condition or builder rule can use. */\nexport type FilterOperator = LiteralUnion<\n | 'eq'\n | 'ne'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'in'\n | 'nin'\n | 'like'\n | 'ilike'\n | 'nlike'\n | 'nilike'\n | 'contains'\n | 'ncontains'\n | 'startsWith'\n | 'endsWith'\n | 'isNull'\n | 'isNotNull'\n | 'isEmpty'\n | 'isNotEmpty'\n>\n\n/** One row of the editor's filter builder, as it stores it. */\nexport interface FilterRule {\n id?: string\n /** How this row joins the rows before it; `and` when omitted. */\n logicalOperator?: 'and' | 'or'\n column: string\n operator: FilterOperator\n value: Value<string | number | boolean>\n collapsed?: boolean\n}\n\n/** A filter-builder value: the editor's rows, `[{ column: 'status', operator: 'eq', value: 'new' }]`. */\nexport type Filter = FilterRule[]\n\n/** One table filter condition: `{ field: 'status', op: 'eq', value: 'new' }`. */\nexport interface TableCondition {\n field: string\n op: FilterOperator\n value?: JsonWithRefs\n}\n\n/**\n * A table predicate: a condition, or an `all` (and) / `any` (or) group of predicates. The\n * `{ status: { $eq: 'new' } }` operator-object grammar is not one: the runtime refuses it.\n */\nexport type TablePredicate = TableCondition | { all: TablePredicate[] } | { any: TablePredicate[] }\n\n/** A table sort by column: `{ createdAt: 'desc' }`. */\nexport type Sort =\n | Record<string, 'asc' | 'desc'>\n | Array<{ column: string; direction: 'asc' | 'desc' }>\n\n/** One knowledge tag filter. */\nexport interface TagFilter {\n tagName: string\n tagValue: Value<string>\n [key: string]: JsonWithRefs\n}\n\n/** One document tag. */\nexport interface DocumentTag {\n tagName: string\n value: Value<string>\n [key: string]: JsonWithRefs\n}\n\n/** One `eval-input` metric. */\nexport interface EvalMetric {\n name: string\n description?: string\n range?: { min: number; max: number }\n [key: string]: JsonWithRefs | undefined\n}\n\n/** One `model-fallback-list` entry. */\nexport interface ModelFallback {\n model: LiteralUnion<Model>\n [key: string]: JsonWithRefs\n}\n\n/**\n * Model ids, generated into `models.d.ts` (which adds one member per model). Kept apart from the\n * block files so a model-list change touches one file.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface ModelIds {}\nexport type Model = Extract<keyof ModelIds, string>\n\n/** A JSON Schema `responseFormat`, or `{ name, strict, schema }` around one. */\nexport type ResponseFormat = JsonWithRefs\n\ntype Depth = [never, 0, 1, 2, 3, 4]\n\ntype FromSchema<S, D extends number> = [D] extends [never]\n ? Json\n : S extends { enum: readonly (infer E)[] }\n ? E\n : S extends { type: 'object'; properties: infer P }\n ? { [K in keyof P]: FromSchema<P[K], Depth[D]> }\n : S extends { type: 'array'; items: infer I }\n ? FromSchema<I, Depth[D]>[]\n : S extends { type: 'string' }\n ? string\n : S extends { type: 'number' | 'integer' }\n ? number\n : S extends { type: 'boolean' }\n ? boolean\n : Json\n\n/**\n * The outputs a literal `responseFormat` adds, read from its JSON Schema with recursion capped at\n * depth 4. A template or reference adds untyped JSON.\n */\nexport type ResponseFormatOutput<RF> = [RF] extends [undefined]\n ? unknown\n : RF extends { schema: infer S }\n ? FromSchema<S, 4>\n : RF extends { type: 'object'; properties: object }\n ? FromSchema<RF, 4>\n : { [key: string]: Json }\n";
|
|
40972
|
+
var CORE_DTS = "/**\n * The authoring surface for Sim workflows written as TypeScript.\n *\n * Nothing declared here runs. `@sim/workflow-code` compiles a workflow file statically, and every\n * runtime export of this package throws `SimSdkNotExecutable`. These declarations exist so an\n * editor, `tsc` (the type-check command `sim` prints) or an agent can check a workflow file before\n * the compiler sees it.\n *\n * Block builders (`slack.sendMessage`, `agent`, `trigger.gmail.poller`, ...) are not declared here:\n * they are generated from the block catalog into `blocks/{type}.d.ts`, which augment this module.\n * The generic `block(type, name, params)` covers any stored type without a builder.\n *\n * Every workflow file starts with the SDK header line, before any import:\n *\n * ```ts\n * // @sim-sdk 1\n * import { agent, trigger, workflow } from '@sim/workflow-sdk'\n * ```\n *\n * The number is the SDK major version the file is written against. A file without the header is\n * refused with `E_SDK_HEADER`, and one written for a newer major than the server supports with\n * `E_SDK_MAJOR`.\n */\n\n/** Plain JSON. */\nexport type Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\ndeclare const REF: unique symbol\ndeclare const TEMPLATE: unique symbol\ndeclare const ENV: unique symbol\ndeclare const RESOURCE: unique symbol\ndeclare const TOOL: unique symbol\ndeclare const NODE: unique symbol\ndeclare const CODE_FILE: unique symbol\ndeclare const RAW: unique symbol\ndeclare const UNTYPED: unique symbol\n\n/** Any reference, whatever it points at. */\nexport interface AnyRef {\n readonly [REF]: unknown\n}\n\n/** Marks a reference into untyped JSON, which any param accepts: its value is known only at run time. */\ninterface Untyped {\n readonly [UNTYPED]: true\n}\n\n/**\n * A reference into untyped JSON, where any path is allowed at any depth. An interface rather than\n * `Ref<Json>`, which TypeScript stops resolving after one step (`a.b.c` failed at `c`).\n */\ninterface UntypedRef extends Untyped {\n readonly [REF]: Json\n readonly [key: string]: UntypedRef\n}\n\ntype RefPaths<T> = [Json] extends [T]\n ? Untyped & { readonly [key: string]: UntypedRef }\n : T extends readonly (infer E)[]\n ? { readonly [index: number]: Ref<E>; readonly length: Ref<number> }\n : T extends object\n ? { readonly [K in keyof T]-?: Ref<T[K]> }\n : unknown\n\n/**\n * A typed reference to a block output, compiled to `<blockkey.path>`.\n * Paths map exactly: `.seg`, `['seg']` and `[n]`. Untyped JSON allows any path.\n */\nexport type Ref<T> = { readonly [REF]: T } & RefPaths<T>\n\n/** Text with references in it, written with one of the tags below. */\nexport type Template = string & { readonly [TEMPLATE]: true }\n\n/** A workspace environment variable, compiled to `{{NAME}}`. */\nexport interface EnvRef {\n readonly [ENV]: string\n}\n\n/**\n * What a reference must hold to fill a param of type `T`. A param taking some strings takes any\n * string (an option id computed at run time); `null` (an output a step left empty) fits anywhere.\n */\ntype RefValue<T> = [Extract<T, string>] extends [never] ? T | null : T | string | null\n\n/**\n * A reference that fits a param of type `T`: one whose value has that type, or one into untyped\n * JSON. A whole block is not a value: reference one of its outputs.\n */\nexport type RefTo<T> = ({ readonly [REF]: RefValue<T> } | (AnyRef & Untyped)) & {\n readonly [NODE]?: never\n}\n\n/** A param value: a literal, a reference of a fitting type, a template or an environment variable. */\nexport type Value<T> = T | RefTo<T> | Template | EnvRef\n\n/** JSON whose leaves may be references, templates or environment variables. */\nexport type JsonWithRefs =\n | null\n | boolean\n | number\n | string\n | AnyRef\n | Template\n | EnvRef\n | JsonWithRefs[]\n | { [key: string]: JsonWithRefs }\n\n/** A literal union that still accepts any other string (option ids read from values). */\nexport type LiteralUnion<T extends string> = T | (string & {})\n\n/** A `time-input` value, `HH:MM`. */\nexport type TimeString = `${number}:${number}`\n\n/** A reference written into text: any output or variable, but not a whole block. */\ntype InterpolatedRef = AnyRef & { readonly [NODE]?: never }\n\ntype Interpolation = InterpolatedRef | EnvRef | VarRef | string | number | boolean\n\n/** Text with interpolated references: `` t`New ${cls.category} ticket` ``. */\nexport declare function t(strings: TemplateStringsArray, ...values: Interpolation[]): Template\n/** JavaScript code (condition expressions, inline function code). */\nexport declare const js: typeof t\n/** Python code. */\nexport declare const py: typeof t\n/** Shell code. */\nexport declare const sh: typeof t\n/**\n * JSON text kept verbatim, for bodies an object literal cannot reproduce byte for byte. In a JSON\n * field an object literal is the usual form: a bare reference keeps its value's type (`n: score.value`\n * is a number), and a template is text.\n */\nexport declare const json: typeof t\n/** Markdown text (note content). */\nexport declare const md: typeof t\n\n/** A reference with a non-canonical spelling, such as `ref('Classify.content')`. */\nexport declare function ref(path: string): Ref<Json>\n\n/** A stored value outside the generated type (a legacy option id, say), kept verbatim. */\nexport declare function raw<T = never>(value: unknown): T & { readonly [RAW]: true }\n\n/** A required value that is still missing; compiles to absent, so canvas drafts type-check. */\nexport declare function todo(): never\n\n/**\n * Keeps the value the stored workflow holds for this param, without showing it: the printer writes\n * it for a secret pasted into a password field. Valid only on a param of a block the stored\n * workflow already has (same name and type) and holds a value for; anything else is\n * `E_STORED_VALUE_MISSING`.\n */\nexport declare function stored(): never\n\n/** Function code kept in a file next to the workflow (`.js`, `.py` or `.sh`), stored verbatim. */\nexport interface CodeFileRef {\n readonly [CODE_FILE]: string\n}\nexport declare function codeFile(path: `./${string}`): CodeFileRef\n\n/**\n * Environment variable names known to the workspace. `workspace.d.ts` adds one member per name;\n * until it exists `env` accepts any name.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceEnv {}\n\nexport declare const env: keyof WorkspaceEnv extends never\n ? { readonly [name: string]: EnvRef }\n : { readonly [K in keyof WorkspaceEnv]: EnvRef }\n\n/**\n * Workspace resources by stable key, filled in by the generated `workspace.d.ts`. Each map's\n * values describe the resource: a table's row type, a credential's provider, a workflow's inputs.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceTables {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceKnowledgeBases {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceCredentials {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceWorkflows {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceSkills {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceCustomTools {}\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface WorkspaceMcpServers {}\n\ntype KeyOf<M> = keyof M extends never ? string : Extract<keyof M, string>\n\nexport type TableKey = KeyOf<WorkspaceTables>\nexport type KnowledgeBaseKey = KeyOf<WorkspaceKnowledgeBases>\nexport type CredentialKey = KeyOf<WorkspaceCredentials>\nexport type WorkflowKey = KeyOf<WorkspaceWorkflows>\nexport type SkillKey = KeyOf<WorkspaceSkills>\nexport type CustomToolKey = KeyOf<WorkspaceCustomTools>\nexport type McpServerKey = KeyOf<WorkspaceMcpServers>\n/**\n * The tool names of MCP server `K`, as `workspace.d.ts` records them from the server's last\n * listing; any name for a server it could not list or does not know.\n */\nexport type McpToolName<K extends string> = K extends keyof WorkspaceMcpServers\n ? WorkspaceMcpServers[K] extends { tools: infer T extends string }\n ? T\n : string\n : string\n\n/** A workspace resource by stable key, compiled to the resource's internal id. */\nexport interface ResourceRef<Kind extends string, Key extends string = string> {\n readonly [RESOURCE]: Kind\n readonly key: Key\n}\n\n/** A saved credential: `credential('support-slack')`. */\nexport type CredentialRef<Key extends string = string> = ResourceRef<'credential', Key>\n\n/**\n * Keys of the saved credentials for one of `Providers`, as `workspace.d.ts` records each\n * credential's provider; any key until it exists.\n */\nexport type CredentialKeyFor<Providers extends string> = keyof WorkspaceCredentials extends never\n ? string\n : {\n [K in Extract<keyof WorkspaceCredentials, string>]: WorkspaceCredentials[K] extends {\n provider: Providers\n }\n ? K\n : never\n }[Extract<keyof WorkspaceCredentials, string>]\nexport declare function credential<K extends CredentialKey>(key: K): CredentialRef<K>\n\n/**\n * The other form a credential field takes beside `credential('key')`: a credential id produced at\n * run time by a reference, a template or an environment variable, stored in the field's advanced\n * twin (`manualCredential`). Literal text is not one, so a pasted token never type-checks; a\n * literal id the stored workflow already holds prints as `raw('…')`.\n */\nexport type CredentialIdValue = RefTo<string> | Template | EnvRef\n\n/** The columns of a workspace table, or loose JSON when `workspace.d.ts` does not know it. */\nexport type TableColumns<K extends string> = K extends keyof WorkspaceTables\n ? WorkspaceTables[K]\n : { [column: string]: Json }\n/**\n * One row as the table blocks output it: the row id, and its cells keyed by column name under\n * `data` (`row.data.status`). Times are ISO strings.\n */\nexport interface TableRow<K extends string> {\n id: string\n data: TableColumns<K>\n position: number\n createdAt: string\n updatedAt: string\n}\n/**\n * A value written to a field of type `T` (a table cell, a child workflow input): a JSON or JSON\n * array field takes JSON with references in it, and `null` leaves the field empty.\n */\ntype FieldValue<T> = [Json] extends [T]\n ? JsonWithRefs\n : [Json[]] extends [T]\n ? JsonWithRefs\n : Value<T> | null\n\n/** The columns of table `K` every row must hold: those whose cell type does not admit `null`. */\ntype RequiredColumns<K extends keyof WorkspaceTables> = {\n [C in keyof WorkspaceTables[K]]-?: null extends WorkspaceTables[K][C] ? never : C\n}[keyof WorkspaceTables[K]]\n\n/**\n * A whole row, as an insert, an upsert or a batch insert writes it, each value checked against\n * its column's type. A required column must be present and not `null`: the table refuses a row\n * without it (`Missing required field`), and an upsert checks the whole row before it looks for a\n * match.\n */\nexport type TableData<K extends string> = K extends keyof WorkspaceTables\n ? { [C in RequiredColumns<K>]-?: Exclude<FieldValue<WorkspaceTables[K][C]>, null> } & {\n [C in Exclude<keyof WorkspaceTables[K], RequiredColumns<K>>]?: FieldValue<\n WorkspaceTables[K][C]\n >\n }\n : { [column: string]: JsonWithRefs }\n\n/**\n * The cells an update writes, each checked against its column's type. Every column is optional:\n * an update merges these cells over the stored row.\n */\nexport type TableDataPatch<K extends string> = K extends keyof WorkspaceTables\n ? { [C in keyof WorkspaceTables[K]]?: FieldValue<WorkspaceTables[K][C]> }\n : { [column: string]: JsonWithRefs }\n\n/** A workspace table: `table('leads')`. Table block operations live on `table.*`. */\nexport type TableRef<Key extends string = string> = ResourceRef<'table', Key>\nexport declare function table<K extends TableKey>(key: K): TableRef<K>\n\n/** A knowledge base: `knowledgeBase('docs')`. */\nexport type KnowledgeBaseRef<Key extends string = string> = ResourceRef<'knowledge-base', Key>\nexport declare function knowledgeBase<K extends KnowledgeBaseKey>(key: K): KnowledgeBaseRef<K>\n\n/** A workspace skill: `skill('triage')`. */\nexport type SkillRef<Key extends string = string> = ResourceRef<'skill', Key>\nexport declare function skill<K extends SkillKey>(key: K): SkillRef<K>\n\n/** A workspace folder: `folder('reports')`. */\nexport type FolderRef = ResourceRef<'file-folder'>\nexport declare function folder(key: string): FolderRef\n\n/** A workspace file: `file('contracts/acme.pdf')`. File block operations live on `file.*`. */\nexport type FileRef = ResourceRef<'file'>\nexport declare function file(path: string): FileRef\n\n/**\n * A file a file-upload field holds, as the editor stores it: one uploaded in place, or a workspace\n * file chosen by `key` (written `file('path')` when the workspace resolves it).\n */\nexport interface UploadedFile {\n name: string\n path: string\n size?: number\n type?: string\n key?: string | FileRef\n id?: string\n folderPath?: string\n}\n\n/** A file produced at run time (`file` / `file[]` outputs). */\nexport interface SimFile {\n id: string\n name: string\n url: string\n size: number\n type: string\n key: string\n}\n\n// Agent tools\n\n/** One entry of an agent's `tools` list. */\nexport interface Tool {\n readonly [TOOL]: true\n}\n\n/** How the model may use a tool, and the stored tool fields a print carries. */\nexport interface ToolOpts {\n usageControl?: 'auto' | 'force' | 'none'\n usageControlExpression?: string\n title?: string\n /** The stored operation, when the method does not pin it. */\n operation?: string\n toolId?: string\n /** Pair modes of the tool's params, which pick the member the agent reads. */\n modes?: Record<string, 'basic' | 'advanced'>\n customTool?: JsonWithRefs\n operationPolicy?: Json\n /** Unknown stored tool keys, kept verbatim. */\n extra?: Json\n}\n\n/**\n * A workspace custom tool by key, as an agent tool: `customTool('lookup-order')`. A stored tool\n * whose definition was copied into the workflow (and may have drifted from the workspace tool)\n * prints as `raw(tool)` instead.\n */\nexport declare function customTool<K extends CustomToolKey>(key: K, options?: ToolUsage): Tool\n\n/** How the model may use a tool the SDK writes by name (`customTool`, `mcp().tool`, `asTool`). */\nexport type ToolUsage = Pick<ToolOpts, 'usageControl' | 'usageControlExpression'>\n\n/** An MCP tool's arguments and the editor's snapshot of its server. */\nexport interface McpToolOpts extends ToolUsage {\n /** Argument values the workflow fixes; the model fills in the rest. */\n args?: Record<string, JsonWithRefs>\n /**\n * What the editor saved about the server and the tool's input schema when the tool was picked.\n * Shown in the editor; never run.\n */\n snapshot?: { serverName?: string; serverUrl?: string; schema?: Json }\n}\n\n/** An MCP server by key: `mcp('linear')`. */\nexport interface McpServerRef<Key extends string = string> extends ResourceRef<'mcp-server', Key> {\n /** One of the server's tools, as an agent tool: `mcp('linear').tool('create_issue')`. */\n tool(name: McpToolName<Key>, options?: McpToolOpts): Tool\n}\nexport declare function mcp<K extends McpServerKey>(key: K): McpServerRef<K>\n\n// Graph\n\n/** Block-level fields (`BlockState`), written as the third builder argument. */\nexport interface BlockMeta {\n /**\n * A legacy key the display name cannot carry (a `name~n` collision key or a reserved name such\n * as `Loop`). Printed only for such a stored block; apply accepts it only for a key the stored\n * workflow already has, so it can never introduce one.\n */\n key?: string\n /** Stored as `enabled: false`. */\n disabled?: true\n /** Locked: apply refuses any change to this block. */\n locked?: true\n /** Exposes the error port without an `onError` edge. */\n errorPort?: boolean\n /** The block-level advanced toggle (`advancedMode`). */\n advancedMode?: boolean\n /**\n * Runs the block as its trigger (`triggerMode`). Trigger builders (`trigger.gmail.poller`) set\n * it themselves; write it on any other builder only for a block stored in trigger mode.\n */\n triggerMode?: boolean\n /** The stored retry policy, written whole. */\n retry?: BlockRetryConfig\n /**\n * Per branch key of a condition or router, the row's display `title` and any stored fields the\n * SDK has no syntax for (`extra`, plain JSON). `title: null` keeps a row stored with no title,\n * which the executor never takes for `else`.\n */\n branches?: Record<string, { title?: string | null; extra?: Record<string, Json> }>\n /**\n * Stored params that run but have no SDK syntax: a schema-agnostic custom block's inputs, the\n * agent's legacy prompt fields, a container's stored params. Values the block keeps but never\n * runs are not written; apply keeps them from the stored workflow.\n */\n extra?: Record<string, unknown>\n /**\n * A loop or parallel's `block.data` subflow keys the loader could not read as config, kept\n * verbatim (plain JSON).\n */\n subflowData?: Record<string, Json>\n}\n\n/** A block's retry policy, field for field the stored `BlockRetryConfig`. */\nexport interface BlockRetryConfig {\n /** Absent config and `false` mean the same thing: the block runs once. */\n enabled: boolean\n /** Total tries including the first. */\n maxTries: number\n /** Delay between tries. */\n waitBetweenTriesMs: number\n}\n\n/** Anything an edge can point at. */\nexport type Target = Node | Group\n\n/** A block or container in the graph. */\nexport interface Node {\n readonly [NODE]: true\n /** Wires this node's default port to each target. Returns the target, or a group of them. */\n to<const T extends Target[]>(...targets: T): T extends [infer One] ? One : Group\n /** Wires this node's error port to each target. */\n onError(...targets: Target[]): void\n}\n\n/** Several nodes; `.to()` wires every member (fan-in). */\nexport interface Group {\n to(...targets: Target[]): Group\n}\n\n/**\n * The failure message a block outputs when an error edge leaves it (`x.onError(y)` runs `y` with\n * `x.error`); a check refuses `x.error` on a block without one, which fails the run instead.\n */\ntype ErrorOutput<O> = [O] extends [{ error: unknown }] ? unknown : { readonly error: Ref<string> }\n\n/** A block: a node whose outputs can be referenced, and `error` after an `onError` edge. */\nexport type Block<O> = Node & Ref<O> & ErrorOutput<O>\n\n/** The named ports of a condition or router. */\nexport type Branches<K extends string> = { readonly [P in K]: Node }\n\n/** Trigger builders (`trigger.start`, `trigger.gmail.poller`, ...), generated from the catalog. */\nexport declare namespace trigger {}\n\n/** Builders for hidden legacy block versions (`legacy.slack.send`), generated from the catalog. */\nexport declare namespace legacy {}\n\n/** A raw edge from a handle the SDK has no name for (a legacy or unknown port). */\nexport declare function edge(from: Node, handle: string, to: Target): void\n\n/** Any stored block type without a builder (legacy, unknown or custom), with untyped outputs. */\nexport declare function block(\n type: string,\n name: string,\n params: Record<string, unknown>,\n meta?: BlockMeta\n): Block<Json>\n\n// Workflow and variables\n\nexport type VariableType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'plain'\n\n/** A workflow variable declared in `workflow(name, { variables })`: its type and initial value. */\nexport interface VariableDeclaration {\n /**\n * The display name, written only when it differs from the key. It must normalize to the key\n * (lowercased, spaces and dots removed), as `'Total Count'` does to `totalcount`.\n */\n name?: string\n type: VariableType\n value: Json\n}\n\n/** The variables a workflow declares, by name. */\nexport type VariableDeclarations = Record<string, VariableDeclaration>\n\ndeclare const VAR: unique symbol\n\n/** A workflow variable, compiled to `<variable.name>`. */\nexport interface VarRef {\n readonly [VAR]: string\n}\n\ntype VariableValue<T extends VariableType> = T extends 'number'\n ? number\n : T extends 'boolean'\n ? boolean\n : T extends 'string' | 'plain'\n ? string\n : Json\n\n/** `vars` in the workflow body: one typed reference per declared variable. */\nexport type VarRefs<V extends VariableDeclarations> = {\n readonly [K in keyof V]: VarRef & Ref<VariableValue<V[K]['type']>>\n}\n\n/**\n * Workflow variables by name, untyped. Prefer the `vars` the `workflow()` body receives, which is\n * typed from the declared variables.\n */\nexport declare const vars: { readonly [name: string]: VarRef & Ref<Json> }\n\ndeclare const WORKFLOW_DEF: unique symbol\n\n/** The default export of a workflow file. */\nexport interface WorkflowDef {\n readonly [WORKFLOW_DEF]: true\n}\n\n/** A child workflow by key, for `runWorkflow` or as an agent tool. */\nexport interface WorkflowRef<Key extends string = string> extends ResourceRef<'workflow', Key> {\n /**\n * The workflow as an agent tool, as the editor's tool picker adds it:\n * `childWorkflow('enrich-lead').asTool()`. A tool with fixed inputs is written `raw(tool)`.\n */\n asTool(options?: ToolUsage): Tool\n}\n\n/**\n * Declares a workflow. The body wires blocks; it never runs. With no description or variables the\n * options may be left out: `workflow('Name', () => { ... })`.\n */\nexport declare function workflow<const V extends VariableDeclarations = Record<never, never>>(\n name: string,\n options: { description?: string; variables?: V },\n body: (scope: { vars: VarRefs<V> }) => void\n): WorkflowDef\nexport declare function workflow(\n name: string,\n body: (scope: { vars: VarRefs<Record<never, never>> }) => void\n): WorkflowDef\n/** A child workflow by key: `childWorkflow('enrich-lead')`. */\nexport declare function childWorkflow<K extends WorkflowKey>(key: K): WorkflowRef<K>\n\n// Containers\n\ntype ItemOf<C> = C extends { readonly [REF]: readonly (infer E)[] }\n ? E\n : C extends readonly (infer E)[]\n ? E\n : Json\n\n/** Inside a loop or parallel body. As a node it is the container's start port: `p.to(first)`. */\nexport interface SubflowScope<Item> extends Node {\n readonly index: Ref<number>\n readonly currentItem: Ref<Item>\n readonly items: Ref<Item[]>\n}\n\n/**\n * A container's outputs, plus its iteration fields by name (`outer.index`), which a block inside\n * the container reads (in a nested container too: an outer loop's index or item). Outside the\n * container only `results` resolves: check reports `W_REF_OUT_OF_SCOPE` on `outer.index` there.\n */\nexport interface SubflowOutput {\n results: Json[]\n index: number\n currentItem: Json\n items: Json[]\n}\n\n/** A loop or parallel container. Its `.to()` wires the port taken after it finishes. */\nexport type Container = Block<SubflowOutput>\n\ntype Collection = AnyRef | Template | Json[] | string\n\nexport declare const loop: {\n for(\n name: string,\n params: { count?: number },\n body: (scope: SubflowScope<never>) => void,\n meta?: BlockMeta\n ): Container\n forEach<const C extends Collection>(\n name: string,\n params: { collection: C },\n body: (scope: SubflowScope<ItemOf<C>>) => void,\n meta?: BlockMeta\n ): Container\n while(\n name: string,\n params: { condition: Template | string },\n body: (scope: SubflowScope<never>) => void,\n meta?: BlockMeta\n ): Container\n doWhile(\n name: string,\n params: { condition?: Template | string; count?: number },\n body: (scope: SubflowScope<never>) => void,\n meta?: BlockMeta\n ): Container\n}\n\nexport declare const parallel: {\n /** A parallel with no stored type, which the loader runs as `count`. */\n (\n name: string,\n params: { count?: number; collection?: Collection; batchSize?: number },\n body: (scope: SubflowScope<Json>) => void,\n meta?: BlockMeta\n ): Container\n count(\n name: string,\n params: { count: number; batchSize?: number },\n body: (scope: SubflowScope<never>) => void,\n meta?: BlockMeta\n ): Container\n collection<const C extends Collection>(\n name: string,\n params: { collection: C; batchSize?: number },\n body: (scope: SubflowScope<ItemOf<C>>) => void,\n meta?: BlockMeta\n ): Container\n}\n\n// Blocks with a source form of their own\n\n/**\n * Params and outputs of the blocks below, generated from the catalog. Each entry is\n * `{ params; output }`; without generated types the params are loose.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface SpecialBuilderTypes {}\n\ntype SpecialParams<K extends string> = K extends keyof SpecialBuilderTypes\n ? SpecialBuilderTypes[K] extends { params: infer P }\n ? P\n : never\n : Record<string, unknown>\n\ntype SpecialOutput<K extends string> = K extends keyof SpecialBuilderTypes\n ? SpecialBuilderTypes[K] extends { output: infer O }\n ? O\n : never\n : Json\n\n/** A condition expression, or `true` for the `else` branch. */\nexport type BranchExpression = Template | string | true\n\ndeclare const ONLY_ELSE: unique symbol\n\n/** What a branch other than `else` written as `true` must be, which no value is: the error names it. */\ninterface OnlyElseMayBeTrue {\n readonly [ONLY_ELSE]: true\n}\n\n/**\n * A condition's branches: every key holds an expression, and only `else` may be `true`. Another\n * branch written as `true` is checked against {@link OnlyElseMayBeTrue}, so the error names that\n * branch alone.\n */\ntype ConditionBranches<B> = {\n [K in keyof B]: K extends 'else'\n ? BranchExpression\n : B[K] extends true\n ? OnlyElseMayBeTrue\n : Template | string\n}\n\n/**\n * Keys of a condition written with no rows (`condition('Name', {})`, the source form of rows\n * that were never persisted): the implicit `if` and `else` ports stay addressable.\n */\ntype ConditionKeys<B> = keyof B extends never ? 'if' | 'else' : Extract<keyof B, string>\ntype RouterKeys<R> = keyof R extends never ? 'route0' : Extract<keyof R, string>\n\n/** A condition: named branches, the last one `else` when there are two or more. */\nexport declare function condition<const B extends Record<string, BranchExpression>>(\n name: string,\n branches: B & ConditionBranches<B>,\n meta?: BlockMeta\n): Block<SpecialOutput<'condition'>> & Branches<ConditionKeys<B>>\n\n/** A router: named routes described for the model. */\nexport declare function router<const R extends Record<string, string | Template>>(\n name: string,\n params: SpecialParams<'router'> & { routes: R },\n meta?: BlockMeta\n): Block<SpecialOutput<'router'>> & Branches<RouterKeys<R>>\n\n/** A function block. `code` is inline (`` js`...` ``) or a code file (`codeFile('./functions/x.js')`). */\nexport declare function fn(\n name: string,\n params: SpecialParams<'fn'> & { code: Template | CodeFileRef | string },\n meta?: BlockMeta\n): Block<SpecialOutput<'fn'>>\n\n/**\n * The inputs of a child workflow by key, each checked against the input its start block\n * declares when `workspace.d.ts` knows the workflow; loose JSON otherwise.\n */\nexport type WorkflowInputMapping<K extends string> = K extends keyof WorkspaceWorkflows\n ? WorkspaceWorkflows[K] extends { inputs: infer I }\n ? { [N in keyof I]?: FieldValue<I[N]> }\n : InputMapping\n : InputMapping\n\n/**\n * Runs a child workflow. A `childWorkflow('key')` checks `inputMapping` against its inputs. Its\n * `result` is the child's output: its first response block's `{ data, status, headers }` (a body\n * field is `result.data.field`), else the output of the last block it ran.\n */\nexport declare function runWorkflow<K extends string = string>(\n name: string,\n params: Omit<SpecialParams<'runWorkflow'>, 'workflowId' | 'inputMapping'> & {\n workflowId: WorkflowRef<K> | Exclude<SpecialParams<'runWorkflow'>['workflowId'], WorkflowRef>\n inputMapping?: WorkflowInputMapping<K>\n },\n meta?: BlockMeta\n): Block<SpecialOutput<'runWorkflow'>>\n\n/**\n * Pauses for a person; the form in `inputFormat` types `submission`. A resumed block also holds\n * each form field at its top level (the runtime copies the submission up, over any output of the\n * same name), so `approval.approved` and `approval.submission.approved` both read it.\n */\nexport declare function human<const F extends InputFields = Record<never, never>>(\n name: string,\n params: SpecialParams<'human'> & { inputFormat?: F },\n meta?: BlockMeta\n): Block<\n Omit<SpecialOutput<'human'>, 'submission' | keyof F> & {\n submission: InputFieldsOutput<F>\n } & InputFieldsOutput<F>\n>\n\n/**\n * A response's body, status and headers: the editor's JSON mode, `body` standing for\n * `{ dataMode: 'json', data }`. An object or array `body` is JSON whose references keep their\n * types; a template or reference is the body text as written.\n */\nexport interface ResponseBody {\n body: JsonWithRefs\n /** HTTP status; 200 when omitted. A template or reference must produce a number. */\n status?: number | RefTo<number> | Template | EnvRef\n /** Response headers by name. */\n headers?: Record<string, Value<string>>\n}\n\n/**\n * Ends the workflow with an API response: `response('Reply', { body: { ok: true }, status: 201 })`\n * (`body` is short for `dataMode: 'json'` with `data`), or the block's own params (`dataMode`,\n * `builderData`, ...) when the body is built field by field.\n */\nexport declare function response(\n name: string,\n params: ResponseBody,\n meta?: BlockMeta\n): Block<SpecialOutput<'response'>>\nexport declare function response(\n name: string,\n params: SpecialParams<'response'>,\n meta?: BlockMeta\n): Block<SpecialOutput<'response'>>\n\n/** Assigns workflow variables. */\nexport declare function setVariables(\n name: string,\n params: SpecialParams<'setVariables'>,\n meta?: BlockMeta\n): Block<SpecialOutput<'setVariables'>>\n\ndeclare const ANNOTATION: unique symbol\n\n/** A canvas note: no edges, no outputs. */\nexport interface Annotation {\n readonly [ANNOTATION]: true\n}\nexport declare function note(\n name: string,\n params: SpecialParams<'note'>,\n meta?: BlockMeta\n): Annotation\n\n// Structured param shapes\n\n/** Type names an input-format field may declare. */\nexport type InputFieldType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'file[]'\n\n/** A structured input field: its type plus a default value, description or required flag. */\nexport interface InputFieldSpec {\n type: InputFieldType\n value?: JsonWithRefs\n description?: string\n required?: boolean\n}\n\n/** `input-format` fields by name: `{ subject: 'string', amount: { type: 'number', value: 0 } }`. */\nexport type InputFields = Record<string, InputFieldType | InputFieldSpec>\n\ntype InputFieldValue<T> = T extends 'string'\n ? string\n : T extends 'number'\n ? number\n : T extends 'boolean'\n ? boolean\n : T extends 'array'\n ? Json[]\n : T extends 'file[]'\n ? SimFile[]\n : Json\n\n/** The outputs an `input-format` declares. */\nexport type InputFieldsOutput<F> = {\n [K in keyof F]: F[K] extends { type: infer T } ? InputFieldValue<T> : InputFieldValue<F[K]>\n}\n\n/**\n * One `response-format` field as the editor's builder stores it. An `object` or `array` field's\n * `value` may hold nested fields. A response is usually written with `body` instead.\n */\nexport interface ResponseField {\n id?: string\n name: string\n type: string\n value?: JsonWithRefs\n collapsed?: boolean\n}\n\n/** `response-format` fields: `[{ name: 'ok', type: 'boolean', value: true }]`. */\nexport type ResponseFields = ResponseField[]\n\n/** An agent message. */\nexport interface Message {\n role: 'system' | 'user' | 'assistant'\n content: Value<string>\n}\n\n/** One `variables-input` assignment, with any other stored keys kept. */\nexport interface VariableAssignment {\n variableId: VarRef\n value?: JsonWithRefs\n [key: string]: JsonWithRefs | VarRef | undefined\n}\n\n/** Child workflow inputs by name (`input-mapping`, `workflow-input-mapper`). */\nexport type InputMapping = Record<string, JsonWithRefs>\n\n/** An operator a table filter condition or builder rule can use. */\nexport type FilterOperator = LiteralUnion<\n | 'eq'\n | 'ne'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'in'\n | 'nin'\n | 'like'\n | 'ilike'\n | 'nlike'\n | 'nilike'\n | 'contains'\n | 'ncontains'\n | 'startsWith'\n | 'endsWith'\n | 'isNull'\n | 'isNotNull'\n | 'isEmpty'\n | 'isNotEmpty'\n>\n\n/** One row of the editor's filter builder, as it stores it. */\nexport interface FilterRule {\n id?: string\n /** How this row joins the rows before it; `and` when omitted. */\n logicalOperator?: 'and' | 'or'\n column: string\n operator: FilterOperator\n value: Value<string | number | boolean>\n collapsed?: boolean\n}\n\n/** A filter-builder value: the editor's rows, `[{ column: 'status', operator: 'eq', value: 'new' }]`. */\nexport type Filter = FilterRule[]\n\n/** One table filter condition: `{ field: 'status', op: 'eq', value: 'new' }`. */\nexport interface TableCondition {\n field: string\n op: FilterOperator\n value?: JsonWithRefs\n}\n\n/**\n * A table predicate: a condition, or an `all` (and) / `any` (or) group of predicates. The\n * `{ status: { $eq: 'new' } }` operator-object grammar is not one: the runtime refuses it.\n */\nexport type TablePredicate = TableCondition | { all: TablePredicate[] } | { any: TablePredicate[] }\n\n/** A table sort by column: `{ createdAt: 'desc' }`. */\nexport type Sort =\n | Record<string, 'asc' | 'desc'>\n | Array<{ column: string; direction: 'asc' | 'desc' }>\n\n/** One knowledge tag filter. */\nexport interface TagFilter {\n tagName: string\n tagValue: Value<string>\n [key: string]: JsonWithRefs\n}\n\n/** One document tag. */\nexport interface DocumentTag {\n tagName: string\n value: Value<string>\n [key: string]: JsonWithRefs\n}\n\n/** One `eval-input` metric. */\nexport interface EvalMetric {\n name: string\n description?: string\n range?: { min: number; max: number }\n [key: string]: JsonWithRefs | undefined\n}\n\n/** One `model-fallback-list` entry. */\nexport interface ModelFallback {\n model: LiteralUnion<Model>\n [key: string]: JsonWithRefs\n}\n\n/**\n * Model ids, generated into `models.d.ts` (which adds one member per model). Kept apart from the\n * block files so a model-list change touches one file.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: an empty interface is the merge target generated declarations augment\nexport interface ModelIds {}\nexport type Model = Extract<keyof ModelIds, string>\n\n/** A JSON Schema `responseFormat`, or `{ name, strict, schema }` around one. */\nexport type ResponseFormat = JsonWithRefs\n\ntype Depth = [never, 0, 1, 2, 3, 4]\n\ntype FromSchema<S, D extends number> = [D] extends [never]\n ? Json\n : S extends { enum: readonly (infer E)[] }\n ? E\n : S extends { type: 'object'; properties: infer P }\n ? { [K in keyof P]: FromSchema<P[K], Depth[D]> }\n : S extends { type: 'array'; items: infer I }\n ? FromSchema<I, Depth[D]>[]\n : S extends { type: 'string' }\n ? string\n : S extends { type: 'number' | 'integer' }\n ? number\n : S extends { type: 'boolean' }\n ? boolean\n : Json\n\n/**\n * The outputs a literal `responseFormat` adds, read from its JSON Schema with recursion capped at\n * depth 4. A template or reference adds untyped JSON.\n */\nexport type ResponseFormatOutput<RF> = [RF] extends [undefined]\n ? unknown\n : RF extends { schema: infer S }\n ? FromSchema<S, 4>\n : RF extends { type: 'object'; properties: object }\n ? FromSchema<RF, 4>\n : { [key: string]: Json }\n";
|
|
40930
40973
|
// ../workflow-code/src/anchors.ts
|
|
40931
40974
|
function portKey(port) {
|
|
40932
40975
|
switch (port.kind) {
|
|
@@ -41933,6 +41976,16 @@ function findWorkflowReferenceTokens(source) {
|
|
|
41933
41976
|
}
|
|
41934
41977
|
return tokens.sort((left, right) => left.start - right.start);
|
|
41935
41978
|
}
|
|
41979
|
+
function collectStringLeaves(value, out) {
|
|
41980
|
+
if (typeof value === "string")
|
|
41981
|
+
out.push(value);
|
|
41982
|
+
else if (Array.isArray(value))
|
|
41983
|
+
for (const item of value)
|
|
41984
|
+
collectStringLeaves(item, out);
|
|
41985
|
+
else if (typeof value === "object" && value !== null)
|
|
41986
|
+
for (const item of Object.values(value))
|
|
41987
|
+
collectStringLeaves(item, out);
|
|
41988
|
+
}
|
|
41936
41989
|
|
|
41937
41990
|
// ../workflow-code/src/limits.ts
|
|
41938
41991
|
var SOURCE_LIMITS = {
|
|
@@ -42415,6 +42468,7 @@ function parseWorkflowSourceHandle(handle, sourceType, branchKind) {
|
|
|
42415
42468
|
var SIDE_ANCHORED_SOURCE_HANDLE_IDS = new Set(WORKFLOW_CARD_SIDES.map((side) => `source-${side}`));
|
|
42416
42469
|
var SIDE_ANCHORED_TARGET_HANDLE_IDS = new Set(WORKFLOW_CARD_SIDES.map((side) => `target-${side}`));
|
|
42417
42470
|
var WORKFLOW_CONTAINER_BLOCK_TYPES = new Set(["loop", "parallel"]);
|
|
42471
|
+
var WORKFLOW_ANNOTATION_ONLY_BLOCK_TYPE = "note";
|
|
42418
42472
|
function getWorkflowEdgeScopeDropReason(edge, blocks) {
|
|
42419
42473
|
const sourceBlock = blocks[edge.source];
|
|
42420
42474
|
const targetBlock = blocks[edge.target];
|
|
@@ -42434,6 +42488,72 @@ function getWorkflowEdgeScopeDropReason(edge, blocks) {
|
|
|
42434
42488
|
}
|
|
42435
42489
|
return `blocks are in different scopes (${sourceParent ?? "root"} -> ${targetParent ?? "root"})`;
|
|
42436
42490
|
}
|
|
42491
|
+
function isWorkflowAnnotationOnlyBlockType(blockType) {
|
|
42492
|
+
return blockType === WORKFLOW_ANNOTATION_ONLY_BLOCK_TYPE;
|
|
42493
|
+
}
|
|
42494
|
+
var RESPONSE_BLOCK_TYPE = "response";
|
|
42495
|
+
function isElseConditionTitle(title) {
|
|
42496
|
+
return typeof title === "string" && title.trim().toLowerCase() === "else";
|
|
42497
|
+
}
|
|
42498
|
+
function hasCycle(successors, pending) {
|
|
42499
|
+
const ready = [...successors.keys()].filter((id) => !pending.has(id));
|
|
42500
|
+
let visited = 0;
|
|
42501
|
+
for (let id = ready.pop();id !== undefined; id = ready.pop()) {
|
|
42502
|
+
visited += 1;
|
|
42503
|
+
for (const next of successors.get(id) ?? []) {
|
|
42504
|
+
const left = (pending.get(next) ?? 0) - 1;
|
|
42505
|
+
pending.set(next, left);
|
|
42506
|
+
if (left === 0)
|
|
42507
|
+
ready.push(next);
|
|
42508
|
+
}
|
|
42509
|
+
}
|
|
42510
|
+
const nodes = new Set([...successors.keys(), ...pending.keys()]);
|
|
42511
|
+
return visited < nodes.size;
|
|
42512
|
+
}
|
|
42513
|
+
function alwaysEndsAtResponse(blocks, edges) {
|
|
42514
|
+
const runs = (id) => {
|
|
42515
|
+
const block = Object.hasOwn(blocks, id) ? blocks[id] : undefined;
|
|
42516
|
+
return block?.enabled === true && !isWorkflowAnnotationOnlyBlockType(block.type);
|
|
42517
|
+
};
|
|
42518
|
+
const isRoot = (id) => blocks[id]?.parentId === null;
|
|
42519
|
+
const portsBySource = new Map;
|
|
42520
|
+
const successors = new Map;
|
|
42521
|
+
const pending = new Map;
|
|
42522
|
+
for (const edge of edges) {
|
|
42523
|
+
if (!runs(edge.source) || !runs(edge.target))
|
|
42524
|
+
continue;
|
|
42525
|
+
const ports = portsBySource.get(edge.source) ?? new Set;
|
|
42526
|
+
ports.add(edge.port);
|
|
42527
|
+
portsBySource.set(edge.source, ports);
|
|
42528
|
+
if (!isRoot(edge.source) || !isRoot(edge.target))
|
|
42529
|
+
continue;
|
|
42530
|
+
const next = successors.get(edge.source) ?? [];
|
|
42531
|
+
next.push(edge.target);
|
|
42532
|
+
successors.set(edge.source, next);
|
|
42533
|
+
pending.set(edge.target, (pending.get(edge.target) ?? 0) + 1);
|
|
42534
|
+
}
|
|
42535
|
+
if (hasCycle(successors, pending))
|
|
42536
|
+
return false;
|
|
42537
|
+
let responds = false;
|
|
42538
|
+
for (const [id, block] of Object.entries(blocks)) {
|
|
42539
|
+
if (!runs(id) || block.parentId !== null)
|
|
42540
|
+
continue;
|
|
42541
|
+
if (block.type === RESPONSE_BLOCK_TYPE) {
|
|
42542
|
+
responds = true;
|
|
42543
|
+
continue;
|
|
42544
|
+
}
|
|
42545
|
+
const ports = portsBySource.get(id);
|
|
42546
|
+
if (block.branches !== undefined) {
|
|
42547
|
+
const { branches } = block;
|
|
42548
|
+
if (branches.length === 0 || !branches.every((branch) => ports?.has(`branch:${branch}`))) {
|
|
42549
|
+
return false;
|
|
42550
|
+
}
|
|
42551
|
+
} else if (!ports?.has(isSubflowType(block.type) ? "subflowEnd" : "out")) {
|
|
42552
|
+
return false;
|
|
42553
|
+
}
|
|
42554
|
+
}
|
|
42555
|
+
return responds;
|
|
42556
|
+
}
|
|
42437
42557
|
var RESERVED_WORKFLOW_BLOCK_NAMES = ["loop", "parallel", "variable"];
|
|
42438
42558
|
function isReservedWorkflowBlockName(name) {
|
|
42439
42559
|
return RESERVED_WORKFLOW_BLOCK_NAMES.includes(name);
|
|
@@ -42838,8 +42958,8 @@ function valueTree(value) {
|
|
|
42838
42958
|
var SDK_MODULE = "@sim/workflow-sdk";
|
|
42839
42959
|
var GENERIC_BUILDER = "block";
|
|
42840
42960
|
var CUSTOM_TOOL_TYPE = "custom-tool";
|
|
42841
|
-
var RESPONSE_BLOCK_TYPE = "response";
|
|
42842
42961
|
var RESPONSE_BODY_KEYS = ["body", "status", "headers"];
|
|
42962
|
+
var RESPONSE_OUTPUTS = ["data", "status", "headers"];
|
|
42843
42963
|
var TEMPLATE_TAGS = [
|
|
42844
42964
|
"t",
|
|
42845
42965
|
"js",
|
|
@@ -43719,6 +43839,9 @@ function renamedReferenceRewriter(renames) {
|
|
|
43719
43839
|
}) : text;
|
|
43720
43840
|
}
|
|
43721
43841
|
|
|
43842
|
+
// ../workflow-code/src/compile/blocks.ts
|
|
43843
|
+
var import_parser3 = __toESM(require_lib(), 1);
|
|
43844
|
+
|
|
43722
43845
|
// ../workflow-code/src/canonicalize/values.ts
|
|
43723
43846
|
var REFERENCE_CANDIDATE = /<([^<>]+)>/g;
|
|
43724
43847
|
var VARIABLE_PREFIX = "variable";
|
|
@@ -43813,6 +43936,20 @@ var MODELED_ROW_KEYS = new Set(["id", "title", "value", "key"]);
|
|
|
43813
43936
|
function isBranchExtraField(field) {
|
|
43814
43937
|
return !MODELED_ROW_KEYS.has(field) && !UI_ROW_KEYS.has(field);
|
|
43815
43938
|
}
|
|
43939
|
+
function storedTitle(kind, row, index, count) {
|
|
43940
|
+
if (row.titleOverride !== undefined)
|
|
43941
|
+
return row.titleOverride;
|
|
43942
|
+
return row.titleMissing ? undefined : positionalTitle(kind, index, count);
|
|
43943
|
+
}
|
|
43944
|
+
function positionalTitle(kind, index, count) {
|
|
43945
|
+
if (kind === "router")
|
|
43946
|
+
return `Route ${index + 1}`;
|
|
43947
|
+
if (index === 0)
|
|
43948
|
+
return "if";
|
|
43949
|
+
if (index === count - 1)
|
|
43950
|
+
return "else";
|
|
43951
|
+
return "else if";
|
|
43952
|
+
}
|
|
43816
43953
|
|
|
43817
43954
|
// ../workflow-code/src/canonicalize/subflows.ts
|
|
43818
43955
|
var PARALLEL_BATCH_MIN = 1;
|
|
@@ -47759,6 +47896,48 @@ function textField(value) {
|
|
|
47759
47896
|
function jsonField(value) {
|
|
47760
47897
|
return isJson(value) ? value : undefined;
|
|
47761
47898
|
}
|
|
47899
|
+
function checkLoopCondition(ctx, decl, text, property) {
|
|
47900
|
+
if (text.trim() === "")
|
|
47901
|
+
return;
|
|
47902
|
+
const at = rangeOf(ctx, property.value);
|
|
47903
|
+
const selfReads = new Set;
|
|
47904
|
+
const ownName = normalizeWorkflowBlockName(decl.name);
|
|
47905
|
+
const runnable = text.replace(REFERENCE_CANDIDATE, (match, inner) => {
|
|
47906
|
+
if (!isLikelyWorkflowReferenceSegment(match))
|
|
47907
|
+
return match;
|
|
47908
|
+
const segments = parseStoredPath(inner);
|
|
47909
|
+
const [head, field] = segments ?? [];
|
|
47910
|
+
if (head?.kind === "name" && normalizeWorkflowBlockName(head.name) === ownName && field?.kind === "name" && LOOP_PROPERTIES.includes(field.name)) {
|
|
47911
|
+
selfReads.add(field.name);
|
|
47912
|
+
}
|
|
47913
|
+
return "(0)";
|
|
47914
|
+
});
|
|
47915
|
+
for (const field of selfReads) {
|
|
47916
|
+
ctx.reporter.report("W_REF_OUT_OF_SCOPE", `${decl.name}'s condition reads its own ${field} by the loop's name. The run evaluates the condition outside the loop's body, where the loop outputs only results, so the run fails.`, at, {
|
|
47917
|
+
hint: `Write <loop.${field}>: the bare loop prefix reads the iteration the condition is evaluated for.`,
|
|
47918
|
+
blockKey: decl.key
|
|
47919
|
+
});
|
|
47920
|
+
}
|
|
47921
|
+
let failure = null;
|
|
47922
|
+
try {
|
|
47923
|
+
const file = import_parser3.parse(`return Boolean(${runnable})`, {
|
|
47924
|
+
sourceType: "script",
|
|
47925
|
+
allowReturnOutsideFunction: true,
|
|
47926
|
+
errorRecovery: true
|
|
47927
|
+
});
|
|
47928
|
+
failure = file.errors?.[0] ?? null;
|
|
47929
|
+
} catch (error) {
|
|
47930
|
+
failure = error;
|
|
47931
|
+
}
|
|
47932
|
+
if (failure === null)
|
|
47933
|
+
return;
|
|
47934
|
+
const { message: raw } = babelErrorShape(failure);
|
|
47935
|
+
const message = typeof raw === "string" ? raw : "Invalid JavaScript";
|
|
47936
|
+
ctx.reporter.report("W_LOOP_CONDITION_SYNTAX", `${decl.name}'s condition is not a JavaScript expression (${message.replace(/\s*\(\d+:\d+\)$/, "")}), so the run fails when it evaluates it.`, at, {
|
|
47937
|
+
hint: "Write one JavaScript expression the loop repeats while it is true, e.g. condition: '<loop.index> < 3'.",
|
|
47938
|
+
blockKey: decl.key
|
|
47939
|
+
});
|
|
47940
|
+
}
|
|
47762
47941
|
function compileContainer(ctx, decl) {
|
|
47763
47942
|
const builder = decl.builder;
|
|
47764
47943
|
if (builder.kind !== "container")
|
|
@@ -47790,6 +47969,12 @@ function compileContainer(ctx, decl) {
|
|
|
47790
47969
|
...doWhileCondition !== undefined && { doWhileCondition }
|
|
47791
47970
|
};
|
|
47792
47971
|
reportUnreadConfig(ctx, decl, form, written, loop);
|
|
47972
|
+
for (const field of ["whileCondition", "doWhileCondition"]) {
|
|
47973
|
+
const text = loop[field];
|
|
47974
|
+
const property = written.get(field);
|
|
47975
|
+
if (text !== undefined && property)
|
|
47976
|
+
checkLoopCondition(ctx, decl, text, property);
|
|
47977
|
+
}
|
|
47793
47978
|
subflow = loop;
|
|
47794
47979
|
} else {
|
|
47795
47980
|
const { fields } = compileConfig(ctx, site, "parallel", parallelForm(builder.method), config);
|
|
@@ -48439,7 +48624,7 @@ function stronglyConnected(keys, successors) {
|
|
|
48439
48624
|
}
|
|
48440
48625
|
|
|
48441
48626
|
// ../workflow-code/src/compile/function-returns.ts
|
|
48442
|
-
var
|
|
48627
|
+
var import_parser4 = __toESM(require_lib(), 1);
|
|
48443
48628
|
var FUNCTION_TYPE = "function";
|
|
48444
48629
|
var NUMBER_FUNCTIONS = new Set(["Number", "parseInt", "parseFloat"]);
|
|
48445
48630
|
var BOOLEAN_FUNCTIONS = new Set(["Boolean", "isNaN", "isFinite"]);
|
|
@@ -48775,7 +48960,7 @@ function returnedFields(object, inference) {
|
|
|
48775
48960
|
function readReturns(code) {
|
|
48776
48961
|
let program;
|
|
48777
48962
|
try {
|
|
48778
|
-
const file =
|
|
48963
|
+
const file = import_parser4.parse(toCodeFile(code, "javascript"), {
|
|
48779
48964
|
sourceType: "unambiguous",
|
|
48780
48965
|
allowReturnOutsideFunction: true,
|
|
48781
48966
|
allowAwaitOutsideFunction: true,
|
|
@@ -48875,6 +49060,7 @@ var COMPILE_SCOPE_CODES = [
|
|
|
48875
49060
|
"W_ENV_UNKNOWN",
|
|
48876
49061
|
"W_CHILD_INPUT_UNKNOWN",
|
|
48877
49062
|
"W_CHILD_NO_START",
|
|
49063
|
+
"W_CHILD_RESULT_PATH",
|
|
48878
49064
|
"E_UNKNOWN_SUBFLOW_PROPERTY",
|
|
48879
49065
|
"W_FORWARD_REF",
|
|
48880
49066
|
"W_REF_NOT_NORMALIZED",
|
|
@@ -48920,7 +49106,8 @@ var COMPILE_CATALOG_CODES = [
|
|
|
48920
49106
|
"W_SUBFLOW_COUNT",
|
|
48921
49107
|
"W_UNKNOWN_OUTPUT_PATH",
|
|
48922
49108
|
"W_OUTPUT_PATH_UNDECLARED",
|
|
48923
|
-
"W_JSON_REF_UNTYPED"
|
|
49109
|
+
"W_JSON_REF_UNTYPED",
|
|
49110
|
+
"W_LOOP_CONDITION_SYNTAX"
|
|
48924
49111
|
];
|
|
48925
49112
|
var CODE_FILE_CODES = [
|
|
48926
49113
|
"E_CODE_FILE_MISSING",
|
|
@@ -49024,6 +49211,7 @@ var APPLY_DIAGNOSTIC_CODES = [
|
|
|
49024
49211
|
"E_APPLY_UNRESOLVED_REF",
|
|
49025
49212
|
"E_APPLY_REF_OUT_OF_SCOPE",
|
|
49026
49213
|
"E_APPLY_CODE_FILE_REF_SYNTAX",
|
|
49214
|
+
"E_APPLY_LOOP_CONDITION_SYNTAX",
|
|
49027
49215
|
"W_APPLY_LINT",
|
|
49028
49216
|
"W_TABLE_UNKNOWN_COLUMN",
|
|
49029
49217
|
"E_APPLY_INVALID_SCHEDULE",
|
|
@@ -49065,7 +49253,8 @@ function refusalClassifier(extra = {}) {
|
|
|
49065
49253
|
}
|
|
49066
49254
|
var refusalClass = refusalClassifier();
|
|
49067
49255
|
var CHANGED_BLOCK_REFUSALS = new Map([
|
|
49068
|
-
["W_REF_OUT_OF_SCOPE", "E_APPLY_REF_OUT_OF_SCOPE"]
|
|
49256
|
+
["W_REF_OUT_OF_SCOPE", "E_APPLY_REF_OUT_OF_SCOPE"],
|
|
49257
|
+
["W_LOOP_CONDITION_SYNTAX", "E_APPLY_LOOP_CONDITION_SYNTAX"]
|
|
49069
49258
|
]);
|
|
49070
49259
|
var PARAM_REFUSALS = new Map([
|
|
49071
49260
|
["W_UNKNOWN_OPTION", "E_APPLY_INVALID_SUBBLOCK_FIELD"]
|
|
@@ -49084,6 +49273,7 @@ var CODE_FILE_REFUSALS = new Map([
|
|
|
49084
49273
|
var REFUSABLE_WARNING_CODES = new Set([
|
|
49085
49274
|
"W_UNKNOWN_OPTION",
|
|
49086
49275
|
"W_REF_OUT_OF_SCOPE",
|
|
49276
|
+
"W_LOOP_CONDITION_SYNTAX",
|
|
49087
49277
|
"W_UNKNOWN_OUTPUT_PATH",
|
|
49088
49278
|
"W_UNRESOLVED_REF",
|
|
49089
49279
|
"W_CODE_FILE_REF_SYNTAX",
|
|
@@ -50617,6 +50807,37 @@ function stableStringify(value) {
|
|
|
50617
50807
|
function sha256Hex(text) {
|
|
50618
50808
|
return bytesToHex(sha256(utf8ToBytes(text)));
|
|
50619
50809
|
}
|
|
50810
|
+
// ../workflow-code/src/responds.ts
|
|
50811
|
+
function alwaysTakenBranches(block) {
|
|
50812
|
+
const branches = block.branches;
|
|
50813
|
+
if (!branches)
|
|
50814
|
+
return;
|
|
50815
|
+
const rows = branches.rows ?? [];
|
|
50816
|
+
if (branches.kind === "router")
|
|
50817
|
+
return rows.map((row) => row.key);
|
|
50818
|
+
const elseAt = rows.findIndex((row, index) => isElseConditionTitle(storedTitle(branches.kind, row, index, rows.length)));
|
|
50819
|
+
return elseAt === -1 ? [] : rows.slice(0, elseAt + 1).map((row) => row.key);
|
|
50820
|
+
}
|
|
50821
|
+
function portName(port) {
|
|
50822
|
+
return port.kind === "branch" ? `branch:${port.key}` : port.kind;
|
|
50823
|
+
}
|
|
50824
|
+
function respondsOnEveryRun(workflow) {
|
|
50825
|
+
const blocks = {};
|
|
50826
|
+
for (const [key, block] of Object.entries(workflow.blocks)) {
|
|
50827
|
+
const branches = alwaysTakenBranches(block);
|
|
50828
|
+
setOwn(blocks, key, {
|
|
50829
|
+
type: block.type,
|
|
50830
|
+
enabled: block.enabled,
|
|
50831
|
+
parentId: block.parent,
|
|
50832
|
+
...branches !== undefined && { branches }
|
|
50833
|
+
});
|
|
50834
|
+
}
|
|
50835
|
+
return alwaysEndsAtResponse(blocks, workflow.edges.map((edge) => ({
|
|
50836
|
+
source: edge.from,
|
|
50837
|
+
target: edge.to,
|
|
50838
|
+
port: portName(edge.port)
|
|
50839
|
+
})));
|
|
50840
|
+
}
|
|
50620
50841
|
// ../workflow-sdk/src/codegen/emit.ts
|
|
50621
50842
|
function literal(value) {
|
|
50622
50843
|
return typeof value === "string" ? quoteString(value) : String(value);
|
|
@@ -51289,7 +51510,8 @@ var RUNTIME_SEMANTICS = [
|
|
|
51289
51510
|
"",
|
|
51290
51511
|
"- **Two retries, nested.** An `api` block's `retries`, `retryDelayMs` and `retryMaxDelayMs` repeat the HTTP request inside one run of the block: only after a timeout, a connection reset, a 429 or a 5xx, only for GET, HEAD, PUT and DELETE unless `retryNonIdempotent: true`, with jittered exponential backoff capped at `retryMaxDelayMs` (a `Retry-After` beyond the cap ends the retries). `meta.retry` (`{ enabled, maxTries, waitBetweenTriesMs }`) reruns the whole block, request retries included, after any failure but a stop or a failed child workflow; `maxTries` counts every try. So `retries: 2` under `maxTries: 3` sends up to 9 requests. Only the last try's failure reaches `onError`. Triggers and `human` never retry.",
|
|
51291
51512
|
"- **`onError`.** `x.onError(y)` makes a failure of `x` an output, `{ error: '<message>' }`, and runs `y` instead of `x`'s other targets; the run goes on. `y` reads the message as `x.error` (only a block with an `onError` edge has it). In a loop or parallel body (`y` must be in the same body) the iteration ends normally and the loop moves to the next item, with that error output as `x`'s entry for the iteration. Without `onError`, a failure in any iteration fails the run and stops the loop.",
|
|
51292
|
-
"- **Joins run once.** A block with several incoming edges runs once, after every one of them has fired or been ruled out (a condition or router branch not taken, the normal edge of a block that failed into `onError`). `a.to(join)`, `b.to(join)`, `c.to(join)` wait for all three; behind a condition only the taken branch fires, and the join runs once after it. A block never runs once per incoming branch.",
|
|
51513
|
+
"- **Joins run once.** A block with several incoming edges runs once, after every one of them has fired or been ruled out (a condition or router branch not taken, the normal edge of a block that failed into `onError`). `a.to(join)`, `b.to(join)`, `c.to(join)` wait for all three; behind a condition only the taken branch fires, and the join runs once after it. A block never runs once per incoming branch. A reference to a block that did not run (on the branch not taken) resolves empty: `null` as a whole value, in function code or in a condition, `''` inside text.",
|
|
51514
|
+
"- **Loop and parallel results.** `x.results` holds one entry per iteration (a parallel: per branch), and each entry is the list of outputs of the body blocks that ran in it, in the order they finished. With one block in the body its output is `x.results[i][0]`; `x.results.flat()` lists every output.",
|
|
51293
51515
|
"- **Outputs in function code.** In `fn` code, `${a.content}` inside js`` is not spliced in as text: it becomes an expression that evaluates to the output's value, a string as a string and an object as an object. Write it where an expression goes (`const reply = ${a.content}`, `[${a.content}, ${b.content}]`) and never wrap it in quotes. Written inside a JavaScript string or template literal it splices in as JSON, quotes included (`'Hi ${a.content}'` gives `Hi \"hello\"`). Python code works the same way.",
|
|
51294
51516
|
"- **Child workflows.** `const c = runWorkflow('C', { workflowId: childWorkflow('k'), inputMapping })` outputs the child's run as `c.result`: the output of the first `response` block the child reaches, `{ data, status, headers }` (a field of its `body` is `c.result.data.field`), or, with no `response` block, the output of the last block it ran. `c.result` is untyped: wrap a value that should become text in `t`. A deployed run of the parent (API, webhook, schedule, chat) runs the child's deployed version and fails while the child is not deployed; a run from the editor runs the child's draft. A failed child fails `c` (`c.onError(...)` catches it).",
|
|
51295
51517
|
"- **MCP headers** (`mcp/<key>.ts`). A header value is plain text in which `{{NAME}}` names an env variable anywhere (`Authorization: 'Bearer {{GITHUB_TOKEN}}'`), `env.NAME` for a whole value, or `stored()` to keep the value the server holds. A `t` template or a template literal with `${}` is refused. A credential header (`Authorization`, `Cookie`, or a name with `key`, `token`, `secret`, `auth`, `password`, `session`, `signature` or `credential`) holds nothing but an optional scheme word (`Bearer`, `Basic`, `Token`, `Bot`, `ApiKey`) and `{{NAME}}` references (`E_MCP_LITERAL_SECRET`). The variables resolve when the server connects, from the personal and workspace env (the workspace value wins); a missing one fails the connection.",
|
|
@@ -51882,6 +52104,7 @@ function describeBuilder(catalog, key) {
|
|
|
51882
52104
|
summary: types.summary,
|
|
51883
52105
|
...entry.builder.operation ? { operation: entry.builder.operation } : {},
|
|
51884
52106
|
legacy: isLegacyBuilder(key),
|
|
52107
|
+
...entry.special ? docOf(key) : {},
|
|
51885
52108
|
signature,
|
|
51886
52109
|
tool,
|
|
51887
52110
|
paramsName: types.paramsName,
|
|
@@ -51905,28 +52128,47 @@ function lookupBuilder(catalog, query) {
|
|
|
51905
52128
|
if (SDK_CORE_EXPORTS.includes(root)) {
|
|
51906
52129
|
return { kind: "core", name: key, declaration: coreDeclaration(root) };
|
|
51907
52130
|
}
|
|
52131
|
+
const ofBlockType = paths.filter((path) => catalogBuilder(catalog, path)?.type === key);
|
|
52132
|
+
const only = ofBlockType.length === 1 ? describeBuilder(catalog, ofBlockType[0]) : null;
|
|
52133
|
+
if (only)
|
|
52134
|
+
return { kind: "builder", reference: only };
|
|
52135
|
+
if (ofBlockType.length > 1) {
|
|
52136
|
+
return {
|
|
52137
|
+
kind: "namespace",
|
|
52138
|
+
namespace: key,
|
|
52139
|
+
builders: ofBlockType.map((path) => ({ key: path, summary: summaryOf(catalog, path) }))
|
|
52140
|
+
};
|
|
52141
|
+
}
|
|
51908
52142
|
const hint = suggestBuilder(key, paths.filter((path) => !isLegacyBuilder(path)));
|
|
51909
52143
|
return hint ? { kind: "missing", hint } : { kind: "missing" };
|
|
51910
52144
|
}
|
|
51911
52145
|
var MAX_CORE_LINES = 80;
|
|
51912
|
-
|
|
51913
|
-
const lines = CORE_DTS.split(`
|
|
52146
|
+
var CORE_LINES = CORE_DTS.split(`
|
|
51914
52147
|
`);
|
|
52148
|
+
function docCommentStart(start) {
|
|
52149
|
+
if (!CORE_LINES[start - 1]?.trim().endsWith("*/"))
|
|
52150
|
+
return start;
|
|
52151
|
+
let first = start - 1;
|
|
52152
|
+
while (first > 0 && !CORE_LINES[first].trim().startsWith("/**"))
|
|
52153
|
+
first--;
|
|
52154
|
+
return first;
|
|
52155
|
+
}
|
|
52156
|
+
function coreDeclarationRanges(name) {
|
|
51915
52157
|
const start = new RegExp(`^export (?:declare )?(?:const|function|namespace|interface|type) ${escapeRegExp(name)}\\b`);
|
|
51916
52158
|
const declarations = [];
|
|
51917
|
-
for (let index = 0;index <
|
|
51918
|
-
if (!start.test(
|
|
52159
|
+
for (let index = 0;index < CORE_LINES.length; index++) {
|
|
52160
|
+
if (!start.test(CORE_LINES[index]))
|
|
51919
52161
|
continue;
|
|
51920
52162
|
let depth = 0;
|
|
51921
52163
|
let end = index;
|
|
51922
|
-
for (;end <
|
|
51923
|
-
for (const char of
|
|
52164
|
+
for (;end < CORE_LINES.length; end++) {
|
|
52165
|
+
for (const char of CORE_LINES[end]) {
|
|
51924
52166
|
if ("({[".includes(char))
|
|
51925
52167
|
depth++;
|
|
51926
52168
|
else if (")}]".includes(char))
|
|
51927
52169
|
depth--;
|
|
51928
52170
|
}
|
|
51929
|
-
const continues = /[=:,|&]\s*$/.test(
|
|
52171
|
+
const continues = /[=:,|&]\s*$/.test(CORE_LINES[end]) || /^\s+[?:|&]/.test(CORE_LINES[end + 1] ?? "");
|
|
51930
52172
|
if (depth <= 0 && !continues)
|
|
51931
52173
|
break;
|
|
51932
52174
|
}
|
|
@@ -51936,28 +52178,26 @@ function coreDeclarationRanges(name) {
|
|
|
51936
52178
|
return declarations;
|
|
51937
52179
|
}
|
|
51938
52180
|
function coreSignatures(name) {
|
|
51939
|
-
|
|
51940
|
-
`);
|
|
51941
|
-
return coreDeclarationRanges(name).map(({ start, end }) => lines.slice(start, end).join(" ").replace(/^export (?:declare )?function /, "").replace(/\s+/g, " ").replace(/([(<]) /g, "$1").replace(/,? ([)>])/g, "$1").trim()).join(`
|
|
52181
|
+
return coreDeclarationRanges(name).map(({ start, end }) => CORE_LINES.slice(start, end).join(" ").replace(/^export (?:declare )?function /, "").replace(/\s+/g, " ").replace(/([(<]) /g, "$1").replace(/,? ([)>])/g, "$1").trim()).join(`
|
|
51942
52182
|
`);
|
|
51943
52183
|
}
|
|
51944
52184
|
function coreDeclaration(name) {
|
|
51945
|
-
const lines = CORE_DTS.split(`
|
|
51946
|
-
`);
|
|
51947
52185
|
const out = [];
|
|
51948
52186
|
for (const { start, end } of coreDeclarationRanges(name)) {
|
|
51949
|
-
let first = start;
|
|
51950
|
-
if (lines[start - 1]?.trim().endsWith("*/")) {
|
|
51951
|
-
while (first > 0 && !lines[first].trim().startsWith("/**"))
|
|
51952
|
-
first--;
|
|
51953
|
-
}
|
|
51954
52187
|
if (out.length > 0)
|
|
51955
52188
|
out.push("");
|
|
51956
|
-
out.push(...
|
|
52189
|
+
out.push(...CORE_LINES.slice(docCommentStart(start), end));
|
|
51957
52190
|
}
|
|
51958
52191
|
return out.slice(0, MAX_CORE_LINES).join(`
|
|
51959
52192
|
`);
|
|
51960
52193
|
}
|
|
52194
|
+
function docOf(name) {
|
|
52195
|
+
const range = coreDeclarationRanges(name)[0];
|
|
52196
|
+
if (!range)
|
|
52197
|
+
return {};
|
|
52198
|
+
const doc = CORE_LINES.slice(docCommentStart(range.start), range.start).map((line) => line.trim().replace(/^\/\*\*\s?|\s?\*\/$|^\*\s?/g, "")).join(" ").replace(/\s+/g, " ").trim();
|
|
52199
|
+
return doc ? { doc } : {};
|
|
52200
|
+
}
|
|
51961
52201
|
var MAX_SNIPPET_TYPE = 60;
|
|
51962
52202
|
var MAX_SNIPPET_OPTIONAL = 12;
|
|
51963
52203
|
function shortType(type) {
|
|
@@ -52048,6 +52288,8 @@ function renderBuilderReference(reference) {
|
|
|
52048
52288
|
if (reference.legacy) {
|
|
52049
52289
|
lines.push("Legacy: an older block version. Write the current builder instead.");
|
|
52050
52290
|
}
|
|
52291
|
+
if (reference.doc)
|
|
52292
|
+
lines.push("", reference.doc);
|
|
52051
52293
|
lines.push("", reference.signature);
|
|
52052
52294
|
if (reference.tool)
|
|
52053
52295
|
lines.push(`${reference.tool} (as an agent tool)`);
|
|
@@ -52300,7 +52542,7 @@ export default defineTable({
|
|
|
52300
52542
|
name: 'orders',
|
|
52301
52543
|
description: 'Order questions the support workflow answered',
|
|
52302
52544
|
columns: {
|
|
52303
|
-
orderId: column.string({ required: true }),
|
|
52545
|
+
orderId: column.string({ required: true, unique: true }),
|
|
52304
52546
|
status: column.select({ options: ['open', 'answered'] }),
|
|
52305
52547
|
total: column.number(),
|
|
52306
52548
|
},
|
|
@@ -52379,9 +52621,10 @@ export default workflow('Support', { description: 'Answers an order question.' }
|
|
|
52379
52621
|
tools: [customTool('lookup-order')],
|
|
52380
52622
|
skills: [skill('tone')],
|
|
52381
52623
|
})
|
|
52382
|
-
const log = table.
|
|
52624
|
+
const log = table.upsertRow('Log Question', {
|
|
52383
52625
|
tableId: table('orders'),
|
|
52384
52626
|
data: { orderId: start.orderId, status: 'answered' },
|
|
52627
|
+
conflictColumn: 'orderId',
|
|
52385
52628
|
})
|
|
52386
52629
|
|
|
52387
52630
|
start.to(policy)
|
|
@@ -53894,7 +54137,7 @@ async function withSourceCommandLock(dir, run, options = {}) {
|
|
|
53894
54137
|
return withSourceDirLock(folder ? folder.root : dir, run, options);
|
|
53895
54138
|
}
|
|
53896
54139
|
// ../workflow-code/src/code-files/references.ts
|
|
53897
|
-
var
|
|
54140
|
+
var import_parser5 = __toESM(require_lib(), 1);
|
|
53898
54141
|
var CODE_FILE_EXPORT = "codeFile";
|
|
53899
54142
|
function codeFileReferences(text) {
|
|
53900
54143
|
if (utf8Bytes(text, SOURCE_LIMITS.maxTotalBytes) > SOURCE_LIMITS.maxTotalBytes)
|
|
@@ -53903,7 +54146,7 @@ function codeFileReferences(text) {
|
|
|
53903
54146
|
return [];
|
|
53904
54147
|
let program;
|
|
53905
54148
|
try {
|
|
53906
|
-
program =
|
|
54149
|
+
program = import_parser5.parse(text, PARSER_OPTIONS).program;
|
|
53907
54150
|
} catch {
|
|
53908
54151
|
return [];
|
|
53909
54152
|
}
|
|
@@ -54119,6 +54362,10 @@ function loopRows(rows) {
|
|
|
54119
54362
|
return rows.map(([command, what]) => ` ${command.padEnd(width)}${what}`.trimEnd()).join(`
|
|
54120
54363
|
`);
|
|
54121
54364
|
}
|
|
54365
|
+
var WORKSPACE_LINE = `Workspace: a directory records it (.sim/base.json, or a starter's .sim/starter.json); any other
|
|
54366
|
+
command takes -w <id>, SIM_WORKSPACE or the profile's (export SIM_WORKSPACE once, or keep only the
|
|
54367
|
+
ID in a variable: one holding "--workspace <id>" is one argument, an unknown option alone and the
|
|
54368
|
+
whole ID after -w).`;
|
|
54122
54369
|
function statusLine(group, dir) {
|
|
54123
54370
|
return `\`${group} status --dir ${dir}\` shows what applying would do and
|
|
54124
54371
|
whether the server changed since the get (exit 0 clean, ${SOURCE_LOCAL_CHANGES_EXIT_CODE} your edits only, ${SOURCE_DRIFT_EXIT_CODE} the server changed).
|
|
@@ -54137,6 +54384,7 @@ ${loopRows([
|
|
|
54137
54384
|
A new workflow: \`sim workflows source create --dir ./new --workspace <workspaceId>\` writes a
|
|
54138
54385
|
starter that records its workspace; edit and check it, then \`create --dir ./new --yes\` creates the
|
|
54139
54386
|
workflow there, and the loop above goes on from there.
|
|
54387
|
+
${WORKSPACE_LINE}
|
|
54140
54388
|
|
|
54141
54389
|
Flags the loop needs: --allow-delete (apply: an edit that removes a block or variable is refused
|
|
54142
54390
|
without it), --deploy (apply, create: also deploy the saved draft), --force (get: replace another
|
|
@@ -54154,6 +54402,7 @@ ${loopRows([
|
|
|
54154
54402
|
])}
|
|
54155
54403
|
Promote dev to prod: \`sim workspaces source apply --dir ./ws --to <workspaceId> --dry-run\`, then
|
|
54156
54404
|
--yes.
|
|
54405
|
+
${WORKSPACE_LINE}
|
|
54157
54406
|
|
|
54158
54407
|
Flags the loop needs: --allow-delete (apply: removing a resource, a column, rows or a document,
|
|
54159
54408
|
or a workflow's block or variable, is refused without it), --force (get: replace edits no apply
|
|
@@ -54447,6 +54696,112 @@ async function printRunFailureSite(dir, workflowId, error) {
|
|
|
54447
54696
|
]);
|
|
54448
54697
|
}
|
|
54449
54698
|
|
|
54699
|
+
// src/commands/protocol/workflow-run-get.ts
|
|
54700
|
+
var BLOCK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
54701
|
+
var SELECT_OUTPUT_FLAG = "select-output";
|
|
54702
|
+
function normalizeBlockName(name) {
|
|
54703
|
+
return name.toLowerCase().replace(/\s+/g, "").replace(/\./g, "");
|
|
54704
|
+
}
|
|
54705
|
+
async function loadWorkflowBlocks(client, workflowId) {
|
|
54706
|
+
const raw = await client.request("getWorkflowState", { params: { workflowId } });
|
|
54707
|
+
const state = isRecordLike(raw) && isRecordLike(raw.data) ? raw.data : raw;
|
|
54708
|
+
const blocks = isRecordLike(state) && isRecordLike(state.blocks) ? Object.entries(state.blocks) : [];
|
|
54709
|
+
return blocks.map(([key, block]) => ({
|
|
54710
|
+
id: isRecordLike(block) && typeof block.id === "string" ? block.id : key,
|
|
54711
|
+
name: isRecordLike(block) && typeof block.name === "string" ? block.name : ""
|
|
54712
|
+
}));
|
|
54713
|
+
}
|
|
54714
|
+
function splitSelector(selector) {
|
|
54715
|
+
const dot = selector.indexOf(".");
|
|
54716
|
+
return dot === -1 ? { head: selector, path: "" } : { head: selector.slice(0, dot), path: selector.slice(dot) };
|
|
54717
|
+
}
|
|
54718
|
+
function isIdHeaded(selector) {
|
|
54719
|
+
return BLOCK_ID.test(splitSelector(selector).head);
|
|
54720
|
+
}
|
|
54721
|
+
function resolveSelection(typed, blocks, workflowId) {
|
|
54722
|
+
const resolved = [];
|
|
54723
|
+
const typedBy = new Map;
|
|
54724
|
+
const unresolved = [];
|
|
54725
|
+
for (const selector of typed) {
|
|
54726
|
+
const { head, path } = splitSelector(selector);
|
|
54727
|
+
let blockId = head;
|
|
54728
|
+
if (!BLOCK_ID.test(head)) {
|
|
54729
|
+
const wanted = normalizeBlockName(head);
|
|
54730
|
+
const matches = blocks.filter((block) => block.id === head || normalizeBlockName(block.name) === wanted);
|
|
54731
|
+
if (matches.length === 0) {
|
|
54732
|
+
unresolved.push(selector);
|
|
54733
|
+
continue;
|
|
54734
|
+
}
|
|
54735
|
+
if (matches.length > 1) {
|
|
54736
|
+
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} ${selector} names ${matches.length} blocks (${matches.map((block) => block.id).join(", ")}); pass the block id instead`, 0);
|
|
54737
|
+
}
|
|
54738
|
+
blockId = matches[0].id;
|
|
54739
|
+
}
|
|
54740
|
+
const rewritten = `${blockId}${path}`;
|
|
54741
|
+
resolved.push(rewritten);
|
|
54742
|
+
if (!typedBy.has(rewritten))
|
|
54743
|
+
typedBy.set(rewritten, selector);
|
|
54744
|
+
}
|
|
54745
|
+
if (unresolved.length > 0) {
|
|
54746
|
+
const names = blocks.map((block) => block.name).filter((name) => name !== "");
|
|
54747
|
+
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} did not resolve to any block on this run: ${unresolved.join(", ")}. Pass a block id or its name — "blockId", "blockId.path", "blockName" or "blockName.path"; names match ignoring case, spaces and dots. Blocks on workflow ${workflowId}: ${names.length > 0 ? names.join(", ") : "none"}.`, 0);
|
|
54748
|
+
}
|
|
54749
|
+
return { resolved, typedBy };
|
|
54750
|
+
}
|
|
54751
|
+
function keyByTyped(payload, typedBy) {
|
|
54752
|
+
if (!isRecordLike(payload) || !isRecordLike(payload.blockOutputs))
|
|
54753
|
+
return payload;
|
|
54754
|
+
const blockOutputs = {};
|
|
54755
|
+
for (const [key, value] of Object.entries(payload.blockOutputs)) {
|
|
54756
|
+
blockOutputs[typedBy.get(key) ?? key] = value;
|
|
54757
|
+
}
|
|
54758
|
+
return { ...payload, blockOutputs };
|
|
54759
|
+
}
|
|
54760
|
+
async function readRunByName(runId, typed, command, { client, profile }) {
|
|
54761
|
+
const flags = command.optsWithGlobals();
|
|
54762
|
+
const operation = V2_OPERATIONS.getWorkflowRun;
|
|
54763
|
+
const spec = CLI_CONTRACT.getWorkflowRun ?? {};
|
|
54764
|
+
await buildRequest("getWorkflowRun", [runId], flags, profile.workspaceId);
|
|
54765
|
+
const workflowId = String(flags.workflow);
|
|
54766
|
+
const selection = resolveSelection(typed, await loadWorkflowBlocks(client, workflowId), workflowId);
|
|
54767
|
+
const request = await buildRequest("getWorkflowRun", [runId], { ...flags, selectOutput: selection.resolved }, profile.workspaceId);
|
|
54768
|
+
let result;
|
|
54769
|
+
try {
|
|
54770
|
+
result = await client.request("getWorkflowRun", {
|
|
54771
|
+
params: request.params,
|
|
54772
|
+
headers: request.headers,
|
|
54773
|
+
query: request.query,
|
|
54774
|
+
body: request.body
|
|
54775
|
+
});
|
|
54776
|
+
} catch (error) {
|
|
54777
|
+
throw retypeApiError(error, "getWorkflowRun", spec, operation);
|
|
54778
|
+
}
|
|
54779
|
+
renderResult("getWorkflowRun", profile.output, keyByTyped(result?.data ?? result, selection.typedBy), spec, {}, result);
|
|
54780
|
+
}
|
|
54781
|
+
function attachWorkflowRunGet(runs) {
|
|
54782
|
+
const get = runs.commands.find((command) => command.name() === "get");
|
|
54783
|
+
const held = get?._actionHandler;
|
|
54784
|
+
if (!get || typeof held !== "function") {
|
|
54785
|
+
throw new Error("workflows runs get must be registered before block names can be attached to it");
|
|
54786
|
+
}
|
|
54787
|
+
const previous = held;
|
|
54788
|
+
const connectGet = callsOperations(get, ["getWorkflowRun", "getWorkflowState"]);
|
|
54789
|
+
get.action(async (runId, _options, command) => {
|
|
54790
|
+
const raw = command.optsWithGlobals().selectOutput;
|
|
54791
|
+
if (raw === undefined) {
|
|
54792
|
+
await previous(command.processedArgs);
|
|
54793
|
+
return;
|
|
54794
|
+
}
|
|
54795
|
+
const typed = await readListValues(raw, SELECT_OUTPUT_FLAG);
|
|
54796
|
+
command.setOptionValue("selectOutput", typed);
|
|
54797
|
+
if (typed.every(isIdHeaded)) {
|
|
54798
|
+
await previous(command.processedArgs);
|
|
54799
|
+
return;
|
|
54800
|
+
}
|
|
54801
|
+
await readRunByName(runId, typed, command, connectGet());
|
|
54802
|
+
});
|
|
54803
|
+
}
|
|
54804
|
+
|
|
54450
54805
|
// src/commands/protocol/workflow-run-wait.ts
|
|
54451
54806
|
var TERMINAL_STATUSES = new Set(["completed", "failed", "cancelled"]);
|
|
54452
54807
|
var WAIT_EXIT_CODES = {
|
|
@@ -54880,6 +55235,14 @@ async function followRun(workflowId, command) {
|
|
|
54880
55235
|
throw new SimApiError(safeOneLine(typeof final.error === "string" ? final.error : "The workflow run failed."), 0);
|
|
54881
55236
|
}
|
|
54882
55237
|
}
|
|
55238
|
+
function stopBlockSelection(selection, flags) {
|
|
55239
|
+
const stopAfter = selection?.stopAfterBlockId;
|
|
55240
|
+
if (stopAfter === undefined)
|
|
55241
|
+
return null;
|
|
55242
|
+
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0)
|
|
55243
|
+
return null;
|
|
55244
|
+
return [BLOCK_ID.test(stopAfter) ? stopAfter : normalizeBlockName(stopAfter)];
|
|
55245
|
+
}
|
|
54883
55246
|
function followOrDelegate(previous) {
|
|
54884
55247
|
return async (workflowId, _options, command) => {
|
|
54885
55248
|
const initialFlags = command.optsWithGlobals();
|
|
@@ -54897,6 +55260,9 @@ function followOrDelegate(previous) {
|
|
|
54897
55260
|
if (selection)
|
|
54898
55261
|
command.setOptionValue("run", selection);
|
|
54899
55262
|
const flags = command.optsWithGlobals();
|
|
55263
|
+
const stopBlock = stopBlockSelection(selection, flags);
|
|
55264
|
+
if (stopBlock)
|
|
55265
|
+
command.setOptionValue("selectOutput", stopBlock);
|
|
54900
55266
|
if (flags.follow !== true) {
|
|
54901
55267
|
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0 && flags.async === true) {
|
|
54902
55268
|
throw new SimApiError("--select-output names outputs of a completed run, and --async returns as soon as the run is queued. Drop one of them, or read the finished run with: sim workflows runs get <runId> --workflow <workflowId> --select-output <blockName|blockId>[.path] — that resource takes the same selectors --select-output takes here.", 0);
|
|
@@ -54918,6 +55284,18 @@ function followOrDelegate(previous) {
|
|
|
54918
55284
|
await followRun(workflowId, command);
|
|
54919
55285
|
};
|
|
54920
55286
|
}
|
|
55287
|
+
var RUN_HELP = `
|
|
55288
|
+
Without --manual (or a flag that implies it) this runs the active deployment; a workflow never
|
|
55289
|
+
deployed has none. --manual runs the saved draft, as the source loop leaves it.
|
|
55290
|
+
|
|
55291
|
+
The result is the run: runId, status (completed, failed, paused or cancelled), error, output (the
|
|
55292
|
+
workflow's final output) and blockOutputs (what --select-output named). It has no success field:
|
|
55293
|
+
branch on status, or on the exit code. With --follow it is the stream's final frame
|
|
55294
|
+
instead: success and output.
|
|
55295
|
+
|
|
55296
|
+
Exit codes: 0 completed or paused (--async: queued); 1 failed or cancelled (the result is printed
|
|
55297
|
+
first, then the error on stderr), or the command failed; ${STILL_RUNNING_EXIT_CODE} still running when --wait-timeout
|
|
55298
|
+
elapsed.`;
|
|
54921
55299
|
function attachWorkflowRunFollow(workflows) {
|
|
54922
55300
|
const run = workflows.commands.find((command) => command.name() === "run");
|
|
54923
55301
|
if (!run) {
|
|
@@ -54926,113 +55304,7 @@ function attachWorkflowRunFollow(workflows) {
|
|
|
54926
55304
|
const held = run._actionHandler;
|
|
54927
55305
|
const previous = typeof held === "function" ? held : null;
|
|
54928
55306
|
callsOperations(run, ["executeWorkflow", "getWorkflowRun"], { runs: "executeWorkflow" });
|
|
54929
|
-
run.option("--manual", "Run the current saved workflow state instead of the active deployment").option("--trigger <blockId>", "Enter the run through this runnable trigger, by its block id; runs the current saved workflow state (implies --manual)").option("--mock-payload", "Use the selected trigger's server-derived mock payload; runs the current saved workflow state (implies --manual)").option("--from-block <block>", "Run manually from this saved workflow block: its id, display name or key").option("--source-run <runId>", "Prior run whose persisted state supplies upstream outputs (requires --from-block)").option("--stop-after <block>", "Stop the run after this saved block (its id, display name or key), failing it if the run takes a path that skips the block; with --from-block on the same block, re-runs only that block (implies --manual)").option("--dir <dir>", "This workflow's source directory: a failed run names the source file and line of the block that failed, read through its .sim/lock.json. Not with --async or --follow, and not for a run --wait-timeout leaves running").option(WAIT_TIMEOUT_FLAG, "Wait at most this many seconds for a synchronous run (0 waits until it settles). A run still going then continues in the background under async limits: the command prints its run record and exits 4, and `sim workflows runs wait` keeps waiting. Not with --async or --follow").option("--follow", "Stream the run as it happens; progress on stderr, result on stdout. The stream reports only success and output, so the result omits the run id and timings a non-streaming run returns").option("--include-thinking", "Show model reasoning while following (requires --follow)").option("--include-tool-calls", "Show tool calls while following (requires --follow)").action(followOrDelegate(previous));
|
|
54930
|
-
}
|
|
54931
|
-
|
|
54932
|
-
// src/commands/protocol/workflow-run-get.ts
|
|
54933
|
-
var BLOCK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
54934
|
-
var SELECT_OUTPUT_FLAG = "select-output";
|
|
54935
|
-
function normalizeBlockName(name) {
|
|
54936
|
-
return name.toLowerCase().replace(/\s+/g, "").replace(/\./g, "");
|
|
54937
|
-
}
|
|
54938
|
-
async function loadWorkflowBlocks(client, workflowId) {
|
|
54939
|
-
const raw = await client.request("getWorkflowState", { params: { workflowId } });
|
|
54940
|
-
const state = isRecordLike(raw) && isRecordLike(raw.data) ? raw.data : raw;
|
|
54941
|
-
const blocks = isRecordLike(state) && isRecordLike(state.blocks) ? Object.entries(state.blocks) : [];
|
|
54942
|
-
return blocks.map(([key, block]) => ({
|
|
54943
|
-
id: isRecordLike(block) && typeof block.id === "string" ? block.id : key,
|
|
54944
|
-
name: isRecordLike(block) && typeof block.name === "string" ? block.name : ""
|
|
54945
|
-
}));
|
|
54946
|
-
}
|
|
54947
|
-
function splitSelector(selector) {
|
|
54948
|
-
const dot = selector.indexOf(".");
|
|
54949
|
-
return dot === -1 ? { head: selector, path: "" } : { head: selector.slice(0, dot), path: selector.slice(dot) };
|
|
54950
|
-
}
|
|
54951
|
-
function isIdHeaded(selector) {
|
|
54952
|
-
return BLOCK_ID.test(splitSelector(selector).head);
|
|
54953
|
-
}
|
|
54954
|
-
function resolveSelection(typed, blocks, workflowId) {
|
|
54955
|
-
const resolved = [];
|
|
54956
|
-
const typedBy = new Map;
|
|
54957
|
-
const unresolved = [];
|
|
54958
|
-
for (const selector of typed) {
|
|
54959
|
-
const { head, path } = splitSelector(selector);
|
|
54960
|
-
let blockId = head;
|
|
54961
|
-
if (!BLOCK_ID.test(head)) {
|
|
54962
|
-
const wanted = normalizeBlockName(head);
|
|
54963
|
-
const matches = blocks.filter((block) => block.id === head || normalizeBlockName(block.name) === wanted);
|
|
54964
|
-
if (matches.length === 0) {
|
|
54965
|
-
unresolved.push(selector);
|
|
54966
|
-
continue;
|
|
54967
|
-
}
|
|
54968
|
-
if (matches.length > 1) {
|
|
54969
|
-
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} ${selector} names ${matches.length} blocks (${matches.map((block) => block.id).join(", ")}); pass the block id instead`, 0);
|
|
54970
|
-
}
|
|
54971
|
-
blockId = matches[0].id;
|
|
54972
|
-
}
|
|
54973
|
-
const rewritten = `${blockId}${path}`;
|
|
54974
|
-
resolved.push(rewritten);
|
|
54975
|
-
if (!typedBy.has(rewritten))
|
|
54976
|
-
typedBy.set(rewritten, selector);
|
|
54977
|
-
}
|
|
54978
|
-
if (unresolved.length > 0) {
|
|
54979
|
-
const names = blocks.map((block) => block.name).filter((name) => name !== "");
|
|
54980
|
-
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} did not resolve to any block on this run: ${unresolved.join(", ")}. Pass a block id or its name — "blockId", "blockId.path", "blockName" or "blockName.path"; names match ignoring case, spaces and dots. Blocks on workflow ${workflowId}: ${names.length > 0 ? names.join(", ") : "none"}.`, 0);
|
|
54981
|
-
}
|
|
54982
|
-
return { resolved, typedBy };
|
|
54983
|
-
}
|
|
54984
|
-
function keyByTyped(payload, typedBy) {
|
|
54985
|
-
if (!isRecordLike(payload) || !isRecordLike(payload.blockOutputs))
|
|
54986
|
-
return payload;
|
|
54987
|
-
const blockOutputs = {};
|
|
54988
|
-
for (const [key, value] of Object.entries(payload.blockOutputs)) {
|
|
54989
|
-
blockOutputs[typedBy.get(key) ?? key] = value;
|
|
54990
|
-
}
|
|
54991
|
-
return { ...payload, blockOutputs };
|
|
54992
|
-
}
|
|
54993
|
-
async function readRunByName(runId, typed, command, { client, profile }) {
|
|
54994
|
-
const flags = command.optsWithGlobals();
|
|
54995
|
-
const operation = V2_OPERATIONS.getWorkflowRun;
|
|
54996
|
-
const spec = CLI_CONTRACT.getWorkflowRun ?? {};
|
|
54997
|
-
await buildRequest("getWorkflowRun", [runId], flags, profile.workspaceId);
|
|
54998
|
-
const workflowId = String(flags.workflow);
|
|
54999
|
-
const selection = resolveSelection(typed, await loadWorkflowBlocks(client, workflowId), workflowId);
|
|
55000
|
-
const request = await buildRequest("getWorkflowRun", [runId], { ...flags, selectOutput: selection.resolved }, profile.workspaceId);
|
|
55001
|
-
let result;
|
|
55002
|
-
try {
|
|
55003
|
-
result = await client.request("getWorkflowRun", {
|
|
55004
|
-
params: request.params,
|
|
55005
|
-
headers: request.headers,
|
|
55006
|
-
query: request.query,
|
|
55007
|
-
body: request.body
|
|
55008
|
-
});
|
|
55009
|
-
} catch (error) {
|
|
55010
|
-
throw retypeApiError(error, "getWorkflowRun", spec, operation);
|
|
55011
|
-
}
|
|
55012
|
-
renderResult("getWorkflowRun", profile.output, keyByTyped(result?.data ?? result, selection.typedBy), spec, {}, result);
|
|
55013
|
-
}
|
|
55014
|
-
function attachWorkflowRunGet(runs) {
|
|
55015
|
-
const get = runs.commands.find((command) => command.name() === "get");
|
|
55016
|
-
const held = get?._actionHandler;
|
|
55017
|
-
if (!get || typeof held !== "function") {
|
|
55018
|
-
throw new Error("workflows runs get must be registered before block names can be attached to it");
|
|
55019
|
-
}
|
|
55020
|
-
const previous = held;
|
|
55021
|
-
const connectGet = callsOperations(get, ["getWorkflowRun", "getWorkflowState"]);
|
|
55022
|
-
get.action(async (runId, _options, command) => {
|
|
55023
|
-
const raw = command.optsWithGlobals().selectOutput;
|
|
55024
|
-
if (raw === undefined) {
|
|
55025
|
-
await previous(command.processedArgs);
|
|
55026
|
-
return;
|
|
55027
|
-
}
|
|
55028
|
-
const typed = await readListValues(raw, SELECT_OUTPUT_FLAG);
|
|
55029
|
-
command.setOptionValue("selectOutput", typed);
|
|
55030
|
-
if (typed.every(isIdHeaded)) {
|
|
55031
|
-
await previous(command.processedArgs);
|
|
55032
|
-
return;
|
|
55033
|
-
}
|
|
55034
|
-
await readRunByName(runId, typed, command, connectGet());
|
|
55035
|
-
});
|
|
55307
|
+
run.option("--manual", "Run the current saved workflow state instead of the active deployment").option("--trigger <blockId>", "Enter the run through this runnable trigger, by its block id; runs the current saved workflow state (implies --manual)").option("--mock-payload", "Use the selected trigger's server-derived mock payload; runs the current saved workflow state (implies --manual)").option("--from-block <block>", "Run manually from this saved workflow block: its id, display name or key").option("--source-run <runId>", "Prior run whose persisted state supplies upstream outputs (requires --from-block)").option("--stop-after <block>", "Stop the run after this saved block (its id, display name or key), failing it if the run takes a path that skips the block; with --from-block on the same block, re-runs only that block (implies --manual). Unless --select-output names others, blockOutputs holds the output of that block under its key (or id); output stays empty").option("--dir <dir>", "This workflow's source directory: a failed run names the source file and line of the block that failed, read through its .sim/lock.json. Not with --async or --follow, and not for a run --wait-timeout leaves running").option(WAIT_TIMEOUT_FLAG, "Wait at most this many seconds for a synchronous run (0 waits until it settles). A run still going then continues in the background under async limits: the command prints its run record and exits 4, and `sim workflows runs wait` keeps waiting. Not with --async or --follow").option("--follow", "Stream the run as it happens; progress on stderr, result on stdout. The stream reports only success and output, so the result omits the run id and timings a non-streaming run returns").option("--include-thinking", "Show model reasoning while following (requires --follow)").option("--include-tool-calls", "Show tool calls while following (requires --follow)").addHelpText("after", RUN_HELP).action(followOrDelegate(previous));
|
|
55036
55308
|
}
|
|
55037
55309
|
|
|
55038
55310
|
// ../../node_modules/minisearch/dist/es/index.js
|
|
@@ -56248,7 +56520,7 @@ function sourceExitCodeRows(prefix) {
|
|
|
56248
56520
|
"workflows source apply": "the source has errors (each printed as file:line:column with its frame and hint) or the command failed",
|
|
56249
56521
|
"workflows source create": "the source has errors (each printed as file:line:column with its frame and hint), the workflow name is taken (SOURCE_NAME_TAKEN: pass --name), or the command failed (a starter is created in the workspace its types were written for unless --workspace names another)",
|
|
56250
56522
|
"workflows source get": "the command failed, the directory is a workspace source directory (SOURCE_DIR_KIND_MISMATCH, even with --force), or it holds another workflow's source (SOURCE_WORKFLOW_MISMATCH) or edits no apply has saved (SOURCE_LOCAL_EDITS: apply them, get into another directory, or pass --force)",
|
|
56251
|
-
"workspaces source apply": "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
|
|
56523
|
+
"workspaces source apply": "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 names (SOURCE_OTHER_WORKSPACE: drop --workspace, or promote it with --to; without --workspace 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), or the command failed",
|
|
56252
56524
|
"workspaces source get": "the command failed, the directory holds edits no apply has saved (SOURCE_LOCAL_EDITS: apply them, get into another directory, or pass --force), --workspace names another workspace than the one the directory was read from (SOURCE_OTHER_WORKSPACE), the directory is a workflow source directory (SOURCE_DIR_KIND_MISMATCH, even with --force), or a downloaded binary file does not match its listing (SOURCE_BLOB_MISMATCH: nothing was written)"
|
|
56253
56525
|
}
|
|
56254
56526
|
},
|
|
@@ -56348,10 +56620,10 @@ function sourceExitCodeRows(prefix) {
|
|
|
56348
56620
|
},
|
|
56349
56621
|
{
|
|
56350
56622
|
code: SOURCE_HELD_EXIT_CODE,
|
|
56351
|
-
meaning: "`sim workspaces source apply` (or `--to`) wrote part of its plan and held the rest back: a change that uses a declared secret the workspace has no value for, or a credential key nothing binds to",
|
|
56623
|
+
meaning: "`sim workspaces source apply` (or `--to`) wrote part of its plan and held the rest back: a change that uses a declared secret the workspace has no value for, or a credential key nothing binds to. Its dry run exits 15 too, so a script can tell beforehand that the apply would write only part",
|
|
56352
56624
|
next: "Set the secret (`sim secrets set`) or connect the credential, then apply again",
|
|
56353
56625
|
help: {
|
|
56354
|
-
"workspaces source apply": "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)"
|
|
56626
|
+
"workspaces source apply": "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"
|
|
56355
56627
|
}
|
|
56356
56628
|
},
|
|
56357
56629
|
{
|
|
@@ -57116,7 +57388,7 @@ async function runSourceWrite(flow) {
|
|
|
57116
57388
|
preview = await flow.preview();
|
|
57117
57389
|
flow.show(preview);
|
|
57118
57390
|
if (preview.diagnostics.some((finding) => finding.severity === "error")) {
|
|
57119
|
-
setSoftExitCode(refusedExitCode(preview.diagnostics));
|
|
57391
|
+
setSoftExitCode(flow.previewExitCode?.(preview) ?? refusedExitCode(preview.diagnostics));
|
|
57120
57392
|
}
|
|
57121
57393
|
if (flow.mode === "dry-run" || flow.refuses(preview)) {
|
|
57122
57394
|
flow.report(preview);
|
|
@@ -57316,12 +57588,18 @@ async function readBase(directory, workflowId) {
|
|
|
57316
57588
|
}
|
|
57317
57589
|
return base;
|
|
57318
57590
|
}
|
|
57591
|
+
var WORKFLOW_GET = `\`sim workflows source get <workflowId> --dir <new dir>\`, with the id from ${SOURCE_BASE_FILE}`;
|
|
57592
|
+
function lockRecoveryHint(get = WORKFLOW_GET) {
|
|
57593
|
+
return `Restore ${SOURCE_LOCK_FILE} from version control, or write the source into a fresh directory (${get}) and carry your edits across.`;
|
|
57594
|
+
}
|
|
57595
|
+
function lockProblem(finding) {
|
|
57596
|
+
return `${finding.path ? `${finding.path}: ` : ""}${finding.message}`;
|
|
57597
|
+
}
|
|
57319
57598
|
async function readLock(directory) {
|
|
57320
57599
|
const parsed = parseWorkflowLock(await readJson(directory, SOURCE_LOCK_FILE, GET_HINT));
|
|
57321
57600
|
if (parsed.lock)
|
|
57322
57601
|
return parsed.lock;
|
|
57323
|
-
|
|
57324
|
-
throw new SourceDirError(`${SOURCE_LOCK_FILE} in ${directory} is not a valid lock: ${problems.join("; ")}`);
|
|
57602
|
+
throw new SourceDirError(`${SOURCE_LOCK_FILE} in ${directory} is not a valid lock: ${parsed.diagnostics.map(lockProblem).join("; ")}. ${lockRecoveryHint()}`);
|
|
57325
57603
|
}
|
|
57326
57604
|
function requireEntry(directory) {
|
|
57327
57605
|
return requireText(directory, SOURCE_ENTRY_FILE, GET_HINT);
|
|
@@ -57360,7 +57638,7 @@ The primer above is enough to edit; read a section here when a step needs it.
|
|
|
57360
57638
|
|
|
57361
57639
|
## Edit loop in detail
|
|
57362
57640
|
|
|
57363
|
-
1. Edit \`${SOURCE_ENTRY_FILE}\` (and \`functions/*\`). \`${SOURCE_EXAMPLES_DIR}/\` holds correct examples to copy from: \`cookbook.ts\` (agent with structured output, condition, function, table query and
|
|
57641
|
+
1. Edit \`${SOURCE_ENTRY_FILE}\` (and \`functions/*\`). \`${SOURCE_EXAMPLES_DIR}/\` holds correct examples to copy from: \`cookbook.ts\` (agent with structured output, condition, function, table query and upsert, knowledge search, Slack, human in the loop, loop, response), \`integrations.ts\` (webhook trigger, weekday cron schedule, HTTP request with headers, table update by row id, Gmail, an error path) and \`agents.ts\` (router, agent tools: custom tool, MCP tool, integration operation, child workflow; run a child workflow; parallel). Their resource keys are examples; this workspace's are in \`${WORKSPACE_TYPES_FILE}\`.
|
|
57364
57642
|
2. \`sim workflows source check --dir .\`: compiles offline with the server's compiler, in milliseconds. It catches what \`tsc\` cannot (duplicate names, cycles, literal secrets), and fails (exit 1) on a missing required field, an unknown option or output path, a wrong value kind, an out-of-range value, an unwired condition or router branch or a literal secret in a block you added (\`--strict\`: in every block). It also adds the blocks the source now uses to \`tsconfig.json\`.
|
|
57365
57643
|
3. \`${typecheckCommand()}\`: about a second; catches what step 2 and the dry run do not (such as a reference to a start input the trigger does not declare). It runs the TypeScript release the declarations are built for (the directory has no \`package.json\`; plain \`bunx tsc\` would run whatever version it finds). \`tsconfig.json\` includes only the blocks the source used at the last check, get or apply: a builder from another block fails with \`has no exported member\` until you run step 2 (or use \`${typecheckCommand(TSCONFIG_FULL_FILE)}\`, every current block). The dry run is the authority: a printed line you did not edit that \`tsc\` flags and the dry run accepts is fine.
|
|
57366
57644
|
4. \`sim workflows source status --dir .\`: the files you changed (\`sim workflows source diff --dir .\` shows the edits), whether the workflow changed on the server since the get, and the command to run next (\`--offline\`: skip the server). Then \`sim workflows source apply --dir . --dry-run\` until it exits 0.
|
|
@@ -57832,7 +58110,7 @@ function summarize(data, creating, machine) {
|
|
|
57832
58110
|
import { join as join9 } from "node:path";
|
|
57833
58111
|
|
|
57834
58112
|
// ../workspace-code/src/declaration/read.ts
|
|
57835
|
-
var
|
|
58113
|
+
var import_parser6 = __toESM(require_lib(), 1);
|
|
57836
58114
|
|
|
57837
58115
|
// ../workspace-code/src/limits.ts
|
|
57838
58116
|
var WORKSPACE_SOURCE_LIMITS = {
|
|
@@ -57956,7 +58234,7 @@ function readDeclaration(file, raw, options) {
|
|
|
57956
58234
|
}
|
|
57957
58235
|
let program;
|
|
57958
58236
|
try {
|
|
57959
|
-
program =
|
|
58237
|
+
program = import_parser6.parse(text, PARSER_OPTIONS2).program;
|
|
57960
58238
|
} catch (error) {
|
|
57961
58239
|
if (error instanceof RangeError) {
|
|
57962
58240
|
diagnostics.push(diagnostic2("E_LIMIT_EXCEEDED", "The file is nested too deeply to parse.", { ...at(0, 0) }));
|
|
@@ -62316,7 +62594,7 @@ var ZodRealError = $constructor("ZodError", initializer2, {
|
|
|
62316
62594
|
});
|
|
62317
62595
|
|
|
62318
62596
|
// ../../node_modules/zod/v4/classic/parse.js
|
|
62319
|
-
var
|
|
62597
|
+
var parse9 = /* @__PURE__ */ _parse(ZodRealError);
|
|
62320
62598
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
62321
62599
|
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
62322
62600
|
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
@@ -62359,7 +62637,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
62359
62637
|
reg.add(inst, meta);
|
|
62360
62638
|
return inst;
|
|
62361
62639
|
};
|
|
62362
|
-
inst.parse = (data, params) =>
|
|
62640
|
+
inst.parse = (data, params) => parse9(inst, data, params, { callee: inst.parse });
|
|
62363
62641
|
inst.safeParse = (data, params) => safeParse2(inst, data, params);
|
|
62364
62642
|
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
62365
62643
|
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
@@ -64378,9 +64656,11 @@ var STRICT_CODES = new Set([
|
|
|
64378
64656
|
"W_LITERAL_SECRET",
|
|
64379
64657
|
"W_TABLE_UNKNOWN_COLUMN",
|
|
64380
64658
|
"W_CHILD_INPUT_UNKNOWN",
|
|
64659
|
+
"W_CHILD_RESULT_PATH",
|
|
64381
64660
|
"W_BRANCH_UNWIRED",
|
|
64382
64661
|
"W_UNRESOLVED_REF",
|
|
64383
|
-
"W_REF_OUT_OF_SCOPE"
|
|
64662
|
+
"W_REF_OUT_OF_SCOPE",
|
|
64663
|
+
"W_LOOP_CONDITION_SYNTAX"
|
|
64384
64664
|
]);
|
|
64385
64665
|
var STORED_EXEMPT_CODES = new Set(["W_BRANCH_UNWIRED"]);
|
|
64386
64666
|
var EDIT_SCOPED_CODES = new Set(["W_JSON_REF_UNTYPED"]);
|
|
@@ -64469,25 +64749,29 @@ function inputMappingOf(canonical) {
|
|
|
64469
64749
|
const value = rowJson(mapping.value);
|
|
64470
64750
|
return toRecord(value);
|
|
64471
64751
|
}
|
|
64472
|
-
function
|
|
64752
|
+
function calledWorkflowKey(canonical) {
|
|
64473
64753
|
const ref = canonical.params.workflowId;
|
|
64474
64754
|
const child = ref?.kind === "value" ? resourceNode(ref.value) : null;
|
|
64475
|
-
|
|
64755
|
+
return child?.kind === "workflow" ? child.key : null;
|
|
64756
|
+
}
|
|
64757
|
+
function childInputFindings(block, canonical, declarations) {
|
|
64758
|
+
const childKey = calledWorkflowKey(canonical);
|
|
64759
|
+
if (childKey === null)
|
|
64476
64760
|
return [];
|
|
64477
|
-
const inputs = declarations.workflowInputs?.get(
|
|
64761
|
+
const inputs = declarations.workflowInputs?.get(childKey);
|
|
64478
64762
|
if (inputs === undefined)
|
|
64479
64763
|
return [];
|
|
64480
|
-
const entry = `${KIND_DIRS.workflow}/${
|
|
64764
|
+
const entry = `${KIND_DIRS.workflow}/${childKey}/${SOURCE_ENTRY_FILE}`;
|
|
64481
64765
|
if (inputs === null) {
|
|
64482
64766
|
return [
|
|
64483
64767
|
{
|
|
64484
64768
|
code: "W_CHILD_NO_START",
|
|
64485
64769
|
severity: "warning",
|
|
64486
|
-
message: `Workflow "${
|
|
64770
|
+
message: `Workflow "${childKey}" has no Start trigger, so it takes no inputs and a call cannot run it.`,
|
|
64487
64771
|
hint: `Add trigger.start('Start', { inputFormat: { … } }) to ${entry}, or call a workflow that has one.`,
|
|
64488
64772
|
block,
|
|
64489
64773
|
param: "workflowId",
|
|
64490
|
-
names:
|
|
64774
|
+
names: childKey
|
|
64491
64775
|
}
|
|
64492
64776
|
];
|
|
64493
64777
|
}
|
|
@@ -64495,12 +64779,65 @@ function childInputFindings(block, canonical, declarations) {
|
|
|
64495
64779
|
return Object.keys(inputMappingOf(canonical)).filter((field) => !names.includes(field)).map((field) => ({
|
|
64496
64780
|
code: "W_CHILD_INPUT_UNKNOWN",
|
|
64497
64781
|
severity: "warning",
|
|
64498
|
-
message: `inputMapping sets ${field}, which is not an input of workflow "${
|
|
64782
|
+
message: `inputMapping sets ${field}, which is not an input of workflow "${childKey}"; the child never receives it.`,
|
|
64499
64783
|
hint: names.length > 0 ? `${didYouMean(field, names) ?? ""} Inputs (the Start trigger's inputFormat in ${entry}): ${listed2(names)}.`.trimStart() : `The Start trigger of ${entry} declares no inputs: add ${field} to its inputFormat.`,
|
|
64500
64784
|
block,
|
|
64501
64785
|
param: "inputMapping"
|
|
64502
64786
|
}));
|
|
64503
64787
|
}
|
|
64788
|
+
function childResultFindings(workflow, declarations) {
|
|
64789
|
+
const responding = declarations.respondingWorkflows;
|
|
64790
|
+
if (!responding || responding.size === 0)
|
|
64791
|
+
return [];
|
|
64792
|
+
const calls = new Map;
|
|
64793
|
+
for (const [key, block] of Object.entries(workflow.blocks)) {
|
|
64794
|
+
const child = calledWorkflowKey(block);
|
|
64795
|
+
if (child !== null && responding.has(child))
|
|
64796
|
+
calls.set(key, child);
|
|
64797
|
+
}
|
|
64798
|
+
if (calls.size === 0)
|
|
64799
|
+
return [];
|
|
64800
|
+
const findings = [];
|
|
64801
|
+
for (const [block, canonical] of Object.entries(workflow.blocks)) {
|
|
64802
|
+
for (const [param, value] of Object.entries(canonical.params)) {
|
|
64803
|
+
if (value.kind !== "value")
|
|
64804
|
+
continue;
|
|
64805
|
+
const reported = new Set;
|
|
64806
|
+
const leaves = [];
|
|
64807
|
+
collectStringLeaves(value.value, leaves);
|
|
64808
|
+
for (const text of leaves) {
|
|
64809
|
+
for (const token of findWorkflowReferenceTokens(text)) {
|
|
64810
|
+
if (token.kind !== "workflow" || reported.has(token.value))
|
|
64811
|
+
continue;
|
|
64812
|
+
const segments = parseStoredPath(token.value.slice(1, -1));
|
|
64813
|
+
const [head, output, field, ...rest] = segments ?? [];
|
|
64814
|
+
const child = head?.kind === "name" ? calls.get(head.name) : undefined;
|
|
64815
|
+
if (child === undefined || output?.kind !== "name" || output.name !== "result")
|
|
64816
|
+
continue;
|
|
64817
|
+
if (field?.kind !== "name" || RESPONSE_OUTPUTS.includes(field.name))
|
|
64818
|
+
continue;
|
|
64819
|
+
reported.add(token.value);
|
|
64820
|
+
const meant = formatStoredPath([
|
|
64821
|
+
head,
|
|
64822
|
+
output,
|
|
64823
|
+
{ kind: "name", name: "data" },
|
|
64824
|
+
field,
|
|
64825
|
+
...rest
|
|
64826
|
+
]);
|
|
64827
|
+
findings.push({
|
|
64828
|
+
code: "W_CHILD_RESULT_PATH",
|
|
64829
|
+
severity: "warning",
|
|
64830
|
+
message: `${token.value} reads ${field.name} from the result of workflow "${child}", which responds: its result is the Response output ({ data, status, headers }), so the path reads nothing.`,
|
|
64831
|
+
hint: `Did you mean <${meant}>? A field of the child's Response data is result.data.${field.name}.`,
|
|
64832
|
+
block,
|
|
64833
|
+
param
|
|
64834
|
+
});
|
|
64835
|
+
}
|
|
64836
|
+
}
|
|
64837
|
+
}
|
|
64838
|
+
}
|
|
64839
|
+
return findings;
|
|
64840
|
+
}
|
|
64504
64841
|
function declarationFindings(workflow, declarations) {
|
|
64505
64842
|
const findings = [];
|
|
64506
64843
|
for (const [block, canonical] of Object.entries(workflow.blocks)) {
|
|
@@ -64569,10 +64906,13 @@ function declarationFindings(workflow, declarations) {
|
|
|
64569
64906
|
}
|
|
64570
64907
|
}
|
|
64571
64908
|
}
|
|
64909
|
+
findings.push(...childResultFindings(workflow, declarations));
|
|
64572
64910
|
return findings;
|
|
64573
64911
|
}
|
|
64574
64912
|
async function compileWorkflowDir(dir, workspaceCatalog, declarations) {
|
|
64575
|
-
const
|
|
64913
|
+
const lockText = await readSourceText(dir, SOURCE_LOCK_FILE);
|
|
64914
|
+
const parsedLock = lockText === null ? null : parseWorkflowLock(lockText);
|
|
64915
|
+
const lock = parsedLock?.lock;
|
|
64576
64916
|
const [files, storedEdges, storedBlocks, printedWith] = await Promise.all([
|
|
64577
64917
|
readSourceFiles(dir, lock ?? null),
|
|
64578
64918
|
readStoredEdges(dir),
|
|
@@ -64591,16 +64931,35 @@ async function compileWorkflowDir(dir, workspaceCatalog, declarations) {
|
|
|
64591
64931
|
...storedEdges ? { storedUnreadEdges: storedEdges } : {},
|
|
64592
64932
|
...envNames ? { envNames, envDeclaredIn: KIND_DIRS.secret } : {}
|
|
64593
64933
|
});
|
|
64594
|
-
return {
|
|
64934
|
+
return {
|
|
64935
|
+
lock,
|
|
64936
|
+
lockProblems: parsedLock?.diagnostics ?? [],
|
|
64937
|
+
files,
|
|
64938
|
+
compiled,
|
|
64939
|
+
storedBlocks,
|
|
64940
|
+
printedWith,
|
|
64941
|
+
catalog
|
|
64942
|
+
};
|
|
64943
|
+
}
|
|
64944
|
+
async function readCheckDeclarations(root, catalog) {
|
|
64945
|
+
const [declared, workflows] = await Promise.all([
|
|
64946
|
+
readWorkspaceDeclarations(root),
|
|
64947
|
+
compileWorkspaceWorkflows(root, catalog)
|
|
64948
|
+
]);
|
|
64949
|
+
return { ...declared, ...workflows };
|
|
64595
64950
|
}
|
|
64596
|
-
async function
|
|
64597
|
-
const
|
|
64951
|
+
async function compileWorkspaceWorkflows(root, catalog) {
|
|
64952
|
+
const workflowInputs = new Map;
|
|
64953
|
+
const respondingWorkflows = new Set;
|
|
64598
64954
|
for (const key of await workspaceWorkflowKeys(root)) {
|
|
64599
64955
|
const { compiled } = await compileWorkflowDir(join9(root, KIND_DIRS.workflow, key), catalog);
|
|
64600
|
-
if (compiled.workflow)
|
|
64601
|
-
|
|
64956
|
+
if (!compiled.workflow)
|
|
64957
|
+
continue;
|
|
64958
|
+
workflowInputs.set(key, startInputs(compiled.workflow));
|
|
64959
|
+
if (respondsOnEveryRun(compiled.workflow))
|
|
64960
|
+
respondingWorkflows.add(key);
|
|
64602
64961
|
}
|
|
64603
|
-
return
|
|
64962
|
+
return { workflowInputs, respondingWorkflows };
|
|
64604
64963
|
}
|
|
64605
64964
|
function withWorkflowInputs(local, inputs) {
|
|
64606
64965
|
const workflows = { ...local.workflows };
|
|
@@ -64613,7 +64972,7 @@ function withWorkflowInputs(local, inputs) {
|
|
|
64613
64972
|
}
|
|
64614
64973
|
async function checkWorkflowDir(dir, catalog, options) {
|
|
64615
64974
|
const compiledDir = await compileWorkflowDir(dir, catalog, options.declarations);
|
|
64616
|
-
const { lock, files, compiled, storedBlocks, printedWith } = compiledDir;
|
|
64975
|
+
const { lock, lockProblems, files, compiled, storedBlocks, printedWith } = compiledDir;
|
|
64617
64976
|
const entryText = files[SOURCE_ENTRY_FILE];
|
|
64618
64977
|
const locate = (block, param, names) => {
|
|
64619
64978
|
const prefix = encodeAnchor({ kind: "param", block, param: "" });
|
|
@@ -64693,6 +65052,14 @@ async function checkWorkflowDir(dir, catalog, options) {
|
|
|
64693
65052
|
}, { changed, codeEdited }),
|
|
64694
65053
|
...compiled.diagnostics.filter(exempt)
|
|
64695
65054
|
];
|
|
65055
|
+
const lockFindings = lockProblems.map((problem) => ({
|
|
65056
|
+
code: problem.code,
|
|
65057
|
+
severity: "error",
|
|
65058
|
+
message: `${problem.message} Every apply and status refuses this lock.`,
|
|
65059
|
+
hint: lockRecoveryHint(options.declarations ? "`sim workspaces source get --dir <new dir>`, from the workspace directory" : undefined),
|
|
65060
|
+
file: `${prefix}${SOURCE_LOCK_FILE}`,
|
|
65061
|
+
...problem.path ? { path: problem.path } : {}
|
|
65062
|
+
}));
|
|
64696
65063
|
const findings = [
|
|
64697
65064
|
...refused.filter((diagnostic) => reported(diagnostic.code, diagnostic.blockKey)),
|
|
64698
65065
|
...declared
|
|
@@ -64740,7 +65107,7 @@ async function checkWorkflowDir(dir, catalog, options) {
|
|
|
64740
65107
|
else
|
|
64741
65108
|
unlisted.warnings += count;
|
|
64742
65109
|
}
|
|
64743
|
-
return { findings, entry: entryText, unlisted };
|
|
65110
|
+
return { findings: [...lockFindings, ...findings], entry: entryText, unlisted };
|
|
64744
65111
|
}
|
|
64745
65112
|
function reportCheck(output, findings, result, options = {}) {
|
|
64746
65113
|
const shown = findingsOutput(output, options.verbose, options.dir);
|
|
@@ -64793,10 +65160,7 @@ function attachWorkflowSourceCheck(source) {
|
|
|
64793
65160
|
throw new CliUsageError(`${options.dir} has no ${SOURCE_BASE_FILE} and no workspace is selected: pass --workspace <workspaceId>.`);
|
|
64794
65161
|
}
|
|
64795
65162
|
const catalog = cachedOrRefuse(await cachedSourceCatalog(options.dir) ?? cachedCatalog(workspaceId), workspaceId, workspace ? `\`sim workspaces source get --dir ${workspace.root}\`` : `\`sim workflows source get <workflowId> --dir ${options.dir}\` (or \`create\`)`);
|
|
64796
|
-
const declarations = workspace ?
|
|
64797
|
-
...await readWorkspaceDeclarations(workspace.root),
|
|
64798
|
-
workflowInputs: await workspaceWorkflowInputs(workspace.root, catalog)
|
|
64799
|
-
} : undefined;
|
|
65163
|
+
const declarations = workspace ? await readCheckDeclarations(workspace.root, catalog) : undefined;
|
|
64800
65164
|
const { findings, entry, unlisted } = await checkWorkflowDir(options.dir, catalog, {
|
|
64801
65165
|
strict: strictMode(options),
|
|
64802
65166
|
...declarations ? { declarations } : {}
|
|
@@ -64897,8 +65261,9 @@ Prints a builder's params (required first, with enums and defaults), the gate fi
|
|
|
64897
65261
|
which others apply, and its outputs, from the block catalog the last get, create or check cached.
|
|
64898
65262
|
No request is made. <builder> is the dotted builder path as source writes it: table.upsertRow,
|
|
64899
65263
|
agent, trigger.schedule, slack.sendMessage (slack.tool.sendMessage names the same builder). A
|
|
64900
|
-
namespace (gmail, trigger.gmail) lists its builders; a
|
|
64901
|
-
|
|
65264
|
+
namespace (gmail, trigger.gmail) lists its builders; a block type prints the builder written for
|
|
65265
|
+
it (function is fn) or lists them (table_v2); a construct core.d.ts declares (loop, parallel, t,
|
|
65266
|
+
env) prints its declaration. Run it from a workflow or workspace source directory,
|
|
64902
65267
|
or pass --dir.
|
|
64903
65268
|
|
|
64904
65269
|
Exit codes: 0 printed; 1 no builder or namespace of that name (the closest one is named), or no
|
|
@@ -65565,10 +65930,14 @@ function splitLines2(text) {
|
|
|
65565
65930
|
return result;
|
|
65566
65931
|
}
|
|
65567
65932
|
// src/commands/protocol/source-status.ts
|
|
65568
|
-
function planFindings(diagnostics
|
|
65569
|
-
return diagnostics.filter((finding) =>
|
|
65933
|
+
function planFindings(diagnostics) {
|
|
65934
|
+
return diagnostics.filter((finding) => finding.severity === "error" || finding.severity === "warning" || finding.code === "I_FINDINGS_TRUNCATED");
|
|
65570
65935
|
}
|
|
65571
65936
|
var STATUS_EXIT_CODES_HELP = `
|
|
65937
|
+
With --json, \`plan\` is what applying would do as \`apply --dry-run --allow-delete\` reports it
|
|
65938
|
+
(its errors and warnings counted the same, a conflict as an error), and \`next\` the command to
|
|
65939
|
+
run (with --allow-delete only when the plan deletes something).
|
|
65940
|
+
|
|
65572
65941
|
Exit codes: 0 clean (nothing to apply, and the server changed nothing since the directory was
|
|
65573
65942
|
read); ${SOURCE_LOCAL_CHANGES_EXIT_CODE} local changes only (applying writes them); ${SOURCE_DRIFT_EXIT_CODE} the server changed since the
|
|
65574
65943
|
directory was read: drift (a resource edited, added or deleted there that the directory leaves
|
|
@@ -65841,7 +66210,7 @@ async function readLocalWorkflow(dir) {
|
|
|
65841
66210
|
};
|
|
65842
66211
|
}
|
|
65843
66212
|
function workflowPlanFindings(data) {
|
|
65844
|
-
return planFindings(data.diagnostics
|
|
66213
|
+
return planFindings(data.diagnostics).filter((finding) => finding.code !== "E_APPLY_STALE");
|
|
65845
66214
|
}
|
|
65846
66215
|
function planSummary(data) {
|
|
65847
66216
|
const planned = workflowPlanFindings(data);
|
|
@@ -65852,12 +66221,14 @@ function planSummary(data) {
|
|
|
65852
66221
|
blocksModified: data.diff.blocks.modified.length,
|
|
65853
66222
|
edgesAdded: data.diff.edges.added,
|
|
65854
66223
|
edgesRemoved: data.diff.edges.removed,
|
|
66224
|
+
variablesRemoved: data.diff.variables.removed.length,
|
|
65855
66225
|
errors: findings("error"),
|
|
65856
66226
|
warnings: findings("warning")
|
|
65857
66227
|
};
|
|
65858
66228
|
}
|
|
65859
66229
|
function planLine(plan) {
|
|
65860
|
-
|
|
66230
|
+
const variables = plan.variablesRemoved > 0 ? `, variables -${plan.variablesRemoved}` : "";
|
|
66231
|
+
return `Applying would: blocks +${plan.blocksAdded} -${plan.blocksRemoved} ~${plan.blocksModified}, connections +${plan.edgesAdded} -${plan.edgesRemoved}${variables}; ${plan.errors} error(s), ${plan.warnings} warning(s).`;
|
|
65861
66232
|
}
|
|
65862
66233
|
function attachWorkflowSourceStatus(source) {
|
|
65863
66234
|
const [command, connect] = apiCommand(source, "status", [
|
|
@@ -65935,7 +66306,7 @@ function attachWorkflowSourceStatus(source) {
|
|
|
65935
66306
|
getArgs: `${workflowId} `,
|
|
65936
66307
|
server,
|
|
65937
66308
|
errors: plan?.errors ?? 0,
|
|
65938
|
-
deletes: (plan?.blocksRemoved ?? 0) > 0,
|
|
66309
|
+
deletes: (plan?.blocksRemoved ?? 0) + (plan?.variablesRemoved ?? 0) > 0,
|
|
65939
66310
|
scope: "",
|
|
65940
66311
|
login
|
|
65941
66312
|
})
|
|
@@ -66213,11 +66584,19 @@ function failedExitCode(failed) {
|
|
|
66213
66584
|
return failed.code === "E_APPLY_FAILED" ? SOURCE_PARTIAL_EXIT_CODE : refusedExitCode([{ code: failed.code, severity: "error" }]);
|
|
66214
66585
|
}
|
|
66215
66586
|
function isHeldFinding(plan, finding) {
|
|
66216
|
-
return plan.some((change) => change.held && change.kind === finding.kind && change.key === finding.key);
|
|
66587
|
+
return finding.code !== "E_PLAN_REF_DELETED" && plan.some((change) => change.held && change.kind === finding.kind && change.key === finding.key);
|
|
66217
66588
|
}
|
|
66218
66589
|
function refusesApply(data) {
|
|
66590
|
+
if (data.refuses !== undefined)
|
|
66591
|
+
return data.refuses;
|
|
66219
66592
|
return data.diagnostics.some((finding) => finding.severity === "error" && !isHeldFinding(data.plan, finding));
|
|
66220
66593
|
}
|
|
66594
|
+
function previewExitCode(data) {
|
|
66595
|
+
if (refusesApply(data))
|
|
66596
|
+
return refusedExitCode(data.diagnostics);
|
|
66597
|
+
const writesSome = data.plan.some((change) => change.action !== "noop" && !change.held);
|
|
66598
|
+
return writesSome ? SOURCE_HELD_EXIT_CODE : 1;
|
|
66599
|
+
}
|
|
66221
66600
|
var sameChange = (a, b) => a.kind === b.kind && a.key === b.key;
|
|
66222
66601
|
function wasWritten(change, outcome) {
|
|
66223
66602
|
return outcome.applied.some((written) => sameChange(written, change));
|
|
@@ -66651,6 +67030,7 @@ function attachWorkspaceSourceApply(source) {
|
|
|
66651
67030
|
findings.print(preview.diagnostics);
|
|
66652
67031
|
},
|
|
66653
67032
|
refuses: refusesApply,
|
|
67033
|
+
previewExitCode,
|
|
66654
67034
|
beforeCommit: (preview) => stage(submission, preview ? new Set(preview.needBlobs) : blobsToStage(submission)),
|
|
66655
67035
|
commit: async () => {
|
|
66656
67036
|
const answer = reported(await send(submission, false));
|
|
@@ -66863,11 +67243,7 @@ ${SOURCE_DIR_BUSY_HELP}`).action(async (options, command) => {
|
|
|
66863
67243
|
}
|
|
66864
67244
|
await withSourceDirLock(options.dir, async () => {
|
|
66865
67245
|
const catalog = cachedCatalog(workspaceId) ?? await fetchedCatalog(connect, workspaceId, options.dir);
|
|
66866
|
-
const
|
|
66867
|
-
const declarations = {
|
|
66868
|
-
...await readWorkspaceDeclarations(options.dir),
|
|
66869
|
-
workflowInputs
|
|
66870
|
-
};
|
|
67246
|
+
const declarations = await readCheckDeclarations(options.dir, catalog);
|
|
66871
67247
|
const keys = await workspaceWorkflowKeys(options.dir);
|
|
66872
67248
|
const findings = [];
|
|
66873
67249
|
const unlisted = { errors: 0, warnings: 0 };
|
|
@@ -66900,7 +67276,7 @@ ${SOURCE_DIR_BUSY_HELP}`).action(async (options, command) => {
|
|
|
66900
67276
|
column
|
|
66901
67277
|
});
|
|
66902
67278
|
}
|
|
66903
|
-
await refreshWorkspaceTypes(options.dir, withWorkflowInputs(declarations.local, workflowInputs));
|
|
67279
|
+
await refreshWorkspaceTypes(options.dir, withWorkflowInputs(declarations.local, declarations.workflowInputs));
|
|
66904
67280
|
await refreshWorkspaceTsconfigs(options.dir, workspaceId);
|
|
66905
67281
|
reportCheck(profile.output, findings, { workflows: keys.length, catalogHash: catalog.hash }, {
|
|
66906
67282
|
verbose: options.verbose === true,
|
|
@@ -67172,8 +67548,8 @@ function aboutWorkflowSentByBase(item, byBase) {
|
|
|
67172
67548
|
function planAsApplied(plan, byBase) {
|
|
67173
67549
|
return plan.map((change) => aboutWorkflowSentByBase(change, byBase) && change.action !== "noop" ? { kind: change.kind, key: change.key, action: "noop" } : change);
|
|
67174
67550
|
}
|
|
67175
|
-
function
|
|
67176
|
-
return planFindings(data.diagnostics
|
|
67551
|
+
function dryRunFindings(data, byBase) {
|
|
67552
|
+
return planFindings(data.diagnostics).filter((finding) => !(aboutWorkflowSentByBase(finding, byBase) && (isFolderEvaluationFinding(finding) || finding.code === "E_APPLY_STALE")));
|
|
67177
67553
|
}
|
|
67178
67554
|
function planSummary2(findings, plan, conflicts) {
|
|
67179
67555
|
const count = (...actions) => plan.filter((change) => actions.includes(change.action)).length;
|
|
@@ -67191,7 +67567,7 @@ function planSummary2(findings, plan, conflicts) {
|
|
|
67191
67567
|
}
|
|
67192
67568
|
function planLine2(plan) {
|
|
67193
67569
|
const counts = `${plan.create} create, ${plan.update} update, ${plan.delete} delete (${plan.unchanged} unchanged); ${plan.errors} error(s), ${plan.warnings} warning(s)`;
|
|
67194
|
-
return plan.conflicts > 0 ? `Applying would be refused as stale (exit ${SOURCE_STALE_EXIT_CODE}): ${plan.conflicts} conflict(s) above.
|
|
67570
|
+
return plan.conflicts > 0 ? `Applying would be refused as stale (exit ${SOURCE_STALE_EXIT_CODE}): the ${plan.conflicts} conflict(s) above. Its dry run: ${counts}.` : `Applying would: ${counts}.`;
|
|
67195
67571
|
}
|
|
67196
67572
|
function fitsWhole(files) {
|
|
67197
67573
|
const paths = Object.keys(files).filter((path) => kindOfPath(path) === "workflow");
|
|
@@ -67278,8 +67654,9 @@ ${SOURCE_DIR_BUSY_HELP}`).action(async (options, invoked) => {
|
|
|
67278
67654
|
}
|
|
67279
67655
|
const skipped = data ? await skippedResources(options.dir) : new Set;
|
|
67280
67656
|
const status = sourceStatus(locals, data ? serverResourceChanges(data.diagnostics).filter((change) => !(change.server === "added" && skipped.has(`${change.kind}:${change.key}`))) : []);
|
|
67281
|
-
const
|
|
67282
|
-
const
|
|
67657
|
+
const dryRun = data ? dryRunFindings(data, byBase) : [];
|
|
67658
|
+
const planned = dryRun.filter((finding) => !isServerChangeFinding(finding.code));
|
|
67659
|
+
const plan = data ? planSummary2(dryRun, applyPlan, status.conflicts.length) : null;
|
|
67283
67660
|
const report = {
|
|
67284
67661
|
workspaceId,
|
|
67285
67662
|
dir: options.dir,
|
|
@@ -69126,7 +69503,7 @@ class Parser extends Transform2 {
|
|
|
69126
69503
|
callback(err);
|
|
69127
69504
|
}
|
|
69128
69505
|
}
|
|
69129
|
-
var
|
|
69506
|
+
var parse11 = function() {
|
|
69130
69507
|
let data, options, callback;
|
|
69131
69508
|
for (const i in arguments) {
|
|
69132
69509
|
const argument = arguments[i];
|
|
@@ -69291,7 +69668,7 @@ async function stagePermissionCsvs(provider, paths, signal) {
|
|
|
69291
69668
|
parts.push({ field, path: partPath });
|
|
69292
69669
|
totalBytes += partBytes;
|
|
69293
69670
|
};
|
|
69294
|
-
const parser =
|
|
69671
|
+
const parser = parse11({
|
|
69295
69672
|
bom: true,
|
|
69296
69673
|
trim: true,
|
|
69297
69674
|
skip_empty_lines: true,
|
|
@@ -69655,6 +70032,15 @@ Profiles work like the AWS CLI: settings live in ~/.sim/config, keys in
|
|
|
69655
70032
|
~/.sim/credentials (0600), or under SIM_CONFIG_DIR when it is set. Select one
|
|
69656
70033
|
with -P, --profile, or SIM_PROFILE.
|
|
69657
70034
|
|
|
70035
|
+
A command targets the profile's workspace unless -w <id> (--workspace <id>) or
|
|
70036
|
+
SIM_WORKSPACE names another. A source directory records its own: a workflow
|
|
70037
|
+
directory acts on the workflow its .sim/base.json names, a workspace directory
|
|
70038
|
+
on the workspace its base names (refusing a -w naming another), and a starter
|
|
70039
|
+
on the one .sim/starter.json names unless -w names another. In a script, export
|
|
70040
|
+
SIM_WORKSPACE=<id> once, or keep only the ID in a variable and write -w "$WS".
|
|
70041
|
+
A variable holding "--workspace <id>" is one argument: alone it is an unknown
|
|
70042
|
+
option, and after -w all of it is taken as the ID.
|
|
70043
|
+
|
|
69658
70044
|
Workflow, knowledge-base and workspace IDs are bare UUIDs. Table IDs carry a
|
|
69659
70045
|
tbl_ prefix and file IDs a wf_ one, so wf_ never names a workflow. An audit-log
|
|
69660
70046
|
or custom-tool ID can open with a dash, which reads as a flag; put -- in front
|