eve 0.70.0 → 0.70.2

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 (216) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/src/channel/adapter.js +1 -1
  3. package/dist/src/channel/channel-operations.js +1 -1
  4. package/dist/src/channel/resolve-text.d.ts +8 -0
  5. package/dist/src/channel/resolve-text.js +2 -1
  6. package/dist/src/cli/banner.d.ts +2 -2
  7. package/dist/src/cli/banner.js +1 -1
  8. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  9. package/dist/src/cli/commands/init.js +1 -1
  10. package/dist/src/cli/dev/tui/prompt-commands.d.ts +7 -7
  11. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  12. package/dist/src/cli/dev/tui/runner.d.ts +4 -3
  13. package/dist/src/cli/dev/tui/runner.js +2 -2
  14. package/dist/src/cli/dev/tui/task-activity.d.ts +0 -17
  15. package/dist/src/cli/dev/tui/task-activity.js +1 -1
  16. package/dist/src/cli/dev/tui/task-records.d.ts +17 -0
  17. package/dist/src/cli/dev/tui/task-records.js +1 -0
  18. package/dist/src/cli/dev/tui/terminal-renderer.js +2 -2
  19. package/dist/src/cli/dev/tui/test/mock-terminal.d.ts +7 -1
  20. package/dist/src/cli/dev/tui/test/mock-terminal.js +4 -3
  21. package/dist/src/cli/dev/tui/theme.d.ts +1 -1
  22. package/dist/src/cli/dev/tui/theme.js +1 -1
  23. package/dist/src/cli/dev/tui/tool-presentation.d.ts +15 -2
  24. package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
  25. package/dist/src/cli/dev/tui/transcript-parts.d.ts +10 -2
  26. package/dist/src/cli/dev/tui/transcript-parts.js +2 -2
  27. package/dist/src/cli/dev/tui/transcript.js +1 -1
  28. package/dist/src/compiled/.vendor-stamp.json +8 -8
  29. package/dist/src/compiled/@photon-ai/chat-adapter-imessage/index.js +1 -1
  30. package/dist/src/compiled/@vercel/sandbox/index.js +1 -1
  31. package/dist/src/compiled/@workflow/core/index.js +2 -2
  32. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +15 -0
  33. package/dist/src/compiled/@workflow/core/runtime/dynamic-workflow.d.ts +182 -0
  34. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +7 -0
  35. package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
  36. package/dist/src/compiled/@workflow/core/runtime/quickjs-assets.generated.d.ts +7 -0
  37. package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +2 -30
  38. package/dist/src/compiled/@workflow/core/runtime/quickjs-log-view.d.ts +27 -4
  39. package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +55 -3
  40. package/dist/src/compiled/@workflow/core/runtime/quickjs-snapshot-codec.d.ts +74 -0
  41. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +4 -0
  42. package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +44 -0
  43. package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
  44. package/dist/src/compiled/@workflow/core/runtime.js +4 -4
  45. package/dist/src/compiled/@workflow/core/schemas.d.ts +1 -1
  46. package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +27 -2
  47. package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +8 -0
  48. package/dist/src/compiled/@workflow/core/serialization/types.d.ts +1 -0
  49. package/dist/src/compiled/@workflow/core/serialization.d.ts +48 -0
  50. package/dist/src/compiled/@workflow/core/serialization.js +1 -1
  51. package/dist/src/compiled/@workflow/core/set-error-stack.d.ts +12 -0
  52. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +47 -0
  53. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  54. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  55. package/dist/src/compiled/@workflow/world/events.d.ts +10 -0
  56. package/dist/src/compiled/@workflow/world/index.d.ts +2 -0
  57. package/dist/src/compiled/@workflow/world/interfaces.d.ts +127 -0
  58. package/dist/src/compiled/@workflow/world/queue.d.ts +6 -0
  59. package/dist/src/compiled/@workflow/world/runs.d.ts +9 -2
  60. package/dist/src/compiled/@workflow/world/snapshots.d.ts +60 -0
  61. package/dist/src/compiled/@workflow/world-local/index.js +5 -5
  62. package/dist/src/compiled/@workflow/world-vercel/index.js +19 -17
  63. package/dist/src/compiled/_chunks/node/undici-B61sz6UT.js +95 -0
  64. package/dist/src/compiled/_chunks/workflow/{attribute-changes-D721NpZv.js → attribute-changes-VaTKT4K8.js} +3 -3
  65. package/dist/src/compiled/_chunks/workflow/dist-B7NC1c9-.js +1 -0
  66. package/dist/src/compiled/_chunks/workflow/{functions-DpZiBxgQ.js → functions-CKkqf9V6.js} +1 -1
  67. package/dist/src/compiled/_chunks/workflow/helpers-CP9TjeO8.js +1 -0
  68. package/dist/src/compiled/_chunks/workflow/{logger-D4GJNTk4.js → logger-oqfblE3p.js} +2 -2
  69. package/dist/src/compiled/_chunks/workflow/resume-hook-yq-NAdBu.js +1 -0
  70. package/dist/src/compiled/_chunks/workflow/run-DYKeqbob.js +32 -0
  71. package/dist/src/compiled/_chunks/workflow/serialization-APSKphN5.js +3 -0
  72. package/dist/src/compiled/_chunks/workflow/signal-exit-iIdjQcCK.js +95 -0
  73. package/dist/src/compiled/_chunks/workflow/sleep-Ba8SExMt.js +1 -0
  74. package/dist/src/compiled/_chunks/workflow/{token-BhlnqoHM.js → token-BKeK6DmC.js} +1 -1
  75. package/dist/src/compiled/_chunks/workflow/token-Cv2GYj9A.js +1 -0
  76. package/dist/src/compiled/_chunks/workflow/{token-util-DaeRTzDa.js → token-util-CddTZ_ef.js} +1 -1
  77. package/dist/src/compiled/_chunks/workflow/{wait-until-3_1djUuL.js → wait-until-Dc9s3yyP.js} +1 -1
  78. package/dist/src/compiled/_chunks/workflow/{wrapper-CzrF_dmI.js → wrapper-Dq4OeGmJ.js} +4 -4
  79. package/dist/src/compiled/{gray-matter → js-yaml}/LICENSE +2 -2
  80. package/dist/src/compiled/js-yaml/index.d.ts +12 -0
  81. package/dist/src/compiled/js-yaml/index.js +34 -0
  82. package/dist/src/compiled/shadcn-registry/index.js +4 -4
  83. package/dist/src/context/serialize.d.ts +5 -1
  84. package/dist/src/context/serialize.js +1 -1
  85. package/dist/src/discover/discover-agent.js +1 -1
  86. package/dist/src/discover/extension-specifier.d.ts +1 -0
  87. package/dist/src/discover/extension-specifier.js +1 -1
  88. package/dist/src/discover/extensions.d.ts +1 -1
  89. package/dist/src/discover/extensions.js +1 -1
  90. package/dist/src/discover/project-source.d.ts +5 -0
  91. package/dist/src/discover/project-source.js +1 -1
  92. package/dist/src/evals/loaders/yaml.js +1 -1
  93. package/dist/src/evals/session.d.ts +1 -0
  94. package/dist/src/evals/session.js +1 -1
  95. package/dist/src/evals/types.d.ts +6 -0
  96. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  97. package/dist/src/execution/legacy-remote-agent/protocol.d.ts +8 -0
  98. package/dist/src/execution/legacy-remote-agent/protocol.js +1 -1
  99. package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
  100. package/dist/src/execution/proxied-deliver-step.d.ts +11 -0
  101. package/dist/src/execution/proxied-deliver-step.js +1 -1
  102. package/dist/src/execution/sandbox/read-file.d.ts +8 -1
  103. package/dist/src/execution/sandbox/read-file.js +3 -3
  104. package/dist/src/execution/session/active-turn.d.ts +4 -1
  105. package/dist/src/execution/session/active-turn.js +1 -1
  106. package/dist/src/execution/session/checkpoint-migrations.d.ts +23 -0
  107. package/dist/src/execution/session/checkpoint-migrations.js +1 -0
  108. package/dist/src/execution/session/entry-input.d.ts +23 -5
  109. package/dist/src/execution/session/entry.js +1 -1
  110. package/dist/src/execution/session/finalization.js +1 -1
  111. package/dist/src/execution/session/handoff-steps.d.ts +24 -5
  112. package/dist/src/execution/session/handoff-steps.js +1 -1
  113. package/dist/src/execution/session/handoff.d.ts +40 -16
  114. package/dist/src/execution/session/handoff.js +1 -1
  115. package/dist/src/execution/session/pending-turn-state.d.ts +2 -0
  116. package/dist/src/execution/session/pending-turn-state.js +1 -1
  117. package/dist/src/execution/session/program.d.ts +16 -3
  118. package/dist/src/execution/session/program.js +1 -1
  119. package/dist/src/execution/session/turn-step-result.js +1 -1
  120. package/dist/src/execution/session/turn-step-types.d.ts +13 -1
  121. package/dist/src/execution/session/turn-step.js +1 -1
  122. package/dist/src/execution/session/turn.d.ts +14 -2
  123. package/dist/src/execution/session/turn.js +1 -1
  124. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  125. package/dist/src/execution/workflow-runtime.d.ts +4 -4
  126. package/dist/src/execution/workflow-runtime.js +1 -1
  127. package/dist/src/harness/attachment-staging.d.ts +27 -7
  128. package/dist/src/harness/attachment-staging.js +1 -1
  129. package/dist/src/harness/compaction-prompt.js +2 -2
  130. package/dist/src/harness/input-requests.js +1 -1
  131. package/dist/src/harness/messages.js +1 -1
  132. package/dist/src/harness/token-estimate.d.ts +5 -3
  133. package/dist/src/harness/token-estimate.js +1 -1
  134. package/dist/src/harness/tool-loop.js +2 -2
  135. package/dist/src/internal/application/package.js +1 -1
  136. package/dist/src/internal/attachments/media-metadata.d.ts +25 -0
  137. package/dist/src/internal/attachments/media-metadata.js +1 -0
  138. package/dist/src/internal/attachments/sandbox-refs.d.ts +12 -7
  139. package/dist/src/internal/attachments/sandbox-refs.js +1 -1
  140. package/dist/src/internal/authored-module-loader.js +1 -1
  141. package/dist/src/internal/bundler/extension-mount-plugin.d.ts +4 -0
  142. package/dist/src/internal/bundler/extension-mount-plugin.js +1 -1
  143. package/dist/src/internal/bundler/extension-scope-plugin.js +2 -2
  144. package/dist/src/internal/helpers/frontmatter.d.ts +24 -0
  145. package/dist/src/internal/helpers/frontmatter.js +1 -0
  146. package/dist/src/internal/helpers/markdown.js +1 -3
  147. package/dist/src/internal/input-text.d.ts +12 -0
  148. package/dist/src/internal/input-text.js +1 -0
  149. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  150. package/dist/src/internal/nitro/host/nitro-bundler-config.js +1 -1
  151. package/dist/src/internal/node-esm-compat-banner.js +1 -1
  152. package/dist/src/internal/workflow/vercel-world-defaults.d.ts +1 -1
  153. package/dist/src/internal/workflow/vercel-world-defaults.js +1 -1
  154. package/dist/src/public/channels/chat-sdk/input-actions.d.ts +8 -2
  155. package/dist/src/public/channels/chat-sdk/input-actions.js +4 -1
  156. package/dist/src/public/channels/github/defaults.js +2 -3
  157. package/dist/src/public/channels/linear/hitl.js +2 -3
  158. package/dist/src/public/channels/slack/action-status.d.ts +10 -5
  159. package/dist/src/public/channels/slack/action-status.js +1 -1
  160. package/dist/src/public/channels/slack/defaults.js +3 -3
  161. package/dist/src/public/channels/slack/limits.d.ts +1 -1
  162. package/dist/src/public/channels/slack/limits.js +1 -1
  163. package/dist/src/public/channels/slack/slackChannel.d.ts +11 -9
  164. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  165. package/dist/src/public/channels/slack/task-card.js +1 -1
  166. package/dist/src/public/channels/slack/thread-status.d.ts +33 -0
  167. package/dist/src/public/channels/slack/thread-status.js +1 -0
  168. package/dist/src/public/channels/twilio/defaults.js +4 -2
  169. package/dist/src/public/definitions/state.d.ts +2 -0
  170. package/dist/src/public/definitions/state.js +1 -1
  171. package/dist/src/runtime/connections/openapi-spec.d.ts +1 -4
  172. package/dist/src/runtime/connections/openapi-spec.js +1 -1
  173. package/dist/src/setup/scaffold/create/project.js +1 -1
  174. package/dist/src/setup/scaffold/create/web-template.d.ts +4 -4
  175. package/dist/src/setup/scaffold/create/web-template.js +33 -26
  176. package/dist/src/subagents/callback-route.js +1 -1
  177. package/dist/src/subagents/hitl-proxy.d.ts +2 -2
  178. package/dist/src/subagents/hitl-proxy.js +1 -1
  179. package/dist/src/subagents/parent-notification.d.ts +7 -7
  180. package/dist/src/subagents/parent-notification.js +1 -1
  181. package/dist/src/tools/provided/ask-question-workflow.js +1 -1
  182. package/dist/src/tools/provided/read-file.d.ts +7 -0
  183. package/dist/src/tools/provided/read-file.js +2 -2
  184. package/dist/src/tools/provided/sleep-workflow.js +1 -1
  185. package/docs/agent-config.md +2 -2
  186. package/docs/channels/chat-sdk.mdx +1 -1
  187. package/docs/channels/slack.mdx +21 -15
  188. package/docs/channels/twilio.mdx +1 -1
  189. package/docs/concepts/built-in-tools.md +1 -1
  190. package/docs/concepts/default-harness.md +4 -0
  191. package/docs/concepts/execution-model-and-durability.mdx +9 -1
  192. package/docs/concepts/sessions-runs-and-streaming.md +3 -3
  193. package/docs/evals/cases.mdx +1 -0
  194. package/docs/extensions.md +6 -3
  195. package/docs/guides/dev-tui.md +5 -3
  196. package/docs/guides/dynamic-capabilities.md +1 -1
  197. package/docs/sandbox/index.mdx +11 -0
  198. package/docs/tools/overview.mdx +4 -2
  199. package/package.json +8 -8
  200. package/dist/src/compiled/_chunks/node/undici-h5GH4RBM.js +0 -95
  201. package/dist/src/compiled/_chunks/workflow/debug-log-CVPstO1D.js +0 -1
  202. package/dist/src/compiled/_chunks/workflow/dist-BUFGAKRb.js +0 -1
  203. package/dist/src/compiled/_chunks/workflow/frames-Dr9fHWdo.js +0 -3
  204. package/dist/src/compiled/_chunks/workflow/helpers-DkKxg_yn.js +0 -1
  205. package/dist/src/compiled/_chunks/workflow/resume-hook-uTW-jBYz.js +0 -1
  206. package/dist/src/compiled/_chunks/workflow/run-5DmiMN9b.js +0 -1
  207. package/dist/src/compiled/_chunks/workflow/serialization-CNIYl1D3.js +0 -3
  208. package/dist/src/compiled/_chunks/workflow/signal-exit-DZKTacNU.js +0 -95
  209. package/dist/src/compiled/_chunks/workflow/sleep-DFKgN7UG.js +0 -1
  210. package/dist/src/compiled/_chunks/workflow/token-1wSBbi5N.js +0 -1
  211. package/dist/src/compiled/_chunks/workflow/token-util-Cm4Ec1Bg.js +0 -1
  212. package/dist/src/compiled/_chunks/workflow/ws-transport--rYOVIaf.js +0 -1
  213. package/dist/src/compiled/gray-matter/index.d.ts +0 -62
  214. package/dist/src/compiled/gray-matter/index.js +0 -48
  215. package/dist/src/internal/helpers/gray-matter.d.ts +0 -25
  216. package/dist/src/internal/helpers/gray-matter.js +0 -1
@@ -29,7 +29,7 @@
29
29
  * `node:vm` engine's replay determinism.
30
30
  */
31
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
+ import { type Event, type RunInput, type SnapshotMetadata, type WorkflowRun, type WorldCapabilities } from '#compiled/@workflow/world/index.js';
33
33
  import { type AttributeChange } from '#compiled/@workflow/world/index.js';
34
34
  import { type Snapshot } from '../_quickjs-wasi.js';
35
35
  import type { DecryptionKey } from '../serialization/encryption.js';
@@ -165,10 +165,26 @@ export interface QuickJSRuntimeOptions {
165
165
  /** Features supported by the World executing this workflow. */
166
166
  worldCapabilities?: WorldCapabilities;
167
167
  /**
168
- * The full event log for the run. Every invocation replays the complete
169
- * log from the start (same replay semantics as the `node:vm` engine).
168
+ * The event log to process. Without a snapshot this is the FULL log and
169
+ * every invocation replays it from the start (same replay semantics as
170
+ * the `node:vm` engine). With `existingSnapshot`, this is the delta of
171
+ * events recorded at/after the snapshot's `eventsCursor` — feeding
172
+ * already-consumed events is harmless (consumed resolvers are gone and
173
+ * hook deliveries are deduped in the VM heap), so an imprecise cursor
174
+ * only costs redundant scanning.
170
175
  */
171
176
  events: Event[];
177
+ /**
178
+ * A previously persisted VM-memory snapshot to restore from, or
179
+ * null/undefined for a fresh boot + full replay. Restoring skips VM
180
+ * bootstrap, bundle evaluation, and pre-snapshot re-execution entirely:
181
+ * the WASM heap resumes at the exact suspension point it was captured
182
+ * at, and only `events` are processed on top.
183
+ */
184
+ existingSnapshot?: {
185
+ data: Uint8Array;
186
+ metadata: SnapshotMetadata;
187
+ } | null;
172
188
  /** Encryption key for decrypting event payloads (undefined if unencrypted) */
173
189
  encryptionKey?: DecryptionKey;
174
190
  /**
@@ -216,6 +232,18 @@ type BaselineEntry = {
216
232
  export declare function __clearBaselineSnapshotCacheForTests(): void;
217
233
  /** Test-only: observe how a bundle was classified. */
218
234
  export declare function __peekBaselineEntryForTests(workflowCode: string): Promise<BaselineEntry | undefined>;
235
+ /**
236
+ * Continue a monotonic ULID sequence from a persisted last value:
237
+ * re-implements the `ulid` package's same-timestamp step (Crockford
238
+ * base32 +1 on the 16-char random part, carrying left; the 10-char time
239
+ * prefix is preserved — the run's seed timestamp is constant, so the
240
+ * package would never re-encode it). Byte-for-byte equivalent to what
241
+ * `monotonicFactory` returns for the same draw position, which is what
242
+ * keeps correlation ids identical between a snapshot-restored invocation
243
+ * and a full replay. Exported for tests (equivalence is asserted against
244
+ * the package itself).
245
+ */
246
+ export declare function incrementUlidRandom(prev: string): string;
219
247
  /**
220
248
  * A live QuickJS workflow invocation. When the initial `result` is
221
249
  * `suspended`, the VM is kept alive so the caller can feed newly recorded
@@ -233,6 +261,30 @@ export interface QuickJSWorkflowSession {
233
261
  * Resets the VM's interrupt budget for the new execution burst.
234
262
  */
235
263
  continueWithEvents(newEvents: Event[]): Promise<QuickJSRuntimeResult>;
264
+ /**
265
+ * Capture and serialize the live VM's memory. Only valid while the
266
+ * last result was `suspended`. The returned bytes restore via
267
+ * `existingSnapshot` on a later invocation (pair them with the events
268
+ * cursor at capture time). `rngDraws` is the seeded PRNG's draw count
269
+ * at capture — persisted in the snapshot metadata so a restore
270
+ * fast-forwards the base seed to the same position. `lastUlid` is the
271
+ * monotonic correlation-id factory's last output (undefined if the
272
+ * run has drawn none) — persisted so a restore continues the exact
273
+ * ULID sequence instead of drawing fresh randomness. `serdeRootPtr`
274
+ * is the host-serde capture root's snapshot-portable token — the
275
+ * restore path re-adopts it so serde initialization executes no guest
276
+ * code after user code has run.
277
+ */
278
+ snapshot(): {
279
+ data: Uint8Array;
280
+ rngDraws: number;
281
+ lastUlid: string | undefined;
282
+ serdeRootPtr: number;
283
+ /** Deterministic clock high-water mark at capture (ms since epoch). */
284
+ clockMs: number;
285
+ /** Exact engine build (quickjs-wasi version) that captured the heap. */
286
+ engineVersion: string;
287
+ };
236
288
  /** Dispose the VM if it is still alive. Safe to call multiple times. */
237
289
  dispose(): void;
238
290
  }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Encoding of the per-run VM snapshots the QuickJS engine persists through
3
+ * `world.experimental_snapshots` (compress, then encrypt on save; the inverse
4
+ * on load), and the checks a stored snapshot must pass before its heap is
5
+ * handed to the engine.
6
+ *
7
+ * A snapshot is executable state: bytecode, closures and pending
8
+ * continuations that run with access to every host callback. So a load
9
+ * treats storage as untrusted input:
10
+ *
11
+ * - The restore-relevant metadata is sealed INSIDE the encrypted payload,
12
+ * bound to the run id, and must equal the metadata the World returned.
13
+ * With an encryption key that makes the pairing authenticated: bytes from
14
+ * one snapshot can't be combined with another's metadata (a wrong cursor
15
+ * silently replays from the wrong log position), and nothing
16
+ * restore-relevant can be edited in the plaintext envelope. Without a key
17
+ * the same check still catches torn or mismatched writes.
18
+ * - A run that has an encryption key only accepts encrypted snapshots, so a
19
+ * plaintext blob written to storage can't bypass encryption.
20
+ * - Decompression is capped, so a small compressed blob can't inflate
21
+ * without bound.
22
+ * - Numeric fields that drive host-side work before the VM exists (the PRNG
23
+ * fast-forward runs `rngDraws` synchronous draws) are bounded.
24
+ */
25
+ import type { SnapshotMetadata } from '#compiled/@workflow/world/index.js';
26
+ import { type RunPayloadKeys } from '../serialization/encryption.js';
27
+ /**
28
+ * Plaintext size ceiling for persisted VM snapshots. A heap beyond this
29
+ * costs more to store, encrypt and decompress than the replay it saves.
30
+ * Captures over it are not saved, and loads refuse to inflate past it.
31
+ */
32
+ export declare const MAX_SNAPSHOT_PLAINTEXT_BYTES: number;
33
+ /**
34
+ * Upper bound on `rngDraws` accepted from a stored snapshot. The restore
35
+ * fast-forwards the run's PRNG that many draws synchronously before the VM
36
+ * exists (about 70 ns per draw), so an unbounded value is a hang. A run that
37
+ * legitimately drew more than this restores by full replay instead.
38
+ */
39
+ export declare const MAX_SNAPSHOT_RNG_DRAWS = 10000000;
40
+ /** Why a stored snapshot was not restored. */
41
+ export type SnapshotRejectReason = 'unencrypted' | 'undecryptable' | 'too_large' | 'malformed' | 'metadata_mismatch' | 'out_of_bounds';
42
+ export declare class SnapshotRejectedError extends Error {
43
+ readonly reason: SnapshotRejectReason;
44
+ constructor(reason: SnapshotRejectReason, message: string);
45
+ }
46
+ /**
47
+ * Bounds on metadata values the runtime acts on before it can validate the
48
+ * heap itself. Checked on the World-supplied metadata before any decrypt or
49
+ * decompress work, so an out-of-range value costs nothing.
50
+ */
51
+ export declare function checkSnapshotMetadataBounds(metadata: SnapshotMetadata): string | undefined;
52
+ /**
53
+ * Encode a captured heap for storage: frame it with its sealed metadata,
54
+ * compress, then encrypt (ciphertext doesn't compress, so compression comes
55
+ * first). Returns the bytes to hand to `experimental_snapshots.save`.
56
+ */
57
+ export declare function sealSnapshot(params: {
58
+ runId: string;
59
+ heap: Uint8Array;
60
+ metadata: SnapshotMetadata;
61
+ encryptionKey: RunPayloadKeys | undefined;
62
+ }): Promise<Uint8Array>;
63
+ /**
64
+ * Decode stored snapshot bytes back to the heap image, enforcing every
65
+ * check in the module doc. Throws {@link SnapshotRejectedError}; the caller
66
+ * treats that as a miss and falls back to full replay.
67
+ */
68
+ export declare function openSnapshot(params: {
69
+ runId: string;
70
+ stored: Uint8Array;
71
+ metadata: SnapshotMetadata;
72
+ encryptionKey: RunPayloadKeys | undefined;
73
+ }): Promise<Uint8Array>;
74
+ //# sourceMappingURL=quickjs-snapshot-codec.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import type { RunRetention, World } from '#compiled/@workflow/world/index.js';
2
+ import { type DynamicStartOptions } from './dynamic-workflow.js';
2
3
  import { type HealthCheckResult } from './helpers.js';
3
4
  import { Run } from './run.js';
4
5
  /**
@@ -191,6 +192,7 @@ export interface StartOptionsWithoutDeploymentId extends StartOptionsBase {
191
192
  * Options for starting a workflow run.
192
193
  */
193
194
  export type StartOptions = StartOptionsWithDeploymentId | StartOptionsWithoutDeploymentId;
195
+ export type { DynamicStartOptions, DynamicWorkflowOptions, DynamicWorkflowStepReference, } from './dynamic-workflow.js';
194
196
  /**
195
197
  * Represents an imported workflow function.
196
198
  */
@@ -213,4 +215,6 @@ export declare function start<TArgs extends unknown[], TResult>(workflow: Workfl
213
215
  export declare function start<TResult>(workflow: WorkflowFunction<[], TResult> | WorkflowMetadata, options: StartOptionsWithDeploymentId): Promise<Run<unknown>>;
214
216
  export declare function start<TArgs extends unknown[], TResult>(workflow: WorkflowFunction<TArgs, TResult> | WorkflowMetadata, args: TArgs, options?: StartOptionsWithoutDeploymentId): Promise<Run<TResult>>;
215
217
  export declare function start<TResult>(workflow: WorkflowFunction<[], TResult> | WorkflowMetadata, options?: StartOptionsWithoutDeploymentId): Promise<Run<TResult>>;
218
+ export declare function start(source: string, args: unknown[], options: DynamicStartOptions): Promise<Run<unknown>>;
219
+ export declare function start(source: string, options: DynamicStartOptions): Promise<Run<unknown>>;
216
220
  //# sourceMappingURL=start.d.ts.map
@@ -41,4 +41,48 @@ export declare function getWorkflowVmFromEnv(env?: NodeJS.ProcessEnv): WorkflowV
41
41
  * unknown value.
42
42
  */
43
43
  export declare function useQuickJSVm(workflowRun: Pick<WorkflowRun, 'executionContext'>): boolean;
44
+ /**
45
+ * Read and validate the `WORKFLOW_SNAPSHOT_THRESHOLD` env var.
46
+ *
47
+ * The threshold is the number of processed events after which the QuickJS
48
+ * engine persists a VM-memory snapshot at suspension, so subsequent
49
+ * invocations restore the VM and replay only the events recorded since —
50
+ * instead of re-executing the workflow from the top against the full log.
51
+ *
52
+ * `0` (or unset) disables snapshotting entirely: short-lived runs never
53
+ * pay the snapshot cost, while long/forever runs can opt in. `1`
54
+ * effectively snapshots at every suspension.
55
+ *
56
+ * Returns the configured threshold, or `undefined` if unset/empty.
57
+ * Throws {@link WorkflowRuntimeError} for non-integer or negative values.
58
+ */
59
+ export declare function getSnapshotThresholdFromEnv(env?: NodeJS.ProcessEnv): number | undefined;
60
+ /**
61
+ * Resolve the snapshot threshold for a run: the run's stamped
62
+ * `executionContext.snapshotThreshold` (set by the SDK at `start()` when
63
+ * `WORKFLOW_SNAPSHOT_THRESHOLD` is set on the client) wins so a run keeps
64
+ * the policy it started with; otherwise the handler's env var; otherwise
65
+ * `0` (disabled). Only consulted by the QuickJS engine.
66
+ *
67
+ * Throws on an invalid value. The workflow handler uses
68
+ * {@link getSnapshotThresholdForHandler}, which doesn't.
69
+ */
70
+ export declare function getSnapshotThreshold(workflowRun: WorkflowRun): number;
71
+ /**
72
+ * {@link getSnapshotThreshold} for the workflow handler: an invalid value
73
+ * disables snapshotting (with a warning through `onInvalid`) instead of
74
+ * throwing. Snapshotting is an optimization, and a throw here would fail
75
+ * every invocation of every QuickJS run on the deployment into a retry
76
+ * loop over a config typo. `start()` still rejects an invalid client-side
77
+ * value up front.
78
+ */
79
+ export declare function getSnapshotThresholdForHandler(workflowRun: WorkflowRun, onInvalid: (message: string) => void): number;
80
+ /**
81
+ * Whether `WORKFLOW_SNAPSHOT_ALLOW_UNENCRYPTED` opts the handler into
82
+ * persisting VM snapshots for runs without an encryption key. A snapshot is
83
+ * executable VM state that also holds the run's in-memory data, so by
84
+ * default the runtime only snapshots runs whose World supplies an
85
+ * encryption key (which also authenticates the snapshot on restore).
86
+ */
87
+ export declare function isUnencryptedSnapshottingAllowed(env?: NodeJS.ProcessEnv): boolean;
44
88
  //# sourceMappingURL=vm-mode.d.ts.map
@@ -5,7 +5,7 @@ export { type HealthCheckOptions, type HealthCheckResult, healthCheck, } from '.
5
5
  export { getHookByToken, type Hook, type ResumedHook, resumeHook, resumeWebhook, } from './runtime/resume-hook.js';
6
6
  export { getRun, Run, type WorkflowReadableStream, type WorkflowReadableStreamOptions, type WorkflowRunWritableStreamOptions, } from './runtime/run.js';
7
7
  export { type CancelRunOptions, cancelRun, cancelRuns, listStreams, type ReadStreamOptions, type RecreateRunOptions, type ReenqueueRunOptions, readStream, recreateRunFromExisting, reenqueueRun, type StopSleepOptions, type StopSleepResult, wakeUpRun, } from './runtime/runs.js';
8
- export { type StartOptions, type StartOptionsBase, type StartOptionsWithDeploymentId, type StartOptionsWithoutDeploymentId, start, } from './runtime/start.js';
8
+ export { type DynamicStartOptions, type DynamicWorkflowOptions, type DynamicWorkflowStepReference, type StartOptions, type StartOptionsBase, type StartOptionsWithDeploymentId, type StartOptionsWithoutDeploymentId, start, } from './runtime/start.js';
9
9
  export { createWorld, createWorldFromModule, getWorld, getWorldHandlers, setWorld, type WorldFactoryModule, } from './runtime/world.js';
10
10
  /**
11
11
  * Creates a single route which handles workflow execution requests,