eve 0.66.2 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/src/channel/channel-address.d.ts +0 -2
  3. package/dist/src/channel/channel-address.js +1 -1
  4. package/dist/src/channel/channel-operations.d.ts +0 -5
  5. package/dist/src/channel/channel-operations.js +1 -1
  6. package/dist/src/channel/compiled-channel.d.ts +8 -0
  7. package/dist/src/channel/compiled-channel.js +2 -2
  8. package/dist/src/channel/conversation-context.js +1 -1
  9. package/dist/src/channel/routes.d.ts +1 -2
  10. package/dist/src/channel/schedule.d.ts +2 -2
  11. package/dist/src/channel/schedule.js +1 -1
  12. package/dist/src/channel/types.d.ts +8 -13
  13. package/dist/src/chunks/{use-eve-agent-PbSMyJ6e.js → use-eve-agent-DzdyI97Z.js} +0 -5
  14. package/dist/src/chunks/{use-eve-agent-Di1u2zKu.js → use-eve-agent-OCHP4s0z.js} +0 -5
  15. package/dist/src/cli/acp/command.js +3 -3
  16. package/dist/src/cli/commands/logs.d.ts +3 -3
  17. package/dist/src/cli/commands/logs.js +1 -1
  18. package/dist/src/cli/commands/register-integration-commands.js +1 -1
  19. package/dist/src/cli/commands/registry-declared-setups.d.ts +0 -1
  20. package/dist/src/cli/commands/registry-declared-setups.js +1 -1
  21. package/dist/src/cli/commands/registry.d.ts +5 -1
  22. package/dist/src/cli/commands/registry.js +1 -1
  23. package/dist/src/cli/commands/trace.js +1 -1
  24. package/dist/src/cli/dev/command.d.ts +9 -5
  25. package/dist/src/cli/dev/command.js +1 -3
  26. package/dist/src/cli/dev/run-interactive-ui.d.ts +0 -1
  27. package/dist/src/cli/dev/run-interactive-ui.js +1 -1
  28. package/dist/src/cli/dev/tui/argument-typeahead.d.ts +1 -2
  29. package/dist/src/cli/dev/tui/argument-typeahead.js +2 -2
  30. package/dist/src/cli/dev/tui/blocks.d.ts +5 -1
  31. package/dist/src/cli/dev/tui/blocks.js +4 -4
  32. package/dist/src/cli/dev/tui/flow-drawer.d.ts +11 -0
  33. package/dist/src/cli/dev/tui/flow-drawer.js +1 -0
  34. package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
  35. package/dist/src/cli/dev/tui/prompt-commands.d.ts +199 -0
  36. package/dist/src/cli/dev/tui/prompt-commands.js +2 -2
  37. package/dist/src/cli/dev/tui/question-panel.d.ts +4 -4
  38. package/dist/src/cli/dev/tui/question-panel.js +1 -1
  39. package/dist/src/cli/dev/tui/registry-result-message.d.ts +15 -4
  40. package/dist/src/cli/dev/tui/registry-result-message.js +4 -4
  41. package/dist/src/cli/dev/tui/runner.d.ts +18 -6
  42. package/dist/src/cli/dev/tui/runner.js +3 -2
  43. package/dist/src/cli/dev/tui/setup-commands.d.ts +5 -22
  44. package/dist/src/cli/dev/tui/setup-commands.js +2 -1
  45. package/dist/src/cli/dev/tui/setup-flow.d.ts +2 -10
  46. package/dist/src/cli/dev/tui/setup-panel.d.ts +4 -23
  47. package/dist/src/cli/dev/tui/setup-panel.js +3 -3
  48. package/dist/src/cli/dev/tui/terminal-renderer.d.ts +11 -7
  49. package/dist/src/cli/dev/tui/terminal-renderer.js +11 -11
  50. package/dist/src/cli/dev/tui/theme.d.ts +1 -1
  51. package/dist/src/cli/dev/tui/tui-prompter.js +1 -1
  52. package/dist/src/cli/dev/tui/tui.js +1 -1
  53. package/dist/src/cli/dev/url-target.js +1 -1
  54. package/dist/src/cli/invoke/command.d.ts +2 -5
  55. package/dist/src/cli/invoke/command.js +1 -1
  56. package/dist/src/cli/invoke/invoke.d.ts +2 -2
  57. package/dist/src/cli/invoke/invoke.js +1 -1
  58. package/dist/src/cli/invoke/result.d.ts +14 -194
  59. package/dist/src/cli/invoke/result.js +1 -1
  60. package/dist/src/cli/run.d.ts +0 -4
  61. package/dist/src/cli/run.js +2 -2
  62. package/dist/src/cli/telemetry/index.js +1 -1
  63. package/dist/src/client/message-reducer.js +1 -1
  64. package/dist/src/compiled/.vendor-stamp.json +6 -6
  65. package/dist/src/compiled/@workflow/core/create-hook.d.ts +38 -1
  66. package/dist/src/compiled/@workflow/core/global.d.ts +2 -0
  67. package/dist/src/compiled/@workflow/core/index.js +2 -2
  68. package/dist/src/compiled/@workflow/core/private.js +1 -1
  69. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +9 -0
  70. package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
  71. package/dist/src/compiled/@workflow/core/runtime/hook-wake.d.ts +89 -0
  72. package/dist/src/compiled/@workflow/core/runtime/open-hook-wait-state.d.ts +55 -0
  73. package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +2 -0
  74. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +8 -1
  75. package/dist/src/compiled/@workflow/core/runtime.js +4 -4
  76. package/dist/src/compiled/@workflow/core/serialization/types.d.ts +8 -0
  77. package/dist/src/compiled/@workflow/core/serialization.d.ts +8 -0
  78. package/dist/src/compiled/@workflow/core/serialization.js +1 -1
  79. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  80. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  81. package/dist/src/compiled/@workflow/errors/index.d.ts +23 -0
  82. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  83. package/dist/src/compiled/@workflow/world/events.d.ts +34 -0
  84. package/dist/src/compiled/@workflow/world/hooks.d.ts +27 -0
  85. package/dist/src/compiled/@workflow/world/index.d.ts +2 -2
  86. package/dist/src/compiled/@workflow/world/interfaces.d.ts +24 -0
  87. package/dist/src/compiled/@workflow/world/spec-version.d.ts +32 -11
  88. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  89. package/dist/src/compiled/@workflow/world-vercel/index.js +17 -17
  90. package/dist/src/compiled/_chunks/workflow/{attribute-changes-89Nwz7XW.js → attribute-changes-DzJovO_f.js} +1 -1
  91. package/dist/src/compiled/_chunks/workflow/dist-BQSf8Hax.js +1 -0
  92. package/dist/src/compiled/_chunks/workflow/dist-BfMqXLK3.js +3 -0
  93. package/dist/src/compiled/_chunks/workflow/frames-qKc30rjg.js +3 -0
  94. package/dist/src/compiled/_chunks/workflow/{global-DIlFoH2w.js → global-BQnKzRXo.js} +1 -1
  95. package/dist/src/compiled/_chunks/workflow/{helpers-k3zcudWr.js → helpers-CNMO7zB1.js} +1 -1
  96. package/dist/src/compiled/_chunks/workflow/{logger-Bzc8jWWj.js → logger-BCEj9caG.js} +1 -1
  97. package/dist/src/compiled/_chunks/workflow/resume-hook-QS_cMwHn.js +1 -0
  98. package/dist/src/compiled/_chunks/workflow/run-CA5wWV2S.js +1 -0
  99. package/dist/src/compiled/_chunks/workflow/serialization-CJ265vSe.js +3 -0
  100. package/dist/src/compiled/_chunks/workflow/sleep-CBn94Ayv.js +1 -0
  101. package/dist/src/compiled/_chunks/workflow/{wait-until-DXLZx3tU.js → wait-until-Bo2U6ON9.js} +1 -1
  102. package/dist/src/compiled/_chunks/workflow/{ws-transport-BSM_Cl7a.js → ws-transport-BrsMYqJg.js} +1 -1
  103. package/dist/src/compiler/compile-from-memory.d.ts +0 -1
  104. package/dist/src/compiler/compile-from-memory.js +1 -1
  105. package/dist/src/compiler/extension-compatibility.d.ts +25 -18
  106. package/dist/src/compiler/extension-compatibility.js +1 -1
  107. package/dist/src/compiler/manifest.d.ts +48 -14
  108. package/dist/src/compiler/manifest.js +1 -1
  109. package/dist/src/compiler/normalize-agent-config.js +1 -1
  110. package/dist/src/compiler/normalize-channel.js +1 -1
  111. package/dist/src/compiler/normalize-connection.js +1 -1
  112. package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
  113. package/dist/src/compiler/normalize-subagent.d.ts +0 -2
  114. package/dist/src/compiler/normalize-subagent.js +1 -1
  115. package/dist/src/compiler/remote-agent-node.d.ts +0 -2
  116. package/dist/src/compiler/remote-agent-node.js +1 -1
  117. package/dist/src/compiler/workspace-resources.js +1 -1
  118. package/dist/src/context/dynamic-subagent-lifecycle.js +1 -1
  119. package/dist/src/context/keys.d.ts +0 -3
  120. package/dist/src/context/keys.js +1 -1
  121. package/dist/src/context/memory-lifecycle.d.ts +1 -0
  122. package/dist/src/context/memory-lifecycle.js +1 -1
  123. package/dist/src/discover/project.js +1 -1
  124. package/dist/src/eve-channel/create-request.d.ts +0 -3
  125. package/dist/src/eve-channel/create-request.js +1 -1
  126. package/dist/src/eve-channel/index.js +1 -1
  127. package/dist/src/eve-channel/request.js +1 -1
  128. package/dist/src/eve-channel/types.d.ts +1 -1
  129. package/dist/src/execution/delegated-session-context.d.ts +2 -0
  130. package/dist/src/execution/delegated-session-context.js +1 -0
  131. package/dist/src/execution/dynamic-connections.d.ts +4 -1
  132. package/dist/src/execution/dynamic-connections.js +1 -1
  133. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  134. package/dist/src/execution/effective-agent-config.js +1 -1
  135. package/dist/src/execution/legacy-session/input.d.ts +0 -2
  136. package/dist/src/execution/legacy-session/input.js +1 -1
  137. package/dist/src/execution/legacy-session/prepare-step.d.ts +0 -1
  138. package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
  139. package/dist/src/execution/node-step.d.ts +4 -2
  140. package/dist/src/execution/node-step.js +1 -1
  141. package/dist/src/execution/proxied-deliver-step.js +1 -1
  142. package/dist/src/execution/publish-channel-event.d.ts +23 -0
  143. package/dist/src/execution/publish-channel-event.js +1 -0
  144. package/dist/src/execution/runtime-context.js +1 -1
  145. package/dist/src/execution/session/entry-input.d.ts +4 -0
  146. package/dist/src/execution/session/entry-input.js +1 -1
  147. package/dist/src/execution/session/entry.js +1 -1
  148. package/dist/src/execution/session/event-sink.d.ts +1 -1
  149. package/dist/src/execution/session/event-sink.js +1 -1
  150. package/dist/src/execution/session/finalization.d.ts +1 -4
  151. package/dist/src/execution/session/finalization.js +1 -1
  152. package/dist/src/execution/session/handoff.d.ts +1 -3
  153. package/dist/src/execution/session/handoff.js +1 -1
  154. package/dist/src/execution/session/input-queue.d.ts +0 -1
  155. package/dist/src/execution/session/input-queue.js +1 -1
  156. package/dist/src/execution/session/next-input.d.ts +0 -1
  157. package/dist/src/execution/session/next-input.js +1 -1
  158. package/dist/src/execution/session/program.d.ts +0 -3
  159. package/dist/src/execution/session/program.js +1 -1
  160. package/dist/src/execution/session/turn-step-result.d.ts +1 -2
  161. package/dist/src/execution/session/turn-step-result.js +1 -1
  162. package/dist/src/execution/session/turn-step.js +1 -1
  163. package/dist/src/execution/session/turn.d.ts +2 -2
  164. package/dist/src/execution/session/turn.js +1 -1
  165. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  166. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
  167. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  168. package/dist/src/execution/tools/agent-router.d.ts +0 -2
  169. package/dist/src/execution/tools/agent-router.js +1 -1
  170. package/dist/src/execution/tools/ask-question-workflow.js +1 -1
  171. package/dist/src/execution/tools/connection-search.d.ts +1 -0
  172. package/dist/src/execution/tools/connection-search.js +1 -1
  173. package/dist/src/execution/tools/sleep-workflow.js +1 -1
  174. package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -1
  175. package/dist/src/execution/workflow-runtime.js +1 -1
  176. package/dist/src/extensions/code/extension/lib/connect-authentication.js +1 -1
  177. package/dist/src/extensions/code/extension/lib/github-shell.js +1 -1
  178. package/dist/src/extensions/code/extension/lib/prwatch-github.js +1 -1
  179. package/dist/src/framework/sources/registry.js +1 -1
  180. package/dist/src/harness/approval-delivery-coordinator.d.ts +3 -13
  181. package/dist/src/harness/approval-delivery-coordinator.js +1 -1
  182. package/dist/src/harness/emission.d.ts +2 -3
  183. package/dist/src/harness/emission.js +1 -1
  184. package/dist/src/harness/input-request-resolution.d.ts +2 -0
  185. package/dist/src/harness/input-request-resolution.js +1 -1
  186. package/dist/src/harness/input-requests.d.ts +3 -3
  187. package/dist/src/harness/input-requests.js +1 -1
  188. package/dist/src/harness/pending-input-batches.d.ts +3 -3
  189. package/dist/src/harness/pending-input-batches.js +1 -1
  190. package/dist/src/harness/proxy-input-requests.d.ts +2 -0
  191. package/dist/src/harness/proxy-input-requests.js +1 -1
  192. package/dist/src/harness/session-limit-enforcement.d.ts +2 -3
  193. package/dist/src/harness/session-limit-enforcement.js +1 -1
  194. package/dist/src/harness/tool-loop.js +2 -2
  195. package/dist/src/harness/tools.js +1 -1
  196. package/dist/src/harness/types.d.ts +11 -13
  197. package/dist/src/instrumentation/session-context.js +1 -1
  198. package/dist/src/instrumentation/session-init.js +1 -1
  199. package/dist/src/internal/application/package.js +1 -1
  200. package/dist/src/internal/authored-definition/core.js +1 -1
  201. package/dist/src/internal/authored-module-loader.js +1 -2
  202. package/dist/src/internal/authored-package-boundary.d.ts +0 -1
  203. package/dist/src/internal/authored-package-boundary.js +1 -1
  204. package/dist/src/internal/authored-relative-extension-resolver.js +1 -1
  205. package/dist/src/internal/external-resources-snapshot.d.ts +46 -0
  206. package/dist/src/internal/external-resources-snapshot.js +1 -0
  207. package/dist/src/internal/external-resources.d.ts +20 -0
  208. package/dist/src/internal/external-resources.js +1 -0
  209. package/dist/src/internal/invocation/workflow-execution.d.ts +0 -2
  210. package/dist/src/internal/invocation/workflow-execution.js +1 -1
  211. package/dist/src/internal/nitro/host/build-application.js +1 -1
  212. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  213. package/dist/src/internal/nitro/host/instrumentation-entry.d.ts +3 -0
  214. package/dist/src/internal/nitro/host/instrumentation-entry.js +2 -0
  215. package/dist/src/internal/nitro/host/start-development-server.d.ts +0 -8
  216. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  217. package/dist/src/internal/nitro/host.d.ts +1 -1
  218. package/dist/src/internal/nitro/host.js +1 -1
  219. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  220. package/dist/src/internal/nitro/routes/index.js +72 -3
  221. package/dist/src/internal/workflow/development-world-client.js +1 -1
  222. package/dist/src/node_modules/.pnpm/{@vercel_cli-config@0.2.7 → @vercel_cli-config@0.3.0}/node_modules/@vercel/cli-config/dist/index.js +1 -1
  223. package/dist/src/node_modules/.pnpm/{@vercel_connect@2.2.0_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_37d5e4f23f0f03cba2e0819e67e81b38 → @vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494}/node_modules/@vercel/connect/dist/authorization.js +1 -1
  224. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/connector.js +1 -0
  225. package/dist/src/node_modules/.pnpm/{@vercel_connect@2.2.0_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_37d5e4f23f0f03cba2e0819e67e81b38 → @vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494}/node_modules/@vercel/connect/dist/installation.js +1 -1
  226. package/dist/src/node_modules/.pnpm/{@vercel_connect@2.2.0_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_37d5e4f23f0f03cba2e0819e67e81b38 → @vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494}/node_modules/@vercel/connect/dist/token.js +1 -1
  227. package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/token-util.js +1 -1
  228. package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/token.js +1 -1
  229. package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/version.js +1 -1
  230. package/dist/src/protocol/message.d.ts +4 -0
  231. package/dist/src/protocol/message.js +1 -1
  232. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +0 -1
  233. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +1 -1
  234. package/dist/src/public/channels/mcp.js +1 -1
  235. package/dist/src/public/channels/slack/activity-plan.d.ts +2 -1
  236. package/dist/src/public/channels/slack/activity-plan.js +1 -1
  237. package/dist/src/public/channels/slack/activity.d.ts +2 -0
  238. package/dist/src/public/channels/slack/activity.js +1 -1
  239. package/dist/src/public/channels/slack/api.d.ts +7 -0
  240. package/dist/src/public/channels/slack/api.js +1 -1
  241. package/dist/src/public/channels/slack/app-manifest.d.ts +9 -0
  242. package/dist/src/public/channels/slack/app-manifest.js +1 -0
  243. package/dist/src/public/channels/slack/attachments.d.ts +5 -2
  244. package/dist/src/public/channels/slack/attachments.js +1 -1
  245. package/dist/src/public/channels/slack/inbound-content.js +6 -3
  246. package/dist/src/public/channels/slack/index.d.ts +1 -0
  247. package/dist/src/public/channels/slack/input-response.d.ts +2 -0
  248. package/dist/src/public/channels/slack/input-response.js +1 -1
  249. package/dist/src/public/channels/slack/interaction-cards.js +1 -1
  250. package/dist/src/public/channels/slack/interactions.d.ts +2 -0
  251. package/dist/src/public/channels/slack/interactions.js +1 -1
  252. package/dist/src/public/channels/slack/slackChannel.d.ts +7 -1
  253. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  254. package/dist/src/public/channels/slack/slash-command.d.ts +5 -1
  255. package/dist/src/public/channels/slack/slash-command.js +1 -1
  256. package/dist/src/public/channels/slack/transport.d.ts +76 -0
  257. package/dist/src/public/channels/slack/transport.js +1 -0
  258. package/dist/src/public/definitions/remote-agent.d.ts +0 -9
  259. package/dist/src/public/definitions/workspace-agent.d.ts +0 -3
  260. package/dist/src/public/definitions/workspace-agent.js +1 -1
  261. package/dist/src/runtime/agent/bootstrap.d.ts +0 -1
  262. package/dist/src/runtime/agent/bootstrap.js +1 -1
  263. package/dist/src/runtime/connections/mcp-client.js +1 -1
  264. package/dist/src/runtime/connections/mcp-tracing.d.ts +27 -0
  265. package/dist/src/runtime/connections/mcp-tracing.js +1 -0
  266. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  267. package/dist/src/runtime/resolve-agent.js +1 -1
  268. package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +0 -2
  269. package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -1
  270. package/dist/src/runtime/subagents/dynamic-remote-agent-config.d.ts +0 -2
  271. package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -1
  272. package/dist/src/runtime/types.d.ts +1 -2
  273. package/dist/src/services/dev-client/vercel-auth-error.d.ts +1 -1
  274. package/dist/src/setup/cli/channel-setup-prompter.d.ts +2 -9
  275. package/dist/src/setup/cli/channel-setup-prompter.js +1 -1
  276. package/dist/src/setup/cli/index.d.ts +1 -1
  277. package/dist/src/setup/connection-connector.js +1 -1
  278. package/dist/src/setup/flows/model-login-connection.d.ts +0 -16
  279. package/dist/src/setup/flows/model-login-connection.js +1 -1
  280. package/dist/src/setup/flows/model-login-options.d.ts +59 -0
  281. package/dist/src/setup/flows/model-login-options.js +1 -0
  282. package/dist/src/setup/flows/model-login.js +1 -1
  283. package/dist/src/setup/flows/model-source-change.d.ts +0 -2
  284. package/dist/src/setup/flows/model-source-change.js +1 -1
  285. package/dist/src/setup/flows/registry-session.d.ts +15 -13
  286. package/dist/src/setup/flows/registry-session.js +1 -1
  287. package/dist/src/setup/flows/registry.js +1 -1
  288. package/dist/src/setup/flows/vercel-model-login.js +1 -1
  289. package/dist/src/setup/integrations/photon/setup-flow.js +1 -1
  290. package/dist/src/setup/prompter.d.ts +2 -2
  291. package/dist/src/setup/registry-setup-client.js +1 -1
  292. package/dist/src/setup/registry-setup-protocol.d.ts +0 -4
  293. package/dist/src/setup/scaffold/create/project.js +1 -1
  294. package/dist/src/setup/slack-connect-lifecycle.js +1 -1
  295. package/dist/src/setup/verified-remote-agent.d.ts +1 -0
  296. package/dist/src/setup/verified-remote-agent.js +1 -1
  297. package/dist/src/shared/action-types.d.ts +2 -2
  298. package/dist/src/shared/agent-definition.d.ts +0 -9
  299. package/dist/src/shared/agent-turn-outcome.d.ts +1 -1
  300. package/dist/src/shared/channel-definition.d.ts +2 -2
  301. package/dist/src/shared/conversation-context.d.ts +0 -4
  302. package/dist/src/shared/conversation-context.js +1 -1
  303. package/dist/src/shared/validate-authorization.js +1 -1
  304. package/dist/src/shared/vercel-connect-metadata.d.ts +12 -0
  305. package/dist/src/shared/vercel-connect-metadata.js +1 -0
  306. package/dist/src/subagents/agent-handle-errors.d.ts +0 -4
  307. package/dist/src/subagents/agent-handle-errors.js +1 -1
  308. package/dist/src/subagents/callback-route.js +1 -1
  309. package/dist/src/subagents/callback-step.d.ts +0 -22
  310. package/dist/src/subagents/callback-step.js +1 -1
  311. package/dist/src/subagents/event-proxy-step.js +1 -1
  312. package/dist/src/subagents/hitl-proxy.d.ts +3 -5
  313. package/dist/src/subagents/hitl-proxy.js +1 -1
  314. package/dist/src/subagents/invocation.d.ts +5 -6
  315. package/dist/src/subagents/parent-notification.d.ts +1 -18
  316. package/dist/src/subagents/parent-notification.js +1 -1
  317. package/dist/src/subagents/remote-dispatch.js +1 -1
  318. package/dist/src/subagents/tool.d.ts +0 -3
  319. package/dist/src/subagents/tool.js +1 -1
  320. package/dist/src/svelte/index.js +1 -1
  321. package/dist/src/svelte/use-eve-agent.js +1 -1
  322. package/dist/src/tools/framework/agent-contract.d.ts +0 -2
  323. package/dist/src/tools/framework/agent-contract.js +1 -1
  324. package/dist/src/tracing/agent-action-instrumentation.js +1 -1
  325. package/dist/src/tracing/agent-approval-instrumentation.js +1 -1
  326. package/dist/src/tracing/agent-memory-instrumentation.js +1 -1
  327. package/dist/src/tracing/agent-otel-provider.js +2 -2
  328. package/dist/src/tracing/agent-otel-session-context.js +1 -1
  329. package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
  330. package/dist/src/tracing/agent-tool-span-context.d.ts +15 -0
  331. package/dist/src/tracing/agent-tool-span-context.js +1 -0
  332. package/dist/src/tracing/otel-declaration.d.ts +4 -9
  333. package/dist/src/vue/index.js +1 -1
  334. package/dist/src/vue/use-eve-agent.js +1 -1
  335. package/docs/agent-config.md +12 -13
  336. package/docs/channels/chat-sdk.mdx +1 -1
  337. package/docs/channels/custom.mdx +1 -1
  338. package/docs/channels/eve.mdx +4 -4
  339. package/docs/channels/mcp.mdx +10 -10
  340. package/docs/channels/slack.mdx +32 -3
  341. package/docs/concepts/sessions-runs-and-streaming.md +5 -6
  342. package/docs/connections/overview.mdx +22 -0
  343. package/docs/guides/deployment/overview.md +1 -1
  344. package/docs/guides/deployment/self-hosting.md +1 -1
  345. package/docs/guides/deployment/vercel.mdx +2 -2
  346. package/docs/guides/dev-tui.md +7 -7
  347. package/docs/guides/dynamic-capabilities.md +2 -2
  348. package/docs/guides/frontend/overview.mdx +5 -3
  349. package/docs/guides/hooks.md +4 -2
  350. package/docs/guides/instrumentation/agent-runs.mdx +7 -7
  351. package/docs/guides/instrumentation/instrumentation.mdx +22 -5
  352. package/docs/guides/instrumentation/otel.mdx +30 -0
  353. package/docs/guides/remote-agents.md +3 -4
  354. package/docs/guides/self-modification.md +1 -1
  355. package/docs/memory/custom-provider.md +1 -1
  356. package/docs/protocols/acp.md +1 -1
  357. package/docs/reference/cli.md +91 -97
  358. package/docs/schedules.mdx +4 -5
  359. package/docs/subagents/index.mdx +5 -7
  360. package/docs/tools/human-in-the-loop.md +4 -0
  361. package/docs/tools/overview.mdx +2 -0
  362. package/docs/tools/workflows.mdx +1 -1
  363. package/docs/tutorial/remember-definitions.mdx +1 -1
  364. package/docs/tutorial/ship-it.mdx +1 -1
  365. package/package.json +8 -7
  366. package/dist/src/cli/commands/channels.d.ts +0 -9
  367. package/dist/src/cli/commands/channels.js +0 -1
  368. package/dist/src/compiled/_chunks/workflow/dist-CNT2vjZ4.js +0 -1
  369. package/dist/src/compiled/_chunks/workflow/dist-DtXwQbZr.js +0 -3
  370. package/dist/src/compiled/_chunks/workflow/frames-DnrfSd1P.js +0 -3
  371. package/dist/src/compiled/_chunks/workflow/resume-hook-BmJ263ZR.js +0 -1
  372. package/dist/src/compiled/_chunks/workflow/run-NLvREued.js +0 -1
  373. package/dist/src/compiled/_chunks/workflow/serialization-HCDeQWcR.js +0 -3
  374. package/dist/src/compiled/_chunks/workflow/sleep-Bi508qmg.js +0 -1
  375. package/dist/src/execution/effective-output-schema.d.ts +0 -22
  376. package/dist/src/execution/effective-output-schema.js +0 -1
  377. package/dist/src/node_modules/.pnpm/@vercel_connect@2.2.0_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_37d5e4f23f0f03cba2e0819e67e81b38/node_modules/@vercel/connect/dist/connector.js +0 -1
  378. package/dist/src/public/channels/slack/api-errors.d.ts +0 -33
  379. package/dist/src/public/channels/slack/api-errors.js +0 -1
  380. package/dist/src/shared/run-mode.d.ts +0 -7
  381. package/dist/src/shared/run-mode.js +0 -1
  382. package/dist/src/subagents/parent-result.d.ts +0 -14
  383. package/dist/src/subagents/parent-result.js +0 -1
  384. /package/dist/src/node_modules/.pnpm/{@vercel_connect@2.2.0_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_37d5e4f23f0f03cba2e0819e67e81b38 → @vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494}/node_modules/@vercel/connect/dist/index.js +0 -0
  385. /package/dist/src/node_modules/.pnpm/{@vercel_connect@2.2.0_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_37d5e4f23f0f03cba2e0819e67e81b38 → @vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494}/node_modules/@vercel/connect/dist/internal/base-url.js +0 -0
  386. /package/dist/src/node_modules/.pnpm/{@vercel_connect@2.2.0_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_37d5e4f23f0f03cba2e0819e67e81b38 → @vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494}/node_modules/@vercel/connect/dist/internal/default-scopes.js +0 -0
  387. /package/dist/src/node_modules/.pnpm/{@vercel_connect@2.2.0_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_37d5e4f23f0f03cba2e0819e67e81b38 → @vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494}/node_modules/@vercel/connect/dist/internal/env.js +0 -0
  388. /package/dist/src/node_modules/.pnpm/{@vercel_connect@2.2.0_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_37d5e4f23f0f03cba2e0819e67e81b38 → @vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494}/node_modules/@vercel/connect/dist/internal/url-validation.js +0 -0
  389. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/auth-errors.js +0 -0
  390. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/exchange-vercel-oidc-token.js +0 -0
  391. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/get-context.js +0 -0
  392. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-sync.js +0 -0
  393. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-with-refresh.js +0 -0
  394. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/index.js +0 -0
  395. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/oauth.js +0 -0
  396. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/token-error.js +0 -0
  397. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/token-io.js +0 -0
  398. /package/dist/src/node_modules/.pnpm/{@vercel_oidc@3.8.8 → @vercel_oidc@3.8.9}/node_modules/@vercel/oidc/dist/verify-vercel-oidc-token.js +0 -0
@@ -1,4 +1,4 @@
1
- import{ct as e,st as t,tt as n}from"./dist-CNT2vjZ4.js";import{Cn as r,Sn as i,Tn as a,wn as o}from"./logger-Bzc8jWWj.js";import{i as s}from"./dist-DtXwQbZr.js";function c(e,t){let n=Error.captureStackTrace;n?.(e,t)}const l=Symbol.for(`nodejs.util.inspect.custom`);function u(e){return`code`in e?`\`${e.code}\``:`dim`in e?e.dim:e.text}function d(e){return`code`in e?i(e.code):`dim`in e?r(e.dim):e.text}function f(e){return e.type===`docs`?`docs: ${e.url}`:e.segments.map(u).join(``)}function p(e){return e.type===`docs`?o(e.url):e.segments.map(d).join(``)}function m(e){let t=[e.title.map(u).join(``)];return e.details.forEach((n,r)=>{let i=r===e.details.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;f(n).split(`
1
+ import{ct as e,st as t,tt as n}from"./dist-BQSf8Hax.js";import{Cn as r,Sn as i,Tn as a,wn as o}from"./logger-BCEj9caG.js";import{i as s}from"./dist-BfMqXLK3.js";function c(e,t){let n=Error.captureStackTrace;n?.(e,t)}const l=Symbol.for(`nodejs.util.inspect.custom`);function u(e){return`code`in e?`\`${e.code}\``:`dim`in e?e.dim:e.text}function d(e){return`code`in e?i(e.code):`dim`in e?r(e.dim):e.text}function f(e){return e.type===`docs`?`docs: ${e.url}`:e.segments.map(u).join(``)}function p(e){return e.type===`docs`?o(e.url):e.segments.map(d).join(``)}function m(e){let t=[e.title.map(u).join(``)];return e.details.forEach((n,r)=>{let i=r===e.details.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;f(n).split(`
2
2
  `).forEach((e,n)=>{t.push(`${n===0?a:o}${e}`)})}),t.join(`
3
3
  `)}function h(e){let t=e.title.map(d).join(``);return a(t,e.details.map(p))}var g=class extends Error{fatal=!0;#e;constructor(e){super(m(e)),this.#e=e}[l](){let e=h(this.#e),t=this.message.split(`
4
4
  `).length,n=(this.stack??``).split(`
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-B_knIduE.js";import*as t from"#compiled/zod/index.js";import{z as n}from"#compiled/zod/index.js";import r from"node:crypto";function i(e,t,n){let r=Symbol.for(`${e}/v${t}`),i=globalThis,a=i[r];if(a!==void 0)return a;let o=n();return i[r]=o,o}const a=Symbol.for(`@workflow/world//warnedEnvValues/v1`),o=globalThis,s=o[a]??=new Set;function c(e,t){s.has(e)||(s.add(e),console.warn(`[workflow] ${t}`))}function l(e,t,n={}){let r=process.env[e];if(r===void 0||r===``)return t;let{min:i=0,max:a,integer:o=!1}=n,s=Number(r);return!Number.isFinite(s)||o&&!Number.isInteger(s)?(c(`${e}=${r}`,`Ignoring ${e}: not a ${o?`finite integer`:`finite number`}; using default ${t}`),t):s<i?(c(`${e}=${r}`,`${e} below minimum ${i}; clamped`),i):a!==void 0&&s>a?(c(`${e}=${r}`,`${e} above maximum ${a}; clamped`),a):s}function u(e,t,n=process.env){let r=n[e];if(r===void 0||r===``)return t;let i=r.toLowerCase();return i===`0`||i===`false`?!1:i===`1`||i===`true`||(c(`${e}=${r}`,`Ignoring ${e}: expected 0/1/true/false; using default ${t}`),t)}const d=25e3;function ee(){let e=l(`WORKFLOW_MAX_EVENTS`,d,{integer:!0});return e>0?e:d}const f=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`;var p;(function(e){e.Base32IncorrectEncoding=`B32_ENC_INVALID`,e.DecodeTimeInvalidCharacter=`DEC_TIME_CHAR`,e.DecodeTimeValueMalformed=`DEC_TIME_MALFORMED`,e.EncodeTimeNegative=`ENC_TIME_NEG`,e.EncodeTimeSizeExceeded=`ENC_TIME_SIZE_EXCEED`,e.EncodeTimeValueMalformed=`ENC_TIME_MALFORMED`,e.PRNGDetectFailure=`PRNG_DETECT`,e.ULIDInvalid=`ULID_INVALID`,e.Unexpected=`UNEXPECTED`,e.UUIDInvalid=`UUID_INVALID`})(p||={});var m=class extends Error{constructor(e,t){super(`${t} (${e})`),this.name=`ULIDError`,this.code=e}};function te(e){let t=Math.floor(e()*32)%32;return f.charAt(t)}function h(e,t,n){return t>e.length-1?e:e.substr(0,t)+n+e.substr(t+1)}function ne(e){let t,n=e.length,r,i,a=e;for(;!t&&n-->=0;){if(r=a[n],i=f.indexOf(r),i===-1)throw new m(p.Base32IncorrectEncoding,`Incorrectly encoded string`);if(i===31){a=h(a,n,f[0]);continue}t=h(a,n,f[i+1])}if(typeof t==`string`)return t;throw new m(p.Base32IncorrectEncoding,`Failed incrementing string`)}function re(e){if(e.length!==26)throw new m(p.DecodeTimeValueMalformed,`Malformed ULID`);let t=e.substr(0,10).toUpperCase().split(``).reverse().reduce((e,t,n)=>{let r=f.indexOf(t);if(r===-1)throw new m(p.DecodeTimeInvalidCharacter,`Time decode error: Invalid character: ${t}`);return e+=r*32**n},0);if(t>0xffffffffffff)throw new m(p.DecodeTimeValueMalformed,`Malformed ULID: timestamp too large: ${t}`);return t}function ie(e){let t=ae(),n=t&&(t.crypto||t.msCrypto)||(r===void 0?null:r);if(typeof n?.getRandomValues==`function`)return()=>{let e=new Uint8Array(1);return n.getRandomValues(e),e[0]/256};if(typeof n?.randomBytes==`function`)return()=>n.randomBytes(1).readUInt8()/256;if(r?.randomBytes)return()=>r.randomBytes(1).readUInt8()/256;throw new m(p.PRNGDetectFailure,`Failed to find a reliable PRNG`)}function ae(){return se()?self:typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:null}function oe(e,t){let n=``;for(;e>0;e--)n=te(t)+n;return n}function g(e,t=10){if(isNaN(e))throw new m(p.EncodeTimeValueMalformed,`Time must be a number: ${e}`);if(e>0xffffffffffff)throw new m(p.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${e}`);if(e<0)throw new m(p.EncodeTimeNegative,`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new m(p.EncodeTimeValueMalformed,`Time must be an integer: ${e}`);let n,r=``;for(let i=t;i>0;i--)n=e%32,r=f.charAt(n)+r,e=(e-n)/32;return r}function se(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function ce(e){let t=e||ie(),n=0,r;return function(e){let i=!e||isNaN(e)?Date.now():e;if(i<=n){let e=r=ne(r);return g(n,10)+e}n=i;let a=r=oe(16,t);return g(i,10)+a}}function le(e,t){let n=t||ie();return g(!e||isNaN(e)?Date.now():e,10)+oe(16,n)}const ue=`$rootRunId`,de=`$parentRunId`,_=`$retention`,v=`default`,fe=/^(?:0|[1-9]\d*)$/;function pe(e){let t=e?.[_];return t===void 0?{mode:`default`,wellFormed:!1,unsupported:!1}:fe.test(t)?t===`0`?{mode:`none`,raw:t,wellFormed:!0,unsupported:!1}:{mode:`default`,raw:t,wellFormed:!0,unsupported:!0}:{mode:`default`,raw:t,wellFormed:!1,unsupported:t!==v}}const y=8192,b=new TextEncoder;var x=class extends Error{constructor(e){super(e),this.name=`AttributeValidationError`}};function me(e){let t=b.encode(JSON.stringify(e)).length;if(t>8192)throw new x(`Attribute eventData exceeds limit ${y} UTF-8 JSON bytes (received ${t} bytes). Split the changes into smaller setAttributes() calls.`)}function he(e,t){if(typeof e!=`string`)throw new x(`Attribute key must be a string, got ${typeof e}`);if(e.length===0)throw new x(`Attribute key must not be empty`);if(e.length>256)throw new x(`Attribute key length ${e.length} exceeds limit 256: ${JSON.stringify(e.slice(0,32))}…`);if(!t&&e.startsWith(`$`))throw new x(`Attribute key ${JSON.stringify(e)} starts with reserved prefix "\$" — that namespace is reserved for framework/library code. Set { allowReservedAttributes: true } only if your caller is framework-level.`)}function ge(e){if(e!==null&&typeof e!=`string`)throw new x(`Attribute value must be a string or null, got ${typeof e}`);if(e===null)return;let t=b.encode(e).length;if(t>256)throw new x(`Attribute value byte length ${t} exceeds limit 256`)}function _e(e,t,n){return t===null?n?.has(e)?-1:0:+(n===void 0||!n.has(e))}function S(e,t={}){let n=new Set,r=t.existingKeys===void 0?void 0:t.existingKeys instanceof Set?t.existingKeys:new Set(t.existingKeys),i=r?.size??0;for(let{key:t,value:a}of e){if(n.has(t))throw new x(`Attribute key ${JSON.stringify(t)} appears more than once in the same batch`);n.add(t),i+=_e(t,a,r)}if(i>64)throw new x(`Run attribute count would exceed limit 64 (post-merge ${i})`)}function ve(e,t={}){for(let{key:n,value:r}of e)he(n,t.allowReservedAttributes===!0),ge(r);S(e,t)}function ye(e,t){let n={...e??{}};for(let{key:e,value:r}of t)r===null?delete n[e]:n[e]=r;return n}const be=new TextEncoder,C=t.compile(t.string().min(1,{error:`Attribute key must not be empty`}).max(256,{error:`Attribute key exceeds limit 256`})),w=t.compile(t.string().refine(e=>be.encode(e).length<=256,{error:`Attribute value exceeds limit 256 UTF-8 bytes`}).nullable()),xe=t.compile(t.object({key:C,value:w})),Se=t.compile(t.array(xe).superRefine((e,t)=>{try{S(e)}catch(n){if(!(n instanceof x))throw n;t.addIssue({code:`custom`,message:n.message,input:e})}}));function T(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Ce(e){return e.eventType===`noop`}const we={attr_set:`attr_set`,step_created:`step_created`,step_started:`step_started`,step_retrying:`step_retrying`,step_completed:`step_terminal`,step_failed:`step_terminal`,wait_created:`wait_created`,wait_completed:`wait_completed`,hook_created:`hook_created`,hook_disposed:`hook_disposed`,run_started:`run_started`};function Te(e){return T(we,e)}function Ee(e){let t=Te(e.eventType);if(t!==void 0)return t===`run_started`?{eventClass:t,entity:``}:e.correlationId?{eventClass:t,entity:e.correlationId}:void 0}const De={run_created:[`input`],run_started:[`input`],run_completed:[`output`],run_failed:[`error`],step_created:[`input`],step_started:[`input`],step_completed:[`result`],step_failed:[`error`],step_retrying:[`error`],hook_created:[`metadata`],hook_received:[`payload`]},Oe=[];function E(e){return T(De,e)??Oe}function ke(e){return E(e)[0]}const Ae=n.compile(n.instanceof(Uint8Array)),je=n.compile(n.any()),D=n.compile(n.union([Ae,je])),O=n.compile(n.enum([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`,`attr_set`,`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`,`hook_created`,`hook_received`,`hook_disposed`,`hook_conflict`,`wait_created`,`wait_completed`,`noop`]));n.compile(O.extract([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`])).options;const Me=n.compile(O.extract([`run_completed`,`run_failed`,`run_cancelled`])).options;function Ne(e){return Me.includes(e)}const Pe=n.compile(O.extract([`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`])).options;function Fe(e){return Pe.includes(e)}n.compile(O.extract([`step_completed`,`step_failed`])).options;const Ie=n.compile(O.extract([`hook_created`,`hook_received`,`hook_disposed`])).options;function Le(e){return Ie.includes(e)}const Re=n.compile(O.extract([`hook_disposed`,`hook_received`])).options;function ze(e){return Re.includes(e)}n.compile(O.extract([`wait_created`,`wait_completed`])).options;const Be=n.compile(O.extract([`step_created`,`hook_created`,`wait_created`])).options;function Ve(e){return Be.includes(e)}function He(e,t){if(t!==`none`||!(`eventData`in e))return e;let n=e.eventData;if(!n||typeof n!=`object`){let{eventData:t,...n}=e;return n}let r=E(e.eventType);if(r.length===0)return e;let i={...n};for(let e of r)delete i[e];let{eventData:a,...o}=e;return{...o,...Object.keys(i).length>0?{eventData:i}:{}}}const k=n.compile(n.object({eventType:O,correlationId:n.string().optional(),specVersion:n.number().optional()})),A={ttfs:n.number().optional(),stso:n.number().optional(),stepCount:n.number().int().positive().optional(),eventCount:n.number().int().positive().optional(),rsfs:n.number().optional(),finalSchedulingReplay:n.number().optional(),optimizations:n.array(n.string()).optional()},j=n.compile(k.extend({eventType:n.literal(`step_completed`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),workflowName:n.string().optional(),result:D,...A})})),M=n.compile(k.extend({eventType:n.literal(`step_failed`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),error:D,...A})})),N=n.compile(k.extend({eventType:n.literal(`step_retrying`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),error:D,retryAfter:n.coerce.date().optional()})})),P=n.compile(k.extend({eventType:n.literal(`step_started`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),attempt:n.number().optional(),workflowName:n.string().optional(),input:D.optional(),ownerMessageId:n.string().optional()}).optional()})),F=n.compile(k.extend({eventType:n.literal(`step_created`),correlationId:n.string(),eventData:n.object({stepName:n.string(),workflowName:n.string().optional(),input:D})})),I=n.compile(k.extend({eventType:n.literal(`hook_created`),correlationId:n.string(),eventData:n.object({token:n.string(),tokenRetentionUntil:n.coerce.date().optional(),metadata:D.optional(),isWebhook:n.boolean().optional(),isSystem:n.boolean().optional(),force:n.boolean().optional(),forceClaimedFrom:n.object({runId:n.string(),hookId:n.string(),workflowName:n.string().optional(),deploymentId:n.string().optional(),runSpecVersion:n.number().optional()}).optional()})})),L=n.compile(k.extend({eventType:n.literal(`hook_received`),correlationId:n.string(),eventData:n.object({token:n.string().optional(),payload:D})})),Ue=n.compile(k.extend({eventType:n.literal(`hook_disposed`),correlationId:n.string(),eventData:n.object({token:n.string().optional(),forceClaimedBy:n.object({runId:n.string(),hookId:n.string()}).optional()}).optional()})),We=n.compile(k.extend({eventType:n.literal(`hook_conflict`),correlationId:n.string(),eventData:n.object({token:n.string(),conflictingRunId:n.string().optional(),forceRefusedReason:n.literal(`victim-spec-version`).optional()})})),Ge=n.compile(k.extend({eventType:n.literal(`noop`),eventData:n.object({sealed:n.boolean().optional()}).passthrough().optional()})),R=n.compile(k.extend({eventType:n.literal(`wait_created`),correlationId:n.string(),eventData:n.object({resumeAt:n.coerce.date()})})),z=n.compile(k.extend({eventType:n.literal(`wait_completed`),correlationId:n.string(),eventData:n.object({resumeAt:n.coerce.date().optional()}).optional()})),Ke=n.compile(n.discriminatedUnion(`type`,[n.object({type:n.literal(`workflow`)}),n.object({type:n.literal(`step`),stepId:n.string(),attempt:n.number()})])),B=n.compile(k.extend({eventType:n.literal(`attr_set`),correlationId:n.string().optional(),eventData:n.object({changes:Se,writer:Ke,allowReservedAttributes:n.literal(!0).optional()})})),V=n.compile(k.extend({eventType:n.literal(`run_created`),eventData:n.object({deploymentId:n.string(),workflowName:n.string(),input:D,executionContext:n.record(n.string(),n.any()).optional(),attributes:n.record(n.string(),n.string()).optional(),allowReservedAttributes:n.literal(!0).optional(),encryptionPublicKey:n.string().optional()})})),H=n.compile(k.extend({eventType:n.literal(`run_started`),eventData:n.object({input:D.optional(),deploymentId:n.string().optional(),workflowName:n.string().optional(),executionContext:n.record(n.string(),n.any()).optional(),attributes:n.record(n.string(),n.string()).optional(),allowReservedAttributes:n.literal(!0).optional(),encryptionPublicKey:n.string().optional()}).optional()})),U=n.compile(k.extend({eventType:n.literal(`run_completed`),eventData:n.object({output:D.optional()})})),W=n.compile(k.extend({eventType:n.literal(`run_failed`),eventData:n.object({error:D,errorCode:n.string().optional()})})),qe=n.compile(k.extend({eventType:n.literal(`run_cancelled`),eventData:n.object({cancelReason:n.string().max(512).optional()}).optional()}));n.compile(n.discriminatedUnion(`eventType`,[V,H,U,W,qe,B,F,j,M,N,P,I,L,Ue,R,z]));const Je=n.compile(n.discriminatedUnion(`eventType`,[V,H,U,W,qe,B,F,j,M,N,P,I,L,Ue,We,R,z,Ge])),Ye=n.compile(Je.and(n.object({runId:n.string(),eventId:n.string(),createdAt:n.coerce.date(),occurredAt:n.coerce.date().optional(),specVersion:n.number().optional(),resumeId:n.string().optional()})));function Xe(e){return Ve(e.eventType)?!0:e.eventType===`step_started`&&typeof e.eventData?.stepName==`string`&&e.eventData.input!==void 0}const G=n.compile(n.enum([`pending`,`running`,`completed`,`failed`,`cancelled`])),Ze=n.compile(G.extract([`completed`,`failed`,`cancelled`])).options;function Qe(e){return Ze.includes(e)}const K=n.compile(n.object({runId:n.string(),status:G,deploymentId:n.string(),workflowName:n.string(),specVersion:n.number().optional(),executionContext:n.record(n.string(),n.any()).optional(),input:D.optional(),output:D.optional(),error:D.optional(),errorCode:n.string().optional(),attributes:n.record(n.string(),n.string()).default({}),encryptionPublicKey:n.string().optional(),expiredAt:n.coerce.date().optional(),startedAt:n.coerce.date().optional(),completedAt:n.coerce.date().optional(),createdAt:n.coerce.date(),updatedAt:n.coerce.date()})),$e=n.compile(n.discriminatedUnion(`status`,[K.extend({status:n.enum([`pending`,`running`]),output:n.undefined().optional(),error:n.undefined().optional(),completedAt:n.undefined().optional()}),K.extend({status:n.literal(`cancelled`),output:n.undefined().optional(),error:n.undefined().optional(),completedAt:n.coerce.date()}),K.extend({status:n.literal(`completed`),output:D.optional(),error:n.undefined().optional(),completedAt:n.coerce.date()}),K.extend({status:n.literal(`failed`),output:n.undefined().optional(),error:D.optional(),completedAt:n.coerce.date()})])),et=n.compile(n.object({runIds:n.array(n.string()).min(1).max(500).refine(e=>new Set(e).size===e.length,{message:`runIds must not contain duplicates`}),cancelReason:n.string().max(512).optional()})),tt=n.compile(n.discriminatedUnion(`outcome`,[n.object({runId:n.string(),outcome:n.literal(`cancelled`)}),n.object({runId:n.string(),outcome:n.literal(`already_cancelled`)}),n.object({runId:n.string(),outcome:n.literal(`not_cancellable`),status:n.string()}),n.object({runId:n.string(),outcome:n.literal(`not_found`)}),n.object({runId:n.string(),outcome:n.literal(`failed`),code:n.string(),retryable:n.boolean()})])),nt=n.compile(n.object({summary:n.object({requested:n.number(),cancelled:n.number(),alreadyCancelled:n.number(),notCancellable:n.number(),notFound:n.number(),failed:n.number()}),results:n.array(tt)})),q=n.compile(n.enum([`pending`,`running`,`completed`,`failed`,`cancelled`])),rt=n.compile(n.object({runId:n.string(),stepId:n.string(),stepName:n.string(),status:q,input:D.optional(),output:D.optional(),error:D.optional(),attempt:n.number(),startedAt:n.coerce.date().optional(),completedAt:n.coerce.date().optional(),createdAt:n.coerce.date(),updatedAt:n.coerce.date(),retryAfter:n.coerce.date().optional(),specVersion:n.number().optional()})),it=n.compile(q.extract([`completed`,`failed`,`cancelled`])).options;function at(e){return it.includes(e)}const ot=n.compile(n.enum([`waiting`,`completed`])),st=n.compile(n.object({waitId:n.string(),runId:n.string(),status:ot,resumeAt:n.coerce.date().optional(),completedAt:n.coerce.date().optional(),createdAt:n.coerce.date(),updatedAt:n.coerce.date(),specVersion:n.number().optional()})),ct=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/,J=n.compile(n.preprocess(e=>typeof e==`string`&&ct.test(e)?`${e.replace(` `,`T`)}Z`:e,n.coerce.date())),Y=n.compile(J.nullable().optional()),X=n.compile(n.string().nullable().optional()),Z=n.compile(n.boolean().nullable().optional()),lt=n.compile(n.object({runId:n.string(),status:G,deploymentId:n.string(),workflowName:n.string(),specVersion:n.coerce.number().optional(),attributes:n.record(n.string(),n.string()).default({}),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z})),ut=n.compile(n.object({runId:n.string(),stepId:n.string(),stepName:X,status:q,attempt:n.number().optional(),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z,computeInstanceId:X})),dt=n.compile(n.object({runId:n.string(),eventId:n.string(),eventType:O,correlationId:X,entityId:X,stepName:X,workflowName:n.string(),deploymentId:n.string(),specVersion:n.coerce.number().optional(),runCreatedAt:J,createdAt:J,region:X,vercelId:X,requestId:X,computeInstanceId:X,resumeAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,isWebhook:Z,isSystem:Z,workflowEncryptionEnabled:Z})),ft=n.compile(n.object({runId:n.string(),hookId:n.string(),status:n.enum([`created`,`received`,`disposed`,`conflict`]),createdAt:J,updatedAt:J,receivedAt:Y,disposedAt:Y,isWebhook:Z,isSystem:Z,workflowCoreVersion:X,workflowEncryptionEnabled:Z})),pt=n.compile(n.object({runId:n.string(),waitId:n.string(),status:ot,resumeAt:Y,createdAt:J,updatedAt:J,completedAt:Y,workflowCoreVersion:X,workflowEncryptionEnabled:Z})),mt=n.compile(n.object({key:n.string(),runCount:n.coerce.number(),firstSeenAt:J,lastSeenAt:J})),ht=1e3,gt=n.compile(n.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/,`Must match __wkf_workflow_ or __{namespace}_wkf_workflow_`)),_t=n.compile(n.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/,`Must be a valid queue name with a recognized prefix`)),vt=n.compile(n.string().regex(/^[a-z][a-z0-9]*$/,`Must be lowercase alphanumeric, starting with a letter`));function yt(e){return e??process.env.WORKFLOW_QUEUE_NAMESPACE??void 0}function bt(e,t){if(e!==`workflow`)throw Error(`Unsupported queue kind: ${e}`);return t===void 0?`__wkf_workflow_`:(vt.parse(t),`__${t}_wkf_workflow_`)}function xt(e){let t=e.match(/^(__(?:[a-z][a-z0-9]*_)?wkf_workflow_)(.+)$/);if(!t)throw Error(`Invalid queue name: ${e}`);return{prefix:gt.parse(t[1]),id:t[2]}}const St=n.compile(n.string().brand().describe(`A stored queue message ID`)),Ct=n.compile(n.record(n.string(),n.string())),wt=n.compile(n.object({input:n.unknown(),deploymentId:n.string(),workflowName:n.string(),specVersion:n.number(),executionContext:n.record(n.string(),n.any()).optional(),attributes:n.record(n.string(),n.string()).optional(),allowReservedAttributes:n.literal(!0).optional(),environment:n.string().optional()})),Tt=n.compile(n.object({input:n.custom(e=>e instanceof Uint8Array,{message:`stepInput.input must be a Uint8Array`})})),Et=n.compile(n.object({deploymentId:n.string(),specVersion:n.number(),startedAt:n.number().optional(),rootRunId:n.string().optional()})),Dt=n.compile(n.object({resumeId:n.string(),hookId:n.string(),token:n.string(),payload:n.unknown(),payloadDigest:n.string(),deploymentId:n.string().optional()})),Ot=n.compile(n.object({resumeRequestedAtMs:n.number(),queuePublishRequestedAtMs:n.number(),strategy:n.string().optional(),consumerStartedAtMs:n.number().optional(),replayStartedAtMs:n.number().optional(),nextStepEncounteredAtMs:n.number().optional(),setupSource:n.string().optional()})),kt=n.compile(n.object({runId:n.string(),invoke:n.literal(!0).optional(),requestId:n.string().optional(),input:n.unknown().optional(),traceCarrier:Ct.optional(),requestedAt:n.coerce.date().optional(),replayDivergence:n.object({eventId:n.string(),count:n.number().int().positive(),eventIds:n.array(n.string()).optional().catch(void 0)}).optional(),preconditionReinvocations:n.number().int().positive().optional(),serverErrorRetryCount:n.number().int().optional(),deploymentMismatchRetryCount:n.number().int().nonnegative().optional(),waitContinuation:n.object({correlationId:n.string(),attempt:n.number().int().nonnegative()}).optional().catch(void 0),stepId:n.string().optional(),stepName:n.string().optional(),runInput:wt.optional(),hookInput:Dt.optional(),stepInput:Tt.optional(),runContext:Et.optional(),hookResumeTiming:Ot.optional().catch(void 0)})),At=n.compile(n.object({__healthCheck:n.literal(!0),correlationId:n.string(),runId:n.string().optional()})),jt=n.compile(n.union([At,kt])),Mt=n.compile(n.object({deploymentId:n.string(),workflowName:n.string(),runSpecVersion:n.number().optional(),workflowCoreVersion:n.string().optional(),traceCarrier:Ct.optional(),encryptionPublicKey:n.string().optional(),hookResumeInputVersion:n.number().optional()})),Nt=n.compile(n.object({hookResumeDedupVersion:n.number()})),Pt=n.compile(n.object({runId:n.string(),hookId:n.string(),workflowName:n.string().optional(),deploymentId:n.string().optional(),runSpecVersion:n.number().optional()})),Ft=n.compile(n.object({runId:n.string(),hookId:n.string(),token:n.string(),ownerId:n.string(),projectId:n.string(),environment:n.string(),metadata:D.optional(),createdAt:n.coerce.date(),specVersion:n.number().optional(),isWebhook:n.boolean().optional(),isSystem:n.boolean().optional(),tokenRetentionUntil:n.coerce.date().optional(),resumeContext:Mt.optional(),resumeCapabilities:Nt.optional(),claimedFrom:Pt.optional()})),It=`WORKFLOW_NODE_HTTP`;function Lt(e=process.env){return u(It,!1,e)}async function Rt(e,t,n,r){let i=bt(`workflow`,yt(r)),a=0,o,s=!0;for(;s;){let r=await e.list({status:[`pending`,`running`],resolveData:`none`,pagination:{cursor:o}});for(let e of r.data)try{await t(`${i}${e.workflowName}`,{runId:e.runId}),a++}catch(t){console.warn(`[${n}] Failed to re-enqueue run ${e.runId}: ${t}`)}s=r.hasMore,o=r.cursor??void 0}a>0&&zt()&&console.debug(`[${n}] Re-enqueued ${a} active run(s) on startup`)}function zt(){let e=typeof process<`u`?process.env.DEBUG:void 0;return typeof e==`string`?e.includes(`workflow:`)||e===`*`:!1}const Bt=n.lazy(()=>n.union([n.string(),n.number(),n.boolean(),n.null(),n.array(Bt),n.record(n.string(),Bt)])),Vt=n.compile(n.object({currentLookbackDays:n.number(),maxLookbackDays:n.number(),currentWindowStart:n.coerce.date(),maxWindowStart:n.coerce.date(),upgradeAvailable:n.boolean()})),Ht=e=>n.compile(n.object({data:n.array(e),cursor:n.string().nullable(),hasMore:n.boolean(),pageInfo:Vt.optional()})),Ut=n.compile(n.object({message:n.string(),stack:n.string().optional(),code:n.string().optional()})),Wt=`evnt_`;function Q(e){if(e.length!==26)return!1;for(let t=0;t<10;t++)if(e[t]!==`0`)return!1;for(let t=10;t<26;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function Gt(e){let t=e.indexOf(`_`);return t===-1?e:e.slice(t+1)}function Kt(e){return Q(Gt(e))}function qt(e){if(!Number.isSafeInteger(e)||e<1)throw RangeError(`Invalid event slot: ${e}`);return`${Wt}${String(e).padStart(26,`0`)}`}function Jt(e){let t=Gt(e);if(!Q(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=1?n:null}function Yt(e){let t=Jt(e);if(t===null)throw Error(`Event id is not slot-numbered: ${e}. This World allocates event positions the runtime cannot read.`);return t}function Xt(e=process.env){return u(`WORKFLOW_SEALED_LOG`,!0,e)?8:6}function Zt(e){return e==null||e<=1}function Qt(e){return e!=null&&e>8}const $t=n.compile(n.string().ulid()),en=n.compile(n.templateLiteral([`wrun_`,n.ulid()])),tn=864e5,nn=3e5;function $(e){if(Q(e))return null;let t=$t.safeParse(e);return t.success?new Date(re(t.data)):null}function rn(e,t,n=tn,r=nn){let i=$(e.startsWith(t)?e.slice(t.length):e);if(!i)return`Invalid runId: "${e}" is not a valid ULID`;let a=new Date().getTime()-i.getTime();return a>0&&a<=n||a<=0&&-a<=r?null:`Invalid runId timestamp: embedded timestamp is ${Math.round(Math.abs(a)/1e3)}s in the ${a>0?`past`:`future`} (threshold: ${Math.round((a>0?n:r)/1e3)}s)`}var an=e({ANALYTICS_EVENTS_GET_MANY_LIMIT:()=>100,ANALYTICS_MAX_ATTRIBUTE_FILTERS:()=>8,ANALYTICS_PAGE_LIMIT:()=>100,ANALYTICS_RUN_SCOPED_PAGE_LIMIT:()=>ht,ATTRIBUTE_EVENT_DATA_MAX_BYTES:()=>y,ATTRIBUTE_KEY_MAX_LENGTH:()=>256,ATTRIBUTE_MAX_PER_RUN:()=>64,ATTRIBUTE_VALUE_MAX_BYTES:()=>256,BULK_CANCEL_MAX_RUN_IDS:()=>500,DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS:()=>nn,DEFAULT_TIMESTAMP_THRESHOLD_MS:()=>DEFAULT_TIMESTAMP_THRESHOLD_MS,DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS:()=>tn,EVENT_ID_BODY_LENGTH:()=>26,EVENT_ID_PREFIX:()=>Wt,FIRST_EVENT_SLOT:()=>1,HOOK_RESUME_DEDUP_VERSION:()=>1,HOOK_RESUME_INPUT_VERSION:()=>1,HookSchema:()=>Ft,NODE_HTTP_DEFAULT:()=>!1,NODE_HTTP_ENV_VAR:()=>It,RESERVED_ATTRIBUTE_KEY_PREFIX:()=>`$`,RETENTION_DEFAULT:()=>v,RETENTION_ZERO:()=>`0`,RUN_ENTITY_KEY:()=>``,SEALED_LOG_ENV_VAR:()=>`WORKFLOW_SEALED_LOG`,SPEC_VERSION_CURRENT:()=>8,SPEC_VERSION_LEGACY:()=>1,SPEC_VERSION_MAX_SUPPORTED:()=>8,SPEC_VERSION_SUPPORTS_ATTRIBUTES:()=>4,SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT:()=>3,SPEC_VERSION_SUPPORTS_COMPRESSION:()=>5,SPEC_VERSION_SUPPORTS_EVENT_SOURCING:()=>2,SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM:()=>8,SPEC_VERSION_SUPPORTS_SEALED_LOG:()=>7,SPEC_VERSION_SUPPORTS_SLOT_IDENTITY:()=>6});export{C as $,ut as A,Ye as B,xt as C,dt as D,mt as E,et as F,Fe as G,Xe as H,nt as I,D as J,Ne as K,K as L,st as M,rt as N,ft as O,at as P,Ce as Q,$e as R,bt as S,ht as T,ze as U,O as V,Le as W,ke as X,Ee as Y,E as Z,At as _,Zt as a,ye as at,_t as b,Jt as c,me as ct,qt as d,le as dt,w as et,Ht as f,l as ft,Ft as g,Lt as h,en as i,ue as it,pt as j,lt as k,Kt as l,re as lt,Rt as m,i as mt,$ as n,de as nt,Xt as o,pe as ot,Ut as p,ee as pt,He as q,rn as r,_ as rt,Qt as s,ve as st,an as t,x as tt,Yt as u,ce as ut,St as v,yt as w,kt as x,jt as y,Qe as z};
@@ -0,0 +1,3 @@
1
+ import{s as e,t}from"./rolldown-runtime-B_knIduE.js";function n(e,t,n){return n===1?e:t}var r=t(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),i=e(r(),1);function a(e){if(typeof e==`string`){let t=(0,i.default)(e);if(typeof t!=`number`||t<0)throw Error(`Invalid duration: "${e}". Expected a valid duration string like "1s", "1m", "1h", etc.`);return new Date(Date.now()+t)}if(typeof e==`number`){if(e<0||!Number.isFinite(e))throw Error(`Invalid duration: ${e}. Expected a non-negative finite number of milliseconds.`);return new Date(Date.now()+e)}if(e instanceof Date||e&&typeof e==`object`&&typeof e.getTime==`function`)return e instanceof Date?e:new Date(e.getTime());throw Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`)}const o={USER_ERROR:`USER_ERROR`,RUNTIME_ERROR:`RUNTIME_ERROR`,CORRUPTED_EVENT_LOG:`CORRUPTED_EVENT_LOG`,REPLAY_DIVERGENCE:`REPLAY_DIVERGENCE`,MAX_DELIVERIES_EXCEEDED:`MAX_DELIVERIES_EXCEEDED`,MAX_EVENTS_EXCEEDED:`MAX_EVENTS_EXCEEDED`,REPLAY_TIMEOUT:`REPLAY_TIMEOUT`,STREAM_ERROR:`STREAM_ERROR`,WORLD_CONTRACT_ERROR:`WORLD_CONTRACT_ERROR`,DEPLOYMENT_MISMATCH:`DEPLOYMENT_MISMATCH`};function s(e){return typeof e==`object`&&!!e&&`name`in e&&`message`in e}function c(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 l(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 u={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`,HOOK_FORCE_CLAIMED:`hook-force-claimed`,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`,DEPLOYMENT_MISMATCH:`deployment-mismatch`};var d=class extends Error{cause;constructor(e,t){let n=c(e,l(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 s(e)&&e.name===`WorkflowError`}},f=class extends d{status;code;url;retryAfter;field;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,this.field=t?.field}static is(e){return s(e)&&e.name===`WorkflowWorldError`}},p=class extends d{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 s(e)&&e.name===`WorkflowRunFailedError`}},m=class extends d{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 s(e)&&e.name===`WorkflowRunNotCompletedError`}},h=class extends d{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return s(e)&&e.name===`WorkflowRuntimeError`}},g=class extends h{constructor(e,t){super(e,{...t,slug:u.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return s(e)&&e.name===`CorruptedEventLogError`}},_=class extends h{eventId;constructor(e,t){super(e,{...t,slug:u.REPLAY_DIVERGENCE}),this.name=`ReplayDivergenceError`,this.eventId=t.eventId}static is(e){return s(e)&&e.name===`ReplayDivergenceError`&&typeof e.eventId==`string`}},v=class extends d{eventCount;limit;constructor(e,t,n){super(`Workflow exceeded the maximum of ${t} events per run`,n),this.name=`MaxEventsExceededError`,this.eventCount=e,this.limit=t}static is(e){return s(e)&&e.name===`MaxEventsExceededError`}},y=class extends h{constructor(e,t){super(e,{cause:t?.cause,slug:u.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return s(e)&&e.name===`RuntimeDecryptionError`}},b=class extends d{hint;constructor(e,t){let n=c(e,l(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return s(e)&&e.name===`WorkflowBuildError`}},x=class extends d{hint;fatal=!0;constructor(e,t){let n=c(e,l(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return s(e)&&e.name===`SerializationError`}},S=class extends h{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:u.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return s(e)&&e.name===`StepNotRegisteredError`}},C=class extends h{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:u.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return s(e)&&e.name===`WorkflowNotRegisteredError`}},w=class extends h{runId;expectedDeploymentId;actualDeploymentId;recoveryAttempts;constructor(e,t,r,i){let a=i?.recoveryAttempts??0,o=a>0?` The runtime re-routed the message to "${t}" ${a} ${n(`time`,`times`,a)} and it kept arriving elsewhere, so the run was stopped to protect against code-skew errors.`:` The run was stopped to protect against code-skew errors.`;super(`Workflow run "${e}" is pinned to deployment "${t}", but was received by deployment "${r}".${o} Verify that the run's deployment is still available and that queue callbacks are routed to it.`,{slug:u.DEPLOYMENT_MISMATCH,cause:i?.cause}),this.name=`WorkflowDeploymentMismatchError`,this.runId=e,this.expectedDeploymentId=t,this.actualDeploymentId=r,this.recoveryAttempts=a}static is(e){return s(e)&&e.name===`WorkflowDeploymentMismatchError`}},T=class extends d{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return s(e)&&e.name===`WorkflowRunNotFoundError`}},E=class extends d{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:u.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return s(e)&&e.name===`HookConflictError`}},D=class extends d{token;claimedByRunId;claimedByHookId;constructor(e,t,n){super(`Hook token "${e}" was force-claimed by another workflow (run "${t}")`,{slug:u.HOOK_FORCE_CLAIMED}),this.name=`HookForceClaimedError`,this.token=e,this.claimedByRunId=t,n!==void 0&&(this.claimedByHookId=n)}static is(e){return s(e)&&e.name===`HookForceClaimedError`}},O=class extends d{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return s(e)&&e.name===`HookNotFoundError`}},k=class extends f{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return s(e)&&e.name===`EntityConflictError`}},A=class extends f{runId;runStatus;expiredAt;constructor(e,t,n,r){super(e,{status:410,code:`run-expired`}),this.runId=t,this.runStatus=n,this.expiredAt=r,this.name=`RunExpiredError`}static is(e){return s(e)&&e.name===`RunExpiredError`}},j=class extends f{constructor(e,t){super(e,{code:o.STREAM_ERROR,cause:t?.cause,url:t?.url,status:t?.status}),this.name=`StreamError`}static is(e){return s(e)&&e.name===`StreamError`}},M=class extends f{runId;streamId;expiredAt;constructor(e,t,n,r){super(e,{status:410,code:`stream-expired`}),this.runId=t,this.streamId=n,this.expiredAt=r,this.name=`StreamExpiredError`}static is(e){return s(e)&&e.name===`StreamExpiredError`}},N=class extends f{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return s(e)&&e.name===`TooEarlyError`}},P=class extends f{retryAfter;constructor(e,t){super(e),this.name=`ThrottleError`,this.retryAfter=t?.retryAfter}static is(e){return s(e)&&e.name===`ThrottleError`}},F=class extends f{details;constructor(e,t){super(e,{status:412,retryAfter:t?.retryAfter}),this.name=`PreconditionFailedError`,this.details=t?.details}static is(e){return s(e)&&e.name===`PreconditionFailedError`}},I=class extends d{runId;constructor(e){super(`Workflow run "${e}" cancelled`,{}),this.name=`WorkflowRunCancelledError`,this.runId=e}static is(e){return s(e)&&e.name===`WorkflowRunCancelledError`}},L=class extends d{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 s(e)&&e.name===`RunNotSupportedError`}},R=class extends Error{fatal=!0;constructor(e){super(e),this.name=`FatalError`}static is(e){return s(e)?e.name===`FatalError`||e.fatal===!0:!1}},z=class extends Error{retryAfter;constructor(e,t={}){super(e),this.name=`RetryableError`,this.retryAfter=t.retryAfter===void 0?new Date(Date.now()+1e3):a(t.retryAfter)}static is(e){return s(e)&&e.name===`RetryableError`}};const B="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.",V=Symbol.for(`@workflow/errors//FatalError`),H=Symbol.for(`@workflow/errors//RetryableError`),U=Symbol.for(`@workflow/errors//HookConflictError`),W=Symbol.for(`@workflow/errors//HookForceClaimedError`),G=Symbol.for(`@workflow/errors//RuntimeDecryptionError`),K=Symbol.for(`@workflow/errors//StreamError`);typeof globalThis<`u`&&(Object.hasOwn(globalThis,V)||Object.defineProperty(globalThis,V,{value:R,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,H)||Object.defineProperty(globalThis,H,{value:z,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,U)||Object.defineProperty(globalThis,U,{value:E,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,W)||Object.defineProperty(globalThis,W,{value:D,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,G)||Object.defineProperty(globalThis,G,{value:y,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,K)||Object.defineProperty(globalThis,K,{value:j,writable:!1,enumerable:!1,configurable:!1}));export{h as A,w as C,p as D,I as E,n as F,o as M,a as N,m as O,r as P,b as S,C as T,j as _,E as a,N as b,v as c,z as d,A as f,S as g,x as h,R as i,f as j,T as k,F as l,y as m,u as n,D as o,L as p,k as r,O as s,g as t,_ as u,M as v,d as w,B as x,P as y};
@@ -0,0 +1,3 @@
1
+ import{a as e,s as t,t as n}from"./rolldown-runtime-B_knIduE.js";import{ft as r,h as i,mt as a}from"./dist-BQSf8Hax.js";import{_ as o,b as s,f as c,j as l,l as u,o as d,r as f,v as p,y as m}from"./dist-BfMqXLK3.js";import{a as h,n as g,r as _}from"./signal-exit-DZKTacNU.js";import{n as v,r as y,t as b}from"./token-util-Cm4Ec1Bg.js";import{z as x}from"#compiled/zod/index.js";import{createRequire as S}from"module";import{inspect as C}from"node:util";import w from"node:os";var T=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),ee=n(((e,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{getVercelOidcToken:()=>p,getVercelOidcTokenSync:()=>m}),n.exports=l(u);var d=T(),f=y();async function p(e){let n=``,r;try{n=m()}catch(e){r=e}try{let[{getTokenPayload:r,isExpired:i},{refreshToken:a}]=await Promise.all([await import(`./token-util-Cm4Ec1Bg.js`).then(e=>t(e.t())),await import(`./token-1wSBbi5N.js`).then(e=>t(e.default))]);(!n||i(r(n),e?.expirationBufferMs))&&(await a(e),n=m())}catch(e){let t=r instanceof Error?r.message:``;throw e instanceof Error&&(t=`${t}
2
+ ${e.message}`),t?new f.VercelOidcTokenError(t):e}return n}function m(){let e=(0,d.getContext)().headers?.[`x-vercel-oidc-token`]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error(`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`);return e}0&&(n.exports={getVercelOidcToken:p,getVercelOidcTokenSync:m})})),te=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>f.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>f.RefreshAccessTokenFailedError,getContext:()=>d.getContext,getVercelOidcToken:()=>u.getVercelOidcToken,getVercelOidcTokenSync:()=>u.getVercelOidcTokenSync,getVercelToken:()=>p.getVercelToken}),t.exports=c(l);var u=ee(),d=T(),f=v(),p=b();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})})),ne=te();let re;try{re=new TextDecoder}catch{}let E,D,O=0;const ie=[],ae=57337,oe={};let se=11281e4,k=1681e4,A=ie,ce=0,j={},M,le,ue=0,N=0,P,F,I=[],de=[],L,R,fe,pe={useRecords:!1,mapsAsObjects:!0},me=!1,he=2;try{Function(``)}catch{he=1/0}var ge=class e{constructor(e){if(e&&((e.keyMap||e._keyMap)&&!e.useRecords&&(e.useRecords=!1,e.mapsAsObjects=!0),e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.getStructures&&(e.getShared=e.getStructures),e.getShared&&!e.structures&&((e.structures=[]).uninitialized=!0),e.keyMap)){this.mapKey=new Map;for(let[t,n]of Object.entries(e.keyMap))this.mapKey.set(n,t)}Object.assign(this,e)}decodeKey(e){return this.keyMap&&this.mapKey.get(e)||e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(e){if(!this._keyMap)return e;let t=new Map;for(let[n,r]of Object.entries(e))t.set(this._keyMap.hasOwnProperty(n)?this._keyMap[n]:n,r);return t}decodeKeys(e){if(!this._keyMap||e.constructor.name!=`Map`)return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let t={};return e.forEach((e,n)=>t[B(this._mapKey.has(n)?this._mapKey.get(n):n)]=e),t}mapDecode(e,t){let n=this.decode(e);if(this._keyMap)switch(n.constructor.name){case`Array`:return n.map(e=>this.decodeKeys(e))}return n}decode(t,n){if(E)return He(()=>(Ue(),this?this.decode(t,n):e.prototype.decode.call(pe,t,n)));D=n>-1?n:t.length,O=0,ce=0,N=0,le=null,A=ie,P=null,E=t;try{R=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw E=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(j=this,L=this.sharedValues&&(this.pack?Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return M=this.structures,_e();(!M||M.length>0)&&(M=[])}else j=pe,(!M||M.length>0)&&(M=[]),L=null;return _e()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;me=!0;let a=this?this.decode(e,i):Ge.decode(e,i);if(t){if(t(a)===!1)return;for(;O<i;)if(r=O,t(_e())===!1)return}else{for(n=[a];O<i;)r=O,n.push(_e());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{me=!1,Ue()}}};function _e(){try{let e=z();if(P){if(O>=P.postBundlePosition){let e=Error(`Unexpected bundle position`);throw e.incomplete=!0,e}O=P.postBundlePosition,P=null}if(O==D)M=null,E=null,F&&=null;else if(O>D){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!me)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw Ue(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`))&&(e.incomplete=!0),e}}function z(){let e=E[O++],t=e>>5;if(e&=31,e>23)switch(e){case 24:e=E[O++];break;case 25:if(t==7)return Oe();e=R.getUint16(O),O+=2;break;case 26:if(t==7){let e=R.getFloat32(O);if(j.useFloat32>2){let t=We[(E[O]&127)<<1|E[O+1]>>7];return O+=4,(t*e+(e>0?.5:-.5)>>0)/t}return O+=4,e}e=R.getUint32(O),O+=4;break;case 27:if(t==7){let e=R.getFloat64(O);return O+=8,e}if(t>1){if(R.getUint32(O)>0)throw Error(`JavaScript does not support arrays, maps, or strings with length over 4294967295`);e=R.getUint32(O+4)}else j.int64AsNumber?(e=R.getUint32(O)*4294967296,e+=R.getUint32(O+4)):e=R.getBigUint64(O);O+=8;break;case 31:switch(t){case 2:case 3:throw Error(`Indefinite length not supported for byte or text strings`);case 4:let e=[],n,r=0;for(;(n=z())!=oe;){if(r>=se)throw Error(`Array length exceeds ${se}`);e[r++]=n}return t==4?e:t==3?e.join(``):Buffer.concat(e);case 5:let i;if(j.mapsAsObjects){let e={},t=0;if(j.keyMap)for(;(i=z())!=oe;){if(t++>=k)throw Error(`Property count exceeds ${k}`);e[B(j.decodeKey(i))]=z()}else for(;(i=z())!=oe;){if(t++>=k)throw Error(`Property count exceeds ${k}`);e[B(i)]=z()}return e}{fe&&=(j.mapsAsObjects=!0,!1);let e=new Map;if(j.keyMap){let t=0;for(;(i=z())!=oe;){if(t++>=k)throw Error(`Map size exceeds ${k}`);e.set(j.decodeKey(i),z())}}else{let t=0;for(;(i=z())!=oe;){if(t++>=k)throw Error(`Map size exceeds ${k}`);e.set(i,z())}}return e}case 7:return oe;default:throw Error(`Invalid major type for indefinite length `+t)}default:throw Error(`Unknown token `+e)}switch(t){case 0:return e;case 1:return~e;case 2:return Te(e);case 3:if(N>=O)return le.slice(O-ue,(O+=e)-ue);if(N==0&&D<140&&e<32){let t=e<16?we(e):Ce(e);if(t!=null)return t}return be(e);case 4:if(e>=se)throw Error(`Array length exceeds ${se}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=z();return t;case 5:if(e>=k)throw Error(`Map size exceeds ${se}`);if(j.mapsAsObjects){let t={};if(j.keyMap)for(let n=0;n<e;n++)t[B(j.decodeKey(z()))]=z();else for(let n=0;n<e;n++)t[B(z())]=z();return t}{fe&&=(j.mapsAsObjects=!0,!1);let t=new Map;if(j.keyMap)for(let n=0;n<e;n++)t.set(j.decodeKey(z()),z());else for(let n=0;n<e;n++)t.set(z(),z());return t}case 6:if(e>=ae){let t=M[e&8191];if(t)return t.read||(t.read=ye(t)),t.read();if(e<65536){if(e==57343){let e=Be(),t=z(),n=z();Ae(t,n);let r={};if(j.keyMap)for(let t=2;t<e;t++){let e=j.decodeKey(n[t-2]);r[B(e)]=z()}else for(let t=2;t<e;t++){let e=n[t-2];r[B(e)]=z()}return r}if(e==57342){let e=Be(),t=z();for(let n=2;n<e;n++)Ae(t++,z());return z()}if(e==ae)return ze();if(j.getShared&&(Ve(),t=M[e&8191],t))return t.read||(t.read=ye(t)),t.read()}}let n=I[e];if(n)return n.handlesRead?n(z):n(z());{let t=z();for(let n=0;n<de.length;n++){let r=de[n](e,t);if(r!==void 0)return r}return new ke(t,e)}case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:let t=(L||Pe())[e];if(t!==void 0)return t;throw Error(`Unknown token `+e)}default:if(isNaN(e)){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}throw Error(`Unknown CBOR token `+e)}}const ve=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ye(e){if(!e)throw Error(`Structure is required in record definition`);function t(){let e=E[O++];if(e&=31,e>23)switch(e){case 24:e=E[O++];break;case 25:e=R.getUint16(O),O+=2;break;case 26:e=R.getUint32(O),O+=4;break;default:throw Error(`Expected array header, but got `+E[O-1])}let t=this.compiledReader;for(;t;){if(t.propertyCount===e)return t(z);t=t.next}if(this.slowReads++>=he){let n=this.length==e?this:this.slice(0,e);return t=j.keyMap?Function(`r`,`return {`+n.map(e=>j.decodeKey(e)).map(e=>ve.test(e)?B(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>ve.test(e)?B(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`),this.compiledReader&&(t.next=this.compiledReader),t.propertyCount=e,this.compiledReader=t,t(z)}let n={};if(j.keyMap)for(let t=0;t<e;t++)n[B(j.decodeKey(this[t]))]=z();else for(let t=0;t<e;t++)n[B(this[t])]=z();return n}return e.slowReads=0,t}function B(e){if(typeof e==`string`)return e===`__proto__`?`__proto_`:e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;throw Error(`Invalid property name type `+typeof e)}let be=Se;function xe(e){be=t(1);function t(t){return function(t){let n=A[ce++];if(n==null){if(P)return Se(t);let r=e(O,D,t,E);if(typeof r==`string`)n=r,A=ie;else if(A=r,ce=1,N=1,n=A[0],n===void 0)throw Error(`Unexpected end of buffer`)}let r=n.length;return r<=t?(O+=t,n):(le=n,ue=O,N=O+r,O+=t,n.slice(0,t))}}}function Se(e){let t;if(e<16&&(t=we(e)))return t;if(e>64&&re)return re.decode(E.subarray(O,O+=e));let n=O+e,r=[];for(t=``;O<n;){let e=E[O++];if(!(e&128))r.push(e);else if((e&224)==192){let t=E[O++]&63;r.push((e&31)<<6|t)}else if((e&240)==224){let t=E[O++]&63,n=E[O++]&63;r.push((e&31)<<12|t<<6|n)}else if((e&248)==240){let t=E[O++]&63,n=E[O++]&63,i=E[O++]&63,a=(e&7)<<18|t<<12|n<<6|i;a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a)}else r.push(e);r.length>=4096&&(t+=V.apply(String,r),r.length=0)}return r.length>0&&(t+=V.apply(String,r)),t}let V=String.fromCharCode;function Ce(e){let t=O,n=Array(e);for(let r=0;r<e;r++){let e=E[O++];if((e&128)>0){O=t;return}n[r]=e}return V.apply(String,n)}function we(e){if(e<4){if(e<2){if(e===0)return``;{let e=E[O++];if((e&128)>1){--O;return}return V(e)}}{let t=E[O++],n=E[O++];if((t&128)>0||(n&128)>0){O-=2;return}if(e<3)return V(t,n);let r=E[O++];if((r&128)>0){O-=3;return}return V(t,n,r)}}{let t=E[O++],n=E[O++],r=E[O++],i=E[O++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){O-=4;return}if(e<6){if(e===4)return V(t,n,r,i);{let e=E[O++];if((e&128)>0){O-=5;return}return V(t,n,r,i,e)}}if(e<8){let a=E[O++],o=E[O++];if((a&128)>0||(o&128)>0){O-=6;return}if(e<7)return V(t,n,r,i,a,o);let s=E[O++];if((s&128)>0){O-=7;return}return V(t,n,r,i,a,o,s)}{let a=E[O++],o=E[O++],s=E[O++],c=E[O++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){O-=8;return}if(e<10){if(e===8)return V(t,n,r,i,a,o,s,c);{let e=E[O++];if((e&128)>0){O-=9;return}return V(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=E[O++],u=E[O++];if((l&128)>0||(u&128)>0){O-=10;return}if(e<11)return V(t,n,r,i,a,o,s,c,l,u);let d=E[O++];if((d&128)>0){O-=11;return}return V(t,n,r,i,a,o,s,c,l,u,d)}{let l=E[O++],u=E[O++],d=E[O++],f=E[O++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){O-=12;return}if(e<14){if(e===12)return V(t,n,r,i,a,o,s,c,l,u,d,f);{let e=E[O++];if((e&128)>0){O-=13;return}return V(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=E[O++],m=E[O++];if((p&128)>0||(m&128)>0){O-=14;return}if(e<15)return V(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=E[O++];if((h&128)>0){O-=15;return}return V(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function Te(e){return j.copyBuffers?Uint8Array.prototype.slice.call(E,O,O+=e):E.subarray(O,O+=e)}let Ee=new Float32Array(1),De=new Uint8Array(Ee.buffer,0,4);function Oe(){let e=E[O++],t=E[O++],n=(e&127)>>2;if(n===31)return t||e&3?NaN:e&128?-1/0:1/0;if(n===0){let n=((e&3)<<8|t)/(1<<24);return e&128?-n:n}return De[3]=e&128|(n>>1)+56,De[2]=(e&7)<<5|t>>3,De[1]=t<<5,De[0]=0,Ee[0]}Array(4096);var ke=class{constructor(e,t){this.value=e,this.tag=t}};I[0]=e=>new Date(e),I[1]=e=>new Date(Math.round(e*1e3)),I[2]=e=>{let t=BigInt(0);for(let n=0,r=e.byteLength;n<r;n++)t=BigInt(e[n])+(t<<BigInt(8));return t},I[3]=e=>BigInt(-1)-I[2](e),I[4]=e=>+(e[1]+`e`+e[0]),I[5]=e=>e[1]*Math.exp(e[0]*Math.log(2));const Ae=(e,t)=>{e-=57344;let n=M[e];n&&n.isShared&&((M.restoreStructures||(M.restoreStructures=[]))[e]=n),M[e]=t,t.read=ye(t)};I[105]=e=>{let t=e.length,n=e[1];Ae(e[0],n);let r={};for(let i=2;i<t;i++){let t=n[i-2];r[B(t)]=e[i]}return r},I[14]=e=>P?P[0].slice(P.position0,P.position0+=e):new ke(e,14),I[15]=e=>P?P[1].slice(P.position1,P.position1+=e):new ke(e,15);let je={Error,RegExp};I[27]=e=>(je[e[0]]||Error)(e[1],e[2]);const Me=e=>{if(E[O++]!=132){let e=Error(`Packed values structure must be followed by a 4 element array`);throw E.length<O&&(e.incomplete=!0),e}let t=e();if(!t||!t.length){let e=Error(`Packed values structure must be followed by a 4 element array`);throw e.incomplete=!0,e}return L=L?t.concat(L.slice(t.length)):t,L.prefixes=e(),L.suffixes=e(),e()};Me.handlesRead=!0,I[51]=Me,I[6]=e=>{if(!L){if(j.getShared)Ve();else return new ke(e,6)}if(typeof e==`number`)return L[16+(e>=0?2*e:-2*e-1)];let t=Error(`No support for non-integer packed references yet`);throw e===void 0&&(t.incomplete=!0),t},I[28]=e=>{F||(F=new Map,F.id=0);let t=F.id++,n=O,r=E[O],i;i=r>>5==4?[]:{};let a={target:i};F.set(t,a);let o=e();return a.used?(Object.getPrototypeOf(i)!==Object.getPrototypeOf(o)&&(O=n,i=o,F.set(t,{target:i}),o=e()),Object.assign(i,o)):(a.target=o,o)},I[28].handlesRead=!0,I[29]=e=>{let t=F.get(e);return t.used=!0,t.target},I[258]=e=>new Set(e),(I[259]=e=>(j.mapsAsObjects&&(j.mapsAsObjects=!1,fe=!0),e())).handlesRead=!0;function Ne(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function Pe(){if(!L){if(j.getShared)Ve();else throw Error(`No packed values available`)}return L}de.push((e,t)=>{if(e>=225&&e<=255)return Ne(Pe().prefixes[e-224],t);if(e>=28704&&e<=32767)return Ne(Pe().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return Ne(Pe().prefixes[e-1879048192],t);if(e>=216&&e<=223)return Ne(t,Pe().suffixes[e-216]);if(e>=27647&&e<=28671)return Ne(t,Pe().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return Ne(t,Pe().suffixes[e-1811939328]);if(e==1399353956)return{packedValues:L,structures:M.slice(0),version:t};if(e==55799)return t});const Fe=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,Ie=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],Le=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<Ie.length;e++)Re(Ie[e],Le[e]);function Re(e,t){let n=`get`+e.name.slice(0,-5),r;typeof e==`function`?r=e.BYTES_PER_ELEMENT:e=null;for(let i=0;i<2;i++){if(!i&&r==1)continue;let a=r==2?1:r==4?2:r==8?3:0;I[i?t:t-4]=r==1||i==Fe?n=>{if(!e)throw Error(`Could not find typed array for code `+t);return!j.copyBuffers&&(r===1||r===2&&!(n.byteOffset&1)||r===4&&!(n.byteOffset&3)||r===8&&!(n.byteOffset&7))?new e(n.buffer,n.byteOffset,n.byteLength>>a):new e(Uint8Array.prototype.slice.call(n,0).buffer)}:r=>{if(!e)throw Error(`Could not find typed array for code `+t);let o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=r.length>>a,c=new e(s),l=o[n];for(let e=0;e<s;e++)c[e]=l.call(o,e<<a,i);return c}}}function ze(){let e=Be(),t=O+z();for(let t=2;t<e;t++){let e=Be();O+=e}let n=O;return O=t,P=[Se(Be()),Se(Be())],P.position0=0,P.position1=0,P.postBundlePosition=O,O=n,z()}function Be(){let e=E[O++]&31;if(e>23)switch(e){case 24:e=E[O++];break;case 25:e=R.getUint16(O),O+=2;break;case 26:e=R.getUint32(O),O+=4}return e}function Ve(){if(j.getShared){let e=He(()=>(E=null,j.getShared()))||{},t=e.structures||[];j.sharedVersion=e.version,L=j.sharedValues=e.packedValues,M===!0?j.structures=M=t:M.splice.apply(M,[0,t.length].concat(t))}}function He(e){let t=D,n=O,r=ce,i=ue,a=N,o=le,s=A,c=F,l=P,u=new Uint8Array(E.slice(0,D)),d=M,f=j,p=me,m=e();return D=t,O=n,ce=r,ue=i,N=a,le=o,A=s,F=c,P=l,E=u,me=p,M=d,j=f,R=new DataView(E.buffer,E.byteOffset,E.byteLength),m}function Ue(){E=null,F=null,M=null}const We=Array(147);for(let e=0;e<256;e++)We[e]=+(`1e`+Math.floor(45.15-e*.30103));let Ge=new ge({useRecords:!1});const Ke=Ge.decode;Ge.decodeMultiple;const qe={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let Je;try{Je=new TextEncoder}catch{}let Ye,Xe;const Ze=typeof globalThis==`object`&&globalThis.Buffer,Qe=Ze!==void 0,$e=Qe?Ze.allocUnsafeSlow:Uint8Array,et=Qe?Ze:Uint8Array,tt=Qe?4294967296:2144337920;let nt,H,U,W=0,G,K=null;const rt=/[\u0080-\uFFFF]/,q=Symbol(`record-id`);var it=class extends ge{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=et.prototype.utf8Write?function(e,t,n){return H.utf8Write(e,t,n)}:Je&&Je.encodeInto?function(e,t){return Je.encodeInto(e,H.subarray(t)).written}:!1,s=this,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?128:0,l>8190)throw Error(`Maximum maxSharedStructure is 8190`);let u=e.sequential;u&&(l=0),this.structures||=[],this.saveStructures&&(this.saveShared=this.saveStructures);let d,f,p=e.sharedValues,m;if(p){m=Object.create(null);for(let e=0,t=p.length;e<t;e++)m[p[e]]=e}let h=[],g=0,_=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e))}return this.encode(e,t)},this.encode=function(o,c){if(H||(H=new $e(8192),U=new DataView(H.buffer,0,8192),W=0),G=H.length-10,G-W<2048?(H=new $e(H.length),U=new DataView(H.buffer,0,H.length),G=H.length-10,W=0):c===512&&(W=W+7&2147483640),t=W,s.useSelfDescribedHeader&&(U.setUint32(W,3654940416),W+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(K=[],K.size=1/0):K=null,n=s.structures,n){if(n.uninitialized){let e=s.getShared()||{};s.structures=n=e.structures||[],s.sharedVersion=e.version;let t=s.sharedValues=e.packedValues;if(t){m={};for(let e=0,n=t.length;e<n;e++)m[t[e]]=e}}let e=n.length;if(e>l&&!u&&(e=l),!n.transitions){n.transitions=Object.create(null);for(let t=0;t<e;t++){let e=n[t];if(!e)continue;let r,i=n.transitions;for(let n=0,a=e.length;n<a;n++){i[q]===void 0&&(i[q]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[q]=t|1048576}}u||(n.nextId=e)}if(r&&=!1,i=n||[],f=m,e.pack){let t=new Map;if(t.values=[],t.encoder=s,t.maxValues=e.maxPrivatePackedValues||(m?16:1/0),t.objectMap=m||!1,t.samplingPackedValues=d,lt(o,t),t.values.length>0){H[W++]=216,H[W++]=51,J(4);let e=t.values;v(e),J(0),J(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}nt=c&bt;try{if(nt)return;if(v(o),K&&pt(t,v),s.offset=W,a&&a.idsToInsert){W+=a.idsToInsert.length*2,W>G&&b(W),s.offset=W;let e=ft(H.subarray(t,W),a.idsToInsert);return a=null,e}return c&512?(H.start=t,H.end=W,H):H.subarray(t,W)}finally{if(n){if(_<10&&_++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,_=0,g=0,h.length>0&&(h=[]);else if(h.length>0&&!u){for(let e=0,t=h.length;e<t;e++)h[e][q]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=H.subarray(t,W);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(W=t)}},this.findCommonStringsToPack=()=>(d=new Map,m||=Object.create(null),e=>{let t=e&&e.threshold||4,n=this.pack?e.maxPrivatePackedValues||16:0;p||=this.sharedValues=[];for(let[e,i]of d)i.count>t&&(m[e]=n++,p.push(e),r=!0);for(;this.saveShared&&this.updateSharedData()===!1;);d=null});let v=n=>{W>G&&(H=b(W));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?H[W++]=t+224:(H[W++]=198,t&1?v(15-t>>1):v(t-16>>1));return}if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(K&&r>=4&&r<1024){if((K.size+=r)>61440){let e,n=(K[0]?K[0].length*3+K[1].length:0)+10;W+n>G&&(H=b(W+n)),H[W++]=217,H[W++]=223,H[W++]=249,H[W++]=K.position?132:130,H[W++]=26,e=W-t,W+=4,K.position&&pt(t,v),K=[``,``],K.size=0,K.position=e}let e=rt.test(n);K[+!e]+=n,H[W++]=e?206:207,v(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(W+s>G&&(H=b(W+s)),r<64||!o){let e,t,o,s=W+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?H[s++]=t:t<2048?(H[s++]=t>>6|192,H[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,H[s++]=t>>18|240,H[s++]=t>>12&63|128,H[s++]=t>>6&63|128,H[s++]=t&63|128):(H[s++]=t>>12|224,H[s++]=t>>6&63|128,H[s++]=t&63|128);i=s-W-a}else i=o(n,W+a,s);i<24?H[W++]=96|i:i<256?(a<2&&H.copyWithin(W+2,W+1,W+1+i),H[W++]=120,H[W++]=i):i<65536?(a<3&&H.copyWithin(W+3,W+2,W+2+i),H[W++]=121,H[W++]=i>>8,H[W++]=i&255):(a<5&&H.copyWithin(W+5,W+3,W+3+i),H[W++]=122,U.setUint32(W,i),W+=4),W+=i}else if(r===`number`){if(!this.alwaysUseFloat&&n>>>0===n)n<24?H[W++]=n:n<256?(H[W++]=24,H[W++]=n):n<65536?(H[W++]=25,H[W++]=n>>8,H[W++]=n&255):(H[W++]=26,U.setUint32(W,n),W+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?H[W++]=31-n:n>=-256?(H[W++]=56,H[W++]=~n):n>=-65536?(H[W++]=57,U.setUint16(W,~n),W+=2):(H[W++]=58,U.setUint32(W,~n),W+=4);else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){H[W++]=250,U.setFloat32(W,n);let t;if(e<4||(t=n*We[(H[W]&127)<<1|H[W+1]>>7])>>0===t){W+=4;return}W--}H[W++]=251,U.setFloat64(W,n),W+=8}}else if(r===`object`){if(!n)H[W++]=246;else{if(a){let e=a.get(n);if(e){if(H[W++]=216,H[W++]=29,H[W++]=25,!e.references){let t=a.idsToInsert||(a.idsToInsert=[]);e.references=[],t.push(e)}e.references.push(W-t),W+=2;return}a.set(n,{offset:W-t})}let e=n.constructor;if(e===Object)y(n);else if(e===Array){i=n.length,i<24?H[W++]=128|i:J(i);for(let e=0;e<i;e++)v(n[e])}else if(e===Map){if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(H[W++]=217,H[W++]=1,H[W++]=3),i=n.size,i<24?H[W++]=160|i:i<256?(H[W++]=184,H[W++]=i):i<65536?(H[W++]=185,H[W++]=i>>8,H[W++]=i&255):(H[W++]=186,U.setUint32(W,i),W+=4),s.keyMap)for(let[e,t]of n)v(s.encodeKey(e)),v(t);else for(let[e,t]of n)v(e),v(t)}else{for(let e=0,t=Ye.length;e<t;e++){let t=Xe[e];if(n instanceof t){let t=Ye[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?H[W++]=192|r:r<256?(H[W++]=216,H[W++]=r):r<65536?(H[W++]=217,H[W++]=r>>8,H[W++]=r&255):r>-1&&(H[W++]=218,U.setUint32(W,r),W+=4),t.encode.call(this,n,v,b);return}}if(n[Symbol.iterator]){if(nt){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}H[W++]=159;for(let e of n)v(e);H[W++]=255;return}if(n[Symbol.asyncIterator]||ct(n)){let e=Error(`Iterable/blob should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}if(this.useToJSON&&n.toJSON){let e=n.toJSON();if(e!==n)return v(e)}y(n)}}}else if(r===`boolean`)H[W++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)H[W++]=27,U.setBigUint64(W,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)H[W++]=59,U.setBigUint64(W,-n-BigInt(1));else if(this.largeBigIntToFloat)H[W++]=251,U.setFloat64(W,Number(n));else{n>=BigInt(0)?H[W++]=194:(H[W++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);dt(new Uint8Array(e.reverse()),b);return}W+=8}else if(r===`undefined`)H[W++]=247;else throw Error(`Unknown type: `+r)},y=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?H[W++]=160|r:r<256?(H[W++]=184,H[W++]=r):r<65536?(H[W++]=185,H[W++]=r>>8,H[W++]=r&255):(H[W++]=186,U.setUint32(W,r),W+=4),s.keyMap)for(let e=0;e<r;e++)v(s.encodeKey(t[e])),v(n[e]);else for(let e=0;e<r;e++)v(t[e]),v(n[e])}:e=>{H[W++]=185;let n=W-t;W+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(s.encodeKey(t)),v(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(t),v(e[t]),r++);H[n+++t]=r>>8,H[n+t]=r&255}:(e,t)=>{let n,a=i.transitions||(i.transitions=Object.create(null)),o=0,s=0,c,u;if(this.keyMap){u=Object.keys(e).map(e=>this.encodeKey(e)),s=u.length;for(let e=0;e<s;e++){let t=u[e];n=a[t],n||(n=a[t]=Object.create(null),o++),a=n}}else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(n=a[t],n||(a[q]&1048576&&(c=a[q]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[q];if(d!==void 0)d&=65535,H[W++]=217,H[W++]=d>>8|224,H[W++]=d&255;else if(u||=a.__keys__||(a.__keys__=Object.keys(e)),c===void 0?(d=i.nextId++,d||(d=0,i.nextId=1),d>=256&&(i.nextId=(d=l)+1)):d=c,i[d]=u,d<l){H[W++]=217,H[W++]=d>>8|224,H[W++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[q]===void 0||a[q]&1048576)&&(a[q]=d),a=a[u[e]];a[q]=d|1048576,r=!0}else{if(a[q]=d,U.setUint32(W,3655335680),W+=3,o&&(g+=_*o),h.length>=256-l&&(h.shift()[q]=void 0),h.push(a),J(s+2),v(57344+d),v(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t]);return}if(s<24?H[W++]=128|s:J(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t])},b=e=>{let n;if(e>16777216){if(e-t>tt)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(tt,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,H.length-1)>>12)+1<<12;let r=new $e(n);return U=new DataView(r.buffer,0,n),H.copy?H.copy(r,0,t,e):r.set(H.slice(t,e)),W-=t,t=0,G=r.length-10,H=r},x=100,S=1e3;this.encodeAsIterable=function(e,t){return ee(e,t,C)},this.encodeAsAsyncIterable=function(e,t){return ee(e,t,te)};function*C(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?y(e,!0):at(Object.keys(e).length,160);for(let r in e){let i=e[r];t||v(r),i&&typeof i==`object`?n[r]?yield*C(i,n[r]):yield*w(i,n,r):v(i)}}else if(i===Array){let r=e.length;J(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||W-t>x)?n.element?yield*C(r,n.element):yield*w(r,n,`element`):v(r)}}else if(e[Symbol.iterator]&&!e.buffer){H[W++]=159;for(let r of e)r&&(typeof r==`object`||W-t>x)?n.element?yield*C(r,n.element):yield*w(r,n,`element`):v(r);H[W++]=255}else ct(e)?(at(e.size,64),yield H.subarray(t,W),yield e,T()):e[Symbol.asyncIterator]?(H[W++]=159,yield H.subarray(t,W),yield e,T(),H[W++]=255):v(e);r&&W>t?yield H.subarray(t,W):W-t>x&&(yield H.subarray(t,W),T())}function*w(e,n,r){let i=W-t;try{v(e),W-t>x&&(yield H.subarray(t,W),T())}catch(a){if(a.iteratorNotHandled)n[r]={},W=t+i,yield*C.call(this,e,n[r]);else throw a}}function T(){x=S,s.encode(null,bt)}function ee(e,t,n){return x=t&&t.chunkThreshold?S=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,bt),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*te(e,t){for(let n of C(e,t,!0)){let e=n.constructor;if(e===et||e===Uint8Array)yield n;else if(ct(n)){let e=n.stream().getReader(),t;for(;!(t=await e.read()).done;)yield t.value}else if(n[Symbol.asyncIterator])for await(let e of n)T(),e?yield*te(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){H=e,U=new DataView(H.buffer,H.byteOffset,H.byteLength),W=0}clearSharedData(){this.structures&&=[],this.sharedValues&&=void 0}updateSharedData(){let e=this.sharedVersion||0;this.sharedVersion=e+1;let t=this.structures.slice(0),n=new ot(t,this.sharedValues,this.sharedVersion),r=this.saveShared(n,t=>(t&&t.version||0)==e);return r===!1?(n=this.getShared()||{},this.structures=n.structures||[],this.sharedValues=n.packedValues,this.sharedVersion=n.version,this.structures.nextId=this.structures.length):t.forEach((e,t)=>this.structures[t]=e),r}};function at(e,t){e<24?H[W++]=t|e:e<256?(H[W++]=t|24,H[W++]=e):e<65536?(H[W++]=t|25,H[W++]=e>>8,H[W++]=e&255):(H[W++]=t|26,U.setUint32(W,e),W+=4)}var ot=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function J(e){e<24?H[W++]=128|e:e<256?(H[W++]=152,H[W++]=e):e<65536?(H[W++]=153,H[W++]=e>>8,H[W++]=e&255):(H[W++]=154,U.setUint32(W,e),W+=4)}const st=typeof Blob>`u`?function(){}:Blob;function ct(e){if(e instanceof st)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function lt(e,t){switch(typeof e){case`string`:if(e.length>3){if(t.objectMap[e]>-1||t.values.length>=t.maxValues)return;let n=t.get(e);if(n)++n.count==2&&t.values.push(e);else if(t.set(e,{count:1}),t.samplingPackedValues){let n=t.samplingPackedValues.get(e);n?n.count++:t.samplingPackedValues.set(e,{count:1})}}break;case`object`:if(e){if(e instanceof Array)for(let n=0,r=e.length;n<r;n++)lt(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&lt(n,t),lt(e[n],t))}}break;case`function`:console.log(e)}}const ut=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;Xe=[Date,Set,Error,RegExp,ke,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,ot],Ye=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(H[W++]=26,U.setUint32(W,n),W+=4):(H[W++]=251,U.setFloat64(W,n),W+=8)}},{tag:258,encode(e,t){t(Array.from(e))}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t([`RegExp`,e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,n){dt(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||Qe&&this.tagUint8Array!==!1))return 64},encode(e,t,n){dt(e,n)}},Y(68,1),Y(69,2),Y(70,4),Y(71,8),Y(72,1),Y(77,2),Y(78,4),Y(79,8),Y(85,4),Y(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){H[W++]=216,H[W++]=51,J(4);let e=n.values;t(e),J(0),J(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){U.setUint32(W,3655335424),W+=3;let n=r.slice(0);n.unshift(57344),n.push(new ke(e.version,1399353956)),t(n)}else t(new ke(e.version,1399353956))}}];function Y(e,t){return!ut&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(Qe?Ze.from(i,r,n):new Uint8Array(i,r,n))}}}function dt(e,t){let n=e.byteLength;n<24?H[W++]=64+n:n<256?(H[W++]=88,H[W++]=n):n<65536?(H[W++]=89,H[W++]=n>>8,H[W++]=n&255):(H[W++]=90,U.setUint32(W,n),W+=4),W+n>=H.length&&t(W+n),H.set(e.buffer?e:new Uint8Array(e),W),W+=n}function ft(e,t){let n,r=t.length*2,i=e.length-r;t.sort((e,t)=>e.offset>t.offset?1:-1);for(let n=0;n<t.length;n++){let r=t[n];r.id=n;for(let t of r.references)e[t++]=n>>8,e[t]=n&255}for(;n=t.pop();){let t=n.offset;e.copyWithin(t+r,t,i),r-=2;let a=t+r;e[a++]=216,e[a++]=28,i=t}return e}function pt(e,t){U.setUint32(K.position+e,W-K.position-e+1);let n=K;K=null,t(n[0]),t(n[1])}let mt=new it({useRecords:!1});const ht=mt.encode;mt.encodeAsIterable,mt.encodeAsAsyncIterable;const{NEVER:gt,ALWAYS:_t,DECIMAL_ROUND:vt,DECIMAL_FIT:yt}=qe,bt=2048;if(process.env.CBOR_NATIVE_ACCELERATION_DISABLED===void 0||process.env.CBOR_NATIVE_ACCELERATION_DISABLED.toLowerCase()!==`true`){let t;try{t=typeof e==`function`?e(`cbor-extract`):S(import.meta.url)(`cbor-extract`),t&&xe(t.extractStrings)}catch{}}var X=g();const xt=`5.0.0-beta.51`,Z=a(`@workflow/world-vercel//httpPools`,1,()=>({dispatcher:void 0,queueDispatcher:void 0,streamDispatcher:void 0,streamCloseDispatcher:void 0,nodeHttpAgents:void 0})),St={connections:8,keepAliveTimeout:1e4},Ct=3e5,wt=3e5,Tt={...St,allowH2:!1,pipelining:1},Et=()=>r(`WORKFLOW_VERCEL_QUEUE_TIMEOUT_MS`,3e4,{integer:!0,min:5e3,max:12e4});function Dt(){let e=Et();return{...Tt,connections:r(`WORKFLOW_VERCEL_QUEUE_CONNECTIONS`,64,{integer:!0,min:1,max:1024}),headersTimeout:e,bodyTimeout:e}}const Ot=X.DecoratorHandler;function kt(e){class t extends Ot{#e=!1;#t;#n;constructor(t){super(t),this.#n=setTimeout(()=>{this.#e=!0,this.#r()},e),this.#n.unref?.()}#r(){this.#t?.abort(Error(`Queue request exceeded its ${e}ms deadline`))}onRequestStart(e,t){this.#t=e,super.onRequestStart(e,t),this.#e&&this.#r()}onResponseEnd(e,t){clearTimeout(this.#n),super.onResponseEnd(e,t)}onResponseError(e,t){clearTimeout(this.#n),super.onResponseError(e,t)}}return e=>(n,r)=>e(n,new t(r))}const At={...St,allowH2:!0,pipelining:100,initialWindowSize:4194304,connectionWindowSize:16777216},jt={...St,allowH2:!1,pipelining:1},Mt={...St,allowH2:!0,pipelining:1},Nt={retryAfter:!0,statusCodes:[500,502,503,504]},Pt={retryAfter:!0,methods:[`PUT`],statusCodes:[429]},Ft={retryAfter:!0,methods:[`PUT`],statusCodes:[429,500,502,503,504]};function It(){return process.env.WORKFLOW_H2_MULTIPLEX!==`0`}function Lt(e){if(!e||typeof e!=`object`||Array.isArray(e))return NaN;let t=e,n=t[`content-length`]??t[`Content-Length`];return typeof n==`string`||typeof n==`number`?Number(n):NaN}function Rt(e){return(t,n)=>{let r=t.body,i=!!r&&typeof r!=`string`&&!Buffer.isBuffer(r)&&typeof r[Symbol.asyncIterator]==`function`,a=Lt(t.headers);return!i||!(a>=0)||a>1048576?e({...t,idempotent:!0},n):((async()=>{try{let i=[];for await(let e of r)i.push(Buffer.from(e));e({...t,body:Buffer.concat(i),idempotent:!0},n)}catch(e){n.onError?.(e)}})(),!0)}}const zt=new Set([`UND_ERR_INFO`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`ERR_HTTP2_GOAWAY_SESSION`,`ERR_HTTP2_INVALID_SESSION`,`ERR_HTTP2_SESSION_ERROR`,`ERR_HTTP2_STREAM_ERROR`]);function Bt(e){let t=e;for(let e=0;t&&e<8;e++){let e=t.code;if(typeof e==`string`&&zt.has(e))return!0;t=t.cause}return!1}function Vt(e,t){let n,r=0,i=0;function a(e){let t=setTimeout(()=>{Promise.resolve(e.close?.()).catch(()=>void 0)},5e3),n=setTimeout(()=>{Promise.resolve(e.destroy?.()).catch(()=>void 0)},6e4);t.unref?.(),n.unref?.()}return{get(){return n??=e(),n},note(e,o){if(!n||e!==n)return;if(o===void 0){r=0;return}if(!Bt(o)||(r++,r<3))return;let s=Date.now();if(s-i<5e3)return;i=s,r=0;let c=n;n=void 0,console.warn(`[workflow] ${t}: rebuilding connection pool after 3 consecutive transport failures`),a(c)}}}const Ht=a(`@workflow/world-vercel//eventsDispatcherRecycler@${xt}`,1,()=>Vt(()=>Qt(),`events transport`));function Ut(e,t){Ht.note(e,t)}function Wt(e,t){return e?.dispatcher?e.dispatcher:i()?void 0:t()}function Gt(e){if(!e?.dispatcher&&i())return Z.nodeHttpAgents??=_({maxSockets:St.connections,keepAliveMs:St.keepAliveTimeout}),Z.nodeHttpAgents}function Kt(e){return Wt(e,rn)}function qt(e){return Wt(e,nn)}function Jt(e){return Wt(e,()=>Ht.get())}function Yt(e){return Wt(e,an)}function Xt(e){return Wt(e,on)}function Zt(e,t){return new X.RetryAgent(new X.Agent(e),t)}function Qt(e){let t=It(),n=new X.RetryAgent(new X.Agent({...t?At:jt,...e}),Nt);return t?$t(n,n.compose(Rt)):n}function $t(e,t){return new Proxy(t,{get:(t,n)=>n===`close`||n===`destroy`?e[n].bind(e):t[n]})}function en(e,t){return new X.RetryAgent(new X.Agent({...Mt,...t}),e)}function tn(){return new X.RetryAgent(new X.Agent(Dt()).compose(kt(Et())),Nt)}function nn(){return Z.queueDispatcher??=tn(),Z.queueDispatcher}function rn(){return Z.dispatcher??=Zt(Tt,Nt),Z.dispatcher}function an(){return Z.streamDispatcher??=en(Pt),Z.streamDispatcher}function on(){return Z.streamCloseDispatcher??=en(Ft),Z.streamCloseDispatcher}const sn=a(`@workflow/world-vercel//telemetry`,1,()=>({apiPromise:null,tracerPromise:null}));async function cn(){return sn.apiPromise||=import(`../../@opentelemetry/api/index.js`).catch(e=>(typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)&&console.warn(`[workflow] @opentelemetry/api unavailable — world-vercel spans disabled:`,e instanceof Error?e.message:e),null)),sn.apiPromise}function ln(){return typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)}let un=!1;function dn(e,t){if(!un&&ln()){un=!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.world_vercel`);console.warn(`[workflow:otel-diag] world-vercel`,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] world-vercel failed:`,e instanceof Error?e.message:e)}}}async function fn(){return sn.tracerPromise||=cn().then(e=>{if(!e)return null;let t=e.trace.getTracer(`workflow`);return dn(e,t),t}),sn.tracerPromise}async function pn(e,...t){let[n,r]=await Promise.all([fn(),cn()]),{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}),t}finally{e.end()}})}async function mn(e){let t=await cn();if(t)return t.SpanKind[e]}async function hn(e){for(let[t,n]of Object.entries(await gn()))e.set(t,n)}async function gn(){let e=await cn();if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}function Q(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const _n=Q(`http.request.method`),vn=Q(`url.full`),yn=Q(`server.address`),bn=Q(`server.port`),xn=Q(`http.response.status_code`),$=Q(`error.type`),Sn=Q(`network.protocol.name`),Cn=Q(`workflow.world.parse.format`),wn=Q(`peer.service`),Tn=Q(`rpc.system`),En=Q(`rpc.service`),Dn=Q(`rpc.method`),On=Q(`workflow.run.id`),kn=Q(`step.id`),An=Q(`workflow.stream.name`),jn=Q(`workflow.stream.operation`),Mn=Q(`workflow.stream.start_index`),Nn=Q(`workflow.events.transport`),Pn=Q(`workflow.http.transport`),Fn=Q(`workflow.event.type`),In=Q(`workflow.step_start.mode`),Ln=Q(`workflow.step_start.owner_stamped`),Rn=Q(`workflow.client.version`),zn=Q(`step.stso_ms`),Bn=Q(`step.latency_optimizations`),Vn=Q(`workflow.events.ws.url`),Hn=Q(`workflow.events.ws.req_id`),Un=Q(`workflow.events.ws.reconnect_attempt`),Wn=new Set([`UND_ERR_INFO`,`UND_ERR_REQ_RETRY`,`UND_ERR_SOCKET`,`UND_ERR_CONNECT`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CLOSED`,`ECONNRESET`,`ECONNREFUSED`,`ENOTFOUND`,`EAI_AGAIN`,`EPIPE`,`ETIMEDOUT`]);function Gn(e){let t=e;for(let e=0;t&&e<8;e++){let e=t.code;if(typeof e==`string`&&Wn.has(e))return e;t=t.cause}}function Kn(e){let{protocol:t,username:n,password:r}=new URL(e);if(t!==`http:`&&t!==`https:`)throw TypeError(`Unsupported URL protocol ${t}; expected http: or https:`);if(n||r)throw TypeError(`HTTP(S) URLs with embedded credentials are unsupported`)}const qn=new Set([`ERR_INVALID_URL`,`ERR_INVALID_ARG_TYPE`,`ERR_INVALID_ARG_VALUE`,`ERR_INVALID_CHAR`,`ERR_INVALID_HTTP_TOKEN`,`ERR_HTTP_INVALID_HEADER_VALUE`,`ERR_UNESCAPED_CHARACTERS`,`UND_ERR_INVALID_ARG`,`UND_ERR_NOT_SUPPORTED`]);function Jn(e){let t=Gn(e);if(t)return t;let n,r,i=e;for(let e=0;i&&e<8;e++){let{code:e,name:t,message:a}=i;if(t===`Error`&&a===`bad port`&&e===void 0)return;if(typeof e==`string`&&e){if(qn.has(e))return;n??=e}typeof t==`string`&&t&&(r=t),i=i.cause}return n??r??`unknown`}const Yn=()=>r(`WORKFLOW_REQUEST_TIMEOUT_MS`,6e4,{integer:!0,min:1e4,max:12e4}),Xn=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`),Zn=[`x-vercel-id`,`x-vercel-error`,`x-vercel-mitigated`];function Qn(e){return Zn.flatMap(t=>{let n=e.get(t);return n?[`${t}=${n}`]:[]})}function $n(e){let t=Qn(e);return t.length>0?` (${t.join(`; `)})`:``}function er(e,t,n,r){if(!Xn)return;let i=Qn(n.headers),a=i.length>0?`; ${i.join(`; `)}`:``;console.debug(`[workflow:world-vercel:http] ${e} ${t} -> ${n.status} (${r}ms${a})`)}function tr(e,t,n){if(!process.env.DEBUG)return;let r=Array.from(n.entries()).filter(([e])=>e.toLowerCase()!==`authorization`).map(([e,t])=>`-H "${e}: ${t}"`).join(` `);console.error(`Failed to fetch, reproduce with:\ncurl -X ${e} ${r} "${t}"`)}function nr(e){if(!e)return;let t=parseInt(e,10);return Number.isNaN(t)?void 0:t}function rr(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function ir(e,t,n={}){let{retryAfter:r,code:i,url:a,mitigated:o,details:h}=n;if(e===409&&i===`hook-force-claimed`){let e=h&&typeof h==`object`?h.claimedBy:void 0;return new d(``,typeof e?.runId==`string`?e.runId:`unknown`,typeof e?.hookId==`string`?e.hookId:void 0)}if(e===409)return new f(t);if(e===410){if(i===`stream-expired`){let e=h&&typeof h==`object`?h:void 0,n=typeof e?.expiredAt==`string`?new Date(e.expiredAt):void 0;return new p(t,typeof e?.runId==`string`?e.runId:void 0,typeof e?.streamId==`string`?e.streamId:void 0,n&&!Number.isNaN(n.getTime())?n:void 0)}return new c(t)}return e===412?new u(t,{retryAfter:r,details:h}):e===425?new s(t,{retryAfter:r}):e===429?ar(e,o)?new l(`${t} (x-vercel-mitigated=challenge)`,{url:a,status:e,code:`TRANSPORT`,retryAfter:r}):new m(t,{retryAfter:r}):new l(t,{url:a,status:e,code:i,retryAfter:r})}function ar(e,t){return e===429&&t===`challenge`}async function or(e){return e?.token??process.env.VERCEL_TOKEN??await(0,ne.getVercelOidcToken)().catch(()=>null)}function sr(e){try{let t=new URL(e),n=t.protocol===`https:`||t.protocol===`wss:`;return{serverAddress:t.hostname,serverPort:t.port?parseInt(t.port,10):n?443:80}}catch{return{}}}function cr(e){let{method:t,url:n,peerService:r}=e,{serverAddress:i,serverPort:a}=sr(n);return{..._n(t),...vn(n),...i?yn(i):{},...a?bn(a):{},...wn(r),...Tn(`http`),...En(r)}}async function lr(e,t){let{method:n,url:r,peerService:i=`workflow-server`,spanName:a,attributes:o}=e;return pn(a??`http ${n}`,{kind:await mn(`CLIENT`)},async e=>{if(a&&Xn&&e){let t=e.spanContext();console.warn(`[workflow:otel-diag] span-open`,JSON.stringify({spanName:a,traceId:t.traceId,spanId:t.spanId,recording:e.isRecording()}))}return e?.setAttributes(cr({method:n,url:r,peerService:i})),o&&e?.setAttributes(o),t(e)})}function ur(e,t){e?.setAttributes({...xn(t)}),(t<200||t>=300)&&e?.setAttributes({...$(`HTTP ${t}`)})}async function dr(e){let{method:t,url:n,headers:r,body:i,dispatcher:a,peerService:s,timeoutMs:c=Yn(),signal:u,injectTraceContext:d=!0,cacheBust:f=!0,logLabel:p,buildError:m,spanName:g,attributes:_,durationAttribute:v,onTransportOutcome:y,deferTransportSuccessUntilBody:b=!1,onRequestDispatched:x,transportErrorCode:S=`TRANSPORT`}=e,C=p??n;return Kn(n),lr({method:t,url:n,peerService:s,spanName:g,attributes:_},async e=>{d&&await hn(r),f&&r.set(`X-Request-Time`,Date.now().toString());let s=c==null?void 0:AbortSignal.timeout(c),p=u&&s?AbortSignal.any([u,s]):u??s,g=a?void 0:Gt();e?.setAttributes({...Pn(g?`node-http`:`undici`)});let _=Date.now(),w;try{let e=g?h(n,{method:t,headers:r,body:i,signal:p,agents:g,headersTimeoutMs:Ct,bodyTimeoutMs:wt}):fetch(n,{method:t,headers:r,body:i,signal:p,dispatcher:a});x?.(),w=await e}catch(r){let i=Date.now()-_;if(y?.(r),r instanceof Error&&(r.name===`TimeoutError`||r.name===`AbortError`)){let a=`${t} ${C} timed out after ${i}ms`,s=S===`STREAM_ERROR`?`STREAM_ERROR`:`TIMEOUT`,c=s===`STREAM_ERROR`?new o(a,{url:n,cause:r}):new l(a,{url:n,code:s,cause:r});throw e?.setAttributes({...$(s)}),e?.recordException?.(c),c}let a=Jn(r);if(a){let s=`${t} ${C} transport failure after ${i}ms (${a})`,c=S===`STREAM_ERROR`?`STREAM_ERROR`:`TRANSPORT`,u=c===`STREAM_ERROR`?new o(s,{url:n,cause:r}):new l(s,{url:n,code:c,cause:r});throw e?.setAttributes({...$(c)}),e?.recordException?.(u),u}throw r}let T=Date.now()-_;if(w.ok&&!b&&y?.(void 0,w),er(t,C,w,T),ur(e,w.status),v&&e?.setAttributes({[v]:T}),!w.ok){if(tr(t,n,r),m){let r;try{r=await m(w)}catch(r){let i=Gn(r);if(i){y?.(r,w);let a=`${t} ${C} response body transport failure (${i})`,s=S===`STREAM_ERROR`?new o(a,{url:n,cause:r}):new l(a,{url:n,code:`TRANSPORT`,cause:r});throw e?.setAttributes({...$(S)}),e?.recordException?.(s),s}throw y?.(void 0,w),r}throw y?.(void 0,w),e?.recordException?.(r),r}let i=``;try{i=await w.text(),y?.(void 0,w)}catch(e){y?.(e,w)}let a=ir(w.status,`${t} ${C} -> HTTP ${w.status}: ${w.statusText}${i?` ${i}`:``}${$n(w.headers)}`,{url:n,retryAfter:nr(w.headers.get(`Retry-After`))});throw e?.recordException?.(a),a}return w})}const fr=new Set([`GET`,`HEAD`]),pr=()=>process.env.VERCEL_WORKFLOW_SERVER_URL||``,mr=()=>process.env.WORKFLOW_TEST_LIMIT_OVERRIDES?.trim()||``;function hr(e){return e}const gr=(...e)=>e.filter(Boolean).join(` `),_r=()=>{let e=process.env.VERCEL_DEPLOYMENT_ID;return e?`@workflow/world-vercel/${xt} node-${process.version} ${w.platform()} (${w.arch()}) ${e}`:`@workflow/world-vercel/${xt} node-${process.version} ${w.platform()} (${w.arch()})`},vr=e=>{let t=e?.projectConfig,n=pr()||`https://vercel-workflow.com`,r=process.env.WORKFLOW_VERCEL_BACKEND_URL,i=!!(t?.projectId&&t?.teamId);return{baseUrl:i?r||`https://api.vercel.com/v1/workflow`:`${n}/api`,usingProxy:i}},yr=e=>{let t=e?.projectConfig;return t?t.environment||`production`:process.env.VERCEL_TARGET_ENV||process.env.VERCEL_ENV||void 0},br=(e,t)=>{let n=e?.projectConfig,r=new Headers(e?.headers);r.set(`User-Agent`,gr(_r(),r.get(`User-Agent`)));let i=mr();i&&r.set(`x-workflow-test-limit-overrides`,i),n&&(r.set(`x-vercel-environment`,yr(e)),n.projectId&&r.set(`x-vercel-project-id`,n.projectId),n.teamId&&r.set(`x-vercel-team-id`,n.teamId));let a=pr();return a&&t.usingProxy&&r.set(`x-vercel-workflow-api-url`,a),r};async function xr(e){let{baseUrl:t,usingProxy:n}=vr(e),r=br(e,{usingProxy:n});if(n){if(!e?.token)throw Error(`world-vercel: api-workflow proxy requested (${t}) but no Vercel auth token was provided. Pass one as \`config.token\` (the SDK reads it from \`WORKFLOW_VERCEL_AUTH_TOKEN\`).`);r.set(`Authorization`,`Bearer ${e.token}`)}else{let t;try{t=await(0,ne.getVercelOidcToken)()}catch{}let n=e?.token??t;n&&r.set(`Authorization`,`Bearer ${n}`),t&&r.set(`x-vercel-trusted-oidc-idp-token`,t)}return{baseUrl:t,headers:r,usingProxy:n}}async function Sr({endpoint:e,options:t={},config:n={},schema:r,data:i,onResponse:a,retryConnectTimeout:o=!1}){let s=(t.method||`GET`).toUpperCase(),{baseUrl:c,headers:u}=await xr(n),d=`${c}${e}`;return Kn(d),pn(`http ${s}`,{kind:await mn(`CLIENT`)},async c=>{c?.setAttributes(cr({method:s,url:d,peerService:`workflow-server`})),u.set(`Accept`,`application/cbor`),await hn(u);let f;i!==void 0&&(u.set(`Content-Type`,`application/cbor`),f=ht(i));let p=fr.has(s),m,g=``;for(let r=0;;r++){u.set(`X-Request-Time`,Date.now().toString());let i=AbortSignal.timeout(Yn()),_=t.signal?AbortSignal.any([t.signal,i]):i,v=Gt(n),y=v?void 0:new Request(d,{...t,body:f,headers:u,signal:_}),b=v?void 0:Kt(n);c?.setAttributes({...Pn(v?`node-http`:`undici`)});let x=Date.now(),S;try{S=v?await h(d,{method:s,headers:u,body:f,signal:_,agents:v,headersTimeoutMs:Ct,bodyTimeoutMs:wt}):await fetch(y,{dispatcher:b})}catch(t){let n=Date.now()-x;if(t instanceof Error&&(t.name===`TimeoutError`||t.name===`AbortError`)){let r=new l(`${s} ${e} timed out after ${n}ms`,{url:d,code:`TIMEOUT`,cause:t});throw c?.setAttributes({...$(`TIMEOUT`)}),c?.recordException?.(r),r}let i=Jn(t);if(i){if(o&&p&&i===`UND_ERR_CONNECT_TIMEOUT`&&r===0){await new Promise(e=>setTimeout(e,100));continue}let a=new l(`${s} ${e} transport failure after ${n}ms (${i})`,{url:d,code:`TRANSPORT`,cause:t});throw c?.setAttributes({...$(`TRANSPORT`)}),c?.recordException?.(a),a}throw t}let C=Date.now()-x;if(g=$n(S.headers),er(s,e,S,C),c?.setAttributes({...xn(S.status)}),!S.ok){let t=await wr(S).then(e=>e.data).catch(()=>({})),n=t.code??t.error;tr(s,d,u);let r=nr(S.headers.get(`Retry-After`)),i=(t.message||`${s} ${e} -> HTTP ${S.status}: ${S.statusText}`)+g,a=ir(S.status,i,{url:d,code:n,retryAfter:r,mitigated:S.headers.get(`x-vercel-mitigated`),details:t.details});throw c?.setAttributes({...$(n||`HTTP ${S.status}`)}),c?.recordException?.(a),a}a?.(S);try{m=await pn(`world.parse`,async e=>{let t=await wr(S),n=(S.headers.get(`Content-Type`)||``).includes(`application/cbor`);return e?.setAttributes({...Cn(n?`cbor`:`json`)}),t});break}catch(t){if(p&&r<2){let n=100*2**r;c?.setAttributes({...$(`PARSE_ERROR_RETRYING`)}),Xn&&console.debug(`[workflow:world-vercel:http] ${s} ${e} body parse failed (attempt ${r+1}/3); retrying in ${n}ms: ${t}`),await new Promise(e=>setTimeout(e,n));continue}let n=S.headers.get(`Content-Type`)||`unknown`;throw new l(`Failed to parse response body for ${s} ${e}${g} (Content-Type: ${n}):\n\n${t}`,{url:d,code:`PARSE_ERROR`,cause:t})}}return await pn(`world.validate`,async()=>{let t=r.safeParse(m.data);if(!t.success){let n=t.error.issues.map(e=>` ${e.path.length>0?e.path.join(`.`):`<root>`}: ${e.message}`).join(`
3
+ `),r=process.env.DEBUG?`\n\nResponse context: ${m.getDebugContext()}`:``;throw new l(`Schema validation failed for ${s} ${e}${g}:\n${n}${r}`,{url:d,code:`SCHEMA_VALIDATION`,cause:t.error})}return t.data})})}function Cr(e){let t=C(e,{depth:3,maxArrayLength:10,breakLength:120});return t.length>500?`${t.slice(0,500)}...`:t}async function wr(e){let t=e.headers.get(`Content-Type`)||``;if(t.includes(`application/cbor`)){let n=await e.arrayBuffer(),r=Ke(new Uint8Array(n));return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.byteLength} bytes (CBOR), preview: ${Cr(r)}`}}let n=await e.text(),r=JSON.parse(n);return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.length} bytes, preview: ${Cr(r)}`}}function Tr(){return process.env.WORKFLOW_EVENTS_TRANSPORT?.trim().toLowerCase()!==`http`}function Er(){let e=process.env.WORKFLOW_INTERNAL_EVENTS_TRANSPORT_STRICT;return e===`1`||e===`true`}function Dr(){return process.env.WORKFLOW_STREAMS_TRANSPORT===`ws`}const Or=`application/vnd.workflow.v4-frames`;var kr=class extends Error{};const Ar=x.compile(x.record(x.string(),x.unknown()));function jr(e,t){let n=new Uint8Array(ht(e)),r=new Uint8Array(4+n.byteLength+4+t.byteLength),i=new DataView(r.buffer);return i.setUint32(0,n.byteLength,!1),r.set(n,4),i.setUint32(4+n.byteLength,t.byteLength,!1),r.set(t,4+n.byteLength+4),r}async function*Mr(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():Pr(e.getReader()),n=new Uint8Array,r=async e=>{if(n.byteLength>=e)return!0;let r=[n],i=n.byteLength;for(;i<e;){let e;try{e=await t.next()}catch(e){throw new kr(`decodeFrames: source stream failed`,{cause:e})}if(e.done)return!1;e.value.byteLength!==0&&(r.push(e.value),i+=e.value.byteLength)}n=new Uint8Array(i);let a=0;for(let e of r)n.set(e,a),a+=e.byteLength;return!0},i=e=>{let t=n.subarray(0,e);return n=n.subarray(e),t};try{for(;;){if(!await r(4))return;let e=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),!await r(e))throw new kr(`decodeFrames: truncated meta block`);let t=Ar.parse(Ke(i(e)));if(!await r(4))throw new kr(`decodeFrames: truncated body length`);let a=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),a>0&&!await r(a))throw new kr(`decodeFrames: truncated body bytes`);if(yield{meta:t,body:n.slice(0,a)},i(a),t._end===1)return}}finally{Nr(()=>t.return?.())}}function Nr(e){try{Promise.resolve(e()).catch(()=>{})}catch{}}async function*Pr(e){try{for(;;){let{done:t,value:n}=await e.read();if(t)return;n&&(yield n)}}finally{Nr(()=>e.cancel())}}export{Xt as $,Tn as A,An as B,or as C,wn as D,Sn as E,Fn as F,Vn as G,Mn as H,Nn as I,hn as J,mn as K,On as L,Bn as M,zn as N,Dn as O,Rn as P,qt as Q,In as R,ur as S,$ as T,Un as U,jn as V,Hn as W,Kt as X,pn as Y,Jt as Z,Qn as _,Tr as a,te as at,dr as b,hr as c,vr as d,Yt as et,Sr as f,Yn as g,ir as h,jr as i,Ke as it,kn as j,En as k,br as l,Jn as m,Or as n,xt as nt,Er as o,yr as p,gn as q,Mr as r,ht as rt,Dr as s,kr as t,Ut as tt,xr as u,rr as v,lr as w,nr as x,er as y,Ln as z};
@@ -1 +1 @@
1
- import{P as e,k as t}from"./dist-DtXwQbZr.js";function n(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function r(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}var i=class t extends Error{items;steps;globalThis;stepCount;hookCount;waitCount;attributeCount;hookDisposedCount;abortCount;constructor(t,n){let r=[...t.values()],i=0,a=0,o=0,s=0,c=0,l=0;for(let e of r)e.type===`step`?i++:e.type===`hook`?e.disposed?c++:e.abortRequested?l++:a++:e.type===`wait`?o++:e.type===`attribute`&&s++;let u=[];i>0&&u.push(`${i} ${e(`step`,`steps`,i)}`),a>0&&u.push(`${a} ${e(`hook`,`hooks`,a)}`),o>0&&u.push(`${o} ${e(`wait`,`waits`,o)}`),s>0&&u.push(`${s} ${e(`attribute write`,`attribute writes`,s)}`),c>0&&u.push(`${c} hook ${e(`disposal`,`disposals`,c)}`);let d=i+a+o+s+c,f=e(`has`,`have`,d),p=+(i>0)+ +(a>0)+ +(o>0)+ +(s>0)+ +(c>0),m;m=p>1?`processed`:i>0?`run`:a>0||o>0?`created`:s>0?`written`:c>0?`processed`:`received`;let h=u.length>0?`${u.join(` and `)} ${f} not been ${m} yet`:`0 steps have not been run yet`;super(h),this.name=`WorkflowSuspension`,this.items=r,this.steps=r,this.globalThis=n,this.stepCount=i,this.hookCount=a,this.waitCount=o,this.attributeCount=s,this.hookDisposedCount=c,this.abortCount=l}static is(e){return e instanceof t}};function a(){throw new t(`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.`)}export{n as i,i as n,r,a as t};
1
+ import{A as e,F as t}from"./dist-BfMqXLK3.js";function n(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function r(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}var i=class e extends Error{items;steps;globalThis;stepCount;hookCount;waitCount;attributeCount;hookDisposedCount;abortCount;constructor(e,n){let r=[...e.values()],i=0,a=0,o=0,s=0,c=0,l=0;for(let e of r)e.type===`step`?i++:e.type===`hook`?e.disposed?c++:e.abortRequested?l++:a++:e.type===`wait`?o++:e.type===`attribute`&&s++;let u=[];i>0&&u.push(`${i} ${t(`step`,`steps`,i)}`),a>0&&u.push(`${a} ${t(`hook`,`hooks`,a)}`),o>0&&u.push(`${o} ${t(`wait`,`waits`,o)}`),s>0&&u.push(`${s} ${t(`attribute write`,`attribute writes`,s)}`),c>0&&u.push(`${c} hook ${t(`disposal`,`disposals`,c)}`);let d=i+a+o+s+c,f=t(`has`,`have`,d),p=+(i>0)+ +(a>0)+ +(o>0)+ +(s>0)+ +(c>0),m;m=p>1?`processed`:i>0?`run`:a>0||o>0?`created`:s>0?`written`:c>0?`processed`:`received`;let h=u.length>0?`${u.join(` and `)} ${f} not been ${m} yet`:`0 steps have not been run yet`;super(h),this.name=`WorkflowSuspension`,this.items=r,this.steps=r,this.globalThis=n,this.stepCount=i,this.hookCount=a,this.waitCount=o,this.attributeCount=s,this.hookDisposedCount=c,this.abortCount=l}static is(t){return t instanceof e}};function a(){throw new e(`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.`)}export{n as i,i as n,r,a as t};
@@ -1 +1 @@
1
- import{S as e,_ as t,it as n,u as r,ut as i,w as a}from"./dist-CNT2vjZ4.js";import{B as o,G as s,Gn as c,H as l,Kn as u,L as d,On as f,R as p,V as m,Vn as h,Xt as g,Yt as _,an as ee,at as v,d as y,fn as b,n as x,ot as S,st as C,y as w,z as T}from"./logger-Bzc8jWWj.js";import{A as E,c as D,j as O}from"./dist-DtXwQbZr.js";const k=`5.0.0-beta.55`,te=/^[a-zA-Z0-9_\-./@()[\]]+$/;function ne(t,n){if(!te.test(t))throw Error(`Invalid workflow name "${t}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, at signs, parentheses, or square brackets`);return`${e(`workflow`,a(n))}${t}`}const re=i();function A(e){return`__health_check__${e}`}function ie(e){let n=t.safeParse(e);if(n.success)return n.data}function j(e){return`wrun_hc_${e}`}async function M(e,t){let n=await u(),r=A(e.correlationId),i;if(e.runId)try{let t=await n.getEncryptionKeyForRun?.(e.runId);t&&(i=h((await c(t)).publicKey))}catch(t){x.warn(`Health check could not derive a run public key; the caller will fall back to a key lookup`,{correlationId:e.correlationId,error:t instanceof Error?t.message:String(t)})}let a=JSON.stringify({healthy:!0,correlationId:e.correlationId,specVersion:t??7,workflowCoreVersion:k,hookResumeInputVersion:1,...i?{encryptionPublicKey:i}:{},timestamp:Date.now()}),o=j(e.correlationId);await n.streams.write(o,r,a),await n.streams.close(o,r)}function N(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 P(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 F(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),typeof o.encryptionPublicKey==`string`&&(s.encryptionPublicKey=o.encryptionPublicKey),typeof o.hookResumeInputVersion==`number`&&(s.hookResumeInputVersion=o.hookResumeInputVersion),s}async function I(t,n){let r=n?.timeout??3e4,i=t.createRunId?.()??re(),o=A(i),s=`${e(`workflow`,a(n?.namespace))}health_check`,c=Date.now();try{for(await t.queue(s,{__healthCheck:!0,correlationId:i,...n?.runId?{runId:n.runId}:{}},{specVersion:1,deploymentId:n?.deploymentId});Date.now()-c<r;)try{let e=r-(Date.now()-c),n=(await N(t.streams.get(j(i),o),e)).getReader(),{chunks:a,timedOut:s}=await P(n,500);if(s){try{n.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=F(a);if(l)return{...l,latencyMs:Date.now()-c};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 L(e,t){return new E(`Event pagination ${t} for workflow run "${e}".`,{code:O.WORLD_CONTRACT_ERROR})}function R(e,t,n){if(t){if(n.has(t))throw L(e,`did not advance`);n.add(t)}}function z(e,t,n){if(t.length===0)return;let r=n??new Set(e.map(e=>e.eventId));for(let n of t)r.has(n.eventId)||(r.add(n.eventId),e.push(n))}function B(e,t){let n=e.length;for(;n>0;){let r=e[n-1];if(r.eventId===t.eventId)return;if(r.eventId<t.eventId)break;n--}e.splice(n,0,t)}function V(e,t,n,r){if(t){if(n===null)throw L(e,`returned more pages without a cursor`);if(r.has(n))throw L(e,`repeated a cursor`)}}function H(e,t,n){return t!==null&&!n&&E.is(e)&&e.status===400}async function U(e,t){let n=t!==void 0;return w(`workflow.replay.load`,async r=>{r?.setAttributes({...b(e),...ee(n?`events_list_incremental`:`events_list`)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,d=!1,f=await u(),p=Date.now();for(;c;){let t=Date.now(),r=s;R(e,r,o);let u;try{u=await f.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(H(t,r,d)){x.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,d=!0;continue}throw t}z(i,u.data,a),c=u.hasMore,V(e,c,u.cursor,o),s=u.cursor??s,l++,x.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:u.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return x.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-p}),r?.setAttributes({..._(i.length),...g(l)}),{events:i,cursor:s}})}function W(e,t){z(e.events,t.events),e.cursor=t.cursor??e.cursor}function G(){return process.env.WORKFLOW_SLOT_GAP_CHECK!==`0`}function K(e,t){let n=e.length;z(e,t);let r=e.length-n;return r>0&&e.sort((e,t)=>e.eventId<t.eventId?-1:+(e.eventId>t.eventId)),r}function ae(e,t){let n=t.events?.length??0;return n===0?{added:0,offered:0,truncated:!1}:t.hasMore===!0?{added:0,offered:n,truncated:!0}:{added:K(e,t.events??[]),offered:n,truncated:!1}}function q(e){let t;for(let n of e){let e=r(n.eventId);(t===void 0||e>t)&&(t=e)}return t}function J(e){let t=new Set,n=0;for(let i of e){let e=r(i.eventId);t.add(e),e>n&&(n=e)}if(n===0)return;let i=t.has(1)?1:2;if(t.size===n-i+1)return;let a,o=0;for(let e=i;e<=n;e++)t.has(e)||(a??=e,o++);if(a!==void 0)return{firstMissingSlot:a,missingCount:o,maxSlot:n}}const oe=3;async function se(e,t){let n=t,r=J(n.events);for(let t=0;r!==void 0&&t<3;t++)await new Promise(e=>setTimeout(e,25*2**t)),n=await U(e),r=J(n.events);return{log:n,gap:r}}function ce(e){let t=q(e);return t===void 0?{}:{eventCount:t}}function le(e,t){if(!D.is(e))return null;let n=e.details;if(typeof n!=`object`||!n)return null;let{events:r,cursor:i}=n;if(!Array.isArray(r)||r.length===0)return null;for(let e of r)if(typeof e!=`object`||!e||typeof e.eventId!=`string`||e.runId!==t)return null;return{events:r,cursor:typeof i==`string`?i:null}}const Y={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function X(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:Y}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??7,workflowCoreVersion:k}),{status:200,headers:{"Content-Type":`application/json`,...Y}}):await e(n)}}function Z(e,t){return e?.[n]??t}function ue(e){return{deploymentId:e.deploymentId,specVersion:e.specVersion??0,...e.startedAt?{startedAt:+e.startedAt}:{},rootRunId:Z(e.attributes,e.runId)}}function de(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function fe(e,t){return`${e}:${de(t)}`}async function Q(e,...t){let n=t[0];await w(`queue.publish`,{attributes:{...m(`vercel-queue`),...p(n),...o(`publish`),...l(`vercel-queue`),...C(`vercel-queue`),...S(`vqs`),...v(`publish`)},kind:await y(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(T(r))})}async function pe(e,t,n){if(n.length===0)return;let r=e.queueBatch?.bind(e);if(!r){await Promise.all(n.map(n=>Q(e,t,n.message,n.opts)));return}await w(`queue.publish`,{attributes:{...m(`vercel-queue`),...p(t),...o(`publish`),...d(n.length),...l(`vercel-queue`),...C(`vercel-queue`),...S(`vqs`),...v(`publishBatch`)},kind:await y(`PRODUCER`)},async()=>{let e=await r(t,n);if(e.length!==n.length)throw Object.assign(Error(`Queue batch for ${t} returned ${e.length} result(s) for ${n.length} message(s)`),{retryable:!0});let i=e.filter(e=>e.error!==void 0);if(i.length===0)return;let a=i.some(e=>e.error!==void 0&&e.retryable),o=Error(`Failed to publish ${i.length} of ${n.length} queue message(s) to ${t}: ${i[0]?.error}`);throw Object.assign(o,{retryable:a}),o})}function me(e){if(e.requestedAt)try{return s(Date.now()-e.requestedAt.getTime())}catch{return}}async function $(e,t,n){let r=typeof t==`string`?await e.getEncryptionKeyForRun?.(t,n):await e.getEncryptionKeyForRun?.(t);return r?await f(r):void 0}function he(e,t){let n;return()=>(n||=$(e,t),n)}export{se as C,k as D,X as E,ue as S,fe as T,le as _,J as a,$ as b,M as c,G as d,U as f,ie as g,K as h,z as i,I as l,he as m,ae as n,me as o,q as p,W as r,ne as s,oe as t,B as u,Q as v,ce as w,Z as x,pe as y};
1
+ import{S as e,_ as t,it as n,u as r,ut as i,w as a}from"./dist-BQSf8Hax.js";import{B as o,G as s,Gn as c,H as l,Kn as u,L as d,On as f,R as p,V as m,Vn as h,Xt as g,Yt as _,an as ee,at as v,d as y,fn as b,n as x,ot as S,st as C,y as w,z as T}from"./logger-BCEj9caG.js";import{M as E,j as D,l as O}from"./dist-BfMqXLK3.js";const k=`5.0.0-beta.56`,te=/^[a-zA-Z0-9_\-./@()[\]]+$/;function ne(t,n){if(!te.test(t))throw Error(`Invalid workflow name "${t}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, at signs, parentheses, or square brackets`);return`${e(`workflow`,a(n))}${t}`}const re=i();function A(e){return`__health_check__${e}`}function ie(e){let n=t.safeParse(e);if(n.success)return n.data}function j(e){return`wrun_hc_${e}`}async function M(e,t){let n=await u(),r=A(e.correlationId),i;if(e.runId)try{let t=await n.getEncryptionKeyForRun?.(e.runId);t&&(i=h((await c(t)).publicKey))}catch(t){x.warn(`Health check could not derive a run public key; the caller will fall back to a key lookup`,{correlationId:e.correlationId,error:t instanceof Error?t.message:String(t)})}let a=JSON.stringify({healthy:!0,correlationId:e.correlationId,specVersion:t??8,workflowCoreVersion:k,hookResumeInputVersion:1,...i?{encryptionPublicKey:i}:{},timestamp:Date.now()}),o=j(e.correlationId);await n.streams.write(o,r,a),await n.streams.close(o,r)}function N(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 P(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 F(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),typeof o.encryptionPublicKey==`string`&&(s.encryptionPublicKey=o.encryptionPublicKey),typeof o.hookResumeInputVersion==`number`&&(s.hookResumeInputVersion=o.hookResumeInputVersion),s}async function I(t,n){let r=n?.timeout??3e4,i=t.createRunId?.()??re(),o=A(i),s=`${e(`workflow`,a(n?.namespace))}health_check`,c=Date.now();try{for(await t.queue(s,{__healthCheck:!0,correlationId:i,...n?.runId?{runId:n.runId}:{}},{specVersion:1,deploymentId:n?.deploymentId});Date.now()-c<r;)try{let e=r-(Date.now()-c),n=(await N(t.streams.get(j(i),o),e)).getReader(),{chunks:a,timedOut:s}=await P(n,500);if(s){try{n.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=F(a);if(l)return{...l,latencyMs:Date.now()-c};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 L(e,t){return new D(`Event pagination ${t} for workflow run "${e}".`,{code:E.WORLD_CONTRACT_ERROR})}function R(e,t,n){if(t){if(n.has(t))throw L(e,`did not advance`);n.add(t)}}function z(e,t,n){if(t.length===0)return;let r=n??new Set(e.map(e=>e.eventId));for(let n of t)r.has(n.eventId)||(r.add(n.eventId),e.push(n))}function B(e,t){let n=e.length;for(;n>0;){let r=e[n-1];if(r.eventId===t.eventId)return;if(r.eventId<t.eventId)break;n--}e.splice(n,0,t)}function V(e,t,n,r){if(t){if(n===null)throw L(e,`returned more pages without a cursor`);if(r.has(n))throw L(e,`repeated a cursor`)}}function H(e,t,n){return t!==null&&!n&&D.is(e)&&e.status===400}async function U(e,t){let n=t!==void 0;return w(`workflow.replay.load`,async r=>{r?.setAttributes({...b(e),...ee(n?`events_list_incremental`:`events_list`)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,d=!1,f=await u(),p=Date.now();for(;c;){let t=Date.now(),r=s;R(e,r,o);let u;try{u=await f.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(H(t,r,d)){x.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,d=!0;continue}throw t}z(i,u.data,a),c=u.hasMore,V(e,c,u.cursor,o),s=u.cursor??s,l++,x.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:u.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return x.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-p}),r?.setAttributes({..._(i.length),...g(l)}),{events:i,cursor:s}})}function W(e,t){z(e.events,t.events),e.cursor=t.cursor??e.cursor}function G(){return process.env.WORKFLOW_SLOT_GAP_CHECK!==`0`}function K(e,t){let n=e.length;z(e,t);let r=e.length-n;return r>0&&e.sort((e,t)=>e.eventId<t.eventId?-1:+(e.eventId>t.eventId)),r}function ae(e,t){let n=t.events?.length??0;return n===0?{added:0,offered:0,truncated:!1}:t.hasMore===!0?{added:0,offered:n,truncated:!0}:{added:K(e,t.events??[]),offered:n,truncated:!1}}function q(e){let t;for(let n of e){let e=r(n.eventId);(t===void 0||e>t)&&(t=e)}return t}function J(e){let t=new Set,n=0;for(let i of e){let e=r(i.eventId);t.add(e),e>n&&(n=e)}if(n===0)return;let i=t.has(1)?1:2;if(t.size===n-i+1)return;let a,o=0;for(let e=i;e<=n;e++)t.has(e)||(a??=e,o++);if(a!==void 0)return{firstMissingSlot:a,missingCount:o,maxSlot:n}}const oe=3;async function se(e,t){let n=t,r=J(n.events);for(let t=0;r!==void 0&&t<3;t++)await new Promise(e=>setTimeout(e,25*2**t)),n=await U(e),r=J(n.events);return{log:n,gap:r}}function ce(e){let t=q(e);return t===void 0?{}:{eventCount:t}}function le(e,t){if(!O.is(e))return null;let n=e.details;if(typeof n!=`object`||!n)return null;let{events:r,cursor:i}=n;if(!Array.isArray(r)||r.length===0)return null;for(let e of r)if(typeof e!=`object`||!e||typeof e.eventId!=`string`||e.runId!==t)return null;return{events:r,cursor:typeof i==`string`?i:null}}const Y={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function X(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:Y}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??8,workflowCoreVersion:k}),{status:200,headers:{"Content-Type":`application/json`,...Y}}):await e(n)}}function Z(e,t){return e?.[n]??t}function ue(e){return{deploymentId:e.deploymentId,specVersion:e.specVersion??0,...e.startedAt?{startedAt:+e.startedAt}:{},rootRunId:Z(e.attributes,e.runId)}}function de(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function fe(e,t){return`${e}:${de(t)}`}async function Q(e,...t){let n=t[0];await w(`queue.publish`,{attributes:{...m(`vercel-queue`),...p(n),...o(`publish`),...l(`vercel-queue`),...C(`vercel-queue`),...S(`vqs`),...v(`publish`)},kind:await y(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(T(r))})}async function pe(e,t,n){if(n.length===0)return;let r=e.queueBatch?.bind(e);if(!r){await Promise.all(n.map(n=>Q(e,t,n.message,n.opts)));return}await w(`queue.publish`,{attributes:{...m(`vercel-queue`),...p(t),...o(`publish`),...d(n.length),...l(`vercel-queue`),...C(`vercel-queue`),...S(`vqs`),...v(`publishBatch`)},kind:await y(`PRODUCER`)},async()=>{let e=await r(t,n);if(e.length!==n.length)throw Object.assign(Error(`Queue batch for ${t} returned ${e.length} result(s) for ${n.length} message(s)`),{retryable:!0});let i=e.filter(e=>e.error!==void 0);if(i.length===0)return;let a=i.some(e=>e.error!==void 0&&e.retryable),o=Error(`Failed to publish ${i.length} of ${n.length} queue message(s) to ${t}: ${i[0]?.error}`);throw Object.assign(o,{retryable:a}),o})}function me(e){if(e.requestedAt)try{return s(Date.now()-e.requestedAt.getTime())}catch{return}}async function $(e,t,n){let r=typeof t==`string`?await e.getEncryptionKeyForRun?.(t,n):await e.getEncryptionKeyForRun?.(t);return r?await f(r):void 0}function he(e,t){let n;return()=>(n||=$(e,t),n)}export{se as C,k as D,X as E,ue as S,fe as T,le as _,J as a,$ as b,M as c,G as d,U as f,ie as g,K as h,z as i,I as l,he as m,ae as n,me as o,q as p,W as r,ne as s,oe as t,B as u,Q as v,ce as w,Z as x,pe as y};
@@ -1,4 +1,4 @@
1
- import{mt as e}from"./dist-CNT2vjZ4.js";import{k as t,p as n}from"./dist-DtXwQbZr.js";import{n as r,r as i}from"./global-DIlFoH2w.js";function a(e,t){if(typeof t!=`string`)return null;let[n,r,...i]=t.split(`//`);if(n!==e||!r||i.length===0)return null;let a=i.join(`//`),o=a.split(`/`).at(-1)??``,s=``;return s=r.startsWith(`./`)?r.split(`/`).at(-1)??``:(r.split(`@`).slice(0,-1).join(`@`)||r.split(`@`)[0])?.split(`/`).at(-1)??``,[`default`,`__default`].includes(o)&&s&&(o=s),{shortName:o,moduleSpecifier:r,functionName:a}}function o(e){return a(`workflow`,e)}function s(e){return a(`step`,e)}function c(e){return p(s(e),e)}function l(e){return p(o(e),e)}function u(e){return o(e)?.shortName??f(`workflow`,e)??e}function d(e){return s(e)?.shortName??f(`step`,e)??e}function f(e,t){if(!t.startsWith(`${e}--`))return null;let n=t.split(`--`).filter(Boolean),r=n.at(-1)?.split(`-`).filter(Boolean).at(-1)??``;if([`default`,`__default`].includes(r)){let t=n.at(-2)?.split(`-`).filter(Boolean).at(-1);t&&t!==e&&(r=t)}return r||null}function p(e,t){return e?`${e.shortName} (${e.moduleSpecifier})`:t}async function m(e,n=[`encrypt`,`decrypt`]){if(e.byteLength!==32)throw new t(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,n)}async function h(e,t,r){let i=globalThis.crypto.getRandomValues(new Uint8Array(12)),a;try{a=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:i,tagLength:128,...r?{additionalData:r}:{}},e,t)}catch(e){throw new n(`AES-256-GCM encryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`encrypt`,byteLength:t.byteLength}})}let o=new Uint8Array(12+a.byteLength);return o.set(i,0),o.set(new Uint8Array(a),12),o}async function g(e,t,r){if(t.byteLength<28)throw new n(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let i=t.subarray(0,12),a=t.subarray(12),o;try{o=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:i,tagLength:128,...r?{additionalData:r}:{}},e,a)}catch(e){let r=e instanceof Error?e.message:String(e);throw new n(`AES-256-GCM decryption failed: ${r}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return new Uint8Array(o)}function _(e){let n=e.specVersion;if(!(n!=null&&n>=6&&n<=7))throw new t(`This Workflow runtime supports Worlds with spec version 6 through 7, but the configured World declares spec version ${n??`none`}. Install a World package version compatible with the current Workflow runtime.`)}const v=Symbol.for(`@workflow/world//cache`),y=Symbol.for(`@workflow/world//cachePromise`),ee=Symbol.for(`@workflow/world//getWorldFn`);async function te(){let e=globalThis;if(e[v])return _(e[v]),e[v];if(e[y])return e[v]=await e[y],_(e[v]),e[v];let t=e[ee];if(t){let e=await t();return _(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 b=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]),x=new TextEncoder;function ne(e){if(e.byteLength!==32)throw new t(`Run key material must be exactly 32 bytes, got ${e.byteLength}`)}function re(e,n){if(e.byteLength!==32)throw new t(`${n} must be exactly 32 bytes, got ${e.byteLength}`)}async function S(e){ne(e);let t=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),n=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:x.encode(`workflow/encp/x25519/v1`)},t,256),r=new Uint8Array(n);return{scalar:r,publicKey:await ie(r)}}async function ie(e){let n=await C(e,!0),r=await globalThis.crypto.subtle.exportKey(`jwk`,n);if(!r.x)throw new t(`X25519 JWK export did not include a public key component ("x")`);let i=se(r.x);if(i.byteLength!==32)throw new t(`X25519 JWK export produced a ${i.byteLength}-byte public key, expected 32`);return i}async function C(e,t){let n=new Uint8Array(b.length+e.byteLength);return n.set(b,0),n.set(e,b.length),globalThis.crypto.subtle.importKey(`pkcs8`,n,{name:`X25519`},t,[`deriveBits`])}function w(e){return globalThis.crypto.subtle.importKey(`raw`,e,{name:`X25519`},!0,[])}const T=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function ae(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:0,a=n+2<e.length?e[n+2]:0;t+=T[r>>2&63],t+=T[(r&3)<<4|i>>4&15],t+=n+1<e.length?T[(i&15)<<2|a>>6&3]:`=`,t+=n+2<e.length?T[a&63]:`=`}return t}function oe(e){let t=e.length;for(;t>0&&e[t-1]===`=`;)t--;let n=e.slice(0,t);if(n.includes(`=`)||n.length%4==1||t!==e.length&&e.length%4!=0)return;let r=0,i=0,a=[];for(let e=0;e<n.length;e++){let t=T.indexOf(n[e]);if(t===-1)return;r=r<<6|t,i+=6,i>=8&&(i-=8,a.push(r>>i&255))}if(!(i>0&&r&(1<<i)-1))return new Uint8Array(a)}function se(e){let n=0,r=0,i=[];for(let a=0;a<e.length;a++){let o=e[a];if(o===`=`)break;let s=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`.indexOf(o);if(s===-1)throw new t(`Invalid base64url character "${o}" in X25519 JWK key component`);n=n<<6|s,r+=6,r>=8&&(r-=8,i.push(n>>r&255))}return new Uint8Array(i)}async function ce(e,t,n,r){let i=x.encode(`workflow/encp/aes256gcm/v1`),a=new Uint8Array(i.length+t.length+n.length);a.set(i,0),a.set(t,i.length),a.set(n,i.length+t.length);let o=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),s=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:a},o,256);return globalThis.crypto.subtle.importKey(`raw`,new Uint8Array(s),`AES-GCM`,!1,r)}async function le(e){re(e,`Recipient public key`);let n;try{n=await w(e)}catch(e){throw new t(`Invalid X25519 recipient public key: ${e instanceof Error?e.message:String(e)}`,{cause:e})}let r=await globalThis.crypto.subtle.generateKey({name:`X25519`},!0,[`deriveBits`]),i=new Uint8Array(await globalThis.crypto.subtle.exportKey(`raw`,r.publicKey)),a;try{a=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:n},r.privateKey,256)}catch(e){throw new t(`X25519 key agreement failed: the recipient public key is not a valid curve point (low-order point or corrupted key material)`,{cause:e})}return{ephemeralPublicKey:i,contentKey:await ce(new Uint8Array(a),i,e,[`encrypt`])}}async function ue(e,t){if(t.byteLength!==32)throw new n(`Sealed payload has a malformed ephemeral public key: expected 32 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r;try{let[n,i]=await Promise.all([C(e.scalar,!1),w(t)]);r=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:i},n,256)}catch(e){throw new n(`X25519 key agreement failed while opening a sealed payload: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return ce(new Uint8Array(r),t,e.publicKey,[`decrypt`])}async function de(e,t,n){let{ephemeralPublicKey:r,contentKey:i}=await le(e),a=await h(i,t,n),o=new Uint8Array(r.byteLength+a.byteLength);return o.set(r,0),o.set(a,r.byteLength),o}async function fe(e,t,r){if(t.byteLength<60)throw new n(`Sealed payload too short: expected at least 60 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let i=t.subarray(0,32),a=t.subarray(32);return g(await ue(e,i),a,r)}function pe(e,t){let n;return{async seal(r){n??=le(e);let{ephemeralPublicKey:i,contentKey:a}=await n,o=await h(a,r,t),s=new Uint8Array(i.byteLength+o.byteLength);return s.set(i,0),s.set(o,i.byteLength),s}}}function me(e,t){let r,i;return{async open(a){if(a.byteLength<60)throw new n(`Sealed payload too short: expected at least 60 bytes, got ${a.byteLength}`,{context:{operation:`decrypt`,byteLength:a.byteLength}});let o=a.subarray(0,32),s=a.subarray(32),c=he(o);(c!==r||!i)&&(r=c,i=ue(e,o));let l;try{l=await i}catch(e){throw r=void 0,i=void 0,e}return g(l,s,t)}}}function he(e){let t=``;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t}function ge(e){if(!e)return;let t=oe(e);if(t&&t.byteLength===32)return t}function E(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const D={DEVALUE_V1:`devl`,ENCRYPTED:`encr`,SEALED:`encp`,GZIP:`gzip`,ZSTD:`zstd`},_e=new TextEncoder,O=new TextDecoder;function k(e,t){if(!(t instanceof Uint8Array))return t;let n=_e.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function A(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=O.decode(t);return E(n)?n:null}function ve(e){return A(e)===D.ENCRYPTED}function j(e){if(!(e instanceof Uint8Array))return{format:D.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=O.decode(t);if(!E(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}const M=Symbol.for(`workflow.serialization.sealTarget`),N=Symbol.for(`workflow.serialization.runKeys`);function ye(e,t){return{[M]:!0,recipientPublicKey:e,aad:t}}function P(e,t,n){return{[N]:!0,aes:e,keyPair:t,aad:n}}async function be(e){let[t,n]=await Promise.all([m(e),S(e)]);return P(t,n)}function F(e){return typeof e==`object`&&!!e&&e[M]===!0}function I(e){return typeof e==`object`&&!!e&&e[N]===!0}function L(e){if(e){if(I(e))return e.aes;if(!F(e))return e}}async function xe(e){return typeof e==`function`?e():e}async function Se(e,t){if(!t||!(e instanceof Uint8Array))return e;if(F(t)){let n=await de(t.recipientPublicKey,e,t.aad);return k(D.SEALED,n)}let n=await h(I(t)?t.aes:t,e);return k(D.ENCRYPTED,n)}async function Ce(e,t){if(!I(t))throw new n(`Sealed data encountered but no run keypair is available. Opening a sealed payload requires the run's own encryption key material; a symmetric key or a seal-only target cannot decrypt it.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encp`}});let{payload:r}=j(e);try{return await fe(t.keyPair,r,t.aad)}catch(e){throw n.is(e)&&e.context&&(e.context.formatPrefix=D.SEALED),e}}async function we(e,t){if(!(e instanceof Uint8Array))return e;let r=A(e);if(r===D.SEALED)return Ce(e,t);if(r!==D.ENCRYPTED)return e;let i=L(t);if(!i)throw new n(`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`}});let{payload:a}=j(e);try{return await g(i,a)}catch(e){throw n.is(e)&&e.context&&(e.context.formatPrefix=r),e}}const Te=(()=>{let e=globalThis.process;return e?.env?e.env.FORCE_COLOR&&e.env.FORCE_COLOR!==`0`?!0:!e.env.NO_COLOR&&!!e.stdout?.isTTY:!1})(),R=(e,t)=>n=>Te?`\x1b[${e}m${n}\x1b[${t}m`:n,z={bold:R(1,22),dim:R(2,22),italic:R(3,23),red:R(31,39),blue:R(34,39),cyan:R(36,39),yellow:R(33,39),magenta:R(35,39)},B={info:z.blue,help:z.cyan,warn:z.yellow,error:z.red};function Ee(e){let t=Array.isArray(e)?e.join(`
1
+ import{mt as e}from"./dist-BQSf8Hax.js";import{A as t,m as n}from"./dist-BfMqXLK3.js";import{n as r,r as i}from"./global-BQnKzRXo.js";function a(e,t){if(typeof t!=`string`)return null;let[n,r,...i]=t.split(`//`);if(n!==e||!r||i.length===0)return null;let a=i.join(`//`),o=a.split(`/`).at(-1)??``,s=``;return s=r.startsWith(`./`)?r.split(`/`).at(-1)??``:(r.split(`@`).slice(0,-1).join(`@`)||r.split(`@`)[0])?.split(`/`).at(-1)??``,[`default`,`__default`].includes(o)&&s&&(o=s),{shortName:o,moduleSpecifier:r,functionName:a}}function o(e){return a(`workflow`,e)}function s(e){return a(`step`,e)}function c(e){return p(s(e),e)}function l(e){return p(o(e),e)}function u(e){return o(e)?.shortName??f(`workflow`,e)??e}function d(e){return s(e)?.shortName??f(`step`,e)??e}function f(e,t){if(!t.startsWith(`${e}--`))return null;let n=t.split(`--`).filter(Boolean),r=n.at(-1)?.split(`-`).filter(Boolean).at(-1)??``;if([`default`,`__default`].includes(r)){let t=n.at(-2)?.split(`-`).filter(Boolean).at(-1);t&&t!==e&&(r=t)}return r||null}function p(e,t){return e?`${e.shortName} (${e.moduleSpecifier})`:t}async function m(e,n=[`encrypt`,`decrypt`]){if(e.byteLength!==32)throw new t(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,n)}async function h(e,t,r){let i=globalThis.crypto.getRandomValues(new Uint8Array(12)),a;try{a=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:i,tagLength:128,...r?{additionalData:r}:{}},e,t)}catch(e){throw new n(`AES-256-GCM encryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`encrypt`,byteLength:t.byteLength}})}let o=new Uint8Array(12+a.byteLength);return o.set(i,0),o.set(new Uint8Array(a),12),o}async function g(e,t,r){if(t.byteLength<28)throw new n(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let i=t.subarray(0,12),a=t.subarray(12),o;try{o=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:i,tagLength:128,...r?{additionalData:r}:{}},e,a)}catch(e){let r=e instanceof Error?e.message:String(e);throw new n(`AES-256-GCM decryption failed: ${r}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return new Uint8Array(o)}function _(e){let n=e.specVersion;if(!(n!=null&&n>=6&&n<=8))throw new t(`This Workflow runtime supports Worlds with spec version 6 through 8, but the configured World declares spec version ${n??`none`}. Install a World package version compatible with the current Workflow runtime.`)}const v=Symbol.for(`@workflow/world//cache`),y=Symbol.for(`@workflow/world//cachePromise`),ee=Symbol.for(`@workflow/world//getWorldFn`);async function te(){let e=globalThis;if(e[v])return _(e[v]),e[v];if(e[y])return e[v]=await e[y],_(e[v]),e[v];let t=e[ee];if(t){let e=await t();return _(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 b=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]),x=new TextEncoder;function ne(e){if(e.byteLength!==32)throw new t(`Run key material must be exactly 32 bytes, got ${e.byteLength}`)}function re(e,n){if(e.byteLength!==32)throw new t(`${n} must be exactly 32 bytes, got ${e.byteLength}`)}async function S(e){ne(e);let t=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),n=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:x.encode(`workflow/encp/x25519/v1`)},t,256),r=new Uint8Array(n);return{scalar:r,publicKey:await ie(r)}}async function ie(e){let n=await C(e,!0),r=await globalThis.crypto.subtle.exportKey(`jwk`,n);if(!r.x)throw new t(`X25519 JWK export did not include a public key component ("x")`);let i=se(r.x);if(i.byteLength!==32)throw new t(`X25519 JWK export produced a ${i.byteLength}-byte public key, expected 32`);return i}async function C(e,t){let n=new Uint8Array(b.length+e.byteLength);return n.set(b,0),n.set(e,b.length),globalThis.crypto.subtle.importKey(`pkcs8`,n,{name:`X25519`},t,[`deriveBits`])}function w(e){return globalThis.crypto.subtle.importKey(`raw`,e,{name:`X25519`},!0,[])}const T=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function ae(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:0,a=n+2<e.length?e[n+2]:0;t+=T[r>>2&63],t+=T[(r&3)<<4|i>>4&15],t+=n+1<e.length?T[(i&15)<<2|a>>6&3]:`=`,t+=n+2<e.length?T[a&63]:`=`}return t}function oe(e){let t=e.length;for(;t>0&&e[t-1]===`=`;)t--;let n=e.slice(0,t);if(n.includes(`=`)||n.length%4==1||t!==e.length&&e.length%4!=0)return;let r=0,i=0,a=[];for(let e=0;e<n.length;e++){let t=T.indexOf(n[e]);if(t===-1)return;r=r<<6|t,i+=6,i>=8&&(i-=8,a.push(r>>i&255))}if(!(i>0&&r&(1<<i)-1))return new Uint8Array(a)}function se(e){let n=0,r=0,i=[];for(let a=0;a<e.length;a++){let o=e[a];if(o===`=`)break;let s=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`.indexOf(o);if(s===-1)throw new t(`Invalid base64url character "${o}" in X25519 JWK key component`);n=n<<6|s,r+=6,r>=8&&(r-=8,i.push(n>>r&255))}return new Uint8Array(i)}async function ce(e,t,n,r){let i=x.encode(`workflow/encp/aes256gcm/v1`),a=new Uint8Array(i.length+t.length+n.length);a.set(i,0),a.set(t,i.length),a.set(n,i.length+t.length);let o=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),s=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:a},o,256);return globalThis.crypto.subtle.importKey(`raw`,new Uint8Array(s),`AES-GCM`,!1,r)}async function le(e){re(e,`Recipient public key`);let n;try{n=await w(e)}catch(e){throw new t(`Invalid X25519 recipient public key: ${e instanceof Error?e.message:String(e)}`,{cause:e})}let r=await globalThis.crypto.subtle.generateKey({name:`X25519`},!0,[`deriveBits`]),i=new Uint8Array(await globalThis.crypto.subtle.exportKey(`raw`,r.publicKey)),a;try{a=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:n},r.privateKey,256)}catch(e){throw new t(`X25519 key agreement failed: the recipient public key is not a valid curve point (low-order point or corrupted key material)`,{cause:e})}return{ephemeralPublicKey:i,contentKey:await ce(new Uint8Array(a),i,e,[`encrypt`])}}async function ue(e,t){if(t.byteLength!==32)throw new n(`Sealed payload has a malformed ephemeral public key: expected 32 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r;try{let[n,i]=await Promise.all([C(e.scalar,!1),w(t)]);r=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:i},n,256)}catch(e){throw new n(`X25519 key agreement failed while opening a sealed payload: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return ce(new Uint8Array(r),t,e.publicKey,[`decrypt`])}async function de(e,t,n){let{ephemeralPublicKey:r,contentKey:i}=await le(e),a=await h(i,t,n),o=new Uint8Array(r.byteLength+a.byteLength);return o.set(r,0),o.set(a,r.byteLength),o}async function fe(e,t,r){if(t.byteLength<60)throw new n(`Sealed payload too short: expected at least 60 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let i=t.subarray(0,32),a=t.subarray(32);return g(await ue(e,i),a,r)}function pe(e,t){let n;return{async seal(r){n??=le(e);let{ephemeralPublicKey:i,contentKey:a}=await n,o=await h(a,r,t),s=new Uint8Array(i.byteLength+o.byteLength);return s.set(i,0),s.set(o,i.byteLength),s}}}function me(e,t){let r,i;return{async open(a){if(a.byteLength<60)throw new n(`Sealed payload too short: expected at least 60 bytes, got ${a.byteLength}`,{context:{operation:`decrypt`,byteLength:a.byteLength}});let o=a.subarray(0,32),s=a.subarray(32),c=he(o);(c!==r||!i)&&(r=c,i=ue(e,o));let l;try{l=await i}catch(e){throw r=void 0,i=void 0,e}return g(l,s,t)}}}function he(e){let t=``;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t}function ge(e){if(!e)return;let t=oe(e);if(t&&t.byteLength===32)return t}function E(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const D={DEVALUE_V1:`devl`,ENCRYPTED:`encr`,SEALED:`encp`,GZIP:`gzip`,ZSTD:`zstd`},_e=new TextEncoder,O=new TextDecoder;function k(e,t){if(!(t instanceof Uint8Array))return t;let n=_e.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function A(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=O.decode(t);return E(n)?n:null}function ve(e){return A(e)===D.ENCRYPTED}function j(e){if(!(e instanceof Uint8Array))return{format:D.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=O.decode(t);if(!E(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}const M=Symbol.for(`workflow.serialization.sealTarget`),N=Symbol.for(`workflow.serialization.runKeys`);function ye(e,t){return{[M]:!0,recipientPublicKey:e,aad:t}}function P(e,t,n){return{[N]:!0,aes:e,keyPair:t,aad:n}}async function be(e){let[t,n]=await Promise.all([m(e),S(e)]);return P(t,n)}function F(e){return typeof e==`object`&&!!e&&e[M]===!0}function I(e){return typeof e==`object`&&!!e&&e[N]===!0}function L(e){if(e){if(I(e))return e.aes;if(!F(e))return e}}async function xe(e){return typeof e==`function`?e():e}async function Se(e,t){if(!t||!(e instanceof Uint8Array))return e;if(F(t)){let n=await de(t.recipientPublicKey,e,t.aad);return k(D.SEALED,n)}let n=await h(I(t)?t.aes:t,e);return k(D.ENCRYPTED,n)}async function Ce(e,t){if(!I(t))throw new n(`Sealed data encountered but no run keypair is available. Opening a sealed payload requires the run's own encryption key material; a symmetric key or a seal-only target cannot decrypt it.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encp`}});let{payload:r}=j(e);try{return await fe(t.keyPair,r,t.aad)}catch(e){throw n.is(e)&&e.context&&(e.context.formatPrefix=D.SEALED),e}}async function we(e,t){if(!(e instanceof Uint8Array))return e;let r=A(e);if(r===D.SEALED)return Ce(e,t);if(r!==D.ENCRYPTED)return e;let i=L(t);if(!i)throw new n(`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`}});let{payload:a}=j(e);try{return await g(i,a)}catch(e){throw n.is(e)&&e.context&&(e.context.formatPrefix=r),e}}const Te=(()=>{let e=globalThis.process;return e?.env?e.env.FORCE_COLOR&&e.env.FORCE_COLOR!==`0`?!0:!e.env.NO_COLOR&&!!e.stdout?.isTTY:!1})(),R=(e,t)=>n=>Te?`\x1b[${e}m${n}\x1b[${t}m`:n,z={bold:R(1,22),dim:R(2,22),italic:R(3,23),red:R(31,39),blue:R(34,39),cyan:R(36,39),yellow:R(33,39),magenta:R(35,39)},B={info:z.blue,help:z.cyan,warn:z.yellow,error:z.red};function Ee(e){let t=Array.isArray(e)?e.join(`
2
2
  `):e;return B.info(`${z.bold(`hint:`)} ${t}`)}function De(e){return B.info(`${z.bold(`docs:`)} ${e}`)}function Oe(e){return z.italic(`${z.dim("`")}${e}${z.dim("`")}`)}function V(e){return z.dim(e)}function ke(e){return z.bold(e)}function Ae(e){return z.red(e)}function je(e){return z.magenta(e)}function Me(e,t){let n=[e];return t.forEach((e,r)=>{let i=e.split(`
3
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
4
  `)}function Ne(e,t,n){let[r,...i]=t.split(`
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-B_knIduE.js";import{_ as t,a as n,ot as r,ut as i,x as a,z as o}from"./dist-BQSf8Hax.js";import{$t as s,A as c,D as l,Jn as u,Kn as d,M as f,N as p,O as m,On as h,Pn as g,Wn as ee,fn as _,m as te,n as v,y,zn as b}from"./logger-BCEj9caG.js";import{A as x,f as S,j as C,k as w,n as T,o as E,s as D}from"./dist-BfMqXLK3.js";import{d as ne,dt as O,k}from"./serialization-CJ265vSe.js";import{s as A}from"./helpers-CNMO7zB1.js";import{n as j,r as re,t as ie}from"./wait-until-Bo2U6ON9.js";import{z as M}from"#compiled/zod/index.js";const N=[25,100];function P(e,t){if(t?.(e))return!1;let n=e??{},r=n.status??n.statusCode;if(typeof r==`number`)return r>=500||r===408||r===429;let i=e?.name;return i!==`BadRequestError`&&i!==`UnauthorizedError`&&i!==`ForbiddenError`}async function F(e,t){let n;for(let r=0;r<=N.length;r++)try{await e();return}catch(e){if(n=e,!P(e,t))break;let i=N[r];i!==void 0&&await new Promise(e=>setTimeout(e,i))}throw D.is(n)?new x(`The hook resume was committed, but its workflow wake could not be published`,{cause:n}):n}async function I(e,t,n){let r=n.claimedFrom;if(!r||r.runId===t)return`skipped`;if(r.workflowName===void 0)return v.warn(`Force-claimed a hook from a run whose workflow name is unknown; not waking it`,{workflowRunId:t,victimRunId:r.runId}),`skipped`;try{return await F(()=>e.queue(A(r.workflowName),{runId:r.runId},{...r.deploymentId!==void 0&&{deploymentId:r.deploymentId},specVersion:r.runSpecVersion??1,idempotencyKey:`hook-force-claim-${n.hookId}`}),e.isDeploymentUnavailableError?.bind(e)),`published`}catch(e){return v.error(`Force-claimed a hook token but could not wake the run it was taken from; it will read the disposal on its next invocation`,{workflowRunId:t,victimRunId:r.runId,error:e instanceof Error?e.message:String(e)}),`failed`}}function L(e){if(e)for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.eventType===`hook_received`||n.eventType===`noop`||n.eventType===`hook_disposed`&&n.eventData?.forceClaimedBy!==void 0))return n.eventType===`hook_created`&&n.eventData.forceClaimedFrom!==void 0?n:void 0}}async function R(e,t,n){let r=L(n);if(!r)return;let i=r.eventData.forceClaimedFrom,a=await I(e,t,{hookId:r.correlationId,claimedFrom:i});a!==`skipped`&&v.info(`Republished the wake of a force-claimed hook victim`,{workflowRunId:t,hookId:r.correlationId,victimRunId:i.runId,victimWake:a})}const z=M.object({type:M.literal(`hook_resume`),version:M.literal(1),hookId:M.string(),token:M.string(),payload:M.instanceof(Uint8Array)}),ae=M.discriminatedUnion(`status`,[M.object({status:M.literal(`accepted`)}),M.object({status:M.literal(`rejected`),code:M.enum([`HOOK_NOT_FOUND`,`INVALID_INPUT`])})]);async function B(e,t,n,i){let a=z.safeParse(i);if(!a.success||!n)throw new C(`Invalid invocation input`,{status:400,code:`INVALID_INPUT`});let s=a.data,c=Buffer.from(await crypto.subtle.digest(`SHA-256`,s.payload)).toString(`hex`);try{let n=await e.hooks.get(s.hookId);if(n.runId!==t||n.token!==s.token)throw new D(s.token);let r=await e.runs.get(t,{resolveData:`none`});if(o(r.status))throw new D(s.token)}catch(i){if(!V(i))throw i;let a=await e.runs.get(t,{resolveData:`none`});if(a.expiredAt||o(a.status)&&r(a.attributes).mode===`none`)throw new C(`Invocation data has expired under the run retention policy`,{status:410,code:`INVOCATION_DATA_EXPIRED`});if(!e.capabilities?.hookResumeDedup||!await H(e,t,s.hookId,n))throw i}return await e.events.create(t,{eventType:`hook_received`,correlationId:s.hookId,specVersion:8,eventData:{token:s.token,payload:s.payload}},{...e.capabilities?.hookResumeDedup?{resumeId:n,resumePayloadDigest:c}:{}}),{status:`accepted`}}function V(e){return D.is(e)||S.is(e)||w.is(e)}async function H(e,t,n,r){let i=null;do{let a=await e.events.listByCorrelationId({runId:t,correlationId:n,resolveData:`none`,pagination:{limit:100,...i?{cursor:i}:{}}});if(a.data.some(e=>e.eventType===`hook_received`&&e.resumeId===r))return!0;i=a.hasMore?a.cursor:null}while(i);return!1}var U=class{revision=0;listeners=new Set;notify(){this.revision++;for(let e of this.listeners)e()}async waitForActivity(e,t=100){return this.revision!==e||(await new Promise(e=>{let n=()=>{clearTimeout(r),this.listeners.delete(n),e()},r=setTimeout(n,t);this.listeners.add(n)}),this.revision!==e)}};function W(e){return n=>{let r=new Map;return async(i,o)=>{if(t.safeParse(i).success)return n(i,o);let s=a.safeParse(i);if(!e.capabilities?.invoke||!s.success||s.data.stepId)return n(i,o);let c=s.data,l=r.get(c.runId);l||(l={activity:new U,admission:Promise.resolve(),references:0},r.set(c.runId,l));let u=l;u.references++;try{if(c.invoke){if(!c.requestId)throw new x(`Invocation requestId is required`);let t=c.requestId,n=u.admission.then(()=>y(`workflow.invoke.receive`,async n=>{n?.setAttributes({..._(c.runId),"workflow.invocation.id":t});let r=await B(e,c.runId,t,c.input);return r.status===`accepted`&&u.activity.notify(),r}));return u.admission=n.catch(()=>{}),await n}if(u.execution)return await u.execution;let t=n(i,o,u.activity);u.execution=t;try{return await t}finally{u.execution===t&&(u.execution=void 0)}}finally{u.references--,u.references===0&&r.get(c.runId)===u&&r.delete(c.runId)}}}}var G=e({getHookByToken:()=>X,resumeHook:()=>Z,resumeWebhook:()=>de});const K=i();async function oe(e){let t=await crypto.subtle.digest(`SHA-256`,e),n=new Uint8Array(t),r=``;for(let e of n)r+=e.toString(16).padStart(2,`0`);return r}function se(e){let t=e.executionContext?.workflowCoreVersion,n=e.executionContext?.traceCarrier,r=e.executionContext?.hookResumeInputVersion;return{deploymentId:e.deploymentId,workflowName:e.workflowName,runSpecVersion:e.specVersion,workflowCoreVersion:typeof t==`string`?t:void 0,traceCarrier:n&&typeof n==`object`?n:void 0,encryptionPublicKey:e.encryptionPublicKey,hookResumeInputVersion:typeof r==`number`?r:void 0}}async function q(e){if(e.resumeContext)return{resumeContext:e.resumeContext,source:`hook`};let t=await(await d()).runs.get(e.runId);return{resumeContext:se(t),source:`run_fallback`,run:t}}async function ce(e,t){let n=await d(),r=t.run?await n.getEncryptionKeyForRun?.(t.run):await n.getEncryptionKeyForRun?.(e.runId,{deploymentId:t.resumeContext.deploymentId});return r?await u(r):void 0}function le(e){let t=Object.getOwnPropertyDescriptor(e,`metadata`);return t!==void 0&&typeof t.get==`function`}function J(e){let t=e.metadata,n,r,i=async()=>{let n=await d(),i=await q(e),a=i.run?await n.getEncryptionKeyForRun?.(i.run):await n.getEncryptionKeyForRun?.(e.runId,{deploymentId:i.resumeContext.deploymentId});return r=a?await h(a):void 0,await k(t,e.runId,r)},a=e;return Object.defineProperty(a,"metadata",{get:()=>n??=t===void 0?Promise.resolve(void 0):i(),enumerable:!1,configurable:!0}),{hook:a,metadataEncryptionKey:()=>r}}function Y(e){return le(e)?e:J(e).hook}async function X(e){return J(await(await d()).hooks.getByToken(e)).hook}async function Z(e,t,n){return $(e,t,n,!1,Date.now())}const Q=new WeakMap;async function $(e,t,n,r,i,a=!1){return await j(()=>y(`hook.resume`,async o=>{let s=await d(),c=typeof e==`string`?e:e.token,l=e,u=r,f=n,p=0,m=0,h=K(),g=e=>{if(t instanceof Request&&t.body!==null&&t.bodyUsed)throw o?.setAttributes({"workflow.hook.resume_redirect_unresendable":!0}),new x(`Hook token "${c}" changed owner while this webhook request was being delivered; a request body can be sent only once and it was not delivered anywhere — retry the request, which will reach the token's new owner`,{cause:e})};for(;;)try{return await ue(s,o,l,t,f,u,i,h,a)}catch(e){if(typeof e==`object`&&e&&Q.get(e)===`not-webhook`)throw e;if(p>=3)throw E.is(e)?(o?.setAttributes({"workflow.hook.resume_redirects_exhausted":!0}),new x(`Hook token "${c}" changed owner ${p} times while this resume was in flight; nothing was delivered — retry the resume`,{cause:e})):e;if(E.is(e)){g(e),p++,o?.setAttributes({"workflow.hook.resume_redirects":p,"workflow.hook.resume_redirect_to_run":e.claimedByRunId}),l=c,u=!0,f=void 0,m=0;continue}if(D.is(e)&&p>0&&typeof l==`string`&&m<5){g(e),m++,await new Promise(e=>setTimeout(e,50));continue}if(D.is(e)&&Q.get(e)!==`lookup`){let t=typeof l==`string`?void 0:l.hookId,n;try{n=await s.hooks.getByToken(c)}catch(e){D.is(e)||v.warn(`Hook resume: re-resolving the token after a not-found failed; surfacing the original error`,{token:c,error:e instanceof Error?e.message:String(e)})}if(n?.claimedFrom!==void 0&&n.hookId!==t&&(t===void 0||n.claimedFrom.hookId===t)&&!(a&&n.isWebhook===!1)){g(e),p++,o?.setAttributes({"workflow.hook.resume_redirects":p,"workflow.hook.resume_redirect_to_run":n.runId}),l=n,u=!0,f=void 0;continue}}throw e}}))}async function ue(e,t,r,i,a,u,d,h,y){try{let l=typeof r==`string`,C;if(l)try{C=await e.hooks.getByToken(r)}catch(e){throw D.is(e)&&Q.set(e,`lookup`),e}else C=r;if(y&&C.isWebhook===!1){let e=new D(C.token);throw Q.set(e,`not-webhook`),e}let w=l||u,T=await q(C),{resumeContext:O}=T;if(t?.setAttributes({...f(C.token),...m(C.hookId),..._(C.runId),"workflow.hook.resume_context_source":T.source}),T.run&&o(T.run.status))throw new D(C.token);let k=re(O.workflowCoreVersion),j,M=a?void 0:ee(O.encryptionPublicKey);if(M)j=g(M);else{let e=a??await ce(C,T);k.supportedFormats.has(b.ENCRYPTED)||(e=void 0),j=e}let N=(O.runSpecVersion??0)>=5&&k.supportedFormats.has(b.GZIP),P=[],I=[],L=n(C.specVersion),R=await ne(i,C.runId,j,P,globalThis,L,k.framedByteStreams,N,void 0,I);if(await Promise.all(P.map(e=>e.catch(e=>{if(e!==void 0)throw e}))),ie(Promise.all(I),e=>{e!==void 0&&v.warn(`Background readback of hook payload failed`,{workflowRunId:C.runId,hookId:C.hookId,error:e instanceof Error?e.message:String(e)})}),e.capabilities?.invoke===!0&&!L&&R instanceof Uint8Array){if(!e.invoke)throw new x(`World advertises invoke without implementing it`);t?.setAttributes({"workflow.hook.resume_strategy":`invoke`});let n=ae.parse(await e.invoke(C.runId,{type:`hook_resume`,version:1,hookId:C.hookId,token:C.token,payload:R},{idempotencyKey:h}));if(n.status===`rejected`)throw n.code===`HOOK_NOT_FOUND`?new D(C.token):new x(`Executor rejected the hook invocation input`);return t?.setAttributes(c(!0)),Y(C)}t?.setAttributes({...s(O.workflowName)});let z=await te(O.traceCarrier);z&&t?.addLink?.(z);let B=A(O.workflowName),V={deploymentId:O.deploymentId,specVersion:O.runSpecVersion??1},H=((w?C.resumeCapabilities?.hookResumeDedupVersion??0:0)>=1||e.capabilities?.hookResumeDedup===!0)&&!L&&R instanceof Uint8Array;t?.setAttributes({"workflow.hook.resume_strategy":`sequential`});let U=H?h:void 0,W=H?await oe(R):void 0;U&&t?.setAttributes({"workflow.hook.resume_id":U});let G=e=>D.is(e)||S.is(e);try{await e.events.create(C.runId,{eventType:`hook_received`,specVersion:8,correlationId:C.hookId,eventData:{...L?{}:{token:C.token},payload:R}},{v1Compat:L,...U&&W?{resumeId:U,resumePayloadDigest:W}:{}})}catch(e){throw E.is(e)?e:G(e)?new D(C.token):e}t?.setAttributes(c(!0));let K=Date.now();return await F(()=>e.queue(B,{runId:C.runId,traceCarrier:O.traceCarrier??void 0,hookResumeTiming:{resumeRequestedAtMs:d,queuePublishRequestedAtMs:K,strategy:`sequential`}},{...V,...U?{idempotencyKey:`hook-${U}`}:{}}),e.isDeploymentUnavailableError?.bind(e)),t?.setAttributes(p(!0)),Y(C)}catch(e){throw t?.setAttributes({...f(typeof r==`string`?r:r.token),...l(!1)}),e}}async function de(e,t){let n=Date.now(),{hook:r,metadataEncryptionKey:i}=J(await(await d()).hooks.getByToken(e));if(r.isWebhook===!1)throw new D(e);let a=await r.metadata,o,s;if(a&&typeof a==`object`&&`respondWith`in a){if(a.respondWith===`manual`){let{readable:e,writable:n}=new TransformStream;s=e,t[O]=n}else if(a.respondWith instanceof Response)o=a.respondWith;else throw new x(`Invalid \`respondWith\` value: ${a.respondWith}`,{slug:T.WEBHOOK_INVALID_RESPOND_WITH_VALUE})}else o=new Response(null,{status:202});if(await $(r,t,i(),!0,n,!0),s){let e=s.getReader(),t=await e.read();t.value&&(o=t.value),e.cancel()}if(!o)throw new x(`Workflow run did not send a response`,{slug:T.WEBHOOK_RESPONSE_NOT_SENT});return o}export{W as a,G as i,Z as n,I as o,de as r,R as s,X as t};
@@ -0,0 +1 @@
1
+ import{a as e,ft as t,i as n,it as r,mt as i,nt as a,rt as o,ut as s}from"./dist-BQSf8Hax.js";import{$t as c,Bt as l,Gn as u,Jn as d,Kn as f,On as p,Pn as ee,S as te,Vn as ne,Wn as re,Zn as m,_ as ie,en as ae,fn as oe,mn as se,n as h,qn as ce,y as g,zn as le}from"./logger-BCEj9caG.js";import{A as _,C as v,D as y,E as b,M as x,O as S,T as C,_ as w,c as T,f as E,g as D,j as O,k,m as A,r as j,t as M,u as N,y as P}from"./dist-BfMqXLK3.js";import{$ as F,C as I,G as L,L as R,M as z,N as B,O as V,Q as H,S as U,W,f as ue,o as de}from"./serialization-CJ265vSe.js";import{D as fe,l as pe,s as G}from"./helpers-CNMO7zB1.js";import{t as me}from"./attribute-changes-DzJovO_f.js";import{n as he,r as ge,t as _e}from"./wait-until-Bo2U6ON9.js";const ve=new Set([`PARSE_ERROR`,`SCHEMA_VALIDATION`,x.WORLD_CONTRACT_ERROR]),ye=new Set([`TRANSPORT`,`TIMEOUT`,x.STREAM_ERROR]),be=[_.is,D.is,C.is,A.is];function K(e){if(!O.is(e)||e.status!==void 0)return!1;let t=`cause`in e?e.cause:void 0;return e.code!==void 0&&ve.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 q(e){return P.is(e)?!0:w.is(e)?e.status===void 0||e.status>=500:O.is(e)?e.status!==void 0&&e.status>=500||e.code!==void 0&&ye.has(e.code):!1}function xe(e){if(N.is(e))return x.REPLAY_DIVERGENCE;if(M.is(e))return x.CORRUPTED_EVENT_LOG;if(T.is(e))return x.MAX_EVENTS_EXCEEDED;if(v.is(e))return x.DEPLOYMENT_MISMATCH;if(w.is(e))return x.STREAM_ERROR;if(K(e)||q(e))return x.WORLD_CONTRACT_ERROR;for(let t of be)if(t(e))return x.RUNTIME_ERROR;return x.USER_ERROR}const J=[`node`,`quickjs`];function Y(e=process.env){let t=e.WORKFLOW_VM;if(t!==void 0&&t!==``){if(J.includes(t))return t;throw new _(`Invalid WORKFLOW_VM value: "${t}". Expected one of: ${J.join(`, `)}.`)}}function Se(e){let t=e.executionContext?.workflowVm;if(t!==void 0){if(!J.includes(t))throw new _(`Invalid executionContext.workflowVm value: "${t}". Expected one of: ${J.join(`, `)}.`);return t===`quickjs`}return Y()===`quickjs`}const Ce=s();function we(){let e=L.getStore(),t=e?.workflowMetadata?.workflowRunId;if(t)return{[r]:e.rootRunId??t,[a]:t}}const X=i(`@workflow/core//latestNoOpWarning`,1,()=>({warned:!1}));async function Z(t,r,i){"use step";return await he(()=>{let a=t?.workflowId;if(!a)throw new _(`'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`});let s=`workflow.start ${m(a)}`;return g(s,async t=>{t?.setAttributes({...c(a),...ae(`start`)});let s=[],p=i??{};Array.isArray(r)?s=r:typeof r==`object`&&(p=r),t?.setAttributes({...l(s.length)});let m=p.world??await f();ce(m);let g=await m.getDeploymentId(),v=p.deploymentId??g;v===`latest`&&(m.resolveLatestDeploymentId?v=await m.resolveLatestDeploymentId():(X.warned||(X.warned=!0,h.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:g})),v=g));let y=`wrun_${m.createRunId?m.createRunId(p):Ce()}`,b,x,S,C;if(v===g)b=!0,x=!0,S=1;else if(typeof m.streams?.get!=`function`)b=!1,x=!1,S=void 0;else{let e=await pe(m,{deploymentId:v,runId:y,timeout:2e3,namespace:p.namespace}).catch(()=>void 0);C=e?.encryptionPublicKey;let t=ge(e?.workflowCoreVersion);b=t.framedByteStreams,x=t.supportedFormats.has(le.GZIP),S=e?.hookResumeInputVersion}let w=[],T=await ie(),E=p.specVersion??m.specVersion,D=e(E),O=p.allowReservedAttributes===!0,k;if(p.attributes&&Object.keys(p.attributes).length>0){if(E<4)throw new _(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(p.attributes))if(typeof t!=`string`)throw new _(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=me(p.attributes,{allowReservedAttributes:O});k=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let A;if(p.experimental_retention!==void 0&&p.experimental_retention!=="default"){if(p.experimental_retention!==0)throw new _(`start({ experimental_retention }) must be 0 or 'default'; received ${JSON.stringify(p.experimental_retention)}.`);if(E<4)throw new _(`start({ experimental_retention }) requires a World that supports spec version 4 or later.`);A={[o]:`0`}}let M=E>=4?we():void 0,N=M||A?{...M,...k,...A}:k,P=N?{attributes:N,...O||M!=null||A!=null?{allowReservedAttributes:!0}:{}}:{};if(p.replayedFromRunId!==void 0&&!n.safeParse(p.replayedFromRunId).success)throw new _(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(p.replayedFromRunId).slice(0,64))}.`);let F=re(C),I,L;if(F)I=ee(F),L=C;else{let e=await m.getEncryptionKeyForRun?.(y,{...p,deploymentId:v});I=e?await d(e):void 0,L=e?ne((await u(e)).publicKey):void 0}let R=await ue(s,y,I,w,globalThis,D,b,x&&E>=5),z=m.getEnvironment?.(),B=Y(),V={traceCarrier:T,workflowCoreVersion:fe,features:{encryption:!!I},...S===void 0?{}:{hookResumeInputVersion:S},...B?{workflowVm:B}:{},...p.replayedFromRunId?{replayedFromRunId:p.replayedFromRunId}:{}},[H,U]=await Promise.allSettled([m.events.create(y,{eventType:`run_created`,specVersion:E,eventData:{deploymentId:v,workflowName:a,input:R,executionContext:V,...L?{encryptionPublicKey:L}:{},...P}},{v1Compat:D}),m.queue(G(a,p.namespace),{runId:y,traceCarrier:T,...E>=3?{runInput:{input:R,deploymentId:v,workflowName:a,specVersion:E,executionContext:V,...L?{encryptionPublicKey:L}:{},...z===void 0?{}:{environment:z},...P}}:{}},{deploymentId:v,specVersion:E,...p.region===void 0?{}:{region:p.region}})]);if(U.status===`rejected`)throw U.reason;let W=!1;if(H.status===`rejected`){let e=H.reason;if(!j.is(e)){if(q(e))W=!0,h.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:y,error:e.message});else throw e}}else{let e=H.value;if(!D&&e.run.runId!==y)throw new _(`Server returned different runId than requested: expected ${y}, got ${e.run.runId}`)}return _e(Promise.all(w),e=>{h.warn(`Background flush of workflow argument streams failed`,{workflowRunId:y,error:e instanceof Error?e.message:String(e)})}),t?.setAttributes({...oe(y),...te(v),...H.status===`fulfilled`?se(H.value.run.status):{}}),new $(y,{resilientStart:W})})})}const Te=e=>Array.isArray(e)?e:[e];async function Ee(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await p(i):void 0,o=Te(await z(r.input,t,a,globalThis)),s=n.specVersion??r.specVersion??1,c=n.deploymentId??r.deploymentId;return(await Z({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 De(t,n,r){try{let i=(await t.runs.get(n,{resolveData:`none`})).specVersion??1,a=e(i),o={eventType:`run_cancelled`,specVersion:i,...r?.cancelReason===void 0?{}:{eventData:{cancelReason:r.cancelReason}}};await t.events.create(n,o,{v1Compat:a})}catch(e){throw Error(`Failed to cancel run ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Oe(e,t,n){if(t.length===0)throw Error(`cancelRuns requires at least one run ID.`);if(t.length>500)throw Error(`cancelRuns accepts at most 500 run IDs (received ${t.length}).`);if(new Set(t).size!==t.length)throw Error(`cancelRuns requires unique run IDs (duplicates found).`);if(e.runs.cancelMany)return e.runs.cancelMany({runIds:t,...n?.cancelReason===void 0?{}:{cancelReason:n.cancelReason}});let r=Array(t.length),i=0,a=async()=>{for(;;){let a=i++;if(a>=t.length)return;let o=t[a];try{await De(e,o,n),r[a]={runId:o,outcome:`cancelled`}}catch{r[a]={runId:o,outcome:`failed`,code:`internal_error`,retryable:!0}}}},o=Math.min(20,t.length);await Promise.all(Array.from({length:o},()=>a()));let s={requested:t.length,cancelled:0,alreadyCancelled:0,notCancellable:0,notFound:0,failed:0};for(let e of r)switch(e.outcome){case`cancelled`:s.cancelled++;break;case`already_cancelled`:s.alreadyCancelled++;break;case`not_cancellable`:s.notCancellable++;break;case`not_found`:s.notFound++;break;case`failed`:s.failed++}return{summary:s,results:r}}async function ke(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`});await e.queue(G(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 Ae(t,n,r){try{let i=await t.runs.get(n,{resolveData:`none`}),a=e(i.specVersion),o=[],s=null;do{let e=await t.events.list({runId:n,pagination:{sortOrder:`asc`,...s?{cursor:s}:{}},resolveData:`none`});o.push(...e.data),s=e.hasMore?e.cursor:null}while(s);let c=o.filter(e=>e.eventType===`wait_created`),l=new Set(o.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),u=c.filter(e=>!l.has(e.correlationId));if(r?.correlationIds&&r.correlationIds.length>0){let e=new Set(r.correlationIds);u=u.filter(t=>t.correlationId&&e.has(t.correlationId))}let d=[],f=0;for(let e of u){if(!e.correlationId)continue;let r=a?{eventType:`wait_completed`,correlationId:e.correlationId}:{eventType:`wait_completed`,correlationId:e.correlationId,specVersion:i.specVersion,eventData:{resumeAt:e.eventData.resumeAt}};try{await t.events.create(n,r,{v1Compat:a}),f++}catch(e){j.is(e)?f++:d.push(e instanceof Error?e:Error(String(e)))}}if(f>0&&await t.queue(G(i.workflowName,r?.namespace),{runId:n},{deploymentId:i.deploymentId,specVersion:i.specVersion??1}),d.length>0)throw AggregateError(d,`Failed to complete ${d.length}/${u.length} pending wait(s) for run ${n}`);return{stoppedCount:f}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function je(e,t,n,r){try{return await e.streams.get(t,n,r?.startIndex)}catch(e){throw w.is(e)?e:new w(`Failed to read stream ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Me(e,t){try{return await e.streams.list(t)}catch(e){throw w.is(e)?e:new w(`Failed to list streams for run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}const Ne=new Set([`completed`,`failed`]),Q=[1e3,3e3,6e3];function Pe(){return t(`WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS`,1e3,{integer:!0,min:1})}function Fe(){return t(`WORKFLOW_RETURN_VALUE_WAIT_MS`,5e4,{integer:!0,min:1})}function Ie(){return t(`WORKFLOW_RETURN_VALUE_MAX_LONG_POLLS`,10,{integer:!0,min:1})}function Le(){let e=process.env.WORKFLOW_RETURN_VALUE_LONG_POLL;return e===void 0||e===``||e!==`0`&&e.toLowerCase()!==`false`}var $=class e{static[F](e){return{runId:e.runId,resilientStart:e.#r}}static[H](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=f(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(e){return this.#n||=(async()=>{let t=await this.#t,n=e??await t.runs.get(this.runId),r=await t.getEncryptionKeyForRun?.(n);return r?await p(r):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return Ae(await this.#t,this.runId,e)}async cancel(e){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:8,...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(k.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(e=>e.status))}get returnValue(){"use step";return this.#c()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).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=W(this.runId,i),o=this.#a(),s=I(n,t,this.runId,a,r,o),c=this.#t,l=this.runId;return Object.assign(s,{getTailIndex:async()=>(await(await c).streams.getInfo(l,a)).tailIndex})}get writable(){return this.getWritable()}getWritable(e={}){"use step";let{ops:t=[],global:n=globalThis,namespace:r}=e,i=W(this.runId,r),a,o,s=()=>(a??=this.#o().then(async e=>{let t={key:await U(this.runId,e.deploymentId,e.encryptionPublicKey),deploymentId:e.deploymentId,encryptionPublicKey:e.encryptionPublicKey};return R(o,t),t}),a);return o=de({global:n,ops:t,runId:this.runId,name:i,key:()=>s().then(({key:e})=>e)}),o}async#o(){let e=await this.#t,t=this.#r?Q.length:0,n=0;for(;;)try{return await e.runs.get(this.runId,{resolveData:`none`})}catch(e){if(!k.is(e)||n>=t)throw e;let r=Q[n];n++,await new Promise(e=>setTimeout(e,r))}}async#s(e){let t=e.expiredAt;if(t!=null&&t<=new Date)throw new E(`Run "${this.runId}" ${e.status===`completed`?`completed`:`is ${e.status}`}, but its data expired at ${t.toISOString()} and is no longer readable.`,this.runId,e.status,t);if(e.status===`completed`){let t=await this.#i(e);return await B(e.output,this.runId,t)}if(e.status===`cancelled`)throw new b(this.runId);if(e.status===`failed`){let t=await this.#i(e),n;try{n=await V(e.error,this.runId,t)}catch{n=Error(`Failed to hydrate workflow run error`)}throw new y(this.runId,n,{errorCode:e.errorCode})}throw new S(this.runId,e.status)}async#c(){let e=await this.#t,t=0,n=this.#r?Q.length:0,r=Le()?e.runs.waitForTerminalStatus?.bind(e.runs):void 0,i=0,a=Ie();for(;;){let o=Date.now();try{let t=r&&i<a;t&&i++;let n=t?await r(this.runId,{timeoutMs:Fe(),resolveData:`none`}):await e.runs.get(this.runId,{resolveData:`none`});if(n.status===`cancelled`)throw new b(this.runId);if(Ne.has(n.status)){let t=await e.runs.get(this.runId,{resolveData:`all`});return await this.#s(t)}throw new S(this.runId,n.status)}catch(e){if(S.is(e)){let e=Pe()-(Date.now()-o);e>0&&await new Promise(t=>setTimeout(t,e));continue}if(k.is(e)&&t<n){let e=Q[t];t++,await new Promise(t=>setTimeout(t,e));continue}throw e}}}};function Re(e){return new $(e)}export{Me as a,ke as c,Se as d,xe as f,Oe as i,Ae as l,K as m,Re as n,je as o,q as p,De as r,Ee as s,$ as t,Z as u};