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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve",
3
- "version": "0.26.2",
3
+ "version": "0.27.1",
4
4
  "private": false,
5
5
  "description": "Filesystem-first framework for durable backend AI agents that run anywhere.",
6
6
  "keywords": [
@@ -282,13 +282,13 @@
282
282
  "nitro": "3.0.260610-beta"
283
283
  },
284
284
  "devDependencies": {
285
- "@ai-sdk/anthropic": "^4.0.14",
286
- "@ai-sdk/google": "^4.0.14",
287
- "@ai-sdk/mcp": "^2.0.12",
288
- "@ai-sdk/openai": "^4.0.13",
289
- "@ai-sdk/otel": "^1.0.26",
285
+ "@ai-sdk/anthropic": "^4.0.18",
286
+ "@ai-sdk/google": "^4.0.21",
287
+ "@ai-sdk/mcp": "^2.0.16",
288
+ "@ai-sdk/openai": "^4.0.17",
289
+ "@ai-sdk/otel": "^1.0.34",
290
290
  "@ai-sdk/provider": "^4.0.3",
291
- "@ai-sdk/provider-utils": "^5.0.9",
291
+ "@ai-sdk/provider-utils": "^5.0.12",
292
292
  "@chat-adapter/slack": "4.34.0",
293
293
  "@chat-adapter/state-memory": "4.34.0",
294
294
  "@chat-adapter/twilio": "4.34.0",
@@ -300,29 +300,29 @@
300
300
  "@types/react": "19.2.15",
301
301
  "@types/react-test-renderer": "19.1.0",
302
302
  "@vercel/detect-agent": "1.2.3",
303
- "@vercel/oidc": "3.5.0",
304
- "@vercel/sandbox": "2.3.0",
305
- "@vercel/sdk": "1.28.1",
306
- "@workflow/core": "5.0.0-beta.35",
307
- "@workflow/errors": "5.0.0-beta.11",
303
+ "@vercel/oidc": "3.8.0",
304
+ "@vercel/sandbox": "2.8.0",
305
+ "@vercel/sdk": "1.28.8",
306
+ "@workflow/core": "5.0.0-beta.36",
307
+ "@workflow/errors": "5.0.0-beta.12",
308
308
  "@workflow/serde": "5.0.0-beta.2",
309
309
  "@workflow/utils": "5.0.0-beta.6",
310
- "@workflow/world": "5.0.0-beta.21",
311
- "@workflow/world-local": "5.0.0-beta.29",
312
- "@workflow/world-vercel": "5.0.0-beta.31",
313
- "ai": "^7.0.26",
310
+ "@workflow/world": "5.0.0-beta.22",
311
+ "@workflow/world-local": "5.0.0-beta.30",
312
+ "@workflow/world-vercel": "5.0.0-beta.32",
313
+ "ai": "^7.0.34",
314
314
  "autoevals": "0.0.132",
315
315
  "chat": "4.34.0",
316
316
  "chokidar": "5.0.0",
317
317
  "commander": "14.0.3",
318
318
  "emulate": "0.6.0",
319
- "env-runner": "0.1.12",
320
- "eventsource-parser": "3.0.8",
319
+ "env-runner": "0.1.16",
320
+ "eventsource-parser": "3.1.0",
321
321
  "experimental-ai-sdk-code-mode": "1.0.16",
322
322
  "gray-matter": "4.0.3",
323
323
  "jose": "6.2.3",
324
324
  "jsonc-parser": "3.3.1",
325
- "just-bash": "3.0.1",
325
+ "just-bash": "3.1.0",
326
326
  "marked": "17.0.6",
327
327
  "microsandbox": "0.5.5",
328
328
  "next": "16.3.0-preview.6",
@@ -332,8 +332,8 @@
332
332
  "semver": "7.8.4",
333
333
  "svelte": "^5.0.0",
334
334
  "turndown": "7.2.4",
335
- "vite": "^8.0.0",
336
- "vitest": "4.1.7",
335
+ "vite": "^8.1.5",
336
+ "vitest": "4.1.10",
337
337
  "vue": "^3.5.0",
338
338
  "zod": "4.4.3",
339
339
  "zod-validation-error": "5.0.0",
@@ -341,7 +341,7 @@
341
341
  },
342
342
  "peerDependencies": {
343
343
  "@opentelemetry/api": "^1.0.0",
344
- "ai": "^7.0.26",
344
+ "ai": "^7.0.34",
345
345
  "braintrust": "^3.0.0",
346
346
  "just-bash": "^3.0.0",
347
347
  "microsandbox": "^0.5.0"
@@ -1,148 +0,0 @@
1
- /**
2
- * Per-run memoization cache for hydrated step return values.
3
- *
4
- * ## Why
5
- *
6
- * The inline replay loop (`runtime.ts`) re-runs the workflow body from the top
7
- * on every iteration, re-consuming the full event log each time. For every
8
- * already-completed step, the step consumer (`step.ts`) re-runs
9
- * `hydrateStepReturnValue` — which AES-GCM-decrypts and devalue-parses the
10
- * serialized result — even though that exact result was already hydrated on
11
- * every prior replay. For a sequential workflow of N steps, replay K hydrates
12
- * K results, so the total work across a single invocation is O(N²)
13
- * decrypt+parse operations.
14
- *
15
- * This cache makes a completed step's hydrated result available in O(1) on
16
- * subsequent replays within the SAME invocation, turning the aggregate cost
17
- * into O(N).
18
- *
19
- * ## Scope / lifetime
20
- *
21
- * The cache is owned by the inline loop in `runtime.ts` (one per workflow run
22
- * invocation) and passed into `runWorkflow` so it survives across the loop's
23
- * iterations but never leaks across unrelated runs or process-level
24
- * invocations. A fresh `runWorkflow` / `WorkflowOrchestratorContext` is created
25
- * each iteration, so the cache must live OUTSIDE the per-iteration context.
26
- *
27
- * ## Keying
28
- *
29
- * Entries are keyed by the persisted event's `eventId` — a stable,
30
- * world-assigned identifier for the `step_completed` event whose serialized
31
- * `result` is being hydrated. The same event (same `eventId`) carries the same
32
- * immutable serialized bytes across every replay, so a hit is guaranteed to
33
- * correspond to the identical input.
34
- *
35
- * ## Identity safety (why primitives only)
36
- *
37
- * `hydrateStepReturnValue` (devalue.parse) produces a FRESH object graph on
38
- * every call, and each replay iteration runs in a FRESH workflow VM. The
39
- * current (uncached) behavior therefore hands the workflow a brand-new value
40
- * on every replay. If we cached and returned the SAME object reference across
41
- * replays, workflow code that mutates a step result (`const r = await step();
42
- * r.count++`) would observe the mutation from a previous replay on the next
43
- * replay — a non-deterministic divergence. Structured-cloning on each hit is
44
- * both lossy (revivers reconstruct stream handles, step-function proxies,
45
- * Request/Response, and AbortController/AbortSignal class instances that don't
46
- * survive a structured clone) and still O(size).
47
- *
48
- * So we only cache values for which returning the same reference on every
49
- * replay is provably indistinguishable from re-hydrating: JavaScript
50
- * primitives (string, number, boolean, bigint, symbol, null, undefined).
51
- * Primitives are immutable and compared by value, so sharing the reference is
52
- * byte-for-byte equivalent to re-parsing. Any non-primitive result falls
53
- * through to a full re-hydrate every replay, preserving current behavior
54
- * exactly. This trades some of the optimization away in the object-returning
55
- * case in exchange for keeping deterministic replay airtight.
56
- *
57
- * ## Memory characteristic
58
- *
59
- * Cached entries hold the decrypted/devalue-parsed *plaintext* of a step
60
- * result, which is retained for the rest of the invocation on top of the
61
- * serialized bytes already held in `cachedEvents`. So the residual cost is:
62
- *
63
- * - **Scoped to one workflow-run invocation.** A fresh `Map` is created per
64
- * invocation (in `runtime.ts`) and is unreachable / GC'd when the invocation
65
- * returns. Nothing accumulates across runs or across process-level
66
- * invocations.
67
- * - **Bounded by the number of primitive-returning completed steps in that
68
- * run** — at most one small entry per such step.
69
- * - **Primitives only, and additionally byte-bounded.** Most primitives
70
- * (numbers, booleans, null/undefined, symbols, short ids/strings) are tiny
71
- * and fixed-size. The only primitive that can be large is a string (or a
72
- * pathologically long bigint), so to keep the doubled-residency worst case
73
- * bounded we *do not* memoize string/bigint results whose character length
74
- * exceeds {@link MAX_MEMOIZED_PRIMITIVE_LENGTH}. A large string is cheap to
75
- * re-hydrate relative to its footprint, so letting it fall through to the
76
- * existing per-replay re-hydrate path costs little and caps peak retained
77
- * memory.
78
- *
79
- * (This is a much weaker concern than a *process-wide* cache: the dominant
80
- * residency — the full event log in `cachedEvents` — already exists for the
81
- * same lifetime, and everything here is freed together with it when the
82
- * invocation ends.)
83
- */
84
- /**
85
- * Upper bound, in characters, on a string/bigint primitive that may be
86
- * memoized. Beyond this, the value falls through to a fresh re-hydrate on every
87
- * replay so the cache never holds a large plaintext payload for the lifetime of
88
- * the invocation. 4 KiB comfortably covers ids, counts, flags, and typical
89
- * short string results while excluding the large-payload case the bound exists
90
- * to guard. Other primitive types (number, boolean, symbol, null, undefined)
91
- * are inherently small and are never length-checked.
92
- */
93
- export declare const MAX_MEMOIZED_PRIMITIVE_LENGTH = 4096;
94
- /**
95
- * Returns true for values that are safe to memoize and return by reference
96
- * across replays: JS primitives. Objects and functions are excluded because
97
- * sharing a mutable reference across replays could change observable behavior.
98
- *
99
- * Strings and bigints are additionally bounded by length: a value longer than
100
- * {@link MAX_MEMOIZED_PRIMITIVE_LENGTH} characters is treated as non-memoizable
101
- * so the cache never retains a large plaintext payload for the whole invocation
102
- * (see the module-level "Memory characteristic" docs). It re-hydrates fresh on
103
- * every replay instead — cheap relative to its footprint.
104
- *
105
- * Note: `typeof null === 'object'`, so it is handled explicitly. `undefined`,
106
- * `string`, `number`, `boolean`, `bigint`, and `symbol` are all primitives.
107
- */
108
- export declare function isMemoizablePrimitive(value: unknown): boolean;
109
- /**
110
- * Cache of hydrated step return values for a single workflow run invocation.
111
- *
112
- * Keyed by `step_completed` event id; the value is the already-hydrated
113
- * primitive result. Only successful, primitive hydrations are stored (see
114
- * {@link getOrHydrateStepReturnValue}), so a non-`undefined` `has(eventId)`
115
- * always means "this step completed with a memoizable primitive value".
116
- */
117
- export type StepHydrationCache = Map<string, unknown>;
118
- /**
119
- * Create an empty per-invocation step hydration cache.
120
- */
121
- export declare function createStepHydrationCache(): StepHydrationCache;
122
- /**
123
- * Return the hydrated step result for `eventId`, using `cache` as a per-run
124
- * memo. On a hit, the cached primitive is returned without re-running the
125
- * expensive decrypt + devalue-parse. On a miss, `hydrate()` runs and its
126
- * result is memoized only when it is a small primitive (see the module docs for
127
- * the identity-safety rationale and the length bound on string/bigint results).
128
- *
129
- * This always returns a `Promise` and `await`s `hydrate()` even on the miss
130
- * path, so the caller's `await` inside its serial `promiseQueue` slot keeps the
131
- * same scheduling on both hit and miss — a cache hit resolves through the exact
132
- * same promise-chain position a re-hydrate would have, preserving the
133
- * deterministic delivery order that `pendingDeliveries`, the delivery barriers,
134
- * and `Promise.race`/`Promise.all` replay all depend on.
135
- *
136
- * `has(eventId)` is used rather than `get(eventId) !== undefined` so that a
137
- * legitimately memoized `undefined` step result still registers as a hit.
138
- *
139
- * When `cache` or `eventId` is absent (lightweight test harnesses, or a context
140
- * that predates this plumbing), this degrades to calling `hydrate()` directly
141
- * with no memoization — identical to the previous behavior.
142
- *
143
- * Errors are intentionally never cached: a rejected hydrate propagates to the
144
- * caller (which rejects the step promise) and the next replay re-attempts it,
145
- * matching the uncached behavior and avoiding a parked rejected promise.
146
- */
147
- export declare function getOrHydrateStepReturnValue(cache: StepHydrationCache | undefined, eventId: string | undefined, hydrate: () => Promise<unknown>): Promise<unknown>;
148
- //# sourceMappingURL=step-hydration-cache.d.ts.map
@@ -1 +0,0 @@
1
- import{pathToFileURL as e}from"node:url";async function t(e){let t=await Promise.all(Object.entries(e).map(async([e,t])=>[e,typeof t==`function`?await t():t]));return Object.fromEntries(t)}const n=`virtual:`;function r(e,t,r=c()){return{resolve:(i,a,o)=>{let c=s(i);if(Object.hasOwn(e,c)){let e=t?.get(c);return{url:n+encodeURIComponent(i)+(e?`?v=${e}`:``),shortCircuit:!0}}return a.parentURL?.startsWith(n)?o(i,{...a,parentURL:r}):o(i,a)},load:(t,r,a)=>{if(t.startsWith(n)){let n=s(decodeURIComponent(t.slice(8)));if(Object.hasOwn(e,n))return{format:i(n),source:e[n],shortCircuit:!0}}return a(t,r)}}}function i(e){return e.endsWith(`.json`)?`json`:e.endsWith(`.ts`)||e.endsWith(`.mts`)?`module-typescript`:`module`}function a(e,t,n,r){if(typeof n!=`function`)throw TypeError(`[env-runner] virtual TypeScript module "${e}" requires \`module.stripTypeScriptTypes\` ${r.requirement}; ${r.remedy} or provide a pre-transpiled JavaScript source instead.`);return n(t)}function o(e,t){let n=[t],r=new Set(n);for(let t of n){let i=[`"${t}"`,`'${t}'`,"`"+t+"`"];for(let[t,a]of Object.entries(e))!r.has(t)&&i.some(e=>a.includes(e))&&(r.add(t),n.push(t))}return n}function s(e){let t=e.indexOf(`?`);return t===-1?e:e.slice(0,t)}function c(){return e(process.cwd()+`/`).href}export{i as a,a as i,o as n,t as r,r as t};
@@ -1,20 +0,0 @@
1
- import{a as e,t}from"./chunk-BHKSVoKr.js";import{c as n,d as r,f as i,l as a,p as o,s,u as c}from"./dist-CttsoN4D.js";import{D as l,E as u,T as d,a as f,c as p,f as m,i as h,l as g,p as _,s as v}from"./dist-BYo8Gno2.js";import{G as y,Y as ee,b as te,d as ne,g as re,n as ie,o as ae,v as oe}from"./dist-CSfKNxQW.js";import{getStepFunction as se}from"../../@workflow/core/private.js";import{types as ce}from"node:util";import{AsyncLocalStorage as le}from"node:async_hooks";function ue(e,t){let n=Error.captureStackTrace;n?.(e,t)}const de=(()=>{let e=globalThis.process;return e?.env?e.env.FORCE_COLOR&&e.env.FORCE_COLOR!==`0`?!0:e.env.NO_COLOR?!1:!!e.stdout?.isTTY:!1})(),b=(e,t)=>n=>de?`\x1b[${e}m${n}\x1b[${t}m`:n,x={bold:b(1,22),dim:b(2,22),italic:b(3,23),red:b(31,39),blue:b(34,39),cyan:b(36,39),yellow:b(33,39),magenta:b(35,39)},fe={info:x.blue,help:x.cyan,warn:x.yellow,error:x.red};function pe(e){let t=Array.isArray(e)?e.join(`
2
- `):e;return fe.info(`${x.bold(`hint:`)} ${t}`)}function me(e){return fe.info(`${x.bold(`docs:`)} ${e}`)}function he(e){return x.italic(`${x.dim("`")}${e}${x.dim("`")}`)}function S(e){return x.dim(e)}function ge(e){return x.bold(e)}function _e(e){return x.red(e)}function ve(e){return x.magenta(e)}function ye(e,t){let n=[e];return t.forEach((e,r)=>{let i=e.split(`
3
- `),a=r===t.length-1,o=a?`╰▶ `:`├▶ `,s=a?` `:`│ `,c=i.map((e,t)=>`${t===0?o:s}${e}`);n.push(...c)}),n.join(`
4
- `)}const be=Symbol.for(`nodejs.util.inspect.custom`);function xe(e){return`code`in e?`\`${e.code}\``:`dim`in e?e.dim:e.text}function Se(e){return`code`in e?he(e.code):`dim`in e?S(e.dim):e.text}function Ce(e){return e.type===`docs`?`docs: ${e.url}`:e.segments.map(xe).join(``)}function we(e){return e.type===`docs`?me(e.url):e.segments.map(Se).join(``)}function Te(e){let t=[e.title.map(xe).join(``)];return e.details.forEach((n,r)=>{let i=r===e.details.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;Ce(n).split(`
5
- `).forEach((e,n)=>t.push(`${n===0?a:o}${e}`))}),t.join(`
6
- `)}function Ee(e){return ye(e.title.map(Se).join(``),e.details.map(we))}var De=class extends Error{fatal=!0;#e;constructor(e){super(Te(e)),this.#e=e}[be](){let e=Ee(this.#e),t=this.message.split(`
7
- `).length,n=(this.stack??``).split(`
8
- `).slice(t).join(`
9
- `);return n?`${this.name}: ${e}\n${n}`:`${this.name}: ${e}`}toString(){return`${this.name}: ${Ee(this.#e)}`}},Oe=class extends De{name=`NotInWorkflowContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow function`}],details:[{type:`docs`,url:t}]})}},ke=class extends De{name=`NotInStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a step function`}],details:[{type:`docs`,url:t}]})}},Ae=class extends De{name=`NotInWorkflowOrStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow or step function`}],details:[{type:`docs`,url:t}]})}};const je=Symbol.for(`WORKFLOW_CONTEXT`);function Me(){let e=globalThis[je];if(!e){let e=new Ae(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`);throw ue(e,Me),e}return e}var Ne=class extends De{name=`UnavailableInWorkflowContextError`;constructor(e,t){let n=globalThis[je]?.workflowName,r=(()=>{if(!n)return null;let e=n.match(/^(workflow\/|step\/)(.*)$/);return e?[{dim:e[1]},{text:e[2]}]:[{text:n}]})(),i=r?{type:`plain`,segments:[{text:`this call was made from the `},...r,{text:` workflow context.`}]}:{type:`plain`,segments:[{text:`this call was made from a workflow context.`}]};super({title:[{code:e},{text:` cannot be called from a workflow context.`}],details:[{type:`plain`,segments:[{text:`calling this in a workflow context can cause determinism issues.`}]},i,{type:`docs`,url:t}]})}};function Pe(e,t,n){let r=new Oe(e,t);throw ue(r,n),r}function Fe(e,t,n){let r=new ke(e,t);throw ue(r,n),r}function Ie(e,t,n){let r=new Ae(e,t);throw ue(r,n),r}function Le(e,t,n){let r=new Ne(e,t);throw ue(r,n),r}var Re=t(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),ze=t(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),Be=t(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=Re(),a=ze();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),Ve=t(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),He=t(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),C=t(((e,t)=>{let n=ze(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=Re(),{safeRe:a,t:o}=Be(),s=Ve(),{compareIdentifiers:c}=He();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),Ue=t(((e,t)=>{let n=C();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),We=t(((e,t)=>{let n=Ue();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),Ge=t(((e,t)=>{let n=Ue();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),Ke=t(((e,t)=>{let n=C();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),qe=t(((e,t)=>{let n=Ue();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),Je=t(((e,t)=>{let n=C();t.exports=(e,t)=>new n(e,t).major})),Ye=t(((e,t)=>{let n=C();t.exports=(e,t)=>new n(e,t).minor})),Xe=t(((e,t)=>{let n=C();t.exports=(e,t)=>new n(e,t).patch})),Ze=t(((e,t)=>{let n=Ue();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),w=t(((e,t)=>{let n=C();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Qe=t(((e,t)=>{let n=w();t.exports=(e,t,r)=>n(t,e,r)})),$e=t(((e,t)=>{let n=w();t.exports=(e,t)=>n(e,t,!0)})),et=t(((e,t)=>{let n=C();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),tt=t(((e,t)=>{let n=et();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),nt=t(((e,t)=>{let n=et();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),rt=t(((e,t)=>{let n=w();t.exports=(e,t,r)=>n(e,t,r)>0})),it=t(((e,t)=>{let n=w();t.exports=(e,t,r)=>n(e,t,r)<0})),at=t(((e,t)=>{let n=w();t.exports=(e,t,r)=>n(e,t,r)===0})),ot=t(((e,t)=>{let n=w();t.exports=(e,t,r)=>n(e,t,r)!==0})),st=t(((e,t)=>{let n=w();t.exports=(e,t,r)=>n(e,t,r)>=0})),ct=t(((e,t)=>{let n=w();t.exports=(e,t,r)=>n(e,t,r)<=0})),lt=t(((e,t)=>{let n=at(),r=ot(),i=rt(),a=st(),o=it(),s=ct();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),ut=t(((e,t)=>{let n=C(),r=Ue(),{safeRe:i,t:a}=Be();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),dt=t(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),T=t(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,ce(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>se(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let ee=[..._.values()];return r.set(t,ee),ee}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(le(this.set[t],e,this.options))return!0;return!1}};let r=new(dt()),i=Ve(),a=ft(),o=ze(),s=C(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=Be(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=Re(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=ne(e,t),o(`caret`,e),e=ee(e,t),o(`tildes`,e),e=ie(e,t),o(`xrange`,e),e=oe(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,ee=(e,t)=>e.trim().split(/\s+/).map(e=>te(e,t)).join(` `),te=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},ne=(e,t)=>e.trim().split(/\s+/).map(e=>re(e,t)).join(` `),re=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},ie=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>ae(e,t)).join(` `)),ae=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},oe=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),se=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),ce=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),le=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),ft=t(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=Ve(),{safeRe:i,t:a}=Be(),o=lt(),s=ze(),c=C(),l=T()})),pt=t(((e,t)=>{let n=T();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),mt=t(((e,t)=>{let n=T();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),ht=t(((e,t)=>{let n=C(),r=T();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),gt=t(((e,t)=>{let n=C(),r=T();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),_t=t(((e,t)=>{let n=C(),r=T(),i=rt();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),vt=t(((e,t)=>{let n=T();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),yt=t(((e,t)=>{let n=C(),r=ft(),{ANY:i}=r,a=T(),o=pt(),s=rt(),c=it(),l=ct(),u=st();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),bt=t(((e,t)=>{let n=yt();t.exports=(e,t,r)=>n(e,t,`>`,r)})),xt=t(((e,t)=>{let n=yt();t.exports=(e,t,r)=>n(e,t,`<`,r)})),St=t(((e,t)=>{let n=T();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),Ct=t(((e,t)=>{let n=pt(),r=w();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),wt=t(((e,t)=>{let n=T(),r=ft(),{ANY:i}=r,a=pt(),o=w(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),Tt=t(((e,t)=>{let n=Be(),r=Re(),i=C(),a=He();t.exports={parse:Ue(),valid:We(),clean:Ge(),inc:Ke(),diff:qe(),major:Je(),minor:Ye(),patch:Xe(),prerelease:Ze(),compare:w(),rcompare:Qe(),compareLoose:$e(),compareBuild:et(),sort:tt(),rsort:nt(),gt:rt(),lt:it(),eq:at(),neq:ot(),gte:st(),lte:ct(),cmp:lt(),coerce:ut(),Comparator:ft(),Range:T(),satisfies:pt(),toComparators:mt(),maxSatisfying:ht(),minSatisfying:gt(),minVersion:_t(),validRange:vt(),outside:yt(),gtr:bt(),ltr:xt(),intersects:St(),simplifyRange:Ct(),subset:wt(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}));function Et(e){return new Uint8Array(e).toBase64()}function Dt(e){return Uint8Array.fromBase64(e).buffer}function Ot(e){return Buffer.from(e).toString(`base64`)}function kt(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function At(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function jt(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}const Mt=typeof Uint8Array.fromBase64==`function`,Nt=typeof process==`object`&&process.versions?.node!==void 0,Pt=Mt?Et:Nt?Ot:At,Ft=Mt?Dt:Nt?kt:jt,It=2**32-1,Lt=It-1;var E=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}};function Rt(e){return e===null||typeof e!=`object`&&typeof e!=`function`}const zt=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function Bt(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===zt}function Vt(e){return Object.prototype.toString.call(e).slice(8,-1)}function Ht(e){switch(e){case`"`:return`\\"`;case`<`:return`\\u003C`;case`\\`:return`\\\\`;case`
10
- `:return`\\n`;case`\r`:return`\\r`;case` `:return`\\t`;case`\b`:return`\\b`;case`\f`:return`\\f`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:return e<` `?`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}function D(e){let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let r=e[i],a=Ht(r);a&&(t+=e.slice(n,i)+a,n=i+1)}return`"${n===0?e:t+e.slice(n)}"`}function Ut(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)}const Wt=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function Gt(e){return Wt.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function Kt(e){return!(!Number.isInteger(e)||e<0||e>Lt)}function qt(e){return!(!Number.isInteger(e)||e<0||e>It)}function Jt(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return Kt(+e)}function Yt(e){let t=Object.keys(e);for(var n=t.length-1;n>=0&&!Jt(t[n]);n--);return t.length=n+1,t}function Xt(e,t){return Zt(JSON.parse(e),t)}function Zt(e,t){if(typeof e==`number`)return a(e,!0);if(!Array.isArray(e)||e.length===0)throw Error(`Invalid input`);let n=e,r=Array(n.length),i=null;function a(e,o=!1){if(e===-1)return;if(e===-3)return NaN;if(e===-4)return 1/0;if(e===-5)return-1/0;if(e===-6)return-0;if(o||typeof e!=`number`)throw Error(`Invalid input`);if(e in r)return r[e];let s=n[e];if(!s||typeof s!=`object`)r[e]=s;else if(Array.isArray(s))if(typeof s[0]==`string`){let o=s[0],c=t&&Object.hasOwn(t,o)?t[o]:void 0;if(c){let t=s[1];if(typeof t!=`number`&&(t=n.push(s[1])-1),i??=new Set,i.has(t))throw Error(`Invalid circular reference`);return i.add(t),r[e]=c(a(t)),i.delete(t),r[e]}switch(o){case`Date`:r[e]=new Date(s[1]);break;case`Set`:let t=new Set;r[e]=t;for(let e=1;e<s.length;e+=1)t.add(a(s[e]));break;case`Map`:let i=new Map;r[e]=i;for(let e=1;e<s.length;e+=2)i.set(a(s[e]),a(s[e+1]));break;case`RegExp`:r[e]=new RegExp(s[1],s[2]);break;case`Object`:{let t=s[1];if(typeof n[t]==`object`&&n[t][0]!==`BigInt`)throw Error(`Invalid input`);r[e]=Object(a(t));break}case`BigInt`:r[e]=BigInt(s[1]);break;case`null`:let c=Object.create(null);r[e]=c;for(let e=1;e<s.length;e+=2){if(s[e]===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");c[s[e]]=a(s[e+1])}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{if(n[s[1]][0]!==`ArrayBuffer`)throw Error(`Invalid data`);let t=globalThis[o],i=a(s[1]);r[e]=s[2]===void 0?new t(i):new t(i,s[2],s[3]);break}case`ArrayBuffer`:{let t=s[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);r[e]=Ft(t);break}case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:{let t=o.slice(9);r[e]=Temporal[t].from(s[1]);break}case`URL`:r[e]=new URL(s[1]);break;case`URLSearchParams`:r[e]=new URLSearchParams(s[1]);break;default:throw Error(`Unknown type ${o}`)}}else if(s[0]===-7){let t=s[1];if(!qt(t))throw Error(`Invalid input`);let n=[];r[e]=n,n[Lt]=void 0,delete n[Lt];for(let e=2;e<s.length;e+=2){let r=s[e];if(!Kt(r)||r>=t)throw Error(`Invalid input`);n[r]=a(s[e+1])}n.length=t}else{let t=Array(s.length);r[e]=t;for(let e=0;e<s.length;e+=1){let n=s[e];n!==-2&&(t[e]=a(n))}}else{let t={};r[e]=t;for(let e of Object.keys(s)){if(e===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");let n=s[e];t[e]=a(n)}}return r[e]}return a(0)}function O(e,t){let n=Qt(!1,e,t);return typeof n==`string`?n:`[${n.join(`,`)}]`}function Qt(e,t,n){let r=[],i=new Map,a=[];if(n)for(let e of Object.getOwnPropertyNames(n))a.push({key:e,fn:n[e]});let o=[],s=0;function c(n,l){if(n===void 0)return-1;if(Number.isNaN(n))return-3;if(n===1/0)return-4;if(n===-1/0)return-5;if(n===0&&1/n<0)return-6;if(i.has(n))return i.get(n);l??=s++,i.set(n,l);for(let{key:e,fn:t}of a){let i=t(n);if(i)return r[l]=`["${e}",${c(i)}]`,l}if(typeof n==`function`)throw new E(`Cannot stringify a function`,o,n,t);if(typeof n==`symbol`)throw new E(`Cannot stringify a Symbol primitive`,o,n,t);let u=``;if(Rt(n))u=$t(n);else if(typeof n.then==`function`){if(!e)throw new E(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,o,n,t);u=Promise.resolve(n).then(e=>{let t=c(e,l);t<0&&(r[l]=t)})}else{let e=Vt(n);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:u=`["Object",${c(n.valueOf())}]`;break;case`Date`:u=`["Date","${isNaN(n.getDate())?``:n.toISOString()}"]`;break;case`URL`:u=`["URL",${D(n.toString())}]`;break;case`URLSearchParams`:u=`["URLSearchParams",${D(n.toString())}]`;break;case`RegExp`:let{source:r,flags:i}=n;u=i?`["RegExp",${D(r)},"${i}"]`:`["RegExp",${D(r)}]`;break;case`Array`:{let e=!1;u=`[`;for(let t=0;t<n.length;t+=1)if(t>0&&(u+=`,`),Object.hasOwn(n,t))o.push(`[${t}]`),u+=c(n[t]),o.pop();else if(e)u+=-2;else{let t=Yt(n),r=t.length,i=String(n.length).length;if((n.length-r)*3>4+i+r*(i+1)){u=`[-7,`+n.length;for(let e=0;e<t.length;e++){let r=t[e];o.push(`[${r}]`),u+=`,`+r+`,`+c(n[r]),o.pop()}break}else e=!0,u+=-2}u+=`]`;break}case`Set`:u=`["Set"`;for(let e of n)u+=`,${c(e)}`;u+=`]`;break;case`Map`:u=`["Map"`;for(let[e,t]of n)o.push(`.get(${Rt(e)?$t(e):`...`})`),u+=`,${c(e)},${c(t)}`,o.pop();u+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{let t=n;u=`["`+e+`",`+c(t.buffer),t.byteLength!==t.buffer.byteLength&&(u+=`,${t.byteOffset},${t.length}`),u+=`]`;break}case`ArrayBuffer`:u=`["ArrayBuffer","${Pt(n)}"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:u=`["${e}",${D(n.toString())}]`;break;default:if(!Bt(n))throw new E(`Cannot stringify arbitrary non-POJOs`,o,n,t);if(Ut(n).length>0)throw new E(`Cannot stringify POJOs with symbolic keys`,o,n,t);if(Object.getPrototypeOf(n)===null){u=`["null"`;for(let e of Object.keys(n)){if(e===`__proto__`)throw new E(`Cannot stringify objects with __proto__ keys`,o,n,t);o.push(Gt(e)),u+=`,${D(e)},${c(n[e])}`,o.pop()}u+=`]`}else{u=`{`;let e=!1;for(let r of Object.keys(n)){if(r===`__proto__`)throw new E(`Cannot stringify objects with __proto__ keys`,o,n,t);e&&(u+=`,`),e=!0,o.push(Gt(r)),u+=`${D(r)}:${c(n[r])}`,o.pop()}u+=`}`}}}return r[l]=u,l}let l=c(t);return l<0?`${l}`:r}function $t(e){let t=typeof e;return t===`string`?D(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`["BigInt","${e}"]`:String(e)}var en=e(Tt(),1);async function tn(e,t=[`encrypt`,`decrypt`]){if(e.byteLength!==32)throw new d(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,t)}async function nn(e,t){let n=globalThis.crypto.getRandomValues(new Uint8Array(12)),r;try{r=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:n,tagLength:128},e,t)}catch(e){throw new m(`AES-256-GCM encryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`encrypt`,byteLength:t.byteLength}})}let i=new Uint8Array(12+r.byteLength);return i.set(n,0),i.set(new Uint8Array(r),12),i}async function rn(e,t){if(t.byteLength<28)throw new m(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let n=t.subarray(0,12),r=t.subarray(12),i;try{i=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:n,tagLength:128},e,r)}catch(e){throw new m(`AES-256-GCM decryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return new Uint8Array(i)}const an=()=>te(`WORKFLOW_LOCK_POLL_INTERVAL_MS`,10,{integer:!0,min:1});function k(){let e={...n(),pendingOps:0,doneResolved:!1,streamEnded:!1};return e.promise.catch(()=>{}),e}function on(e){if(e.locked)return!1;let t;try{t=e.getWriter()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function sn(e){if(e.locked)return!1;let t;try{t=e.getReader()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function cn(e,t){if(t.writablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.writablePollingInterval=void 0;return}on(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.writablePollingInterval=void 0)},an());t.writablePollingInterval=n}function ln(e,t){if(t.readablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.readablePollingInterval=void 0;return}sn(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.readablePollingInterval=void 0)},an());t.readablePollingInterval=n}async function A(e,t,n){let r=e.getReader(),i=t.getWriter(),a;try{for(;;){if(n.streamEnded)return;let e=await Promise.race([r.read(),i.closed.then(()=>{throw new d(`Writable stream closed prematurely`)})]);if(n.streamEnded)return;if(e.done){n.streamEnded=!0,await i.close(),n.doneResolved||(n.doneResolved=!0,n.resolve());return}n.pendingOps++;try{await i.write(e.value)}finally{n.pendingOps--}}}catch(e){throw n.streamEnded=!0,a=e,n.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{r.cancel(a).catch(()=>{}),r.releaseLock(),i.releaseLock()}}function un(e){if(e.specVersion!==5)throw new d(`This Workflow runtime requires a World with matching spec version 5, but the configured World declares spec version ${e.specVersion??`none`}. Install a World package version compatible with the current Workflow runtime.`)}const dn=Symbol.for(`@workflow/world//cache`),fn=Symbol.for(`@workflow/world//cachePromise`),pn=Symbol.for(`@workflow/world//getWorldFn`);async function j(){let e=globalThis;if(e[dn])return un(e[dn]),e[dn];if(e[fn])return e[dn]=await e[fn],un(e[dn]),e[dn];let t=e[pn];if(t){let e=await t();return un(e),e}throw Error("Workflow world runtime was not initialized. Import from the host workflow entrypoints (`workflow`, `workflow/api`, or `workflow/runtime`) so @workflow/core/runtime/world-init can register getWorld before getWorldLazy() is used.")}const mn=Symbol.for(`workflow-serialize`),hn=Symbol.for(`workflow-deserialize`),gn=Symbol.for(`WORKFLOW_USE_STEP`),_n=Symbol.for(`WORKFLOW_SET_ATTRIBUTES`),vn=Symbol.for(`WORKFLOW_CREATE_HOOK`),yn=Symbol.for(`WORKFLOW_SLEEP`),bn=Symbol.for(`WORKFLOW_GET_STREAM_ID`),xn=Symbol.for(`WORKFLOW_STABLE_ULID`),M=Symbol.for(`WORKFLOW_STREAM_NAME`),Sn=Symbol.for(`WORKFLOW_STREAM_TYPE`),Cn=Symbol.for(`WORKFLOW_STREAM_FRAMING`),N=Symbol.for(`WORKFLOW_STREAM_SERVER_RUN_ID`),P=Symbol.for(`WORKFLOW_STREAM_SERVER_DEPLOYMENT_ID`),wn=Symbol.for(`BODY_INIT`),Tn=Symbol.for(`WEBHOOK_RESPONSE_WRITABLE`),En=Symbol.for(`workflow-class-registry`),F=Symbol.for(`WORKFLOW_ABORT_STREAM_NAME`),I=Symbol.for(`WORKFLOW_ABORT_HOOK_TOKEN`),Dn=Symbol.for(`WORKFLOW_ABORT_LISTENER_ATTACHED`),On=Symbol.for(`WORKFLOW_ABORT_READER_CANCEL`);function kn(e=globalThis){let t=e,n=t[En];return n||(n=new Map,t[En]=n),n}const An=`class//workflow//Run`;function jn(e,t,n=globalThis){kn(n).set(e,t)}function Mn(e,t){return kn(t).get(e)}function Nn(){return{Class:e=>{if(typeof e!=`function`)return!1;let t=e.classId;return typeof t==`string`?{classId:t}:!1},Instance:e=>{if(typeof e!=`object`||!e)return!1;let t=e.constructor;if(!t||typeof t!=`function`)return!1;let n=t[mn];if(typeof n!=`function`)return!1;let r=t.classId;if(typeof r!=`string`)throw Error(`Class "${t.name}" with ${String(mn)} must have a static "classId" property.`);return{classId:r,data:n.call(t,e)}}}}function Pn(e=globalThis){return{Class:t=>{let n=t.classId,r=Mn(n,e);if(!r)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);return r},Instance:t=>{let n=t.classId,r=t.data,i=Mn(n,e);if(!i)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);let a=i[hn];if(typeof a!=`function`)throw Error(`Class "${n}" does not have a static ${String(hn)} method.`);return a.call(i,r)}}}function Fn(e,t,n){if(n===0)return`.`;let r=new Uint8Array(e,t,n);return Buffer.from(r).toString(`base64`)}function L(e){return Fn(e.buffer,e.byteOffset,e.byteLength)}function R(e,t){let n=e===`.`?``:e,r=Buffer.from(n,`base64`),i=new t.ArrayBuffer(r.length);return new t.Uint8Array(i).set(r),i}function In(e){return JSON.parse(e)}function Ln(e){if(!ce.isNativeError(e))return!1;let t={message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t}function Rn(e,t){return!ce.isNativeError(t)||t.name!==e?!1:Ln(t)}function z(e){return t=>Rn(e,t)||!1}function B(e,t){return n=>{let r=n,i=`cause`in r?{cause:r.cause}:void 0,a=e[t],o=new a(r.message,i);return r.stack!==void 0&&(o.stack=r.stack),o}}function zn(e=globalThis){return{ArrayBuffer:t=>t instanceof e.ArrayBuffer&&Fn(t,0,t.byteLength),BigInt:e=>typeof e==`bigint`&&e.toString(),BigInt64Array:t=>t instanceof e.BigInt64Array&&L(t),BigUint64Array:t=>t instanceof e.BigUint64Array&&L(t),Date:t=>t instanceof e.Date?Number.isNaN(t.getDate())?`.`:t.toISOString():!1,DOMException:e=>{if(typeof e!=`object`||!e||e.constructor?.name!==`DOMException`)return!1;let t=e,n={message:t.message,name:t.name,stack:t.stack};return`cause`in t&&(n.cause=t.cause),n},EvalError:z(`EvalError`),FatalError:z(`FatalError`),HookConflictError:e=>{let t=Rn(`HookConflictError`,e);if(!t)return!1;let n=e,r={...t,token:n.token};return n.conflictingRunId!==void 0&&(r.conflictingRunId=n.conflictingRunId),r},RangeError:z(`RangeError`),ReferenceError:z(`ReferenceError`),RetryableError:e=>{let t=Rn(`RetryableError`,e);if(!t)return!1;let n=e.retryAfter,r;if(n&&typeof n==`object`&&typeof n.getTime==`function`){let e=n.getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else if(typeof n==`string`||typeof n==`number`){let e=new Date(n).getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else r=Date.now()+1e3;return{...t,retryAfter:r}},RuntimeDecryptionError:e=>{let t=Rn(`RuntimeDecryptionError`,e);if(!t)return!1;let n={...t},r=e.context;return r!==void 0&&(n.context=r),n},SyntaxError:z(`SyntaxError`),TypeError:z(`TypeError`),URIError:z(`URIError`),AggregateError:e=>{let t=Rn(`AggregateError`,e);return t?{...t,errors:e.errors}:!1},Error:e=>{if(!ce.isNativeError(e))return!1;let t={name:e.name,message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t},Float32Array:t=>t instanceof e.Float32Array&&L(t),Float64Array:t=>t instanceof e.Float64Array&&L(t),Headers:t=>t instanceof e.Headers&&Array.from(t),Int8Array:t=>t instanceof e.Int8Array&&L(t),Int16Array:t=>t instanceof e.Int16Array&&L(t),Int32Array:t=>t instanceof e.Int32Array&&L(t),Map:t=>t instanceof e.Map&&Array.from(t),RegExp:t=>t instanceof e.RegExp&&{source:t.source,flags:t.flags},Set:t=>t instanceof e.Set&&Array.from(t),URL:t=>t instanceof e.URL&&t.href,WorkflowFunction:e=>{if(typeof e!=`function`)return!1;let t=e.workflowId;return typeof t==`string`?{workflowId:t}:!1},URLSearchParams:t=>t instanceof e.URLSearchParams?t.size===0?`.`:String(t):!1,Uint8Array:t=>t instanceof e.Uint8Array&&L(t),Uint8ClampedArray:t=>t instanceof e.Uint8ClampedArray&&L(t),Uint16Array:t=>t instanceof e.Uint16Array&&L(t),Uint32Array:t=>t instanceof e.Uint32Array&&L(t)}}function Bn(e=globalThis){return{ArrayBuffer:t=>R(t,e),BigInt:t=>e.BigInt(t),BigInt64Array:t=>new e.BigInt64Array(R(t,e)),BigUint64Array:t=>new e.BigUint64Array(R(t,e)),Date:t=>new e.Date(t),DOMException:t=>{let n=new e.DOMException(t.message,t.name);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},EvalError:B(e,`EvalError`),FatalError:t=>{let n=new(e[Symbol.for(`@workflow/errors//FatalError`)]??h)(t.message);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},HookConflictError:t=>{let n=new(e[Symbol.for(`@workflow/errors//HookConflictError`)]??f)(t.token,t.conflictingRunId);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RangeError:B(e,`RangeError`),ReferenceError:B(e,`ReferenceError`),RetryableError:t=>{let n=new(e[Symbol.for(`@workflow/errors//RetryableError`)]??g)(t.message,{retryAfter:new e.Date(t.retryAfter)});return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RuntimeDecryptionError:t=>{let n=e[Symbol.for(`@workflow/errors//RuntimeDecryptionError`)]??m,r={};`cause`in t&&(r.cause=t.cause),t.context!==void 0&&(r.context=t.context);let i=new n(t.message,r);return t.stack!==void 0&&(i.stack=t.stack),i},SyntaxError:B(e,`SyntaxError`),TypeError:B(e,`TypeError`),URIError:B(e,`URIError`),AggregateError:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.AggregateError(t.errors,t.message,n);return t.stack!==void 0&&(r.stack=t.stack),r},Error:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.Error(t.message,n);return r.name=t.name,t.stack!==void 0&&(r.stack=t.stack),r},Float32Array:t=>new e.Float32Array(R(t,e)),Float64Array:t=>new e.Float64Array(R(t,e)),Headers:t=>new e.Headers(t),Int8Array:t=>new e.Int8Array(R(t,e)),Int16Array:t=>new e.Int16Array(R(t,e)),Int32Array:t=>new e.Int32Array(R(t,e)),Map:t=>new e.Map(t),RegExp:t=>new e.RegExp(t.source,t.flags),Set:t=>new e.Set(t),URL:t=>new e.URL(t),WorkflowFunction:e=>Object.assign(()=>{throw Error(`Workflow functions cannot be called directly. Use start() to invoke them.`)},{workflowId:e.workflowId}),URLSearchParams:t=>new e.URLSearchParams(t===`.`?``:t),Uint8Array:t=>new e.Uint8Array(R(t,e)),Uint8ClampedArray:t=>new e.Uint8ClampedArray(R(t,e)),Uint16Array:t=>new e.Uint16Array(R(t,e)),Uint32Array:t=>new e.Uint32Array(R(t,e))}}function Vn(){return{StepFunction:e=>{if(typeof e!=`function`)return!1;let t=e.stepId;if(typeof t!=`string`)return!1;let n=e.__closureVarsFn,r=n&&typeof n==`function`?n():void 0,i=`__boundThis`in e,a=i?e.__boundThis:void 0,o=e.__boundArgs,s={stepId:t};return r!==void 0&&(s.closureVars=r),i&&(s.boundThis=a),Array.isArray(o)&&o.length>0&&(s.boundArgs=o),s}}}function Hn(e=globalThis){let t=e[Symbol.for(`WORKFLOW_USE_STEP`)];return{StepFunction:e=>{let n=e.stepId,r=e.closureVars;if(!t)throw Error(`WORKFLOW_USE_STEP not found on global object. Step functions cannot be deserialized outside workflow context.`);let i=r?t(n,()=>r):t(n);if(`boundThis`in e){let t=Array.isArray(e.boundArgs)?e.boundArgs:[];return i.bind(e.boundThis,...t)}return i}}}function Un(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const V={DEVALUE_V1:`devl`,ENCRYPTED:`encr`,GZIP:`gzip`,ZSTD:`zstd`},Wn=new TextEncoder,Gn=new TextDecoder;function Kn(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Nn(),...Vn(),...zn(t)};break;case`step`:r={...Nn(),...zn(t)};break;case`client`:r={...Nn(),...zn(t)};break}return n?{...r,...n}:r}function qn(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Pn(t),...Hn(t),...Bn(t)};break;case`step`:r={...Pn(t),...Bn(t)};break;case`client`:r={...Pn(t),...Bn(t),StepFunction:()=>{throw Error(`Step functions cannot be deserialized in client context.`)}};break}return n?{...r,...n}:r}const H={formatPrefix:V.DEVALUE_V1,serialize(e,t,n){let r=O(e,Kn(t,n?.global,n?.extraReducers));return Wn.encode(r)},deserialize(e,t,n){let r=qn(t,n?.global,n?.extraRevivers);return Xt(Gn.decode(e),r)},deserializeLegacy(e,t,n){return Zt(e,qn(t,n?.global,n?.extraRevivers))}},Jn=new TextEncoder,Yn=new TextDecoder;function U(e,t){if(!(t instanceof Uint8Array))return t;let n=Jn.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function Xn(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=Yn.decode(t);return Un(n)?n:null}function W(e){if(!(e instanceof Uint8Array))return{format:V.DEVALUE_V1,payload:new TextEncoder().encode(JSON.stringify(e))};if(e.length<4)throw Error(`Data too short to contain format prefix: expected at least 4 bytes, got ${e.length}`);let t=e.subarray(0,4),n=Yn.decode(t);if(!Un(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}function Zn(){try{return typeof process<`u`&&process.env?.WORKFLOW_DISABLE_COMPRESSION===`1`}catch{return!1}}function Qn(){try{let e=process.env?.WORKFLOW_COMPRESSION_CODEC;return e===`gzip`||e===`zstd`?e:void 0}catch{return}}function $n(){try{return globalThis.process?.getBuiltinModule?.(`node:zlib`)}catch{return}}function er(){let e=$n();return typeof e?.zstdCompressSync==`function`&&typeof e?.zstdDecompressSync==`function`}function tr(){return typeof CompressionStream==`function`&&typeof DecompressionStream==`function`}async function nr(e,t){let n=t.writable.getWriter(),r=n.write(e).then(()=>n.close());r.catch(()=>{});let i=[],a=0,o=t.readable.getReader();for(;;){let{done:e,value:t}=await o.read();if(e)break;i.push(t),a+=t.length}await r;let s=new Uint8Array(a),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function rr(e){return nr(e,new CompressionStream(`gzip`))}async function ir(e){return nr(e,new DecompressionStream(`gzip`))}function ar(e){let t=$n(),n=t?.constants?.ZSTD_c_compressionLevel,r=n===void 0?void 0:{params:{[n]:3}};return new Uint8Array(t.zstdCompressSync(e,r))}function or(e){let t=$n();if(!t?.zstdDecompressSync)throw Error(`Compressed (zstd) workflow data encountered but node:zlib zstd support is not available in this runtime (requires Node.js 22.15+). In the browser, register a zstd decoder via registerZstdDecoder (serialization-format.ts).`);return new Uint8Array(t.zstdDecompressSync(e))}function G(e,t,n,r){e&&(e.recorded=!0,e.compressed=t!==`none`,e.codec=t,e.uncompressedBytes=n,e.storedBytes=r)}function sr(){return Qn()===`gzip`?tr()?`gzip`:`none`:er()?`zstd`:tr()?`gzip`:`none`}async function cr(e,t,n){if(!(e instanceof Uint8Array))return e;if(!t||e.length<1024||Zn())return G(n,`none`,e.length,e.length),e;let r=sr();if(r===`none`)return G(n,`none`,e.length,e.length),e;let i=r===`zstd`?ar(e):await rr(e),a=r===`zstd`?V.ZSTD:V.GZIP,o=4+i.length;return o>=e.length*.95?(G(n,`none`,e.length,e.length),e):(G(n,r,e.length,o),U(a,i))}async function lr(e,t){if(!(e instanceof Uint8Array))return e;let n=Xn(e);if(n===V.ZSTD){let{payload:n}=W(e),r=or(n);return G(t,`zstd`,r.length,e.length),r}if(n===V.GZIP){if(!tr())throw Error(`Compressed (gzip) workflow data encountered but DecompressionStream is not available in this runtime. Node.js 18+, browsers, and edge runtimes all support it.`);let{payload:n}=W(e),r=await ir(n);return G(t,`gzip`,r.length,e.length),r}return G(t,`none`,e.length,e.length),e}async function ur(e){return typeof e==`function`?e():e}async function dr(e,t){if(!t||!(e instanceof Uint8Array))return e;let n=await nn(t,e);return U(V.ENCRYPTED,n)}async function fr(e,t){if(!(e instanceof Uint8Array))return e;let n=Xn(e);if(n===V.ENCRYPTED&&!t)throw new m(`Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encr`}});if(n!==V.ENCRYPTED)return e;let{payload:r}=W(e);try{return await rn(t,r)}catch(e){throw m.is(e)&&e.context&&(e.context.formatPrefix=n),e}}function pr(e,t,n){let[r,...i]=t.split(`
11
- `),a=i.join(`
12
- `),o=mr(r??``,n),s=hr(a),c=[`${e} ${r??``}`];return o&&c.push(o),s&&c.push(s),c.join(`
13
- `)}function mr(e,t){if(!t||Object.keys(t).length===0)return null;let n=new Set;n.add(`errorStack`),typeof t.errorMessage==`string`&&e.includes(t.errorMessage)&&n.add(`errorMessage`);let i=new Set([`workflowRunId`,`workflowName`,`stepId`,`stepName`,`errorAttribution`,`errorCode`,`errorName`,`errorMessage`,`errorStack`,`hint`,`attempt`,`retryCount`]),a=[],o=K(t,`errorName`),s=K(t,`errorAttribution`);if(o||s){let e=s?s===`sdk`?ve(`sdk error`):_e(`user error`):``,t=o?ge(o):``,n=e&&t?S(` · `):``;a.push(` ${e}${n}${t}`)}let l=K(t,`workflowRunId`),u=K(t,`workflowName`);l?a.push(vr(`run`,l,u,r)):u&&a.push(vr(`run`,null,u,r));let d=K(t,`stepId`),f=K(t,`stepName`);if((d||f)&&a.push(vr(`step`,d,f,c)),t.attempt!==void 0||t.retryCount!==void 0){let e=t.attempt,n=t.retryCount;e!==void 0&&n!==void 0?a.push(` ${_r(`retry`)} ${e} ${S(`attempts ·`)} ${n} ${S(`max retries`)}`):e!==void 0&&a.push(` ${_r(`retry`)} ${e} ${S(`attempts`)}`)}let p=K(t,`errorCode`);p&&p!==o&&a.push(` ${_r(`code`)} ${S(p)}`);let m=K(t,`hint`);m&&a.push(` ${pe(m)}`);let h=Object.entries(t).filter(([e,t])=>!i.has(e)&&!n.has(e)&&t!=null).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of h)a.push(` ${_r(e)} ${yr(t)}`);return a.length?a.join(`
14
- `):null}function hr(e){if(!e)return null;let t=e.split(`
15
- `),n=[],r=0,i=0,a=0,o=()=>{r>0&&(n.push(S(` … ${r} more ${r===1?`frame`:`frames`} in framework internals`)),r=0)};for(let e of t){let t=e.trimStart().startsWith(`at `);if(t&&gr(e)){r++;continue}if(t&&i>=6){a++;continue}o(),n.push(e),t&&i++}return o(),a>0&&n.push(S(` … ${a} more ${a===1?`frame`:`frames`} (run \`pnpm wf inspect run <id>\` for the full stack)`)),n.join(`
16
- `)}function gr(e){let t=e.trimStart();return t.startsWith(`at `)?!!(t.includes(`node:internal/`)||t.includes(`node_modules/.pnpm/`)||t.includes(`node_modules__pnpm_`)||t.includes(`_next_dist_`)||t.includes(`node_modules/next/`)||t.includes(`node_modules/@opentelemetry/`)||t.includes(`node_modules/vitest/`)||t.includes(`node_modules/@vitest/`)):!1}function K(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function _r(e){return S(e.padEnd(6))}function vr(e,t,n,r){let a=t||S(`—`),s=n&&(e===`run`?o(n):i(n))?`${S(`·`)} ${r(n)}`:``;return` ${_r(e)} ${a}${s?` `+s:``}`}function yr(e){if(typeof e==`string`)return e.includes(`
17
- `)?e.split(`
18
- `).map((e,t)=>t===0?e:` ${e}`).join(`
19
- `):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var br=class e extends Error{steps;globalThis;stepCount;hookCount;waitCount;attributeCount;hookDisposedCount;abortCount;constructor(e,t){let n=[...e.values()],r=0,i=0,o=0,s=0,c=0,l=0;for(let e of n)e.type===`step`?r++:e.type===`hook`?e.disposed?c++:e.abortRequested?l++:i++:e.type===`wait`?o++:e.type===`attribute`&&s++;let u=[];r>0&&u.push(`${r} ${a(`step`,`steps`,r)}`),i>0&&u.push(`${i} ${a(`hook`,`hooks`,i)}`),o>0&&u.push(`${o} ${a(`wait`,`waits`,o)}`),s>0&&u.push(`${s} ${a(`attribute write`,`attribute writes`,s)}`),c>0&&u.push(`${c} hook ${a(`disposal`,`disposals`,c)}`);let d=a(`has`,`have`,r+i+o+s+c),f=+(r>0)+ +(i>0)+ +(o>0)+ +(s>0)+ +(c>0),p;p=f>1?`processed`:r>0?`run`:i>0||o>0?`created`:s>0?`written`:c>0?`processed`:`received`;let m=u.length>0?`${u.join(` and `)} ${d} not been ${p} yet`:`0 steps have not been run yet`;super(m),this.name=`WorkflowSuspension`,this.steps=n,this.globalThis=t,this.stepCount=r,this.hookCount=i,this.waitCount=o,this.attributeCount=s,this.hookDisposedCount=c,this.abortCount=l}static is(t){return t instanceof e}};function xr(){throw new d(`This API is not available inside a workflow function. Workflow functions run in a deterministic VM; move the call to a step function for full Node.js access.`)}function q(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const Sr=q(`workflow.name`),Cr=q(`workflow.operation`),wr=q(`workflow.run.id`),Tr=q(`workflow.run.status`),Er=q(`workflow.started_at`),Dr=q(`workflow.events.count`),Or=q(`workflow.arguments.count`),kr=q(`workflow.result.type`),Ar=q(`workflow.trace.propagated`),jr=q(`workflow.trace.mode`),Mr=q(`workflow.turbo`),Nr=q(`workflow.error.name`),Pr=q(`workflow.error.message`),Fr=q(`workflow.error.code`),Ir=q(`workflow.steps.created`),Lr=q(`workflow.hooks.created`),Rr=q(`workflow.waits.created`),zr=q(`workflow.inline_ownership.owned_recovery_steps`),Br=q(`workflow.inline_ownership.backstop_wakes_armed`),Vr=q(`workflow.route.type`),Hr=q(`workflow.route.handler_cached`),Ur=q(`workflow.route.invocation_count`),Wr=q(`workflow.route.entrypoint_age_ms`),Gr=q(`workflow.route.module_body_init_ms`),Kr=q(`step.name`),qr=q(`step.id`),Jr=q(`step.attempt`),Yr=q(`step.status`),Xr=q(`step.max_retries`),Zr=q(`step.ttfs_ms`),Qr=q(`step.stso_ms`),$r=q(`step.rsfs_ms`),ei=q(`step.final_scheduling_replay_ms`),ti=q(`step.latency_optimizations`),ni=q(`step.skipped`),ri=q(`step.skip_reason`),ii=q(`step.arguments.count`),ai=q(`step.result.type`),oi=q(`step.error.name`),si=q(`step.error.message`),ci=q(`step.fatal_error`),li=q(`step.retry.exhausted`),ui=q(`step.retry.timeout_seconds`),di=q(`step.retry.will_retry`),fi=q(`messaging.system`),pi=q(`messaging.destination.name`),mi=q(`messaging.message.id`),hi=q(`messaging.operation.type`),gi=q(`workflow.queue.overhead_ms`),_i=q(`deployment.id`),vi=q(`workflow.hook.token`),yi=q(`workflow.hook.id`),bi=q(`workflow.hook.found`),xi=q(`workflow.suspension.state`),Si=q(`workflow.suspension.hook_count`),Ci=q(`workflow.suspension.step_count`),wi=q(`workflow.suspension.wait_count`),Ti=q(`http.request.method`),Ei=q(`http.route`),Di=q(`http.response.status_code`),Oi=q(`error.type`),ki=q(`workflow.events.pages_loaded`),Ai=q(`workflow.queue.deserialize_time_ms`),ji=q(`workflow.queue.execution_time_ms`),Mi=q(`workflow.queue.serialize_time_ms`),Ni=q(`workflow.serialization.operation`),Pi=q(`workflow.serialization.compressed`),Fi=q(`workflow.serialization.codec`),Ii=q(`workflow.serialization.uncompressed_bytes`),Li=q(`workflow.serialization.stored_bytes`),Ri=q(`workflow.serialization.compression_ratio`),zi=q(`peer.service`),Bi=q(`rpc.system`),Vi=q(`rpc.service`),Hi=q(`rpc.method`),Ui=q(`error.retryable`),Wi=q(`error.category`),Gi=new Set;function Ki(){let e=process.env.WORKFLOW_TRACE_MODE;return e===`continuous`?`continuous`:(e&&e!==`linked`&&!Gi.has(e)&&(Gi.add(e),Y.warn(`Unrecognized WORKFLOW_TRACE_MODE value "${e}"; expected "linked" or "continuous". Falling back to "linked".`)),`linked`)}function qi(e){return e!==void 0&&Object.keys(e).length>0}function Ji(e,t){return e===`linked`&&qi(t)?Promise.resolve(t):Xi()}async function Yi(e,t){if(e!==`linked`)return la();let n=await ua(qi(t)?t:void 0);return n?[n]:void 0}async function Xi(){let e=await J.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function Zi(e){let t=await J.value;if(t)return t.propagation.extract(t.context.active(),e)}async function Qi(e,t){if(!e)return t();let n=await J.value;if(!n)return t();let r=await Zi(e);return r?n.context.with(r,async()=>await t()):t()}const J=s(async()=>{try{return await import(`./src-CQuMexnO.js`).then(t=>e(t.t(),1))}catch{return Y.info(`OpenTelemetry not available, tracing will be disabled`),null}}),$i=s(async()=>{let e=await J.value;if(!e)return null;let t=e.trace.getTracer(`workflow`);return ta(e,t),t});let ea=!1;function ta(e,t){let n=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`);if(!(ea||!n)){ea=!0;try{let n=globalThis[Symbol.for(`opentelemetry.js.api.1`)],r=e.trace.getTracerProvider(),i=r.getDelegate?.()??r,a=t.startSpan(`workflow.otel.probe.core`);console.warn(`[workflow:otel-diag] core`,JSON.stringify({globalRegistrationVersion:n?.version??null,providerCtor:r?.constructor?.name??null,delegateCtor:i?.constructor?.name??null,tracerCtor:t?.constructor?.name??null,probeCtor:a?.constructor?.name??null,probeRecording:a.isRecording()})),a.end()}catch(e){console.warn(`[workflow:otel-diag] core failed:`,e instanceof Error?e.message:e)}}}async function na(e,...t){let[n,r]=await Promise.all([$i.value,J.value]),{fn:i,opts:a}=typeof t[0]==`function`?{fn:t[0],opts:{}}:{fn:t[1],opts:t[0]};if(!i)throw Error(`Function to trace must be provided`);return!n||!r?await i():n.startActiveSpan(e,a,async e=>{try{let t=await i(e);return e.setStatus({code:r.SpanStatusCode.OK}),t}catch(t){throw e.setStatus({code:r.SpanStatusCode.ERROR,message:t.message}),ia(t,r,e),t}finally{e.end()}})}async function ra(e,t,n){let r=await $i.value;r&&r.startSpan(e,{...n,startTime:t}).end()}function ia(e,t,n){!e||!br.is(e)||(n.setStatus({code:t.SpanStatusCode.OK}),n.setAttributes({...xi(`suspended`),...Ci(e.stepCount),...Si(e.hookCount),...wi(e.waitCount)}))}async function aa(e){let[t,n]=await Promise.all([Zi(e),J.value]);if(!(!t||!n))return n.trace.getSpanContext(t)}async function oa(){return await ca(e=>e.trace.getActiveSpan())}async function sa(e){return ca(t=>t.SpanKind[e])}async function ca(e){let t=await J.value;if(t)return await e(t)}function la(){return ca(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function ua(e){if(!e)return;let[t,n]=await Promise.all([aa(e),J.value]);if(!(!t||!n)&&n.trace.isSpanContextValid(t))return{context:t}}async function da(e,t){let n=await J.value;if(!n)return t();let r=n.propagation.createBaggage({"workflow.run_id":{value:e.workflowRunId},"workflow.name":{value:e.workflowName}}),i=n.propagation.setBaggage(n.context.active(),r);return n.context.with(i,()=>t())}function fa(e,t){if(!t)return!1;let n=!1;for(let r of t.split(`,`)){let t=r.trim();if(!t)continue;let i=t.startsWith(`-`),a=i?t.slice(1):t;RegExp(`^${a.replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`)}$`).test(e)&&(n=!i)}return n}function pa(e,t={}){let n=r=>{let i=n=>t.debugNamespace??`workflow:${e}:${n}`,a=t=>{let n=i(t);return(i,a)=>{let o=Object.keys(r).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...r,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(pr(`[workflow-sdk]`,i,c)),fa(n,process.env.DEBUG)&&(console.debug(`[${n}] ${i}`,c??``),oa().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:a(`debug`),info:a(`info`),warn:a(`warn`),error:a(`error`),child:e=>n({...r,...e}),forRun:(e,t,i)=>n({...r,workflowRunId:e,...t===void 0?{}:{workflowName:t},...i??{}})}};return n({})}const ma=pa(`step`),Y=pa(`runtime`),ha=pa(`webhook`),ga=pa(`events`);pa(`adapter`),pa(`build`,{debugNamespace:`workflow:build`});function _a(e){if(m.is(e))throw e}function X(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof E&&t.path&&(r+=` at path "${t.path}"`);let i=`Ensure you're ${n} workflow serializable types. Check the serialization docs to see what's serializable: https://workflow-sdk.dev/docs/foundations/serialization`;return t instanceof E&&t.value!==void 0&&Y.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function va(e,t,n){try{let r=H.serialize(e,`client`,n);return dr(await cr(U(V.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){_a(e);let{message:t,hint:n}=X(`client value`,e);throw new _(t,{hint:n,cause:e})}}async function ya(e,t,n){let r=await lr(await fr(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(r,`client`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=W(r);if(i===V.DEVALUE_V1)return H.deserialize(a,`client`,n);throw Error(`Unsupported serialization format: ${i}`)}async function ba(e,t,n){try{let r=H.serialize(e,`step`,n);return dr(await cr(U(V.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){_a(e);let{message:t,hint:n}=X(`step value`,e);throw new _(t,{hint:n,cause:e})}}async function xa(e,t,n){let r=await lr(await fr(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(r,`step`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=W(r);if(i===V.DEVALUE_V1)return H.deserialize(a,`step`,n);throw Error(`Unsupported serialization format: ${i}`)}function Sa(e,t){if(!(e instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(e,`workflow`,t);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:n,payload:r}=W(e);if(n===V.DEVALUE_V1)return H.deserialize(r,`workflow`,t);throw Error(`Unsupported serialization format: ${n}`)}const Ca=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),wa=globalThis[Ca]??(globalThis[Ca]=new le);function Ta(e,t,n){if(e===0&&t===0&&n===0)return null;let r=[];e>0&&r.push(`${e} ${a(`step`,`steps`,e)}`),t>0&&r.push(`${t} ${a(`hook`,`hooks`,t)}`),n>0&&r.push(`${n} ${a(`timer`,`timers`,n)}`);let i=[];e>0&&i.push(`steps are completed`),t>0&&i.push(`hooks are received`),n>0&&i.push(`timers have elapsed`);let o=i.join(` and `);return`${r.join(` and `)} to be enqueued\n Workflow will suspend and resume when ${o}`}function Ea(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function Da(e){return`strm_${e}_system_abort`}function Oa(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return Da(e.slice(5))}const ka=()=>te(`WORKFLOW_DEFERRED_CHECK_DELAY_MS`,100,{integer:!0,min:10});var Z;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Z||={});var Aa=class{eventIndex;events=[];callbacks=[];onConsumedEvent;onUnconsumedEvent;getPromiseQueue;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;constructor(e,t){this.events=e,this.eventIndex=0,this.onConsumedEvent=t.onConsumedEvent,this.onUnconsumedEvent=t.onUnconsumedEvent,this.getPromiseQueue=t.getPromiseQueue}subscribe(e){this.callbacks.push(e),this.pendingUnconsumedCheck!==null&&(this.unconsumedCheckVersion++,this.pendingUnconsumedCheck=null,this.pendingUnconsumedTimeout!==null&&(clearTimeout(this.pendingUnconsumedTimeout),this.pendingUnconsumedTimeout=null)),process.nextTick(this.consume)}notifyConsumedEvent(e){if(this.onConsumedEvent)try{this.onConsumedEvent(e)}catch(e){ga.error(`onConsumedEvent callback threw an error`,{error:e})}}consume=()=>{for(;;){let e=this.events[this.eventIndex]??null;if(!this.consumeOne(e)){this.handleUnconsumed(e);return}}};consumeOne(e){for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Z.NotConsumed;try{r=n(e)}catch(e){ga.error(`EventConsumer callback threw an error`,{error:e})}if(!(r!==Z.Consumed&&r!==Z.Finished))return e!==null&&this.notifyConsumedEvent(e),this.eventIndex++,r===Z.Finished&&this.callbacks.splice(t,1),e!==null}return!1}handleUnconsumed(e){if(e!==null){let t=++this.unconsumedCheckVersion;this.pendingUnconsumedCheck=this.getPromiseQueue().then(()=>new Promise(e=>setTimeout(e,0))).then(()=>this.getPromiseQueue()).then(()=>{this.pendingUnconsumedTimeout=setTimeout(()=>{this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===t&&(this.pendingUnconsumedCheck=null,this.onUnconsumedEvent(e))},ka())})}}},ja=class{aborted=!1;reason=void 0;[F];[I];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[F]=e,this[I]=t}_setAborted(e){if(!this.aborted){this.aborted=!0,this.reason=e,this.#t&&this.#t.call(this);for(let e of this.#e)e();this.#e=[]}}addEventListener(e,t){if(e===`abort`){if(this.aborted){t();return}this.#e.push(t)}}removeEventListener(e,t){e===`abort`&&(this.#e=this.#e.filter(e=>e!==t))}throwIfAborted(){if(this.aborted)throw this.reason??new DOMException(`The operation was aborted.`,`AbortError`)}};function Ma(e){return class{signal;[F];[I];constructor(){let t=e.generateUlid(),n=Da(t),r=`abrt_${t}`;this[F]=n,this[I]=r,this.signal=new ja(n,r);let i=`hook_${e.generateUlid()}`;e.invocationsQueue.set(i,{type:`hook`,correlationId:i,token:r,isWebhook:!1,isSystem:!0}),e.eventsConsumer.subscribe(t=>{if(!t||t.correlationId!==i)return Z.NotConsumed;let n=`eventData`in t&&t.eventData&&`token`in t.eventData?t.eventData.token:void 0;if(typeof n==`string`&&n!==this[I])return e.promiseQueue=e.promiseQueue.then(()=>{e.onWorkflowError(new p(`Replay divergence: abort hook event ${t.eventType} for ${i} belongs to token "${n}", but the current abort hook expects "${this[I]}"`,{eventId:t.eventId}))}),Z.Finished;if(t.eventType===`hook_created`){let t=e.invocationsQueue.get(i);return t&&t.type===`hook`&&(t.hasCreatedEvent=!0),Z.Consumed}if(t.eventType===`hook_received`){let n=t.eventData?.payload;return e.pendingDeliveries++,e.promiseQueue=e.promiseQueue.then(async()=>{let t;try{if(n!==void 0)try{let r=await ko(n,e.runId,e.encryptionKey,e.globalThis);r&&typeof r==`object`&&`reason`in r&&(t=r.reason)}catch{}this.signal._setAborted(t)}finally{e.pendingDeliveries--}}),e.invocationsQueue.delete(i),Z.Consumed}return t.eventType===`hook_disposed`?(e.invocationsQueue.delete(i),Z.Finished):Z.NotConsumed})}abort(t){if(!this.signal.aborted){this.signal._setAborted(t);for(let[,n]of e.invocationsQueue)if(n.type===`hook`&&n.token===this[I]){n.abortRequested=!0,n.abortReason=t;break}}}}}function Na(){return{abort(e){let t=new ja(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new ja(``,``),n=Array.from(e);for(let e of n)if(e.aborted)return t._setAborted(e.reason),t;let r=[],i=()=>{for(let{signal:e,listener:t}of r)e.removeEventListener&&e.removeEventListener(`abort`,t);r.length=0};for(let e of n){if(!e.addEventListener)continue;let n=()=>{t.aborted||(t._setAborted(e.reason),i())};r.push({signal:e,listener:n}),e.addEventListener(`abort`,n)}return t},timeout(){throw Error(`AbortSignal.timeout() is not supported in workflow functions. Use sleep() with an AbortController instead. See: /docs/errors/abort-signal-timeout-in-workflow`)}}}const Pa=ae();function Fa(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function Ia(e){return _a(e),e instanceof _&&e.cause!==void 0||e instanceof d&&e.cause!==void 0?e.cause:e}async function Q(e,t){if(e.recorded)try{let n=await oa();if(!n)return;let r=e.uncompressedBytes??0,i=e.storedBytes??0;n.setAttributes({...Ni(t),...Pi(e.compressed??!1),...Fi(e.codec??`none`),...Ii(r),...Li(i),...e.compressed&&r>0?Ri(1-i/r):{}})}catch{}}function La(e,t){let n=new TextEncoder,r={resolved:!1,key:void 0};return new TransformStream({async transform(i,a){try{r.resolved||=(r.key=await ur(t),!0);let o=O(i,e),s=n.encode(o),c=U(V.DEVALUE_V1,s);if(r.key){let e=await nn(r.key,c);c=U(V.ENCRYPTED,e)}let l=new Uint8Array(4+c.length);new DataView(l.buffer).setUint32(0,c.length,!1),l.set(c,4),a.enqueue(l)}catch(e){if(m.is(e)){a.error(e);return}let{message:t,hint:n}=X(`stream chunk`,e);a.error(new _(t,{hint:n,cause:e}))}}})}function Ra(e,t){let n=new TextDecoder,r=new Uint8Array,i={resolved:!1,key:void 0};function a(e){let t=new Uint8Array(r.length+e.length);t.set(r,0),t.set(e,r.length),r=t}async function o(a){for(i.resolved||=(i.key=await ur(t),!0);r.length>=4;){let t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,!1);if(r.length<4+t)break;let o=r.slice(4,4+t);r=r.slice(4+t);let{format:s,payload:c}=W(o);if(s===V.ENCRYPTED){if(!i.key){a.error(new m(`Encrypted stream data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:c.byteLength,formatPrefix:`encr`}}));return}let e;try{e=await rn(i.key,c)}catch(e){throw m.is(e)&&e.context&&(e.context.formatPrefix=s),e}({format:s,payload:c}=W(e))}if(s===V.DEVALUE_V1){let t=n.decode(c);a.enqueue(Xt(t,e))}}}return new TransformStream({async transform(t,i){if(r.length===0&&t.length>=4){let e=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!1);if(e>0&&e<1e8){a(t),await o(i);return}}else if(r.length>0){a(t),await o(i);return}let s=n.decode(t).split(`
20
- `);for(let t of s)t.length>0&&i.enqueue(Xt(t,e))},async flush(e){r.length>0&&await o(e)}})}const za=1e8;function Ba(){return new TransformStream({transform(e,t){if(e.length===0)return;if(e.length>za){t.error(new d(`Byte-stream chunk of ${e.length} bytes exceeds the maximum framed chunk size (${za}). Split the data into smaller chunks before writing.`,{slug:`serialization-failed`}));return}let n=new Uint8Array(4+e.length);new DataView(n.buffer).setUint32(0,e.length,!1),n.set(e,4),t.enqueue(n)}})}function Va(){let e=new Uint8Array;function t(t){let n=new Uint8Array(e.length+t.length);n.set(e,0),n.set(t,e.length),e=n}return new TransformStream({transform(n,r){for(n.length>0&&t(n);e.length>=4;){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(t>za){r.error(new d(`Byte-stream frame length ${t} exceeds maximum (${za}). This usually means a non-framed byte stream is being read as framed.`,{slug:`serialization-failed`}));return}let n=4+t;if(e.length<n)break;r.enqueue(e.slice(4,n)),e=e.slice(n)}},flush(t){e.length>0&&t.error(new d(`Byte-stream ended with ${e.length} bytes of incomplete frame data. The stream was truncated mid-frame.`,{slug:`serialization-failed`}))}})}function Ha(e,t,n,r,i){(async()=>{await ra(`workflow.stream.read`,e,{kind:await sa(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read`,"workflow.stream.read.ttfc_ms":Date.now()-e,...typeof i==`number`?{"workflow.stream.read.connect_ms":i}:{},...typeof r==`number`?{"workflow.stream.start_index":r}:{}}})})()}function Ua(e,t,n,r,i,a){(async()=>{await ra(`workflow.stream.read.complete`,e,{kind:await sa(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read_complete`,"workflow.stream.read.total_ms":Date.now()-e,"workflow.stream.read.chunks":r,"workflow.stream.read.bytes":i,...typeof a==`number`?{"workflow.stream.read.reconnects":a}:{}}})})()}var Wa=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new d(`"name" is required, got "${t}"`);let r,i=!1,a,o=0,s=0;super({type:`bytes`,pull:async c=>{let l=this.#e;if(!l){r===void 0&&(r=Date.now());let i=await j(),o=Date.now(),s=await i.streams.get(e,t,n);a=Date.now()-o,l=this.#e=s.getReader()}if(!l){c.error(Error(`Failed to get reader`));return}let u=await l.read();u.done?(this.#e=void 0,r!==void 0&&Ua(r,e,t,o,s),c.close()):(!i&&u.value.byteLength>0&&r!==void 0&&(i=!0,Ha(r,e,t,n,a)),o+=1,s+=u.value.byteLength,c.enqueue(u.value))},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}};const Ga=()=>te(`WORKFLOW_FRAMED_STREAM_MAX_RECONNECTS`,50,{integer:!0,min:1}),Ka=()=>te(`WORKFLOW_FRAMED_STREAM_MAX_TOTAL_RECONNECTS`,1e3,{integer:!0,min:1});function qa(e,t,n){let r=n===void 0||n>=0,i=n??0,a=0,o=0,s=0,c,l=new Uint8Array,u,d,f=!1,p=0,m=0;async function h(){let o=await j(),s=r?i+a:n,l=Date.now(),u=await o.streams.get(e,t,s);d===void 0&&(d=Date.now()-l),c=u.getReader()}async function g(){c&&=(await c.cancel().catch(()=>{}),void 0),i+=a,a=0,l=new Uint8Array;let e=Ga(),n=Ka();for(;;){if(o++,s++,o>e)throw Error(`Stream "${t}" exceeded maximum reconnection attempts (${e})`);if(s>n)throw Error(`Stream "${t}" exceeded maximum total reconnection attempts (${n})`);try{await h();return}catch{}}}return new ReadableStream({pull:async i=>{for(u===void 0&&(u=Date.now());;){if(!c)try{await h()}catch(e){i.error(e);return}let _;try{_=await c.read()}catch(e){if(!r){i.error(e);return}try{await g()}catch(e){i.error(e);return}continue}if(_.done||!_.value){c=void 0,u!==void 0&&Ua(u,e,t,p,m,s),i.close();return}let v=_.value;if(v.length>0){let e=new Uint8Array(l.length+v.length);e.set(l,0),e.set(v,l.length),l=e}let y=!1;for(;l.length>=4;){let r=4+new DataView(l.buffer,l.byteOffset,l.byteLength).getUint32(0,!1);if(l.length<r)break;i.enqueue(l.slice(0,r)),l=l.slice(r),a++,p++,m+=r,!f&&u!==void 0&&(f=!0,Ha(u,e,t,n,d)),y=!0}if(y){o=0;return}}},cancel:async()=>{c&&=(await c.cancel().catch(e=>{console.warn(`Error closing ReadableStream reader:`,e)}),void 0)}})}const Ja=()=>te(`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`,10,{integer:!0});function Ya(e,t,n,r,i,a,o){(async()=>{await ra(`workflow.stream.flush`,e,{kind:await sa(`CLIENT`),attributes:{"workflow.run.id":n,"workflow.stream.name":r,"workflow.stream.operation":`flush`,"workflow.stream.flush.buffer_dwell_ms":t-e,"workflow.stream.flush.chunks":i,"workflow.stream.flush.bytes":a,"workflow.stream.write.chunk_rtt":o}})})()}function Xa(e,t,n){(async()=>{await ra(`workflow.stream.close`,e,{kind:await sa(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`close`,"workflow.stream.close.rpc_ms":Date.now()-e}})})()}var $=class extends WritableStream{constructor(e,t,n){if(typeof e!=`string`)throw new d(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new d(`"name" is required, got "${t}"`);let r=j(),i=n,a=async()=>{if(i){try{await i}catch{}i=void 0}},o=[],s=null,c=null,l,u,f=async()=>{if(s&&=(clearTimeout(s),null),o.length===0)return;await a();let n=o.slice(),i=u;u=void 0;let c=Date.now(),d=await r;l===void 0&&(l=d.streamFlushIntervalMs??Ja());let f=Date.now();try{if(typeof d.streams.writeMulti==`function`&&n.length>1)await d.streams.writeMulti(e,t,n);else for(let r of n)await d.streams.write(e,t,r)}catch(e){throw i!==void 0&&(u=u===void 0?i:Math.min(u,i)),e}i!==void 0&&Ya(i,c,e,t,n.length,n.reduce((e,t)=>e+t.byteLength,0),Date.now()-f),o=[]},p=[],m=()=>{s||=setTimeout(()=>{s=null;let e=p;p=[],c=f().then(()=>{for(let t of e)t.resolve()},t=>{for(let n of e)n.reject(t)})},l??Ja())};super({async write(e){u===void 0&&(u=Date.now()),c&&=(await c,null),o.push(e),m(),await new Promise((e,t)=>{p.push({resolve:e,reject:t})})},async close(){c&&=(await c,null),await f(),await a();let n=await r,i=Date.now();await n.streams.close(e,t),Xa(i,e,t)},abort(e){s&&=(clearTimeout(s),null),o=[];let t=p;p=[];let n=e??Error(`Stream aborted`);for(let e of t)e.reject(n)}})}};function Za(e=globalThis){return{...Nn(),...Vn(),...zn(e),Request:t=>{if(!(t instanceof e.Request))return!1;let n={method:t.method,url:t.url,headers:t.headers,body:t.body,duplex:t.duplex},r=t[Tn];return r&&(n.responseWritable=r),t.signal&&(t.signal.aborted||t.signal[F])&&(n.signal=t.signal),n},Response:t=>t instanceof e.Response?{type:t.type,url:t.url,status:t.status,statusText:t.statusText,headers:t.headers,body:t.body,redirected:t.redirected}:!1}}function Qa(e,t,n,r,i,a){let o=t[F],s=t[I];if(!o){let e=(n[xn]||Pa)();o=Da(e),s=`abrt_${e}`,t[F]=o,t[I]=s,t.signal&&(t.signal[F]=o,t.signal[I]=s)}return eo(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function $a(e,t){let n=t[F]??t.signal?.[F],r=t[I]??t.signal?.[I];if(!n)throw Error(`AbortController/AbortSignal stream name is not set`);return{streamName:n,hookToken:r,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function eo(e,t,n,r,i){e.aborted||e[Dn]||(e[Dn]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await ur(r),a=await So({aborted:!0,reason:e.reason},n,i),o=new $(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function to(e=globalThis,t,n,r,i=!1,a){return{...Za(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new _(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=`strm_${(e[xn]||Pa)()}`,c=Fa(o),l=new $(n,s,a);c===`bytes`?i?t.push(o.pipeThrough(Ba()).pipeTo(l)):t.push(o.pipeTo(l)):t.push(o.pipeThrough(La(to(e,t,n,r,i,a),r)).pipeTo(l));let u={name:s};return c&&(u.type=c),c===`bytes`&&i&&(u.framing=`framed-v1`),u},WritableStream:r=>{if(!(r instanceof e.WritableStream))return!1;let i=r[M],a=r[N];if(typeof i==`string`&&typeof a==`string`){let e={name:i,runId:a},t=r[P];return typeof t==`string`&&(e.deploymentId=t),e}let o=`strm_${(e[xn]||Pa)()}`,s=new Wa(n,o);return t.push(s.pipeTo(r)),{name:o}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Qa(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Qa(i,i,e,t,n,r)}}function no(e=globalThis){return{...Za(e),ReadableStream:t=>{if(!(t instanceof e.ReadableStream))return!1;let n=t[wn];if(n!==void 0)return{bodyInit:n};let r=t[M];if(!r)throw new d("ReadableStream `name` is not set");let i={name:r},a=t[Sn];a&&(i.type=a);let o=t[Cn];return o&&(i.framing=o),i},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let n=t[M];if(!n)throw new d("WritableStream `name` is not set");let r={name:n},i=t[N];typeof i==`string`&&(r.runId=i);let a=t[P];return typeof a==`string`&&(r.deploymentId=a),r},AbortController:t=>{if(!t||!t.signal)return!1;let n=t,r=n[F]??n.signal?.[F],i=e.AbortController&&typeof e.AbortController==`function`&&t instanceof e.AbortController;return!r&&!i?!1:$a(t.signal,n)},AbortSignal:t=>{let n=t?.[F],r=e.AbortSignal&&typeof e.AbortSignal==`function`&&t instanceof e.AbortSignal;return!n&&!r?!1:$a(t,t)}}}function ro(e=globalThis,t,n,r,i=!1,a){return{...Za(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new _(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=o[M],c=o[Sn],l=o[Cn];if(!s){s=`strm_${(e[xn]||Pa)()}`,c=Fa(o),l=c===`bytes`&&i?`framed-v1`:l;let u=new $(n,s,a);c===`bytes`?l===`framed-v1`?t.push(o.pipeThrough(Ba()).pipeTo(u)):t.push(o.pipeTo(u)):t.push(o.pipeThrough(La(ro(e,t,n,r,i,a),r)).pipeTo(u))}let u={name:s};return c&&(u.type=c),l&&(u.framing=l),u},WritableStream:i=>{if(!(i instanceof e.WritableStream))return!1;let a=i[M],o=i[N];a||(a=`strm_${(e[xn]||Pa)()}`,t.push(new Wa(n,a).pipeThrough(Ra(ho(e,t,n,r),r)).pipeTo(i)));let s={name:a};typeof o==`string`&&(s.runId=o);let c=i[P];return typeof c==`string`&&(s.deploymentId=c),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Qa(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Qa(i,i,e,t,n,r)}}function io(...e){let t=new WeakSet;function n(e){let t=e[On];t&&!t.signal.aborted&&t.abort()}function r(e){if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),e instanceof AbortController){n(e),n(e.signal);return}if(e instanceof AbortSignal){n(e);return}if(Array.isArray(e)){for(let t of e)r(t);return}if(e instanceof Map){for(let t of e.values())r(t);return}if(e instanceof Set){for(let t of e)r(t);return}if(typeof Request<`u`&&e instanceof Request){r(e.signal);return}for(let t of Object.values(e))r(t)}}for(let t of e)r(t)}function ao(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new Wa(t,n).getReader(),a=await Promise.race([r.read(),new Promise(e=>{if(i.signal.aborted){e({value:void 0,done:!0});return}i.signal.addEventListener(`abort`,()=>e({value:void 0,done:!0}),{once:!0})})]);if(a.value&&!a.done){try{r.releaseLock()}catch{}try{let n=wa.getStore(),r=await Co(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}else r.cancel().catch(()=>{})}catch{}})()),i}function oo(e,t,n){let r=e,i=e.signal;r[F]=t.streamName,r[I]=t.hookToken,i[F]=t.streamName,i[I]=t.hookToken,n&&(r[On]=n,i[On]=n)}function so(e,t){let n=e,r=t;n[F]!==void 0&&(r[F]=n[F]),n[I]!==void 0&&(r[I]=n[I]),n[On]!==void 0&&(r[On]=n[On])}function co(e,t,n){let r=new AbortController;e.aborted?(oo(r,e),r.abort(e.reason)):e.streamName?oo(r,e,ao(r,n,e.streamName,t)):oo(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=wa.getStore();if(n&&(n.ops.push((async()=>{try{let r=await So({aborted:!0,reason:t},n.workflowMetadata.workflowRunId,n.encryptionKey),i=new $(n.workflowMetadata.workflowRunId,e.streamName).getWriter();await i.write(r),await i.close()}catch{}})()),e.hookToken)){let r=(async()=>{try{let{resumeHook:n}=await import(`./resume-hook-CHXbXuRZ.js`).then(e=>e.i);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})();n.preCompletionOps.push(r)}},r}function lo(e,t,n){let r=new AbortController;return e.aborted?(oo(r,e),r.abort(e.reason)):e.streamName?oo(r,e,ao(r,n,e.streamName,t)):oo(r,e),r.signal}function uo(e=globalThis){return{...Pn(e),...Bn(e)}}async function fo(e,t){let n=await j();if(!n.getEncryptionKeyForRun)return;let r=t?await n.getEncryptionKeyForRun(e,{deploymentId:t}):await n.getEncryptionKeyForRun(await n.runs.get(e));return r?await tn(r,[`encrypt`]):void 0}function po(e=globalThis,t,n,r){return{...uo(e),StepFunction:()=>{throw new _(`Step functions cannot be deserialized in client context. Step functions should not be returned from workflows.`,{hint:`A step function reference reached the client. Return a serializable value (e.g. the step result) instead of the step itself.`})},WorkflowFunction:e=>Object.assign(()=>{throw new _(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(n.signal=t.signal);let r=new e.Request(t.url,n);return t.signal&&so(t.signal,r.signal),r},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}if(i.type===`bytes`){let r=new Wa(n,i.name,i.startIndex),a=k();t.push(a.promise);let{readable:o,writable:s}=i.framing===`framed-v1`?Va():new e.TransformStream;return A(r,s,a).catch(()=>{}),ln(o,a),o}else{let a=qa(n,i.name,i.startIndex),o=Ra(po(e,t,n,r),r),s=k();return t.push(s.promise),A(a,o.writable,s).catch(()=>{}),ln(o.readable,s),o.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:fo(a,i.deploymentId),s=La(to(e,t,a,o),o),c=new $(a,i.name),l=k();return t.push(l.promise),A(s.readable,c,l).catch(()=>{}),cn(s.writable,l),Object.defineProperty(s.writable,M,{value:i.name,writable:!1}),Object.defineProperty(s.writable,N,{value:a,writable:!1}),typeof i.deploymentId==`string`&&Object.defineProperty(s.writable,P,{value:i.deploymentId,writable:!1}),s.writable},AbortController:e=>co(e,t,n),AbortSignal:e=>lo(e,t,n)}}function mo(e=globalThis){return{...uo(e),...Hn(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[Tn]=n,delete t.responseWritable,t.respondWith=()=>{throw new _("`respondWith()` must be called from within a step function.",{hint:'Move the `respondWith(...)` call inside a `"use step"` function — it cannot be invoked from a workflow context.'})}),t},WorkflowFunction:e=>Object.assign(()=>{throw new _(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Response:t=>(Object.setPrototypeOf(t,e.Response.prototype),t),ReadableStream:t=>`bodyInit`in t?Object.create(e.ReadableStream.prototype,{[wn]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[M]:{value:t.name,writable:!1},[Sn]:{value:t.type,writable:!1},[Cn]:{value:t.framing,writable:!1}}),WritableStream:t=>{let n={[M]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[N]={value:t.runId,writable:!1}),typeof t.deploymentId==`string`&&(n[P]={value:t.deploymentId,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new ja(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[F]:e.streamName,[I]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new ja(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function ho(e=globalThis,t,n,r,i){return{...uo(e),StepFunction:e=>{let t=e.stepId,n=e.closureVars,r=`boundThis`in e,i=r?e.boundThis:void 0,a=Array.isArray(e.boundArgs)?e.boundArgs:[],o=se(t);if(!o)throw new _(`Step function "${t}" not found. Make sure the step function is registered.`,{hint:`Make sure the step file is included in your build (i.e. it is listed in the workflow manifest), and that the SWC plugin is configured for the file.`});if(!n&&!r&&a.length===0)return o;let s=function(...e){let t=r?i:this,s=a.length>0?[...a,...e]:e;if(n){let e=wa.getStore();if(!e)throw new d(`Cannot call step function with closure variables outside step context`);let r={...e,closureVars:n};return wa.run(r,()=>o.apply(t,s))}return o.apply(t,s)};return Object.defineProperty(s,"name",{value:o.name}),Object.defineProperty(s,"stepId",{value:t,writable:!1,enumerable:!1,configurable:!1}),o.maxRetries!==void 0&&(s.maxRetries=o.maxRetries),s},WorkflowFunction:e=>Object.assign(()=>{throw new _(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n=t.responseWritable,r={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(r.signal=t.signal);let i=new e.Request(t.url,r);return t.signal&&so(t.signal,i.signal),n&&(i.respondWith=async e=>{let t=n.getWriter();await t.write(e),await t.close()}),i},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:a=>{if(`bodyInit`in a){let t=a.bodyInit;return new e.Response(t).body}let o=new Wa(n,a.name);if(a.type===`bytes`){let n=k();t.push(n.promise);let{readable:r,writable:i}=a.framing===`framed-v1`?Va():new e.TransformStream;return A(o,i,n).catch(()=>{}),ln(r,n),r}else{let a=Ra(ho(e,t,n,r,i),r),s=k();return t.push(s.promise),A(o,a.writable,s).catch(()=>{}),ln(a.readable,s),a.readable}},WritableStream:a=>{let o=typeof a.runId==`string`?a.runId:n,s=typeof a.deploymentId==`string`?a.deploymentId:o===n?i:void 0,c=o===n?r:fo(o,s),l=La(ro(e,t,o,c),c),u=new $(o,a.name),d=k();return t.push(d.promise),A(l.readable,u,d).catch(()=>{}),cn(l.writable,d),Object.defineProperty(l.writable,M,{value:a.name,writable:!1}),Object.defineProperty(l.writable,N,{value:o,writable:!1}),s&&Object.defineProperty(l.writable,P,{value:s,writable:!1}),l.writable},AbortController:e=>co(e,t,n),AbortSignal:e=>lo(e,t,n)}}async function go(e,t){return await dr(e,t)}async function _o(e,t){return fr(e,t)}async function vo(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1){if(a)return In(O(e,to(i,r,t,n,o)));try{let a={},c=await va(e,n,{global:i,extraReducers:jo(to(i,r,t,n,o)),compression:s,compressionStats:a});return await Q(a,`serialize`),c}catch(e){let t=Ia(e),{message:n,hint:r}=X(`workflow arguments`,t);throw new _(n,{hint:r,cause:t})}}async function yo(e,t,n,r=globalThis,i={}){let a={},o=await lr(await _o(e,n),a);return await Q(a,`deserialize`),Sa(o,{global:r,extraRevivers:{...Mo(mo(r)),...i}})}async function bo(e,t,n,r=globalThis,i=!1,a=!1){if(i)return In(O(e,no(r)));try{let t={},i=await ba(e,n,{global:r,extraReducers:jo(no(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=Ia(e),{message:n,hint:r}=X(`workflow return value`,t);throw new _(n,{hint:r,cause:t})}}async function xo(e,t,n,r=[],i=globalThis,a={}){let o={},s=await ya(e,n,{global:i,extraRevivers:{...Mo(po(i,r,t,n)),...a},compressionStats:o});return await Q(o,`deserialize`),s}async function So(e,t,n,r=globalThis,i=!1,a=!1){if(i)return In(O(e,no(r)));try{let t={},i=await ba(e,n,{global:r,extraReducers:jo(no(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=Ia(e),{message:n,hint:r}=X(`step arguments`,t);throw new _(n,{hint:r,cause:t})}}async function Co(e,t,n,r=[],i=globalThis,a={},o){let s={},c=await xa(e,n,{global:i,extraRevivers:{...Mo(ho(i,r,t,n,o)),...a},compressionStats:s});return await Q(s,`deserialize`),c}async function wo(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c){if(a)return In(O(e,ro(i,r,t,n,o,c)));try{let a={},l=await ba(e,n,{global:i,extraReducers:jo(ro(i,r,t,n,o,c)),compression:s,compressionStats:a});return await Q(a,`serialize`),l}catch(e){let t=Ia(e),{message:n,hint:r}=X(`step return value`,t);throw new _(n,{hint:r,cause:t})}}async function To(e,t,n,r=[],i=globalThis,a=!1){try{let o=O(e,ro(i,r,t,n)),s=new TextEncoder().encode(o),c=U(V.DEVALUE_V1,s),l={},u=await go(await cr(c,a,l),n);return await Q(l,`serialize`),u}catch(e){let t=Ia(e),{message:n,hint:r}=X(`step error`,t);throw new _(n,{hint:r,cause:t})}}async function Eo(e,t,n,r=globalThis,i={}){let a={},o=await lr(await _o(e,n),a);if(await Q(a,`deserialize`),!(o instanceof Uint8Array))return Zt(o,{...mo(r),...i});let{format:s,payload:c}=W(o);if(s===V.DEVALUE_V1)return Xt(new TextDecoder().decode(c),{...mo(r),...i});throw Error(`Unsupported serialization format: ${s}`)}async function Do(e,t,n,r=globalThis,i=!1){try{let t=O(e,no(r)),a=new TextEncoder().encode(t),o=U(V.DEVALUE_V1,a),s={},c=await go(await cr(o,i,s),n);return await Q(s,`serialize`),c}catch(e){let t=Ia(e),{message:n,hint:r}=X(`run error`,t);throw new _(n,{hint:r,cause:t})}}async function Oo(e,t,n,r=[],i=globalThis,a={}){let o={},s=await lr(await _o(e,n),o);if(await Q(o,`deserialize`),!(s instanceof Uint8Array))return Zt(s,{...po(i,r,t,n),...a});let{format:c,payload:l}=W(s);if(c===V.DEVALUE_V1)return Xt(new TextDecoder().decode(l),{...po(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${c}`)}async function ko(e,t,n,r=globalThis,i={}){let a={},o=await lr(await _o(e,n),a);return await Q(a,`deserialize`),Sa(o,{global:r,extraRevivers:{...Mo(mo(r)),...i}})}const Ao=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function jo(e){let t={};for(let n of Ao)n in e&&(t[n]=e[n]);return t}function Mo(e){let t={};for(let n of Ao)n in e&&(t[n]=e[n]);return t}const No=[{format:V.ENCRYPTED,minVersion:`4.2.0-beta.64`},{format:V.GZIP,minVersion:`5.0.0-beta.18`},{format:V.ZSTD,minVersion:`5.0.0-beta.18`}],Po=[{capability:`framedByteStreams`,minVersion:`5.0.0-beta.15`}],Fo=new Set([V.DEVALUE_V1]);function Io(e){if(!e||!en.default.valid(e))return{supportedFormats:Fo,framedByteStreams:!1};let t=new Set(Fo);for(let{format:n,minVersion:r}of No)en.default.gte(e,r)&&t.add(n);let n={supportedFormats:t,framedByteStreams:!1};for(let{capability:t,minVersion:r}of Po)en.default.gte(e,r)&&(n[t]=!0);return n}const Lo=`5.0.0-beta.35`,Ro=/^[a-zA-Z0-9_\-./@]+$/;function zo(e,t){if(!Ro.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`${re(`workflow`,oe(t))}${e}`}const Bo=ae();function Vo(e){return`__health_check__${e}`}function Ho(e){let t=ne.safeParse(e);if(t.success)return t.data}function Uo(e){return`wrun_hc_${e}`}async function Wo(e,t,n){let r=await j(),i=Vo(e.correlationId),a=JSON.stringify({healthy:!0,endpoint:t,correlationId:e.correlationId,specVersion:n??5,workflowCoreVersion:Lo,timestamp:Date.now()}),o=Uo(e.correlationId);await r.streams.write(o,i,a),await r.streams.close(o,i)}function Go(e,t){let n;return Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(Error(`Operation timed out after ${t}ms`)),t)})]).finally(()=>clearTimeout(n))}async function Ko(e,t){let n=[],r=!1,i=!1;for(;!r&&!i;){let a=e.read(),o=new Promise(e=>setTimeout(()=>{i=!0,e({done:!0,value:void 0})},t)),s=await Promise.race([a,o]);r=s.done,s.value&&n.push(s.value)}return{chunks:n,timedOut:i}}function qo(e){if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;let i=new TextDecoder().decode(n),a;try{a=JSON.parse(i)}catch{return i.length>0?{healthy:!0}:null}if(typeof a!=`object`||!a||!(`healthy`in a)||typeof a.healthy!=`boolean`)return null;let o=a,s={healthy:o.healthy};return typeof o.specVersion==`number`&&(s.specVersion=o.specVersion),typeof o.workflowCoreVersion==`string`&&(s.workflowCoreVersion=o.workflowCoreVersion),s}async function Jo(e,t,n){let r=n?.timeout??3e4,i=e.createRunId?.()??Bo(),a=Vo(i),o=`${re(t,oe(n?.namespace))}health_check`,s=Date.now();try{for(await e.queue(o,{__healthCheck:!0,correlationId:i},{specVersion:1,deploymentId:n?.deploymentId});Date.now()-s<r;)try{let t=r-(Date.now()-s),n=(await Go(e.streams.get(Uo(i),a),t)).getReader(),{chunks:o,timedOut:c}=await Ko(n,500);if(c){try{n.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=qo(o);if(l)return{...l,latencyMs:Date.now()-s};await new Promise(e=>setTimeout(e,100))}catch{await new Promise(e=>setTimeout(e,100))}return{healthy:!1,error:`Health check timed out after ${r}ms`}}catch(e){return{healthy:!1,error:e instanceof Error?e.message:String(e)}}}function Yo(e,t){return new u(`Event pagination ${t} for workflow run "${e}".`,{code:l.WORLD_CONTRACT_ERROR})}function Xo(e,t,n){if(t){if(n.has(t))throw Yo(e,`did not advance`);n.add(t)}}function Zo(e,t,n){for(let r of n)t.has(r.eventId)||(t.add(r.eventId),e.push(r))}function Qo(e,t,n,r){if(t){if(n===null)throw Yo(e,`returned more pages without a cursor`);if(r.has(n))throw Yo(e,`repeated a cursor`)}}function $o(e,t,n){return t!==null&&!n&&u.is(e)&&e.status===400}async function es(e,t){let n=t!==void 0;return na(n?`workflow.loadNewEvents`:`workflow.loadEvents`,async r=>{r?.setAttributes({...wr(e)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,u=!1,d=await j(),f=Date.now();for(;c;){let t=Date.now(),r=s;Xo(e,r,o);let f;try{f=await d.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if($o(t,r,u)){Y.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,u=!0;continue}throw t}Zo(i,a,f.data),c=f.hasMore,Qo(e,c,f.cursor,o),s=f.cursor??s,l++,Y.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:f.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return Y.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-f}),r?.setAttributes({...Dr(i.length),...ki(l)}),{events:i,cursor:s}})}function ts(){return process.env.WORKFLOW_PRECONDITION_GUARD===`1`}function ns(e){let t=e[e.length-1];if(!t)return;let n=t.eventId,r=n.lastIndexOf(`_`);return ie(r===-1?n:n.slice(r+1))?.getTime()??void 0}function rs(e){return ts()?ns(e):void 0}async function is(e,t,n){for(let r=0;;r++)try{return await n(rs(t.events))}catch(n){if(!v.is(n)||r>=2)throw n;Y.info(`Event creation rejected as stale; reloading event log and retrying`,{workflowRunId:e,attempt:r+1,maxRetries:2});let i=await es(e,t.cursor??void 0);Zo(t.events,new Set(t.events.map(e=>e.eventId)),i.events),t.cursor=i.cursor??t.cursor}}const as={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function os(e,t){return async n=>{let r=new URL(n.url);return r.searchParams.has(`__health`)?n.method===`OPTIONS`?new Response(null,{status:204,headers:as}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??5,workflowCoreVersion:Lo}),{status:200,headers:{"Content-Type":`application/json`,...as}}):await e(n)}}async function ss(e,...t){let n=t[0];await na(`queue.publish`,{attributes:{...fi(`vercel-queue`),...pi(n),...hi(`publish`),...zi(`vercel-queue`),...Bi(`vercel-queue`),...Vi(`vqs`),...Hi(`publish`)},kind:await sa(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(mi(r))})}function cs(e){if(e.requestedAt)try{return gi(Date.now()-e.requestedAt.getTime())}catch{return}}function ls(e,t){let n;return()=>(n||=(async()=>{let n=await e.getEncryptionKeyForRun?.(t);return n?await tn(n):void 0})(),n)}function us(t){import(`./functions-PT9ri9Hu.js`).then(t=>e(t.default,1)).then(({waitUntil:e})=>{e(t)})}function ds(e,t){us(e.catch(e=>{if(!(e?.name===`AbortError`||e?.name===`ResponseAborted`))try{t(e)}catch{}}))}async function fs(e){let t=e();return us(t.catch(()=>{})),t}function ps(e,t={}){if(typeof e!=`object`||!e||Array.isArray(e))throw new h(`setAttributes requires a plain object, got ${e===null?`null`:Array.isArray(e)?`array`:typeof e}`);let n=Object.entries(e).map(([e,t])=>({key:e,value:t===void 0?null:t}));if(n.length===0)return n;let r=t.allowReservedAttributes===!0;try{ee(n,{allowReservedAttributes:r})}catch(e){throw e instanceof y?new h(e.message):e}return n}export{Qi as $,Vr as $t,Eo as A,A as An,ui as At,Ea as B,ke as Bn,Fr as Bt,vo as C,yn as Cn,ei as Ct,La as D,j as Dn,Kr as Dt,po as E,mn as En,Xr as Et,Ma as F,Pe as Fn,Yr as Ft,Yi as G,Sr as Gt,Y as H,Ae as Hn,Nr as Ht,Z as I,Ie as In,Qr as It,Ki as J,kr as Jt,Ji as K,Cr as Kt,Aa as L,Le as Ln,Zr as Lt,yo as M,tn as Mn,$r as Mt,xo as N,Ne as Nn,ri as Nt,Oo as O,un as On,ai as Ot,Na as P,Fe as Pn,ni as Pt,na as Q,Gr as Qt,Ta as R,je as Rn,Or as Rt,wo as S,_n as Sn,ci as St,to as T,hn as Tn,ti as Tt,ma as U,Dr as Ut,wa as V,Oe as Vn,Pr as Vt,ha as W,Lr as Wt,ua as X,Hr as Xt,qi as Y,Wr as Yt,Xi as Z,Ur as Zt,$ as _,P as _n,Mi as _t,zo as a,Ar as an,bi as at,So as b,vn as bn,si as bt,es as c,xr as cn,Ti as ct,ss as d,An as dn,pi as dt,wr as en,da as et,rs as f,jn as fn,mi as ft,Io as g,M as gn,ji as gt,Lo as h,xn as hn,Ai as ht,cs as i,jr as in,Oi as it,ko as j,cn as jn,di as jt,Co as k,k as kn,li as kt,ls as l,br as ln,Di as lt,is as m,wn as mn,fi as mt,ds as n,Er as nn,Wi as nt,Wo as o,Mr as on,yi as ot,os as p,Mn as pn,hi as pt,sa as q,zr as qt,fs as r,Ir as rn,Ui as rt,Jo as s,Rr as sn,vi as st,ps as t,Tr as tn,_i as tt,Ho as u,V as un,Ei as ut,io as v,N as vn,ii as vt,bo as w,gn as wn,qr as wt,To as x,bn as xn,oi as xt,Do as y,Tn as yn,Jr as yt,Oa as z,Me as zn,Br as zt};
@@ -1,3 +0,0 @@
1
- import{o as e}from"./dist-CttsoN4D.js";const t={USER_ERROR:`USER_ERROR`,RUNTIME_ERROR:`RUNTIME_ERROR`,CORRUPTED_EVENT_LOG:`CORRUPTED_EVENT_LOG`,REPLAY_DIVERGENCE:`REPLAY_DIVERGENCE`,MAX_DELIVERIES_EXCEEDED:`MAX_DELIVERIES_EXCEEDED`,REPLAY_TIMEOUT:`REPLAY_TIMEOUT`,WORLD_CONTRACT_ERROR:`WORLD_CONTRACT_ERROR`};function n(e){return typeof e==`object`&&!!e&&`name`in e&&`message`in e}function r(e,t){if(t.length===0)return e;let n=[e];return t.forEach((e,r)=>{let i=r===t.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;`${e.label}: ${e.value}`.split(`
2
- `).forEach((e,t)=>n.push(`${t===0?a:o}${e}`))}),n.join(`
3
- `)}function i(e,t){let n=[];return e&&n.push({label:`hint`,value:e}),t&&n.push({label:`docs`,value:`https://workflow-sdk.dev/err/${t}`}),n}const a={NODE_JS_MODULE_IN_WORKFLOW:`node-js-module-in-workflow`,START_INVALID_WORKFLOW_FUNCTION:`start-invalid-workflow-function`,SERIALIZATION_FAILED:`serialization-failed`,WEBHOOK_INVALID_RESPOND_WITH_VALUE:`webhook-invalid-respond-with-value`,WEBHOOK_RESPONSE_NOT_SENT:`webhook-response-not-sent`,FETCH_IN_WORKFLOW_FUNCTION:`fetch-in-workflow`,TIMEOUT_FUNCTIONS_IN_WORKFLOW:`timeout-in-workflow`,HOOK_CONFLICT:`hook-conflict`,CORRUPTED_EVENT_LOG:`corrupted-event-log`,REPLAY_DIVERGENCE:`replay-divergence`,STEP_NOT_REGISTERED:`step-not-registered`,WORKFLOW_NOT_REGISTERED:`workflow-not-registered`,RUNTIME_DECRYPTION_FAILED:`runtime-decryption-failed`};var o=class extends Error{cause;constructor(e,t){let n=r(e,i(void 0,t?.slug));super(n,{cause:t?.cause}),t?.cause!==void 0&&(this.cause=t.cause),t?.cause instanceof Error&&(this.stack=`${this.stack}\nCaused by: ${t.cause.stack}`)}static is(e){return n(e)&&e.name===`WorkflowError`}},s=class extends o{status;code;url;retryAfter;constructor(e,t){super(e,{cause:t?.cause}),this.name=`WorkflowWorldError`,this.status=t?.status,this.code=t?.code,this.url=t?.url,this.retryAfter=t?.retryAfter}static is(e){return n(e)&&e.name===`WorkflowWorldError`}},c=class extends o{runId;errorCode;constructor(e,t,n={}){let r=t instanceof Error?t.message:typeof t==`string`?t:t&&typeof t==`object`&&`message`in t?String(t.message):`Unknown error`;super(`Workflow run "${e}" failed: ${r}`,{cause:t}),this.name=`WorkflowRunFailedError`,this.runId=e,n.errorCode!==void 0&&(this.errorCode=n.errorCode)}static is(e){return n(e)&&e.name===`WorkflowRunFailedError`}},l=class extends o{runId;status;constructor(e,t){super(`Workflow run "${e}" has not completed`,{}),this.name=`WorkflowRunNotCompletedError`,this.runId=e,this.status=t}static is(e){return n(e)&&e.name===`WorkflowRunNotCompletedError`}},u=class extends o{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return n(e)&&e.name===`WorkflowRuntimeError`}},d=class extends u{constructor(e,t){super(e,{...t,slug:a.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return n(e)&&e.name===`CorruptedEventLogError`}},f=class extends u{eventId;constructor(e,t){super(e,{...t,slug:a.REPLAY_DIVERGENCE}),this.name=`ReplayDivergenceError`,this.eventId=t.eventId}static is(e){return n(e)&&e.name===`ReplayDivergenceError`&&typeof e.eventId==`string`}},p=class extends u{constructor(e,t){super(e,{cause:t?.cause,slug:a.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return n(e)&&e.name===`RuntimeDecryptionError`}},m=class extends o{hint;constructor(e,t){let n=r(e,i(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return n(e)&&e.name===`WorkflowBuildError`}},h=class extends o{hint;fatal=!0;constructor(e,t){let n=r(e,i(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return n(e)&&e.name===`SerializationError`}},g=class extends u{stepName;constructor(e){super(`Step "${e}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`,{slug:a.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return n(e)&&e.name===`StepNotRegisteredError`}},_=class extends u{workflowName;constructor(e){super(`Workflow "${e}" is not registered in the current deployment. This usually means a run was started against a deployment that does not have this workflow, or there was a build/bundling issue.`,{slug:a.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return n(e)&&e.name===`WorkflowNotRegisteredError`}},v=class extends o{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return n(e)&&e.name===`WorkflowRunNotFoundError`}},y=class extends o{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:a.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return n(e)&&e.name===`HookConflictError`}},b=class extends o{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return n(e)&&e.name===`HookNotFoundError`}},x=class extends s{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return n(e)&&e.name===`EntityConflictError`}},S=class extends s{constructor(e){super(e),this.name=`RunExpiredError`}static is(e){return n(e)&&e.name===`RunExpiredError`}},C=class extends s{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return n(e)&&e.name===`TooEarlyError`}},w=class extends s{retryAfter;constructor(e,t){super(e),this.name=`ThrottleError`,this.retryAfter=t?.retryAfter}static is(e){return n(e)&&e.name===`ThrottleError`}},T=class extends s{constructor(e,t){super(e,{status:412,retryAfter:t?.retryAfter}),this.name=`PreconditionFailedError`}static is(e){return n(e)&&e.name===`PreconditionFailedError`}},E=class extends o{runId;constructor(e){super(`Workflow run "${e}" cancelled`,{}),this.name=`WorkflowRunCancelledError`,this.runId=e}static is(e){return n(e)&&e.name===`WorkflowRunCancelledError`}},D=class extends o{runSpecVersion;worldSpecVersion;constructor(e,t){super(`Run requires spec version ${e}, but world supports version ${t}. Please upgrade 'workflow' package.`),this.name=`RunNotSupportedError`,this.runSpecVersion=e,this.worldSpecVersion=t}static is(e){return n(e)&&e.name===`RunNotSupportedError`}},O=class extends Error{fatal=!0;constructor(e){super(e),this.name=`FatalError`}static is(e){return n(e)?e.name===`FatalError`?!0:e.fatal===!0:!1}},k=class extends Error{retryAfter;constructor(t,n={}){super(t),this.name=`RetryableError`,n.retryAfter===void 0?this.retryAfter=new Date(Date.now()+1e3):this.retryAfter=e(n.retryAfter)}static is(e){return n(e)&&e.name===`RetryableError`}};const A="Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account.",j=Symbol.for(`@workflow/errors//FatalError`),M=Symbol.for(`@workflow/errors//RetryableError`),N=Symbol.for(`@workflow/errors//HookConflictError`),P=Symbol.for(`@workflow/errors//RuntimeDecryptionError`);typeof globalThis<`u`&&(Object.hasOwn(globalThis,j)||Object.defineProperty(globalThis,j,{value:O,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,M)||Object.defineProperty(globalThis,M,{value:k,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,N)||Object.defineProperty(globalThis,N,{value:y,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,P)||Object.defineProperty(globalThis,P,{value:p,writable:!1,enumerable:!1,configurable:!1}));export{l as C,t as D,s as E,c as S,u as T,A as _,y as a,_ as b,f as c,D as d,p as f,C as g,w as h,O as i,k as l,g as m,a as n,b as o,h as p,x as r,T as s,d as t,S as u,m as v,v as w,E as x,o as y};
@@ -1 +0,0 @@
1
- import{r as e}from"./chunk-BHKSVoKr.js";import{T as t,n,o as r}from"./dist-BYo8Gno2.js";import{Dn as i,Gt as a,H as o,Mn as s,Q as c,S as l,X as u,a as d,at as f,en as p,g as m,k as h,n as g,ot as _,r as v,st as y,un as b,yn as x}from"./attribute-changes-CXiYB8h9.js";import{s as S}from"./dist-CSfKNxQW.js";var C=e({getHookByToken:()=>T,resumeHook:()=>E,resumeWebhook:()=>D});async function w(e){let t=await i(),n=await t.hooks.getByToken(e),r=await t.runs.get(n.runId),a=await t.getEncryptionKeyForRun?.(r),o=a?await s(a):void 0;return n.metadata!==void 0&&(n.metadata=await h(n.metadata,n.runId,o)),{hook:n,run:r,encryptionKey:o}}async function T(e){let{hook:t}=await w(e);return t}async function E(e,t,n){return await v(()=>c(`hook.resume`,async r=>{let c=await i();try{let i,f,h;if(typeof e==`string`){let t=await w(e);i=t.hook,f=t.run,h=n??t.encryptionKey}else if(i=e,f=await c.runs.get(i.runId),n)h=n;else{let e=await c.getEncryptionKeyForRun?.(f);h=e?await s(e):void 0}r?.setAttributes({...y(i.token),..._(i.hookId),...p(i.runId)});let v=f.executionContext?.workflowCoreVersion,x=m(typeof v==`string`?v:void 0);x.supportedFormats.has(b.ENCRYPTED)||(h=void 0);let C=(f.specVersion??0)>=5&&x.supportedFormats.has(b.GZIP),T=[],E=S(i.specVersion),D=await l(t,i.runId,h,T,globalThis,E,x.framedByteStreams,C);g(Promise.all(T),e=>{e!==void 0&&o.warn(`Background flush of hook payload ops failed`,{workflowRunId:i.runId,hookId:i.hookId,error:e instanceof Error?e.message:String(e)})}),await c.events.create(i.runId,{eventType:`hook_received`,specVersion:5,correlationId:i.hookId,eventData:{...E?{}:{token:i.token},payload:D}},{v1Compat:E}),r?.setAttributes({...a(f.workflowName)});let O=await u(f.executionContext?.traceCarrier);return O&&r?.addLink?.(O),await c.queue(d(f.workflowName),{runId:i.runId,traceCarrier:f.executionContext?.traceCarrier??void 0},{deploymentId:f.deploymentId,specVersion:f.specVersion??1}),i}catch(t){throw r?.setAttributes({...y(typeof e==`string`?e:e.token),...f(!1)}),t}}))}async function D(e,i){let{hook:a,encryptionKey:o}=await w(e);if(a.isWebhook===!1)throw new r(e);let s,c;if(a.metadata&&typeof a.metadata==`object`&&`respondWith`in a.metadata)if(a.metadata.respondWith===`manual`){let{readable:e,writable:t}=new TransformStream;c=e,i[x]=t}else if(a.metadata.respondWith instanceof Response)s=a.metadata.respondWith;else throw new t(`Invalid \`respondWith\` value: ${a.metadata.respondWith}`,{slug:n.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else s=new Response(null,{status:202});if(await E(a,i,o),c){let e=c.getReader(),t=await e.read();t.value&&(s=t.value),e.cancel()}if(!s)throw new t(`Workflow run did not send a response`,{slug:n.WEBHOOK_RESPONSE_NOT_SENT});return s}export{C as i,E as n,D as r,T as t};
@@ -1 +0,0 @@
1
- import{h as e}from"./dist-CttsoN4D.js";import{C as t,D as n,E as r,S as i,T as a,b as o,c as s,f as c,h as l,m as u,r as d,t as f,w as p,x as m}from"./dist-BYo8Gno2.js";import{B as h,C as ee,Dn as g,E as _,En as v,Gt as y,H as b,Kt as x,M as S,Mn as C,N as w,O as T,On as E,Q as D,Rt as O,Tn as k,V as A,Z as j,a as M,en as N,g as P,h as F,n as te,r as I,s as ne,t as re,tn as ie,tt as L,un as R}from"./attribute-changes-CXiYB8h9.js";import{K as z,i as B,o as V,q as H,s as U}from"./dist-CSfKNxQW.js";const W=new Set([`PARSE_ERROR`,`SCHEMA_VALIDATION`,n.WORLD_CONTRACT_ERROR]),G=new Set([`TRANSPORT`,`TIMEOUT`]),K=[a.is,u.is,o.is,c.is];function q(e){if(!r.is(e)||e.status!==void 0)return!1;let t=`cause`in e?e.cause:void 0;return e.code!==void 0&&W.has(e.code)||e.message.startsWith(`Failed to parse response body for `)||e.message.startsWith(`Schema validation failed for `)||typeof t==`object`&&!!t&&`name`in t&&t.name===`ZodError`}function J(e){return l.is(e)?!0:r.is(e)?e.status!==void 0&&e.status>=500?!0:e.code!==void 0&&G.has(e.code):!1}function ae(e){if(s.is(e))return n.REPLAY_DIVERGENCE;if(f.is(e))return n.CORRUPTED_EVENT_LOG;if(q(e)||J(e))return n.WORLD_CONTRACT_ERROR;for(let t of K)if(t(e))return n.RUNTIME_ERROR;return n.USER_ERROR}const oe=V();function se(){let e=A.getStore(),t=e?.workflowMetadata?.workflowRunId;if(t)return{[H]:e.rootRunId??t,[z]:t}}let Y=!1;async function X(t,n,r){"use step";return await I(()=>{let i=t?.workflowId;if(!i)throw new a(`'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`,{slug:`start-invalid-workflow-function`});return D(`workflow.start ${e(i)}`,async e=>{e?.setAttributes({...y(i),...x(`start`)});let t=[],o=r??{};Array.isArray(n)?t=n:typeof n==`object`&&(o=n),e?.setAttributes({...O(t.length)});let s=o.world??await g();E(s);let c=await s.getDeploymentId(),l=o.deploymentId??c;l===`latest`&&(s.resolveLatestDeploymentId?l=await s.resolveLatestDeploymentId():(Y||(Y=!0,b.warn(`deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.`,{currentDeploymentId:c})),l=c));let u,f;if(l===c)u=!0,f=!0;else if(typeof s.streams?.get!=`function`)u=!1,f=!1;else{let e=P((await ne(s,`workflow`,{deploymentId:l,timeout:2e3,namespace:o.namespace}).catch(()=>void 0))?.workflowCoreVersion);u=e.framedByteStreams,f=e.supportedFormats.has(R.GZIP)}let p=[],m=`wrun_${s.createRunId?s.createRunId(o):oe()}`,h=await j(),_=o.specVersion??s.specVersion,v=U(_),S=o.allowReservedAttributes===!0,w;if(o.attributes&&Object.keys(o.attributes).length>0){if(_<4)throw new a(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(o.attributes))if(typeof t!=`string`)throw new a(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=re(o.attributes,{allowReservedAttributes:S});w=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let T=_>=4?se():void 0,D=T?{...T,...w}:w,k=D?{attributes:D,...S||T!=null?{allowReservedAttributes:!0}:{}}:{};if(o.replayedFromRunId!==void 0&&!B.safeParse(o.replayedFromRunId).success)throw new a(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(o.replayedFromRunId).slice(0,64))}.`);let A=await s.getEncryptionKeyForRun?.(m,{...o,deploymentId:l}),I=A?await C(A):void 0,z=await ee(t,m,I,p,globalThis,v,u,f&&_>=5),V={traceCarrier:h,workflowCoreVersion:F,features:{encryption:!!I},...o.replayedFromRunId?{replayedFromRunId:o.replayedFromRunId}:{}},[H,W]=await Promise.allSettled([s.events.create(m,{eventType:`run_created`,specVersion:_,eventData:{deploymentId:l,workflowName:i,input:z,executionContext:V,...k}},{v1Compat:v}),s.queue(M(i,o.namespace),{runId:m,traceCarrier:h,..._>=3?{runInput:{input:z,deploymentId:l,workflowName:i,specVersion:_,executionContext:V,...k}}:{}},{deploymentId:l,specVersion:_,...o.region===void 0?{}:{region:o.region}})]);if(W.status===`rejected`)throw W.reason;let G=!1;if(H.status===`rejected`){let e=H.reason;if(!d.is(e))if(J(e))G=!0,b.warn(`Run creation event failed, but the run was accepted via the queue. The run_created event will be re-tried async by the runtime.`,{workflowRunId:m,error:e.message});else throw e}else{let e=H.value;if(!e.run)throw new a(`Missing 'run' in server response for 'run_created' event`);if(!v&&e.run.runId!==m)throw new a(`Server returned different runId than requested: expected ${m}, got ${e.run.runId}`)}return te(Promise.all(p),e=>{b.warn(`Background flush of workflow argument streams failed`,{workflowRunId:m,error:e instanceof Error?e.message:String(e)})}),e?.setAttributes({...N(m),...L(l),...H.status===`fulfilled`&&H.value.run?ie(H.value.run.status):{}}),new $(m,{resilientStart:G})})})}const ce=e=>Array.isArray(e)?e:[e];async function Z(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await C(i):void 0,o=ce(await S(r.input,t,a,globalThis)),s=n.specVersion??r.specVersion??1,c=n.deploymentId??r.deploymentId;return(await X({workflowId:r.workflowName},o,{deploymentId:c,world:e,specVersion:s,replayedFromRunId:t,namespace:n.namespace})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function le(e,t,n){try{let r=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,i=U(r),a={eventType:`run_cancelled`,specVersion:r,...n?.cancelReason===void 0?{}:{eventData:{cancelReason:n.cancelReason}}};await e.events.create(t,a,{v1Compat:i})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function ue(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`});await e.queue(M(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1})}catch(e){throw Error(`Failed to re-enqueue run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Q(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`}),i=U(r.specVersion),a=[],o=null;do{let n=await e.events.list({runId:t,pagination:{limit:1e3,...o?{cursor:o}:{}},resolveData:`none`});a.push(...n.data),o=n.hasMore?n.cursor:null}while(o);let s=a.filter(e=>e.eventType===`wait_created`),c=new Set(a.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),l=s.filter(e=>!c.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);l=l.filter(t=>t.correlationId&&e.has(t.correlationId))}let u=[],f=0;for(let n of l){if(!n.correlationId)continue;let a=i?{eventType:`wait_completed`,correlationId:n.correlationId}:{eventType:`wait_completed`,correlationId:n.correlationId,specVersion:r.specVersion,eventData:{resumeAt:n.eventData.resumeAt}};try{await e.events.create(t,a,{v1Compat:i}),f++}catch(e){d.is(e)?f++:u.push(e instanceof Error?e:Error(String(e)))}}if(f>0&&await e.queue(M(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),u.length>0)throw AggregateError(u,`Failed to complete ${u.length}/${l.length} pending wait(s) for run ${t}`);return{stoppedCount:f}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function de(e,t,n,r){try{return await e.streams.get(t,n,r?.startIndex)}catch(e){throw Error(`Failed to read stream ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function fe(e,t){try{return await e.streams.list(t)}catch(e){throw Error(`Failed to list streams for run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}var $=class e{static[v](e){return{runId:e.runId,resilientStart:e.#r}}static[k](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=g(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(){return this.#n||=(async()=>{let e=await this.#t,t=await e.runs.get(this.runId),n=await e.getEncryptionKeyForRun?.(t);return n?await C(n):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return Q(await this.#t,this.runId,e)}async cancel(e){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:5,...e?.cancelReason===void 0?{}:{eventData:{cancelReason:e.cancelReason}}})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(p.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.status))}get returnValue(){"use step";return this.#o()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.completedAt))}get readable(){return this.getReadable()}getReadable(e={}){"use step";let{ops:t=[],global:n=globalThis,startIndex:r,namespace:i}=e,a=h(this.runId,i),o=this.#a(),s=_(n,t,this.runId,o).ReadableStream({name:a,startIndex:r}),c=this.#t,l=this.runId;return Object.assign(s,{getTailIndex:async()=>(await(await c).streams.getInfo(l,a)).tailIndex})}async#o(){let e=await this.#t,n=0,r=this.#r?3:0,a=[1e3,3e3,6e3];for(;;)try{let n=await e.runs.get(this.runId);if(n.status===`completed`){let e=await this.#i();return await w(n.output,this.runId,e)}if(n.status===`cancelled`)throw new m(this.runId);if(n.status===`failed`){let e=await this.#i(),t;try{t=await T(n.error,this.runId,e)}catch{t=Error(`Failed to hydrate workflow run error`)}throw new i(this.runId,t,{errorCode:n.errorCode})}throw new t(this.runId,n.status)}catch(e){if(t.is(e)){await new Promise(e=>setTimeout(e,1e3));continue}if(p.is(e)&&n<r){let e=a[n];n++,await new Promise(t=>setTimeout(t,e));continue}throw e}}};function pe(e){return new $(e)}export{de as a,Q as c,J as d,q as f,fe as i,X as l,pe as n,Z as o,le as r,ue as s,$ as t,ae as u};
@@ -1 +0,0 @@
1
- import{Cn as e,Fn as t}from"./attribute-changes-CXiYB8h9.js";async function n(r){let i=globalThis[e];return i||t(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./chunk-BHKSVoKr.js";import{n as t,t as n}from"../../@workflow/world-vercel/index.js";var r=e(((e,r)=>{var i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,c=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of o(t))!s.call(e,c)&&c!==n&&i(e,c,{get:()=>t[c],enumerable:!(r=a(t,c))||r.enumerable});return e},u=e=>l(i({},`__esModule`,{value:!0}),e),d={};c(d,{refreshToken:()=>m}),r.exports=u(d);var f=t(),p=n();async function m(e){let t=e?.project,n=e?.team;if(!t&&!n){let e=(0,p.findProjectInfo)();t=e.projectId,n=e.teamId}else if(!t||!n){let e=(0,p.findProjectInfo)();t??=e.projectId,n??=e.teamId}if(!t)throw new f.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let r=(0,p.loadToken)(t);if(!r||(0,p.isExpired)((0,p.getTokenPayload)(r.token),e?.expirationBufferMs)){let i=await(0,p.getVercelToken)({expirationBufferMs:e?.expirationBufferMs});if(r=await(0,p.getVercelOidcToken)(i,t,n),!r)throw new f.VercelOidcTokenError(`Failed to refresh OIDC token`);(0,p.saveToken)(r,t)}process.env.VERCEL_OIDC_TOKEN=r.token}0&&(r.exports={refreshToken:m})}));export default r();export{};