@frontera-sdk/workflow 1.50.62-next.0

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Sebati
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,150 @@
1
+ # @frontera-sdk/workflow
2
+
3
+ A typed, headless client for Frontera workflows. From a script or a backend it
4
+ authors and publishes a definition, starts runs, reads the run tree, waits for a
5
+ run to settle, and manages versions and agent access. No React, no UI.
6
+
7
+ ```bash
8
+ bun add @frontera-sdk/workflow @frontera-sdk/core
9
+ ```
10
+
11
+ ## Credential
12
+
13
+ Use a workspace key (`sk-ws-…`). Workflows are closed to organization keys, and
14
+ no capability on an organization key opens them. A call made with one fails
15
+ with a `FronteraError` whose `code` is `FORBIDDEN` and whose message says so.
16
+
17
+ ## Run a workflow
18
+
19
+ ```ts
20
+ import { FronteraClient } from '@frontera-sdk/core/client'
21
+ import { FronteraError } from '@frontera-sdk/core/errors'
22
+ import { WorkflowClient } from '@frontera-sdk/workflow/workflow-client'
23
+
24
+ const client = new FronteraClient({
25
+ apiBaseUrl: 'https://api.acme.example',
26
+ credential: { kind: 'apiKey', key: process.env.FRONTERA_WORKSPACE_KEY! },
27
+ })
28
+ const workflows = new WorkflowClient(client)
29
+
30
+ const { runId } = await workflows.run('supplier-onboarding', {
31
+ input: { supplierId: 'S-1042' },
32
+ })
33
+
34
+ const run = await workflows.waitForRun(runId, { timeoutMs: 5 * 60_000 })
35
+ console.log(run.status, run.output)
36
+ ```
37
+
38
+ `waitForRun` polls every 1.5 seconds by default and resolves once the run is
39
+ `succeeded`, `failed` or `canceled`. On timeout it throws a `FronteraError` with
40
+ code `RUN_WAIT_TIMEOUT` and leaves the run alone.
41
+
42
+ ### Cancel
43
+
44
+ ```ts
45
+ const controller = new AbortController()
46
+ setTimeout(() => controller.abort(), 30_000)
47
+
48
+ try {
49
+ await workflows.waitForRun(runId, { signal: controller.signal })
50
+ } catch (err) {
51
+ if (err instanceof FronteraError && err.code === 'ABORTED') {
52
+ const { status } = await workflows.cancel(runId)
53
+ console.log('cancelled, run is now', status)
54
+ } else {
55
+ throw err
56
+ }
57
+ }
58
+ ```
59
+
60
+ A run that had already finished comes back from `cancel` with the status it
61
+ reached, not `canceled`.
62
+
63
+ ### File inputs
64
+
65
+ Put a `File` in `input` and the request goes as multipart, with each file as its
66
+ own part. Nothing else changes.
67
+
68
+ ```ts
69
+ await workflows.run('supplier-onboarding', {
70
+ input: { supplierId: 'S-1042', contract: new File([bytes], 'contract.pdf') },
71
+ })
72
+ ```
73
+
74
+ ## Author a workflow
75
+
76
+ A definition is a plain object typed as `WorkflowDefinition`, so the step kinds,
77
+ their parameters and the trigger forms are checked as you write them.
78
+
79
+ ```ts
80
+ import type { WorkflowDefinition } from '@frontera-sdk/workflow/definition'
81
+
82
+ const definition: WorkflowDefinition = {
83
+ apiVersion: 'workflow/v1',
84
+ name: 'supplier-onboarding',
85
+ trigger: [{ kind: 'manual' }],
86
+ nodes: [
87
+ { id: 'score', kind: 'function', params: { slug: 'score-supplier' } },
88
+ ],
89
+ }
90
+
91
+ const check = await workflows.push('supplier-onboarding', definition, { dryRun: true })
92
+ if (!check.ok) throw new Error(check.errors?.join('\n'))
93
+
94
+ const published = await workflows.push('supplier-onboarding', definition)
95
+ await workflows.promote('supplier-onboarding', published.version!.number)
96
+ ```
97
+
98
+ A dry run validates and writes nothing, reporting every problem at once as
99
+ `ok: false` with `errors`. It also returns `grants`, the set of resources the
100
+ server derived from the definition. A slug that does not exist is created by the
101
+ first push.
102
+
103
+ The type describes the document after the server applies its defaults, so a
104
+ field with a default reads as required.
105
+
106
+ ### Iterate on a draft
107
+
108
+ ```ts
109
+ await workflows.overwriteDraft('supplier-onboarding', number, definition)
110
+ const result = await workflows.testNode('supplier-onboarding', number, 'score')
111
+ ```
112
+
113
+ `overwriteDraft` rewrites a draft in place instead of stacking a version per
114
+ edit. `testNode` runs one step. `copyVersion` opens a published version as a new
115
+ draft, `deleteVersion` discards one.
116
+
117
+ ## Read the run tree
118
+
119
+ `runById(runId)` and `waitForRun` return a `RunTree`. `RunTree.nodes[]` has one
120
+ entry per executed step with its `status`, `input`, `output`, `error` and the
121
+ ids of any Function run, Action request, conversation or child run it produced.
122
+ Pass `depth: 'all'` to have those expanded inline, child runs included, so a
123
+ renderer needs no further request.
124
+
125
+ ```ts
126
+ const run = await workflows.runById(runId, 'all')
127
+ for (const node of run.nodes) console.log(node.nodeId, node.status)
128
+ ```
129
+
130
+ ## Page through run history
131
+
132
+ `runs(slug, filters)` returns the newest rows first. Pass
133
+ `before: runCursor(lastRow)` to fetch the page after the one you have.
134
+ `workspaceRuns(filters)` does the same across every workflow in the workspace.
135
+
136
+ ## Entry points
137
+
138
+ | Import | What it is |
139
+ |---|---|
140
+ | `@frontera-sdk/workflow/workflow-client` | `WorkflowClient` |
141
+ | `@frontera-sdk/workflow/definition` | `WorkflowDefinition` and the step and trigger types |
142
+ | `@frontera-sdk/workflow/types` | request and response types, `runCursor`, `isTerminalRunStatus` |
143
+
144
+ `@frontera-sdk/workflow/definition` is the same model the engine validates
145
+ against; the service reads these types back from this package, and a drift
146
+ between them fails its typecheck.
147
+
148
+ ## License
149
+
150
+ Apache-2.0. See [LICENSE](./LICENSE).
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@frontera-sdk/workflow",
3
+ "version": "1.50.62-next.0",
4
+ "description": "Typed headless client for starting, inspecting, waiting on and cancelling Frontera workflow runs from a script or backend.",
5
+ "keywords": [
6
+ "frontera",
7
+ "workflow",
8
+ "sdk"
9
+ ],
10
+ "license": "Apache-2.0",
11
+ "type": "module",
12
+ "files": [
13
+ "src",
14
+ "!src/__tests__",
15
+ "!src/**/*.test.ts",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "exports": {
23
+ "./definition": {
24
+ "types": "./src/definition.ts",
25
+ "import": "./src/definition.ts"
26
+ },
27
+ "./types": {
28
+ "types": "./src/types.ts",
29
+ "import": "./src/types.ts"
30
+ },
31
+ "./workflow-client": {
32
+ "types": "./src/workflow-client.ts",
33
+ "import": "./src/workflow-client.ts"
34
+ }
35
+ },
36
+ "scripts": {
37
+ "test": "bun test",
38
+ "typecheck": "bunx tsc --noEmit"
39
+ },
40
+ "dependencies": {
41
+ "@frontera-sdk/core": "1.50.62",
42
+ "@frontera-sdk/functions": "1.50.62"
43
+ },
44
+ "devDependencies": {
45
+ "@types/bun": "^1.3.14",
46
+ "typescript": "^5.9.3"
47
+ }
48
+ }
@@ -0,0 +1,297 @@
1
+ /**
2
+ * The workflow definition: the authored artifact, as types.
3
+ *
4
+ * This is the shape a script author writes and pushes. It is types only — the
5
+ * platform still validates a pushed definition (shape, then lookups: does this
6
+ * `resourceId` exist, is this model enabled, does `$steps.risk` name an earlier
7
+ * node), and this file deliberately carries none of that. What it buys is the
8
+ * compile check and the autocomplete, so a mistake shows up in the editor
9
+ * instead of in a `dryRun` round trip.
10
+ *
11
+ * Every node is three layers: identity (`id`, `kind`, `resourceId?`, `label?`),
12
+ * `params` discriminated by `kind` (and, inside `blueprint`, by `mode`), and
13
+ * the shared settings every kind accepts.
14
+ *
15
+ * The node set is closed. All fourteen kinds are describable here, so a
16
+ * definition written for a later phase is refused by the engine as "not yet
17
+ * runnable", never as "unknown kind".
18
+ *
19
+ * These types describe the definition as the engine reads it, after the
20
+ * platform has applied documented defaults (`trigger.path`, `respond.status`,
21
+ * `stop.status` and friends). A field that has a default is written required
22
+ * here; the server fills it if the pushed document omits it.
23
+ */
24
+
25
+ export const WORKFLOW_API_VERSION = 'workflow/v1'
26
+
27
+ export const NODE_KINDS = [
28
+ 'blueprint',
29
+ 'function',
30
+ 'llm',
31
+ 'action',
32
+ 'agent',
33
+ 'plugin',
34
+ 'http',
35
+ 'transform',
36
+ 'branch',
37
+ 'forEach',
38
+ 'parallel',
39
+ 'wait',
40
+ 'stop',
41
+ 'respond',
42
+ ] as const
43
+ export type NodeKind = (typeof NODE_KINDS)[number]
44
+
45
+ /** A data input inside `params`: a literal, or a JSONata expression evaluated per run. */
46
+ export type DataInput = { type: 'static'; value: unknown } | { type: 'expr'; expr: string }
47
+
48
+ // ─── Triggers ────────────────────────────────────────────────────────────────
49
+
50
+ export const WEBHOOK_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'] as const
51
+ export type WebhookMethod = (typeof WEBHOOK_METHODS)[number]
52
+
53
+ /** How the webhook caller is authenticated. An open door is `{ type: 'none' }`, never implied. */
54
+ export type WebhookAuth =
55
+ | { type: 'none' }
56
+ | { type: 'header'; name: string; secret: string }
57
+ | { type: 'basic'; username: string; secret: string }
58
+ | {
59
+ type: 'hmac'
60
+ header: string
61
+ secret: string
62
+ algorithm: 'sha256' | 'sha512' | 'sha1'
63
+ encoding: 'hex' | 'base64'
64
+ /** Stripped before compare, e.g. `sha256=`. */
65
+ prefix?: string
66
+ }
67
+
68
+ /** When and with what the webhook answers its caller. */
69
+ export type WebhookRespond =
70
+ | {
71
+ mode: 'immediately'
72
+ status: number
73
+ headers?: Record<string, string>
74
+ body: 'runId' | 'none'
75
+ }
76
+ | {
77
+ mode: 'onFinish'
78
+ /** Bounded 1s..250s. */
79
+ timeout: string
80
+ status: number
81
+ headers?: Record<string, string>
82
+ body: 'output' | 'none'
83
+ }
84
+ /** A `respond` node answers mid-run. */
85
+ | { mode: 'node'; timeout: string }
86
+
87
+ /**
88
+ * The trigger types are type aliases rather than interfaces on purpose: an
89
+ * alias gets an implicit index signature, so a stored `Record<string, unknown>`
90
+ * row can be narrowed to a trigger without going through `unknown` first. An
91
+ * interface would make that a compile error at every read site.
92
+ */
93
+ export type WebhookTrigger = {
94
+ kind: 'webhook'
95
+ description?: string
96
+ methods: WebhookMethod[]
97
+ /** `shipments/:shipmentId`: literal segments and `:name` captures. `''` is the bare workflow URL. */
98
+ path: string
99
+ auth: WebhookAuth
100
+ respond: WebhookRespond
101
+ /** JSONata over `$request`, giving the run input object. Absent: the body's declared keys. */
102
+ input?: string
103
+ /** JSONata over `$request`, giving the subject pk. Required iff the definition has a subject. */
104
+ subject?: string
105
+ /** JSONata over `$request`, giving the dedupe key. Absent: no dedupe. */
106
+ idempotencyKey?: string
107
+ /** The whole non-multipart body becomes this `file` input. */
108
+ binaryInput?: string
109
+ /** `*`, or origins as absolute URLs. */
110
+ allowedOrigins?: string[]
111
+ /** IPv4/IPv6 addresses or CIDRs. */
112
+ ipAllowlist?: string[]
113
+ ignoreBots?: boolean
114
+ }
115
+
116
+ export type ManualTrigger = {
117
+ kind: 'manual'
118
+ description?: string
119
+ }
120
+
121
+ export type CronTrigger = {
122
+ kind: 'cron'
123
+ description?: string
124
+ schedule: string
125
+ input?: Record<string, unknown>
126
+ /** Run once per object the predicate selects. */
127
+ subjects?: { where: string; limit?: number }
128
+ }
129
+
130
+ /** Started by another workflow. */
131
+ export type WorkflowCallTrigger = {
132
+ kind: 'workflow'
133
+ description?: string
134
+ }
135
+
136
+ /** Started by an agent. */
137
+ export type AgentTrigger = {
138
+ kind: 'agent'
139
+ description?: string
140
+ }
141
+
142
+ export type WorkflowTrigger =
143
+ | ManualTrigger
144
+ | CronTrigger
145
+ | WorkflowCallTrigger
146
+ | AgentTrigger
147
+ | WebhookTrigger
148
+
149
+ // ─── Shared node settings ────────────────────────────────────────────────────
150
+
151
+ export interface RetryPolicy {
152
+ attempts: number
153
+ backoff?: 'constant' | 'exponential'
154
+ /** JSONata predicate: retry only when it holds. */
155
+ retryIf?: string
156
+ }
157
+
158
+ export interface WorkflowNodeBase {
159
+ id: string
160
+ kind: NodeKind
161
+ label?: string
162
+ description?: string
163
+ resourceId?: string
164
+ params: Record<string, unknown>
165
+ retry?: RetryPolicy
166
+ /** A duration like `30s`, `3m`, `2h`, `1d`. */
167
+ timeout?: string
168
+ continueOnError?: boolean
169
+ cacheTtl?: number
170
+ mock?: unknown
171
+ skipIf?: string
172
+ /**
173
+ * Authoring state, not a run decision: `enabled: false` parks the step in
174
+ * the editor. Absent means enabled. A parked step is evaluated by nothing and
175
+ * leaves no trace at all, unlike `skipIf`, which is evaluated per run and
176
+ * recorded as a `skipped` node.
177
+ */
178
+ enabled?: boolean
179
+ /**
180
+ * The step's own predecessors, by node id: it runs once every step it names
181
+ * has finished. Absent means "after the previous element of my list"; `[]`
182
+ * means "after nothing", so the step starts with the list. An entry names a
183
+ * sibling — a step in the same container arm, or the same root list.
184
+ */
185
+ after?: string[]
186
+ }
187
+
188
+ // ─── Node params by kind ─────────────────────────────────────────────────────
189
+
190
+ export interface BlueprintQueryParams {
191
+ mode: 'query'
192
+ /** Read from this saved object set rather than every object of the type. */
193
+ objectSetId?: string
194
+ where?: string
195
+ select?: string[]
196
+ limit?: number
197
+ }
198
+ export interface BlueprintAggregateParams {
199
+ mode: 'aggregate'
200
+ /** Read from this saved object set rather than every object of the type. */
201
+ objectSetId?: string
202
+ where?: string
203
+ groupBy: string[]
204
+ metrics: Array<{ as: string; fn: 'count' | 'sum' | 'avg' | 'min' | 'max'; property?: string }>
205
+ }
206
+ export interface FunctionParams {
207
+ version?: number
208
+ input: DataInput
209
+ }
210
+ export interface LlmParams {
211
+ prompt: DataInput
212
+ system?: DataInput
213
+ files?: DataInput
214
+ structured?: Record<string, unknown>
215
+ temperature?: number
216
+ maxTokens?: number
217
+ }
218
+ export interface ActionParams {
219
+ input: DataInput
220
+ }
221
+ export interface AgentParams {
222
+ message: DataInput
223
+ files?: DataInput
224
+ }
225
+ export interface PluginParams {
226
+ capability: string
227
+ input: DataInput
228
+ }
229
+ export interface HttpParams {
230
+ url: string
231
+ method: string
232
+ headers?: Record<string, DataInput>
233
+ body?: DataInput
234
+ auth?: { secret: string; header?: string; prefix?: string }
235
+ }
236
+ export interface TransformParams {
237
+ value: DataInput
238
+ }
239
+ export interface StopParams {
240
+ result?: DataInput
241
+ status: 'succeeded' | 'failed'
242
+ }
243
+ export interface BranchParams {
244
+ cases: Array<{ when: string; nodes: WorkflowNode[] }>
245
+ else?: WorkflowNode[]
246
+ }
247
+ export interface ForEachParams {
248
+ over: string
249
+ parallelism?: number
250
+ skipFailure?: boolean
251
+ mode?: 'auto' | 'inline' | 'child'
252
+ nodes: WorkflowNode[]
253
+ }
254
+ export interface ParallelParams {
255
+ branches: Array<{ id: string; nodes: WorkflowNode[] }>
256
+ }
257
+ export interface WaitParams {
258
+ /** Exactly one of `for` or `until`. */
259
+ for?: string
260
+ until?: string
261
+ }
262
+ export interface RespondParams {
263
+ status: number
264
+ headers?: Record<string, DataInput>
265
+ body?: DataInput
266
+ }
267
+
268
+ type NodeOf<K extends NodeKind, P> = Omit<WorkflowNodeBase, 'kind' | 'params'> & { kind: K; params: P }
269
+
270
+ export type WorkflowNode =
271
+ | NodeOf<'blueprint', BlueprintQueryParams | BlueprintAggregateParams>
272
+ | NodeOf<'function', FunctionParams>
273
+ | NodeOf<'llm', LlmParams>
274
+ | NodeOf<'action', ActionParams>
275
+ | NodeOf<'agent', AgentParams>
276
+ | NodeOf<'plugin', PluginParams>
277
+ | NodeOf<'http', HttpParams>
278
+ | NodeOf<'transform', TransformParams>
279
+ | NodeOf<'stop', StopParams>
280
+ | NodeOf<'branch', BranchParams>
281
+ | NodeOf<'forEach', ForEachParams>
282
+ | NodeOf<'parallel', ParallelParams>
283
+ | NodeOf<'wait', WaitParams>
284
+ | NodeOf<'respond', RespondParams>
285
+
286
+ export interface WorkflowDefinition {
287
+ apiVersion: typeof WORKFLOW_API_VERSION
288
+ /** A slug: lowercase letters, digits, dashes. */
289
+ name: string
290
+ description?: string
291
+ subject?: { objectTypeId: string; label?: string }
292
+ /** The same flat field map Functions declare. */
293
+ input?: Record<string, Record<string, unknown>>
294
+ trigger: WorkflowTrigger[]
295
+ nodes: WorkflowNode[]
296
+ output?: DataInput
297
+ }