@fluidgrids/workflows 2026.1027.0 → 2026.1028.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.
Files changed (168) hide show
  1. package/README.md +170 -18
  2. package/dist/activation-BBh1p82z.d.cts +57 -0
  3. package/dist/activation-DnhG7SmF.d.ts +57 -0
  4. package/dist/assemble-BLqQ8lSu.d.cts +39 -0
  5. package/dist/assemble-DWgaXHd-.d.ts +39 -0
  6. package/dist/chunk-2DP2Y6EU.cjs +832 -0
  7. package/dist/chunk-2J6TF7YI.cjs +86 -0
  8. package/dist/chunk-3FOTFQ3J.js +1622 -0
  9. package/dist/chunk-4LYSEANA.js +199 -0
  10. package/dist/{chunk-KUTMY2IO.cjs → chunk-57MSZ24T.cjs} +162 -98
  11. package/dist/{chunk-BWSLWF2E.js → chunk-5HDSBTBX.js} +99 -32
  12. package/dist/chunk-623FVQSN.cjs +251 -0
  13. package/dist/{chunk-4DPEGDPW.js → chunk-6FSHT5IL.js} +4 -4
  14. package/dist/{chunk-REV7ZOA4.js → chunk-7AAZGVKD.js} +1 -35
  15. package/dist/chunk-7NQ37GZU.js +73 -0
  16. package/dist/chunk-ABFZWYHT.js +612 -0
  17. package/dist/{chunk-SS4LT2IP.js → chunk-BD7ZPG53.js} +5 -10
  18. package/dist/chunk-BO6OVILK.js +79 -0
  19. package/dist/chunk-C5OLWZ42.js +245 -0
  20. package/dist/chunk-CBL5JSCC.cjs +75 -0
  21. package/dist/{chunk-LSKSBVL4.cjs → chunk-CPDK3K5N.cjs} +6 -6
  22. package/dist/chunk-CSNWNFKU.cjs +1635 -0
  23. package/dist/chunk-DJYMDLV5.js +227 -0
  24. package/dist/{chunk-X4HKU3MX.js → chunk-E2VK7J2C.js} +3 -1
  25. package/dist/chunk-FMSW2HDF.cjs +267 -0
  26. package/dist/chunk-FQIHX7YI.cjs +80 -0
  27. package/dist/chunk-FR7KYWRO.cjs +41 -0
  28. package/dist/{chunk-AU3YW7FZ.cjs → chunk-GBQ33SIZ.cjs} +46 -51
  29. package/dist/{chunk-RRQ5HOBF.cjs → chunk-GVTZMA5C.cjs} +4 -4
  30. package/dist/chunk-H7KEVW2M.js +816 -0
  31. package/dist/chunk-HR3BN4C4.cjs +27 -0
  32. package/dist/chunk-IISBRUWJ.js +13 -0
  33. package/dist/chunk-JD2VQIDZ.cjs +15 -0
  34. package/dist/{chunk-PL73GJR4.js → chunk-JZ4TOOLN.js} +1 -1
  35. package/dist/chunk-L24YIZY7.cjs +207 -0
  36. package/dist/chunk-LNUQE6D6.js +39 -0
  37. package/dist/{chunk-BYJ7QTLY.cjs → chunk-NEIUQASE.cjs} +13 -13
  38. package/dist/chunk-P6TA5EZT.cjs +634 -0
  39. package/dist/chunk-PDHLTDZB.js +72 -0
  40. package/dist/chunk-PMCM2OH4.js +46 -0
  41. package/dist/chunk-PZCVF76Q.cjs +868 -0
  42. package/dist/{chunk-GO34UHSY.js → chunk-QAN5MZEM.js} +3 -3
  43. package/dist/{chunk-27HASETB.cjs → chunk-QKZL3ONM.cjs} +3 -1
  44. package/dist/chunk-SAENRNBJ.cjs +52 -0
  45. package/dist/{chunk-LMX35GNQ.js → chunk-SMCANK3F.js} +5 -4
  46. package/dist/{chunk-IZQNUNSU.cjs → chunk-SX2PNKKT.cjs} +18 -17
  47. package/dist/{chunk-LRM6JXJA.cjs → chunk-TBDXTV22.cjs} +0 -37
  48. package/dist/chunk-VOKMAAJP.js +848 -0
  49. package/dist/chunk-XB53G2DK.js +25 -0
  50. package/dist/chunk-Z2Y65YOY.cjs +7 -0
  51. package/dist/codegen/index.cjs +9 -7
  52. package/dist/codegen/index.d.cts +2 -2
  53. package/dist/codegen/index.d.ts +2 -2
  54. package/dist/codegen/index.js +6 -5
  55. package/dist/file-BOoHZgoQ.d.cts +1557 -0
  56. package/dist/file-yuPCFU5b.d.ts +1557 -0
  57. package/dist/history/index.cjs +287 -0
  58. package/dist/history/index.d.cts +157 -0
  59. package/dist/history/index.d.ts +157 -0
  60. package/dist/history/index.js +5 -0
  61. package/dist/index.cjs +134 -36
  62. package/dist/index.d.cts +137 -9
  63. package/dist/index.d.ts +137 -9
  64. package/dist/index.js +8 -3
  65. package/dist/ir/index.cjs +161 -165
  66. package/dist/ir/index.d.cts +32 -12
  67. package/dist/ir/index.d.ts +32 -12
  68. package/dist/ir/index.js +54 -61
  69. package/dist/lower-BuSvAFqi.d.cts +129 -0
  70. package/dist/lower-C_Qv_34S.d.ts +129 -0
  71. package/dist/lower-types-nofRXw9c.d.cts +15 -0
  72. package/dist/lower-types-nofRXw9c.d.ts +15 -0
  73. package/dist/{manifest-Duf-gHdO.d.cts → manifest-0OLw0i7k.d.cts} +1 -1
  74. package/dist/{manifest-Bp9ZJlav.d.ts → manifest-C8N6HDYl.d.ts} +1 -1
  75. package/dist/node-evaluator-CJNP4GHX.js +12 -0
  76. package/dist/node-evaluator-DMKPKUWA.cjs +22 -0
  77. package/dist/quickjs/index.cjs +256 -78
  78. package/dist/quickjs/index.d.cts +48 -7
  79. package/dist/quickjs/index.d.ts +48 -7
  80. package/dist/quickjs/index.js +254 -79
  81. package/dist/roundtrip/index.cjs +404 -129
  82. package/dist/roundtrip/index.d.cts +43 -8
  83. package/dist/roundtrip/index.d.ts +43 -8
  84. package/dist/roundtrip/index.js +260 -19
  85. package/dist/runtime/index.cjs +90 -0
  86. package/dist/runtime/index.d.cts +297 -0
  87. package/dist/runtime/index.d.ts +297 -0
  88. package/dist/runtime/index.js +8 -0
  89. package/dist/testing/index.cjs +1057 -0
  90. package/dist/testing/index.d.cts +305 -0
  91. package/dist/testing/index.d.ts +305 -0
  92. package/dist/testing/index.js +1037 -0
  93. package/dist/{types-Dr2Fn1Ax.d.ts → types-BGoPzgcl.d.cts} +1 -1
  94. package/dist/{types-Dr2Fn1Ax.d.cts → types-BGoPzgcl.d.ts} +1 -1
  95. package/dist/types-CpBBjaGX.d.cts +380 -0
  96. package/dist/types-DV-HX_Gt.d.ts +380 -0
  97. package/dist/{assemble-DMOuaxRI.d.ts → workflow-Bpr3vnA_.d.ts} +60 -162
  98. package/dist/workflow-C2a05WUJ.d.ts +444 -0
  99. package/dist/{assemble-BJo9TECS.d.cts → workflow-FXUkpIBc.d.cts} +60 -162
  100. package/dist/workflow-J-yYixny.d.cts +444 -0
  101. package/fixtures/README.md +128 -0
  102. package/fixtures/histories/activity-failure-fails-run.history.json +163 -0
  103. package/fixtures/histories/activity-retry-then-success.history.json +147 -0
  104. package/fixtures/histories/cancel-activity-abandon.history.json +126 -0
  105. package/fixtures/histories/cancel-activity-compensate.history.json +307 -0
  106. package/fixtures/histories/cancel-concurrent-non-cancellable.history.json +234 -0
  107. package/fixtures/histories/cancel-concurrent-scope-timeout.history.json +184 -0
  108. package/fixtures/histories/cancel-condition-after-cancel.history.json +200 -0
  109. package/fixtures/histories/cancel-during-timer.history.json +123 -0
  110. package/fixtures/histories/cancel-saga-compensations.history.json +325 -0
  111. package/fixtures/histories/cancel-scope-timeout.history.json +148 -0
  112. package/fixtures/histories/child-abandon-outlives-parent.history.json +191 -0
  113. package/fixtures/histories/child-cancel-default.history.json +234 -0
  114. package/fixtures/histories/child-cancel-request.history.json +206 -0
  115. package/fixtures/histories/child-durable-child-side.history.json +124 -0
  116. package/fixtures/histories/child-durable-result.history.json +163 -0
  117. package/fixtures/histories/child-failure-caught.history.json +166 -0
  118. package/fixtures/histories/child-graph-by-key.history.json +138 -0
  119. package/fixtures/histories/child-terminated-by-parent-close.history.json +85 -0
  120. package/fixtures/histories/continue-as-new-first-run.history.json +146 -0
  121. package/fixtures/histories/continue-as-new-history-limit.history.json +489 -0
  122. package/fixtures/histories/continue-as-new-last-run.history.json +147 -0
  123. package/fixtures/histories/continue-as-new-suggested.history.json +352 -0
  124. package/fixtures/histories/details-and-context.history.json +176 -0
  125. package/fixtures/histories/deterministic-values.history.json +128 -0
  126. package/fixtures/histories/engine-builtins.history.json +172 -0
  127. package/fixtures/histories/gather-activities.history.json +291 -0
  128. package/fixtures/histories/gather-all-settled.history.json +219 -0
  129. package/fixtures/histories/gather-mixed.history.json +281 -0
  130. package/fixtures/histories/input-during-running-task.history.json +111 -0
  131. package/fixtures/histories/nondeterminism-reordered.history.json +218 -0
  132. package/fixtures/histories/patched-deprecated.history.json +271 -0
  133. package/fixtures/histories/patched-new-run.history.json +270 -0
  134. package/fixtures/histories/patched-old-history.history.json +190 -0
  135. package/fixtures/histories/race-activity-wins.history.json +152 -0
  136. package/fixtures/histories/race-signal-beats-child.history.json +161 -0
  137. package/fixtures/histories/race-timeout-wins.history.json +118 -0
  138. package/fixtures/histories/side-effect-recorded.history.json +153 -0
  139. package/fixtures/histories/signal-buffered-at-start.history.json +157 -0
  140. package/fixtures/histories/signal-default-handler.history.json +187 -0
  141. package/fixtures/histories/signal-handler.history.json +191 -0
  142. package/fixtures/histories/signal-parent-child-side.history.json +132 -0
  143. package/fixtures/histories/signal-parent.history.json +202 -0
  144. package/fixtures/histories/signal-run-delivered.history.json +128 -0
  145. package/fixtures/histories/signal-run-undelivered.history.json +134 -0
  146. package/fixtures/histories/signal-wait.history.json +111 -0
  147. package/fixtures/histories/task-failure-code-error.history.json +137 -0
  148. package/fixtures/histories/task-failure-then-transient-attempt.history.json +140 -0
  149. package/fixtures/histories/timer-condition-met.history.json +201 -0
  150. package/fixtures/histories/timer-condition-timeout.history.json +118 -0
  151. package/fixtures/histories/timer-sleep-once.history.json +118 -0
  152. package/fixtures/histories/timer-sleep-sequence.history.json +210 -0
  153. package/fixtures/histories/update-accepted-completed.history.json +149 -0
  154. package/fixtures/histories/update-with-start-rejected-validation.history.json +91 -0
  155. package/package.json +85 -20
  156. package/schema/history-file.schema.json +2544 -0
  157. package/schema/ir-v2.schema.json +16 -0
  158. package/schema/run-event.schema.json +2374 -0
  159. package/schema/workflow-command.schema.json +1095 -0
  160. package/schema/workflow-task.schema.json +3560 -0
  161. package/dist/chunk-265J2FCH.cjs +0 -33
  162. package/dist/chunk-LUXCXFOE.cjs +0 -269
  163. package/dist/chunk-S34NJE3A.js +0 -262
  164. package/dist/chunk-SRQRLWOS.js +0 -31
  165. package/dist/lower-DcOY8ux0.d.cts +0 -49
  166. package/dist/lower-Dw5grNrI.d.ts +0 -49
  167. package/dist/node-evaluator-2GTUZVPK.cjs +0 -17
  168. package/dist/node-evaluator-RMYEWCXZ.js +0 -8
@@ -1,6 +1,8 @@
1
1
  import { autoLayout } from './chunk-5LUIDMF4.js';
2
- import { makeRef, isPredicate, conditionTreeOf, BuilderError, refModelOf } from './chunk-PL73GJR4.js';
3
- import { isRecord, cloneJson, formatRefTemplate } from './chunk-REV7ZOA4.js';
2
+ import { makeRef, isPredicate, conditionTreeOf, BuilderError, refModelOf } from './chunk-JZ4TOOLN.js';
3
+ import { formatRefTemplate } from './chunk-7AAZGVKD.js';
4
+ import { isRecord, setOwn, cloneJson, ownValue } from './chunk-PMCM2OH4.js';
5
+ import { isDurableWorkflow, SDK_VERSION } from './chunk-7NQ37GZU.js';
4
6
 
5
7
  // src/builder/descriptors.ts
6
8
  function op(nodeType, version, operation) {
@@ -84,7 +86,7 @@ function isTier1Workflow(value) {
84
86
  }
85
87
  function deepMerge(base, extra, path) {
86
88
  for (const [key, value] of Object.entries(extra)) {
87
- const existing = base[key];
89
+ const existing = ownValue(base, key);
88
90
  if (isRecord(existing) && isRecord(value)) {
89
91
  deepMerge(existing, value, `${path}.${key}`);
90
92
  } else if (existing !== void 0) {
@@ -92,7 +94,7 @@ function deepMerge(base, extra, path) {
92
94
  `extra sets ${path}.${key}, which the builder already wrote; use the typed option`
93
95
  );
94
96
  } else {
95
- base[key] = lowerValue(value, `${path}.${key}`);
97
+ setOwn(base, key, lowerValue(value, `${path}.${key}`));
96
98
  }
97
99
  }
98
100
  }
@@ -117,7 +119,7 @@ function lowerValue(value, path) {
117
119
  const out = {};
118
120
  for (const [key, child] of Object.entries(value)) {
119
121
  if (child === void 0) continue;
120
- out[key] = lowerValue(child, `${path}.${key}`);
122
+ setOwn(out, key, lowerValue(child, `${path}.${key}`));
121
123
  }
122
124
  return out;
123
125
  }
@@ -196,8 +198,12 @@ var WorkflowBuilder = class {
196
198
  edges = [];
197
199
  notes = [];
198
200
  ids = /* @__PURE__ */ new Set();
201
+ /** Ids given explicitly; a second edge with the same explicit id is an error. */
199
202
  edgeIds = /* @__PURE__ */ new Set();
203
+ /** Edges whose id is the default, as indices into `edges`, with the unsuffixed default id. */
204
+ defaultIds = [];
200
205
  edgeOrder;
206
+ durableRefs = [];
201
207
  /** A reference to a node by id, for nodes declared later in the source. */
202
208
  ref(id) {
203
209
  return nodeRef(id);
@@ -271,10 +277,21 @@ var WorkflowBuilder = class {
271
277
  }
272
278
  /** `internal:wait-for-signal` (IR v2). */
273
279
  waitForSignal(options) {
274
- const { name, limit, ...rest } = options;
280
+ const { name, limit, until, consume, ...rest } = options;
281
+ if (limit !== void 0 && until !== void 0)
282
+ throw new BuilderError("wf.waitForSignal takes limit or until, not both");
283
+ if (consume !== void 0 && consume !== "first" && consume !== "all")
284
+ throw new BuilderError(`consume must be "first" or "all" (got "${String(consume)}")`);
275
285
  const sugar = {};
276
286
  if (name !== void 0) sugar["signalName"] = name;
287
+ if (consume !== void 0) sugar["consume"] = consume;
277
288
  if (limit !== void 0) sugar["limitWait"] = limitWait(limit);
289
+ if (until !== void 0) {
290
+ const deadline = until instanceof Date ? until.toISOString() : until;
291
+ if (typeof deadline !== "string" || Number.isNaN(Date.parse(deadline)))
292
+ throw new BuilderError(`until "${String(until)}" is not an ISO 8601 date-time`);
293
+ sugar["limitWaitUntil"] = deadline;
294
+ }
278
295
  const ref = this.add(internalNodes.waitForSignal, rest, sugar);
279
296
  return { ...ref, received: ref.handle("received"), timedOut: ref.handle("timedOut") };
280
297
  }
@@ -297,6 +314,45 @@ var WorkflowBuilder = class {
297
314
  if (input !== void 0) sugar["inputMapping"] = input;
298
315
  return this.add(internalNodes.subworkflow, rest, sugar);
299
316
  }
317
+ /**
318
+ * `internal:code-workflow`: run a tier-2 function of this project as a
319
+ * durable child run. `fn` is a `workflow()` value (its export name is
320
+ * resolved when the bundle is collected) or an export name.
321
+ */
322
+ codeWorkflow(fn, options = {}) {
323
+ const {
324
+ input,
325
+ taskQueue,
326
+ waitForCompletion,
327
+ timeoutSeconds,
328
+ failOnError,
329
+ parentClosePolicy,
330
+ ...rest
331
+ } = options;
332
+ let workflowFn;
333
+ let definition;
334
+ if (typeof fn === "string" && fn !== "") workflowFn = fn;
335
+ else if (isDurableWorkflow(fn)) {
336
+ definition = fn;
337
+ workflowFn = fn.name;
338
+ } else throw new BuilderError("wf.codeWorkflow needs a workflow() function or its export name");
339
+ if (parentClosePolicy !== void 0 && !["TERMINATE", "ABANDON", "REQUEST_CANCEL"].includes(parentClosePolicy))
340
+ throw new BuilderError(`parentClosePolicy "${String(parentClosePolicy)}" is not a policy`);
341
+ const sugar = { workflowFn };
342
+ if (input !== void 0) sugar["inputMapping"] = input;
343
+ if (taskQueue !== void 0) sugar["taskQueue"] = taskQueue;
344
+ if (waitForCompletion !== void 0) sugar["waitForCompletion"] = waitForCompletion;
345
+ if (timeoutSeconds !== void 0) sugar["timeout"] = timeoutSeconds;
346
+ if (failOnError !== void 0) sugar["failOnError"] = failOnError;
347
+ if (parentClosePolicy !== void 0) sugar["parentClosePolicy"] = parentClosePolicy;
348
+ const ref = this.add(internalNodes.codeWorkflow, rest, sugar);
349
+ if (definition) this.durableRefs.push({ nodeId: ref.id, definition });
350
+ return ref;
351
+ }
352
+ /** The `wf.codeWorkflow` calls that named a function. */
353
+ durableReferences() {
354
+ return [...this.durableRefs];
355
+ }
300
356
  /** `internal:validate`. */
301
357
  validate(options) {
302
358
  const ref = this.add(internalNodes.validate, options, {});
@@ -407,6 +463,7 @@ var WorkflowBuilder = class {
407
463
  }
408
464
  /** The recording, once the callback has returned. */
409
465
  finish(key, document) {
466
+ this.assignDefaultEdgeIds();
410
467
  return {
411
468
  format: RECORDING_FORMAT,
412
469
  formatVersion: RECORDING_FORMAT_VERSION,
@@ -433,13 +490,35 @@ var WorkflowBuilder = class {
433
490
  for (let suffix = 2; this.ids.has(candidate); suffix++) candidate = `${base}-${suffix}`;
434
491
  return candidate;
435
492
  }
493
+ /**
494
+ * Give every edge declared without an id its default id. Explicit ids are
495
+ * claimed first, so a default never takes an id the code names; a default that
496
+ * is taken gets `-2`, `-3`, … in declaration order. The result depends only on
497
+ * the builder calls.
498
+ */
499
+ assignDefaultEdgeIds() {
500
+ const taken = new Set(this.edgeIds);
501
+ for (const { index, base } of this.defaultIds) {
502
+ let id = base;
503
+ for (let suffix = 2; taken.has(id); suffix++) id = `${base}-${suffix}`;
504
+ taken.add(id);
505
+ const built = this.edges[index];
506
+ if (built) built.id = id;
507
+ }
508
+ this.defaultIds.length = 0;
509
+ }
436
510
  addEdge(spec, target) {
437
511
  const { source, sourceHandle } = sourceOf(spec.from);
438
- const id = spec.id === false ? void 0 : spec.id ?? defaultEdgeId(source, target, sourceHandle, spec.targetHandle);
439
- if (id !== void 0) {
440
- if (this.edgeIds.has(id)) throw new BuilderError(`Duplicate edge id "${id}"`);
441
- this.edgeIds.add(id);
512
+ const explicit = typeof spec.id === "string" ? spec.id : void 0;
513
+ if (spec.id !== void 0 && spec.id !== false && explicit === void 0)
514
+ throw new BuilderError("An edge id must be a string or false");
515
+ if (explicit !== void 0) {
516
+ if (this.edgeIds.has(explicit)) throw new BuilderError(`Duplicate edge id "${explicit}"`);
517
+ this.edgeIds.add(explicit);
442
518
  }
519
+ const base = spec.id === void 0 ? defaultEdgeId(source, target, sourceHandle, spec.targetHandle) : void 0;
520
+ const id = explicit ?? base;
521
+ if (base !== void 0) this.defaultIds.push({ index: this.edges.length, base });
443
522
  const built = id !== void 0 ? { id, source, target } : { source, target };
444
523
  if (sourceHandle !== void 0) built["sourceHandle"] = sourceHandle;
445
524
  if (spec.targetHandle !== void 0) built["targetHandle"] = spec.targetHandle;
@@ -554,12 +633,15 @@ function defineWorkflow(options, build) {
554
633
  if (options.extra !== void 0)
555
634
  deepMerge(document, lowerObject(options.extra, "extra"), "workflow");
556
635
  const recording = builder.finish(options.key, document);
557
- return { __fluidgrids: WORKFLOW_MARKER, key: options.key, recording };
636
+ const durableRefs = builder.durableReferences();
637
+ return {
638
+ __fluidgrids: WORKFLOW_MARKER,
639
+ key: options.key,
640
+ recording,
641
+ ...durableRefs.length > 0 ? { durableRefs } : {}
642
+ };
558
643
  }
559
644
 
560
- // src/generated/version.ts
561
- var SDK_VERSION = "2026.1027.0";
562
-
563
645
  // src/builder/assemble.ts
564
646
  var LAYOUT_FORMAT = "fluidgrids.layout";
565
647
  var LAYOUT_FORMAT_VERSION = 1;
@@ -589,7 +671,7 @@ function parseLayoutSidecar(value) {
589
671
  if (!isRecord(position) || typeof position["x"] !== "number" || typeof position["y"] !== "number") {
590
672
  throw new BuilderError(`The layout position of "${id}" must be { x, y }`);
591
673
  }
592
- parsed[id] = { x: position["x"], y: position["y"] };
674
+ setOwn(parsed, id, { x: position["x"], y: position["y"] });
593
675
  }
594
676
  const sidecar = {
595
677
  format: LAYOUT_FORMAT,
@@ -694,7 +776,7 @@ function assembleRecording(recording, options = {}) {
694
776
  document["meta"] = meta;
695
777
  }
696
778
  for (const [key, value] of Object.entries(document)) {
697
- if (!Object.hasOwn(out, key) && value !== void 0) out[key] = value;
779
+ if (!Object.hasOwn(out, key) && value !== void 0) setOwn(out, key, value);
698
780
  }
699
781
  return out;
700
782
  }
@@ -704,19 +786,4 @@ function toIR(workflow, options = {}) {
704
786
  return assembleRecording(workflow.recording, options);
705
787
  }
706
788
 
707
- // src/builder/collect.ts
708
- var COLLECTION_FORMAT = "fluidgrids.tier1-collection";
709
- function collectWorkflowExports(modules) {
710
- const workflows = [];
711
- for (const [module, namespace] of modules) {
712
- for (const exportName of Object.keys(namespace).sort()) {
713
- const value = namespace[exportName];
714
- if (isTier1Workflow(value))
715
- workflows.push({ module, exportName, recording: value.recording });
716
- }
717
- }
718
- const collection = { format: COLLECTION_FORMAT, workflows };
719
- return JSON.stringify(collection);
720
- }
721
-
722
- export { COLLECTION_FORMAT, LAYOUT_FORMAT, LAYOUT_FORMAT_VERSION, RECORDING_FORMAT, RECORDING_FORMAT_VERSION, SDK_VERSION, UnresolvedConnectionsError, WorkflowBuilder, assembleRecording, collectWorkflowExports, defaultEdgeId, defineWorkflow, edge, internalNodes, isOperation, isTier1Workflow, nodes, op, parseLayoutSidecar, toIR, trigger, triggers };
789
+ export { LAYOUT_FORMAT, LAYOUT_FORMAT_VERSION, RECORDING_FORMAT, RECORDING_FORMAT_VERSION, UnresolvedConnectionsError, WorkflowBuilder, assembleRecording, defaultEdgeId, defineWorkflow, edge, internalNodes, isOperation, isTier1Workflow, nodes, op, parseLayoutSidecar, toIR, trigger, triggers };
@@ -0,0 +1,251 @@
1
+ 'use strict';
2
+
3
+ // src/history/types.ts
4
+ var HISTORY_PROTOCOL = 1;
5
+ var EVENT_TYPES = [
6
+ "WORKFLOW_STARTED",
7
+ "WORKFLOW_TASK_SCHEDULED",
8
+ "WORKFLOW_TASK_STARTED",
9
+ "WORKFLOW_TASK_COMPLETED",
10
+ "WORKFLOW_TASK_FAILED",
11
+ "WORKFLOW_TASK_TIMED_OUT",
12
+ "ACTIVITY_SCHEDULED",
13
+ "ACTIVITY_STARTED",
14
+ "ACTIVITY_HEARTBEAT",
15
+ "ACTIVITY_COMPLETED",
16
+ "ACTIVITY_FAILED",
17
+ "ACTIVITY_TIMED_OUT",
18
+ "ACTIVITY_CANCEL_REQUESTED",
19
+ "ACTIVITY_CANCELLED",
20
+ "ACTIVITY_PAUSED",
21
+ "ACTIVITY_UNPAUSED",
22
+ "ACTIVITY_RESET",
23
+ "ACTIVITY_OPTIONS_UPDATED",
24
+ "TIMER_STARTED",
25
+ "TIMER_FIRED",
26
+ "TIMER_CANCELLED",
27
+ "SIGNAL_RECEIVED",
28
+ "UPDATE_ADMITTED",
29
+ "UPDATE_ACCEPTED",
30
+ "UPDATE_COMPLETED",
31
+ "CHILD_RUN_INITIATED",
32
+ "CHILD_RUN_STARTED",
33
+ "CHILD_RUN_COMPLETED",
34
+ "CHILD_RUN_FAILED",
35
+ "CHILD_RUN_CANCELLED",
36
+ "CHILD_RUN_TERMINATED",
37
+ "CHILD_RUN_TIMED_OUT",
38
+ "EXTERNAL_RUN_CANCEL_REQUESTED",
39
+ "EXTERNAL_RUN_CANCEL_RESOLVED",
40
+ "EXTERNAL_RUN_SIGNALED",
41
+ "SIDE_EFFECT_RECORDED",
42
+ "LOCAL_ACTIVITY_COMPLETED",
43
+ "LOCAL_ACTIVITY_FAILED",
44
+ "SEARCH_ATTRIBUTES_UPSERTED",
45
+ "CONTEXT_UPSERTED",
46
+ "MARKER_RECORDED",
47
+ "WORKFLOW_CANCEL_REQUESTED",
48
+ "WORKFLOW_RESET",
49
+ "VERSIONING_OVERRIDE_SET",
50
+ "WORKFLOW_COMPLETED",
51
+ "WORKFLOW_FAILED",
52
+ "WORKFLOW_CANCELLED",
53
+ "WORKFLOW_TERMINATED",
54
+ "WORKFLOW_TIMED_OUT",
55
+ "WORKFLOW_CONTINUED_AS_NEW"
56
+ ];
57
+ var COMMAND_TYPES = [
58
+ "SCHEDULE_ACTIVITY",
59
+ "REQUEST_CANCEL_ACTIVITY",
60
+ "START_TIMER",
61
+ "CANCEL_TIMER",
62
+ "START_CHILD_RUN",
63
+ "SIGNAL_RUN",
64
+ "RECORD_SIDE_EFFECT",
65
+ "RECORD_MARKER",
66
+ "COMPLETE_WORKFLOW",
67
+ "FAIL_WORKFLOW",
68
+ "CANCEL_WORKFLOW",
69
+ "UPSERT_CONTEXT",
70
+ "RECORD_LOCAL_ACTIVITY",
71
+ "CONTINUE_AS_NEW",
72
+ "REQUEST_CANCEL_EXTERNAL_RUN",
73
+ "UPSERT_SEARCH_ATTRIBUTES",
74
+ "ACCEPT_UPDATE",
75
+ "REJECT_UPDATE",
76
+ "COMPLETE_UPDATE"
77
+ ];
78
+ var PHASE_B_CORE_COMMANDS = /* @__PURE__ */ new Set([
79
+ "SCHEDULE_ACTIVITY",
80
+ "REQUEST_CANCEL_ACTIVITY",
81
+ "START_TIMER",
82
+ "CANCEL_TIMER",
83
+ "START_CHILD_RUN",
84
+ "SIGNAL_RUN",
85
+ "RECORD_SIDE_EFFECT",
86
+ "RECORD_MARKER",
87
+ "COMPLETE_WORKFLOW",
88
+ "FAIL_WORKFLOW",
89
+ "CANCEL_WORKFLOW"
90
+ ]);
91
+ var PHASE_B_PARITY_COMMANDS = /* @__PURE__ */ new Set([
92
+ "UPSERT_CONTEXT",
93
+ "RECORD_LOCAL_ACTIVITY",
94
+ "CONTINUE_AS_NEW",
95
+ "REQUEST_CANCEL_EXTERNAL_RUN"
96
+ ]);
97
+ var PHASE_C_COMMANDS = /* @__PURE__ */ new Set([
98
+ "UPSERT_SEARCH_ATTRIBUTES",
99
+ "ACCEPT_UPDATE",
100
+ "REJECT_UPDATE",
101
+ "COMPLETE_UPDATE"
102
+ ]);
103
+ var TERMINAL_COMMANDS = /* @__PURE__ */ new Set([
104
+ "COMPLETE_WORKFLOW",
105
+ "FAIL_WORKFLOW",
106
+ "CANCEL_WORKFLOW",
107
+ "CONTINUE_AS_NEW"
108
+ ]);
109
+ var TASK_FAILURE_CAUSES = [
110
+ "NON_DETERMINISM",
111
+ "TASK_TIMEOUT",
112
+ "ISOLATE_MEMORY",
113
+ "PROTOCOL_MISMATCH",
114
+ "BUNDLE_UNAVAILABLE",
115
+ "BUNDLE_INTEGRITY",
116
+ "WORKFLOW_CODE_ERROR",
117
+ "HISTORY_LIMIT",
118
+ "UNSUPPORTED_COMMAND",
119
+ "INVALID_REQUEST",
120
+ "INTERNAL"
121
+ ];
122
+ var ERROR_TYPES = [
123
+ "TIMEOUT",
124
+ "TRANSIENT",
125
+ "DEPENDENCY",
126
+ "AUTHORIZATION",
127
+ "VALIDATION",
128
+ "PERMANENT",
129
+ "UNKNOWN"
130
+ ];
131
+ var EXECUTION_KINDS = ["GRAPH", "DURABLE_FN"];
132
+ var PARENT_CLOSE_POLICIES = ["TERMINATE", "ABANDON", "REQUEST_CANCEL"];
133
+ var ACTIVITY_CANCELLATION_TYPES = [
134
+ "WAIT_CANCELLATION_COMPLETED",
135
+ "TRY_CANCEL",
136
+ "ABANDON"
137
+ ];
138
+ var CHILD_CANCELLATION_TYPES = [
139
+ "WAIT_CANCELLATION_COMPLETED",
140
+ "WAIT_CANCELLATION_REQUESTED",
141
+ "TRY_CANCEL",
142
+ "ABANDON"
143
+ ];
144
+ var DEFAULT_HISTORY_LIMIT = { events: 1e4, bytes: 16 * 1024 * 1024 };
145
+ var CONTINUE_AS_NEW_SUGGESTED_RATIO = 0.8;
146
+ var HISTORY_LIMIT_EXCEEDED_RATIO = 0.95;
147
+ var BUILT_IN_QUERIES = [
148
+ "__stack_trace",
149
+ "__enhanced_stack_trace",
150
+ "__metadata"
151
+ ];
152
+ var COMMAND_EVENT_TYPES = {
153
+ SCHEDULE_ACTIVITY: "ACTIVITY_SCHEDULED",
154
+ REQUEST_CANCEL_ACTIVITY: "ACTIVITY_CANCEL_REQUESTED",
155
+ START_TIMER: "TIMER_STARTED",
156
+ CANCEL_TIMER: "TIMER_CANCELLED",
157
+ START_CHILD_RUN: "CHILD_RUN_INITIATED",
158
+ SIGNAL_RUN: "EXTERNAL_RUN_SIGNALED",
159
+ RECORD_SIDE_EFFECT: "SIDE_EFFECT_RECORDED",
160
+ RECORD_MARKER: "MARKER_RECORDED",
161
+ COMPLETE_WORKFLOW: "WORKFLOW_COMPLETED",
162
+ FAIL_WORKFLOW: "WORKFLOW_FAILED",
163
+ CANCEL_WORKFLOW: "WORKFLOW_CANCELLED",
164
+ UPSERT_CONTEXT: "CONTEXT_UPSERTED",
165
+ RECORD_LOCAL_ACTIVITY: "LOCAL_ACTIVITY_COMPLETED",
166
+ CONTINUE_AS_NEW: "WORKFLOW_CONTINUED_AS_NEW",
167
+ REQUEST_CANCEL_EXTERNAL_RUN: "EXTERNAL_RUN_CANCEL_REQUESTED",
168
+ UPSERT_SEARCH_ATTRIBUTES: "SEARCH_ATTRIBUTES_UPSERTED",
169
+ ACCEPT_UPDATE: "UPDATE_ACCEPTED",
170
+ REJECT_UPDATE: null,
171
+ COMPLETE_UPDATE: "UPDATE_COMPLETED"
172
+ };
173
+ var COMMAND_EVENTS = /* @__PURE__ */ new Set([
174
+ "ACTIVITY_SCHEDULED",
175
+ "ACTIVITY_CANCEL_REQUESTED",
176
+ "TIMER_STARTED",
177
+ "TIMER_CANCELLED",
178
+ "CHILD_RUN_INITIATED",
179
+ "EXTERNAL_RUN_SIGNALED",
180
+ "SIDE_EFFECT_RECORDED",
181
+ "MARKER_RECORDED",
182
+ "WORKFLOW_COMPLETED",
183
+ "WORKFLOW_FAILED",
184
+ "WORKFLOW_CANCELLED",
185
+ "CONTEXT_UPSERTED",
186
+ "LOCAL_ACTIVITY_COMPLETED",
187
+ "LOCAL_ACTIVITY_FAILED",
188
+ "WORKFLOW_CONTINUED_AS_NEW",
189
+ "EXTERNAL_RUN_CANCEL_REQUESTED",
190
+ "SEARCH_ATTRIBUTES_UPSERTED",
191
+ "UPDATE_ACCEPTED",
192
+ "UPDATE_COMPLETED"
193
+ ]);
194
+ var INPUT_EVENTS = /* @__PURE__ */ new Set([
195
+ "WORKFLOW_STARTED",
196
+ "ACTIVITY_COMPLETED",
197
+ "ACTIVITY_FAILED",
198
+ "ACTIVITY_TIMED_OUT",
199
+ "ACTIVITY_CANCELLED",
200
+ "TIMER_FIRED",
201
+ "SIGNAL_RECEIVED",
202
+ "UPDATE_ADMITTED",
203
+ "CHILD_RUN_STARTED",
204
+ "CHILD_RUN_COMPLETED",
205
+ "CHILD_RUN_FAILED",
206
+ "CHILD_RUN_CANCELLED",
207
+ "CHILD_RUN_TERMINATED",
208
+ "CHILD_RUN_TIMED_OUT",
209
+ "EXTERNAL_RUN_CANCEL_RESOLVED",
210
+ "WORKFLOW_CANCEL_REQUESTED"
211
+ ]);
212
+ var TERMINAL_EVENTS = /* @__PURE__ */ new Set([
213
+ "WORKFLOW_COMPLETED",
214
+ "WORKFLOW_FAILED",
215
+ "WORKFLOW_CANCELLED",
216
+ "WORKFLOW_TERMINATED",
217
+ "WORKFLOW_TIMED_OUT",
218
+ "WORKFLOW_CONTINUED_AS_NEW"
219
+ ]);
220
+ function isInputEvent(event) {
221
+ if (event.type === "EXTERNAL_RUN_SIGNALED") return event.payload["resolved"] === true;
222
+ return INPUT_EVENTS.has(event.type);
223
+ }
224
+ function isCommandEvent(event) {
225
+ if (event.type === "EXTERNAL_RUN_SIGNALED") return event.payload["resolved"] !== true;
226
+ return COMMAND_EVENTS.has(event.type);
227
+ }
228
+
229
+ exports.ACTIVITY_CANCELLATION_TYPES = ACTIVITY_CANCELLATION_TYPES;
230
+ exports.BUILT_IN_QUERIES = BUILT_IN_QUERIES;
231
+ exports.CHILD_CANCELLATION_TYPES = CHILD_CANCELLATION_TYPES;
232
+ exports.COMMAND_EVENTS = COMMAND_EVENTS;
233
+ exports.COMMAND_EVENT_TYPES = COMMAND_EVENT_TYPES;
234
+ exports.COMMAND_TYPES = COMMAND_TYPES;
235
+ exports.CONTINUE_AS_NEW_SUGGESTED_RATIO = CONTINUE_AS_NEW_SUGGESTED_RATIO;
236
+ exports.DEFAULT_HISTORY_LIMIT = DEFAULT_HISTORY_LIMIT;
237
+ exports.ERROR_TYPES = ERROR_TYPES;
238
+ exports.EVENT_TYPES = EVENT_TYPES;
239
+ exports.EXECUTION_KINDS = EXECUTION_KINDS;
240
+ exports.HISTORY_LIMIT_EXCEEDED_RATIO = HISTORY_LIMIT_EXCEEDED_RATIO;
241
+ exports.HISTORY_PROTOCOL = HISTORY_PROTOCOL;
242
+ exports.INPUT_EVENTS = INPUT_EVENTS;
243
+ exports.PARENT_CLOSE_POLICIES = PARENT_CLOSE_POLICIES;
244
+ exports.PHASE_B_CORE_COMMANDS = PHASE_B_CORE_COMMANDS;
245
+ exports.PHASE_B_PARITY_COMMANDS = PHASE_B_PARITY_COMMANDS;
246
+ exports.PHASE_C_COMMANDS = PHASE_C_COMMANDS;
247
+ exports.TASK_FAILURE_CAUSES = TASK_FAILURE_CAUSES;
248
+ exports.TERMINAL_COMMANDS = TERMINAL_COMMANDS;
249
+ exports.TERMINAL_EVENTS = TERMINAL_EVENTS;
250
+ exports.isCommandEvent = isCommandEvent;
251
+ exports.isInputEvent = isInputEvent;
@@ -1,5 +1,5 @@
1
- import { hashedProjection } from './chunk-SS4LT2IP.js';
2
- import { isRecord, deepEqual } from './chunk-REV7ZOA4.js';
1
+ import { hashedProjection } from './chunk-BD7ZPG53.js';
2
+ import { isRecord, deepEqual, ownValue } from './chunk-PMCM2OH4.js';
3
3
 
4
4
  // src/ir/diff.ts
5
5
  function keyPath(base, key) {
@@ -10,8 +10,8 @@ function diffValues(before, after, path, out) {
10
10
  if (isRecord(before) && isRecord(after)) {
11
11
  const keys = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])].sort();
12
12
  for (const key of keys) {
13
- const left = before[key];
14
- const right = after[key];
13
+ const left = ownValue(before, key);
14
+ const right = ownValue(after, key);
15
15
  if (left === void 0 && right !== void 0)
16
16
  out.push({ kind: "added", path: keyPath(path, key), after: right });
17
17
  else if (left !== void 0 && right === void 0)
@@ -1,37 +1,3 @@
1
- // src/ir/json-utils.ts
2
- function isRecord(value) {
3
- return typeof value === "object" && value !== null && !Array.isArray(value);
4
- }
5
- function deepEqual(left, right) {
6
- if (left === right) return true;
7
- if (Array.isArray(left)) {
8
- if (!Array.isArray(right) || left.length !== right.length) return false;
9
- return left.every((item, index) => deepEqual(item, right[index]));
10
- }
11
- if (isRecord(left)) {
12
- if (!isRecord(right)) return false;
13
- const leftKeys = Object.keys(left).filter((key) => left[key] !== void 0);
14
- const rightKeys = Object.keys(right).filter((key) => right[key] !== void 0);
15
- if (leftKeys.length !== rightKeys.length) return false;
16
- return leftKeys.every((key) => Object.hasOwn(right, key) && deepEqual(left[key], right[key]));
17
- }
18
- return false;
19
- }
20
- function cloneJson(value) {
21
- return structuredCloneJson(value);
22
- }
23
- function structuredCloneJson(value) {
24
- if (Array.isArray(value)) return value.map(structuredCloneJson);
25
- if (isRecord(value)) {
26
- const out = {};
27
- for (const [key, child] of Object.entries(value)) {
28
- if (child !== void 0) out[key] = structuredCloneJson(child);
29
- }
30
- return out;
31
- }
32
- return value;
33
- }
34
-
35
1
  // src/ir/expressions.ts
36
2
  var IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
37
3
  function segmentFromKey(key) {
@@ -167,4 +133,4 @@ function isJsIdentifier(name) {
167
133
  return IDENTIFIER.test(name);
168
134
  }
169
135
 
170
- export { cloneJson, deepEqual, formatRefExpression, formatRefTemplate, hasLegacyTemplate, isJsIdentifier, isRecord, parseRefExpression, parseTemplate, segmentFromKey };
136
+ export { formatRefExpression, formatRefTemplate, hasLegacyTemplate, isJsIdentifier, parseRefExpression, parseTemplate, segmentFromKey };
@@ -0,0 +1,73 @@
1
+ // src/durable/workflow.ts
2
+ var DURABLE_MARKER = "fluidgrids.durable-workflow";
3
+ var KEY = /^[a-z0-9][a-z0-9_-]{0,127}$/;
4
+ function workflow(name, optionsOrFn, maybeFn) {
5
+ if (typeof name !== "string" || !KEY.test(name))
6
+ throw new TypeError(
7
+ `workflow() needs a key of lowercase letters, digits, "-" and "_" (got "${String(name)}")`
8
+ );
9
+ const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
10
+ const options = typeof optionsOrFn === "function" ? {} : optionsOrFn ?? {};
11
+ if (typeof fn !== "function") throw new TypeError(`workflow("${name}") needs a function`);
12
+ return Object.freeze({ __fluidgrids: DURABLE_MARKER, name, options, fn });
13
+ }
14
+ function isDurableWorkflow(value) {
15
+ return typeof value === "object" && value !== null && value.__fluidgrids === DURABLE_MARKER && typeof value.fn === "function";
16
+ }
17
+ function isJsonValue(value, depth = 0) {
18
+ if (depth > 64) return false;
19
+ if (value === null || typeof value === "string" || typeof value === "boolean") return true;
20
+ if (typeof value === "number") return Number.isFinite(value);
21
+ if (Array.isArray(value)) return value.every((item) => isJsonValue(item, depth + 1));
22
+ if (typeof value === "object") {
23
+ if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
24
+ return false;
25
+ return Object.values(value).every((item) => isJsonValue(item, depth + 1));
26
+ }
27
+ return false;
28
+ }
29
+ function jsonSchemaOf(schema) {
30
+ if (schema === void 0) return void 0;
31
+ const method = schema.toJSONSchema;
32
+ if (typeof method === "function") {
33
+ const produced = method.call(schema);
34
+ return isJsonValue(produced) && typeof produced === "object" && !Array.isArray(produced) && produced !== null ? produced : void 0;
35
+ }
36
+ return isJsonValue(schema) && !Array.isArray(schema) && schema !== null && typeof schema === "object" ? schema : void 0;
37
+ }
38
+ function interfaceOf(definition) {
39
+ const out = {};
40
+ const input = jsonSchemaOf(definition.options.input);
41
+ const output = jsonSchemaOf(definition.options.output);
42
+ if (input) out.input = input;
43
+ if (output) out.output = output;
44
+ const signals = definition.options.signals ?? [];
45
+ if (signals.length > 0) {
46
+ out.signals = {};
47
+ for (const signal of signals) {
48
+ const entry = {};
49
+ const payload = jsonSchemaOf(signal.schema);
50
+ if (payload) entry.payload = payload;
51
+ if (signal.description !== void 0) entry.description = signal.description;
52
+ out.signals[signal.name] = entry;
53
+ }
54
+ }
55
+ const queries = definition.options.queries ?? [];
56
+ if (queries.length > 0) {
57
+ out.queries = {};
58
+ for (const query of queries)
59
+ out.queries[query.name] = query.description !== void 0 ? { description: query.description } : {};
60
+ }
61
+ const updates = definition.options.updates ?? [];
62
+ if (updates.length > 0) {
63
+ out.updates = {};
64
+ for (const update of updates)
65
+ out.updates[update.name] = update.description !== void 0 ? { description: update.description } : {};
66
+ }
67
+ return out;
68
+ }
69
+
70
+ // src/generated/version.ts
71
+ var SDK_VERSION = "2026.1028.1";
72
+
73
+ export { DURABLE_MARKER, SDK_VERSION, interfaceOf, isDurableWorkflow, jsonSchemaOf, workflow };