@workflow/core 5.0.0-beta.50 → 5.0.0-beta.52

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 (50) hide show
  1. package/README.md +5 -0
  2. package/dist/events-consumer.d.ts +26 -0
  3. package/dist/events-consumer.d.ts.map +1 -1
  4. package/dist/events-consumer.js +28 -1
  5. package/dist/flushable-stream.d.ts +41 -0
  6. package/dist/flushable-stream.d.ts.map +1 -1
  7. package/dist/flushable-stream.js +169 -1
  8. package/dist/log-format.d.ts +3 -0
  9. package/dist/log-format.d.ts.map +1 -1
  10. package/dist/log-format.js +45 -10
  11. package/dist/replay-divergence.d.ts +25 -0
  12. package/dist/replay-divergence.d.ts.map +1 -0
  13. package/dist/replay-divergence.js +61 -0
  14. package/dist/runtime/helpers.d.ts +75 -1
  15. package/dist/runtime/helpers.d.ts.map +1 -1
  16. package/dist/runtime/helpers.js +134 -5
  17. package/dist/runtime/quickjs-entrypoint.d.ts +30 -8
  18. package/dist/runtime/quickjs-entrypoint.d.ts.map +1 -1
  19. package/dist/runtime/quickjs-entrypoint.js +209 -32
  20. package/dist/runtime/quickjs-log-view.d.ts +129 -0
  21. package/dist/runtime/quickjs-log-view.d.ts.map +1 -0
  22. package/dist/runtime/quickjs-log-view.js +229 -0
  23. package/dist/runtime/step-executor.d.ts +2 -21
  24. package/dist/runtime/step-executor.d.ts.map +1 -1
  25. package/dist/runtime/step-executor.js +85 -80
  26. package/dist/runtime/suspension-handler.d.ts +0 -22
  27. package/dist/runtime/suspension-handler.d.ts.map +1 -1
  28. package/dist/runtime/suspension-handler.js +126 -75
  29. package/dist/runtime.d.ts.map +1 -1
  30. package/dist/runtime.js +262 -91
  31. package/dist/serialization.d.ts +2 -2
  32. package/dist/serialization.d.ts.map +1 -1
  33. package/dist/serialization.js +16 -13
  34. package/dist/step/context-storage.d.ts +2 -0
  35. package/dist/step/context-storage.d.ts.map +1 -1
  36. package/dist/step/context-storage.js +1 -1
  37. package/dist/step/writable-stream.d.ts.map +1 -1
  38. package/dist/step/writable-stream.js +14 -10
  39. package/dist/telemetry/semantic-conventions.d.ts +36 -0
  40. package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
  41. package/dist/telemetry/semantic-conventions.js +23 -1
  42. package/dist/test-support/orchestrator-context.d.ts.map +1 -1
  43. package/dist/test-support/orchestrator-context.js +8 -2
  44. package/dist/version.d.ts +1 -1
  45. package/dist/version.js +2 -2
  46. package/dist/workflow.d.ts.map +1 -1
  47. package/dist/workflow.js +8 -3
  48. package/docs/foundations/streaming.mdx +1 -1
  49. package/docs/how-it-works/event-sourcing.mdx +27 -0
  50. package/package.json +6 -6
@@ -38,14 +38,29 @@ export declare function isFirstInvocation(preloadedEvents: readonly Event[] | un
38
38
  * This replaces the `node:vm` replay path (runWorkflow + EventsConsumer)
39
39
  * with a QuickJS VM invocation that performs the same full event replay.
40
40
  *
41
- * KNOWN GAP (slot snapshot): unlike the node:vm path, no event write in
42
- * this file carries {@link CreateEventParams.eventCount}, so a World never
43
- * learns which events the writer had not seen and never reports them back.
44
- * The engine currently relies on per-(runId, correlationId) event
45
- * uniqueness (EntityConflictError dedup) alone. This is a deliberate
46
- * simplification while the engine is experimental: wiring the snapshot is
47
- * tracked follow-up work; anyone adding new write paths here should not
48
- * assume parity with the node engine on this axis.
41
+ * Log position on writes. This engine follows the same rule as the node:vm
42
+ * replay loop for which writes tell the World where the writer stood (see the
43
+ * "Who names a position" table above `slotSnapshotParams` in `helpers.ts`):
44
+ *
45
+ * - Writes made from this invocation's view of the log (`step_created`,
46
+ * `wait_created`, `hook_created`, `hook_disposed`, `attr_set`, the abort
47
+ * `hook_received`, `wait_completed`, and the `step_created` + `step_failed`
48
+ * pair for an unserializable input) carry `eventCount`, and the page a
49
+ * World hands back is queued for the live VM through {@link QuickJSLogView}.
50
+ * - A single inline step's terminal write asks for the inline delta
51
+ * (`sinceCursor`) through `executeStep`, and so does a lone `hook_created`
52
+ * (see `dispatchPendingOps.deltaCursor`); the delta is queued the same
53
+ * way. The step executor's other writes carry nothing: it holds no log.
54
+ * - Run-terminal writes (`run_completed`, `run_failed`) and the terminal drain
55
+ * of pending ops carry nothing: nothing reads the log afterwards.
56
+ *
57
+ * What differs from the node engine is what "merge into the log" means. The
58
+ * node engine merges a returned page into the array it replays from. This
59
+ * engine holds a live VM that consumes events exactly once, in position
60
+ * order, so a returned page is queued and delivered ahead of the next
61
+ * `events.list`, which then only runs when the queue cannot account for the
62
+ * next position. Both engines fall back to a list for anything a page did
63
+ * not carry.
49
64
  */
50
65
  export declare function runWorkflowWithQuickJS(params: {
51
66
  workflowCode: string;
@@ -67,6 +82,13 @@ export declare function runWorkflowWithQuickJS(params: {
67
82
  * hook-resume preload would be discarded and refetched.
68
83
  */
69
84
  preloadedEventsComplete?: boolean;
85
+ /**
86
+ * The `events.list` cursor positioned after the last of `preloadedEvents`,
87
+ * when the caller has one. Lets this invocation read incrementally from
88
+ * where the preload ended and ask for an inline delta against it. Without
89
+ * it the first read after the preload starts from the top of the log.
90
+ */
91
+ preloadedCursor?: string | null;
70
92
  /**
71
93
  * Run input carried through the queue message on first delivery. Used
72
94
  * as a last-resort fallback for `run_created.eventData.input` when
@@ -1 +1 @@
1
- {"version":3,"file":"quickjs-entrypoint.d.ts","sourceRoot":"","sources":["../../src/runtime/quickjs-entrypoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAS/C,OAAO,EACL,KAAK,KAAK,EAEV,KAAK,QAAQ,EAIb,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAoDzB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAC/B,eAAe,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,GAC5C,OAAO,CAOT;AAuqBD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE;IACnD,Y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