eve 0.48.0 → 0.49.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.
Files changed (189) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/channel/channel-address.js +1 -1
  3. package/dist/src/channel/types.d.ts +10 -0
  4. package/dist/src/cli/commands/registry-metadata.d.ts +30 -0
  5. package/dist/src/cli/commands/registry-metadata.js +1 -1
  6. package/dist/src/cli/commands/registry-package.d.ts +6 -0
  7. package/dist/src/cli/commands/registry-package.js +1 -1
  8. package/dist/src/cli/commands/registry-pnpm-build-policy-flow.d.ts +30 -0
  9. package/dist/src/cli/commands/registry-pnpm-build-policy-flow.js +1 -0
  10. package/dist/src/cli/commands/registry-pnpm-build-policy.d.ts +12 -0
  11. package/dist/src/cli/commands/registry-pnpm-build-policy.js +6 -0
  12. package/dist/src/cli/commands/registry-recovery.d.ts +4 -0
  13. package/dist/src/cli/commands/registry-recovery.js +1 -1
  14. package/dist/src/cli/commands/registry.d.ts +1 -1
  15. package/dist/src/cli/commands/registry.js +1 -1
  16. package/dist/src/cli/dev/tui/setup-commands.js +2 -2
  17. package/dist/src/compiled/.vendor-stamp.json +7 -7
  18. package/dist/src/compiled/@workflow/core/attribute-changes.d.ts +2 -4
  19. package/dist/src/compiled/@workflow/core/capabilities.d.ts +10 -9
  20. package/dist/src/compiled/@workflow/core/capture-stack.d.ts +1 -1
  21. package/dist/src/compiled/@workflow/core/class-serialization.d.ts +8 -8
  22. package/dist/src/compiled/@workflow/core/context-violation-error.d.ts +5 -5
  23. package/dist/src/compiled/@workflow/core/create-hook.d.ts +2 -2
  24. package/dist/src/compiled/@workflow/core/describe-error.d.ts +7 -7
  25. package/dist/src/compiled/@workflow/core/encryption.d.ts +5 -5
  26. package/dist/src/compiled/@workflow/core/events-consumer.d.ts +49 -14
  27. package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +4 -4
  28. package/dist/src/compiled/@workflow/core/global.d.ts +4 -2
  29. package/dist/src/compiled/@workflow/core/index.d.ts +1 -1
  30. package/dist/src/compiled/@workflow/core/index.js +2 -2
  31. package/dist/src/compiled/@workflow/core/log-format.d.ts +2 -2
  32. package/dist/src/compiled/@workflow/core/private.d.ts +40 -78
  33. package/dist/src/compiled/@workflow/core/private.js +1 -1
  34. package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +13 -17
  35. package/dist/src/compiled/@workflow/core/runtime/compute-instance.d.ts +4 -3
  36. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +27 -27
  37. package/dist/src/compiled/@workflow/core/runtime/count-step-started-events.d.ts +7 -7
  38. package/dist/src/compiled/@workflow/core/runtime/deployment-guard.d.ts +7 -7
  39. package/dist/src/compiled/@workflow/core/runtime/get-port-lazy.d.ts +2 -2
  40. package/dist/src/compiled/@workflow/core/runtime/get-world-lazy.d.ts +2 -2
  41. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +30 -49
  42. package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +21 -10
  43. package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +31 -15
  44. package/dist/src/compiled/@workflow/core/runtime/quickjs-serde.d.ts +10 -10
  45. package/dist/src/compiled/@workflow/core/runtime/replay-budget.d.ts +4 -4
  46. package/dist/src/compiled/@workflow/core/runtime/replay-recovery-reporter.d.ts +1 -1
  47. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +20 -12
  48. package/dist/src/compiled/@workflow/core/runtime/resume-latency.d.ts +37 -30
  49. package/dist/src/compiled/@workflow/core/runtime/run-id-time.d.ts +2 -2
  50. package/dist/src/compiled/@workflow/core/runtime/run.d.ts +22 -5
  51. package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +4 -4
  52. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +3 -3
  53. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +14 -14
  54. package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +42 -25
  55. package/dist/src/compiled/@workflow/core/runtime/step-ownership.d.ts +6 -6
  56. package/dist/src/compiled/@workflow/core/runtime/step-single-flight.d.ts +1 -1
  57. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +38 -24
  58. package/dist/src/compiled/@workflow/core/runtime/unserializable-step.d.ts +34 -0
  59. package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +2 -2
  60. package/dist/src/compiled/@workflow/core/runtime/wait-continuation.d.ts +31 -9
  61. package/dist/src/compiled/@workflow/core/runtime/wait-until.d.ts +1 -1
  62. package/dist/src/compiled/@workflow/core/runtime/world-compatibility.d.ts +20 -9
  63. package/dist/src/compiled/@workflow/core/runtime/world-init.d.ts +5 -5
  64. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  65. package/dist/src/compiled/@workflow/core/sealed-box.d.ts +7 -7
  66. package/dist/src/compiled/@workflow/core/serialization/codec-devalue-vm.d.ts +1 -1
  67. package/dist/src/compiled/@workflow/core/serialization/codec-devalue.d.ts +1 -1
  68. package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +4 -4
  69. package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +12 -11
  70. package/dist/src/compiled/@workflow/core/serialization/encryption.d.ts +7 -7
  71. package/dist/src/compiled/@workflow/core/serialization/format.d.ts +6 -6
  72. package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +23 -22
  73. package/dist/src/compiled/@workflow/core/serialization/index.d.ts +1 -1
  74. package/dist/src/compiled/@workflow/core/serialization/reducers/class-vm.d.ts +1 -1
  75. package/dist/src/compiled/@workflow/core/serialization/reducers/step-function-vm.d.ts +1 -1
  76. package/dist/src/compiled/@workflow/core/serialization/types.d.ts +5 -5
  77. package/dist/src/compiled/@workflow/core/serialization/workflow-vm.d.ts +1 -1
  78. package/dist/src/compiled/@workflow/core/serialization-format.d.ts +11 -11
  79. package/dist/src/compiled/@workflow/core/serialization.d.ts +18 -19
  80. package/dist/src/compiled/@workflow/core/source-map.d.ts +1 -1
  81. package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +5 -5
  82. package/dist/src/compiled/@workflow/core/step/writable-stream.d.ts +3 -3
  83. package/dist/src/compiled/@workflow/core/symbols.d.ts +2 -2
  84. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +71 -20
  85. package/dist/src/compiled/@workflow/core/telemetry.d.ts +15 -3
  86. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  87. package/dist/src/compiled/@workflow/core/vm/script-cache.d.ts +9 -11
  88. package/dist/src/compiled/@workflow/core/workflow/abort-controller.d.ts +1 -1
  89. package/dist/src/compiled/@workflow/core/workflow/set-attributes.d.ts +1 -1
  90. package/dist/src/compiled/@workflow/core/workflow/world-init-stub.d.ts +1 -1
  91. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  92. package/dist/src/compiled/@workflow/errors/index.d.ts +18 -18
  93. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  94. package/dist/src/compiled/@workflow/world/analytics.d.ts +3 -2
  95. package/dist/src/compiled/@workflow/world/attributes-validation.d.ts +28 -0
  96. package/dist/src/compiled/@workflow/world/attributes.d.ts +8 -107
  97. package/dist/src/compiled/@workflow/world/env-config.d.ts +5 -5
  98. package/dist/src/compiled/@workflow/world/event-metadata.d.ts +132 -0
  99. package/dist/src/compiled/@workflow/world/events.d.ts +42 -96
  100. package/dist/src/compiled/@workflow/world/hooks.d.ts +12 -11
  101. package/dist/src/compiled/@workflow/world/index.d.ts +3 -3
  102. package/dist/src/compiled/@workflow/world/interfaces.d.ts +94 -39
  103. package/dist/src/compiled/@workflow/world/queue.d.ts +29 -22
  104. package/dist/src/compiled/@workflow/world/runs.d.ts +20 -0
  105. package/dist/src/compiled/@workflow/world/slot-identity.d.ts +3 -3
  106. package/dist/src/compiled/@workflow/world/spec-version.d.ts +82 -15
  107. package/dist/src/compiled/@workflow/world/ulid.d.ts +2 -2
  108. package/dist/src/compiled/@workflow/world-local/index.js +5 -5
  109. package/dist/src/compiled/@workflow/world-vercel/index.js +12 -12
  110. package/dist/src/compiled/_chunks/workflow/{attribute-changes-DXbpwBdw.js → attribute-changes-BwAadFfB.js} +3 -3
  111. package/dist/src/compiled/_chunks/workflow/debug-log-CVPstO1D.js +1 -0
  112. package/dist/src/compiled/_chunks/workflow/dist-CgbVZs5l.js +40 -0
  113. package/dist/src/compiled/_chunks/workflow/dist-DjojkP5e.js +3 -0
  114. package/dist/src/compiled/_chunks/workflow/frames-CZ9eHShe.js +3 -0
  115. package/dist/src/compiled/_chunks/workflow/global-singleton-BNinwFrL.js +1 -0
  116. package/dist/src/compiled/_chunks/workflow/private-CZFMABEf.js +1 -0
  117. package/dist/src/compiled/_chunks/workflow/resume-hook-BToMtPbH.js +1 -0
  118. package/dist/src/compiled/_chunks/workflow/run-DzyAoGh4.js +1 -0
  119. package/dist/src/compiled/_chunks/workflow/sleep-3_A5uOp-.js +1 -0
  120. package/dist/src/compiled/_chunks/workflow/undici-DfxNX5og.js +95 -0
  121. package/dist/src/compiled/_chunks/workflow/wait-until-BtySPYD0.js +15 -0
  122. package/dist/src/compiled/_chunks/workflow/ws-transport-PnVVxT0R.js +1 -0
  123. package/dist/src/eve-channel/index.js +1 -1
  124. package/dist/src/execution/agent-handle-dispatch.js +1 -1
  125. package/dist/src/execution/continuation-conflict-step.d.ts +10 -0
  126. package/dist/src/execution/continuation-conflict-step.js +1 -0
  127. package/dist/src/execution/delegated-parent-notification.js +1 -1
  128. package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +7 -29
  129. package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -1
  130. package/dist/src/execution/dispatch-runtime-actions-start.d.ts +33 -0
  131. package/dist/src/execution/dispatch-runtime-actions-start.js +1 -0
  132. package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
  133. package/dist/src/execution/dispatch-turn-step.js +1 -1
  134. package/dist/src/execution/dynamic-connections.js +1 -1
  135. package/dist/src/execution/inline-turn.js +1 -1
  136. package/dist/src/execution/next-driver-action.d.ts +5 -4
  137. package/dist/src/execution/proxied-deliver-step.js +1 -1
  138. package/dist/src/execution/runtime-errors.d.ts +0 -12
  139. package/dist/src/execution/runtime-errors.js +1 -1
  140. package/dist/src/execution/session-timeout-steps.js +1 -1
  141. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  142. package/dist/src/execution/stable-workflow-names.d.ts +2 -2
  143. package/dist/src/execution/subagent-start-local.js +1 -1
  144. package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -1
  145. package/dist/src/execution/tasks/parent/run-parent.js +1 -1
  146. package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
  147. package/dist/src/execution/tool-run/start.js +1 -1
  148. package/dist/src/execution/tools/subagent/local.js +1 -1
  149. package/dist/src/execution/turn-workflow.js +1 -1
  150. package/dist/src/execution/workflow-entry.d.ts +5 -1
  151. package/dist/src/execution/workflow-entry.js +1 -1
  152. package/dist/src/execution/workflow-runtime.d.ts +12 -12
  153. package/dist/src/execution/workflow-runtime.js +1 -1
  154. package/dist/src/execution/workflow-steps.js +1 -1
  155. package/dist/src/harness/tool-loop.js +1 -1
  156. package/dist/src/internal/application/package.js +1 -1
  157. package/dist/src/internal/workflow/development-world-client.js +1 -1
  158. package/dist/src/packages/eve-catalog/src/index.js +1 -1
  159. package/dist/src/public/channels/slack/slackChannel.d.ts +7 -1
  160. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  161. package/dist/src/setup/flows/registry.js +1 -1
  162. package/dist/src/setup/scaffold/connections/catalog.js +1 -1
  163. package/dist/src/setup/scaffold/create/project.js +1 -1
  164. package/docs/channels/custom.mdx +4 -0
  165. package/docs/channels/eve.mdx +12 -8
  166. package/docs/channels/mcp.mdx +4 -1
  167. package/docs/guides/instrumentation.md +1 -1
  168. package/docs/install-integrations.mdx +2 -0
  169. package/docs/instructions.mdx +1 -1
  170. package/docs/memory/custom-provider.md +214 -0
  171. package/docs/memory/file.md +129 -0
  172. package/docs/memory/meta.json +5 -0
  173. package/docs/memory/overview.mdx +282 -0
  174. package/docs/patterns/multi-tenant-memory.md +12 -20
  175. package/package.json +8 -8
  176. package/dist/src/compiled/_chunks/workflow/dist-CqvWKNQv.js +0 -3
  177. package/dist/src/compiled/_chunks/workflow/dist-Dk0aQqFO.js +0 -40
  178. package/dist/src/compiled/_chunks/workflow/dist-DpYyXbJv.js +0 -1
  179. package/dist/src/compiled/_chunks/workflow/env-config-L94XftKz.js +0 -1
  180. package/dist/src/compiled/_chunks/workflow/frames-Dl2Hcma4.js +0 -3
  181. package/dist/src/compiled/_chunks/workflow/private-CuQ4HTFC.js +0 -1
  182. package/dist/src/compiled/_chunks/workflow/resume-hook-E-Nkx8q_.js +0 -1
  183. package/dist/src/compiled/_chunks/workflow/run-cIeex2KF.js +0 -1
  184. package/dist/src/compiled/_chunks/workflow/sleep-CxFsdxB_.js +0 -1
  185. package/dist/src/compiled/_chunks/workflow/spec-version-DBUVfF_R.js +0 -1
  186. package/dist/src/compiled/_chunks/workflow/undici-DznrXKcM.js +0 -95
  187. package/dist/src/compiled/_chunks/workflow/wait-until-BZHmJCAW.js +0 -15
  188. package/dist/src/compiled/_chunks/workflow/ws-transport-Ct6yyRWZ.js +0 -1
  189. package/docs/memory.md +0 -408
@@ -1,11 +1,11 @@
1
1
  /**
2
- * QuickJS WASM workflow VM.
2
+ * QuickJS WebAssembly (WASM) workflow VM.
3
3
  *
4
4
  * An alternative engine for the event-replay execution model: the workflow
5
5
  * code runs inside a QuickJS WASM VM (via quickjs-wasi) instead of a
6
6
  * `node:vm` context. Every invocation creates a fresh VM, re-executes the
7
7
  * workflow function from the top, and replays the recorded event log to
8
- * resolve awaited primitives — the same replay semantics as the `node:vm`
8
+ * resolve awaited primitives: the same replay semantics as the `node:vm`
9
9
  * engine.
10
10
  *
11
11
  * The workflow primitives (useStep, sleep, createHook) are implemented as
@@ -14,11 +14,11 @@
14
14
  * resolve/reject promises.
15
15
  *
16
16
  * The VM bootstrap is deliberately split into two phases:
17
- * 1. Static initialization (`initWorkflowVM`) — run-independent setup:
17
+ * 1. Static initialization (`initWorkflowVM`): run-independent setup:
18
18
  * VM creation and the workflow primitives. (Serialization lives on
19
- * the host — see quickjs-serde.ts — so no serde code is evaluated
19
+ * the host (see quickjs-serde.ts) so no serde code is evaluated
20
20
  * in the VM.)
21
- * 2. Per-run initialization (inline in `runQuickJSWorkflow`) — seeded
21
+ * 2. Per-run initialization (inline in `runQuickJSWorkflow`): seeded
22
22
  * PRNG/ULID host functions, workflow bundle evaluation, run metadata,
23
23
  * workflow input, and start.
24
24
  * Keeping the phases separate is groundwork for VM-memory snapshotting:
@@ -28,17 +28,33 @@
28
28
  * module-scope user code observes the seeded `Math.random`, matching the
29
29
  * `node:vm` engine's replay determinism.
30
30
  */
31
- import type { Event, RunInput, WorkflowRun, WorldCapabilities } from '#compiled/@workflow/world/index.js';
31
+ import { SerializationError } from '#compiled/@workflow/errors/index.js';
32
+ import { type Event, type RunInput, type WorkflowRun, type WorldCapabilities } from '#compiled/@workflow/world/index.js';
32
33
  import { type Snapshot } from '../_quickjs-wasi.js';
33
34
  import type { DecryptionKey } from '../serialization/encryption.js';
34
35
  export interface PendingStep {
35
36
  type: 'step';
36
37
  correlationId: string;
37
38
  stepId: string;
38
- /** Format-prefixed devalue-serialized step input (args + closureVars) */
39
- input: Uint8Array;
39
+ /**
40
+ * Format-prefixed devalue-serialized step input (args + closureVars).
41
+ * Absent when {@link serializationError} is set: the input is precisely
42
+ * what refused to serialize.
43
+ */
44
+ input?: Uint8Array;
40
45
  /** Whether a step_created event already exists for this step */
41
46
  hasCreatedEvent: boolean;
47
+ /**
48
+ * Set when host-side serialization of the step's raw input failed while
49
+ * dumping the VM's pending ops (see `dumpPendingOps`). The failure is
50
+ * deterministic (replaying re-derives the same unserializable value), so
51
+ * instead of failing the whole collection the op is surfaced with the
52
+ * reframed error and no `input`; the entrypoint finalizes the step as
53
+ * `step_created` (placeholder input) + `step_failed`, mirroring the
54
+ * node:vm engine's `finalizeUnserializableStep`, so a try/catch around
55
+ * the step call observes the SerializationError.
56
+ */
57
+ serializationError?: SerializationError;
42
58
  }
43
59
  export interface PendingWait {
44
60
  type: 'wait';
@@ -100,7 +116,7 @@ export interface PendingHookDispose {
100
116
  }
101
117
  export type PendingOperation = PendingStep | PendingWait | PendingHook | PendingAttribute | PendingHookDispose;
102
118
  export interface QuickJSRuntimeResult {
103
- /** The workflow completed — result is format-prefixed devalue bytes */
119
+ /** The workflow completed: result is format-prefixed devalue bytes */
104
120
  completed?: {
105
121
  result: Uint8Array;
106
122
  /**
@@ -121,7 +137,7 @@ export interface QuickJSRuntimeResult {
121
137
  message: string;
122
138
  stack?: string;
123
139
  name?: string;
124
- /** See completed.drainOperations — same semantics on failure. */
140
+ /** See completed.drainOperations: same semantics on failure. */
125
141
  drainOperations?: PendingOperation[];
126
142
  /**
127
143
  * Format-prefixed devalue bytes of the original thrown value
@@ -155,8 +171,8 @@ export interface QuickJSRuntimeOptions {
155
171
  /**
156
172
  * The local port the workflow server is listening on, used to populate
157
173
  * `workflowMetadata.url`. Resolved at call time on the host side so the
158
- * VM doesn't have to probe the filesystem. Ignored on Vercel — VERCEL_URL
159
- * takes precedence there.
174
+ * VM doesn't have to probe the filesystem. Ignored on Vercel, where
175
+ * VERCEL_URL takes precedence.
160
176
  */
161
177
  port?: number;
162
178
  /**
@@ -170,7 +186,7 @@ export interface QuickJSRuntimeOptions {
170
186
  * Eval filename used when hydrating the baseline VM. The baseline is
171
187
  * shared by EVERY workflow in the bundle, so the filename baked into
172
188
  * its compiled code (and therefore into snapshot-path stack frames)
173
- * must be workflow-independent — hydrating under the first caller's
189
+ * must be workflow-independent: hydrating under the first caller's
174
190
  * workflowId would break `remapErrorStack`'s filename matching for
175
191
  * every other workflow in the bundle. Remap call sites match this
176
192
  * constant IN ADDITION to the run's module specifier (which covers
@@ -185,7 +201,7 @@ type BaselineEntry = {
185
201
  * bundle evaluated (see captureSerdeRoot). The box lives in the
186
202
  * snapshot's memory image at this offset; every restored VM
187
203
  * re-adopts it so serde initialization executes no guest code
188
- * after user code has run — capture-before-user-code semantics,
204
+ * after user code has run: capture-before-user-code semantics,
189
205
  * identical to the fresh path.
190
206
  */
191
207
  serdeRootPtr: number;
@@ -201,7 +217,7 @@ export declare function __peekBaselineEntryForTests(workflowCode: string): Promi
201
217
  * A live QuickJS workflow invocation. When the initial `result` is
202
218
  * `suspended`, the VM is kept alive so the caller can feed newly recorded
203
219
  * events (e.g. terminal events of inline-executed steps) into the SAME VM
204
- * via `continueWithEvents` — resuming execution exactly where it left off
220
+ * via `continueWithEvents`, resuming execution exactly where it left off
205
221
  * without a fresh-VM re-replay. Terminal results dispose the VM
206
222
  * automatically; `dispose()` must be called when abandoning a suspended
207
223
  * session (idempotent).
@@ -6,8 +6,8 @@
6
6
  * host code operating on `JSValueHandle`s, using devalue 5.9's pluggable
7
7
  * operations (quickjs-wasi's host-side introspection primitives underneath).
8
8
  * The serde bundle previously evaluated inside the VM is gone: guest values
9
- * are read and built through handles, so no serializer code lives in — or
10
- * can be tampered with from — the guest realm.
9
+ * are read and built through handles, so no serializer code lives in (or
10
+ * can be tampered with from) the guest realm.
11
11
  *
12
12
  * Side-effect discipline mirrors the node:vm engine's hardened codec
13
13
  * (serialization/hardened.ts):
@@ -17,7 +17,7 @@
17
17
  * `Symbol.toStringTag`;
18
18
  * - extraction goes through intrinsics captured at boot (before any user
19
19
  * code runs) invoked with explicit receivers, or through own-property
20
- * descriptor reads — patched prototypes and inherited accessors never
20
+ * descriptor reads, so patched prototypes and inherited accessors never
21
21
  * run;
22
22
  * - the only guest code serialization can execute is the same code the
23
23
  * previous in-VM codec executed by contract: a class's static
@@ -30,7 +30,7 @@
30
30
  * versa).
31
31
  *
32
32
  * Hybrid value space: reducers return host shapes (plain objects, strings,
33
- * numbers) whose leaves may be guest handles — exactly how the node:vm
33
+ * numbers) whose leaves may be guest handles, exactly how the node:vm
34
34
  * codec mixes host shapes with sandbox-realm leaves. Every stringify
35
35
  * operation therefore dispatches on `JSValueHandle` and falls back to
36
36
  * devalue's default host operations for host values. Parse operations
@@ -42,7 +42,7 @@ import { JSValueHandle, type QuickJS } from '../_quickjs-wasi.js';
42
42
  * bootstrap and BEFORE any user code. The returned handle owns the
43
43
  * container; on the baseline-snapshot path its raw box pointer
44
44
  * (`handle.ptr`) is recorded next to the snapshot and re-adopted per
45
- * restored VM via {@link adoptSerdeRoot} — do NOT dispose the handle
45
+ * restored VM via {@link adoptSerdeRoot}. Do NOT dispose the handle
46
46
  * before the snapshot is taken (the box must stay live in the memory
47
47
  * image).
48
48
  */
@@ -51,14 +51,14 @@ export declare function captureSerdeRoot(vm: QuickJS): JSValueHandle;
51
51
  * Re-create the capture-root handle in a VM restored from a snapshot
52
52
  * taken while the exported root was alive, via quickjs-wasi's
53
53
  * snapshot-portable handle tokens (`importHandle` duplicates the
54
- * underlying value — the returned handle is independently owned and the
54
+ * underlying value: the returned handle is independently owned and the
55
55
  * serde disposes it per restored VM). No guest code executes.
56
56
  */
57
57
  export declare function adoptSerdeRoot(vm: QuickJS, token: number): JSValueHandle;
58
58
  /**
59
59
  * Export the capture root as a snapshot-portable token to record next to
60
60
  * the baseline snapshot. The root handle must stay undisposed until the
61
- * snapshot is taken (its box — and the reference it holds — must be part
61
+ * snapshot is taken (its box, and the reference it holds, must be part
62
62
  * of the memory image).
63
63
  */
64
64
  export declare function exportSerdeRoot(vm: QuickJS, root: JSValueHandle): number;
@@ -70,7 +70,7 @@ export interface QuickJSSerde {
70
70
  /**
71
71
  * The reducer names this codec applies, in registration order. Exposed
72
72
  * so tests can assert exhaustiveness against the shared value-space
73
- * codec (codec-devalue-vm) — a reducer added there but not here would
73
+ * codec (codec-devalue-vm): a reducer added there but not here would
74
74
  * otherwise silently round-trip values as plain objects.
75
75
  */
76
76
  reducerKeys: readonly string[];
@@ -78,7 +78,7 @@ export interface QuickJSSerde {
78
78
  reviverKeys: readonly string[];
79
79
  /**
80
80
  * Install `globalThis.process = { env: Object.freeze({...}) }` in the
81
- * VM through handles and boot-captured intrinsics only — no guest
81
+ * VM through handles and boot-captured intrinsics only: no guest
82
82
  * source is evaluated, so a module-scope wrapper around JSON.parse /
83
83
  * Object.freeze cannot observe the injection. This matters on the
84
84
  * baseline-snapshot path, where env injection happens after user code
@@ -98,7 +98,7 @@ export declare function createQuickJSSerde(vm: QuickJS,
98
98
  * Pre-captured serde root (baseline-snapshot path): the container
99
99
  * `captureSerdeRoot` created BEFORE user code, re-adopted from the
100
100
  * restored memory image via `adoptSerdeRoot`. When omitted, the root
101
- * is captured now — callers must guarantee no user code has run yet.
101
+ * is captured now; callers must guarantee no user code has run yet.
102
102
  * Either way, initialization below performs only plain-data property
103
103
  * reads and C-level classId reads on the container: NO guest code
104
104
  * executes here, so nothing user-patchable can observe or perturb it.
@@ -4,7 +4,7 @@ import { type SlotSnapshotParams } from './helpers.js';
4
4
  * handler run: deterministic event-log replay, workflow-VM execution
5
5
  * between step boundaries, suspension handling, queue round-trips, etc.
6
6
  * Inline step bodies (`"use step"` functions invoked via `executeStep`)
7
- * are intentionally excluded — they are bounded by the platform's
7
+ * are intentionally excluded since they are bounded by the platform's
8
8
  * function `maxDuration` and the `NO_INLINE_REPLAY_AFTER_MS` early-return
9
9
  * guard.
10
10
  *
@@ -30,7 +30,7 @@ import { type SlotSnapshotParams } from './helpers.js';
30
30
  * This protects against double-counting in future refactors that nest
31
31
  * step execution or take an early-return path between a `pause()` and
32
32
  * the matching `resume()`.
33
- * - `isExhausted()` is checked at loop boundaries by the caller — the
33
+ * - `isExhausted()` is checked at loop boundaries by the caller; the
34
34
  * budget itself does not arm any timers. This means an in-flight
35
35
  * pathological `runWorkflow` call (e.g. a huge event-log replay) can
36
36
  * overshoot the budget by up to one iteration's worth of work before
@@ -54,13 +54,13 @@ export declare class ReplayBudget {
54
54
  */
55
55
  elapsed(): number;
56
56
  /**
57
- * Stop counting elapsed time toward the budget. Idempotent — safe to
57
+ * Stop counting elapsed time toward the budget. Idempotent: safe to
58
58
  * call multiple times in a row; subsequent calls are no-ops until
59
59
  * `resume()` reopens an interval.
60
60
  */
61
61
  pause(): void;
62
62
  /**
63
- * Resume counting elapsed time toward the budget. Idempotent — safe to
63
+ * Resume counting elapsed time toward the budget. Idempotent: safe to
64
64
  * call multiple times in a row; subsequent calls re-anchor the
65
65
  * interval start to `now()`, which is fine because no time accrues
66
66
  * between back-to-back `resume()` calls.
@@ -17,7 +17,7 @@ export declare class ReplayRecoveryReporter {
17
17
  * it, so `withEventCreate` always passes writes through untouched. Lets every
18
18
  * call site hold a non-optional reporter instead of branching on one.
19
19
  *
20
- * Structurally inert rather than a zero-count reporter on purpose — the
20
+ * Structurally inert rather than a zero-count reporter on purpose: the
21
21
  * server rejects a count below 1 as out-of-range and emits a
22
22
  * `telemetry_rejected` metric, so a reporter that *can* report zero is a
23
23
  * live footgun.
@@ -15,18 +15,10 @@ export declare function getHookByToken(token: string): Promise<Hook>;
15
15
  * The result of {@link resumeHook}: a {@link Hook} augmented with an optional
16
16
  * resilience signal.
17
17
  *
18
- * On the parallel fast path, `resumeHook()` writes the `hook_received` event and
19
- * dispatches the workflow queue message concurrently. When the direct event
20
- * write fails *transiently* — a 429/5xx, a transport error, or an expected
21
- * `(runId, resumeId)` conflict with its own re-ensuring consumer — but the queue
22
- * dispatch succeeds, the resume is still guaranteed: the queue consumer
23
- * idempotently materializes the `hook_received` event from the payload carried
24
- * on the message before replay. In that recovered case the returned hook carries
25
- * `resilientResume: true`.
26
- *
27
- * On the happy path (the direct write landed) and on the sequential fallback
28
- * path, the flag is absent (`undefined`). Callers that don't care about the
29
- * distinction can treat the result as a plain {@link Hook}.
18
+ * `resilientResume` is retained for source compatibility and is never set.
19
+ * `resumeHook()` now requires the durable `hook_received` write and workflow
20
+ * wake to both succeed before it resolves. Treat the result as a plain
21
+ * {@link Hook}.
30
22
  */
31
23
  export type ResumedHook = Hook & {
32
24
  resilientResume?: boolean;
@@ -37,6 +29,22 @@ export type ResumedHook = Hook & {
37
29
  * This function is called externally (e.g., from an API route or server action)
38
30
  * to send data to a hook and resume the associated workflow run.
39
31
  *
32
+ * Resolving means BOTH that the `hook_received` event is durably recorded in
33
+ * the run's event log and that the workflow wake was accepted by the queue, in
34
+ * that order. A {@link HookNotFoundError} means this invocation committed no
35
+ * event. Any other error after the write is ambiguous only in dispatch, never
36
+ * in durability: the event may already be committed, and a later wake of the
37
+ * run (from any source) will deliver it.
38
+ *
39
+ * Prefer passing the token string over a cached {@link Hook} object. A token
40
+ * is looked up fresh, so the live backend can attest its atomic resume claim
41
+ * and the durable write becomes idempotent-on-retry (transport retries of the
42
+ * same write converge on one event). A supplied Hook object may carry a stale
43
+ * attestation, so it is deliberately ignored and the write is claim-less —
44
+ * meaning a lost response cannot be retried safely: retrying at the
45
+ * application level mints a fresh claim and can commit a second
46
+ * `hook_received`.
47
+ *
40
48
  * @param tokenOrHook - The unique token identifying the hook, or the hook object itself
41
49
  * @param payload - The data payload to send to the hook
42
50
  * @returns Promise resolving to the {@link ResumedHook}
@@ -6,46 +6,53 @@ import type { HookResumeTiming } from '#compiled/@workflow/world/index.js';
6
6
  *
7
7
  * ```text
8
8
  * T0 resumeHook() entered
9
- * producer_prep — hook lookup, serialization, encryption
9
+ * producer_prep : hook lookup, serialization, encryption
10
10
  * T1 queue publish requested
11
- * queue_delivery — network + VQS delivery (incl. any affinity re-route)
11
+ * queue_delivery : network + VQS delivery (incl. any affinity re-route)
12
12
  * T2 final consumer's queue handler entered
13
- * resume_setup — affinity check, hook_received re-ensure, replay preload
13
+ * resume_setup : affinity check, hook_received re-ensure, replay preload
14
14
  * T3 replay begins
15
- * replay — VM/session creation and workflow replay
15
+ * replay : VM/session creation and workflow replay
16
16
  * T4 next durable step encountered
17
- * step_dispatch — suspension handling, inline batch or queue dispatch
17
+ * step_dispatch : suspension handling, inline batch or queue dispatch
18
18
  * T5 step_started request begins
19
- * step_claim — the claim round trip
19
+ * step_claim : the claim round trip
20
20
  * T6 step_started response returned
21
- * step_prepare — key resolution, argument hydration, context setup
21
+ * step_prepare : key resolution, argument hydration, context setup
22
22
  * T7 immediately before stepFn.apply()
23
23
  * ```
24
24
  *
25
- * The producer's direct `hook_received` POST races the queue publish on the
26
- * parallel fast path, so it deliberately has no phase of its own — the two
27
- * overlap, and representing both as additive phases would double-count. It
28
- * remains visible as a contextual span (`hook.resume`).
25
+ * The producer's `hook_received` write is awaited inside `producer_prep`
26
+ * (the wake is only published after it commits). Older producers may report
27
+ * `lazy`, where the consumer materializes the event from `hookInput`, or
28
+ * `parallel`, where the write raced the publish. The write has no phase of
29
+ * its own; it remains visible as a contextual span (`hook.resume`).
29
30
  *
30
31
  * T0/T1 are stamped on the producer's machine and T2..T7 on the consumer's, so
31
32
  * the measurement is subject to cross-machine clock skew. Rather than clamp
32
33
  * (which would break the sum-equals-total property this decomposition exists
33
- * for), a non-monotonic boundary set drops the whole sample — see
34
+ * for), a non-monotonic boundary set drops the whole sample; see
34
35
  * {@link computeResumeTtrAttributes}.
35
36
  */
36
37
  /** What caused the resumption being measured. Only hooks are measured today. */
37
38
  export type ResumeTrigger = 'hook';
38
- /** Which `resumeHook()` dispatch path produced this resume. */
39
- export type ResumeStrategy = 'parallel' | 'sequential';
39
+ /**
40
+ * Which `resumeHook()` dispatch path produced this resume.
41
+ *
42
+ * Current producers always send `sequential` (durable write, then wake).
43
+ * Older producers may send `lazy` (the consumer materializes the event from
44
+ * `hookInput`) or `parallel` (the write raced the publish).
45
+ */
46
+ export type ResumeStrategy = 'lazy' | 'parallel' | 'sequential';
40
47
  /**
41
48
  * How the consuming invocation initialized its replay state:
42
49
  *
43
- * - `hook_preload` — the hoisted `hook_received` write returned a usable
50
+ * - `hook_preload`: the hoisted `hook_received` write returned a usable
44
51
  * replay preload, so neither `run_started` nor the initial `events.list` ran.
45
- * - `run_started` — the generic `run_started` setup ran (including the fast
52
+ * - `run_started`: the generic `run_started` setup ran (including the fast
46
53
  * path's fallback, where the hoisted write succeeded but returned no usable
47
54
  * preload).
48
- * - `event_load` — neither setup ran because the run arrived already loaded,
55
+ * - `event_load`: neither setup ran because the run arrived already loaded,
49
56
  * so setup was a plain event load. No current path produces it (the one
50
57
  * preloaded-run path, the background-step fall-through, consumes the
51
58
  * tracking on its own step first); it is the honest default rather than a
@@ -62,7 +69,7 @@ export type ResumeStepExecution = 'inline' | 'dispatched';
62
69
  *
63
70
  * The runtime holds at most one of these per invocation and CONSUMES it when
64
71
  * it hands it to the execution that will attempt the next durable step, so a
65
- * later step in the same invocation — or a retry of the same step — never
72
+ * later step in the same invocation (or a retry of the same step) never
66
73
  * re-reports the same resumption. Within one inline batch the object is
67
74
  * shared by every step and the {@link ResumeTtrTracking.reported} latch picks
68
75
  * the single reporter.
@@ -71,19 +78,19 @@ export interface ResumeTtrTracking {
71
78
  trigger: ResumeTrigger;
72
79
  /** Absent only if an older producer omitted it from the queue message. */
73
80
  strategy?: ResumeStrategy;
74
- /** T0 — entry into `resumeHook()`. */
81
+ /** T0: entry into `resumeHook()`. */
75
82
  resumeRequestedAtMs: number;
76
- /** T1 — immediately before the queue publish was requested. */
83
+ /** T1: immediately before the queue publish was requested. */
77
84
  queuePublishRequestedAtMs: number;
78
85
  /**
79
- * T2 — entry into the FINAL consumer's queue handler. A delivery that
86
+ * T2: entry into the FINAL consumer's queue handler. A delivery that
80
87
  * re-routes for deployment affinity never stamps this, so the re-routed hop
81
88
  * stays inside `queue_delivery` where it belongs.
82
89
  */
83
90
  consumerStartedAtMs: number;
84
- /** T3 — this invocation's first replay pass. */
91
+ /** T3: this invocation's first replay pass. */
85
92
  replayStartedAtMs?: number;
86
- /** T4 — replay first encountered a durable step after the resume. */
93
+ /** T4: replay first encountered a durable step after the resume. */
87
94
  nextStepEncounteredAtMs?: number;
88
95
  setupSource?: ResumeSetupSource;
89
96
  stepExecution: ResumeStepExecution;
@@ -91,7 +98,7 @@ export interface ResumeTtrTracking {
91
98
  * One-shot latch, set by the step executor once this resumption has been
92
99
  * reported. Every step of an inline batch is handed the SAME tracking
93
100
  * object, so the first one to reach user code takes the measurement and the
94
- * rest see this and skip — one resumption, one sample, without pinning the
101
+ * rest see this and skip: one resumption, one sample, without pinning the
95
102
  * sample to a step that may lose its create-claim and never run.
96
103
  *
97
104
  * Deliberately not part of {@link HookResumeTiming}: it is invocation-local
@@ -101,8 +108,8 @@ export interface ResumeTtrTracking {
101
108
  }
102
109
  /**
103
110
  * Rebuild tracking from a queue message's timing object. Returns undefined for
104
- * a message that carries none (an older producer, or any non-hook delivery) —
105
- * the caller then simply reports no TTR.
111
+ * a message that carries none (an older producer, or any non-hook delivery);
112
+ * the caller then reports no TTR.
106
113
  */
107
114
  export declare function resumeTrackingFromMessage(timing: HookResumeTiming | undefined, stepExecution: ResumeStepExecution): ResumeTtrTracking | undefined;
108
115
  /**
@@ -114,7 +121,7 @@ export declare function resumeTrackingFromMessage(timing: HookResumeTiming | und
114
121
  export declare function resumeTimingForMessage(tracking: ResumeTtrTracking | undefined): HookResumeTiming | undefined;
115
122
  /**
116
123
  * Compute the TTR span attributes for a step that is the first durable step
117
- * following a hook resume. Returns undefined — emitting nothing at all — when
124
+ * following a hook resume. Returns undefined (emitting nothing at all) when
118
125
  * any of these hold:
119
126
  *
120
127
  * - the invocation carries no resume tracking (not a hook resume, or an older
@@ -133,11 +140,11 @@ export declare function computeResumeTtrAttributes(params: {
133
140
  tracking: ResumeTtrTracking | undefined;
134
141
  /** The attempt number of the execution about to run. */
135
142
  attempt: number;
136
- /** T5 — `Date.now()` immediately before the `step_started` request. */
143
+ /** T5: `Date.now()` immediately before the `step_started` request. */
137
144
  stepClaimStartedAtMs: number | undefined;
138
- /** T6 — `Date.now()` once the `step_started` response returned. */
145
+ /** T6: `Date.now()` once the `step_started` response returned. */
139
146
  stepClaimCompletedAtMs: number | undefined;
140
- /** T7 — `Date.now()` immediately before `stepFn.apply()`. */
147
+ /** T7: `Date.now()` immediately before `stepFn.apply()`. */
141
148
  stepCodeStartedAtMs: number;
142
149
  }): Record<string, string | number> | undefined;
143
150
  //# sourceMappingURL=resume-latency.d.ts.map
@@ -5,8 +5,8 @@
5
5
  * `@workflow/world-vercel`'s region-tagged run IDs mark an ID as carrying
6
6
  * metadata by setting the most-significant bit of the ULID's 48-bit
7
7
  * timestamp, which would otherwise skew the decoded time past the year 6400.
8
- * The tag-bit handling is delegated to the scheme's own codec —
9
- * `decode()` returns the ULID with the tag bit cleared — so if the tagged
8
+ * The tag-bit handling is delegated to the scheme's own codec
9
+ * (`decode()` returns the ULID with the tag bit cleared), so if the tagged
10
10
  * layout ever evolves (the scheme carries a 5-bit version field for exactly
11
11
  * that), this anchor keeps tracking the codec instead of silently diverging.
12
12
  * For untagged input `decode()` is a passthrough.
@@ -1,8 +1,25 @@
1
1
  import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from '../_workflow-serde.js';
2
- import { type WorkflowRunStatus } from '#compiled/@workflow/world/index.js';
2
+ import type { WorkflowRunStatus } from '#compiled/@workflow/world/index.js';
3
3
  import { type CancelRunOptions, type StopSleepOptions, type StopSleepResult } from './runs.js';
4
4
  /** @internal */
5
5
  export declare function getReturnValuePollIntervalMs(): number;
6
+ /** @internal */
7
+ export declare function getReturnValueWaitTimeoutMs(): number;
8
+ /** @internal */
9
+ export declare function getReturnValueMaxLongPolls(): number;
10
+ /**
11
+ * Whether `await run.returnValue` may use the World's long poll
12
+ * (`runs.waitForTerminalStatus`) instead of interval-polling `runs.get`.
13
+ *
14
+ * Default **ON** wherever the World implements the method; a World that does
15
+ * not is already on the interval path with nothing to switch off. Reads
16
+ * `process.env.WORKFLOW_RETURN_VALUE_LONG_POLL` lazily; an explicit `'0'` /
17
+ * `'false'` is the kill switch, restoring the fixed-interval poll exactly as
18
+ * it behaved before the fast path existed.
19
+ *
20
+ * @internal
21
+ */
22
+ export declare function isReturnValueLongPollEnabled(): boolean;
6
23
  /**
7
24
  * A `ReadableStream` extended with workflow-specific helpers.
8
25
  */
@@ -10,7 +27,7 @@ export type WorkflowReadableStream<R = any> = ReadableStream<R> & {
10
27
  /**
11
28
  * Returns the tail index (index of the last known chunk, 0-based) of the
12
29
  * underlying workflow stream. Useful for resolving a negative `startIndex`
13
- * into an absolute position — for example, when building reconnection
30
+ * into an absolute position, for example, when building reconnection
14
31
  * endpoints that need to inform the client where the stream starts.
15
32
  *
16
33
  * Returns `-1` when no chunks have been written yet.
@@ -32,8 +49,8 @@ export interface WorkflowReadableStreamOptions {
32
49
  */
33
50
  startIndex?: number;
34
51
  /**
35
- * Any asynchronous operations that need to be performed before the execution
36
- * environment is paused / terminated
52
+ * Any asynchronous operations to complete before pausing or terminating the
53
+ * execution environment
37
54
  * (i.e. using [`waitUntil()`](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) or similar).
38
55
  */
39
56
  ops?: Promise<any>[];
@@ -90,7 +107,7 @@ export declare class Run<TResult> {
90
107
  get status(): Promise<WorkflowRunStatus>;
91
108
  /**
92
109
  * The return value of the workflow run.
93
- * Polls the workflow return value until it is completed.
110
+ * Polls the workflow return value until the workflow run completes.
94
111
  */
95
112
  get returnValue(): Promise<TResult>;
96
113
  /**
@@ -6,9 +6,9 @@ export interface RecreateRunOptions {
6
6
  * Queue namespace of the target deployment (e.g. `'eve'` for topics like
7
7
  * `__eve_wkf_workflow_*`). Falls back to `WORKFLOW_QUEUE_NAMESPACE` in
8
8
  * the calling process. Cross-context callers (e.g. the observability
9
- * dashboard) must pass the target deployment's namespace explicitly —
10
- * a run enqueued to a topic the target deployment has no consumer for
11
- * is never picked up.
9
+ * dashboard) must pass the target deployment's namespace explicitly,
10
+ * since a run enqueued to a topic the target deployment has no consumer
11
+ * for is never picked up.
12
12
  */
13
13
  namespace?: string;
14
14
  }
@@ -75,7 +75,7 @@ export declare function cancelRun(world: World, runId: string, options?: CancelR
75
75
  * `cancelRun()` calls with at most {@link CANCEL_RUNS_FALLBACK_CONCURRENCY}
76
76
  * in flight at a time. Fallback successes are reported as `cancelled`;
77
77
  * failures are reported as `failed` with `code: 'internal_error'` and
78
- * `retryable: true` — deliberately without per-world error classification.
78
+ * `retryable: true`, deliberately without per-world error classification.
79
79
  *
80
80
  * @throws if `runIds` is empty, contains duplicates, or exceeds
81
81
  * {@link BULK_CANCEL_MAX_RUN_IDS}.
@@ -1,7 +1,7 @@
1
1
  import type { World } from '#compiled/@workflow/world/index.js';
2
2
  import { Run } from './run.js';
3
3
  /**
4
- * Reset the `deploymentId: 'latest'` no-op warn-once guard. Test-only —
4
+ * Reset the `deploymentId: 'latest'` no-op warn-once guard. Test-only,
5
5
  * exported so unit tests can exercise the warn path across `start()` calls.
6
6
  *
7
7
  * @internal
@@ -23,7 +23,7 @@ export interface StartOptionsBase {
23
23
  * run ID and routes the initial workflow message to the matching
24
24
  * regional queue. When omitted, the world falls back to its own
25
25
  * default (for `world-vercel`: the `VERCEL_REGION` environment
26
- * variable, then the server-side default region `iad1` — a concrete,
26
+ * variable, then the server-side default region `iad1`; a concrete,
27
27
  * routable region is always chosen).
28
28
  *
29
29
  * Worlds without a regional dimension ignore this field.
@@ -89,7 +89,7 @@ export interface StartOptionsWithDeploymentId extends StartOptionsBase {
89
89
  * This is only meaningful in worlds with atomic, immutable deployments
90
90
  * (currently Vercel). In other worlds (local dev, Postgres) there is no
91
91
  * notion of multiple deployments to resolve between, so `'latest'` has no
92
- * effect — a warning is logged and the run targets the current deployment.
92
+ * effect: a warning is logged and the run targets the current deployment.
93
93
  *
94
94
  * **Note:** When `deploymentId` is provided, the argument and return types become `unknown`
95
95
  * since there is no guarantee the types will be consistent across deployments.