sim 2.3.0-preview.327.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 +594 -201
- package/dist/program.d.ts +1 -1
- package/dist/runtime.js +594 -201
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -35167,7 +35167,34 @@ Source handles:
|
|
|
35167
35167
|
parallel-start-source, parallel-end-source the same for a parallel
|
|
35168
35168
|
Renames:
|
|
35169
35169
|
An edit's {"name":"New name"} also rewrites every <old key.field> reference to the block, in
|
|
35170
|
-
other blocks' inputs and in a loop's or parallel's collection and condition
|
|
35170
|
+
other blocks' inputs and in a loop's or parallel's collection and condition.
|
|
35171
|
+
Inputs:
|
|
35172
|
+
inputs takes the field ids \`sim blocks get <type>\` lists (inputSchema, operationInputSchema),
|
|
35173
|
+
or the name a pair of them shares (inputDefinitions: tableId for tableSelector and
|
|
35174
|
+
manualTableId; a string goes to the typed field). Add the type it answers with: \`blocks get
|
|
35175
|
+
table\` answers table_v2, and an add of legacy table is refused.
|
|
35176
|
+
conditions (condition): [{"title":"if","value":"<start.n> > 3"},{"title":"else if","value":"…"},
|
|
35177
|
+
{"title":"else","value":""}]; the last entry is the else, and ids are assigned.
|
|
35178
|
+
inputFormat (Start): [{"name":"email","type":"string"}]; types string, number, boolean,
|
|
35179
|
+
object, array, file[]; an optional default "value" as text.
|
|
35180
|
+
Block settings, beside inputs in an add's or edit's params:
|
|
35181
|
+
"retry":{"enabled":true,"maxTries":3,"waitBetweenTriesMs":1000} retries a failed block; null
|
|
35182
|
+
clears it.
|
|
35183
|
+
Outputs:
|
|
35184
|
+
A block that fails outputs {"error":"<message>"}: connect its error handle and read
|
|
35185
|
+
<name.error> there (without one, the run fails). A Workflow block's result is the child's
|
|
35186
|
+
output; a child ending in a Response block gives {data, status, headers}, so read
|
|
35187
|
+
<call.result.data.x>.`;
|
|
35188
|
+
var BLOCK_DETAIL_GUIDE = `
|
|
35189
|
+
Reading it for \`sim workflows operations apply\`:
|
|
35190
|
+
id the type to add: \`blocks get table\` answers table_v2 (an add of legacy
|
|
35191
|
+
table is refused)
|
|
35192
|
+
inputSchema the field ids inputs takes; operationInputSchema, an operation's own
|
|
35193
|
+
inputDefinitions the block's inputs by name; one a pair of fields shares (tableId for
|
|
35194
|
+
tableSelector and manualTableId) is accepted in place of the pair
|
|
35195
|
+
outputs what it outputs on success; a failed block outputs {"error":"…"}
|
|
35196
|
+
instead, read on its error path as <name.error>
|
|
35197
|
+
Block settings such as retry are not fields: \`sim workflows operations apply --help\`.`;
|
|
35171
35198
|
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';
|
|
35172
35199
|
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"}]';
|
|
35173
35200
|
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';
|
|
@@ -35614,6 +35641,7 @@ var CLI_CONTRACT = {
|
|
|
35614
35641
|
command: "workflows state replace",
|
|
35615
35642
|
confirm: "This replaces the entire draft graph and cannot be undone."
|
|
35616
35643
|
},
|
|
35644
|
+
getBlock: { helpText: BLOCK_DETAIL_GUIDE },
|
|
35617
35645
|
applyWorkflowOperations: {
|
|
35618
35646
|
command: "workflows operations apply",
|
|
35619
35647
|
describe: "Edit a workflow’s blocks, connections and settings with a batch of operations",
|
|
@@ -35834,6 +35862,9 @@ var CLI_CONTRACT = {
|
|
|
35834
35862
|
flags: { folderPath: FOLDER_PATH_FLAG }
|
|
35835
35863
|
},
|
|
35836
35864
|
createWorkflow: {
|
|
35865
|
+
helpText: `
|
|
35866
|
+
The new workflow's draft holds one Start block (start_trigger, named Start): connect the
|
|
35867
|
+
blocks you add from it.`,
|
|
35837
35868
|
flags: {
|
|
35838
35869
|
folderPath: {
|
|
35839
35870
|
...FOLDER_PATH_FLAG,
|
|
@@ -36956,6 +36987,10 @@ var CLI_CONTRACT = {
|
|
|
36956
36987
|
},
|
|
36957
36988
|
exportWorkflow: {
|
|
36958
36989
|
describe: "Print a workflow as a portable JSON document",
|
|
36990
|
+
helpText: `
|
|
36991
|
+
Workspace bindings (a table, a child workflow, a knowledge base) print as null unless
|
|
36992
|
+
--include-workspace-bindings, and credentials always do: to read what a block is set to, use
|
|
36993
|
+
\`sim workflows state get\`.`,
|
|
36959
36994
|
flags: {
|
|
36960
36995
|
includeReferences: {
|
|
36961
36996
|
boolean: true,
|
|
@@ -40702,15 +40737,19 @@ export default workflow('Cookbook', { description: 'One example of each common b
|
|
|
40702
40737
|
code: js\`return { id: \${start.orderId}, cents: Math.round(\${start.amount} * 100) }\`,
|
|
40703
40738
|
})
|
|
40704
40739
|
|
|
40705
|
-
// Tables: query rows (each row is { id, data: { column } }) and
|
|
40740
|
+
// Tables: query rows (each row is { id, data: { column } }) and write one.
|
|
40706
40741
|
const recent = table.queryRows('Recent Orders', {
|
|
40707
40742
|
tableId: table('orders'),
|
|
40708
40743
|
filterInput: { all: [{ field: 'status', op: 'eq', value: 'open' }] },
|
|
40709
40744
|
limit: 50,
|
|
40710
40745
|
})
|
|
40711
|
-
|
|
40746
|
+
// Upsert: updates the row whose conflictColumn (a unique column, by name) matches data, else
|
|
40747
|
+
// inserts one, so a second run for the same order updates it. table.insertRow takes the same
|
|
40748
|
+
// data without conflictColumn and adds a row every run.
|
|
40749
|
+
const save = table.upsertRow('Save Order', {
|
|
40712
40750
|
tableId: table('orders'),
|
|
40713
|
-
data: { orderId: start.orderId, status: 'open'
|
|
40751
|
+
data: { orderId: start.orderId, status: 'open' },
|
|
40752
|
+
conflictColumn: 'orderId',
|
|
40714
40753
|
})
|
|
40715
40754
|
|
|
40716
40755
|
// Knowledge base search: results is the list of matching chunks.
|
|
@@ -40765,8 +40804,12 @@ export default workflow('Cookbook', { description: 'One example of each common b
|
|
|
40765
40804
|
})
|
|
40766
40805
|
|
|
40767
40806
|
// Response: the API reply body. Wrap an untyped value (fn.result.x) in t\`\` when it is text.
|
|
40807
|
+
// body is the short form of the editor's JSON mode: { dataMode: 'json', data } as below.
|
|
40768
40808
|
const reply = response('Respond', { body: { risk: check.risk, id: t\`\${shape.result.id}\` } })
|
|
40769
|
-
const rejected = response('Respond Rejected', {
|
|
40809
|
+
const rejected = response('Respond Rejected', {
|
|
40810
|
+
dataMode: 'json',
|
|
40811
|
+
data: { status: 'rejected' },
|
|
40812
|
+
})
|
|
40770
40813
|
|
|
40771
40814
|
// Wiring: a.to(b) chains; a block can fan out to several targets.
|
|
40772
40815
|
start.to(check)
|
|
@@ -40877,7 +40920,7 @@ export default workflow(
|
|
|
40877
40920
|
)
|
|
40878
40921
|
` };
|
|
40879
40922
|
// ../workflow-sdk/src/codegen/core-text.generated.ts
|
|
40880
|
-
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";
|
|
40923
|
+
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";
|
|
40881
40924
|
// ../workflow-code/src/anchors.ts
|
|
40882
40925
|
function portKey(port) {
|
|
40883
40926
|
switch (port.kind) {
|
|
@@ -41884,6 +41927,16 @@ function findWorkflowReferenceTokens(source) {
|
|
|
41884
41927
|
}
|
|
41885
41928
|
return tokens.sort((left, right) => left.start - right.start);
|
|
41886
41929
|
}
|
|
41930
|
+
function collectStringLeaves(value, out) {
|
|
41931
|
+
if (typeof value === "string")
|
|
41932
|
+
out.push(value);
|
|
41933
|
+
else if (Array.isArray(value))
|
|
41934
|
+
for (const item of value)
|
|
41935
|
+
collectStringLeaves(item, out);
|
|
41936
|
+
else if (typeof value === "object" && value !== null)
|
|
41937
|
+
for (const item of Object.values(value))
|
|
41938
|
+
collectStringLeaves(item, out);
|
|
41939
|
+
}
|
|
41887
41940
|
|
|
41888
41941
|
// ../workflow-code/src/limits.ts
|
|
41889
41942
|
var SOURCE_LIMITS = {
|
|
@@ -42366,6 +42419,7 @@ function parseWorkflowSourceHandle(handle, sourceType, branchKind) {
|
|
|
42366
42419
|
var SIDE_ANCHORED_SOURCE_HANDLE_IDS = new Set(WORKFLOW_CARD_SIDES.map((side) => `source-${side}`));
|
|
42367
42420
|
var SIDE_ANCHORED_TARGET_HANDLE_IDS = new Set(WORKFLOW_CARD_SIDES.map((side) => `target-${side}`));
|
|
42368
42421
|
var WORKFLOW_CONTAINER_BLOCK_TYPES = new Set(["loop", "parallel"]);
|
|
42422
|
+
var WORKFLOW_ANNOTATION_ONLY_BLOCK_TYPE = "note";
|
|
42369
42423
|
function getWorkflowEdgeScopeDropReason(edge, blocks) {
|
|
42370
42424
|
const sourceBlock = blocks[edge.source];
|
|
42371
42425
|
const targetBlock = blocks[edge.target];
|
|
@@ -42385,6 +42439,72 @@ function getWorkflowEdgeScopeDropReason(edge, blocks) {
|
|
|
42385
42439
|
}
|
|
42386
42440
|
return `blocks are in different scopes (${sourceParent ?? "root"} -> ${targetParent ?? "root"})`;
|
|
42387
42441
|
}
|
|
42442
|
+
function isWorkflowAnnotationOnlyBlockType(blockType) {
|
|
42443
|
+
return blockType === WORKFLOW_ANNOTATION_ONLY_BLOCK_TYPE;
|
|
42444
|
+
}
|
|
42445
|
+
var RESPONSE_BLOCK_TYPE = "response";
|
|
42446
|
+
function isElseConditionTitle(title) {
|
|
42447
|
+
return typeof title === "string" && title.trim().toLowerCase() === "else";
|
|
42448
|
+
}
|
|
42449
|
+
function hasCycle(successors, pending) {
|
|
42450
|
+
const ready = [...successors.keys()].filter((id) => !pending.has(id));
|
|
42451
|
+
let visited = 0;
|
|
42452
|
+
for (let id = ready.pop();id !== undefined; id = ready.pop()) {
|
|
42453
|
+
visited += 1;
|
|
42454
|
+
for (const next of successors.get(id) ?? []) {
|
|
42455
|
+
const left = (pending.get(next) ?? 0) - 1;
|
|
42456
|
+
pending.set(next, left);
|
|
42457
|
+
if (left === 0)
|
|
42458
|
+
ready.push(next);
|
|
42459
|
+
}
|
|
42460
|
+
}
|
|
42461
|
+
const nodes = new Set([...successors.keys(), ...pending.keys()]);
|
|
42462
|
+
return visited < nodes.size;
|
|
42463
|
+
}
|
|
42464
|
+
function alwaysEndsAtResponse(blocks, edges) {
|
|
42465
|
+
const runs = (id) => {
|
|
42466
|
+
const block = Object.hasOwn(blocks, id) ? blocks[id] : undefined;
|
|
42467
|
+
return block?.enabled === true && !isWorkflowAnnotationOnlyBlockType(block.type);
|
|
42468
|
+
};
|
|
42469
|
+
const isRoot = (id) => blocks[id]?.parentId === null;
|
|
42470
|
+
const portsBySource = new Map;
|
|
42471
|
+
const successors = new Map;
|
|
42472
|
+
const pending = new Map;
|
|
42473
|
+
for (const edge of edges) {
|
|
42474
|
+
if (!runs(edge.source) || !runs(edge.target))
|
|
42475
|
+
continue;
|
|
42476
|
+
const ports = portsBySource.get(edge.source) ?? new Set;
|
|
42477
|
+
ports.add(edge.port);
|
|
42478
|
+
portsBySource.set(edge.source, ports);
|
|
42479
|
+
if (!isRoot(edge.source) || !isRoot(edge.target))
|
|
42480
|
+
continue;
|
|
42481
|
+
const next = successors.get(edge.source) ?? [];
|
|
42482
|
+
next.push(edge.target);
|
|
42483
|
+
successors.set(edge.source, next);
|
|
42484
|
+
pending.set(edge.target, (pending.get(edge.target) ?? 0) + 1);
|
|
42485
|
+
}
|
|
42486
|
+
if (hasCycle(successors, pending))
|
|
42487
|
+
return false;
|
|
42488
|
+
let responds = false;
|
|
42489
|
+
for (const [id, block] of Object.entries(blocks)) {
|
|
42490
|
+
if (!runs(id) || block.parentId !== null)
|
|
42491
|
+
continue;
|
|
42492
|
+
if (block.type === RESPONSE_BLOCK_TYPE) {
|
|
42493
|
+
responds = true;
|
|
42494
|
+
continue;
|
|
42495
|
+
}
|
|
42496
|
+
const ports = portsBySource.get(id);
|
|
42497
|
+
if (block.branches !== undefined) {
|
|
42498
|
+
const { branches } = block;
|
|
42499
|
+
if (branches.length === 0 || !branches.every((branch) => ports?.has(`branch:${branch}`))) {
|
|
42500
|
+
return false;
|
|
42501
|
+
}
|
|
42502
|
+
} else if (!ports?.has(isSubflowType(block.type) ? "subflowEnd" : "out")) {
|
|
42503
|
+
return false;
|
|
42504
|
+
}
|
|
42505
|
+
}
|
|
42506
|
+
return responds;
|
|
42507
|
+
}
|
|
42388
42508
|
var RESERVED_WORKFLOW_BLOCK_NAMES = ["loop", "parallel", "variable"];
|
|
42389
42509
|
function isReservedWorkflowBlockName(name) {
|
|
42390
42510
|
return RESERVED_WORKFLOW_BLOCK_NAMES.includes(name);
|
|
@@ -42789,8 +42909,8 @@ function valueTree(value) {
|
|
|
42789
42909
|
var SDK_MODULE = "@sim/workflow-sdk";
|
|
42790
42910
|
var GENERIC_BUILDER = "block";
|
|
42791
42911
|
var CUSTOM_TOOL_TYPE = "custom-tool";
|
|
42792
|
-
var RESPONSE_BLOCK_TYPE = "response";
|
|
42793
42912
|
var RESPONSE_BODY_KEYS = ["body", "status", "headers"];
|
|
42913
|
+
var RESPONSE_OUTPUTS = ["data", "status", "headers"];
|
|
42794
42914
|
var TEMPLATE_TAGS = [
|
|
42795
42915
|
"t",
|
|
42796
42916
|
"js",
|
|
@@ -43523,8 +43643,8 @@ var VERB_SYNONYMS = [
|
|
|
43523
43643
|
["delete", "remove", "destroy", "archive"]
|
|
43524
43644
|
];
|
|
43525
43645
|
function splitVerb(method) {
|
|
43526
|
-
const
|
|
43527
|
-
return
|
|
43646
|
+
const verb = /^[a-z]*/.exec(method)?.[0] ?? "";
|
|
43647
|
+
return [verb, method.slice(verb.length).toLowerCase()];
|
|
43528
43648
|
}
|
|
43529
43649
|
var BUILDER_ALIASES = {
|
|
43530
43650
|
http: "api",
|
|
@@ -43670,6 +43790,9 @@ function renamedReferenceRewriter(renames) {
|
|
|
43670
43790
|
}) : text;
|
|
43671
43791
|
}
|
|
43672
43792
|
|
|
43793
|
+
// ../workflow-code/src/compile/blocks.ts
|
|
43794
|
+
var import_parser3 = __toESM(require_lib(), 1);
|
|
43795
|
+
|
|
43673
43796
|
// ../workflow-code/src/canonicalize/values.ts
|
|
43674
43797
|
var REFERENCE_CANDIDATE = /<([^<>]+)>/g;
|
|
43675
43798
|
var VARIABLE_PREFIX = "variable";
|
|
@@ -43764,6 +43887,20 @@ var MODELED_ROW_KEYS = new Set(["id", "title", "value", "key"]);
|
|
|
43764
43887
|
function isBranchExtraField(field) {
|
|
43765
43888
|
return !MODELED_ROW_KEYS.has(field) && !UI_ROW_KEYS.has(field);
|
|
43766
43889
|
}
|
|
43890
|
+
function storedTitle(kind, row, index, count) {
|
|
43891
|
+
if (row.titleOverride !== undefined)
|
|
43892
|
+
return row.titleOverride;
|
|
43893
|
+
return row.titleMissing ? undefined : positionalTitle(kind, index, count);
|
|
43894
|
+
}
|
|
43895
|
+
function positionalTitle(kind, index, count) {
|
|
43896
|
+
if (kind === "router")
|
|
43897
|
+
return `Route ${index + 1}`;
|
|
43898
|
+
if (index === 0)
|
|
43899
|
+
return "if";
|
|
43900
|
+
if (index === count - 1)
|
|
43901
|
+
return "else";
|
|
43902
|
+
return "else if";
|
|
43903
|
+
}
|
|
43767
43904
|
|
|
43768
43905
|
// ../workflow-code/src/canonicalize/subflows.ts
|
|
43769
43906
|
var PARALLEL_BATCH_MIN = 1;
|
|
@@ -47710,6 +47847,48 @@ function textField(value) {
|
|
|
47710
47847
|
function jsonField(value) {
|
|
47711
47848
|
return isJson(value) ? value : undefined;
|
|
47712
47849
|
}
|
|
47850
|
+
function checkLoopCondition(ctx, decl, text, property) {
|
|
47851
|
+
if (text.trim() === "")
|
|
47852
|
+
return;
|
|
47853
|
+
const at = rangeOf(ctx, property.value);
|
|
47854
|
+
const selfReads = new Set;
|
|
47855
|
+
const ownName = normalizeWorkflowBlockName(decl.name);
|
|
47856
|
+
const runnable = text.replace(REFERENCE_CANDIDATE, (match, inner) => {
|
|
47857
|
+
if (!isLikelyWorkflowReferenceSegment(match))
|
|
47858
|
+
return match;
|
|
47859
|
+
const segments = parseStoredPath(inner);
|
|
47860
|
+
const [head, field] = segments ?? [];
|
|
47861
|
+
if (head?.kind === "name" && normalizeWorkflowBlockName(head.name) === ownName && field?.kind === "name" && LOOP_PROPERTIES.includes(field.name)) {
|
|
47862
|
+
selfReads.add(field.name);
|
|
47863
|
+
}
|
|
47864
|
+
return "(0)";
|
|
47865
|
+
});
|
|
47866
|
+
for (const field of selfReads) {
|
|
47867
|
+
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, {
|
|
47868
|
+
hint: `Write <loop.${field}>: the bare loop prefix reads the iteration the condition is evaluated for.`,
|
|
47869
|
+
blockKey: decl.key
|
|
47870
|
+
});
|
|
47871
|
+
}
|
|
47872
|
+
let failure = null;
|
|
47873
|
+
try {
|
|
47874
|
+
const file = import_parser3.parse(`return Boolean(${runnable})`, {
|
|
47875
|
+
sourceType: "script",
|
|
47876
|
+
allowReturnOutsideFunction: true,
|
|
47877
|
+
errorRecovery: true
|
|
47878
|
+
});
|
|
47879
|
+
failure = file.errors?.[0] ?? null;
|
|
47880
|
+
} catch (error) {
|
|
47881
|
+
failure = error;
|
|
47882
|
+
}
|
|
47883
|
+
if (failure === null)
|
|
47884
|
+
return;
|
|
47885
|
+
const { message: raw } = babelErrorShape(failure);
|
|
47886
|
+
const message = typeof raw === "string" ? raw : "Invalid JavaScript";
|
|
47887
|
+
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, {
|
|
47888
|
+
hint: "Write one JavaScript expression the loop repeats while it is true, e.g. condition: '<loop.index> < 3'.",
|
|
47889
|
+
blockKey: decl.key
|
|
47890
|
+
});
|
|
47891
|
+
}
|
|
47713
47892
|
function compileContainer(ctx, decl) {
|
|
47714
47893
|
const builder = decl.builder;
|
|
47715
47894
|
if (builder.kind !== "container")
|
|
@@ -47741,6 +47920,12 @@ function compileContainer(ctx, decl) {
|
|
|
47741
47920
|
...doWhileCondition !== undefined && { doWhileCondition }
|
|
47742
47921
|
};
|
|
47743
47922
|
reportUnreadConfig(ctx, decl, form, written, loop);
|
|
47923
|
+
for (const field of ["whileCondition", "doWhileCondition"]) {
|
|
47924
|
+
const text = loop[field];
|
|
47925
|
+
const property = written.get(field);
|
|
47926
|
+
if (text !== undefined && property)
|
|
47927
|
+
checkLoopCondition(ctx, decl, text, property);
|
|
47928
|
+
}
|
|
47744
47929
|
subflow = loop;
|
|
47745
47930
|
} else {
|
|
47746
47931
|
const { fields } = compileConfig(ctx, site, "parallel", parallelForm(builder.method), config);
|
|
@@ -48390,7 +48575,7 @@ function stronglyConnected(keys, successors) {
|
|
|
48390
48575
|
}
|
|
48391
48576
|
|
|
48392
48577
|
// ../workflow-code/src/compile/function-returns.ts
|
|
48393
|
-
var
|
|
48578
|
+
var import_parser4 = __toESM(require_lib(), 1);
|
|
48394
48579
|
var FUNCTION_TYPE = "function";
|
|
48395
48580
|
var NUMBER_FUNCTIONS = new Set(["Number", "parseInt", "parseFloat"]);
|
|
48396
48581
|
var BOOLEAN_FUNCTIONS = new Set(["Boolean", "isNaN", "isFinite"]);
|
|
@@ -48726,7 +48911,7 @@ function returnedFields(object, inference) {
|
|
|
48726
48911
|
function readReturns(code) {
|
|
48727
48912
|
let program;
|
|
48728
48913
|
try {
|
|
48729
|
-
const file =
|
|
48914
|
+
const file = import_parser4.parse(toCodeFile(code, "javascript"), {
|
|
48730
48915
|
sourceType: "unambiguous",
|
|
48731
48916
|
allowReturnOutsideFunction: true,
|
|
48732
48917
|
allowAwaitOutsideFunction: true,
|
|
@@ -48826,6 +49011,7 @@ var COMPILE_SCOPE_CODES = [
|
|
|
48826
49011
|
"W_ENV_UNKNOWN",
|
|
48827
49012
|
"W_CHILD_INPUT_UNKNOWN",
|
|
48828
49013
|
"W_CHILD_NO_START",
|
|
49014
|
+
"W_CHILD_RESULT_PATH",
|
|
48829
49015
|
"E_UNKNOWN_SUBFLOW_PROPERTY",
|
|
48830
49016
|
"W_FORWARD_REF",
|
|
48831
49017
|
"W_REF_NOT_NORMALIZED",
|
|
@@ -48871,7 +49057,8 @@ var COMPILE_CATALOG_CODES = [
|
|
|
48871
49057
|
"W_SUBFLOW_COUNT",
|
|
48872
49058
|
"W_UNKNOWN_OUTPUT_PATH",
|
|
48873
49059
|
"W_OUTPUT_PATH_UNDECLARED",
|
|
48874
|
-
"W_JSON_REF_UNTYPED"
|
|
49060
|
+
"W_JSON_REF_UNTYPED",
|
|
49061
|
+
"W_LOOP_CONDITION_SYNTAX"
|
|
48875
49062
|
];
|
|
48876
49063
|
var CODE_FILE_CODES = [
|
|
48877
49064
|
"E_CODE_FILE_MISSING",
|
|
@@ -48975,6 +49162,7 @@ var APPLY_DIAGNOSTIC_CODES = [
|
|
|
48975
49162
|
"E_APPLY_UNRESOLVED_REF",
|
|
48976
49163
|
"E_APPLY_REF_OUT_OF_SCOPE",
|
|
48977
49164
|
"E_APPLY_CODE_FILE_REF_SYNTAX",
|
|
49165
|
+
"E_APPLY_LOOP_CONDITION_SYNTAX",
|
|
48978
49166
|
"W_APPLY_LINT",
|
|
48979
49167
|
"W_TABLE_UNKNOWN_COLUMN",
|
|
48980
49168
|
"E_APPLY_INVALID_SCHEDULE",
|
|
@@ -49016,7 +49204,8 @@ function refusalClassifier(extra = {}) {
|
|
|
49016
49204
|
}
|
|
49017
49205
|
var refusalClass = refusalClassifier();
|
|
49018
49206
|
var CHANGED_BLOCK_REFUSALS = new Map([
|
|
49019
|
-
["W_REF_OUT_OF_SCOPE", "E_APPLY_REF_OUT_OF_SCOPE"]
|
|
49207
|
+
["W_REF_OUT_OF_SCOPE", "E_APPLY_REF_OUT_OF_SCOPE"],
|
|
49208
|
+
["W_LOOP_CONDITION_SYNTAX", "E_APPLY_LOOP_CONDITION_SYNTAX"]
|
|
49020
49209
|
]);
|
|
49021
49210
|
var PARAM_REFUSALS = new Map([
|
|
49022
49211
|
["W_UNKNOWN_OPTION", "E_APPLY_INVALID_SUBBLOCK_FIELD"]
|
|
@@ -49035,6 +49224,7 @@ var CODE_FILE_REFUSALS = new Map([
|
|
|
49035
49224
|
var REFUSABLE_WARNING_CODES = new Set([
|
|
49036
49225
|
"W_UNKNOWN_OPTION",
|
|
49037
49226
|
"W_REF_OUT_OF_SCOPE",
|
|
49227
|
+
"W_LOOP_CONDITION_SYNTAX",
|
|
49038
49228
|
"W_UNKNOWN_OUTPUT_PATH",
|
|
49039
49229
|
"W_UNRESOLVED_REF",
|
|
49040
49230
|
"W_CODE_FILE_REF_SYNTAX",
|
|
@@ -50568,6 +50758,37 @@ function stableStringify(value) {
|
|
|
50568
50758
|
function sha256Hex(text) {
|
|
50569
50759
|
return bytesToHex(sha256(utf8ToBytes(text)));
|
|
50570
50760
|
}
|
|
50761
|
+
// ../workflow-code/src/responds.ts
|
|
50762
|
+
function alwaysTakenBranches(block) {
|
|
50763
|
+
const branches = block.branches;
|
|
50764
|
+
if (!branches)
|
|
50765
|
+
return;
|
|
50766
|
+
const rows = branches.rows ?? [];
|
|
50767
|
+
if (branches.kind === "router")
|
|
50768
|
+
return rows.map((row) => row.key);
|
|
50769
|
+
const elseAt = rows.findIndex((row, index) => isElseConditionTitle(storedTitle(branches.kind, row, index, rows.length)));
|
|
50770
|
+
return elseAt === -1 ? [] : rows.slice(0, elseAt + 1).map((row) => row.key);
|
|
50771
|
+
}
|
|
50772
|
+
function portName(port) {
|
|
50773
|
+
return port.kind === "branch" ? `branch:${port.key}` : port.kind;
|
|
50774
|
+
}
|
|
50775
|
+
function respondsOnEveryRun(workflow) {
|
|
50776
|
+
const blocks = {};
|
|
50777
|
+
for (const [key, block] of Object.entries(workflow.blocks)) {
|
|
50778
|
+
const branches = alwaysTakenBranches(block);
|
|
50779
|
+
setOwn(blocks, key, {
|
|
50780
|
+
type: block.type,
|
|
50781
|
+
enabled: block.enabled,
|
|
50782
|
+
parentId: block.parent,
|
|
50783
|
+
...branches !== undefined && { branches }
|
|
50784
|
+
});
|
|
50785
|
+
}
|
|
50786
|
+
return alwaysEndsAtResponse(blocks, workflow.edges.map((edge) => ({
|
|
50787
|
+
source: edge.from,
|
|
50788
|
+
target: edge.to,
|
|
50789
|
+
port: portName(edge.port)
|
|
50790
|
+
})));
|
|
50791
|
+
}
|
|
50571
50792
|
// ../workflow-sdk/src/codegen/emit.ts
|
|
50572
50793
|
function literal(value) {
|
|
50573
50794
|
return typeof value === "string" ? quoteString(value) : String(value);
|
|
@@ -50684,12 +50905,19 @@ function declaredBlockTypes(catalog) {
|
|
|
50684
50905
|
function legacyOnlyBlockTypes(catalog) {
|
|
50685
50906
|
return new Set([...declaredBlockTypes(catalog)].flatMap(([type, { legacyOnly }]) => legacyOnly ? [type] : []));
|
|
50686
50907
|
}
|
|
50687
|
-
var
|
|
50908
|
+
var CHAIN = /[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*/g;
|
|
50909
|
+
var OPEN_PAREN = /\s*\(/y;
|
|
50910
|
+
function* calledPaths(text) {
|
|
50911
|
+
for (const match of text.matchAll(CHAIN)) {
|
|
50912
|
+
OPEN_PAREN.lastIndex = match.index + match[0].length;
|
|
50913
|
+
if (OPEN_PAREN.test(text))
|
|
50914
|
+
yield match[0].replace(/\s+/g, "").split(".");
|
|
50915
|
+
}
|
|
50916
|
+
}
|
|
50688
50917
|
function referencedBuilders(catalog, sources) {
|
|
50689
50918
|
const keys = new Set;
|
|
50690
50919
|
for (const text of sources) {
|
|
50691
|
-
for (const
|
|
50692
|
-
const path = match[1].replace(/\s+/g, "").split(".");
|
|
50920
|
+
for (const path of calledPaths(text)) {
|
|
50693
50921
|
if (path.length > 1 && path[path.length - 2] === TOOL_NAMESPACE)
|
|
50694
50922
|
path.splice(path.length - 2, 1);
|
|
50695
50923
|
else if (path.length > 1 && path[path.length - 1] === TOOL_NAMESPACE)
|
|
@@ -51233,7 +51461,8 @@ var RUNTIME_SEMANTICS = [
|
|
|
51233
51461
|
"",
|
|
51234
51462
|
"- **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.",
|
|
51235
51463
|
"- **`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.",
|
|
51236
|
-
"- **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.",
|
|
51464
|
+
"- **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.",
|
|
51465
|
+
"- **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.",
|
|
51237
51466
|
"- **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.",
|
|
51238
51467
|
"- **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).",
|
|
51239
51468
|
"- **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.",
|
|
@@ -51826,6 +52055,7 @@ function describeBuilder(catalog, key) {
|
|
|
51826
52055
|
summary: types.summary,
|
|
51827
52056
|
...entry.builder.operation ? { operation: entry.builder.operation } : {},
|
|
51828
52057
|
legacy: isLegacyBuilder(key),
|
|
52058
|
+
...entry.special ? docOf(key) : {},
|
|
51829
52059
|
signature,
|
|
51830
52060
|
tool,
|
|
51831
52061
|
paramsName: types.paramsName,
|
|
@@ -51849,28 +52079,47 @@ function lookupBuilder(catalog, query) {
|
|
|
51849
52079
|
if (SDK_CORE_EXPORTS.includes(root)) {
|
|
51850
52080
|
return { kind: "core", name: key, declaration: coreDeclaration(root) };
|
|
51851
52081
|
}
|
|
52082
|
+
const ofBlockType = paths.filter((path) => catalogBuilder(catalog, path)?.type === key);
|
|
52083
|
+
const only = ofBlockType.length === 1 ? describeBuilder(catalog, ofBlockType[0]) : null;
|
|
52084
|
+
if (only)
|
|
52085
|
+
return { kind: "builder", reference: only };
|
|
52086
|
+
if (ofBlockType.length > 1) {
|
|
52087
|
+
return {
|
|
52088
|
+
kind: "namespace",
|
|
52089
|
+
namespace: key,
|
|
52090
|
+
builders: ofBlockType.map((path) => ({ key: path, summary: summaryOf(catalog, path) }))
|
|
52091
|
+
};
|
|
52092
|
+
}
|
|
51852
52093
|
const hint = suggestBuilder(key, paths.filter((path) => !isLegacyBuilder(path)));
|
|
51853
52094
|
return hint ? { kind: "missing", hint } : { kind: "missing" };
|
|
51854
52095
|
}
|
|
51855
52096
|
var MAX_CORE_LINES = 80;
|
|
51856
|
-
|
|
51857
|
-
const lines = CORE_DTS.split(`
|
|
52097
|
+
var CORE_LINES = CORE_DTS.split(`
|
|
51858
52098
|
`);
|
|
51859
|
-
|
|
52099
|
+
function docCommentStart(start) {
|
|
52100
|
+
if (!CORE_LINES[start - 1]?.trim().endsWith("*/"))
|
|
52101
|
+
return start;
|
|
52102
|
+
let first = start - 1;
|
|
52103
|
+
while (first > 0 && !CORE_LINES[first].trim().startsWith("/**"))
|
|
52104
|
+
first--;
|
|
52105
|
+
return first;
|
|
52106
|
+
}
|
|
52107
|
+
function coreDeclarationRanges(name) {
|
|
52108
|
+
const start = new RegExp(`^export (?:declare )?(?:const|function|namespace|interface|type) ${escapeRegExp(name)}\\b`);
|
|
51860
52109
|
const declarations = [];
|
|
51861
|
-
for (let index = 0;index <
|
|
51862
|
-
if (!start.test(
|
|
52110
|
+
for (let index = 0;index < CORE_LINES.length; index++) {
|
|
52111
|
+
if (!start.test(CORE_LINES[index]))
|
|
51863
52112
|
continue;
|
|
51864
52113
|
let depth = 0;
|
|
51865
52114
|
let end = index;
|
|
51866
|
-
for (;end <
|
|
51867
|
-
for (const char of
|
|
52115
|
+
for (;end < CORE_LINES.length; end++) {
|
|
52116
|
+
for (const char of CORE_LINES[end]) {
|
|
51868
52117
|
if ("({[".includes(char))
|
|
51869
52118
|
depth++;
|
|
51870
52119
|
else if (")}]".includes(char))
|
|
51871
52120
|
depth--;
|
|
51872
52121
|
}
|
|
51873
|
-
const continues = /[=:,|&]\s*$/.test(
|
|
52122
|
+
const continues = /[=:,|&]\s*$/.test(CORE_LINES[end]) || /^\s+[?:|&]/.test(CORE_LINES[end + 1] ?? "");
|
|
51874
52123
|
if (depth <= 0 && !continues)
|
|
51875
52124
|
break;
|
|
51876
52125
|
}
|
|
@@ -51880,28 +52129,26 @@ function coreDeclarationRanges(name) {
|
|
|
51880
52129
|
return declarations;
|
|
51881
52130
|
}
|
|
51882
52131
|
function coreSignatures(name) {
|
|
51883
|
-
|
|
51884
|
-
`);
|
|
51885
|
-
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(`
|
|
52132
|
+
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(`
|
|
51886
52133
|
`);
|
|
51887
52134
|
}
|
|
51888
52135
|
function coreDeclaration(name) {
|
|
51889
|
-
const lines = CORE_DTS.split(`
|
|
51890
|
-
`);
|
|
51891
52136
|
const out = [];
|
|
51892
52137
|
for (const { start, end } of coreDeclarationRanges(name)) {
|
|
51893
|
-
let first = start;
|
|
51894
|
-
if (lines[start - 1]?.trim().endsWith("*/")) {
|
|
51895
|
-
while (first > 0 && !lines[first].trim().startsWith("/**"))
|
|
51896
|
-
first--;
|
|
51897
|
-
}
|
|
51898
52138
|
if (out.length > 0)
|
|
51899
52139
|
out.push("");
|
|
51900
|
-
out.push(...
|
|
52140
|
+
out.push(...CORE_LINES.slice(docCommentStart(start), end));
|
|
51901
52141
|
}
|
|
51902
52142
|
return out.slice(0, MAX_CORE_LINES).join(`
|
|
51903
52143
|
`);
|
|
51904
52144
|
}
|
|
52145
|
+
function docOf(name) {
|
|
52146
|
+
const range = coreDeclarationRanges(name)[0];
|
|
52147
|
+
if (!range)
|
|
52148
|
+
return {};
|
|
52149
|
+
const doc = CORE_LINES.slice(docCommentStart(range.start), range.start).map((line) => line.trim().replace(/^\/\*\*\s?|\s?\*\/$|^\*\s?/g, "")).join(" ").replace(/\s+/g, " ").trim();
|
|
52150
|
+
return doc ? { doc } : {};
|
|
52151
|
+
}
|
|
51905
52152
|
var MAX_SNIPPET_TYPE = 60;
|
|
51906
52153
|
var MAX_SNIPPET_OPTIONAL = 12;
|
|
51907
52154
|
function shortType(type) {
|
|
@@ -51992,6 +52239,8 @@ function renderBuilderReference(reference) {
|
|
|
51992
52239
|
if (reference.legacy) {
|
|
51993
52240
|
lines.push("Legacy: an older block version. Write the current builder instead.");
|
|
51994
52241
|
}
|
|
52242
|
+
if (reference.doc)
|
|
52243
|
+
lines.push("", reference.doc);
|
|
51995
52244
|
lines.push("", reference.signature);
|
|
51996
52245
|
if (reference.tool)
|
|
51997
52246
|
lines.push(`${reference.tool} (as an agent tool)`);
|
|
@@ -52244,7 +52493,7 @@ export default defineTable({
|
|
|
52244
52493
|
name: 'orders',
|
|
52245
52494
|
description: 'Order questions the support workflow answered',
|
|
52246
52495
|
columns: {
|
|
52247
|
-
orderId: column.string({ required: true }),
|
|
52496
|
+
orderId: column.string({ required: true, unique: true }),
|
|
52248
52497
|
status: column.select({ options: ['open', 'answered'] }),
|
|
52249
52498
|
total: column.number(),
|
|
52250
52499
|
},
|
|
@@ -52323,9 +52572,10 @@ export default workflow('Support', { description: 'Answers an order question.' }
|
|
|
52323
52572
|
tools: [customTool('lookup-order')],
|
|
52324
52573
|
skills: [skill('tone')],
|
|
52325
52574
|
})
|
|
52326
|
-
const log = table.
|
|
52575
|
+
const log = table.upsertRow('Log Question', {
|
|
52327
52576
|
tableId: table('orders'),
|
|
52328
52577
|
data: { orderId: start.orderId, status: 'answered' },
|
|
52578
|
+
conflictColumn: 'orderId',
|
|
52329
52579
|
})
|
|
52330
52580
|
|
|
52331
52581
|
start.to(policy)
|
|
@@ -53838,7 +54088,7 @@ async function withSourceCommandLock(dir, run, options = {}) {
|
|
|
53838
54088
|
return withSourceDirLock(folder ? folder.root : dir, run, options);
|
|
53839
54089
|
}
|
|
53840
54090
|
// ../workflow-code/src/code-files/references.ts
|
|
53841
|
-
var
|
|
54091
|
+
var import_parser5 = __toESM(require_lib(), 1);
|
|
53842
54092
|
var CODE_FILE_EXPORT = "codeFile";
|
|
53843
54093
|
function codeFileReferences(text) {
|
|
53844
54094
|
if (utf8Bytes(text, SOURCE_LIMITS.maxTotalBytes) > SOURCE_LIMITS.maxTotalBytes)
|
|
@@ -53847,7 +54097,7 @@ function codeFileReferences(text) {
|
|
|
53847
54097
|
return [];
|
|
53848
54098
|
let program;
|
|
53849
54099
|
try {
|
|
53850
|
-
program =
|
|
54100
|
+
program = import_parser5.parse(text, PARSER_OPTIONS).program;
|
|
53851
54101
|
} catch {
|
|
53852
54102
|
return [];
|
|
53853
54103
|
}
|
|
@@ -54063,6 +54313,10 @@ function loopRows(rows) {
|
|
|
54063
54313
|
return rows.map(([command, what]) => ` ${command.padEnd(width)}${what}`.trimEnd()).join(`
|
|
54064
54314
|
`);
|
|
54065
54315
|
}
|
|
54316
|
+
var WORKSPACE_LINE = `Workspace: a directory records it (.sim/base.json, or a starter's .sim/starter.json); any other
|
|
54317
|
+
command takes -w <id>, SIM_WORKSPACE or the profile's (export SIM_WORKSPACE once, or keep only the
|
|
54318
|
+
ID in a variable: one holding "--workspace <id>" is one argument, an unknown option alone and the
|
|
54319
|
+
whole ID after -w).`;
|
|
54066
54320
|
function statusLine(group, dir) {
|
|
54067
54321
|
return `\`${group} status --dir ${dir}\` shows what applying would do and
|
|
54068
54322
|
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).
|
|
@@ -54081,6 +54335,7 @@ ${loopRows([
|
|
|
54081
54335
|
A new workflow: \`sim workflows source create --dir ./new --workspace <workspaceId>\` writes a
|
|
54082
54336
|
starter that records its workspace; edit and check it, then \`create --dir ./new --yes\` creates the
|
|
54083
54337
|
workflow there, and the loop above goes on from there.
|
|
54338
|
+
${WORKSPACE_LINE}
|
|
54084
54339
|
|
|
54085
54340
|
Flags the loop needs: --allow-delete (apply: an edit that removes a block or variable is refused
|
|
54086
54341
|
without it), --deploy (apply, create: also deploy the saved draft), --force (get: replace another
|
|
@@ -54098,6 +54353,7 @@ ${loopRows([
|
|
|
54098
54353
|
])}
|
|
54099
54354
|
Promote dev to prod: \`sim workspaces source apply --dir ./ws --to <workspaceId> --dry-run\`, then
|
|
54100
54355
|
--yes.
|
|
54356
|
+
${WORKSPACE_LINE}
|
|
54101
54357
|
|
|
54102
54358
|
Flags the loop needs: --allow-delete (apply: removing a resource, a column, rows or a document,
|
|
54103
54359
|
or a workflow's block or variable, is refused without it), --force (get: replace edits no apply
|
|
@@ -54391,6 +54647,112 @@ async function printRunFailureSite(dir, workflowId, error) {
|
|
|
54391
54647
|
]);
|
|
54392
54648
|
}
|
|
54393
54649
|
|
|
54650
|
+
// src/commands/protocol/workflow-run-get.ts
|
|
54651
|
+
var BLOCK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
54652
|
+
var SELECT_OUTPUT_FLAG = "select-output";
|
|
54653
|
+
function normalizeBlockName(name) {
|
|
54654
|
+
return name.toLowerCase().replace(/\s+/g, "").replace(/\./g, "");
|
|
54655
|
+
}
|
|
54656
|
+
async function loadWorkflowBlocks(client, workflowId) {
|
|
54657
|
+
const raw = await client.request("getWorkflowState", { params: { workflowId } });
|
|
54658
|
+
const state = isRecordLike(raw) && isRecordLike(raw.data) ? raw.data : raw;
|
|
54659
|
+
const blocks = isRecordLike(state) && isRecordLike(state.blocks) ? Object.entries(state.blocks) : [];
|
|
54660
|
+
return blocks.map(([key, block]) => ({
|
|
54661
|
+
id: isRecordLike(block) && typeof block.id === "string" ? block.id : key,
|
|
54662
|
+
name: isRecordLike(block) && typeof block.name === "string" ? block.name : ""
|
|
54663
|
+
}));
|
|
54664
|
+
}
|
|
54665
|
+
function splitSelector(selector) {
|
|
54666
|
+
const dot = selector.indexOf(".");
|
|
54667
|
+
return dot === -1 ? { head: selector, path: "" } : { head: selector.slice(0, dot), path: selector.slice(dot) };
|
|
54668
|
+
}
|
|
54669
|
+
function isIdHeaded(selector) {
|
|
54670
|
+
return BLOCK_ID.test(splitSelector(selector).head);
|
|
54671
|
+
}
|
|
54672
|
+
function resolveSelection(typed, blocks, workflowId) {
|
|
54673
|
+
const resolved = [];
|
|
54674
|
+
const typedBy = new Map;
|
|
54675
|
+
const unresolved = [];
|
|
54676
|
+
for (const selector of typed) {
|
|
54677
|
+
const { head, path } = splitSelector(selector);
|
|
54678
|
+
let blockId = head;
|
|
54679
|
+
if (!BLOCK_ID.test(head)) {
|
|
54680
|
+
const wanted = normalizeBlockName(head);
|
|
54681
|
+
const matches = blocks.filter((block) => block.id === head || normalizeBlockName(block.name) === wanted);
|
|
54682
|
+
if (matches.length === 0) {
|
|
54683
|
+
unresolved.push(selector);
|
|
54684
|
+
continue;
|
|
54685
|
+
}
|
|
54686
|
+
if (matches.length > 1) {
|
|
54687
|
+
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} ${selector} names ${matches.length} blocks (${matches.map((block) => block.id).join(", ")}); pass the block id instead`, 0);
|
|
54688
|
+
}
|
|
54689
|
+
blockId = matches[0].id;
|
|
54690
|
+
}
|
|
54691
|
+
const rewritten = `${blockId}${path}`;
|
|
54692
|
+
resolved.push(rewritten);
|
|
54693
|
+
if (!typedBy.has(rewritten))
|
|
54694
|
+
typedBy.set(rewritten, selector);
|
|
54695
|
+
}
|
|
54696
|
+
if (unresolved.length > 0) {
|
|
54697
|
+
const names = blocks.map((block) => block.name).filter((name) => name !== "");
|
|
54698
|
+
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);
|
|
54699
|
+
}
|
|
54700
|
+
return { resolved, typedBy };
|
|
54701
|
+
}
|
|
54702
|
+
function keyByTyped(payload, typedBy) {
|
|
54703
|
+
if (!isRecordLike(payload) || !isRecordLike(payload.blockOutputs))
|
|
54704
|
+
return payload;
|
|
54705
|
+
const blockOutputs = {};
|
|
54706
|
+
for (const [key, value] of Object.entries(payload.blockOutputs)) {
|
|
54707
|
+
blockOutputs[typedBy.get(key) ?? key] = value;
|
|
54708
|
+
}
|
|
54709
|
+
return { ...payload, blockOutputs };
|
|
54710
|
+
}
|
|
54711
|
+
async function readRunByName(runId, typed, command, { client, profile }) {
|
|
54712
|
+
const flags = command.optsWithGlobals();
|
|
54713
|
+
const operation = V2_OPERATIONS.getWorkflowRun;
|
|
54714
|
+
const spec = CLI_CONTRACT.getWorkflowRun ?? {};
|
|
54715
|
+
await buildRequest("getWorkflowRun", [runId], flags, profile.workspaceId);
|
|
54716
|
+
const workflowId = String(flags.workflow);
|
|
54717
|
+
const selection = resolveSelection(typed, await loadWorkflowBlocks(client, workflowId), workflowId);
|
|
54718
|
+
const request = await buildRequest("getWorkflowRun", [runId], { ...flags, selectOutput: selection.resolved }, profile.workspaceId);
|
|
54719
|
+
let result;
|
|
54720
|
+
try {
|
|
54721
|
+
result = await client.request("getWorkflowRun", {
|
|
54722
|
+
params: request.params,
|
|
54723
|
+
headers: request.headers,
|
|
54724
|
+
query: request.query,
|
|
54725
|
+
body: request.body
|
|
54726
|
+
});
|
|
54727
|
+
} catch (error) {
|
|
54728
|
+
throw retypeApiError(error, "getWorkflowRun", spec, operation);
|
|
54729
|
+
}
|
|
54730
|
+
renderResult("getWorkflowRun", profile.output, keyByTyped(result?.data ?? result, selection.typedBy), spec, {}, result);
|
|
54731
|
+
}
|
|
54732
|
+
function attachWorkflowRunGet(runs) {
|
|
54733
|
+
const get = runs.commands.find((command) => command.name() === "get");
|
|
54734
|
+
const held = get?._actionHandler;
|
|
54735
|
+
if (!get || typeof held !== "function") {
|
|
54736
|
+
throw new Error("workflows runs get must be registered before block names can be attached to it");
|
|
54737
|
+
}
|
|
54738
|
+
const previous = held;
|
|
54739
|
+
const connectGet = callsOperations(get, ["getWorkflowRun", "getWorkflowState"]);
|
|
54740
|
+
get.action(async (runId, _options, command) => {
|
|
54741
|
+
const raw = command.optsWithGlobals().selectOutput;
|
|
54742
|
+
if (raw === undefined) {
|
|
54743
|
+
await previous(command.processedArgs);
|
|
54744
|
+
return;
|
|
54745
|
+
}
|
|
54746
|
+
const typed = await readListValues(raw, SELECT_OUTPUT_FLAG);
|
|
54747
|
+
command.setOptionValue("selectOutput", typed);
|
|
54748
|
+
if (typed.every(isIdHeaded)) {
|
|
54749
|
+
await previous(command.processedArgs);
|
|
54750
|
+
return;
|
|
54751
|
+
}
|
|
54752
|
+
await readRunByName(runId, typed, command, connectGet());
|
|
54753
|
+
});
|
|
54754
|
+
}
|
|
54755
|
+
|
|
54394
54756
|
// src/commands/protocol/workflow-run-wait.ts
|
|
54395
54757
|
var TERMINAL_STATUSES = new Set(["completed", "failed", "cancelled"]);
|
|
54396
54758
|
var WAIT_EXIT_CODES = {
|
|
@@ -54824,6 +55186,14 @@ async function followRun(workflowId, command) {
|
|
|
54824
55186
|
throw new SimApiError(safeOneLine(typeof final.error === "string" ? final.error : "The workflow run failed."), 0);
|
|
54825
55187
|
}
|
|
54826
55188
|
}
|
|
55189
|
+
function stopBlockSelection(selection, flags) {
|
|
55190
|
+
const stopAfter = selection?.stopAfterBlockId;
|
|
55191
|
+
if (stopAfter === undefined)
|
|
55192
|
+
return null;
|
|
55193
|
+
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0)
|
|
55194
|
+
return null;
|
|
55195
|
+
return [BLOCK_ID.test(stopAfter) ? stopAfter : normalizeBlockName(stopAfter)];
|
|
55196
|
+
}
|
|
54827
55197
|
function followOrDelegate(previous) {
|
|
54828
55198
|
return async (workflowId, _options, command) => {
|
|
54829
55199
|
const initialFlags = command.optsWithGlobals();
|
|
@@ -54841,6 +55211,9 @@ function followOrDelegate(previous) {
|
|
|
54841
55211
|
if (selection)
|
|
54842
55212
|
command.setOptionValue("run", selection);
|
|
54843
55213
|
const flags = command.optsWithGlobals();
|
|
55214
|
+
const stopBlock = stopBlockSelection(selection, flags);
|
|
55215
|
+
if (stopBlock)
|
|
55216
|
+
command.setOptionValue("selectOutput", stopBlock);
|
|
54844
55217
|
if (flags.follow !== true) {
|
|
54845
55218
|
if (Array.isArray(flags.selectOutput) && flags.selectOutput.length > 0 && flags.async === true) {
|
|
54846
55219
|
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);
|
|
@@ -54862,6 +55235,18 @@ function followOrDelegate(previous) {
|
|
|
54862
55235
|
await followRun(workflowId, command);
|
|
54863
55236
|
};
|
|
54864
55237
|
}
|
|
55238
|
+
var RUN_HELP = `
|
|
55239
|
+
Without --manual (or a flag that implies it) this runs the active deployment; a workflow never
|
|
55240
|
+
deployed has none. --manual runs the saved draft, as the source loop leaves it.
|
|
55241
|
+
|
|
55242
|
+
The result is the run: runId, status (completed, failed, paused or cancelled), error, output (the
|
|
55243
|
+
workflow's final output) and blockOutputs (what --select-output named). It has no success field:
|
|
55244
|
+
branch on status, or on the exit code. With --follow it is the stream's final frame
|
|
55245
|
+
instead: success and output.
|
|
55246
|
+
|
|
55247
|
+
Exit codes: 0 completed or paused (--async: queued); 1 failed or cancelled (the result is printed
|
|
55248
|
+
first, then the error on stderr), or the command failed; ${STILL_RUNNING_EXIT_CODE} still running when --wait-timeout
|
|
55249
|
+
elapsed.`;
|
|
54865
55250
|
function attachWorkflowRunFollow(workflows) {
|
|
54866
55251
|
const run = workflows.commands.find((command) => command.name() === "run");
|
|
54867
55252
|
if (!run) {
|
|
@@ -54870,113 +55255,7 @@ function attachWorkflowRunFollow(workflows) {
|
|
|
54870
55255
|
const held = run._actionHandler;
|
|
54871
55256
|
const previous = typeof held === "function" ? held : null;
|
|
54872
55257
|
callsOperations(run, ["executeWorkflow", "getWorkflowRun"], { runs: "executeWorkflow" });
|
|
54873
|
-
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));
|
|
54874
|
-
}
|
|
54875
|
-
|
|
54876
|
-
// src/commands/protocol/workflow-run-get.ts
|
|
54877
|
-
var BLOCK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
54878
|
-
var SELECT_OUTPUT_FLAG = "select-output";
|
|
54879
|
-
function normalizeBlockName(name) {
|
|
54880
|
-
return name.toLowerCase().replace(/\s+/g, "").replace(/\./g, "");
|
|
54881
|
-
}
|
|
54882
|
-
async function loadWorkflowBlocks(client, workflowId) {
|
|
54883
|
-
const raw = await client.request("getWorkflowState", { params: { workflowId } });
|
|
54884
|
-
const state = isRecordLike(raw) && isRecordLike(raw.data) ? raw.data : raw;
|
|
54885
|
-
const blocks = isRecordLike(state) && isRecordLike(state.blocks) ? Object.entries(state.blocks) : [];
|
|
54886
|
-
return blocks.map(([key, block]) => ({
|
|
54887
|
-
id: isRecordLike(block) && typeof block.id === "string" ? block.id : key,
|
|
54888
|
-
name: isRecordLike(block) && typeof block.name === "string" ? block.name : ""
|
|
54889
|
-
}));
|
|
54890
|
-
}
|
|
54891
|
-
function splitSelector(selector) {
|
|
54892
|
-
const dot = selector.indexOf(".");
|
|
54893
|
-
return dot === -1 ? { head: selector, path: "" } : { head: selector.slice(0, dot), path: selector.slice(dot) };
|
|
54894
|
-
}
|
|
54895
|
-
function isIdHeaded(selector) {
|
|
54896
|
-
return BLOCK_ID.test(splitSelector(selector).head);
|
|
54897
|
-
}
|
|
54898
|
-
function resolveSelection(typed, blocks, workflowId) {
|
|
54899
|
-
const resolved = [];
|
|
54900
|
-
const typedBy = new Map;
|
|
54901
|
-
const unresolved = [];
|
|
54902
|
-
for (const selector of typed) {
|
|
54903
|
-
const { head, path } = splitSelector(selector);
|
|
54904
|
-
let blockId = head;
|
|
54905
|
-
if (!BLOCK_ID.test(head)) {
|
|
54906
|
-
const wanted = normalizeBlockName(head);
|
|
54907
|
-
const matches = blocks.filter((block) => block.id === head || normalizeBlockName(block.name) === wanted);
|
|
54908
|
-
if (matches.length === 0) {
|
|
54909
|
-
unresolved.push(selector);
|
|
54910
|
-
continue;
|
|
54911
|
-
}
|
|
54912
|
-
if (matches.length > 1) {
|
|
54913
|
-
throw new SimApiError(`--${SELECT_OUTPUT_FLAG} ${selector} names ${matches.length} blocks (${matches.map((block) => block.id).join(", ")}); pass the block id instead`, 0);
|
|
54914
|
-
}
|
|
54915
|
-
blockId = matches[0].id;
|
|
54916
|
-
}
|
|
54917
|
-
const rewritten = `${blockId}${path}`;
|
|
54918
|
-
resolved.push(rewritten);
|
|
54919
|
-
if (!typedBy.has(rewritten))
|
|
54920
|
-
typedBy.set(rewritten, selector);
|
|
54921
|
-
}
|
|
54922
|
-
if (unresolved.length > 0) {
|
|
54923
|
-
const names = blocks.map((block) => block.name).filter((name) => name !== "");
|
|
54924
|
-
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);
|
|
54925
|
-
}
|
|
54926
|
-
return { resolved, typedBy };
|
|
54927
|
-
}
|
|
54928
|
-
function keyByTyped(payload, typedBy) {
|
|
54929
|
-
if (!isRecordLike(payload) || !isRecordLike(payload.blockOutputs))
|
|
54930
|
-
return payload;
|
|
54931
|
-
const blockOutputs = {};
|
|
54932
|
-
for (const [key, value] of Object.entries(payload.blockOutputs)) {
|
|
54933
|
-
blockOutputs[typedBy.get(key) ?? key] = value;
|
|
54934
|
-
}
|
|
54935
|
-
return { ...payload, blockOutputs };
|
|
54936
|
-
}
|
|
54937
|
-
async function readRunByName(runId, typed, command, { client, profile }) {
|
|
54938
|
-
const flags = command.optsWithGlobals();
|
|
54939
|
-
const operation = V2_OPERATIONS.getWorkflowRun;
|
|
54940
|
-
const spec = CLI_CONTRACT.getWorkflowRun ?? {};
|
|
54941
|
-
await buildRequest("getWorkflowRun", [runId], flags, profile.workspaceId);
|
|
54942
|
-
const workflowId = String(flags.workflow);
|
|
54943
|
-
const selection = resolveSelection(typed, await loadWorkflowBlocks(client, workflowId), workflowId);
|
|
54944
|
-
const request = await buildRequest("getWorkflowRun", [runId], { ...flags, selectOutput: selection.resolved }, profile.workspaceId);
|
|
54945
|
-
let result;
|
|
54946
|
-
try {
|
|
54947
|
-
result = await client.request("getWorkflowRun", {
|
|
54948
|
-
params: request.params,
|
|
54949
|
-
headers: request.headers,
|
|
54950
|
-
query: request.query,
|
|
54951
|
-
body: request.body
|
|
54952
|
-
});
|
|
54953
|
-
} catch (error) {
|
|
54954
|
-
throw retypeApiError(error, "getWorkflowRun", spec, operation);
|
|
54955
|
-
}
|
|
54956
|
-
renderResult("getWorkflowRun", profile.output, keyByTyped(result?.data ?? result, selection.typedBy), spec, {}, result);
|
|
54957
|
-
}
|
|
54958
|
-
function attachWorkflowRunGet(runs) {
|
|
54959
|
-
const get = runs.commands.find((command) => command.name() === "get");
|
|
54960
|
-
const held = get?._actionHandler;
|
|
54961
|
-
if (!get || typeof held !== "function") {
|
|
54962
|
-
throw new Error("workflows runs get must be registered before block names can be attached to it");
|
|
54963
|
-
}
|
|
54964
|
-
const previous = held;
|
|
54965
|
-
const connectGet = callsOperations(get, ["getWorkflowRun", "getWorkflowState"]);
|
|
54966
|
-
get.action(async (runId, _options, command) => {
|
|
54967
|
-
const raw = command.optsWithGlobals().selectOutput;
|
|
54968
|
-
if (raw === undefined) {
|
|
54969
|
-
await previous(command.processedArgs);
|
|
54970
|
-
return;
|
|
54971
|
-
}
|
|
54972
|
-
const typed = await readListValues(raw, SELECT_OUTPUT_FLAG);
|
|
54973
|
-
command.setOptionValue("selectOutput", typed);
|
|
54974
|
-
if (typed.every(isIdHeaded)) {
|
|
54975
|
-
await previous(command.processedArgs);
|
|
54976
|
-
return;
|
|
54977
|
-
}
|
|
54978
|
-
await readRunByName(runId, typed, command, connectGet());
|
|
54979
|
-
});
|
|
55258
|
+
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));
|
|
54980
55259
|
}
|
|
54981
55260
|
|
|
54982
55261
|
// ../../node_modules/minisearch/dist/es/index.js
|
|
@@ -56192,7 +56471,7 @@ function sourceExitCodeRows(prefix) {
|
|
|
56192
56471
|
"workflows source apply": "the source has errors (each printed as file:line:column with its frame and hint) or the command failed",
|
|
56193
56472
|
"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)",
|
|
56194
56473
|
"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)",
|
|
56195
|
-
"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
|
|
56474
|
+
"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",
|
|
56196
56475
|
"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)"
|
|
56197
56476
|
}
|
|
56198
56477
|
},
|
|
@@ -56292,10 +56571,10 @@ function sourceExitCodeRows(prefix) {
|
|
|
56292
56571
|
},
|
|
56293
56572
|
{
|
|
56294
56573
|
code: SOURCE_HELD_EXIT_CODE,
|
|
56295
|
-
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",
|
|
56574
|
+
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",
|
|
56296
56575
|
next: "Set the secret (`sim secrets set`) or connect the credential, then apply again",
|
|
56297
56576
|
help: {
|
|
56298
|
-
"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)"
|
|
56577
|
+
"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"
|
|
56299
56578
|
}
|
|
56300
56579
|
},
|
|
56301
56580
|
{
|
|
@@ -57060,7 +57339,7 @@ async function runSourceWrite(flow) {
|
|
|
57060
57339
|
preview = await flow.preview();
|
|
57061
57340
|
flow.show(preview);
|
|
57062
57341
|
if (preview.diagnostics.some((finding) => finding.severity === "error")) {
|
|
57063
|
-
setSoftExitCode(refusedExitCode(preview.diagnostics));
|
|
57342
|
+
setSoftExitCode(flow.previewExitCode?.(preview) ?? refusedExitCode(preview.diagnostics));
|
|
57064
57343
|
}
|
|
57065
57344
|
if (flow.mode === "dry-run" || flow.refuses(preview)) {
|
|
57066
57345
|
flow.report(preview);
|
|
@@ -57260,12 +57539,18 @@ async function readBase(directory, workflowId) {
|
|
|
57260
57539
|
}
|
|
57261
57540
|
return base;
|
|
57262
57541
|
}
|
|
57542
|
+
var WORKFLOW_GET = `\`sim workflows source get <workflowId> --dir <new dir>\`, with the id from ${SOURCE_BASE_FILE}`;
|
|
57543
|
+
function lockRecoveryHint(get = WORKFLOW_GET) {
|
|
57544
|
+
return `Restore ${SOURCE_LOCK_FILE} from version control, or write the source into a fresh directory (${get}) and carry your edits across.`;
|
|
57545
|
+
}
|
|
57546
|
+
function lockProblem(finding) {
|
|
57547
|
+
return `${finding.path ? `${finding.path}: ` : ""}${finding.message}`;
|
|
57548
|
+
}
|
|
57263
57549
|
async function readLock(directory) {
|
|
57264
57550
|
const parsed = parseWorkflowLock(await readJson(directory, SOURCE_LOCK_FILE, GET_HINT));
|
|
57265
57551
|
if (parsed.lock)
|
|
57266
57552
|
return parsed.lock;
|
|
57267
|
-
|
|
57268
|
-
throw new SourceDirError(`${SOURCE_LOCK_FILE} in ${directory} is not a valid lock: ${problems.join("; ")}`);
|
|
57553
|
+
throw new SourceDirError(`${SOURCE_LOCK_FILE} in ${directory} is not a valid lock: ${parsed.diagnostics.map(lockProblem).join("; ")}. ${lockRecoveryHint()}`);
|
|
57269
57554
|
}
|
|
57270
57555
|
function requireEntry(directory) {
|
|
57271
57556
|
return requireText(directory, SOURCE_ENTRY_FILE, GET_HINT);
|
|
@@ -57304,7 +57589,7 @@ The primer above is enough to edit; read a section here when a step needs it.
|
|
|
57304
57589
|
|
|
57305
57590
|
## Edit loop in detail
|
|
57306
57591
|
|
|
57307
|
-
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
|
|
57592
|
+
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}\`.
|
|
57308
57593
|
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\`.
|
|
57309
57594
|
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.
|
|
57310
57595
|
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.
|
|
@@ -57776,7 +58061,7 @@ function summarize(data, creating, machine) {
|
|
|
57776
58061
|
import { join as join9 } from "node:path";
|
|
57777
58062
|
|
|
57778
58063
|
// ../workspace-code/src/declaration/read.ts
|
|
57779
|
-
var
|
|
58064
|
+
var import_parser6 = __toESM(require_lib(), 1);
|
|
57780
58065
|
|
|
57781
58066
|
// ../workspace-code/src/limits.ts
|
|
57782
58067
|
var WORKSPACE_SOURCE_LIMITS = {
|
|
@@ -57900,7 +58185,7 @@ function readDeclaration(file, raw, options) {
|
|
|
57900
58185
|
}
|
|
57901
58186
|
let program;
|
|
57902
58187
|
try {
|
|
57903
|
-
program =
|
|
58188
|
+
program = import_parser6.parse(text, PARSER_OPTIONS2).program;
|
|
57904
58189
|
} catch (error) {
|
|
57905
58190
|
if (error instanceof RangeError) {
|
|
57906
58191
|
diagnostics.push(diagnostic2("E_LIMIT_EXCEEDED", "The file is nested too deeply to parse.", { ...at(0, 0) }));
|
|
@@ -62260,7 +62545,7 @@ var ZodRealError = $constructor("ZodError", initializer2, {
|
|
|
62260
62545
|
});
|
|
62261
62546
|
|
|
62262
62547
|
// ../../node_modules/zod/v4/classic/parse.js
|
|
62263
|
-
var
|
|
62548
|
+
var parse9 = /* @__PURE__ */ _parse(ZodRealError);
|
|
62264
62549
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
62265
62550
|
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
62266
62551
|
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
@@ -62303,7 +62588,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
62303
62588
|
reg.add(inst, meta);
|
|
62304
62589
|
return inst;
|
|
62305
62590
|
};
|
|
62306
|
-
inst.parse = (data, params) =>
|
|
62591
|
+
inst.parse = (data, params) => parse9(inst, data, params, { callee: inst.parse });
|
|
62307
62592
|
inst.safeParse = (data, params) => safeParse2(inst, data, params);
|
|
62308
62593
|
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
62309
62594
|
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
@@ -64322,9 +64607,11 @@ var STRICT_CODES = new Set([
|
|
|
64322
64607
|
"W_LITERAL_SECRET",
|
|
64323
64608
|
"W_TABLE_UNKNOWN_COLUMN",
|
|
64324
64609
|
"W_CHILD_INPUT_UNKNOWN",
|
|
64610
|
+
"W_CHILD_RESULT_PATH",
|
|
64325
64611
|
"W_BRANCH_UNWIRED",
|
|
64326
64612
|
"W_UNRESOLVED_REF",
|
|
64327
|
-
"W_REF_OUT_OF_SCOPE"
|
|
64613
|
+
"W_REF_OUT_OF_SCOPE",
|
|
64614
|
+
"W_LOOP_CONDITION_SYNTAX"
|
|
64328
64615
|
]);
|
|
64329
64616
|
var STORED_EXEMPT_CODES = new Set(["W_BRANCH_UNWIRED"]);
|
|
64330
64617
|
var EDIT_SCOPED_CODES = new Set(["W_JSON_REF_UNTYPED"]);
|
|
@@ -64413,25 +64700,29 @@ function inputMappingOf(canonical) {
|
|
|
64413
64700
|
const value = rowJson(mapping.value);
|
|
64414
64701
|
return toRecord(value);
|
|
64415
64702
|
}
|
|
64416
|
-
function
|
|
64703
|
+
function calledWorkflowKey(canonical) {
|
|
64417
64704
|
const ref = canonical.params.workflowId;
|
|
64418
64705
|
const child = ref?.kind === "value" ? resourceNode(ref.value) : null;
|
|
64419
|
-
|
|
64706
|
+
return child?.kind === "workflow" ? child.key : null;
|
|
64707
|
+
}
|
|
64708
|
+
function childInputFindings(block, canonical, declarations) {
|
|
64709
|
+
const childKey = calledWorkflowKey(canonical);
|
|
64710
|
+
if (childKey === null)
|
|
64420
64711
|
return [];
|
|
64421
|
-
const inputs = declarations.workflowInputs?.get(
|
|
64712
|
+
const inputs = declarations.workflowInputs?.get(childKey);
|
|
64422
64713
|
if (inputs === undefined)
|
|
64423
64714
|
return [];
|
|
64424
|
-
const entry = `${KIND_DIRS.workflow}/${
|
|
64715
|
+
const entry = `${KIND_DIRS.workflow}/${childKey}/${SOURCE_ENTRY_FILE}`;
|
|
64425
64716
|
if (inputs === null) {
|
|
64426
64717
|
return [
|
|
64427
64718
|
{
|
|
64428
64719
|
code: "W_CHILD_NO_START",
|
|
64429
64720
|
severity: "warning",
|
|
64430
|
-
message: `Workflow "${
|
|
64721
|
+
message: `Workflow "${childKey}" has no Start trigger, so it takes no inputs and a call cannot run it.`,
|
|
64431
64722
|
hint: `Add trigger.start('Start', { inputFormat: { … } }) to ${entry}, or call a workflow that has one.`,
|
|
64432
64723
|
block,
|
|
64433
64724
|
param: "workflowId",
|
|
64434
|
-
names:
|
|
64725
|
+
names: childKey
|
|
64435
64726
|
}
|
|
64436
64727
|
];
|
|
64437
64728
|
}
|
|
@@ -64439,12 +64730,65 @@ function childInputFindings(block, canonical, declarations) {
|
|
|
64439
64730
|
return Object.keys(inputMappingOf(canonical)).filter((field) => !names.includes(field)).map((field) => ({
|
|
64440
64731
|
code: "W_CHILD_INPUT_UNKNOWN",
|
|
64441
64732
|
severity: "warning",
|
|
64442
|
-
message: `inputMapping sets ${field}, which is not an input of workflow "${
|
|
64733
|
+
message: `inputMapping sets ${field}, which is not an input of workflow "${childKey}"; the child never receives it.`,
|
|
64443
64734
|
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.`,
|
|
64444
64735
|
block,
|
|
64445
64736
|
param: "inputMapping"
|
|
64446
64737
|
}));
|
|
64447
64738
|
}
|
|
64739
|
+
function childResultFindings(workflow, declarations) {
|
|
64740
|
+
const responding = declarations.respondingWorkflows;
|
|
64741
|
+
if (!responding || responding.size === 0)
|
|
64742
|
+
return [];
|
|
64743
|
+
const calls = new Map;
|
|
64744
|
+
for (const [key, block] of Object.entries(workflow.blocks)) {
|
|
64745
|
+
const child = calledWorkflowKey(block);
|
|
64746
|
+
if (child !== null && responding.has(child))
|
|
64747
|
+
calls.set(key, child);
|
|
64748
|
+
}
|
|
64749
|
+
if (calls.size === 0)
|
|
64750
|
+
return [];
|
|
64751
|
+
const findings = [];
|
|
64752
|
+
for (const [block, canonical] of Object.entries(workflow.blocks)) {
|
|
64753
|
+
for (const [param, value] of Object.entries(canonical.params)) {
|
|
64754
|
+
if (value.kind !== "value")
|
|
64755
|
+
continue;
|
|
64756
|
+
const reported = new Set;
|
|
64757
|
+
const leaves = [];
|
|
64758
|
+
collectStringLeaves(value.value, leaves);
|
|
64759
|
+
for (const text of leaves) {
|
|
64760
|
+
for (const token of findWorkflowReferenceTokens(text)) {
|
|
64761
|
+
if (token.kind !== "workflow" || reported.has(token.value))
|
|
64762
|
+
continue;
|
|
64763
|
+
const segments = parseStoredPath(token.value.slice(1, -1));
|
|
64764
|
+
const [head, output, field, ...rest] = segments ?? [];
|
|
64765
|
+
const child = head?.kind === "name" ? calls.get(head.name) : undefined;
|
|
64766
|
+
if (child === undefined || output?.kind !== "name" || output.name !== "result")
|
|
64767
|
+
continue;
|
|
64768
|
+
if (field?.kind !== "name" || RESPONSE_OUTPUTS.includes(field.name))
|
|
64769
|
+
continue;
|
|
64770
|
+
reported.add(token.value);
|
|
64771
|
+
const meant = formatStoredPath([
|
|
64772
|
+
head,
|
|
64773
|
+
output,
|
|
64774
|
+
{ kind: "name", name: "data" },
|
|
64775
|
+
field,
|
|
64776
|
+
...rest
|
|
64777
|
+
]);
|
|
64778
|
+
findings.push({
|
|
64779
|
+
code: "W_CHILD_RESULT_PATH",
|
|
64780
|
+
severity: "warning",
|
|
64781
|
+
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.`,
|
|
64782
|
+
hint: `Did you mean <${meant}>? A field of the child's Response data is result.data.${field.name}.`,
|
|
64783
|
+
block,
|
|
64784
|
+
param
|
|
64785
|
+
});
|
|
64786
|
+
}
|
|
64787
|
+
}
|
|
64788
|
+
}
|
|
64789
|
+
}
|
|
64790
|
+
return findings;
|
|
64791
|
+
}
|
|
64448
64792
|
function declarationFindings(workflow, declarations) {
|
|
64449
64793
|
const findings = [];
|
|
64450
64794
|
for (const [block, canonical] of Object.entries(workflow.blocks)) {
|
|
@@ -64513,10 +64857,13 @@ function declarationFindings(workflow, declarations) {
|
|
|
64513
64857
|
}
|
|
64514
64858
|
}
|
|
64515
64859
|
}
|
|
64860
|
+
findings.push(...childResultFindings(workflow, declarations));
|
|
64516
64861
|
return findings;
|
|
64517
64862
|
}
|
|
64518
64863
|
async function compileWorkflowDir(dir, workspaceCatalog, declarations) {
|
|
64519
|
-
const
|
|
64864
|
+
const lockText = await readSourceText(dir, SOURCE_LOCK_FILE);
|
|
64865
|
+
const parsedLock = lockText === null ? null : parseWorkflowLock(lockText);
|
|
64866
|
+
const lock = parsedLock?.lock;
|
|
64520
64867
|
const [files, storedEdges, storedBlocks, printedWith] = await Promise.all([
|
|
64521
64868
|
readSourceFiles(dir, lock ?? null),
|
|
64522
64869
|
readStoredEdges(dir),
|
|
@@ -64535,16 +64882,35 @@ async function compileWorkflowDir(dir, workspaceCatalog, declarations) {
|
|
|
64535
64882
|
...storedEdges ? { storedUnreadEdges: storedEdges } : {},
|
|
64536
64883
|
...envNames ? { envNames, envDeclaredIn: KIND_DIRS.secret } : {}
|
|
64537
64884
|
});
|
|
64538
|
-
return {
|
|
64885
|
+
return {
|
|
64886
|
+
lock,
|
|
64887
|
+
lockProblems: parsedLock?.diagnostics ?? [],
|
|
64888
|
+
files,
|
|
64889
|
+
compiled,
|
|
64890
|
+
storedBlocks,
|
|
64891
|
+
printedWith,
|
|
64892
|
+
catalog
|
|
64893
|
+
};
|
|
64894
|
+
}
|
|
64895
|
+
async function readCheckDeclarations(root, catalog) {
|
|
64896
|
+
const [declared, workflows] = await Promise.all([
|
|
64897
|
+
readWorkspaceDeclarations(root),
|
|
64898
|
+
compileWorkspaceWorkflows(root, catalog)
|
|
64899
|
+
]);
|
|
64900
|
+
return { ...declared, ...workflows };
|
|
64539
64901
|
}
|
|
64540
|
-
async function
|
|
64541
|
-
const
|
|
64902
|
+
async function compileWorkspaceWorkflows(root, catalog) {
|
|
64903
|
+
const workflowInputs = new Map;
|
|
64904
|
+
const respondingWorkflows = new Set;
|
|
64542
64905
|
for (const key of await workspaceWorkflowKeys(root)) {
|
|
64543
64906
|
const { compiled } = await compileWorkflowDir(join9(root, KIND_DIRS.workflow, key), catalog);
|
|
64544
|
-
if (compiled.workflow)
|
|
64545
|
-
|
|
64907
|
+
if (!compiled.workflow)
|
|
64908
|
+
continue;
|
|
64909
|
+
workflowInputs.set(key, startInputs(compiled.workflow));
|
|
64910
|
+
if (respondsOnEveryRun(compiled.workflow))
|
|
64911
|
+
respondingWorkflows.add(key);
|
|
64546
64912
|
}
|
|
64547
|
-
return
|
|
64913
|
+
return { workflowInputs, respondingWorkflows };
|
|
64548
64914
|
}
|
|
64549
64915
|
function withWorkflowInputs(local, inputs) {
|
|
64550
64916
|
const workflows = { ...local.workflows };
|
|
@@ -64557,7 +64923,7 @@ function withWorkflowInputs(local, inputs) {
|
|
|
64557
64923
|
}
|
|
64558
64924
|
async function checkWorkflowDir(dir, catalog, options) {
|
|
64559
64925
|
const compiledDir = await compileWorkflowDir(dir, catalog, options.declarations);
|
|
64560
|
-
const { lock, files, compiled, storedBlocks, printedWith } = compiledDir;
|
|
64926
|
+
const { lock, lockProblems, files, compiled, storedBlocks, printedWith } = compiledDir;
|
|
64561
64927
|
const entryText = files[SOURCE_ENTRY_FILE];
|
|
64562
64928
|
const locate = (block, param, names) => {
|
|
64563
64929
|
const prefix = encodeAnchor({ kind: "param", block, param: "" });
|
|
@@ -64637,6 +65003,14 @@ async function checkWorkflowDir(dir, catalog, options) {
|
|
|
64637
65003
|
}, { changed, codeEdited }),
|
|
64638
65004
|
...compiled.diagnostics.filter(exempt)
|
|
64639
65005
|
];
|
|
65006
|
+
const lockFindings = lockProblems.map((problem) => ({
|
|
65007
|
+
code: problem.code,
|
|
65008
|
+
severity: "error",
|
|
65009
|
+
message: `${problem.message} Every apply and status refuses this lock.`,
|
|
65010
|
+
hint: lockRecoveryHint(options.declarations ? "`sim workspaces source get --dir <new dir>`, from the workspace directory" : undefined),
|
|
65011
|
+
file: `${prefix}${SOURCE_LOCK_FILE}`,
|
|
65012
|
+
...problem.path ? { path: problem.path } : {}
|
|
65013
|
+
}));
|
|
64640
65014
|
const findings = [
|
|
64641
65015
|
...refused.filter((diagnostic) => reported(diagnostic.code, diagnostic.blockKey)),
|
|
64642
65016
|
...declared
|
|
@@ -64684,7 +65058,7 @@ async function checkWorkflowDir(dir, catalog, options) {
|
|
|
64684
65058
|
else
|
|
64685
65059
|
unlisted.warnings += count;
|
|
64686
65060
|
}
|
|
64687
|
-
return { findings, entry: entryText, unlisted };
|
|
65061
|
+
return { findings: [...lockFindings, ...findings], entry: entryText, unlisted };
|
|
64688
65062
|
}
|
|
64689
65063
|
function reportCheck(output, findings, result, options = {}) {
|
|
64690
65064
|
const shown = findingsOutput(output, options.verbose, options.dir);
|
|
@@ -64737,10 +65111,7 @@ function attachWorkflowSourceCheck(source) {
|
|
|
64737
65111
|
throw new CliUsageError(`${options.dir} has no ${SOURCE_BASE_FILE} and no workspace is selected: pass --workspace <workspaceId>.`);
|
|
64738
65112
|
}
|
|
64739
65113
|
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\`)`);
|
|
64740
|
-
const declarations = workspace ?
|
|
64741
|
-
...await readWorkspaceDeclarations(workspace.root),
|
|
64742
|
-
workflowInputs: await workspaceWorkflowInputs(workspace.root, catalog)
|
|
64743
|
-
} : undefined;
|
|
65114
|
+
const declarations = workspace ? await readCheckDeclarations(workspace.root, catalog) : undefined;
|
|
64744
65115
|
const { findings, entry, unlisted } = await checkWorkflowDir(options.dir, catalog, {
|
|
64745
65116
|
strict: strictMode(options),
|
|
64746
65117
|
...declarations ? { declarations } : {}
|
|
@@ -64841,8 +65212,9 @@ Prints a builder's params (required first, with enums and defaults), the gate fi
|
|
|
64841
65212
|
which others apply, and its outputs, from the block catalog the last get, create or check cached.
|
|
64842
65213
|
No request is made. <builder> is the dotted builder path as source writes it: table.upsertRow,
|
|
64843
65214
|
agent, trigger.schedule, slack.sendMessage (slack.tool.sendMessage names the same builder). A
|
|
64844
|
-
namespace (gmail, trigger.gmail) lists its builders; a
|
|
64845
|
-
|
|
65215
|
+
namespace (gmail, trigger.gmail) lists its builders; a block type prints the builder written for
|
|
65216
|
+
it (function is fn) or lists them (table_v2); a construct core.d.ts declares (loop, parallel, t,
|
|
65217
|
+
env) prints its declaration. Run it from a workflow or workspace source directory,
|
|
64846
65218
|
or pass --dir.
|
|
64847
65219
|
|
|
64848
65220
|
Exit codes: 0 printed; 1 no builder or namespace of that name (the closest one is named), or no
|
|
@@ -65509,10 +65881,14 @@ function splitLines2(text) {
|
|
|
65509
65881
|
return result;
|
|
65510
65882
|
}
|
|
65511
65883
|
// src/commands/protocol/source-status.ts
|
|
65512
|
-
function planFindings(diagnostics
|
|
65513
|
-
return diagnostics.filter((finding) =>
|
|
65884
|
+
function planFindings(diagnostics) {
|
|
65885
|
+
return diagnostics.filter((finding) => finding.severity === "error" || finding.severity === "warning" || finding.code === "I_FINDINGS_TRUNCATED");
|
|
65514
65886
|
}
|
|
65515
65887
|
var STATUS_EXIT_CODES_HELP = `
|
|
65888
|
+
With --json, \`plan\` is what applying would do as \`apply --dry-run --allow-delete\` reports it
|
|
65889
|
+
(its errors and warnings counted the same, a conflict as an error), and \`next\` the command to
|
|
65890
|
+
run (with --allow-delete only when the plan deletes something).
|
|
65891
|
+
|
|
65516
65892
|
Exit codes: 0 clean (nothing to apply, and the server changed nothing since the directory was
|
|
65517
65893
|
read); ${SOURCE_LOCAL_CHANGES_EXIT_CODE} local changes only (applying writes them); ${SOURCE_DRIFT_EXIT_CODE} the server changed since the
|
|
65518
65894
|
directory was read: drift (a resource edited, added or deleted there that the directory leaves
|
|
@@ -65671,7 +66047,7 @@ function realPath(path) {
|
|
|
65671
66047
|
function filterForms(filter, dir) {
|
|
65672
66048
|
const forms = new Set;
|
|
65673
66049
|
if (!isAbsolute3(filter)) {
|
|
65674
|
-
const given = filter.replace(/\\/g, "/").replace(/^(\.\/)+/, "")
|
|
66050
|
+
const given = stripTrailingSlashes(filter.replace(/\\/g, "/").replace(/^(\.\/)+/, ""));
|
|
65675
66051
|
forms.add(given === "" ? "." : given);
|
|
65676
66052
|
}
|
|
65677
66053
|
const resolved = relative2(realPath(resolve6(dir)), realPath(resolve6(filter))).split(sep).join("/");
|
|
@@ -65785,7 +66161,7 @@ async function readLocalWorkflow(dir) {
|
|
|
65785
66161
|
};
|
|
65786
66162
|
}
|
|
65787
66163
|
function workflowPlanFindings(data) {
|
|
65788
|
-
return planFindings(data.diagnostics
|
|
66164
|
+
return planFindings(data.diagnostics).filter((finding) => finding.code !== "E_APPLY_STALE");
|
|
65789
66165
|
}
|
|
65790
66166
|
function planSummary(data) {
|
|
65791
66167
|
const planned = workflowPlanFindings(data);
|
|
@@ -65796,12 +66172,14 @@ function planSummary(data) {
|
|
|
65796
66172
|
blocksModified: data.diff.blocks.modified.length,
|
|
65797
66173
|
edgesAdded: data.diff.edges.added,
|
|
65798
66174
|
edgesRemoved: data.diff.edges.removed,
|
|
66175
|
+
variablesRemoved: data.diff.variables.removed.length,
|
|
65799
66176
|
errors: findings("error"),
|
|
65800
66177
|
warnings: findings("warning")
|
|
65801
66178
|
};
|
|
65802
66179
|
}
|
|
65803
66180
|
function planLine(plan) {
|
|
65804
|
-
|
|
66181
|
+
const variables = plan.variablesRemoved > 0 ? `, variables -${plan.variablesRemoved}` : "";
|
|
66182
|
+
return `Applying would: blocks +${plan.blocksAdded} -${plan.blocksRemoved} ~${plan.blocksModified}, connections +${plan.edgesAdded} -${plan.edgesRemoved}${variables}; ${plan.errors} error(s), ${plan.warnings} warning(s).`;
|
|
65805
66183
|
}
|
|
65806
66184
|
function attachWorkflowSourceStatus(source) {
|
|
65807
66185
|
const [command, connect] = apiCommand(source, "status", [
|
|
@@ -65879,7 +66257,7 @@ function attachWorkflowSourceStatus(source) {
|
|
|
65879
66257
|
getArgs: `${workflowId} `,
|
|
65880
66258
|
server,
|
|
65881
66259
|
errors: plan?.errors ?? 0,
|
|
65882
|
-
deletes: (plan?.blocksRemoved ?? 0) > 0,
|
|
66260
|
+
deletes: (plan?.blocksRemoved ?? 0) + (plan?.variablesRemoved ?? 0) > 0,
|
|
65883
66261
|
scope: "",
|
|
65884
66262
|
login
|
|
65885
66263
|
})
|
|
@@ -66157,11 +66535,19 @@ function failedExitCode(failed) {
|
|
|
66157
66535
|
return failed.code === "E_APPLY_FAILED" ? SOURCE_PARTIAL_EXIT_CODE : refusedExitCode([{ code: failed.code, severity: "error" }]);
|
|
66158
66536
|
}
|
|
66159
66537
|
function isHeldFinding(plan, finding) {
|
|
66160
|
-
return plan.some((change) => change.held && change.kind === finding.kind && change.key === finding.key);
|
|
66538
|
+
return finding.code !== "E_PLAN_REF_DELETED" && plan.some((change) => change.held && change.kind === finding.kind && change.key === finding.key);
|
|
66161
66539
|
}
|
|
66162
66540
|
function refusesApply(data) {
|
|
66541
|
+
if (data.refuses !== undefined)
|
|
66542
|
+
return data.refuses;
|
|
66163
66543
|
return data.diagnostics.some((finding) => finding.severity === "error" && !isHeldFinding(data.plan, finding));
|
|
66164
66544
|
}
|
|
66545
|
+
function previewExitCode(data) {
|
|
66546
|
+
if (refusesApply(data))
|
|
66547
|
+
return refusedExitCode(data.diagnostics);
|
|
66548
|
+
const writesSome = data.plan.some((change) => change.action !== "noop" && !change.held);
|
|
66549
|
+
return writesSome ? SOURCE_HELD_EXIT_CODE : 1;
|
|
66550
|
+
}
|
|
66165
66551
|
var sameChange = (a, b) => a.kind === b.kind && a.key === b.key;
|
|
66166
66552
|
function wasWritten(change, outcome) {
|
|
66167
66553
|
return outcome.applied.some((written) => sameChange(written, change));
|
|
@@ -66595,6 +66981,7 @@ function attachWorkspaceSourceApply(source) {
|
|
|
66595
66981
|
findings.print(preview.diagnostics);
|
|
66596
66982
|
},
|
|
66597
66983
|
refuses: refusesApply,
|
|
66984
|
+
previewExitCode,
|
|
66598
66985
|
beforeCommit: (preview) => stage(submission, preview ? new Set(preview.needBlobs) : blobsToStage(submission)),
|
|
66599
66986
|
commit: async () => {
|
|
66600
66987
|
const answer = reported(await send(submission, false));
|
|
@@ -66807,11 +67194,7 @@ ${SOURCE_DIR_BUSY_HELP}`).action(async (options, command) => {
|
|
|
66807
67194
|
}
|
|
66808
67195
|
await withSourceDirLock(options.dir, async () => {
|
|
66809
67196
|
const catalog = cachedCatalog(workspaceId) ?? await fetchedCatalog(connect, workspaceId, options.dir);
|
|
66810
|
-
const
|
|
66811
|
-
const declarations = {
|
|
66812
|
-
...await readWorkspaceDeclarations(options.dir),
|
|
66813
|
-
workflowInputs
|
|
66814
|
-
};
|
|
67197
|
+
const declarations = await readCheckDeclarations(options.dir, catalog);
|
|
66815
67198
|
const keys = await workspaceWorkflowKeys(options.dir);
|
|
66816
67199
|
const findings = [];
|
|
66817
67200
|
const unlisted = { errors: 0, warnings: 0 };
|
|
@@ -66844,7 +67227,7 @@ ${SOURCE_DIR_BUSY_HELP}`).action(async (options, command) => {
|
|
|
66844
67227
|
column
|
|
66845
67228
|
});
|
|
66846
67229
|
}
|
|
66847
|
-
await refreshWorkspaceTypes(options.dir, withWorkflowInputs(declarations.local, workflowInputs));
|
|
67230
|
+
await refreshWorkspaceTypes(options.dir, withWorkflowInputs(declarations.local, declarations.workflowInputs));
|
|
66848
67231
|
await refreshWorkspaceTsconfigs(options.dir, workspaceId);
|
|
66849
67232
|
reportCheck(profile.output, findings, { workflows: keys.length, catalogHash: catalog.hash }, {
|
|
66850
67233
|
verbose: options.verbose === true,
|
|
@@ -67116,8 +67499,8 @@ function aboutWorkflowSentByBase(item, byBase) {
|
|
|
67116
67499
|
function planAsApplied(plan, byBase) {
|
|
67117
67500
|
return plan.map((change) => aboutWorkflowSentByBase(change, byBase) && change.action !== "noop" ? { kind: change.kind, key: change.key, action: "noop" } : change);
|
|
67118
67501
|
}
|
|
67119
|
-
function
|
|
67120
|
-
return planFindings(data.diagnostics
|
|
67502
|
+
function dryRunFindings(data, byBase) {
|
|
67503
|
+
return planFindings(data.diagnostics).filter((finding) => !(aboutWorkflowSentByBase(finding, byBase) && (isFolderEvaluationFinding(finding) || finding.code === "E_APPLY_STALE")));
|
|
67121
67504
|
}
|
|
67122
67505
|
function planSummary2(findings, plan, conflicts) {
|
|
67123
67506
|
const count = (...actions) => plan.filter((change) => actions.includes(change.action)).length;
|
|
@@ -67135,7 +67518,7 @@ function planSummary2(findings, plan, conflicts) {
|
|
|
67135
67518
|
}
|
|
67136
67519
|
function planLine2(plan) {
|
|
67137
67520
|
const counts = `${plan.create} create, ${plan.update} update, ${plan.delete} delete (${plan.unchanged} unchanged); ${plan.errors} error(s), ${plan.warnings} warning(s)`;
|
|
67138
|
-
return plan.conflicts > 0 ? `Applying would be refused as stale (exit ${SOURCE_STALE_EXIT_CODE}): ${plan.conflicts} conflict(s) above.
|
|
67521
|
+
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}.`;
|
|
67139
67522
|
}
|
|
67140
67523
|
function fitsWhole(files) {
|
|
67141
67524
|
const paths = Object.keys(files).filter((path) => kindOfPath(path) === "workflow");
|
|
@@ -67222,8 +67605,9 @@ ${SOURCE_DIR_BUSY_HELP}`).action(async (options, invoked) => {
|
|
|
67222
67605
|
}
|
|
67223
67606
|
const skipped = data ? await skippedResources(options.dir) : new Set;
|
|
67224
67607
|
const status = sourceStatus(locals, data ? serverResourceChanges(data.diagnostics).filter((change) => !(change.server === "added" && skipped.has(`${change.kind}:${change.key}`))) : []);
|
|
67225
|
-
const
|
|
67226
|
-
const
|
|
67608
|
+
const dryRun = data ? dryRunFindings(data, byBase) : [];
|
|
67609
|
+
const planned = dryRun.filter((finding) => !isServerChangeFinding(finding.code));
|
|
67610
|
+
const plan = data ? planSummary2(dryRun, applyPlan, status.conflicts.length) : null;
|
|
67227
67611
|
const report = {
|
|
67228
67612
|
workspaceId,
|
|
67229
67613
|
dir: options.dir,
|
|
@@ -69070,7 +69454,7 @@ class Parser extends Transform2 {
|
|
|
69070
69454
|
callback(err);
|
|
69071
69455
|
}
|
|
69072
69456
|
}
|
|
69073
|
-
var
|
|
69457
|
+
var parse11 = function() {
|
|
69074
69458
|
let data, options, callback;
|
|
69075
69459
|
for (const i in arguments) {
|
|
69076
69460
|
const argument = arguments[i];
|
|
@@ -69235,7 +69619,7 @@ async function stagePermissionCsvs(provider, paths, signal) {
|
|
|
69235
69619
|
parts.push({ field, path: partPath });
|
|
69236
69620
|
totalBytes += partBytes;
|
|
69237
69621
|
};
|
|
69238
|
-
const parser =
|
|
69622
|
+
const parser = parse11({
|
|
69239
69623
|
bom: true,
|
|
69240
69624
|
trim: true,
|
|
69241
69625
|
skip_empty_lines: true,
|
|
@@ -69599,6 +69983,15 @@ Profiles work like the AWS CLI: settings live in ~/.sim/config, keys in
|
|
|
69599
69983
|
~/.sim/credentials (0600), or under SIM_CONFIG_DIR when it is set. Select one
|
|
69600
69984
|
with -P, --profile, or SIM_PROFILE.
|
|
69601
69985
|
|
|
69986
|
+
A command targets the profile's workspace unless -w <id> (--workspace <id>) or
|
|
69987
|
+
SIM_WORKSPACE names another. A source directory records its own: a workflow
|
|
69988
|
+
directory acts on the workflow its .sim/base.json names, a workspace directory
|
|
69989
|
+
on the workspace its base names (refusing a -w naming another), and a starter
|
|
69990
|
+
on the one .sim/starter.json names unless -w names another. In a script, export
|
|
69991
|
+
SIM_WORKSPACE=<id> once, or keep only the ID in a variable and write -w "$WS".
|
|
69992
|
+
A variable holding "--workspace <id>" is one argument: alone it is an unknown
|
|
69993
|
+
option, and after -w all of it is taken as the ID.
|
|
69994
|
+
|
|
69602
69995
|
Workflow, knowledge-base and workspace IDs are bare UUIDs. Table IDs carry a
|
|
69603
69996
|
tbl_ prefix and file IDs a wf_ one, so wf_ never names a workflow. An audit-log
|
|
69604
69997
|
or custom-tool ID can open with a dash, which reads as a flag; put -- in front
|