@oomol-lab/open-flow 0.1.0-beta.3 → 0.1.0-beta.30

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.
Files changed (123) hide show
  1. package/dist/browser/{_virtual_open-flow-twemoji-DJwKsM_w.js → _virtual_open-flow-twemoji-CpHJOEsk.js} +4028 -2
  2. package/dist/browser/carbon-Cn-DTyjG.js +54 -0
  3. package/dist/browser/createResourceDialog-_y2xHaUA.js +110 -0
  4. package/dist/browser/{dist-DWADUsVB.js → dist-By46o5UV.js} +47 -47
  5. package/dist/browser/dist-CoszrK7m.js +4 -0
  6. package/dist/browser/{dist-CPuF50D9.js → dist-D1VYgicl.js} +426 -305
  7. package/dist/browser/dist-DSe6KRsr.js +1224 -0
  8. package/dist/browser/dist-DYjIVIZC.js +795 -0
  9. package/dist/browser/{dist-3Mj8q8Pr.js → dist-DmuE3M0R.js} +53 -54
  10. package/dist/browser/{dist-BN4ZCyOB.js → dist-DpDLsYtO.js} +14 -15
  11. package/dist/browser/{dist-CJpzJrLM.js → dist-DwvhuMxw.js} +894 -895
  12. package/dist/browser/dist-DxahK_I8.js +2688 -0
  13. package/dist/browser/{dist-C46JByB-.js → dist-Dz6Nglsd.js} +61 -61
  14. package/dist/browser/{dist-DUzA0Ukh.js → dist-TJfrvoIQ.js} +141 -142
  15. package/dist/browser/editorComponent-Dq4IKp5R.js +14790 -0
  16. package/dist/browser/{esm-C2UUqIUP.js → esm-B7A42FzW.js} +68 -59
  17. package/dist/browser/event-sources.d.ts +30 -0
  18. package/dist/browser/flow-authoring-module.d.ts +2 -2
  19. package/dist/browser/flow-authoring-node.d.ts +26 -8
  20. package/dist/browser/flow-authoring.d.ts +1 -1
  21. package/dist/browser/flow-authoring.js +5282 -313
  22. package/dist/browser/flow-change-schema.d.ts +11 -0
  23. package/dist/browser/flow-change.d.ts +193 -18
  24. package/dist/browser/flow-change.js +5192 -137
  25. package/dist/browser/flow-notifications.d.ts +11 -2
  26. package/dist/browser/flowChanges-AdN0Iqma.js +12304 -0
  27. package/dist/browser/{flowRunInputEditorStore-CwvOiIiU.js → flowRunInputEditorStore-CTORQcA2.js} +864 -4000
  28. package/dist/browser/flowWorkspace-BrtzLKWB.js +153066 -0
  29. package/dist/browser/host-conformance.d.ts +7 -0
  30. package/dist/browser/host-conformance.js +39 -0
  31. package/dist/browser/inputValues-DJfFraxG.js +43 -0
  32. package/dist/browser/licenses.md +195 -662
  33. package/dist/browser/lite-BuKZ8joP.js +8545 -0
  34. package/dist/browser/main-BDnNHhkU.js +50 -0
  35. package/dist/browser/{markdownContent-DUfLdnUt.js → markdownContent-D2oHGWc6.js} +53 -53
  36. package/dist/browser/theme.css +527 -34
  37. package/dist/browser/{typeScriptSession-mPCiA9sV.js → typeScriptSession-DnAmJCzu.js} +70 -71
  38. package/dist/browser/ui-input.d.ts +5 -0
  39. package/dist/browser/ui-label.d.ts +3 -0
  40. package/dist/browser/ui-textarea.d.ts +3 -0
  41. package/dist/browser/ui.css +2 -0
  42. package/dist/browser/ui.css.d.ts +1 -0
  43. package/dist/browser/ui.d.ts +34 -0
  44. package/dist/browser/ui.js +2632 -0
  45. package/dist/browser/value-DPg_9yXB.js +93 -0
  46. package/dist/browser/warmCodeTheme-DVv4-rDO.js +35 -0
  47. package/dist/browser/workbench-contract.d.ts +27 -2
  48. package/dist/browser/workbench.css +1 -1
  49. package/dist/browser/workbench.d.ts +2 -0
  50. package/dist/browser/workbench.js +2767 -1406
  51. package/dist/browser/workbenchSelect-BDPIQxYK.js +5967 -0
  52. package/dist/common/authoringExamples.d.ts +28 -0
  53. package/dist/common/control-api-conformance.d.ts +7 -0
  54. package/dist/common/control-api-conformance.js +5568 -171
  55. package/dist/common/control-api-errors.d.ts +37 -0
  56. package/dist/common/control-api.d.ts +394 -47
  57. package/dist/common/control-api.js +6066 -569
  58. package/dist/common/control-requests.d.ts +98 -0
  59. package/dist/common/control-requests.js +5412 -0
  60. package/dist/common/cron-trigger.d.ts +2 -1
  61. package/dist/common/cron-trigger.js +27 -24
  62. package/dist/common/draftOperations.d.ts +14 -0
  63. package/dist/common/engine-contract.d.ts +3 -1
  64. package/dist/common/event-sources.d.ts +50 -0
  65. package/dist/common/feishu-events.d.ts +20 -0
  66. package/dist/common/feishu-subscriptions.d.ts +10 -0
  67. package/dist/common/flow-agent.d.ts +10 -0
  68. package/dist/common/flow-encoding.d.ts +16 -2
  69. package/dist/common/flow-encoding.js +5092 -68
  70. package/dist/common/flow-graph.d.ts +52 -0
  71. package/dist/common/flow-json.d.ts +2 -0
  72. package/dist/common/flow-modules.d.ts +20 -0
  73. package/dist/common/flow-notifications.d.ts +11 -2
  74. package/dist/common/flow-schema.d.ts +17 -0
  75. package/dist/common/flow-semantics.d.ts +12 -6
  76. package/dist/common/flow-semantics.js +15870 -9668
  77. package/dist/common/flowInspection.d.ts +16 -0
  78. package/dist/common/fr-iv1541dF.js +93 -0
  79. package/dist/common/integration-trigger.d.ts +29 -2
  80. package/dist/common/integration-trigger.js +192 -56
  81. package/dist/common/ja-Bq-ZDOD4.js +93 -0
  82. package/dist/common/ko-Z-k9R2c6.js +93 -0
  83. package/dist/common/localization.d.ts +2 -0
  84. package/dist/common/localization.js +37 -1
  85. package/dist/common/mcp-conformance.d.ts +2 -0
  86. package/dist/common/mcp.d.ts +767 -0
  87. package/dist/common/mcp.js +6733 -0
  88. package/dist/common/poll-trigger.d.ts +5 -0
  89. package/dist/common/poll-trigger.js +26 -22
  90. package/dist/common/provider-triggers.d.ts +4 -0
  91. package/dist/common/provider-triggers.js +7310 -1736
  92. package/dist/common/ru-B4gFecYZ.js +93 -0
  93. package/dist/common/run-events.d.ts +2 -2
  94. package/dist/common/run-events.js +13 -17
  95. package/dist/common/run-lifecycle.d.ts +21 -2
  96. package/dist/common/run-lifecycle.js +83 -2
  97. package/dist/common/run-results.d.ts +57 -0
  98. package/dist/common/runtime-contract.d.ts +38 -3
  99. package/dist/common/runtime-contract.js +291 -19
  100. package/dist/common/scheduler.d.ts +97 -19
  101. package/dist/common/scheduler.js +8234 -261
  102. package/dist/common/trigger-catalog.d.ts +17 -0
  103. package/dist/common/trigger-config-options.d.ts +13 -0
  104. package/dist/common/trigger-contract.d.ts +5 -0
  105. package/dist/common/trigger-localization.d.ts +7 -0
  106. package/dist/common/webhook-trigger.d.ts +3 -3
  107. package/dist/common/webhook-trigger.js +64 -18
  108. package/dist/common/zh-CN-ByQ6nYam.js +93 -0
  109. package/dist/common/zh-TW-QjIarvX9.js +93 -0
  110. package/dist/index.d.ts +6 -5
  111. package/package.json +21 -1
  112. package/dist/browser/carbon-DMCVsjHo.js +0 -53
  113. package/dist/browser/createResourceDialog-BkZns-oZ.js +0 -504
  114. package/dist/browser/diagnostics-SDCyFuxm.js +0 -11634
  115. package/dist/browser/dist-BMqL-qR5.js +0 -1894
  116. package/dist/browser/dist-BpopSHwP.js +0 -1543
  117. package/dist/browser/dist-CP0883sY.js +0 -4
  118. package/dist/browser/dist-CUSrALSX.js +0 -1620
  119. package/dist/browser/flowWorkspace-BZ_eiQNR.js +0 -45393
  120. package/dist/browser/getPseudoElementBounds-ESJExRFX.js +0 -7642
  121. package/dist/browser/languages-DgJehE1g.js +0 -62
  122. package/dist/browser/main-DmjVyuWr.js +0 -76
  123. package/dist/browser/workbenchSelect-B2s1HV-Y.js +0 -1374
@@ -19,19 +19,101 @@ function t(n, r) {
19
19
  }
20
20
  //#endregion
21
21
  //#region src/execution/common/engineContract.ts
22
- var n = "open-flow-engine/v1", r = {
22
+ var n = "open-flow-engine/v5", r = "open-flow-engine/v5/nodejs-compat-v1", i = {
23
23
  platformExports: /* @__PURE__ */ new Set(["engineContract", "identity"]),
24
24
  platformModule: "open-flow:platform",
25
25
  platformSource: `export const engineContract = ${JSON.stringify(n)}
26
26
  export function identity(value) { return value }
27
27
  `
28
+ }, a = {
29
+ ...i,
30
+ builtinModules: new Set([
31
+ "assert",
32
+ "assert/strict",
33
+ "buffer",
34
+ "console",
35
+ "constants",
36
+ "crypto",
37
+ "events",
38
+ "fs",
39
+ "fs/promises",
40
+ "os",
41
+ "path",
42
+ "path/posix",
43
+ "process",
44
+ "punycode",
45
+ "querystring",
46
+ "stream",
47
+ "stream/promises",
48
+ "stream/web",
49
+ "string_decoder",
50
+ "timers",
51
+ "timers/promises",
52
+ "url",
53
+ "util",
54
+ "zlib"
55
+ ].flatMap((e) => [e, `node:${e}`])),
56
+ platformSource: `export const engineContract = ${JSON.stringify(r)}
57
+ export function identity(value) { return value }
58
+ `
28
59
  };
29
- function i(e) {
30
- return e == "open-flow-engine/v1" ? r : void 0;
60
+ function o(e) {
61
+ if (e == "open-flow-engine/v5") return i;
62
+ if (e == "open-flow-engine/v5/nodejs-compat-v1") return a;
31
63
  }
32
64
  //#endregion
33
65
  //#region src/execution/common/runtime.ts
34
- function a(e, t, r = {}) {
66
+ function s(e) {
67
+ let t = /* @__PURE__ */ new Set(), n = (e, r) => {
68
+ if (r > 64) throw Error("Task result exceeds the maximum JSON depth.");
69
+ if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
70
+ if (typeof e != "object" || t.has(e) || !Array.isArray(e) && Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null || Object.getOwnPropertySymbols(e).length > 0) throw Error("Task result must contain only JSON values.");
71
+ t.add(e);
72
+ let i = Array.isArray(e) ? Array.from(e, (e) => n(e, r + 1)) : Object.fromEntries(Object.entries(e).filter(([, e]) => r != 0 || e !== void 0).map(([e, t]) => [e, n(t, r + 1)]));
73
+ return t.delete(e), i;
74
+ };
75
+ return e === void 0 ? void 0 : n(e, 0);
76
+ }
77
+ var c = [{
78
+ name: "supports Node builtin imports and asynchronous virtual file operations",
79
+ async verify(e) {
80
+ u(await e.invoke({
81
+ capability: async () => ({
82
+ body: null,
83
+ status: 403
84
+ }),
85
+ input: null,
86
+ invocationId: "nodejs-files",
87
+ program: {
88
+ ...l(e, "import assert from 'node:assert/strict';\nimport { Buffer } from 'node:buffer'; import path from 'node:path'; import fs from 'node:fs/promises';\nexport default async () => {\n const file = path.join('/tmp', 'conformance.txt');\n await fs.writeFile(file, Buffer.from('你好'));\n const text = await fs.readFile(file, 'utf8');\n assert.equal(text, '你好');\n await fs.unlink(file);\n return { text, bytes: Buffer.byteLength(text) };\n}"),
89
+ engineContract: r
90
+ }
91
+ }), {
92
+ text: "你好",
93
+ bytes: 6
94
+ }, "Node virtual files");
95
+ }
96
+ }, {
97
+ name: "preserves abort reasons and cancels Promise timers",
98
+ async verify(e) {
99
+ u(await e.invoke({
100
+ capability: async () => ({
101
+ body: null,
102
+ status: 403
103
+ }),
104
+ input: null,
105
+ invocationId: "nodejs-abort",
106
+ program: {
107
+ ...l(e, "import { setTimeout } from 'node:timers/promises';\nexport default async () => {\n const controller = new AbortController(); const reason = { message: 'stop' };\n const combined = AbortSignal.any([controller.signal]);\n const pending = setTimeout(60000, 'late', { signal: combined });\n controller.abort(reason); controller.abort('ignored');\n let thrown; try { combined.throwIfAborted(); } catch (error) { thrown = error; }\n try { await pending; return false; } catch (error) {\n return { sameReason: combined.reason === reason && thrown === reason, name: error.name };\n }\n}"),
108
+ engineContract: r
109
+ }
110
+ }), {
111
+ sameReason: !0,
112
+ name: "AbortError"
113
+ }, "Node cancellation");
114
+ }
115
+ }];
116
+ function l(e, t, r = {}) {
35
117
  return {
36
118
  engineContract: n,
37
119
  engineDigest: e.engineDigest,
@@ -45,10 +127,10 @@ function a(e, t, r = {}) {
45
127
  }
46
128
  };
47
129
  }
48
- function o(e, n, r) {
130
+ function u(e, n, r) {
49
131
  if (!t(e, n)) throw Error(`${r}: expected ${JSON.stringify(n)}, received ${JSON.stringify(e)}.`);
50
132
  }
51
- async function s(e, t, n) {
133
+ async function d(e, t, n) {
52
134
  try {
53
135
  await e;
54
136
  } catch (e) {
@@ -57,17 +139,135 @@ async function s(e, t, n) {
57
139
  }
58
140
  throw Error(`${n}: operation unexpectedly succeeded.`);
59
141
  }
60
- var c = [
142
+ var f = [
143
+ {
144
+ name: "rejects Task results that JSON transport would discard or coerce",
145
+ async verify(e) {
146
+ for (let t of [
147
+ "{ value: () => 42 }",
148
+ "{ value: Symbol(\"value\") }",
149
+ "{ value: NaN }",
150
+ "{ value: Infinity }",
151
+ "{ value: 1n }",
152
+ "{ value: { nested: undefined } }",
153
+ "{ value: [undefined] }",
154
+ "{ value: Array(1) }",
155
+ "{ value: new Date() }",
156
+ "{ value: { toJSON() { return \"hidden\" } } }",
157
+ "{ [Symbol(\"key\")]: 1 }",
158
+ "(() => { const value = {}; value.self = value; return { value } })()"
159
+ ]) await d(e.invoke({
160
+ capability: async () => ({
161
+ body: null,
162
+ status: 200
163
+ }),
164
+ input: null,
165
+ invocationId: "invalid-task-result",
166
+ program: l(e, `export default () => (${t})`)
167
+ }), /Task result must contain only JSON values/, `Invalid Task result: ${t}`);
168
+ }
169
+ },
170
+ {
171
+ name: "snapshots JSON results while preserving missing ports and shared values",
172
+ async verify(e) {
173
+ let t = await e.invoke({
174
+ capability: async () => ({
175
+ body: null,
176
+ status: 200
177
+ }),
178
+ input: null,
179
+ invocationId: "json-task-result",
180
+ program: l(e, "export default () => {\n const shared = { text: 'hello', values: [1, true, null] };\n return { missing: undefined, nullable: null, first: shared, second: shared };\n }")
181
+ }), n = {
182
+ text: "hello",
183
+ values: [
184
+ 1,
185
+ !0,
186
+ null
187
+ ]
188
+ };
189
+ u(t, {
190
+ nullable: null,
191
+ first: n,
192
+ second: n
193
+ }, "JSON Task result");
194
+ }
195
+ },
196
+ {
197
+ name: "preserves Action error codes and fixed per-call Connection selection",
198
+ async verify(e) {
199
+ let t = [{
200
+ kind: "connector",
201
+ action: "example.echo",
202
+ connections: [{
203
+ connectionId: "work",
204
+ alias: "office"
205
+ }, { connectionId: "home" }]
206
+ }];
207
+ u(await e.invoke({
208
+ capabilities: t,
209
+ capability: async ({ payload: e }) => {
210
+ let n = m(t, e);
211
+ if (n.input.fail) throw Object.assign(/* @__PURE__ */ Error("Provider unavailable."), { code: "connector.unavailable" });
212
+ return {
213
+ body: n.connectionId ?? null,
214
+ status: 200
215
+ };
216
+ },
217
+ input: null,
218
+ invocationId: "action-accounts",
219
+ program: l(e, "export default async (_, context) => {\n const values = await Promise.all([\n context.actions.example.echo({}, { connectionAlias: 'office' }),\n context.actions['example.echo']({}, { connectionId: 'home' }),\n ])\n try { await context.actions.example.echo({ fail: true }, { connectionId: 'work' }) }\n catch (error) { values.push(error.code) }\n return values\n }")
220
+ }), [
221
+ "work",
222
+ "home",
223
+ "connector.unavailable"
224
+ ], "Action selection and recovery");
225
+ }
226
+ },
227
+ {
228
+ name: "shares Action entries and assigns independent concurrent call identities",
229
+ async verify(e) {
230
+ let t = [];
231
+ u(await e.invoke({
232
+ capabilities: [{
233
+ kind: "connector",
234
+ action: "example.echo",
235
+ connections: []
236
+ }],
237
+ capability: async (e) => (t.push(e), {
238
+ body: e.payload,
239
+ status: 200
240
+ }),
241
+ input: null,
242
+ invocationId: "action-calls",
243
+ program: l(e, "export default async (_input, context) => {\n const call = context.actions.example.echo\n return { same: call === context.actions['example.echo'], values: await Promise.all([call({ value: 1 }), call({ value: 2 }), call({ value: 3 })]) }\n }")
244
+ }), {
245
+ same: !0,
246
+ values: [
247
+ 1,
248
+ 2,
249
+ 3
250
+ ].map((e) => ({
251
+ action: "example.echo",
252
+ input: { value: e }
253
+ }))
254
+ }, "Action results"), u(new Set(t.map((e) => e.callId)).size, 3, "Independent Action identities"), u(t.map((e) => e.invocationId), [
255
+ "action-calls",
256
+ "action-calls",
257
+ "action-calls"
258
+ ], "Task identity");
259
+ }
260
+ },
61
261
  {
62
262
  name: "loads the fixed ESM closure and platform module",
63
263
  async verify(e) {
64
- o(await e.invoke({
264
+ u(await e.invoke({
65
265
  capability: async () => {
66
266
  throw Error("Capability must not be called.");
67
267
  },
68
268
  input: { value: 6 },
69
269
  invocationId: "module-closure",
70
- program: a(e, "import { double } from './helper.mjs'\nimport { engineContract, identity } from 'open-flow:platform'\nexport default (input) => ({ engineContract, value: identity(double(input.value)) })", { helper: {
270
+ program: l(e, "import { double } from './helper.mjs'\nimport { engineContract, identity } from 'open-flow:platform'\nexport default (input) => ({ engineContract, value: identity(double(input.value)) })", { helper: {
71
271
  imports: [],
72
272
  source: "export const double = (value) => value * 2"
73
273
  } })
@@ -80,14 +280,14 @@ var c = [
80
280
  {
81
281
  name: "rejects modules outside the fixed closure",
82
282
  async verify(e) {
83
- await s(e.invoke({
283
+ await d(e.invoke({
84
284
  capability: async () => ({
85
285
  body: null,
86
286
  status: 200
87
287
  }),
88
288
  input: null,
89
289
  invocationId: "closed-linker",
90
- program: a(e, "import fs from 'node:fs'\nexport default () => fs.readFileSync('/etc/passwd', 'utf8')")
290
+ program: l(e, "import fs from 'node:fs'\nexport default () => fs.readFileSync('/etc/passwd', 'utf8')")
91
291
  }), /invalid|unsupported|cannot import|not part of/i, "Closed linker");
92
292
  }
93
293
  },
@@ -95,7 +295,7 @@ var c = [
95
295
  name: "copies asynchronous Capability requests and responses",
96
296
  async verify(e) {
97
297
  let t = [];
98
- o(await e.invoke({
298
+ u(await e.invoke({
99
299
  capability: async (e) => (t.push(e), {
100
300
  body: {
101
301
  accepted: !0,
@@ -105,7 +305,7 @@ var c = [
105
305
  }),
106
306
  input: { issue: 42 },
107
307
  invocationId: "async-capability",
108
- program: a(e, "export default async (input, capability) => capability.connector({ action: 'read', input })")
308
+ program: l(e, "export default async (input, capability) => capability.artifact.put({ action: 'read', input })")
109
309
  }), {
110
310
  body: {
111
311
  accepted: !0,
@@ -115,13 +315,13 @@ var c = [
115
315
  }
116
316
  },
117
317
  status: 200
118
- }, "Capability result"), o(t.map(({ invocationId: e, kind: t, payload: n }) => ({
318
+ }, "Capability result"), u(t.map(({ invocationId: e, kind: t, payload: n }) => ({
119
319
  invocationId: e,
120
320
  kind: t,
121
321
  payload: n
122
322
  })), [{
123
323
  invocationId: "async-capability",
124
- kind: "connector",
324
+ kind: "artifact.put",
125
325
  payload: {
126
326
  action: "read",
127
327
  input: { issue: 42 }
@@ -129,23 +329,95 @@ var c = [
129
329
  }], "Capability request");
130
330
  }
131
331
  },
332
+ {
333
+ name: "returns final outputs without exposing intermediate output capability",
334
+ async verify(e) {
335
+ u(await e.invoke({
336
+ capability: async () => {
337
+ throw Error("Capability must not be called.");
338
+ },
339
+ input: null,
340
+ invocationId: "final-outputs",
341
+ program: l(e, "export default (_input, context) => ({ available: typeof context.outputs, value: 1 })")
342
+ }), {
343
+ available: "undefined",
344
+ value: 1
345
+ }, "Final Task outputs");
346
+ }
347
+ },
132
348
  {
133
349
  name: "cancels a pending Capability and the user invocation",
134
350
  async verify(e) {
135
351
  let t = new AbortController(), n = !1, r, i = new Promise((e) => {
136
352
  r = e;
137
- }), c = e.invoke({
353
+ }), a = e.invoke({
354
+ capabilities: [{
355
+ kind: "connector",
356
+ action: "example.wait",
357
+ connections: []
358
+ }],
138
359
  capability: async ({ signal: e }) => (r(), await new Promise((t, r) => e.addEventListener("abort", () => {
139
360
  n = !0, r(e.reason);
140
361
  }, { once: !0 }))),
141
362
  input: null,
142
363
  invocationId: "canceled-capability",
143
- program: a(e, "export default async (_input, capability) => capability.connector({ action: 'wait' })"),
364
+ program: l(e, "export default async (_input, context) => context.actions.example.wait({})"),
144
365
  signal: t.signal
145
366
  });
146
- await i, t.abort(/* @__PURE__ */ Error("Invocation canceled.")), await s(c, /cancel|abort|disposed/i, "Canceled invocation"), o(n, !0, "Capability cancellation");
367
+ await i, t.abort(/* @__PURE__ */ Error("Invocation canceled.")), await d(a, /cancel|abort|disposed/i, "Canceled invocation"), u(n, !0, "Capability cancellation");
147
368
  }
148
369
  }
149
370
  ];
371
+ function p(e, t) {
372
+ let n = (e, t) => {
373
+ if (!(e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e))) {
374
+ if (typeof e != "object" || t.has(e) || !Array.isArray(e) && Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null || Object.getOwnPropertySymbols(e).length > 0) throw Object.assign(/* @__PURE__ */ Error("Action parameters must contain only JSON values."), { code: "capability.invalid" });
375
+ t.add(e);
376
+ for (let r of Array.isArray(e) ? e : Object.values(e)) n(r, t);
377
+ t.delete(e);
378
+ }
379
+ }, r = Object.create(null), i = /* @__PURE__ */ new Map();
380
+ for (let a of e) {
381
+ let e = a.action.indexOf("."), o = a.action.slice(0, e), s = a.action.slice(e + 1), c = i.get(o);
382
+ c ?? (c = Object.create(null), i.set(o, c), r[o] = c);
383
+ let l = async (e = {}, r) => (n(e, /* @__PURE__ */ new Set()), r !== void 0 && n(r, /* @__PURE__ */ new Set()), (await t({
384
+ action: a.action,
385
+ input: e,
386
+ ...r === void 0 ? {} : { options: r }
387
+ })).body);
388
+ r[a.action] = l, c[s] = l;
389
+ }
390
+ for (let e of i.values()) Object.freeze(e);
391
+ return Object.freeze(r);
392
+ }
393
+ function m(e, t) {
394
+ let n = Object.assign(/* @__PURE__ */ Error("The Action request is invalid."), { code: "capability.invalid" }), r = Object.assign(/* @__PURE__ */ Error("The Action or Connection is not declared for this Task."), { code: "capability.denied" });
395
+ if (typeof t != "object" || !t || Array.isArray(t)) throw n;
396
+ let i = t;
397
+ if (Object.keys(i).some((e) => ![
398
+ "action",
399
+ "input",
400
+ "options"
401
+ ].includes(e)) || typeof i.action != "string" || i.input == null || typeof i.input != "object" || Array.isArray(i.input)) throw n;
402
+ let a = e.find((e) => e.action == i.action);
403
+ if (a == null) throw r;
404
+ let o = a.connectionId;
405
+ if (Object.hasOwn(i, "options")) {
406
+ if (i.options == null || typeof i.options != "object" || Array.isArray(i.options)) throw n;
407
+ let e = i.options, t = Object.keys(e);
408
+ if (t.length != 1) throw n;
409
+ if (typeof e.connectionId == "string" && e.connectionId.length > 0 && t[0] == "connectionId") o = e.connectionId;
410
+ else if (typeof e.connectionAlias == "string" && e.connectionAlias.length > 0 && t[0] == "connectionAlias") {
411
+ if (o = a.connections.find((t) => t.alias == e.connectionAlias)?.connectionId, o == null) throw r;
412
+ } else throw n;
413
+ }
414
+ if (o != null && !a.connections.some((e) => e.connectionId == o)) throw r;
415
+ if (o == null && a.connections.length > 0) throw Object.assign(/* @__PURE__ */ Error("Choose a Connector Connection for this Action."), { code: "connector.connection-required" });
416
+ return {
417
+ action: i.action,
418
+ input: i.input,
419
+ ...o == null ? {} : { connectionId: o }
420
+ };
421
+ }
150
422
  //#endregion
151
- export { n as currentEngineContract, i as findEngineContract, c as runtimeConformanceCases };
423
+ export { p as createActions, n as currentEngineContract, o as findEngineContract, r as nodejsEngineContract, c as nodejsRuntimeConformanceCases, m as resolveAction, f as runtimeConformanceCases, s as snapshotRuntimeResult };
@@ -1,5 +1,6 @@
1
- import type { ConnectorCapability, JsonValue } from '../browser/flow-change.js';
1
+ import type { ConnectorCapability, JsonValue, WaitAction } from '../browser/flow-change.js';
2
2
  import type { PreparedFlow } from './flow-semantics.js';
3
+ import type { AgentCheckpoint } from './runtime-contract.js';
3
4
  import * as Effect from 'effect/Effect';
4
5
  export type SchedulerEvent = {
5
6
  readonly flowId: string;
@@ -17,29 +18,30 @@ export type SchedulerEvent = {
17
18
  readonly inputs: Readonly<Record<string, JsonValue>>;
18
19
  readonly jobId: string;
19
20
  readonly nodeId: string;
20
- readonly nodeKind: 'condition' | 'connector' | 'javascript' | 'llm' | 'subflow' | 'value';
21
+ readonly nodeKind: 'agent' | 'approval' | 'condition' | 'connector' | 'javascript' | 'llm' | 'subflow' | 'value' | 'wait';
21
22
  readonly nodeTitle?: string;
22
23
  readonly runId: string;
23
24
  readonly type: 'node.started';
24
25
  } | {
25
- readonly handle: string;
26
26
  readonly jobId: string;
27
27
  readonly nodeId: string;
28
+ readonly outputs: Readonly<Record<string, JsonValue>>;
28
29
  readonly runId: string;
29
- readonly type: 'node.output';
30
- readonly value: JsonValue;
30
+ readonly type: 'node.completed';
31
31
  } | {
32
+ readonly code: string;
32
33
  readonly jobId: string;
34
+ readonly message: string;
33
35
  readonly nodeId: string;
34
36
  readonly runId: string;
35
- readonly type: 'node.completed';
37
+ readonly type: 'node.failed';
36
38
  } | {
37
- readonly code: string;
38
39
  readonly jobId: string;
40
+ readonly level: 'debug' | 'error' | 'info' | 'warn';
39
41
  readonly message: string;
40
42
  readonly nodeId: string;
41
43
  readonly runId: string;
42
- readonly type: 'node.failed';
44
+ readonly type: 'node.log';
43
45
  } | {
44
46
  readonly result: FlowRunResult | SubflowRunResult;
45
47
  readonly runId: string;
@@ -52,19 +54,82 @@ export type SchedulerEvent = {
52
54
  export interface FlowRunResult {
53
55
  readonly kind: 'node-results';
54
56
  readonly nodes: readonly {
55
- readonly jobs: readonly {
56
- readonly jobId: string;
57
- readonly outputs: Readonly<Record<string, JsonValue>>;
58
- }[];
59
57
  readonly nodeId: string;
58
+ readonly status: 'completed';
59
+ readonly jobId: string;
60
+ readonly outputs: Readonly<Record<string, JsonValue>>;
60
61
  }[];
61
62
  }
63
+ export interface PendingWait {
64
+ readonly jobId: string;
65
+ readonly nodeId: string;
66
+ readonly value: JsonValue;
67
+ readonly waitId: string;
68
+ readonly pending?: JsonValue;
69
+ }
70
+ export interface WaitRequest {
71
+ readonly jobId: string;
72
+ readonly nodeId: string;
73
+ readonly value: JsonValue;
74
+ readonly waitId: string;
75
+ readonly actions: readonly ['continue'] | readonly ['approve', 'reject'];
76
+ readonly prompt: string;
77
+ readonly notify: boolean;
78
+ readonly notification?: {
79
+ readonly input: Readonly<Record<string, JsonValue>>;
80
+ readonly messageHandle: string;
81
+ readonly taskId: string;
82
+ };
83
+ }
84
+ export type WaitOperation = {
85
+ readonly kind: 'create';
86
+ readonly wait: WaitRequest;
87
+ } | {
88
+ readonly kind: 'resolutions';
89
+ readonly waitIds: readonly string[];
90
+ readonly block: boolean;
91
+ };
92
+ export interface WaitHost {
93
+ readonly create: (wait: WaitRequest) => Effect.Effect<JsonValue | undefined, Error>;
94
+ readonly resolutions: (waitIds: readonly string[], block: boolean) => Effect.Effect<Readonly<Record<string, WaitAction>>, Error>;
95
+ }
96
+ export declare const waitRetentionMs = 120000;
97
+ export interface FlowRunCheckpoint {
98
+ readonly bindingValues: Readonly<Record<string, string>>;
99
+ readonly inputs: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
100
+ readonly results: Readonly<Record<string, {
101
+ readonly jobId: string;
102
+ readonly outputs: Readonly<Record<string, JsonValue>>;
103
+ }>>;
104
+ readonly counts: Readonly<Record<string, Readonly<Record<string, number>>>>;
105
+ readonly frames: Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, JsonValue>>>>>>;
106
+ readonly version: 5;
107
+ readonly waits: readonly PendingWait[];
108
+ readonly agents: Readonly<Record<string, {
109
+ readonly invocationId: string;
110
+ readonly input: Readonly<Record<string, JsonValue>>;
111
+ readonly remainingMs?: number;
112
+ readonly checkpoint: AgentCheckpoint;
113
+ }>>;
114
+ }
115
+ export type FlowRunOutcome = FlowRunResult | {
116
+ readonly checkpoint: FlowRunCheckpoint;
117
+ readonly kind: 'waiting';
118
+ readonly remainingMs?: number;
119
+ };
62
120
  export interface SubflowRunResult {
63
121
  readonly kind: 'function-outputs';
64
122
  readonly outputs: Readonly<Record<string, JsonValue>>;
65
123
  readonly target: 'subflow';
66
124
  }
67
125
  interface TaskInvocationBase {
126
+ readonly agent?: {
127
+ readonly action: 'approve' | 'reject';
128
+ readonly checkpoint: AgentCheckpoint;
129
+ };
130
+ readonly additionalInputs: Readonly<Record<string, JsonValue>>;
131
+ readonly blockId: string;
132
+ readonly flowId: string;
68
133
  readonly input: Readonly<Record<string, JsonValue>>;
69
134
  readonly invocationId: string;
70
135
  readonly jobId: string;
@@ -79,22 +144,35 @@ export type TaskInvocation = TaskInvocationBase & ({
79
144
  });
80
145
  export interface TriggerSeed {
81
146
  readonly nodeId: string;
82
- readonly payload: JsonValue;
147
+ readonly outputs: Readonly<Record<string, JsonValue>>;
83
148
  }
84
149
  export interface SchedulerFailure {
85
150
  readonly code: string;
86
151
  readonly message: string;
87
152
  }
88
- export interface FlowRunOptions {
89
- readonly bindingValues?: Readonly<Record<string, string>>;
153
+ export type FlowRunOptions = {
90
154
  readonly createId: () => string;
91
155
  readonly emit?: (event: SchedulerEvent) => Effect.Effect<void, Error>;
92
156
  readonly flowId: string;
93
- readonly inputs?: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
94
157
  readonly invokeTask: (invocation: TaskInvocation) => Effect.Effect<unknown, Error>;
95
158
  readonly projectFailure?: (error: unknown) => SchedulerFailure;
96
159
  readonly runId: string;
97
- readonly trigger?: TriggerSeed;
98
- }
99
- export declare function runFlow(prepared: PreparedFlow, options: FlowRunOptions): Effect.Effect<FlowRunResult, Error>;
160
+ readonly waits?: WaitHost;
161
+ readonly remainingMs?: number;
162
+ } & RunLaunch;
163
+ export type RunLaunch = {
164
+ readonly bindingValues?: Readonly<Record<string, string>>;
165
+ readonly inputs?: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
166
+ readonly trigger: TriggerSeed;
167
+ readonly resume?: never;
168
+ } | {
169
+ readonly resume: {
170
+ readonly checkpoint: unknown;
171
+ };
172
+ readonly bindingValues?: never;
173
+ readonly inputs?: never;
174
+ readonly trigger?: never;
175
+ };
176
+ export declare function decodeFlowRunCheckpoint(input: unknown): FlowRunCheckpoint;
177
+ export declare function runFlow(prepared: PreparedFlow, options: FlowRunOptions): Effect.Effect<FlowRunOutcome, Error>;
100
178
  export {};