eve 0.26.2 → 0.27.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 (185) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/src/channel/resolve-active-session.d.ts +4 -0
  3. package/dist/src/channel/resolve-active-session.js +1 -0
  4. package/dist/src/channel/routes.d.ts +11 -0
  5. package/dist/src/cli/dev/tui/vercel-trusted-sources-policy.d.ts +1 -1
  6. package/dist/src/cli/dev/tui/vercel-trusted-sources.js +1 -1
  7. package/dist/src/compiled/.vendor-stamp.json +16 -16
  8. package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
  9. package/dist/src/compiled/@ai-sdk/google/index.d.ts +9 -2
  10. package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
  11. package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +18 -3
  12. package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
  13. package/dist/src/compiled/@ai-sdk/openai/index.d.ts +285 -24
  14. package/dist/src/compiled/@ai-sdk/openai/index.js +2 -2
  15. package/dist/src/compiled/@ai-sdk/otel/index.js +1 -1
  16. package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +7 -3
  17. package/dist/src/compiled/@vercel/oidc/index.js +28 -2
  18. package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +11 -0
  19. package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +7 -0
  20. package/dist/src/compiled/@vercel/sandbox/command.d.ts +8 -0
  21. package/dist/src/compiled/@vercel/sandbox/execution-context.d.ts +116 -0
  22. package/dist/src/compiled/@vercel/sandbox/index.d.ts +3 -1
  23. package/dist/src/compiled/@vercel/sandbox/index.js +20 -19
  24. package/dist/src/compiled/@vercel/sandbox/network-policy.d.ts +13 -5
  25. package/dist/src/compiled/@vercel/sandbox/sandbox-user.d.ts +212 -0
  26. package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +133 -2
  27. package/dist/src/compiled/@vercel/sandbox/session.d.ts +2 -1
  28. package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +1 -1
  29. package/dist/src/compiled/@workflow/core/create-hook.d.ts +41 -22
  30. package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +29 -0
  31. package/dist/src/compiled/@workflow/core/global.d.ts +2 -0
  32. package/dist/src/compiled/@workflow/core/index.js +2 -2
  33. package/dist/src/compiled/@workflow/core/private.d.ts +6 -17
  34. package/dist/src/compiled/@workflow/core/private.js +1 -1
  35. package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +56 -0
  36. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +11 -0
  37. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +6 -4
  38. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +4 -1
  39. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +39 -0
  40. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  41. package/dist/src/compiled/@workflow/core/serialization.d.ts +44 -4
  42. package/dist/src/compiled/@workflow/core/symbols.d.ts +13 -0
  43. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  44. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  45. package/dist/src/compiled/@workflow/errors/error-codes.d.ts +2 -0
  46. package/dist/src/compiled/@workflow/errors/index.d.ts +14 -0
  47. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  48. package/dist/src/compiled/@workflow/world/events.d.ts +15 -0
  49. package/dist/src/compiled/@workflow/world/hooks.d.ts +2 -1
  50. package/dist/src/compiled/@workflow/world/interfaces.d.ts +77 -4
  51. package/dist/src/compiled/@workflow/world-local/index.js +4 -4
  52. package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
  53. package/dist/src/compiled/_chunks/node/{auth-BuQkq4Gr.js → auth-l7F2PF2b.js} +2 -2
  54. package/dist/src/compiled/_chunks/node/{version-DD-FX9rK.js → version-CjHTLx2a.js} +1 -1
  55. package/dist/src/compiled/_chunks/node/virtual-loader-Cwgujv7l.js +1 -0
  56. package/dist/src/compiled/_chunks/workflow/attribute-changes-Dk1fP6vt.js +20 -0
  57. package/dist/src/compiled/_chunks/workflow/{chunk-BHKSVoKr.js → chunk-BTyA9uPd.js} +1 -1
  58. package/dist/src/compiled/_chunks/workflow/dist-B3qkUnLJ.js +3 -0
  59. package/dist/src/compiled/_chunks/workflow/{dist-CSfKNxQW.js → dist-BX517Nmz.js} +2 -2
  60. package/dist/src/compiled/_chunks/workflow/{dist-zLevmMyU.js → dist-C_VDTghO.js} +10 -10
  61. package/dist/src/compiled/_chunks/workflow/{dist-CttsoN4D.js → dist-CrxV2rsR.js} +1 -1
  62. package/dist/src/compiled/_chunks/workflow/{functions-PT9ri9Hu.js → functions-Dv8dc_-I.js} +1 -1
  63. package/dist/src/compiled/_chunks/workflow/resume-hook-czpG5xnP.js +1 -0
  64. package/dist/src/compiled/_chunks/workflow/run-6zaMjFY6.js +1 -0
  65. package/dist/src/compiled/_chunks/workflow/sleep-B2u06FWc.js +1 -0
  66. package/dist/src/compiled/_chunks/workflow/{src-CQuMexnO.js → src-D1EltLDA.js} +1 -1
  67. package/dist/src/compiled/_chunks/workflow/{token-CaY0nA5J.js → token-Cz223z3C.js} +1 -1
  68. package/dist/src/compiled/_chunks/workflow/token-DWqA5-DA.js +1 -0
  69. package/dist/src/compiled/_chunks/workflow/token-util-B6qBs3-0.js +27 -0
  70. package/dist/src/compiled/_chunks/workflow/{undici-fb54XL8i.js → undici-C2ZhYnV9.js} +1 -1
  71. package/dist/src/compiled/_chunks/workflow/wrapper-Cc2otuUR.js +6 -0
  72. package/dist/src/compiled/env-runner/index.js +1 -1
  73. package/dist/src/compiled/env-runner/node-worker.js +1 -1
  74. package/dist/src/compiled/eventsource-parser/stream/index.d.ts +16 -3
  75. package/dist/src/compiled/jose/index.js +1 -1
  76. package/dist/src/compiler/compile-from-memory.d.ts +5 -0
  77. package/dist/src/compiler/compile-from-memory.js +1 -1
  78. package/dist/src/compiler/extension-compatibility.d.ts +10 -10
  79. package/dist/src/compiler/extension-compatibility.js +1 -1
  80. package/dist/src/execution/deliver-payloads.d.ts +1 -1
  81. package/dist/src/execution/deliver-payloads.js +1 -1
  82. package/dist/src/execution/workflow-entry.js +1 -1
  83. package/dist/src/execution/workflow-steps.js +1 -1
  84. package/dist/src/harness/compaction-prompt.d.ts +19 -1
  85. package/dist/src/harness/compaction-prompt.js +7 -5
  86. package/dist/src/harness/compaction.d.ts +4 -11
  87. package/dist/src/harness/compaction.js +1 -1
  88. package/dist/src/harness/prompt-cache.d.ts +16 -5
  89. package/dist/src/harness/prompt-cache.js +1 -1
  90. package/dist/src/harness/session-limit-continuation.d.ts +8 -0
  91. package/dist/src/harness/session-limit-continuation.js +1 -1
  92. package/dist/src/harness/session-limit-enforcement.d.ts +9 -6
  93. package/dist/src/harness/session-limit-enforcement.js +1 -1
  94. package/dist/src/harness/stale-input-responses.d.ts +21 -3
  95. package/dist/src/harness/stale-input-responses.js +2 -2
  96. package/dist/src/harness/token-estimate.d.ts +9 -0
  97. package/dist/src/harness/token-estimate.js +1 -0
  98. package/dist/src/harness/tool-loop.js +2 -2
  99. package/dist/src/harness/turn-cancellation.d.ts +13 -0
  100. package/dist/src/harness/turn-cancellation.js +1 -1
  101. package/dist/src/internal/application/package.js +1 -1
  102. package/dist/src/internal/nitro/host/copy-host-middleware.js +1 -1
  103. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
  104. package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
  105. package/dist/src/node_modules/.pnpm/@vercel_sdk@1.28.8/node_modules/@vercel/sdk/esm/models/updateprojectblock.js +1 -0
  106. package/dist/src/node_modules/.pnpm/@vercel_sdk@1.28.8/node_modules/@vercel/sdk/esm/models/updateprojectprojectsbranchmatcher.js +1 -0
  107. package/dist/src/packages/eve-catalog/src/index.js +1 -1
  108. package/dist/src/public/channels/auth.d.ts +59 -9
  109. package/dist/src/public/channels/auth.js +1 -1
  110. package/dist/src/public/channels/discord/defaults.js +1 -1
  111. package/dist/src/public/channels/linear/api.d.ts +2 -0
  112. package/dist/src/public/channels/linear/api.js +3 -1
  113. package/dist/src/public/channels/linear/defaults.js +2 -2
  114. package/dist/src/public/channels/linear/hitl.d.ts +8 -13
  115. package/dist/src/public/channels/linear/hitl.js +3 -3
  116. package/dist/src/public/channels/linear/index.d.ts +1 -1
  117. package/dist/src/public/channels/linear/index.js +1 -1
  118. package/dist/src/public/channels/linear/linearChannel.js +1 -1
  119. package/dist/src/public/channels/slack/api.d.ts +20 -0
  120. package/dist/src/public/channels/slack/api.js +1 -1
  121. package/dist/src/public/channels/slack/defaults.js +1 -1
  122. package/dist/src/public/channels/slack/inbound.d.ts +31 -0
  123. package/dist/src/public/channels/slack/inbound.js +1 -1
  124. package/dist/src/public/channels/slack/index.d.ts +2 -2
  125. package/dist/src/public/channels/slack/slackChannel.d.ts +72 -4
  126. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  127. package/dist/src/public/channels/teams/defaults.js +2 -2
  128. package/dist/src/public/channels/teams/index.d.ts +1 -1
  129. package/dist/src/public/channels/teams/teamsChannel.d.ts +7 -2
  130. package/dist/src/public/channels/teams/teamsChannel.js +1 -1
  131. package/dist/src/public/channels/telegram/defaults.js +1 -1
  132. package/dist/src/public/definitions/channel.d.ts +1 -1
  133. package/dist/src/public/next/index.js +1 -1
  134. package/dist/src/public/nuxt/index.d.ts +1 -1
  135. package/dist/src/public/nuxt/index.js +1 -1
  136. package/dist/src/public/nuxt/module.d.ts +10 -24
  137. package/dist/src/public/nuxt/module.js +1 -1
  138. package/dist/src/public/nuxt/routing.d.ts +5 -39
  139. package/dist/src/public/nuxt/routing.js +1 -1
  140. package/dist/src/public/nuxt/vercel-services.d.ts +117 -0
  141. package/dist/src/public/nuxt/vercel-services.js +1 -0
  142. package/dist/src/runtime/framework-tools/connection-search-dynamic.js +2 -1
  143. package/dist/src/runtime/framework-tools/todo.js +1 -1
  144. package/dist/src/runtime/governance/auth/http-basic.js +1 -1
  145. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  146. package/dist/src/setup/scaffold/create/project.js +2 -2
  147. package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
  148. package/dist/src/setup/scaffold/create/web-template.js +90 -5
  149. package/dist/src/setup/scaffold/update/channels.js +2 -2
  150. package/dist/src/setup/scaffold/update/connections.js +1 -1
  151. package/dist/src/{public/next → shared}/resolve-eve-binary.d.ts +1 -1
  152. package/docs/agent-config.md +10 -5
  153. package/docs/channels/slack.mdx +76 -10
  154. package/docs/channels/teams.mdx +10 -3
  155. package/docs/extensions.md +115 -77
  156. package/docs/guides/auth-and-route-protection.md +14 -1
  157. package/docs/guides/deployment/vercel.mdx +1 -1
  158. package/docs/guides/frontend/nuxt.mdx +22 -1
  159. package/docs/guides/frontend/overview.mdx +2 -0
  160. package/docs/meta.json +1 -0
  161. package/package.json +22 -22
  162. package/dist/src/compiled/@workflow/core/step-hydration-cache.d.ts +0 -148
  163. package/dist/src/compiled/_chunks/node/virtual-loader-B8K8w9cr.js +0 -1
  164. package/dist/src/compiled/_chunks/workflow/attribute-changes-CXiYB8h9.js +0 -20
  165. package/dist/src/compiled/_chunks/workflow/dist-BYo8Gno2.js +0 -3
  166. package/dist/src/compiled/_chunks/workflow/resume-hook-CHXbXuRZ.js +0 -1
  167. package/dist/src/compiled/_chunks/workflow/run-BjtAGa3_.js +0 -1
  168. package/dist/src/compiled/_chunks/workflow/sleep-BJAv0MFP.js +0 -1
  169. package/dist/src/compiled/_chunks/workflow/token-D4VIwGlD.js +0 -1
  170. package/dist/src/compiled/_chunks/workflow/wrapper-ulTvoTdW.js +0 -6
  171. package/dist/src/node_modules/.pnpm/@vercel_sdk@1.28.1/node_modules/@vercel/sdk/esm/models/updateprojectprojectsaction.js +0 -1
  172. package/dist/src/node_modules/.pnpm/@vercel_sdk@1.28.1/node_modules/@vercel/sdk/esm/models/updateprojectprojectsoptionsallowlist.js +0 -1
  173. package/dist/src/public/nuxt/vercel-json.d.ts +0 -17
  174. package/dist/src/public/nuxt/vercel-json.js +0 -1
  175. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/lib/primitives.js +0 -0
  176. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/lib/schemas.js +0 -0
  177. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/models/aclaction.js +0 -0
  178. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/models/sdkvalidationerror.js +0 -0
  179. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/defaultToZeroValue.js +0 -0
  180. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/fp.js +0 -0
  181. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/primitives.js +0 -0
  182. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/rfcdate.js +0 -0
  183. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/smartUnion.js +0 -0
  184. /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/unrecognized.js +0 -0
  185. /package/dist/src/{public/next → shared}/resolve-eve-binary.js +0 -0
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Utils used by the bundler when transforming code
3
3
  */
4
+ import type { WorldCapabilities } from '#compiled/@workflow/world/index.js';
4
5
  import type { CryptoKey } from './encryption.js';
5
6
  import type { EventsConsumer } from './events-consumer.js';
6
7
  import type { QueueItem } from './global.js';
8
+ import type { ReplayPayloadCache } from './replay-payload-cache.js';
7
9
  import type { Serializable } from './schemas.js';
8
- import type { StepHydrationCache } from './step-hydration-cache.js';
9
10
  export type StepFunction<Args extends Serializable[] = any[], Result extends Serializable | unknown = unknown> = ((...args: Args) => Promise<Result>) & {
10
11
  maxRetries?: number;
11
12
  stepId?: string;
@@ -27,6 +28,7 @@ export declare function getStepFunction(stepId: string): StepFunction | undefine
27
28
  export interface WorkflowOrchestratorContext {
28
29
  runId: string;
29
30
  encryptionKey: CryptoKey | undefined;
31
+ worldCapabilities?: WorldCapabilities;
30
32
  globalThis: typeof globalThis;
31
33
  eventsConsumer: EventsConsumer;
32
34
  /**
@@ -85,23 +87,10 @@ export interface WorkflowOrchestratorContext {
85
87
  */
86
88
  pendingDeliveryBarriers?: Map<number, DeliveryBarrierEntry>;
87
89
  /**
88
- * Per-run memoization cache for hydrated step return values, keyed by the
89
- * `step_completed` event id. Owned by the inline replay loop in `runtime.ts`
90
- * and threaded through each `runWorkflow` call so it survives across replay
91
- * iterations of the SAME run (a fresh context is created each iteration) but
92
- * never leaks across unrelated runs.
93
- *
94
- * On replay K of a sequential N-step workflow, the step consumer would
95
- * otherwise re-decrypt and re-parse the results of all K already-completed
96
- * steps — O(N²) across an invocation. This cache makes a completed step's
97
- * result available in O(1) on subsequent replays. Only primitive results are
98
- * memoized, so a shared reference can never let one replay's mutation leak
99
- * into the next; see `step-hydration-cache.ts` for the full rationale.
100
- *
101
- * Optional so contexts that do not initialize it (test harnesses) degrade
102
- * gracefully to re-hydrating every replay — identical to previous behavior.
90
+ * Invocation-scoped cache of prepared serialized payloads and immutable final
91
+ * values. Prepared bytes survive fresh replay VMs; object graphs do not.
103
92
  */
104
- stepHydrationCache?: StepHydrationCache;
93
+ replayPayloadCache: ReplayPayloadCache;
105
94
  }
106
95
  /** The kind of branch-deciding delivery a barrier represents. */
107
96
  export type DeliveryKind = 'hook' | 'wait';
@@ -1 +1 @@
1
- import{c as e}from"../../_chunks/workflow/dist-CttsoN4D.js";const t=Symbol.for(`@workflow/core//registeredSteps`),n=globalThis,r=n[t]??=new Map,i=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);function a(e){let t=e.split(`//`);if(t.length!==3||t[0]!==`step`)return[];let n=t[1],r=t[2],i=new Set,a=e=>{e!==n&&i.add(e)};if(n.startsWith(`./workflows/`)){let e=n.slice(2);a(`./example/${e}`),a(`./src/${e}`)}else if(n.startsWith(`./example/workflows/`)){let e=n.slice(10);a(`./${e}`),a(`./src/${e}`)}else if(n.startsWith(`./src/workflows/`)){let e=n.slice(6);a(`./${e}`),a(`./example/${e}`)}return Array.from(i,e=>`step//${e}//${r}`)}function o(e){if(i.has(e)){for(let[t,n]of r.entries())if(t.endsWith(`//${e}`))return n}}function s(e,t){r.set(e,t),t.stepId=e}function c(e){let t=r.get(e);if(t)return t;for(let t of a(e)){let e=r.get(t);if(e)return e}let n=o(e);if(n)return n}async function l(e,t,n){if(t===void 0||!e.pendingDeliveryBarriers||e.pendingDeliveryBarriers.size===0)return;let r=[];for(let[i,a]of e.pendingDeliveryBarriers)i<t&&n.includes(a.kind)&&r.push(a.delivered);r.length>0&&await Promise.all(r)}function u(t,n,r){let i=t.pendingDeliveryBarriers;if(!i||n===void 0)return{markDelivered:()=>{}};let a=!1,{promise:o,resolve:s}=e(),c={kind:r,delivered:o};i.set(n,c);let l=()=>{a||(a=!0,i.get(n)===c&&i.delete(n),s())};return d(t,l),{markDelivered:l}}function d(e,t){let n=()=>{e.pendingDeliveries>0?e.promiseQueue.then(()=>{setTimeout(n,0)}):t()};setTimeout(n,0)}export{l as awaitEarlierDeliveries,c as getStepFunction,u as registerDeliveryBarrier,s as registerStepFunction,d as scheduleWhenIdle};
1
+ import{c as e}from"../../_chunks/workflow/dist-CrxV2rsR.js";const t=Symbol.for(`@workflow/core//registeredSteps`),n=globalThis,r=n[t]??=new Map,i=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);function a(e){let t=e.split(`//`);if(t.length!==3||t[0]!==`step`)return[];let n=t[1],r=t[2],i=new Set,a=e=>{e!==n&&i.add(e)};if(n.startsWith(`./workflows/`)){let e=n.slice(2);a(`./example/${e}`),a(`./src/${e}`)}else if(n.startsWith(`./example/workflows/`)){let e=n.slice(10);a(`./${e}`),a(`./src/${e}`)}else if(n.startsWith(`./src/workflows/`)){let e=n.slice(6);a(`./${e}`),a(`./example/${e}`)}return Array.from(i,e=>`step//${e}//${r}`)}function o(e){if(i.has(e)){for(let[t,n]of r.entries())if(t.endsWith(`//${e}`))return n}}function s(e,t){r.set(e,t),t.stepId=e}function c(e){let t=r.get(e);if(t)return t;for(let t of a(e)){let e=r.get(t);if(e)return e}let n=o(e);if(n)return n}async function l(e,t,n){if(t===void 0||!e.pendingDeliveryBarriers||e.pendingDeliveryBarriers.size===0)return;let r=[];for(let[i,a]of e.pendingDeliveryBarriers)i<t&&n.includes(a.kind)&&r.push(a.delivered);r.length>0&&await Promise.all(r)}function u(t,n,r){let i=t.pendingDeliveryBarriers;if(!i||n===void 0)return{markDelivered:()=>{}};let a=!1,{promise:o,resolve:s}=e(),c={kind:r,delivered:o};i.set(n,c);let l=()=>{a||(a=!0,i.get(n)===c&&i.delete(n),s())};return d(t,l),{markDelivered:l}}function d(e,t){let n=()=>{e.pendingDeliveries>0?e.promiseQueue.then(()=>{setTimeout(n,0)}):t()};setTimeout(n,0)}export{l as awaitEarlierDeliveries,c as getStepFunction,u as registerDeliveryBarrier,s as registerStepFunction,d as scheduleWhenIdle};
@@ -0,0 +1,56 @@
1
+ import type { Event, WorkflowRun } from '#compiled/@workflow/world/index.js';
2
+ import type { CryptoKey } from './encryption.js';
3
+ import { type PreparedReplayPayload, type ReplayPayloadPreparer } from './serialization.js';
4
+ type ReplayPayloadField = 'result' | 'error' | 'payload';
5
+ /**
6
+ * Invocation-scoped cache for replay payload hydration.
7
+ *
8
+ * A workflow invocation may replay the same event log through several fresh
9
+ * VMs. This cache keeps the VM-independent decrypt/decompress result across
10
+ * those replays. Deserialization still runs against each VM's globals so every
11
+ * replay receives fresh object graphs and correctly revived Workflow objects.
12
+ *
13
+ * Successful prepared plaintext remains resident for the invocation lifetime.
14
+ * Its memory cost is the sum of decrypted and decompressed payload sizes, but
15
+ * it never crosses workflow runs or queue deliveries.
16
+ */
17
+ export declare class ReplayPayloadCache {
18
+ private readonly encryptionKey;
19
+ private readonly preparer;
20
+ private readonly preparedPayloads;
21
+ private readonly primitiveStepResults;
22
+ constructor(encryptionKey: CryptoKey | undefined, preparer?: ReplayPayloadPreparer);
23
+ /**
24
+ * Start every missing binary preparation before workflow execution. Failures
25
+ * are intentionally retained: the ordered event consumer must observe the
26
+ * original rejection before that entry becomes retryable.
27
+ */
28
+ prewarm(workflowRun: WorkflowRun, events: Event[]): Promise<void>;
29
+ /** Return the workflow input after shared host-side preparation. */
30
+ prepareWorkflowInput(workflowRun: WorkflowRun): Promise<PreparedReplayPayload>;
31
+ /**
32
+ * Return an event payload after shared host-side preparation. A rejected
33
+ * preparation is evicted only after this ordered consumer requests it, so a
34
+ * later replay can retry without hiding the original failure.
35
+ */
36
+ prepareEventPayload(eventId: string, field: ReplayPayloadField, value: unknown): Promise<PreparedReplayPayload>;
37
+ /**
38
+ * Reuse final step values only when sharing them across VMs is unobservable.
39
+ * Objects and large strings/bigints always run `hydrate` again, producing a
40
+ * fresh VM-specific value from the separately cached prepared payload.
41
+ */
42
+ getStepResult(eventId: string, hydrate: () => Promise<unknown>): Promise<unknown>;
43
+ /**
44
+ * Consumer-facing lookup. Binary payloads share preparation; legacy values
45
+ * bypass the cache because their flattened representation may be mutated.
46
+ */
47
+ private consumePreparation;
48
+ /** Start preparation once and share the exact in-flight promise. */
49
+ private ensurePreparation;
50
+ /** Normalize synchronous and asynchronous preparers to one promise contract. */
51
+ private runPreparation;
52
+ private workflowInputKey;
53
+ private eventPayloadKey;
54
+ }
55
+ export {};
56
+ //# sourceMappingURL=replay-payload-cache.d.ts.map
@@ -85,6 +85,17 @@ export declare const MAX_MAX_INLINE_STEPS = 16;
85
85
  * one-time warning so misconfiguration is observable.
86
86
  */
87
87
  export declare function getMaxInlineSteps(): number;
88
+ /**
89
+ * Optional client-side override for the server-supplied per-run event ceiling.
90
+ * When set to a positive integer, the runtime clamps the server's limit *down*
91
+ * to this value (never raises it) so enforcement can be exercised without a
92
+ * server-side change. `undefined` (unset) ⇒ use the server value as-is.
93
+ *
94
+ * Reads `process.env.WORKFLOW_MAX_EVENTS_OVERRIDE` lazily so tests and
95
+ * deployments can override per invocation. Invalid values fall back to unset
96
+ * (no throw — the env var is an escape hatch) and emit a one-time warning.
97
+ */
98
+ export declare function getMaxEventsOverride(): number | undefined;
88
99
  /**
89
100
  * Whether optimistic inline step start is enabled. When on, the owned-inline
90
101
  * path begins running a brand-new step's body *before* its lazy `step_started`
@@ -89,10 +89,12 @@ export interface MutableEventLog {
89
89
  cursor: string | null;
90
90
  }
91
91
  /**
92
- * Whether the optimistic-concurrency guard for event creation is enabled
93
- * (`WORKFLOW_PRECONDITION_GUARD=1`, set where the runtime executes). Off by
94
- * default: replay-context creates only send a `stateUpdatedAt` snapshot (and
95
- * can therefore be rejected with 412 by the backend) when it is enabled.
92
+ * Whether the optimistic-concurrency guard for event creation is enabled.
93
+ * **On by default** where the runtime executes: replay-context creates send a
94
+ * `stateUpdatedAt` snapshot (and can be rejected with 412 by a supporting
95
+ * backend) unless `WORKFLOW_PRECONDITION_GUARD` is set to `0`. Backends without
96
+ * guard support ignore the snapshot, so enabling by default is
97
+ * backward-compatible.
96
98
  */
97
99
  export declare function isPreconditionGuardEnabled(): boolean;
98
100
  /**
@@ -5,6 +5,9 @@ import { type CryptoKey } from '../encryption.js';
5
5
  * and hydrate the `metadata` property if it was set from within
6
6
  * the workflow run.
7
7
  *
8
+ * A Hook kept by minimum retention remains available here after its run ends,
9
+ * but cannot be resumed.
10
+ *
8
11
  * @param token - The unique token identifying the hook
9
12
  */
10
13
  export declare function getHookByToken(token: string): Promise<Hook>;
@@ -17,7 +20,7 @@ export declare function getHookByToken(token: string): Promise<Hook>;
17
20
  * @param tokenOrHook - The unique token identifying the hook, or the hook object itself
18
21
  * @param payload - The data payload to send to the hook
19
22
  * @returns Promise resolving to the hook
20
- * @throws Error if the hook is not found or if there's an error during the process
23
+ * @throws {HookNotFoundError} If the Hook does not exist or its run has ended
21
24
  *
22
25
  * @example
23
26
  *
@@ -1,6 +1,7 @@
1
1
  import type { Event, SerializedData, World } from '#compiled/@workflow/world/index.js';
2
2
  import type { CryptoKey } from '../encryption.js';
3
3
  import { type StepLatencyTracking } from './step-latency.js';
4
+ export declare const DEFAULT_STEP_MAX_RETRIES = 3;
4
5
  export interface StepExecutorParams {
5
6
  world: World;
6
7
  workflowRunId: string;
@@ -54,6 +55,33 @@ export interface StepExecutorParams {
54
55
  * handler is the sole inline writer for the run on this iteration.
55
56
  */
56
57
  inlineDeltaSinceCursor?: string;
58
+ /**
59
+ * Precondition-guard snapshot (epoch ms of the latest event the caller's
60
+ * replay loaded) to attach to this step's `step_started` claim. On the lazy
61
+ * inline path the claim is the step's FIRST durable write (its
62
+ * `step_created` is deferred), so without this the claim would bypass the
63
+ * optimistic-concurrency guard entirely: a replay working from a stale view
64
+ * could claim — and then commit — a step scheduled without observing an
65
+ * out-of-band event. A guard-enforcing World rejects a stale claim with
66
+ * `PreconditionFailedError` (412); executeStep does NOT translate that
67
+ * rejection (re-claiming in place would still commit the stale schedule),
68
+ * so it propagates for the caller to abandon the batch and force a fresh
69
+ * replay. Undefined when the guard is disabled or the caller has no
70
+ * snapshot; Worlds that don't enforce the guard ignore it.
71
+ */
72
+ stateUpdatedAt?: number;
73
+ /**
74
+ * Suppress optimistic inline start for this step regardless of
75
+ * `WORKFLOW_OPTIMISTIC_INLINE_START` / `forceOptimisticStart`: take the
76
+ * await-then-run path so the body only runs after the `step_started` claim
77
+ * succeeds. Set by the runtime for guard-enforced batches that are
78
+ * stale-sensitive (an open hook means an out-of-band event can make the
79
+ * scheduling view stale): the guard's 412 fence can reject a stale claim's
80
+ * durable writes, but it cannot un-run a body that optimistic start began
81
+ * before the claim settled — awaiting the claim extends the fence to user
82
+ * code. Wins over `forceOptimisticStart` and the env flag.
83
+ */
84
+ suppressOptimisticStart?: boolean;
57
85
  /**
58
86
  * Force optimistic inline start regardless of
59
87
  * `WORKFLOW_OPTIMISTIC_INLINE_START`. Set by turbo mode on the first delivery
@@ -80,6 +108,17 @@ export interface StepExecutorParams {
80
108
  * runtime/step-latency.ts.
81
109
  */
82
110
  latencyTracking?: StepLatencyTracking;
111
+ /**
112
+ * Authoritative attempt number for this execution, used to bound retries
113
+ * against `maxRetries` BEFORE the body runs. In order to also catch
114
+ * step timeouts (which we can't have catch handlers for), we determine
115
+ * the attempt count based as follows:
116
+ * - Inline (combined handler): the number of `step_started` events already
117
+ * in the event log for this step, plus one for the attempt about to run.
118
+ * - Background (queue-dispatched): the queue delivery count
119
+ * (`metadata.attempt`), which increments on every redelivery.
120
+ */
121
+ authoritativeAttempt?: number;
83
122
  }
84
123
  /**
85
124
  * Inline-delta returned by a step-terminal write when the caller passed