eve 0.27.5 → 0.27.6

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 (261) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/src/channel/forwarded-principal.d.ts +74 -0
  3. package/dist/src/channel/forwarded-principal.js +1 -0
  4. package/dist/src/channel/routes.d.ts +7 -0
  5. package/dist/src/channel/send.js +1 -1
  6. package/dist/src/chunks/{use-eve-agent-BtkhbY2I.js → use-eve-agent-COlXhAaF.js} +1 -1
  7. package/dist/src/chunks/{use-eve-agent-NUjD28Iu.js → use-eve-agent-DzVlKcUV.js} +1 -1
  8. package/dist/src/cli/commands/channels.d.ts +5 -2
  9. package/dist/src/cli/commands/channels.js +1 -1
  10. package/dist/src/cli/dev/local-server-child.d.ts +1 -0
  11. package/dist/src/cli/dev/local-server-child.js +1 -0
  12. package/dist/src/cli/dev/local-server-cleanup.d.ts +5 -0
  13. package/dist/src/cli/dev/local-server-cleanup.js +1 -0
  14. package/dist/src/cli/dev/local-server-process.d.ts +35 -0
  15. package/dist/src/cli/dev/local-server-process.js +1 -0
  16. package/dist/src/cli/dev/tui/remote-auth.js +1 -1
  17. package/dist/src/cli/dev/tui/runner.d.ts +4 -0
  18. package/dist/src/cli/dev/tui/runner.js +1 -1
  19. package/dist/src/cli/dev/tui/terminal-renderer.d.ts +3 -0
  20. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  21. package/dist/src/cli/dev/tui/tui.d.ts +2 -0
  22. package/dist/src/cli/dev/tui/tui.js +1 -1
  23. package/dist/src/cli/dev/wait-for-ui.d.ts +13 -0
  24. package/dist/src/cli/dev/wait-for-ui.js +1 -0
  25. package/dist/src/cli/run.js +2 -2
  26. package/dist/src/cli/shutdown.d.ts +23 -0
  27. package/dist/src/cli/shutdown.js +1 -0
  28. package/dist/src/client/client.js +1 -1
  29. package/dist/src/client/types.d.ts +2 -1
  30. package/dist/src/compiled/@workflow/core/index.js +1 -1
  31. package/dist/src/compiled/@workflow/core/runtime.js +1 -1
  32. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  33. package/dist/src/compiled/_chunks/workflow/{attribute-changes-Dk1fP6vt.js → attribute-changes-CB7nRYoY.js} +1 -1
  34. package/dist/src/compiled/_chunks/workflow/{functions-Dv8dc_-I.js → functions-DareOZz_.js} +1 -1
  35. package/dist/src/compiled/_chunks/workflow/{resume-hook-czpG5xnP.js → resume-hook-g1vh0WRC.js} +1 -1
  36. package/dist/src/compiled/_chunks/workflow/{run-6zaMjFY6.js → run-lsS-QDok.js} +1 -1
  37. package/dist/src/compiled/_chunks/workflow/{sleep-B2u06FWc.js → sleep-BXg5I9l2.js} +1 -1
  38. package/dist/src/compiled/_chunks/workflow/wrapper-DnoQohyD.js +8 -0
  39. package/dist/src/compiler/normalize-subagent.js +1 -1
  40. package/dist/src/evals/autoevals-client.js +1 -1
  41. package/dist/src/evals/cli/eval.js +2 -2
  42. package/dist/src/evals/expect/index.js +1 -1
  43. package/dist/src/evals/judge.js +1 -1
  44. package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
  45. package/dist/src/execution/remote-agent-dispatch.d.ts +5 -1
  46. package/dist/src/execution/remote-agent-dispatch.js +1 -1
  47. package/dist/src/execution/sandbox/bash-tool.js +1 -1
  48. package/dist/src/execution/sandbox/bindings/docker-container.js +1 -1
  49. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +1 -1
  50. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
  51. package/dist/src/execution/sandbox/development-cleanup.js +1 -1
  52. package/dist/src/execution/sandbox/ensure.js +1 -1
  53. package/dist/src/execution/subagent-invocation.d.ts +10 -0
  54. package/dist/src/execution/subagent-invocation.js +2 -2
  55. package/dist/src/execution/subagent-tool.js +1 -1
  56. package/dist/src/internal/application/optional-package-install.js +1 -1
  57. package/dist/src/internal/application/package.js +1 -1
  58. package/dist/src/internal/authored-module-map-loader.js +1 -1
  59. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  60. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  61. package/dist/src/internal/nitro/host/sandbox-shutdown-plugin.js +1 -1
  62. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  63. package/dist/src/node_modules/.pnpm/{autoevals@0.0.132_ws@8.21.1 → autoevals@0.0.132_ws@8.21.1_bufferutil@4.1.0_}/node_modules/autoevals/jsdist/index.js +1 -1
  64. package/dist/src/public/channels/eve.d.ts +20 -0
  65. package/dist/src/public/channels/eve.js +1 -1
  66. package/dist/src/public/definitions/remote-agent.d.ts +15 -0
  67. package/dist/src/public/sandbox/backends/default.js +1 -1
  68. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  69. package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
  70. package/dist/src/runtime/types.d.ts +1 -0
  71. package/dist/src/setup/boxes/add-channels.d.ts +9 -7
  72. package/dist/src/setup/boxes/add-channels.js +2 -2
  73. package/dist/src/setup/boxes/select-channels.d.ts +4 -5
  74. package/dist/src/setup/channel-setup-deployment.d.ts +11 -0
  75. package/dist/src/setup/channel-setup-deployment.js +1 -0
  76. package/dist/src/setup/channel-setup-environment.d.ts +16 -0
  77. package/dist/src/setup/channel-setup-environment.js +1 -0
  78. package/dist/src/setup/channel-setup-integration.d.ts +31 -0
  79. package/dist/src/setup/channel-setup-integration.js +1 -0
  80. package/dist/src/setup/channel-setup-integrations.d.ts +7 -0
  81. package/dist/src/setup/channel-setup-integrations.js +1 -0
  82. package/dist/src/setup/channel-setup-runner.d.ts +7 -0
  83. package/dist/src/setup/channel-setup-runner.js +1 -0
  84. package/dist/src/setup/channel-setup-slack.d.ts +3 -0
  85. package/dist/src/setup/channel-setup-slack.js +1 -0
  86. package/dist/src/setup/channel-setup-ui.d.ts +18 -0
  87. package/dist/src/setup/channel-setup-ui.js +2 -0
  88. package/dist/src/setup/channel-setup-web.d.ts +3 -0
  89. package/dist/src/setup/channel-setup-web.js +1 -0
  90. package/dist/src/setup/flows/channels.d.ts +5 -10
  91. package/dist/src/setup/flows/channels.js +1 -1
  92. package/dist/src/setup/flows/install-vercel-cli.js +1 -1
  93. package/dist/src/setup/flows/login.js +1 -1
  94. package/dist/src/setup/index.js +1 -1
  95. package/dist/src/setup/scaffold/channels-catalog.d.ts +0 -2
  96. package/dist/src/setup/scaffold/channels-catalog.js +1 -1
  97. package/dist/src/setup/scaffold/create/project.js +1 -1
  98. package/dist/src/setup/scaffold/update/channels.d.ts +5 -3
  99. package/dist/src/setup/scaffold/update/channels.js +5 -2
  100. package/dist/src/setup/slack-connect-lifecycle.d.ts +3 -2
  101. package/dist/src/setup/slack-connect-lifecycle.js +1 -1
  102. package/dist/src/setup/slack-connect.d.ts +2 -0
  103. package/dist/src/setup/slack-connect.js +1 -1
  104. package/dist/src/setup/slackbot.d.ts +4 -0
  105. package/dist/src/setup/slackbot.js +1 -1
  106. package/dist/src/svelte/index.js +1 -1
  107. package/dist/src/svelte/use-eve-agent.js +1 -1
  108. package/dist/src/vue/index.js +1 -1
  109. package/dist/src/vue/use-eve-agent.js +1 -1
  110. package/docs/channels/slack.mdx +3 -0
  111. package/docs/guides/auth-and-route-protection.md +20 -0
  112. package/docs/guides/client/overview.mdx +2 -0
  113. package/docs/guides/remote-agents.md +31 -8
  114. package/docs/reference/cli.md +1 -1
  115. package/package.json +1 -1
  116. package/dist/src/compiled/_chunks/workflow/wrapper-Cc2otuUR.js +0 -6
  117. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/_vendor/partial-json-parser/parser.js +0 -0
  118. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/auth/workload-identity-auth.js +0 -0
  119. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/azure.js +0 -0
  120. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/client.js +0 -0
  121. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/core/api-promise.js +0 -0
  122. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/core/error.js +0 -0
  123. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/core/pagination.js +0 -0
  124. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/core/resource.js +0 -0
  125. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/core/streaming.js +0 -0
  126. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/core/uploads.js +0 -0
  127. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/error.js +0 -0
  128. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/index.js +0 -0
  129. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/decoders/line.js +0 -0
  130. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/detect-platform.js +0 -0
  131. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/errors.js +0 -0
  132. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/headers.js +0 -0
  133. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/parse.js +0 -0
  134. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/qs/formats.js +0 -0
  135. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/qs/stringify.js +0 -0
  136. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/qs/utils.js +0 -0
  137. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/request-options.js +0 -0
  138. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/shims.js +0 -0
  139. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/to-file.js +0 -0
  140. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/tslib.js +0 -0
  141. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/uploads.js +0 -0
  142. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils/base64.js +0 -0
  143. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils/bytes.js +0 -0
  144. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils/env.js +0 -0
  145. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils/log.js +0 -0
  146. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils/path.js +0 -0
  147. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils/query.js +0 -0
  148. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils/sleep.js +0 -0
  149. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils/uuid.js +0 -0
  150. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils/values.js +0 -0
  151. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/internal/utils.js +0 -0
  152. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/AbstractChatCompletionRunner.js +0 -0
  153. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/AssistantStream.js +0 -0
  154. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/ChatCompletionRunner.js +0 -0
  155. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/ChatCompletionStream.js +0 -0
  156. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/ChatCompletionStreamingRunner.js +0 -0
  157. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/EventStream.js +0 -0
  158. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/ResponsesParser.js +0 -0
  159. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/RunnableFunction.js +0 -0
  160. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/Util.js +0 -0
  161. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/chatCompletionUtils.js +0 -0
  162. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/parser.js +0 -0
  163. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/lib/responses/ResponseStream.js +0 -0
  164. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/admin.js +0 -0
  165. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/admin-api-keys.js +0 -0
  166. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/audit-logs.js +0 -0
  167. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/certificates.js +0 -0
  168. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/data-retention.js +0 -0
  169. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/groups/groups.js +0 -0
  170. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/groups/roles.js +0 -0
  171. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/groups/users.js +0 -0
  172. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/invites.js +0 -0
  173. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/organization.js +0 -0
  174. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/api-keys.js +0 -0
  175. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/certificates.js +0 -0
  176. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/data-retention.js +0 -0
  177. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/groups/groups.js +0 -0
  178. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/groups/roles.js +0 -0
  179. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.js +0 -0
  180. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/model-permissions.js +0 -0
  181. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/projects.js +0 -0
  182. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/rate-limits.js +0 -0
  183. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/roles.js +0 -0
  184. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/service-accounts.js +0 -0
  185. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/spend-alerts.js +0 -0
  186. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/users/roles.js +0 -0
  187. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/projects/users/users.js +0 -0
  188. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/roles.js +0 -0
  189. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/spend-alerts.js +0 -0
  190. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/usage.js +0 -0
  191. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/users/roles.js +0 -0
  192. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/admin/organization/users/users.js +0 -0
  193. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/audio/audio.js +0 -0
  194. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/audio/speech.js +0 -0
  195. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/audio/transcriptions.js +0 -0
  196. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/audio/translations.js +0 -0
  197. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/batches.js +0 -0
  198. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/assistants.js +0 -0
  199. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/beta.js +0 -0
  200. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/chatkit/chatkit.js +0 -0
  201. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/chatkit/sessions.js +0 -0
  202. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/chatkit/threads.js +0 -0
  203. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/realtime/realtime.js +0 -0
  204. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/realtime/sessions.js +0 -0
  205. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/realtime/transcription-sessions.js +0 -0
  206. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/threads/messages.js +0 -0
  207. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/threads/runs/runs.js +0 -0
  208. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/threads/runs/steps.js +0 -0
  209. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/beta/threads/threads.js +0 -0
  210. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/chat/chat.js +0 -0
  211. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/chat/completions/completions.js +0 -0
  212. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/chat/completions/index.js +0 -0
  213. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/chat/completions/messages.js +0 -0
  214. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/chat/index.js +0 -0
  215. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/completions.js +0 -0
  216. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/containers/containers.js +0 -0
  217. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/containers/files/content.js +0 -0
  218. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/containers/files/files.js +0 -0
  219. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/conversations/conversations.js +0 -0
  220. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/conversations/items.js +0 -0
  221. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/embeddings.js +0 -0
  222. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/evals/evals.js +0 -0
  223. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/evals/runs/output-items.js +0 -0
  224. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/evals/runs/runs.js +0 -0
  225. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/files.js +0 -0
  226. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/fine-tuning/alpha/alpha.js +0 -0
  227. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/fine-tuning/alpha/graders.js +0 -0
  228. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.js +0 -0
  229. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/fine-tuning/checkpoints/permissions.js +0 -0
  230. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/fine-tuning/fine-tuning.js +0 -0
  231. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/fine-tuning/jobs/checkpoints.js +0 -0
  232. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/fine-tuning/jobs/jobs.js +0 -0
  233. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/fine-tuning/methods.js +0 -0
  234. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/graders/grader-models.js +0 -0
  235. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/graders/graders.js +0 -0
  236. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/images.js +0 -0
  237. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/index.js +0 -0
  238. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/models.js +0 -0
  239. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/moderations.js +0 -0
  240. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/realtime/calls.js +0 -0
  241. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/realtime/client-secrets.js +0 -0
  242. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/realtime/realtime.js +0 -0
  243. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/responses/input-items.js +0 -0
  244. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/responses/input-tokens.js +0 -0
  245. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/responses/responses.js +0 -0
  246. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/shared.js +0 -0
  247. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/skills/content.js +0 -0
  248. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/skills/skills.js +0 -0
  249. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/skills/versions/content.js +0 -0
  250. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/skills/versions/versions.js +0 -0
  251. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/uploads/parts.js +0 -0
  252. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/uploads/uploads.js +0 -0
  253. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/vector-stores/file-batches.js +0 -0
  254. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/vector-stores/files.js +0 -0
  255. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/vector-stores/vector-stores.js +0 -0
  256. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/videos.js +0 -0
  257. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/webhooks/index.js +0 -0
  258. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/webhooks/webhooks.js +0 -0
  259. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/resources/webhooks.js +0 -0
  260. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/streaming.js +0 -0
  261. /package/dist/src/node_modules/.pnpm/{openai@6.39.1_ws@8.21.1_zod@3.25.76 → openai@6.39.1_ws@8.21.1_bufferutil@4.1.0__zod@3.25.76}/node_modules/openai/version.js +0 -0
@@ -1 +1 @@
1
- import{t as e}from"./chunk-BTyA9uPd.js";var t=e(((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,{CITY_HEADER_NAME:()=>u,COUNTRY_HEADER_NAME:()=>d,EMOJI_FLAG_UNICODE_STARTING_POSITION:()=>v,IP_HEADER_NAME:()=>f,LATITUDE_HEADER_NAME:()=>p,LONGITUDE_HEADER_NAME:()=>m,POSTAL_CODE_HEADER_NAME:()=>g,REGION_HEADER_NAME:()=>h,REQUEST_ID_HEADER_NAME:()=>_,geolocation:()=>w,ipAddress:()=>S}),t.exports=c(l);let u=`x-vercel-ip-city`,d=`x-vercel-ip-country`,f=`x-real-ip`,p=`x-vercel-ip-latitude`,m=`x-vercel-ip-longitude`,h=`x-vercel-ip-country-region`,g=`x-vercel-ip-postal-code`,_=`x-vercel-id`,v=127397;function y(e,t){return e.get(t)??void 0}function b(e,t){let n=y(e.headers,t);return n?decodeURIComponent(n):void 0}function x(e){let t=RegExp(`^[A-Z]{2}$`).test(e);if(!(!e||!t))return String.fromCodePoint(...e.split(``).map(e=>v+e.charCodeAt(0)))}function S(e){return y(`headers`in e?e.headers:e,f)}function C(e){return e?e.split(`:`)[0]:`dev1`}function w(e){return{city:b(e,u),country:y(e.headers,d),flag:x(y(e.headers,d)),countryRegion:y(e.headers,h),region:C(y(e.headers,_)),latitude:y(e.headers,p),longitude:y(e.headers,m),postalCode:y(e.headers,g)}}0&&(t.exports={CITY_HEADER_NAME:u,COUNTRY_HEADER_NAME:d,EMOJI_FLAG_UNICODE_STARTING_POSITION:v,IP_HEADER_NAME:f,LATITUDE_HEADER_NAME:p,LONGITUDE_HEADER_NAME:m,POSTAL_CODE_HEADER_NAME:g,REGION_HEADER_NAME:h,REQUEST_ID_HEADER_NAME:_,geolocation:w,ipAddress:S})})),n=e(((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,{getEnv:()=>u}),t.exports=c(l);let u=(e=process.env)=>({VERCEL:d(e,`VERCEL`),CI:d(e,`CI`),VERCEL_ENV:d(e,`VERCEL_ENV`),VERCEL_URL:d(e,`VERCEL_URL`),VERCEL_BRANCH_URL:d(e,`VERCEL_BRANCH_URL`),VERCEL_PROJECT_PRODUCTION_URL:d(e,`VERCEL_PROJECT_PRODUCTION_URL`),VERCEL_REGION:d(e,`VERCEL_REGION`),VERCEL_DEPLOYMENT_ID:d(e,`VERCEL_DEPLOYMENT_ID`),VERCEL_SKEW_PROTECTION_ENABLED:d(e,`VERCEL_SKEW_PROTECTION_ENABLED`),VERCEL_AUTOMATION_BYPASS_SECRET:d(e,`VERCEL_AUTOMATION_BYPASS_SECRET`),VERCEL_GIT_PROVIDER:d(e,`VERCEL_GIT_PROVIDER`),VERCEL_GIT_REPO_SLUG:d(e,`VERCEL_GIT_REPO_SLUG`),VERCEL_GIT_REPO_OWNER:d(e,`VERCEL_GIT_REPO_OWNER`),VERCEL_GIT_REPO_ID:d(e,`VERCEL_GIT_REPO_ID`),VERCEL_GIT_COMMIT_REF:d(e,`VERCEL_GIT_COMMIT_REF`),VERCEL_GIT_COMMIT_SHA:d(e,`VERCEL_GIT_COMMIT_SHA`),VERCEL_GIT_COMMIT_MESSAGE:d(e,`VERCEL_GIT_COMMIT_MESSAGE`),VERCEL_GIT_COMMIT_AUTHOR_LOGIN:d(e,`VERCEL_GIT_COMMIT_AUTHOR_LOGIN`),VERCEL_GIT_COMMIT_AUTHOR_NAME:d(e,`VERCEL_GIT_COMMIT_AUTHOR_NAME`),VERCEL_GIT_PREVIOUS_SHA:d(e,`VERCEL_GIT_PREVIOUS_SHA`),VERCEL_GIT_PULL_REQUEST_ID:d(e,`VERCEL_GIT_PULL_REQUEST_ID`)}),d=(e,t)=>{let n=e[t];return n===``?void 0:n};0&&(t.exports={getEnv:u})})),r=e(((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})})),i=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{waitUntil:()=>f}),t.exports=l(u);var d=r();let f=e=>{if(typeof e!=`object`||!e||typeof e.then!=`function`)throw TypeError(`waitUntil can only be called with a Promise, got ${typeof e}`);return(0,d.getContext)().waitUntil?.(e)};0&&(t.exports={waitUntil:f})})),a=e(((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,{next:()=>f,rewrite:()=>d}),t.exports=c(l);function u(e,t){if(e?.request?.headers){if(!(e.request.headers instanceof Headers))throw Error(`request.headers must be an instance of Headers`);let n=[];for(let[r,i]of e.request.headers)t.set(`x-middleware-request-`+r,i),n.push(r);t.set(`x-middleware-override-headers`,n.join(`,`))}}function d(e,t){let n=new Headers(t?.headers??{});return n.set(`x-middleware-rewrite`,String(e)),u(t,n),new Response(null,{...t,headers:n})}function f(e){let t=new Headers(e?.headers??{});return t.set(`x-middleware-next`,`1`),u(e,t),new Response(null,{...e,headers:t})}0&&(t.exports={next:f,rewrite:d})})),o=e(((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,{InMemoryCache:()=>u}),t.exports=c(l);var u=class{constructor(){this.cache={}}async get(e){let t=this.cache[e];return t?t.ttl&&t.lastModified+t.ttl*1e3<Date.now()?(await this.delete(e),null):JSON.parse(t.value):null}async set(e,t,n){let r=JSON.stringify(t??null);this.cache[e]={value:r,lastModified:Date.now(),ttl:n?.ttl,tags:new Set(n?.tags||[])}}async delete(e){delete this.cache[e]}async expireTag(e){let t=Array.isArray(e)?e:[e];for(let e in this.cache)if(Object.prototype.hasOwnProperty.call(this.cache,e)){let n=this.cache[e];t.some(e=>n.tags.has(e))&&delete this.cache[e]}}};0&&(t.exports={InMemoryCache:u})})),s=e(((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},l=e=>s(n({},`__esModule`,{value:!0}),e),u={};o(u,{BuildCache:()=>f}),t.exports=l(u);var d=c(),f=class{constructor({endpoint:e,headers:t,onError:n,timeout:r=500}){this.get=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{headers:this.headers,method:`GET`,signal:t.signal});if(r.status===404)return clearTimeout(n),null;if(r.status===200){if(r.headers.get(d.HEADERS_VERCEL_CACHE_STATE)!==d.PkgCacheState.Fresh)return r.body?.cancel?.(),clearTimeout(n),null;let e=await r.json();return clearTimeout(n),e}else throw clearTimeout(n),Error(`Failed to get cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e);return null}},this.set=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeout);try{let a={};n?.ttl&&(a[d.HEADERS_VERCEL_REVALIDATE]=n.ttl.toString()),n?.tags&&n.tags.length>0&&(a[d.HEADERS_VERCEL_CACHE_TAGS]=n.tags.join(`,`)),n?.name&&(a[d.HEADERS_VERCEL_CACHE_ITEM_NAME]=n.name);let o=await fetch(`${this.endpoint}${e}`,{method:`POST`,headers:{...this.headers,...a},body:JSON.stringify(t),signal:r.signal});if(clearTimeout(i),o.status!==200)throw Error(`Failed to set cache: ${o.status} ${o.statusText}`)}catch(e){if(clearTimeout(i),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.delete=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{method:`DELETE`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to delete cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.expireTag=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{Array.isArray(e)&&(e=e.join(`,`));let r=await fetch(`${this.endpoint}revalidate?tags=${e}`,{method:`POST`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to revalidate tag: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.endpoint=e,this.headers=t,this.onError=n,this.timeout=r}};0&&(t.exports={BuildCache:f})})),c=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of a(t))!c.call(e,s)&&s!==r&&n(e,s,{get:()=>t[s],enumerable:!(o=i(t,s))||o.enumerable});return e},d=e=>u(n({},`__esModule`,{value:!0}),e),f={};l(f,{HEADERS_VERCEL_CACHE_ITEM_NAME:()=>O,HEADERS_VERCEL_CACHE_STATE:()=>T,HEADERS_VERCEL_CACHE_TAGS:()=>D,HEADERS_VERCEL_REVALIDATE:()=>E,PkgCacheState:()=>w,getCache:()=>y}),t.exports=d(f);var p=r(),m=o(),h=s();let g=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)},_=null,v=null,y=e=>x(()=>{let e;return e=(0,p.getContext)().cache?(0,p.getContext)().cache:C(process.env.SUSPENSE_CACHE_DEBUG===`true`),e},b(e));function b(e){let t=e?.keyHashFunction||g;return n=>{if(!e?.namespace)return t(n);let r=e.namespaceSeparator||`$`;return`${e.namespace}${r}${t(n)}`}}function x(e,t){return{get:n=>e().get(t(n)),set:(n,r,i)=>e().set(t(n),r,{...i,name:i?.name??n}),delete:n=>e().delete(t(n)),expireTag:t=>e().expireTag(t)}}let S=!1;function C(e){if(_||=new m.InMemoryCache,process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE===`true`)return e&&console.log(`Using InMemoryCache as build cache is disabled`),_;let{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}=process.env;if(e&&console.log(`Runtime cache environment variables:`,{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}),!t||!n)return S||=(console.warn(`Runtime Cache unavailable in this environment. Falling back to in-memory cache.`),!0),_;if(!v){let e={};try{e=JSON.parse(n)}catch(e){return console.error(`Failed to parse RUNTIME_CACHE_HEADERS:`,e),_}let r=500;if(process.env.RUNTIME_CACHE_TIMEOUT){let e=parseInt(process.env.RUNTIME_CACHE_TIMEOUT,10);!isNaN(e)&&e>0?r=e:console.warn(`Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${r}ms`)}v=new h.BuildCache({endpoint:t,headers:e,onError:e=>console.error(e),timeout:r})}return v}var w=(e=>(e.Fresh=`fresh`,e.Stale=`stale`,e.Expired=`expired`,e.NotFound=`notFound`,e.Error=`error`,e))(w||{});let T=`x-vercel-cache-state`,E=`x-vercel-revalidate`,D=`x-vercel-cache-tags`,O=`x-vercel-cache-item-name`;0&&(t.exports={HEADERS_VERCEL_CACHE_ITEM_NAME:O,HEADERS_VERCEL_CACHE_STATE:T,HEADERS_VERCEL_CACHE_TAGS:D,HEADERS_VERCEL_REVALIDATE:E,PkgCacheState:w,getCache:y})})),l=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{attachDatabasePool:()=>v,experimental_attachDatabasePool:()=>y}),t.exports=l(u);var d=r();let f=!!process.env.DEBUG;function p(e){if(`options`in e&&e.options){if(`idleTimeoutMillis`in e.options)return typeof e.options.idleTimeoutMillis==`number`?e.options.idleTimeoutMillis:1e4;if(`maxIdleTimeMS`in e.options)return typeof e.options.maxIdleTimeMS==`number`?e.options.maxIdleTimeMS:0;if(`status`in e)return 5e3;if(`connect`in e&&`execute`in e)return 3e4}if(`config`in e&&e.config){if(`connectionConfig`in e.config&&e.config.connectionConfig)return e.config.connectionConfig.idleTimeout||6e4;if(`idleTimeout`in e.config)return typeof e.config.idleTimeout==`number`?e.config.idleTimeout:6e4}return`poolTimeout`in e?typeof e.poolTimeout==`number`?e.poolTimeout:6e4:`idleTimeout`in e?typeof e.idleTimeout==`number`?e.idleTimeout:0:1e4}let m=null,h=()=>{},g=Date.now();function _(e){if(!process.env.VERCEL_URL||!process.env.VERCEL_REGION)return;m&&(clearTimeout(m),h());let t=new Promise(e=>{h=e}),n=Math.min(p(e)+100,Math.max(100,899e3-(Date.now()-g)));m=setTimeout(()=>{h?.(),f&&console.log(`Database pool idle timeout reached. Releasing connections.`)},n);let r=(0,d.getContext)();r?.waitUntil?r.waitUntil(t):console.warn(`Pool release event triggered outside of request scope.`)}function v(e){if(m&&(h?.(),clearTimeout(m)),`on`in e&&e.on&&`options`in e&&`idleTimeoutMillis`in e.options){e.on(`release`,()=>{f&&console.log(`Client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`connectionConfig`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`idleTimeout`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL2/MariaDB client released from pool`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`maxIdleTimeMS`in e.options){e.on(`connectionCheckedOut`,()=>{f&&console.log(`MongoDB connection checked out`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`socket`in e.options){e.on(`end`,()=>{f&&console.log(`Redis connection ended`),_(e)});return}throw Error(`Unsupported database pool type`)}let y=v;0&&(t.exports={attachDatabasePool:v,experimental_attachDatabasePool:y})})),u=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{dangerouslyDeleteBySrcImage:()=>h,dangerouslyDeleteByTag:()=>p,invalidateBySrcImage:()=>m,invalidateByTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateByTag(e):Promise.resolve()},p=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteByTag(e,t):Promise.resolve()},m=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateBySrcImage(e):Promise.resolve()},h=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteBySrcImage(e,t):Promise.resolve()};0&&(t.exports={dangerouslyDeleteBySrcImage:h,dangerouslyDeleteByTag:p,invalidateBySrcImage:m,invalidateByTag:f})})),d=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{addCacheTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().addCacheTag;return t?t(e):Promise.resolve()};0&&(t.exports={addCacheTag:f})})),f=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{experimental_upgradeWebSocket:()=>p}),t.exports=l(u);var d=r();async function f(){try{return(await import(`./wrapper-Cc2otuUR.js`)).WebSocketServer}catch{throw Error(`The "ws" package is required for experimental_upgradeWebSocket(). Install it with: npm install ws`)}}async function p(e,t={}){let n=(0,d.getContext)();if(typeof n.upgradeWebSocket!=`function`)throw Error(`experimental_upgradeWebSocket is not available in the current runtime environment. This feature requires a Vercel runtime that supports WebSocket upgrades.`);let r=await f(),{req:i,socket:a,head:o}=n.upgradeWebSocket(),s=new r({noServer:!0,maxPayload:t.maxPayload??262144}),c=await new Promise((e,t)=>{let n=()=>{a.removeListener(`error`,l),a.removeListener(`close`,u)},r=e=>{if(n(),e instanceof Error){t(e);return}let r=Error(`WebSocket upgrade failed`);r.cause=e,t(r)},c=t=>{n(),e(t)},l=e=>r(e),u=()=>r(Error(`socket closed before the WebSocket upgrade completed`));a.once(`error`,l),a.once(`close`,u);try{s.handleUpgrade(i,a,o,c)}catch(e){r(e)}});try{await e(c)}catch(e){throw c.close(1011,`WebSocket handler failed`),e}return new Response(null,{status:204})}0&&(t.exports={experimental_upgradeWebSocket:p})})),p=e(((e,r)=>{var o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,m=Object.prototype.hasOwnProperty,h=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of p(t))!m.call(e,i)&&i!==n&&o(e,i,{get:()=>t[i],enumerable:!(r=s(t,i))||r.enumerable});return e},_=e=>g(o({},`__esModule`,{value:!0}),e),v={};h(v,{addCacheTag:()=>E.addCacheTag,attachDatabasePool:()=>w.attachDatabasePool,dangerouslyDeleteBySrcImage:()=>T.dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag:()=>T.dangerouslyDeleteByTag,experimental_attachDatabasePool:()=>w.experimental_attachDatabasePool,experimental_upgradeWebSocket:()=>D.experimental_upgradeWebSocket,geolocation:()=>y.geolocation,getCache:()=>C.getCache,getEnv:()=>b.getEnv,invalidateBySrcImage:()=>T.invalidateBySrcImage,invalidateByTag:()=>T.invalidateByTag,ipAddress:()=>y.ipAddress,next:()=>S.next,rewrite:()=>S.rewrite,waitUntil:()=>x.waitUntil}),r.exports=_(v);var y=t(),b=n(),x=i(),S=a(),C=c(),w=l(),T=u(),E=d(),D=f();0&&(r.exports={addCacheTag,attachDatabasePool,dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag,experimental_attachDatabasePool,experimental_upgradeWebSocket,geolocation,getCache,getEnv,invalidateBySrcImage,invalidateByTag,ipAddress,next,rewrite,waitUntil})}));export default p();export{};
1
+ import{t as e}from"./chunk-BTyA9uPd.js";var t=e(((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,{CITY_HEADER_NAME:()=>u,COUNTRY_HEADER_NAME:()=>d,EMOJI_FLAG_UNICODE_STARTING_POSITION:()=>v,IP_HEADER_NAME:()=>f,LATITUDE_HEADER_NAME:()=>p,LONGITUDE_HEADER_NAME:()=>m,POSTAL_CODE_HEADER_NAME:()=>g,REGION_HEADER_NAME:()=>h,REQUEST_ID_HEADER_NAME:()=>_,geolocation:()=>w,ipAddress:()=>S}),t.exports=c(l);let u=`x-vercel-ip-city`,d=`x-vercel-ip-country`,f=`x-real-ip`,p=`x-vercel-ip-latitude`,m=`x-vercel-ip-longitude`,h=`x-vercel-ip-country-region`,g=`x-vercel-ip-postal-code`,_=`x-vercel-id`,v=127397;function y(e,t){return e.get(t)??void 0}function b(e,t){let n=y(e.headers,t);return n?decodeURIComponent(n):void 0}function x(e){let t=RegExp(`^[A-Z]{2}$`).test(e);if(!(!e||!t))return String.fromCodePoint(...e.split(``).map(e=>v+e.charCodeAt(0)))}function S(e){return y(`headers`in e?e.headers:e,f)}function C(e){return e?e.split(`:`)[0]:`dev1`}function w(e){return{city:b(e,u),country:y(e.headers,d),flag:x(y(e.headers,d)),countryRegion:y(e.headers,h),region:C(y(e.headers,_)),latitude:y(e.headers,p),longitude:y(e.headers,m),postalCode:y(e.headers,g)}}0&&(t.exports={CITY_HEADER_NAME:u,COUNTRY_HEADER_NAME:d,EMOJI_FLAG_UNICODE_STARTING_POSITION:v,IP_HEADER_NAME:f,LATITUDE_HEADER_NAME:p,LONGITUDE_HEADER_NAME:m,POSTAL_CODE_HEADER_NAME:g,REGION_HEADER_NAME:h,REQUEST_ID_HEADER_NAME:_,geolocation:w,ipAddress:S})})),n=e(((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,{getEnv:()=>u}),t.exports=c(l);let u=(e=process.env)=>({VERCEL:d(e,`VERCEL`),CI:d(e,`CI`),VERCEL_ENV:d(e,`VERCEL_ENV`),VERCEL_URL:d(e,`VERCEL_URL`),VERCEL_BRANCH_URL:d(e,`VERCEL_BRANCH_URL`),VERCEL_PROJECT_PRODUCTION_URL:d(e,`VERCEL_PROJECT_PRODUCTION_URL`),VERCEL_REGION:d(e,`VERCEL_REGION`),VERCEL_DEPLOYMENT_ID:d(e,`VERCEL_DEPLOYMENT_ID`),VERCEL_SKEW_PROTECTION_ENABLED:d(e,`VERCEL_SKEW_PROTECTION_ENABLED`),VERCEL_AUTOMATION_BYPASS_SECRET:d(e,`VERCEL_AUTOMATION_BYPASS_SECRET`),VERCEL_GIT_PROVIDER:d(e,`VERCEL_GIT_PROVIDER`),VERCEL_GIT_REPO_SLUG:d(e,`VERCEL_GIT_REPO_SLUG`),VERCEL_GIT_REPO_OWNER:d(e,`VERCEL_GIT_REPO_OWNER`),VERCEL_GIT_REPO_ID:d(e,`VERCEL_GIT_REPO_ID`),VERCEL_GIT_COMMIT_REF:d(e,`VERCEL_GIT_COMMIT_REF`),VERCEL_GIT_COMMIT_SHA:d(e,`VERCEL_GIT_COMMIT_SHA`),VERCEL_GIT_COMMIT_MESSAGE:d(e,`VERCEL_GIT_COMMIT_MESSAGE`),VERCEL_GIT_COMMIT_AUTHOR_LOGIN:d(e,`VERCEL_GIT_COMMIT_AUTHOR_LOGIN`),VERCEL_GIT_COMMIT_AUTHOR_NAME:d(e,`VERCEL_GIT_COMMIT_AUTHOR_NAME`),VERCEL_GIT_PREVIOUS_SHA:d(e,`VERCEL_GIT_PREVIOUS_SHA`),VERCEL_GIT_PULL_REQUEST_ID:d(e,`VERCEL_GIT_PULL_REQUEST_ID`)}),d=(e,t)=>{let n=e[t];return n===``?void 0:n};0&&(t.exports={getEnv:u})})),r=e(((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})})),i=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{waitUntil:()=>f}),t.exports=l(u);var d=r();let f=e=>{if(typeof e!=`object`||!e||typeof e.then!=`function`)throw TypeError(`waitUntil can only be called with a Promise, got ${typeof e}`);return(0,d.getContext)().waitUntil?.(e)};0&&(t.exports={waitUntil:f})})),a=e(((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,{next:()=>f,rewrite:()=>d}),t.exports=c(l);function u(e,t){if(e?.request?.headers){if(!(e.request.headers instanceof Headers))throw Error(`request.headers must be an instance of Headers`);let n=[];for(let[r,i]of e.request.headers)t.set(`x-middleware-request-`+r,i),n.push(r);t.set(`x-middleware-override-headers`,n.join(`,`))}}function d(e,t){let n=new Headers(t?.headers??{});return n.set(`x-middleware-rewrite`,String(e)),u(t,n),new Response(null,{...t,headers:n})}function f(e){let t=new Headers(e?.headers??{});return t.set(`x-middleware-next`,`1`),u(e,t),new Response(null,{...e,headers:t})}0&&(t.exports={next:f,rewrite:d})})),o=e(((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,{InMemoryCache:()=>u}),t.exports=c(l);var u=class{constructor(){this.cache={}}async get(e){let t=this.cache[e];return t?t.ttl&&t.lastModified+t.ttl*1e3<Date.now()?(await this.delete(e),null):JSON.parse(t.value):null}async set(e,t,n){let r=JSON.stringify(t??null);this.cache[e]={value:r,lastModified:Date.now(),ttl:n?.ttl,tags:new Set(n?.tags||[])}}async delete(e){delete this.cache[e]}async expireTag(e){let t=Array.isArray(e)?e:[e];for(let e in this.cache)if(Object.prototype.hasOwnProperty.call(this.cache,e)){let n=this.cache[e];t.some(e=>n.tags.has(e))&&delete this.cache[e]}}};0&&(t.exports={InMemoryCache:u})})),s=e(((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},l=e=>s(n({},`__esModule`,{value:!0}),e),u={};o(u,{BuildCache:()=>f}),t.exports=l(u);var d=c(),f=class{constructor({endpoint:e,headers:t,onError:n,timeout:r=500}){this.get=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{headers:this.headers,method:`GET`,signal:t.signal});if(r.status===404)return clearTimeout(n),null;if(r.status===200){if(r.headers.get(d.HEADERS_VERCEL_CACHE_STATE)!==d.PkgCacheState.Fresh)return r.body?.cancel?.(),clearTimeout(n),null;let e=await r.json();return clearTimeout(n),e}else throw clearTimeout(n),Error(`Failed to get cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e);return null}},this.set=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeout);try{let a={};n?.ttl&&(a[d.HEADERS_VERCEL_REVALIDATE]=n.ttl.toString()),n?.tags&&n.tags.length>0&&(a[d.HEADERS_VERCEL_CACHE_TAGS]=n.tags.join(`,`)),n?.name&&(a[d.HEADERS_VERCEL_CACHE_ITEM_NAME]=n.name);let o=await fetch(`${this.endpoint}${e}`,{method:`POST`,headers:{...this.headers,...a},body:JSON.stringify(t),signal:r.signal});if(clearTimeout(i),o.status!==200)throw Error(`Failed to set cache: ${o.status} ${o.statusText}`)}catch(e){if(clearTimeout(i),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.delete=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{method:`DELETE`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to delete cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.expireTag=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{Array.isArray(e)&&(e=e.join(`,`));let r=await fetch(`${this.endpoint}revalidate?tags=${e}`,{method:`POST`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to revalidate tag: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.endpoint=e,this.headers=t,this.onError=n,this.timeout=r}};0&&(t.exports={BuildCache:f})})),c=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of a(t))!c.call(e,s)&&s!==r&&n(e,s,{get:()=>t[s],enumerable:!(o=i(t,s))||o.enumerable});return e},d=e=>u(n({},`__esModule`,{value:!0}),e),f={};l(f,{HEADERS_VERCEL_CACHE_ITEM_NAME:()=>O,HEADERS_VERCEL_CACHE_STATE:()=>T,HEADERS_VERCEL_CACHE_TAGS:()=>D,HEADERS_VERCEL_REVALIDATE:()=>E,PkgCacheState:()=>w,getCache:()=>y}),t.exports=d(f);var p=r(),m=o(),h=s();let g=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)},_=null,v=null,y=e=>x(()=>{let e;return e=(0,p.getContext)().cache?(0,p.getContext)().cache:C(process.env.SUSPENSE_CACHE_DEBUG===`true`),e},b(e));function b(e){let t=e?.keyHashFunction||g;return n=>{if(!e?.namespace)return t(n);let r=e.namespaceSeparator||`$`;return`${e.namespace}${r}${t(n)}`}}function x(e,t){return{get:n=>e().get(t(n)),set:(n,r,i)=>e().set(t(n),r,{...i,name:i?.name??n}),delete:n=>e().delete(t(n)),expireTag:t=>e().expireTag(t)}}let S=!1;function C(e){if(_||=new m.InMemoryCache,process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE===`true`)return e&&console.log(`Using InMemoryCache as build cache is disabled`),_;let{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}=process.env;if(e&&console.log(`Runtime cache environment variables:`,{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}),!t||!n)return S||=(console.warn(`Runtime Cache unavailable in this environment. Falling back to in-memory cache.`),!0),_;if(!v){let e={};try{e=JSON.parse(n)}catch(e){return console.error(`Failed to parse RUNTIME_CACHE_HEADERS:`,e),_}let r=500;if(process.env.RUNTIME_CACHE_TIMEOUT){let e=parseInt(process.env.RUNTIME_CACHE_TIMEOUT,10);!isNaN(e)&&e>0?r=e:console.warn(`Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${r}ms`)}v=new h.BuildCache({endpoint:t,headers:e,onError:e=>console.error(e),timeout:r})}return v}var w=(e=>(e.Fresh=`fresh`,e.Stale=`stale`,e.Expired=`expired`,e.NotFound=`notFound`,e.Error=`error`,e))(w||{});let T=`x-vercel-cache-state`,E=`x-vercel-revalidate`,D=`x-vercel-cache-tags`,O=`x-vercel-cache-item-name`;0&&(t.exports={HEADERS_VERCEL_CACHE_ITEM_NAME:O,HEADERS_VERCEL_CACHE_STATE:T,HEADERS_VERCEL_CACHE_TAGS:D,HEADERS_VERCEL_REVALIDATE:E,PkgCacheState:w,getCache:y})})),l=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{attachDatabasePool:()=>v,experimental_attachDatabasePool:()=>y}),t.exports=l(u);var d=r();let f=!!process.env.DEBUG;function p(e){if(`options`in e&&e.options){if(`idleTimeoutMillis`in e.options)return typeof e.options.idleTimeoutMillis==`number`?e.options.idleTimeoutMillis:1e4;if(`maxIdleTimeMS`in e.options)return typeof e.options.maxIdleTimeMS==`number`?e.options.maxIdleTimeMS:0;if(`status`in e)return 5e3;if(`connect`in e&&`execute`in e)return 3e4}if(`config`in e&&e.config){if(`connectionConfig`in e.config&&e.config.connectionConfig)return e.config.connectionConfig.idleTimeout||6e4;if(`idleTimeout`in e.config)return typeof e.config.idleTimeout==`number`?e.config.idleTimeout:6e4}return`poolTimeout`in e?typeof e.poolTimeout==`number`?e.poolTimeout:6e4:`idleTimeout`in e?typeof e.idleTimeout==`number`?e.idleTimeout:0:1e4}let m=null,h=()=>{},g=Date.now();function _(e){if(!process.env.VERCEL_URL||!process.env.VERCEL_REGION)return;m&&(clearTimeout(m),h());let t=new Promise(e=>{h=e}),n=Math.min(p(e)+100,Math.max(100,899e3-(Date.now()-g)));m=setTimeout(()=>{h?.(),f&&console.log(`Database pool idle timeout reached. Releasing connections.`)},n);let r=(0,d.getContext)();r?.waitUntil?r.waitUntil(t):console.warn(`Pool release event triggered outside of request scope.`)}function v(e){if(m&&(h?.(),clearTimeout(m)),`on`in e&&e.on&&`options`in e&&`idleTimeoutMillis`in e.options){e.on(`release`,()=>{f&&console.log(`Client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`connectionConfig`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`idleTimeout`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL2/MariaDB client released from pool`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`maxIdleTimeMS`in e.options){e.on(`connectionCheckedOut`,()=>{f&&console.log(`MongoDB connection checked out`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`socket`in e.options){e.on(`end`,()=>{f&&console.log(`Redis connection ended`),_(e)});return}throw Error(`Unsupported database pool type`)}let y=v;0&&(t.exports={attachDatabasePool:v,experimental_attachDatabasePool:y})})),u=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{dangerouslyDeleteBySrcImage:()=>h,dangerouslyDeleteByTag:()=>p,invalidateBySrcImage:()=>m,invalidateByTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateByTag(e):Promise.resolve()},p=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteByTag(e,t):Promise.resolve()},m=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateBySrcImage(e):Promise.resolve()},h=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteBySrcImage(e,t):Promise.resolve()};0&&(t.exports={dangerouslyDeleteBySrcImage:h,dangerouslyDeleteByTag:p,invalidateBySrcImage:m,invalidateByTag:f})})),d=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{addCacheTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().addCacheTag;return t?t(e):Promise.resolve()};0&&(t.exports={addCacheTag:f})})),f=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{experimental_upgradeWebSocket:()=>p}),t.exports=l(u);var d=r();async function f(){try{return(await import(`./wrapper-DnoQohyD.js`)).WebSocketServer}catch{throw Error(`The "ws" package is required for experimental_upgradeWebSocket(). Install it with: npm install ws`)}}async function p(e,t={}){let n=(0,d.getContext)();if(typeof n.upgradeWebSocket!=`function`)throw Error(`experimental_upgradeWebSocket is not available in the current runtime environment. This feature requires a Vercel runtime that supports WebSocket upgrades.`);let r=await f(),{req:i,socket:a,head:o}=n.upgradeWebSocket(),s=new r({noServer:!0,maxPayload:t.maxPayload??262144}),c=await new Promise((e,t)=>{let n=()=>{a.removeListener(`error`,l),a.removeListener(`close`,u)},r=e=>{if(n(),e instanceof Error){t(e);return}let r=Error(`WebSocket upgrade failed`);r.cause=e,t(r)},c=t=>{n(),e(t)},l=e=>r(e),u=()=>r(Error(`socket closed before the WebSocket upgrade completed`));a.once(`error`,l),a.once(`close`,u);try{s.handleUpgrade(i,a,o,c)}catch(e){r(e)}});try{await e(c)}catch(e){throw c.close(1011,`WebSocket handler failed`),e}return new Response(null,{status:204})}0&&(t.exports={experimental_upgradeWebSocket:p})})),p=e(((e,r)=>{var o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,m=Object.prototype.hasOwnProperty,h=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of p(t))!m.call(e,i)&&i!==n&&o(e,i,{get:()=>t[i],enumerable:!(r=s(t,i))||r.enumerable});return e},_=e=>g(o({},`__esModule`,{value:!0}),e),v={};h(v,{addCacheTag:()=>E.addCacheTag,attachDatabasePool:()=>w.attachDatabasePool,dangerouslyDeleteBySrcImage:()=>T.dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag:()=>T.dangerouslyDeleteByTag,experimental_attachDatabasePool:()=>w.experimental_attachDatabasePool,experimental_upgradeWebSocket:()=>D.experimental_upgradeWebSocket,geolocation:()=>y.geolocation,getCache:()=>C.getCache,getEnv:()=>b.getEnv,invalidateBySrcImage:()=>T.invalidateBySrcImage,invalidateByTag:()=>T.invalidateByTag,ipAddress:()=>y.ipAddress,next:()=>S.next,rewrite:()=>S.rewrite,waitUntil:()=>x.waitUntil}),r.exports=_(v);var y=t(),b=n(),x=i(),S=a(),C=c(),w=l(),T=u(),E=d(),D=f();0&&(r.exports={addCacheTag,attachDatabasePool,dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag,experimental_attachDatabasePool,experimental_upgradeWebSocket,geolocation,getCache,getEnv,invalidateBySrcImage,invalidateByTag,ipAddress,next,rewrite,waitUntil})}));export default p();export{};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-BTyA9uPd.js";import{E as t,n,o as r}from"./dist-B3qkUnLJ.js";import{A as i,C as a,On as o,Pn as s,Q as c,W as l,_ as u,a as d,ct as f,et as p,fn as m,lt as h,n as g,nn as _,qt as v,r as y,st as b,vn as x}from"./attribute-changes-Dk1fP6vt.js";import{N as S,s as C}from"./dist-BX517Nmz.js";var w=e({getHookByToken:()=>D,resumeHook:()=>O,resumeWebhook:()=>k});async function T(e){let t=await x(),n=await t.hooks.getByToken(e);return{hook:n,run:await t.runs.get(n.runId)}}async function E(e){let{hook:t,run:n}=await T(e),r=await(await x()).getEncryptionKeyForRun?.(n),a=r?await s(r):void 0;return t.metadata!==void 0&&(t.metadata=await i(t.metadata,t.runId,a)),{hook:t,encryptionKey:a}}async function D(e){let{hook:t}=await E(e);return t}async function O(e,t,n){return await y(()=>p(`hook.resume`,async i=>{let o=await x();try{let p,y;if(typeof e==`string`){let t=await T(e);p=t.hook,y=t.run}else p=e,y=await o.runs.get(p.runId);if(i?.setAttributes({...h(p.token),...f(p.hookId),..._(p.runId)}),S(y.status))throw new r(p.token);let b=n;if(!b){let e=await o.getEncryptionKeyForRun?.(y);b=e?await s(e):void 0}let x=y.executionContext?.workflowCoreVersion,w=u(typeof x==`string`?x:void 0);w.supportedFormats.has(m.ENCRYPTED)||(b=void 0);let E=(y.specVersion??0)>=5&&w.supportedFormats.has(m.GZIP),D=[],O=C(p.specVersion),k=await a(t,p.runId,b,D,globalThis,O,w.framedByteStreams,E);g(Promise.all(D),e=>{e!==void 0&&l.warn(`Background flush of hook payload ops failed`,{workflowRunId:p.runId,hookId:p.hookId,error:e instanceof Error?e.message:String(e)})}),await o.events.create(p.runId,{eventType:`hook_received`,specVersion:5,correlationId:p.hookId,eventData:{...O?{}:{token:p.token},payload:k}},{v1Compat:O}),i?.setAttributes({...v(y.workflowName)});let A=await c(y.executionContext?.traceCarrier);return A&&i?.addLink?.(A),await o.queue(d(y.workflowName),{runId:p.runId,traceCarrier:y.executionContext?.traceCarrier??void 0},{deploymentId:y.deploymentId,specVersion:y.specVersion??1}),p}catch(t){throw i?.setAttributes({...h(typeof e==`string`?e:e.token),...b(!1)}),t}}))}async function k(e,i){let{hook:a,encryptionKey:s}=await E(e);if(a.isWebhook===!1)throw new r(e);let c,l;if(a.metadata&&typeof a.metadata==`object`&&`respondWith`in a.metadata)if(a.metadata.respondWith===`manual`){let{readable:e,writable:t}=new TransformStream;l=e,i[o]=t}else if(a.metadata.respondWith instanceof Response)c=a.metadata.respondWith;else throw new t(`Invalid \`respondWith\` value: ${a.metadata.respondWith}`,{slug:n.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else c=new Response(null,{status:202});if(await O(a,i,s),l){let e=l.getReader(),t=await e.read();t.value&&(c=t.value),e.cancel()}if(!c)throw new t(`Workflow run did not send a response`,{slug:n.WEBHOOK_RESPONSE_NOT_SENT});return c}export{w as i,O as n,k as r,D as t};
1
+ import{r as e}from"./chunk-BTyA9uPd.js";import{E as t,n,o as r}from"./dist-B3qkUnLJ.js";import{A as i,C as a,On as o,Pn as s,Q as c,W as l,_ as u,a as d,ct as f,et as p,fn as m,lt as h,n as g,nn as _,qt as v,r as y,st as b,vn as x}from"./attribute-changes-CB7nRYoY.js";import{N as S,s as C}from"./dist-BX517Nmz.js";var w=e({getHookByToken:()=>D,resumeHook:()=>O,resumeWebhook:()=>k});async function T(e){let t=await x(),n=await t.hooks.getByToken(e);return{hook:n,run:await t.runs.get(n.runId)}}async function E(e){let{hook:t,run:n}=await T(e),r=await(await x()).getEncryptionKeyForRun?.(n),a=r?await s(r):void 0;return t.metadata!==void 0&&(t.metadata=await i(t.metadata,t.runId,a)),{hook:t,encryptionKey:a}}async function D(e){let{hook:t}=await E(e);return t}async function O(e,t,n){return await y(()=>p(`hook.resume`,async i=>{let o=await x();try{let p,y;if(typeof e==`string`){let t=await T(e);p=t.hook,y=t.run}else p=e,y=await o.runs.get(p.runId);if(i?.setAttributes({...h(p.token),...f(p.hookId),..._(p.runId)}),S(y.status))throw new r(p.token);let b=n;if(!b){let e=await o.getEncryptionKeyForRun?.(y);b=e?await s(e):void 0}let x=y.executionContext?.workflowCoreVersion,w=u(typeof x==`string`?x:void 0);w.supportedFormats.has(m.ENCRYPTED)||(b=void 0);let E=(y.specVersion??0)>=5&&w.supportedFormats.has(m.GZIP),D=[],O=C(p.specVersion),k=await a(t,p.runId,b,D,globalThis,O,w.framedByteStreams,E);g(Promise.all(D),e=>{e!==void 0&&l.warn(`Background flush of hook payload ops failed`,{workflowRunId:p.runId,hookId:p.hookId,error:e instanceof Error?e.message:String(e)})}),await o.events.create(p.runId,{eventType:`hook_received`,specVersion:5,correlationId:p.hookId,eventData:{...O?{}:{token:p.token},payload:k}},{v1Compat:O}),i?.setAttributes({...v(y.workflowName)});let A=await c(y.executionContext?.traceCarrier);return A&&i?.addLink?.(A),await o.queue(d(y.workflowName),{runId:p.runId,traceCarrier:y.executionContext?.traceCarrier??void 0},{deploymentId:y.deploymentId,specVersion:y.specVersion??1}),p}catch(t){throw i?.setAttributes({...h(typeof e==`string`?e:e.token),...b(!1)}),t}}))}async function k(e,i){let{hook:a,encryptionKey:s}=await E(e);if(a.isWebhook===!1)throw new r(e);let c,l;if(a.metadata&&typeof a.metadata==`object`&&`respondWith`in a.metadata)if(a.metadata.respondWith===`manual`){let{readable:e,writable:t}=new TransformStream;l=e,i[o]=t}else if(a.metadata.respondWith instanceof Response)c=a.metadata.respondWith;else throw new t(`Invalid \`respondWith\` value: ${a.metadata.respondWith}`,{slug:n.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else c=new Response(null,{status:202});if(await O(a,i,s),l){let e=l.getReader(),t=await e.read();t.value&&(c=t.value),e.cancel()}if(!c)throw new t(`Workflow run did not send a response`,{slug:n.WEBHOOK_RESPONSE_NOT_SENT});return c}export{w as i,O as n,k as r,D as t};
@@ -1 +1 @@
1
- import{h as e}from"./dist-CrxV2rsR.js";import{C as t,D as n,E as r,O as i,S as a,T as o,g as s,h as c,l,p as u,r as d,s as f,t as p,w as m,x as h}from"./dist-B3qkUnLJ.js";import{$ as ee,Bt as g,D as _,H as v,Jt as y,N as b,P as x,Pn as S,U as C,W as w,_ as T,_n as E,a as D,et as O,fn as k,g as A,gn as j,k as M,n as N,nn as P,qt as te,r as F,rn as ne,rt as re,s as ie,t as ae,vn as I,w as L,yn as R}from"./attribute-changes-Dk1fP6vt.js";import{J as z,i as B,o as V,q as H,s as U}from"./dist-BX517Nmz.js";const W=new Set([`PARSE_ERROR`,`SCHEMA_VALIDATION`,i.WORLD_CONTRACT_ERROR]),G=new Set([`TRANSPORT`,`TIMEOUT`]),K=[r.is,c.is,h.is,u.is];function q(e){if(!n.is(e)||e.status!==void 0)return!1;let t=`cause`in e?e.cause:void 0;return e.code!==void 0&&W.has(e.code)||e.message.startsWith(`Failed to parse response body for `)||e.message.startsWith(`Schema validation failed for `)||typeof t==`object`&&!!t&&`name`in t&&t.name===`ZodError`}function J(e){return s.is(e)?!0:n.is(e)?e.status!==void 0&&e.status>=500?!0:e.code!==void 0&&G.has(e.code):!1}function oe(e){if(l.is(e))return i.REPLAY_DIVERGENCE;if(p.is(e))return i.CORRUPTED_EVENT_LOG;if(f.is(e))return i.MAX_EVENTS_EXCEEDED;if(q(e)||J(e))return i.WORLD_CONTRACT_ERROR;for(let t of K)if(t(e))return i.RUNTIME_ERROR;return i.USER_ERROR}const se=V();function ce(){let e=C.getStore(),t=e?.workflowMetadata?.workflowRunId;if(t)return{[z]:e.rootRunId??t,[H]:t}}let Y=!1;async function X(t,n,i){"use step";return await F(()=>{let a=t?.workflowId;if(!a)throw new r(`'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`,{slug:`start-invalid-workflow-function`});return O(`workflow.start ${e(a)}`,async e=>{e?.setAttributes({...te(a),...y(`start`)});let t=[],o=i??{};Array.isArray(n)?t=n:typeof n==`object`&&(o=n),e?.setAttributes({...g(t.length)});let s=o.world??await I();R(s);let c=await s.getDeploymentId(),l=o.deploymentId??c;l===`latest`&&(s.resolveLatestDeploymentId?l=await s.resolveLatestDeploymentId():(Y||(Y=!0,w.warn(`deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.`,{currentDeploymentId:c})),l=c));let u,f;if(l===c)u=!0,f=!0;else if(typeof s.streams?.get!=`function`)u=!1,f=!1;else{let e=T((await ie(s,`workflow`,{deploymentId:l,timeout:2e3,namespace:o.namespace}).catch(()=>void 0))?.workflowCoreVersion);u=e.framedByteStreams,f=e.supportedFormats.has(k.GZIP)}let p=[],m=`wrun_${s.createRunId?s.createRunId(o):se()}`,h=await ee(),_=o.specVersion??s.specVersion,v=U(_),b=o.allowReservedAttributes===!0,x;if(o.attributes&&Object.keys(o.attributes).length>0){if(_<4)throw new r(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(o.attributes))if(typeof t!=`string`)throw new r(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=ae(o.attributes,{allowReservedAttributes:b});x=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let C=_>=4?ce():void 0,E=C?{...C,...x}:x,O=E?{attributes:E,...b||C!=null?{allowReservedAttributes:!0}:{}}:{};if(o.replayedFromRunId!==void 0&&!B.safeParse(o.replayedFromRunId).success)throw new r(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(o.replayedFromRunId).slice(0,64))}.`);let j=await s.getEncryptionKeyForRun?.(m,{...o,deploymentId:l}),M=j?await S(j):void 0,F=await L(t,m,M,p,globalThis,v,u,f&&_>=5),z={traceCarrier:h,workflowCoreVersion:A,features:{encryption:!!M},...o.replayedFromRunId?{replayedFromRunId:o.replayedFromRunId}:{}},[V,H]=await Promise.allSettled([s.events.create(m,{eventType:`run_created`,specVersion:_,eventData:{deploymentId:l,workflowName:a,input:F,executionContext:z,...O}},{v1Compat:v}),s.queue(D(a,o.namespace),{runId:m,traceCarrier:h,..._>=3?{runInput:{input:F,deploymentId:l,workflowName:a,specVersion:_,executionContext:z,...O}}:{}},{deploymentId:l,specVersion:_,...o.region===void 0?{}:{region:o.region}})]);if(H.status===`rejected`)throw H.reason;let W=!1;if(V.status===`rejected`){let e=V.reason;if(!d.is(e))if(J(e))W=!0,w.warn(`Run creation event failed, but the run was accepted via the queue. The run_created event will be re-tried async by the runtime.`,{workflowRunId:m,error:e.message});else throw e}else{let e=V.value;if(!e.run)throw new r(`Missing 'run' in server response for 'run_created' event`);if(!v&&e.run.runId!==m)throw new r(`Server returned different runId than requested: expected ${m}, got ${e.run.runId}`)}return N(Promise.all(p),e=>{w.warn(`Background flush of workflow argument streams failed`,{workflowRunId:m,error:e instanceof Error?e.message:String(e)})}),e?.setAttributes({...P(m),...re(l),...V.status===`fulfilled`&&V.value.run?ne(V.value.run.status):{}}),new $(m,{resilientStart:W})})})}const Z=e=>Array.isArray(e)?e:[e];async function le(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await S(i):void 0,o=Z(await b(r.input,t,a,globalThis)),s=n.specVersion??r.specVersion??1,c=n.deploymentId??r.deploymentId;return(await X({workflowId:r.workflowName},o,{deploymentId:c,world:e,specVersion:s,replayedFromRunId:t,namespace:n.namespace})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function ue(e,t,n){try{let r=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,i=U(r),a={eventType:`run_cancelled`,specVersion:r,...n?.cancelReason===void 0?{}:{eventData:{cancelReason:n.cancelReason}}};await e.events.create(t,a,{v1Compat:i})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function de(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`});await e.queue(D(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1})}catch(e){throw Error(`Failed to re-enqueue run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Q(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`}),i=U(r.specVersion),a=[],o=null;do{let n=await e.events.list({runId:t,pagination:{limit:1e3,...o?{cursor:o}:{}},resolveData:`none`});a.push(...n.data),o=n.hasMore?n.cursor:null}while(o);let s=a.filter(e=>e.eventType===`wait_created`),c=new Set(a.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),l=s.filter(e=>!c.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);l=l.filter(t=>t.correlationId&&e.has(t.correlationId))}let u=[],f=0;for(let n of l){if(!n.correlationId)continue;let a=i?{eventType:`wait_completed`,correlationId:n.correlationId}:{eventType:`wait_completed`,correlationId:n.correlationId,specVersion:r.specVersion,eventData:{resumeAt:n.eventData.resumeAt}};try{await e.events.create(t,a,{v1Compat:i}),f++}catch(e){d.is(e)?f++:u.push(e instanceof Error?e:Error(String(e)))}}if(f>0&&await e.queue(D(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),u.length>0)throw AggregateError(u,`Failed to complete ${u.length}/${l.length} pending wait(s) for run ${t}`);return{stoppedCount:f}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function fe(e,t,n,r){try{return await e.streams.get(t,n,r?.startIndex)}catch(e){throw Error(`Failed to read stream ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function pe(e,t){try{return await e.streams.list(t)}catch(e){throw Error(`Failed to list streams for run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}var $=class e{static[E](e){return{runId:e.runId,resilientStart:e.#r}}static[j](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=I(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(){return this.#n||=(async()=>{let e=await this.#t,t=await e.runs.get(this.runId),n=await e.getEncryptionKeyForRun?.(t);return n?await S(n):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return Q(await this.#t,this.runId,e)}async cancel(e){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:5,...e?.cancelReason===void 0?{}:{eventData:{cancelReason:e.cancelReason}}})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(o.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.status))}get returnValue(){"use step";return this.#o()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.completedAt))}get readable(){return this.getReadable()}getReadable(e={}){"use step";let{ops:t=[],global:n=globalThis,startIndex:r,namespace:i}=e,a=v(this.runId,i),o=this.#a(),s=_(n,t,this.runId,o).ReadableStream({name:a,startIndex:r}),c=this.#t,l=this.runId;return Object.assign(s,{getTailIndex:async()=>(await(await c).streams.getInfo(l,a)).tailIndex})}async#o(){let e=await this.#t,n=0,r=this.#r?3:0,i=[1e3,3e3,6e3];for(;;)try{let n=await e.runs.get(this.runId);if(n.status===`completed`){let e=await this.#i();return await x(n.output,this.runId,e)}if(n.status===`cancelled`)throw new a(this.runId);if(n.status===`failed`){let e=await this.#i(),r;try{r=await M(n.error,this.runId,e)}catch{r=Error(`Failed to hydrate workflow run error`)}throw new t(this.runId,r,{errorCode:n.errorCode})}throw new m(this.runId,n.status)}catch(e){if(m.is(e)){await new Promise(e=>setTimeout(e,1e3));continue}if(o.is(e)&&n<r){let e=i[n];n++,await new Promise(t=>setTimeout(t,e));continue}throw e}}};function me(e){return new $(e)}export{fe as a,Q as c,J as d,q as f,pe as i,X as l,me as n,le as o,ue as r,de as s,$ as t,oe as u};
1
+ import{h as e}from"./dist-CrxV2rsR.js";import{C as t,D as n,E as r,O as i,S as a,T as o,g as s,h as c,l,p as u,r as d,s as f,t as p,w as m,x as h}from"./dist-B3qkUnLJ.js";import{$ as ee,Bt as g,D as _,H as v,Jt as y,N as b,P as x,Pn as S,U as C,W as w,_ as T,_n as E,a as D,et as O,fn as k,g as A,gn as j,k as M,n as N,nn as P,qt as te,r as F,rn as ne,rt as re,s as ie,t as ae,vn as I,w as L,yn as R}from"./attribute-changes-CB7nRYoY.js";import{J as z,i as B,o as V,q as H,s as U}from"./dist-BX517Nmz.js";const W=new Set([`PARSE_ERROR`,`SCHEMA_VALIDATION`,i.WORLD_CONTRACT_ERROR]),G=new Set([`TRANSPORT`,`TIMEOUT`]),K=[r.is,c.is,h.is,u.is];function q(e){if(!n.is(e)||e.status!==void 0)return!1;let t=`cause`in e?e.cause:void 0;return e.code!==void 0&&W.has(e.code)||e.message.startsWith(`Failed to parse response body for `)||e.message.startsWith(`Schema validation failed for `)||typeof t==`object`&&!!t&&`name`in t&&t.name===`ZodError`}function J(e){return s.is(e)?!0:n.is(e)?e.status!==void 0&&e.status>=500?!0:e.code!==void 0&&G.has(e.code):!1}function oe(e){if(l.is(e))return i.REPLAY_DIVERGENCE;if(p.is(e))return i.CORRUPTED_EVENT_LOG;if(f.is(e))return i.MAX_EVENTS_EXCEEDED;if(q(e)||J(e))return i.WORLD_CONTRACT_ERROR;for(let t of K)if(t(e))return i.RUNTIME_ERROR;return i.USER_ERROR}const se=V();function ce(){let e=C.getStore(),t=e?.workflowMetadata?.workflowRunId;if(t)return{[z]:e.rootRunId??t,[H]:t}}let Y=!1;async function X(t,n,i){"use step";return await F(()=>{let a=t?.workflowId;if(!a)throw new r(`'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`,{slug:`start-invalid-workflow-function`});return O(`workflow.start ${e(a)}`,async e=>{e?.setAttributes({...te(a),...y(`start`)});let t=[],o=i??{};Array.isArray(n)?t=n:typeof n==`object`&&(o=n),e?.setAttributes({...g(t.length)});let s=o.world??await I();R(s);let c=await s.getDeploymentId(),l=o.deploymentId??c;l===`latest`&&(s.resolveLatestDeploymentId?l=await s.resolveLatestDeploymentId():(Y||(Y=!0,w.warn(`deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.`,{currentDeploymentId:c})),l=c));let u,f;if(l===c)u=!0,f=!0;else if(typeof s.streams?.get!=`function`)u=!1,f=!1;else{let e=T((await ie(s,`workflow`,{deploymentId:l,timeout:2e3,namespace:o.namespace}).catch(()=>void 0))?.workflowCoreVersion);u=e.framedByteStreams,f=e.supportedFormats.has(k.GZIP)}let p=[],m=`wrun_${s.createRunId?s.createRunId(o):se()}`,h=await ee(),_=o.specVersion??s.specVersion,v=U(_),b=o.allowReservedAttributes===!0,x;if(o.attributes&&Object.keys(o.attributes).length>0){if(_<4)throw new r(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(o.attributes))if(typeof t!=`string`)throw new r(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=ae(o.attributes,{allowReservedAttributes:b});x=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let C=_>=4?ce():void 0,E=C?{...C,...x}:x,O=E?{attributes:E,...b||C!=null?{allowReservedAttributes:!0}:{}}:{};if(o.replayedFromRunId!==void 0&&!B.safeParse(o.replayedFromRunId).success)throw new r(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(o.replayedFromRunId).slice(0,64))}.`);let j=await s.getEncryptionKeyForRun?.(m,{...o,deploymentId:l}),M=j?await S(j):void 0,F=await L(t,m,M,p,globalThis,v,u,f&&_>=5),z={traceCarrier:h,workflowCoreVersion:A,features:{encryption:!!M},...o.replayedFromRunId?{replayedFromRunId:o.replayedFromRunId}:{}},[V,H]=await Promise.allSettled([s.events.create(m,{eventType:`run_created`,specVersion:_,eventData:{deploymentId:l,workflowName:a,input:F,executionContext:z,...O}},{v1Compat:v}),s.queue(D(a,o.namespace),{runId:m,traceCarrier:h,..._>=3?{runInput:{input:F,deploymentId:l,workflowName:a,specVersion:_,executionContext:z,...O}}:{}},{deploymentId:l,specVersion:_,...o.region===void 0?{}:{region:o.region}})]);if(H.status===`rejected`)throw H.reason;let W=!1;if(V.status===`rejected`){let e=V.reason;if(!d.is(e))if(J(e))W=!0,w.warn(`Run creation event failed, but the run was accepted via the queue. The run_created event will be re-tried async by the runtime.`,{workflowRunId:m,error:e.message});else throw e}else{let e=V.value;if(!e.run)throw new r(`Missing 'run' in server response for 'run_created' event`);if(!v&&e.run.runId!==m)throw new r(`Server returned different runId than requested: expected ${m}, got ${e.run.runId}`)}return N(Promise.all(p),e=>{w.warn(`Background flush of workflow argument streams failed`,{workflowRunId:m,error:e instanceof Error?e.message:String(e)})}),e?.setAttributes({...P(m),...re(l),...V.status===`fulfilled`&&V.value.run?ne(V.value.run.status):{}}),new $(m,{resilientStart:W})})})}const Z=e=>Array.isArray(e)?e:[e];async function le(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await S(i):void 0,o=Z(await b(r.input,t,a,globalThis)),s=n.specVersion??r.specVersion??1,c=n.deploymentId??r.deploymentId;return(await X({workflowId:r.workflowName},o,{deploymentId:c,world:e,specVersion:s,replayedFromRunId:t,namespace:n.namespace})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function ue(e,t,n){try{let r=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,i=U(r),a={eventType:`run_cancelled`,specVersion:r,...n?.cancelReason===void 0?{}:{eventData:{cancelReason:n.cancelReason}}};await e.events.create(t,a,{v1Compat:i})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function de(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`});await e.queue(D(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1})}catch(e){throw Error(`Failed to re-enqueue run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Q(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`}),i=U(r.specVersion),a=[],o=null;do{let n=await e.events.list({runId:t,pagination:{limit:1e3,...o?{cursor:o}:{}},resolveData:`none`});a.push(...n.data),o=n.hasMore?n.cursor:null}while(o);let s=a.filter(e=>e.eventType===`wait_created`),c=new Set(a.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),l=s.filter(e=>!c.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);l=l.filter(t=>t.correlationId&&e.has(t.correlationId))}let u=[],f=0;for(let n of l){if(!n.correlationId)continue;let a=i?{eventType:`wait_completed`,correlationId:n.correlationId}:{eventType:`wait_completed`,correlationId:n.correlationId,specVersion:r.specVersion,eventData:{resumeAt:n.eventData.resumeAt}};try{await e.events.create(t,a,{v1Compat:i}),f++}catch(e){d.is(e)?f++:u.push(e instanceof Error?e:Error(String(e)))}}if(f>0&&await e.queue(D(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),u.length>0)throw AggregateError(u,`Failed to complete ${u.length}/${l.length} pending wait(s) for run ${t}`);return{stoppedCount:f}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function fe(e,t,n,r){try{return await e.streams.get(t,n,r?.startIndex)}catch(e){throw Error(`Failed to read stream ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function pe(e,t){try{return await e.streams.list(t)}catch(e){throw Error(`Failed to list streams for run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}var $=class e{static[E](e){return{runId:e.runId,resilientStart:e.#r}}static[j](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=I(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(){return this.#n||=(async()=>{let e=await this.#t,t=await e.runs.get(this.runId),n=await e.getEncryptionKeyForRun?.(t);return n?await S(n):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return Q(await this.#t,this.runId,e)}async cancel(e){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:5,...e?.cancelReason===void 0?{}:{eventData:{cancelReason:e.cancelReason}}})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(o.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.status))}get returnValue(){"use step";return this.#o()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.completedAt))}get readable(){return this.getReadable()}getReadable(e={}){"use step";let{ops:t=[],global:n=globalThis,startIndex:r,namespace:i}=e,a=v(this.runId,i),o=this.#a(),s=_(n,t,this.runId,o).ReadableStream({name:a,startIndex:r}),c=this.#t,l=this.runId;return Object.assign(s,{getTailIndex:async()=>(await(await c).streams.getInfo(l,a)).tailIndex})}async#o(){let e=await this.#t,n=0,r=this.#r?3:0,i=[1e3,3e3,6e3];for(;;)try{let n=await e.runs.get(this.runId);if(n.status===`completed`){let e=await this.#i();return await x(n.output,this.runId,e)}if(n.status===`cancelled`)throw new a(this.runId);if(n.status===`failed`){let e=await this.#i(),r;try{r=await M(n.error,this.runId,e)}catch{r=Error(`Failed to hydrate workflow run error`)}throw new t(this.runId,r,{errorCode:n.errorCode})}throw new m(this.runId,n.status)}catch(e){if(m.is(e)){await new Promise(e=>setTimeout(e,1e3));continue}if(o.is(e)&&n<r){let e=i[n];n++,await new Promise(t=>setTimeout(t,e));continue}throw e}}};function me(e){return new $(e)}export{fe as a,Q as c,J as d,q as f,pe as i,X as l,me as n,le as o,ue as r,de as s,$ as t,oe as u};
@@ -1 +1 @@
1
- import{Ln as e,Mn as t}from"./attribute-changes-Dk1fP6vt.js";async function n(r){let i=globalThis[t];return i||e(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
1
+ import{Ln as e,Mn as t}from"./attribute-changes-CB7nRYoY.js";async function n(r){let i=globalThis[t];return i||e(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
@@ -0,0 +1,8 @@
1
+ import{i as e,n as t,o as n,t as r}from"./chunk-BTyA9uPd.js";var i=r(((e,t)=>{let n=[`nodebuffer`,`arraybuffer`,`fragments`],r=typeof Blob<`u`;r&&n.push(`blob`),t.exports={BINARY_TYPES:n,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,hasBlob:r,kForOnEventAttribute:Symbol(`kIsForOnEventAttribute`),kListener:Symbol(`kListener`),kStatusCode:Symbol(`status-code`),kWebSocket:Symbol(`websocket`),NOOP:()=>{}}})),a=r(((t,n)=>{var r=e(`fs`),i=e(`path`),a=e(`os`),o=typeof __webpack_require__==`function`?__non_webpack_require__:e,s=process.config&&process.config.variables||{},c=!!process.env.PREBUILDS_ONLY,l=process.versions.modules,u=O()?`electron`:D()?`node-webkit`:`node`,d=process.env.npm_config_arch||a.arch(),f=process.env.npm_config_platform||a.platform(),p=process.env.LIBC||(k(f)?`musl`:`glibc`),m=process.env.ARM_VERSION||(d===`arm64`?`8`:s.arm_version)||``,h=(process.versions.uv||``).split(`.`)[0];n.exports=g;function g(e){return o(g.resolve(e))}g.resolve=g.path=function(e){e=i.resolve(e||`.`);try{var t=o(i.join(e,`package.json`)).name.toUpperCase().replace(/-/g,`_`);process.env[t+`_PREBUILD`]&&(e=process.env[t+`_PREBUILD`])}catch{}if(!c){var n=v(i.join(e,`build/Release`),y);if(n)return n;var r=v(i.join(e,`build/Debug`),y);if(r)return r}var a=T(e);if(a)return a;var s=T(i.dirname(process.execPath));if(s)return s;var g=[`platform=`+f,`arch=`+d,`runtime=`+u,`abi=`+l,`uv=`+h,m?`armv=`+m:``,`libc=`+p,`node=`+process.versions.node,process.versions.electron?`electron=`+process.versions.electron:``,typeof __webpack_require__==`function`?`webpack=true`:``].filter(Boolean).join(` `);throw Error(`No native build was found for `+g+`
2
+ loaded from: `+e+`
3
+ `);function T(e){var t=_(i.join(e,`prebuilds`)).map(b).filter(x(f,d)).sort(S)[0];if(t){var n=i.join(e,`prebuilds`,t.name),r=_(n).map(C).filter(w(u,l)).sort(E(u))[0];if(r)return i.join(n,r.file)}}};function _(e){try{return r.readdirSync(e)}catch{return[]}}function v(e,t){var n=_(e).filter(t);return n[0]&&i.join(e,n[0])}function y(e){return/\.node$/.test(e)}function b(e){var t=e.split(`-`);if(t.length===2){var n=t[0],r=t[1].split(`+`);if(n&&r.length&&r.every(Boolean))return{name:e,platform:n,architectures:r}}}function x(e,t){return function(n){return n==null||n.platform!==e?!1:n.architectures.includes(t)}}function S(e,t){return e.architectures.length-t.architectures.length}function C(e){var t=e.split(`.`),n=t.pop(),r={file:e,specificity:0};if(n===`node`){for(var i=0;i<t.length;i++){var a=t[i];if(a===`node`||a===`electron`||a===`node-webkit`)r.runtime=a;else if(a===`napi`)r.napi=!0;else if(a.slice(0,3)===`abi`)r.abi=a.slice(3);else if(a.slice(0,2)===`uv`)r.uv=a.slice(2);else if(a.slice(0,4)===`armv`)r.armv=a.slice(4);else if(a===`glibc`||a===`musl`)r.libc=a;else continue;r.specificity++}return r}}function w(e,t){return function(n){return!(n==null||n.runtime&&n.runtime!==e&&!T(n)||n.abi&&n.abi!==t&&!n.napi||n.uv&&n.uv!==h||n.armv&&n.armv!==m||n.libc&&n.libc!==p)}}function T(e){return e.runtime===`node`&&e.napi}function E(e){return function(t,n){return t.runtime===n.runtime?t.abi===n.abi?t.specificity===n.specificity?0:t.specificity>n.specificity?-1:1:t.abi?-1:1:t.runtime===e?-1:1}}function D(){return!!(process.versions&&process.versions.nw)}function O(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window<`u`&&window.process&&window.process.type===`renderer`}function k(e){return e===`linux`&&r.existsSync(`/etc/alpine-release`)}g.parseTags=C,g.matchTags=w,g.compareTags=E,g.parseTuple=b,g.matchTuple=x,g.compareTuples=S})),o=r(((t,n)=>{let r=typeof __webpack_require__==`function`?__non_webpack_require__:e;typeof r.addon==`function`?n.exports=r.addon.bind(r):n.exports=a()})),s=r(((e,t)=>{t.exports={mask:(e,t,n,r,i)=>{for(var a=0;a<i;a++)n[r+a]=e[a]^t[a&3]},unmask:(e,t)=>{let n=e.length;for(var r=0;r<n;r++)e[r]^=t[r&3]}}})),c=r(((e,t)=>{try{t.exports=o()(__dirname)}catch{t.exports=s()}})),l=r(((e,t)=>{let{EMPTY_BUFFER:n}=i(),r=Buffer[Symbol.species];function a(e,t){if(e.length===0)return n;if(e.length===1)return e[0];let i=Buffer.allocUnsafe(t),a=0;for(let t=0;t<e.length;t++){let n=e[t];i.set(n,a),a+=n.length}return a<t?new r(i.buffer,i.byteOffset,a):i}function o(e,t,n,r,i){for(let a=0;a<i;a++)n[r+a]=e[a]^t[a&3]}function s(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function l(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function u(e){if(u.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new r(e):ArrayBuffer.isView(e)?t=new r(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),u.readOnly=!1),t}if(t.exports={concat:a,mask:o,toArrayBuffer:l,toBuffer:u,unmask:s},!process.env.WS_NO_BUFFER_UTIL)try{let e=c();t.exports.mask=function(t,n,r,i,a){a<48?o(t,n,r,i,a):e.mask(t,n,r,i,a)},t.exports.unmask=function(t,n){t.length<32?s(t,n):e.unmask(t,n)}}catch{}})),u=r(((e,t)=>{let n=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}})),d=r(((t,n)=>{let r=e(`zlib`),a=l(),o=u(),{kStatusCode:s}=i(),c=Buffer[Symbol.species],d=Buffer.from([0,0,255,255]),f=Symbol(`permessage-deflate`),p=Symbol(`total-length`),m=Symbol(`callback`),h=Symbol(`buffers`),g=Symbol(`error`),_;n.exports=class{constructor(e){this._options=e||{},this._threshold=this._options.threshold===void 0?1024:this._options.threshold,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,_||=new o(this._options.concurrencyLimit===void 0?10:this._options.concurrencyLimit)}static get extensionName(){return`permessage-deflate`}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits??(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&=(this._inflate.close(),null),this._deflate){let e=this._deflate[m];this._deflate.close(),this._deflate=null,e&&e(Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){let t=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==`number`&&!e.client_max_window_bits));if(!n)throw Error(`None of the extension offers can be accepted`);return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw Error(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error(`Unexpected or invalid parameter "client_max_window_bits"`);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else if(t===`server_max_window_bits`){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){_.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){_.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,n){let i=this._isServer?`client`:`server`;if(!this._inflate){let e=`${i}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:r.Z_DEFAULT_WINDOWBITS;this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[f]=this,this._inflate[p]=0,this._inflate[h]=[],this._inflate.on(`error`,b),this._inflate.on(`data`,y)}this._inflate[m]=n,this._inflate.write(e),t&&this._inflate.write(d),this._inflate.flush(()=>{let e=this._inflate[g];if(e){this._inflate.close(),this._inflate=null,n(e);return}let r=a.concat(this._inflate[h],this._inflate[p]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[p]=0,this._inflate[h]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),n(null,r)})}_compress(e,t,n){let i=this._isServer?`server`:`client`;if(!this._deflate){let e=`${i}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:r.Z_DEFAULT_WINDOWBITS;this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[p]=0,this._deflate[h]=[],this._deflate.on(`data`,v)}this._deflate[m]=n,this._deflate.write(e),this._deflate.flush(r.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=a.concat(this._deflate[h],this._deflate[p]);t&&(e=new c(e.buffer,e.byteOffset,e.length-4)),this._deflate[m]=null,this._deflate[p]=0,this._deflate[h]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,e)})}};function v(e){this[h].push(e),this[p]+=e.length}function y(e){if(this[p]+=e.length,this[f]._maxPayload<1||this[p]<=this[f]._maxPayload){this[h].push(e);return}this[g]=RangeError(`Max payload size exceeded`),this[g].code=`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`,this[g][s]=1009,this.removeListener(`data`,y),this.reset()}function b(e){if(this[f]._inflate=null,this[g]){this[m](this[g]);return}e[s]=1007,this[m](e)}})),f=r(((t,n)=>{let{isUtf8:r}=e(`buffer`),{hasBlob:a}=i(),o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function s(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function c(e){let t=e.length,n=0;for(;n<t;)if(!(e[n]&128))n++;else if((e[n]&224)==192){if(n+1===t||(e[n+1]&192)!=128||(e[n]&254)==192)return!1;n+=2}else if((e[n]&240)==224){if(n+2>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||e[n]===224&&(e[n+1]&224)==128||e[n]===237&&(e[n+1]&224)==160)return!1;n+=3}else if((e[n]&248)==240){if(n+3>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||(e[n+3]&192)!=128||e[n]===240&&(e[n+1]&240)==128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function l(e){return a&&typeof e==`object`&&typeof e.arrayBuffer==`function`&&typeof e.type==`string`&&typeof e.stream==`function`&&(e[Symbol.toStringTag]===`Blob`||e[Symbol.toStringTag]===`File`)}if(n.exports={isBlob:l,isValidStatusCode:s,isValidUTF8:c,tokenChars:o},r)n.exports.isValidUTF8=function(e){return e.length<24?c(e):r(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=e(`utf-8-validate`);n.exports.isValidUTF8=function(e){return e.length<32?c(e):t(e)}}catch{}})),p=r(((t,n)=>{let{Writable:r}=e(`stream`),a=d(),{BINARY_TYPES:o,EMPTY_BUFFER:s,kStatusCode:c,kWebSocket:u}=i(),{concat:p,toArrayBuffer:m,unmask:h}=l(),{isValidStatusCode:g,isValidUTF8:_}=f(),v=Buffer[Symbol.species];n.exports=class extends r{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents===void 0?!0:e.allowSynchronousEvents,this._binaryType=e.binaryType||o[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[u]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(this._opcode===8&&this._state==0)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,`Too many buffered chunks`,!1,1008,`WS_ERR_TOO_MANY_BUFFERED_PARTS`));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new v(t.buffer,t.byteOffset+e,t.length-e),new v(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new v(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){e(this.createError(RangeError,`RSV2 and RSV3 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_2_3`));return}let n=(t[0]&64)==64;if(n&&!this._extensions[a.extensionName]){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._fin=(t[0]&128)==128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(!this._fragmented){e(this.createError(RangeError,`invalid opcode 0`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){e(this.createError(RangeError,`FIN must be set`,!0,1002,`WS_ERR_EXPECTED_FIN`));return}if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`));return}}else{e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)==128,this._isServer){if(!this._masked){e(this.createError(RangeError,`MASK must be set`,!0,1002,`WS_ERR_EXPECTED_MASK`));return}}else if(this._masked){e(this.createError(RangeError,`MASK must be clear`,!0,1002,`WS_ERR_UNEXPECTED_MASK`));return}this._payloadLength===126?this._state=1:this._payloadLength===127?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>2**21-1){e(this.createError(RangeError,`Unsupported WebSocket frame: payload length > 2^53 - 1`,!1,1009,`WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH`));return}this._payloadLength=n*2**32+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=s;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&h(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){e(this.createError(RangeError,`Too many message fragments`,!1,1008,`WS_ERR_TOO_MANY_BUFFERED_PARTS`));return}if(this._compressed){this._state=5,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[a.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){t(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._fragments.push(n)}this.dataMessage(t),this._state===0&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let r;r=this._binaryType===`nodebuffer`?p(n,t):this._binaryType===`arraybuffer`?m(p(n,t)):this._binaryType===`blob`?new Blob(n):n,this._allowSynchronousEvents?(this.emit(`message`,r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!0),this._state=0,this.startLoop(e)}))}else{let r=p(n,t);if(!this._skipUTF8Validation&&!_(r)){e(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._state===5||this._allowSynchronousEvents?(this.emit(`message`,r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit(`conclude`,1005,s),this.end();else{let n=e.readUInt16BE(0);if(!g(n)){t(this.createError(RangeError,`invalid status code ${n}`,!0,1002,`WS_ERR_INVALID_CLOSE_CODE`));return}let r=new v(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!_(r)){t(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._loop=!1,this.emit(`conclude`,n,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0,this.startLoop(t)}))}createError(e,t,n,r,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[c]=r,a}}})),m=r(((t,n)=>{let{Duplex:r}=e(`stream`),{randomFillSync:a}=e(`crypto`),{types:{isUint8Array:o}}=e(`util`),s=d(),{EMPTY_BUFFER:c,kWebSocket:u,NOOP:p}=i(),{isBlob:m,isValidStatusCode:h}=f(),{mask:g,toBuffer:_}=l(),v=Symbol(`kByteLength`),y=Buffer.alloc(4),b=8*1024,x,S=b;n.exports=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=p,this[u]=void 0}static frame(e,t){let n,r=!1,i=2,o=!1;t.mask&&(n=t.maskBuffer||y,t.generateMask?t.generateMask(n):(S===b&&(x===void 0&&(x=Buffer.alloc(b)),a(x,0,b),S=0),n[0]=x[S++],n[1]=x[S++],n[2]=x[S++],n[3]=x[S++]),o=(n[0]|n[1]|n[2]|n[3])===0,i=6);let s;typeof e==`string`?(!t.mask||o)&&t[v]!==void 0?s=t[v]:(e=Buffer.from(e),s=e.length):(s=e.length,r=t.mask&&t.readOnly&&!o);let c=s;s>=65536?(i+=8,c=127):s>125&&(i+=2,c=126);let l=Buffer.allocUnsafe(r?s+i:i);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(s,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),!t.mask||(l[1]|=128,l[i-4]=n[0],l[i-3]=n[1],l[i-2]=n[2],l[i-1]=n[3],o)?[l,e]:r?(g(e,n,l,i,s),[l]):(g(e,n,e,0,s),[l,e])}close(t,n,r,i){let a;if(t===void 0)a=c;else if(typeof t!=`number`||!h(t))throw TypeError(`First argument must be a valid error code number`);else if(n===void 0||!n.length)a=Buffer.allocUnsafe(2),a.writeUInt16BE(t,0);else{let e=Buffer.byteLength(n);if(e>123)throw RangeError(`The message must not be greater than 123 bytes`);if(a=Buffer.allocUnsafe(2+e),a.writeUInt16BE(t,0),typeof n==`string`)a.write(n,2);else if(o(n))a.set(n,2);else throw TypeError(`Second argument must be a string or a Uint8Array`)}let s={[v]:a.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state===0?this.sendFrame(e.frame(a,s),i):this.enqueue([this.dispatch,a,!1,s,i])}ping(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):m(t)?(i=t.size,a=!1):(t=_(t),i=t.length,a=_.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[v]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};m(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}pong(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):m(t)?(i=t.size,a=!1):(t=_(t),i=t.length,a=_.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[v]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};m(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}send(e,t,n){let r=this._extensions[s.extensionName],i=t.binary?2:1,a=t.compress,o,c;typeof e==`string`?(o=Buffer.byteLength(e),c=!1):m(e)?(o=e.size,c=!1):(e=_(e),o=e.length,c=_.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?`server_no_context_takeover`:`client_no_context_takeover`]&&(a=o>=r._threshold),this._compress=a):(a=!1,i=0),t.fin&&(this._firstFragment=!0);let l={[v]:o,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:a};m(e)?this._state===0?this.getBlobData(e,this._compress,l,n):this.enqueue([this.getBlobData,e,this._compress,l,n]):this._state===0?this.dispatch(e,this._compress,l,n):this.enqueue([this.dispatch,e,this._compress,l,n])}getBlobData(t,n,r,i){this._bufferedBytes+=r[v],this._state=2,t.arrayBuffer().then(t=>{if(this._socket.destroyed){let e=Error(`The socket was closed while the blob was being read`);process.nextTick(C,this,e,i);return}this._bufferedBytes-=r[v];let a=_(t);n?this.dispatch(a,n,r,i):(this._state=0,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(e=>{process.nextTick(w,this,e,i)})}dispatch(t,n,r,i){if(!n){this.sendFrame(e.frame(t,r),i);return}let a=this._extensions[s.extensionName];this._bufferedBytes+=r[v],this._state=1,a.compress(t,r.fin,(t,n)=>{if(this._socket.destroyed){let e=Error(`The socket was closed while data was being compressed`);C(this,e,i);return}this._bufferedBytes-=r[v],this._state=0,r.readOnly=!1,this.sendFrame(e.frame(n,r),i),this.dequeue()})}dequeue(){for(;this._state===0&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][v],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][v],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};function C(e,t,n){typeof n==`function`&&n(t);for(let n=0;n<e._queue.length;n++){let r=e._queue[n],i=r[r.length-1];typeof i==`function`&&i(t)}}function w(e,t,n){C(e,t,n),e.onerror(t)}})),h=r(((e,t)=>{let{kForOnEventAttribute:n,kListener:r}=i(),a=Symbol(`kCode`),o=Symbol(`kData`),s=Symbol(`kError`),c=Symbol(`kMessage`),l=Symbol(`kReason`),u=Symbol(`kTarget`),d=Symbol(`kType`),f=Symbol(`kWasClean`);var p=class{constructor(e){this[u]=null,this[d]=e}get target(){return this[u]}get type(){return this[d]}};Object.defineProperty(p.prototype,"target",{enumerable:!0}),Object.defineProperty(p.prototype,"type",{enumerable:!0});var m=class extends p{constructor(e,t={}){super(e),this[a]=t.code===void 0?0:t.code,this[l]=t.reason===void 0?``:t.reason,this[f]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[a]}get reason(){return this[l]}get wasClean(){return this[f]}};Object.defineProperty(m.prototype,"code",{enumerable:!0}),Object.defineProperty(m.prototype,"reason",{enumerable:!0}),Object.defineProperty(m.prototype,"wasClean",{enumerable:!0});var h=class extends p{constructor(e,t={}){super(e),this[s]=t.error===void 0?null:t.error,this[c]=t.message===void 0?``:t.message}get error(){return this[s]}get message(){return this[c]}};Object.defineProperty(h.prototype,"error",{enumerable:!0}),Object.defineProperty(h.prototype,"message",{enumerable:!0});var g=class extends p{constructor(e,t={}){super(e),this[o]=t.data===void 0?null:t.data}get data(){return this[o]}};Object.defineProperty(g.prototype,"data",{enumerable:!0}),t.exports={CloseEvent:m,ErrorEvent:h,Event:p,EventTarget:{addEventListener(e,t,i={}){for(let a of this.listeners(e))if(!i[n]&&a[r]===t&&!a[n])return;let a;if(e===`message`)a=function(e,n){let r=new g(`message`,{data:n?e:e.toString()});r[u]=this,_(t,this,r)};else if(e===`close`)a=function(e,n){let r=new m(`close`,{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[u]=this,_(t,this,r)};else if(e===`error`)a=function(e){let n=new h(`error`,{error:e,message:e.message});n[u]=this,_(t,this,n)};else if(e===`open`)a=function(){let e=new p(`open`);e[u]=this,_(t,this,e)};else return;a[n]=!!i[n],a[r]=t,i.once?this.once(e,a):this.on(e,a)},removeEventListener(e,t){for(let i of this.listeners(e))if(i[r]===t&&!i[n]){this.removeListener(e,i);break}}},MessageEvent:g};function _(e,t,n){typeof e==`object`&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}})),g=r(((e,t)=>{let{tokenChars:n}=f();function r(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function i(e){let t=Object.create(null),i=Object.create(null),a=!1,o=!1,s=!1,c,l,u=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),c===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(p!==0&&(d===32||d===9))f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);d===44?(r(t,n,i),i=Object.create(null)):c=n,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);else if(l===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(d===32||d===9)f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),r(i,e.slice(u,f),!0),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),u=f=-1}else if(d===61&&u!==-1&&f===-1)l=e.slice(u,p),u=f=-1;else throw SyntaxError(`Unexpected character at index ${p}`);else if(o){if(n[d]!==1)throw SyntaxError(`Unexpected character at index ${p}`);u===-1?u=p:a||=!0,o=!1}else if(s)if(n[d]===1)u===-1&&(u=p);else if(d===34&&u!==-1)s=!1,f=p;else if(d===92)o=!0;else throw SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&n[d]===1)u===-1&&(u=p);else if(u!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);a&&=(n=n.replace(/\\/g,``),!1),r(i,l,n),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),l=void 0,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);if(u===-1||s||d===32||d===9)throw SyntaxError(`Unexpected end of input`);f===-1&&(f=p);let m=e.slice(u,f);return c===void 0?r(t,m,i):(l===void 0?r(i,m,!0):a?r(i,l,m.replace(/\\/g,``)):r(i,l,m),r(t,c,i)),t}function a(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>e===!0?t:`${t}=${e}`).join(`; `)})).join(`; `)).join(`, `)}).join(`, `)}t.exports={format:a,parse:i}})),_=r(((t,n)=>{let r=e(`events`),a=e(`https`),o=e(`http`),s=e(`net`),c=e(`tls`),{randomBytes:u,createHash:_}=e(`crypto`),{Duplex:v,Readable:y}=e(`stream`),{URL:b}=e(`url`),x=d(),S=p(),C=m(),{isBlob:w}=f(),{BINARY_TYPES:T,CLOSE_TIMEOUT:E,EMPTY_BUFFER:D,GUID:O,kForOnEventAttribute:k,kListener:A,kStatusCode:j,kWebSocket:M,NOOP:N}=i(),{EventTarget:{addEventListener:P,removeEventListener:ee}}=h(),{format:te,parse:ne}=g(),{toBuffer:F}=l(),I=Symbol(`kAborted`),L=[8,13],R=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],z=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;var B=class e extends r{constructor(t,n,r){super(),this._binaryType=T[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=D,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol=``,this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t===null?(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0):(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n==`object`&&n?(r=n,n=[]):n=[n]),V(this,t,n,r))}get binaryType(){return this._binaryType}set binaryType(e){T.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new S({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),a=new C(t,this._extensions,r.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[M]=this,a[M]=this,t[M]=this,i.on(`conclude`,re),i.on(`drain`,ie),i.on(`error`,ae),i.on(`message`,oe),i.on(`ping`,se),i.on(`pong`,ce),a.onerror=le,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,X),t.on(`data`,Z),t.on(`end`,Q),t.on(`error`,$),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[x.extensionName]&&this._extensions[x.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){G(this,this._req,`WebSocket was closed before the connection was established`);return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Y(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){K(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||D,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){K(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||D,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof n==`function`&&(r=n,n={}),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){K(this,t,r);return}let i={binary:typeof t!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[x.extensionName]||(i.compress=!1),this._sender.send(t||D,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){G(this,this._req,`WebSocket was closed before the connection was established`);return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(B,"CONNECTING",{enumerable:!0,value:R.indexOf(`CONNECTING`)}),Object.defineProperty(B.prototype,"CONNECTING",{enumerable:!0,value:R.indexOf(`CONNECTING`)}),Object.defineProperty(B,"OPEN",{enumerable:!0,value:R.indexOf(`OPEN`)}),Object.defineProperty(B.prototype,"OPEN",{enumerable:!0,value:R.indexOf(`OPEN`)}),Object.defineProperty(B,"CLOSING",{enumerable:!0,value:R.indexOf(`CLOSING`)}),Object.defineProperty(B.prototype,"CLOSING",{enumerable:!0,value:R.indexOf(`CLOSING`)}),Object.defineProperty(B,"CLOSED",{enumerable:!0,value:R.indexOf(`CLOSED`)}),Object.defineProperty(B.prototype,"CLOSED",{enumerable:!0,value:R.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`isPaused`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(B.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(B.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[k])return t[A];return null},set(t){for(let t of this.listeners(e))if(t[k]){this.removeListener(e,t);break}typeof t==`function`&&this.addEventListener(e,t,{[k]:!0})}})}),B.prototype.addEventListener=P,B.prototype.removeEventListener=ee,n.exports=B;function V(e,t,n,r){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:E,protocolVersion:L[1],maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:`GET`,host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,e._closeTimeout=i.closeTimeout,!L.includes(i.protocolVersion))throw RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${L.join(`, `)})`);let s;if(t instanceof b)s=t;else try{s=new b(t)}catch{throw SyntaxError(`Invalid URL: ${t}`)}s.protocol===`http:`?s.protocol=`ws:`:s.protocol===`https:`&&(s.protocol=`wss:`),e._url=s.href;let c=s.protocol===`wss:`,l=s.protocol===`ws+unix:`,d;if(s.protocol!==`ws:`&&!c&&!l?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!s.pathname?d=`The URL's pathname is empty`:s.hash&&(d=`The URL contains a fragment identifier`),d){let t=SyntaxError(d);if(e._redirects===0)throw t;H(e,t);return}let f=c?443:80,p=u(16).toString(`base64`),m=c?a.request:o.request,h=new Set,g;if(i.createConnection=i.createConnection||(c?W:U),i.defaultPort=i.defaultPort||f,i.port=s.port||f,i.host=s.hostname.startsWith(`[`)?s.hostname.slice(1,-1):s.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":p,Connection:`Upgrade`,Upgrade:`websocket`},i.path=s.pathname+s.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(g=new x({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers[`Sec-WebSocket-Extensions`]=te({[x.extensionName]:g.offer()})),n.length){for(let e of n){if(typeof e!=`string`||!z.test(e)||h.has(e))throw SyntaxError(`An invalid or duplicated subprotocol was specified`);h.add(e)}i.headers[`Sec-WebSocket-Protocol`]=n.join(`,`)}if(i.origin&&(i.protocolVersion<13?i.headers[`Sec-WebSocket-Origin`]=i.origin:i.headers.Origin=i.origin),(s.username||s.password)&&(i.auth=`${s.username}:${s.password}`),l){let e=i.path.split(`:`);i.socketPath=e[0],i.path=e[1]}let v;if(i.followRedirects){if(e._redirects===0){e._originalIpc=l,e._originalSecure=c,e._originalHostOrSocketPath=l?i.socketPath:s.host;let t=r&&r.headers;if(r={...r,headers:{}},t)for(let[e,n]of Object.entries(t))r.headers[e.toLowerCase()]=n}else if(e.listenerCount(`redirect`)===0){let t=l?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!c)&&(delete i.headers.authorization,delete i.headers.cookie,t||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization=`Basic `+Buffer.from(i.auth).toString(`base64`)),v=e._req=m(i),e._redirects&&e.emit(`redirect`,e.url,v)}else v=e._req=m(i);i.timeout&&v.on(`timeout`,()=>{G(e,v,`Opening handshake has timed out`)}),v.on(`error`,t=>{v===null||v[I]||(v=e._req=null,H(e,t))}),v.on(`response`,a=>{let o=a.headers.location,s=a.statusCode;if(o&&i.followRedirects&&s>=300&&s<400){if(++e._redirects>i.maxRedirects){G(e,v,`Maximum redirects exceeded`);return}v.abort();let a;try{a=new b(o,t)}catch{H(e,SyntaxError(`Invalid URL: ${o}`));return}V(e,a,n,r)}else e.emit(`unexpected-response`,v,a)||G(e,v,`Unexpected server response: ${a.statusCode}`)}),v.on(`upgrade`,(t,n,r)=>{if(e.emit(`upgrade`,t),e.readyState!==B.CONNECTING)return;v=e._req=null;let a=t.headers.upgrade;if(a===void 0||a.toLowerCase()!==`websocket`){G(e,n,`Invalid Upgrade header`);return}let o=_(`sha1`).update(p+O).digest(`base64`);if(t.headers[`sec-websocket-accept`]!==o){G(e,n,`Invalid Sec-WebSocket-Accept header`);return}let s=t.headers[`sec-websocket-protocol`],c;if(s===void 0?h.size&&(c=`Server sent no subprotocol`):h.size?h.has(s)||(c=`Server sent an invalid subprotocol`):c=`Server sent a subprotocol but none was requested`,c){G(e,n,c);return}s&&(e._protocol=s);let l=t.headers[`sec-websocket-extensions`];if(l!==void 0){if(!g){G(e,n,`Server sent a Sec-WebSocket-Extensions header but no extension was requested`);return}let t;try{t=ne(l)}catch{G(e,n,`Invalid Sec-WebSocket-Extensions header`);return}let r=Object.keys(t);if(r.length!==1||r[0]!==x.extensionName){G(e,n,`Server indicated an extension that was not requested`);return}try{g.accept(t[x.extensionName])}catch{G(e,n,`Invalid Sec-WebSocket-Extensions header`);return}e._extensions[x.extensionName]=g}e.setSocket(n,r,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(v,e):v.end()}function H(e,t){e._readyState=B.CLOSING,e._errorEmitted=!0,e.emit(`error`,t),e.emitClose()}function U(e){return e.path=e.socketPath,s.connect(e)}function W(e){return e.path=void 0,!e.servername&&e.servername!==``&&(e.servername=s.isIP(e.host)?``:e.host),c.connect(e)}function G(e,t,n){e._readyState=B.CLOSING;let r=Error(n);Error.captureStackTrace(r,G),t.setHeader?(t[I]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(H,e,r)):(t.destroy(r),t.once(`error`,e.emit.bind(e,`error`)),t.once(`close`,e.emitClose.bind(e)))}function K(e,t,n){if(t){let n=w(t)?t.size:F(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${R[e.readyState]})`);process.nextTick(n,t)}}function re(e,t){let n=this[M];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[M]!==void 0&&(n._socket.removeListener(`data`,Z),process.nextTick(J,n._socket),e===1005?n.close():n.close(e,t))}function ie(){let e=this[M];e.isPaused||e._socket.resume()}function ae(e){let t=this[M];t._socket[M]!==void 0&&(t._socket.removeListener(`data`,Z),process.nextTick(J,t._socket),t.close(e[j])),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e))}function q(){this[M].emitClose()}function oe(e,t){this[M].emit(`message`,e,t)}function se(e){let t=this[M];t._autoPong&&t.pong(e,!this._isServer,N),t.emit(`ping`,e)}function ce(e){this[M].emit(`pong`,e)}function J(e){e.resume()}function le(e){let t=this[M];t.readyState!==B.CLOSED&&(t.readyState===B.OPEN&&(t._readyState=B.CLOSING,Y(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e)))}function Y(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function X(){let e=this[M];if(this.removeListener(`close`,X),this.removeListener(`data`,Z),this.removeListener(`end`,Q),e._readyState=B.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[M]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on(`error`,q),e._receiver.on(`finish`,q))}function Z(e){this[M]._receiver.write(e)||this.pause()}function Q(){let e=this[M];e._readyState=B.CLOSING,e._receiver.end(),this.end()}function $(){let e=this[M];this.removeListener(`error`,$),this.on(`error`,N),e&&(e._readyState=B.CLOSING,this.destroy())}})),v=r(((t,n)=>{_();let{Duplex:r}=e(`stream`);function i(e){e.emit(`close`)}function a(){!this.destroyed&&this._writableState.finished&&this.destroy()}function o(e){this.removeListener(`error`,o),this.destroy(),this.listenerCount(`error`)===0&&this.emit(`error`,e)}function s(e,t){let n=!0,s=new r({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on(`message`,function(t,n){let r=!n&&s._readableState.objectMode?t.toString():t;s.push(r)||e.pause()}),e.once(`error`,function(e){s.destroyed||(n=!1,s.destroy(e))}),e.once(`close`,function(){s.destroyed||s.push(null)}),s._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t),process.nextTick(i,s);return}let a=!1;e.once(`error`,function(e){a=!0,r(e)}),e.once(`close`,function(){a||r(t),process.nextTick(i,s)}),n&&e.terminate()},s._final=function(t){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._final(t)});return}e._socket!==null&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once(`finish`,function(){t()}),e.close()))},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,r){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._write(t,n,r)});return}e.send(t,r)},s.on(`end`,a),s.on(`error`,o),s}n.exports=s})),y=r(((e,t)=>{let{tokenChars:n}=f();function r(e){let t=new Set,r=-1,i=-1,a=0;for(;a<e.length;a++){let o=e.charCodeAt(a);if(i===-1&&n[o]===1)r===-1&&(r=a);else if(a!==0&&(o===32||o===9))i===-1&&r!==-1&&(i=a);else if(o===44){if(r===-1)throw SyntaxError(`Unexpected character at index ${a}`);i===-1&&(i=a);let n=e.slice(r,i);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),r=i=-1}else throw SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||i!==-1)throw SyntaxError(`Unexpected end of input`);let o=e.slice(r,a);if(t.has(o))throw SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}t.exports={parse:r}})),b=r(((t,n)=>{let r=e(`events`),a=e(`http`),{Duplex:o}=e(`stream`),{createHash:s}=e(`crypto`),c=g(),l=d(),u=y(),f=_(),{CLOSE_TIMEOUT:p,GUID:m,kWebSocket:h}=i(),v=/^[+/0-9A-Za-z]{22}==$/;n.exports=class extends r{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:p,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:f,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError(`One and only one of the "port", "server", or "noServer" options must be specified`);if(e.port==null?e.server&&(this._server=e.server):(this._server=a.createServer((e,t)=>{let n=a.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":`text/plain`}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)),this._server){let e=this.emit.bind(this,`connection`);this._removeListeners=b(this._server,{listening:this.emit.bind(this,`listening`),error:this.emit.bind(this,`error`),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error(`The server is operating in "noServer" mode`);return this._server?this._server.address():null}close(e){if(this._state===2){e&&this.once(`close`,()=>{e(Error(`The server is not running`))}),process.nextTick(x,this);return}if(e&&this.once(`close`,e),this._state!==1)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(x,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{x(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf(`?`);if((t===-1?e.url:e.url.slice(0,t))!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,r){t.on(`error`,S);let i=e.headers[`sec-websocket-key`],a=e.headers.upgrade,o=+e.headers[`sec-websocket-version`];if(e.method!==`GET`){w(this,e,t,405,`Invalid HTTP method`);return}if(a===void 0||a.toLowerCase()!==`websocket`){w(this,e,t,400,`Invalid Upgrade header`);return}if(i===void 0||!v.test(i)){w(this,e,t,400,`Missing or invalid Sec-WebSocket-Key header`);return}if(o!==13&&o!==8){w(this,e,t,400,`Missing or invalid Sec-WebSocket-Version header`,{"Sec-WebSocket-Version":`13, 8`});return}if(!this.shouldHandle(e)){C(t,400);return}let s=e.headers[`sec-websocket-protocol`],d=new Set;if(s!==void 0)try{d=u.parse(s)}catch{w(this,e,t,400,`Invalid Sec-WebSocket-Protocol header`);return}let f=e.headers[`sec-websocket-extensions`],p={};if(this.options.perMessageDeflate&&f!==void 0){let n=new l({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let e=c.parse(f);e[l.extensionName]&&(n.accept(e[l.extensionName]),p[l.extensionName]=n)}catch{w(this,e,t,400,`Invalid or unacceptable Sec-WebSocket-Extensions header`);return}}if(this.options.verifyClient){let a={origin:e.headers[`${o===8?`sec-websocket-origin`:`origin`}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(a,(a,o,s,c)=>{if(!a)return C(t,o||401,s,c);this.completeUpgrade(p,i,d,e,t,n,r)});return}if(!this.options.verifyClient(a))return C(t,401)}this.completeUpgrade(p,i,d,e,t,n,r)}completeUpgrade(e,t,n,r,i,a,o){if(!i.readable||!i.writable)return i.destroy();if(i[h])throw Error(`server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration`);if(this._state>0)return C(i,503);let u=[`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${s(`sha1`).update(t+m).digest(`base64`)}`],d=new this.options.WebSocket(null,void 0,this.options);if(n.size){let e=this.options.handleProtocols?this.options.handleProtocols(n,r):n.values().next().value;e&&(u.push(`Sec-WebSocket-Protocol: ${e}`),d._protocol=e)}if(e[l.extensionName]){let t=e[l.extensionName].params,n=c.format({[l.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${n}`),d._extensions=e}this.emit(`headers`,u,r),i.write(u.concat(`\r
4
+ `).join(`\r
5
+ `)),i.removeListener(`error`,S),d.setSocket(i,a,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on(`close`,()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(x,this)})),o(d,r)}};function b(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n])}}function x(e){e._state=2,e.emit(`close`)}function S(){this.destroy()}function C(e,t,n,r){n||=a.STATUS_CODES[t],r={Connection:`close`,"Content-Type":`text/html`,"Content-Length":Buffer.byteLength(n),...r},e.once(`finish`,e.destroy),e.end(`HTTP/1.1 ${t} ${a.STATUS_CODES[t]}\r\n`+Object.keys(r).map(e=>`${e}: ${r[e]}`).join(`\r
6
+ `)+`\r
7
+ \r
8
+ `+n)}function w(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,w),e.emit(`wsClientError`,r,n,t)}else C(n,r,i,a)}})),x;t((()=>{v(),g(),d(),p(),m(),y(),_(),x=n(b(),1)}))();var S=x.default;export{S as WebSocketServer};
@@ -1 +1 @@
1
- import{expectObjectRecord,expectOnlyKnownKeys,expectString}from"#internal/authored-module.js";import{EVE_CREATE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{serializeOutputSchema}from"#shared/tool-schema.js";import{createCompiledSubagentNodeId}from"#compiler/manifest.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{createPathDerivedSourceId}from"#discover/manifest.js";async function compileSubagentGraph(e){let t=[],n=[],r=[];for(let i of e.subagents){let a=await compileSubagentDefinition({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:e.externalDependencies,parentNodeId:e.parentNodeId,source:i});if(a.kind===`remote`){r.push(a.node);continue}t.push(a.node,...a.descendants.nodes),n.push({childNodeId:a.node.nodeId,parentNodeId:e.parentNodeId},...a.descendants.edges)}return{edges:n,nodes:t,remoteAgents:r}}async function compileSubagentDefinition(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Subagent "${e.source.logicalPath}" is missing an agent config module.`);let n=createSubagentConfigModuleSourceRef(e.source,t),r=await loadModuleBackedDefinition({agentRoot:e.source.manifest.agentRoot,displayPath:n.logicalPath,externalDependencies:e.externalDependencies,kind:`subagent config`,source:t});return readAgentDefinitionKind(r)===`remote`?{kind:`remote`,node:compileRemoteAgent({source:e.source,value:r})}:{kind:`local`,...await compileLocalSubagent(e)}}async function compileSubagent(e){let t=createCompiledSubagentNodeId(e.parentNodeId,e.source.sourceId),n=e.source.subagentId,r=await e.compileAgentNodeManifest({...e.source.manifest,appRoot:e.appRoot},e.context,{allowWorkflowConfig:!1,externalDependencies:e.externalDependencies}),i=r.config.description;if(!i)throw Error(`Local subagent "${e.source.logicalPath}" is missing a "description" field on its agent config. Add \`description\` to \`defineAgent({ ... })\` so the parent agent can decide when to delegate to this subagent.`);let o=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:r.config.build?.externalDependencies,parentNodeId:t,subagents:e.source.manifest.subagents});return{descendants:o,node:{agent:{...r,remoteAgents:[...o.remoteAgents]},description:i,entryPath:e.source.entryPath,logicalPath:e.source.logicalPath,name:n,nodeId:t,rootPath:e.source.rootPath,sourceId:e.source.sourceId,sourceKind:`module`}}}const compileLocalSubagent=compileSubagent;function compileRemoteAgent(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Remote agent "${e.source.logicalPath}" is missing a config module.`);assertRemoteAgentDefinitionHasNoLocalPackageEntries(e.source);let n=createSubagentConfigModuleSourceRef(e.source,t),r=normalizeRemoteAgentDefinition(e.value,`Expected the remote agent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`),i={...n,description:r.description,entryPath:e.source.entryPath,name:e.source.subagentId,nodeId:e.source.sourceId,outputSchema:r.outputSchema,path:r.path,rootPath:e.source.rootPath};return r.url===void 0?i:{...i,url:r.url}}function createSubagentConfigModuleSourceRef(e,t){let n=e.logicalPath===t.logicalPath?t.logicalPath:`${e.logicalPath}/${t.logicalPath}`,r={logicalPath:n,sourceId:createPathDerivedSourceId(n),sourceKind:`module`};return t.exportName!==void 0&&(r.exportName=t.exportName),r}function readAgentDefinitionKind(e){return typeof e!=`object`||!e?`local`:e.kind===`remote`?`remote`:`local`}function normalizeRemoteAgentDefinition(a,o){let s=expectObjectRecord(a,o);if(expectOnlyKnownKeys(s,[`auth`,`description`,`headers`,`kind`,`outputSchema`,`path`,`url`],o),s.kind!==`remote`)throw Error(`${o} Expected "kind" to be "remote".`);return{description:expectString(s.description,o),outputSchema:serializeOutputSchema(s.outputSchema),path:s.path===void 0?EVE_CREATE_SESSION_ROUTE_PATH:expectString(s.path,o),url:typeof s.url==`function`?void 0:expectString(s.url,o)}}function assertRemoteAgentDefinitionHasNoLocalPackageEntries(e){let t=e.manifest,n=[t.connections.length>0?`connections/`:void 0,t.hooks.length>0?`hooks/`:void 0,t.instructions.length>0?`instructions`:void 0,t.lib.length>0?`lib/`:void 0,t.sandbox===null?void 0:`sandbox/`,t.sandboxWorkspaces.length>0?`sandbox/workspace/`:void 0,t.schedules.length>0?`schedules/`:void 0,t.skills.length>0?`skills/`:void 0,t.subagents.length>0?`subagents/`:void 0,t.tools.length>0?`tools/`:void 0].filter(e=>e!==void 0);if(n.length!==0)throw Error(`Remote subagent definition "${e.logicalPath}" cannot include local package entries. Remove unsupported entries: ${n.join(`, `)}.`)}export{compileSubagentGraph};
1
+ import{expectBoolean,expectObjectRecord,expectOnlyKnownKeys,expectString}from"#internal/authored-module.js";import{EVE_CREATE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{serializeOutputSchema}from"#shared/tool-schema.js";import{createCompiledSubagentNodeId}from"#compiler/manifest.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{createPathDerivedSourceId}from"#discover/manifest.js";async function compileSubagentGraph(e){let t=[],n=[],r=[];for(let i of e.subagents){let a=await compileSubagentDefinition({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:e.externalDependencies,parentNodeId:e.parentNodeId,source:i});if(a.kind===`remote`){r.push(a.node);continue}t.push(a.node,...a.descendants.nodes),n.push({childNodeId:a.node.nodeId,parentNodeId:e.parentNodeId},...a.descendants.edges)}return{edges:n,nodes:t,remoteAgents:r}}async function compileSubagentDefinition(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Subagent "${e.source.logicalPath}" is missing an agent config module.`);let n=createSubagentConfigModuleSourceRef(e.source,t),r=await loadModuleBackedDefinition({agentRoot:e.source.manifest.agentRoot,displayPath:n.logicalPath,externalDependencies:e.externalDependencies,kind:`subagent config`,source:t});return readAgentDefinitionKind(r)===`remote`?{kind:`remote`,node:compileRemoteAgent({source:e.source,value:r})}:{kind:`local`,...await compileLocalSubagent(e)}}async function compileSubagent(e){let t=createCompiledSubagentNodeId(e.parentNodeId,e.source.sourceId),n=e.source.subagentId,r=await e.compileAgentNodeManifest({...e.source.manifest,appRoot:e.appRoot},e.context,{allowWorkflowConfig:!1,externalDependencies:e.externalDependencies}),i=r.config.description;if(!i)throw Error(`Local subagent "${e.source.logicalPath}" is missing a "description" field on its agent config. Add \`description\` to \`defineAgent({ ... })\` so the parent agent can decide when to delegate to this subagent.`);let a=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:r.config.build?.externalDependencies,parentNodeId:t,subagents:e.source.manifest.subagents});return{descendants:a,node:{agent:{...r,remoteAgents:[...a.remoteAgents]},description:i,entryPath:e.source.entryPath,logicalPath:e.source.logicalPath,name:n,nodeId:t,rootPath:e.source.rootPath,sourceId:e.source.sourceId,sourceKind:`module`}}}const compileLocalSubagent=compileSubagent;function compileRemoteAgent(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Remote agent "${e.source.logicalPath}" is missing a config module.`);assertRemoteAgentDefinitionHasNoLocalPackageEntries(e.source);let n=createSubagentConfigModuleSourceRef(e.source,t),r=normalizeRemoteAgentDefinition(e.value,`Expected the remote agent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`),i={...n,description:r.description,entryPath:e.source.entryPath,name:e.source.subagentId,nodeId:e.source.sourceId,outputSchema:r.outputSchema,path:r.path,rootPath:e.source.rootPath};return r.url===void 0?i:{...i,url:r.url}}function createSubagentConfigModuleSourceRef(e,t){let n=e.logicalPath===t.logicalPath?t.logicalPath:`${e.logicalPath}/${t.logicalPath}`,r={logicalPath:n,sourceId:createPathDerivedSourceId(n),sourceKind:`module`};return t.exportName!==void 0&&(r.exportName=t.exportName),r}function readAgentDefinitionKind(e){return typeof e!=`object`||!e?`local`:e.kind===`remote`?`remote`:`local`}function normalizeRemoteAgentDefinition(o,s){let c=expectObjectRecord(o,s);if(expectOnlyKnownKeys(c,[`auth`,`description`,`forwardPrincipal`,`headers`,`kind`,`outputSchema`,`path`,`url`],s),c.kind!==`remote`)throw Error(`${s} Expected "kind" to be "remote".`);return c.forwardPrincipal!==void 0&&expectBoolean(c.forwardPrincipal,`${s} Expected "forwardPrincipal" to be a boolean.`),{description:expectString(c.description,s),outputSchema:serializeOutputSchema(c.outputSchema),path:c.path===void 0?EVE_CREATE_SESSION_ROUTE_PATH:expectString(c.path,s),url:typeof c.url==`function`?void 0:expectString(c.url,s)}}function assertRemoteAgentDefinitionHasNoLocalPackageEntries(e){let t=e.manifest,n=[t.connections.length>0?`connections/`:void 0,t.hooks.length>0?`hooks/`:void 0,t.instructions.length>0?`instructions`:void 0,t.lib.length>0?`lib/`:void 0,t.sandbox===null?void 0:`sandbox/`,t.sandboxWorkspaces.length>0?`sandbox/workspace/`:void 0,t.schedules.length>0?`schedules/`:void 0,t.skills.length>0?`skills/`:void 0,t.subagents.length>0?`subagents/`:void 0,t.tools.length>0?`tools/`:void 0].filter(e=>e!==void 0);if(n.length!==0)throw Error(`Remote subagent definition "${e.logicalPath}" cannot include local package entries. Remove unsupported entries: ${n.join(`, `)}.`)}export{compileSubagentGraph};
@@ -1,2 +1,2 @@
1
- import"../node_modules/.pnpm/autoevals@0.0.132_ws@8.21.1/node_modules/autoevals/jsdist/index.js";import{toInputSchema}from"#shared/tool-schema.js";import{resolveProviderHeaders}from"#internal/gateway.js";import{generateText}from"ai";function createAutoevalsClient(e){return{chat:{completions:{create:t=>createChatCompletion(t,e)}}}}async function createChatCompletion(e,r){let i=convertTools(e.tools),a=await generateText({headers:resolveProviderHeaders(r.languageModel),model:r.languageModel,messages:convertMessages(e.messages??[]),tools:Object.keys(i).length>0?i:void 0,toolChoice:convertToolChoice(e.tool_choice),providerOptions:r.providerOptions}),o=a.toolCalls.map(e=>({id:e.toolCallId,type:`function`,function:{name:e.toolName,arguments:JSON.stringify(e.input??{})}}));return{choices:[{index:0,finish_reason:o.length>0?`tool_calls`:`stop`,message:{role:`assistant`,content:a.text||null,tool_calls:o.length>0?o:void 0}}]}}function convertMessages(e){return e.map(e=>{let t=contentToText(e.content);switch(e.role){case`assistant`:return{role:`assistant`,content:t};case`developer`:case`system`:return{role:`system`,content:t};default:return{role:`user`,content:t}}})}function contentToText(e){return e==null?``:typeof e==`string`?e:e.map(e=>e.text??``).filter(Boolean).join(`
1
+ import"../node_modules/.pnpm/autoevals@0.0.132_ws@8.21.1_bufferutil@4.1.0_/node_modules/autoevals/jsdist/index.js";import{toInputSchema}from"#shared/tool-schema.js";import{resolveProviderHeaders}from"#internal/gateway.js";import{generateText}from"ai";function createAutoevalsClient(e){return{chat:{completions:{create:t=>createChatCompletion(t,e)}}}}async function createChatCompletion(e,r){let i=convertTools(e.tools),a=await generateText({headers:resolveProviderHeaders(r.languageModel),model:r.languageModel,messages:convertMessages(e.messages??[]),tools:Object.keys(i).length>0?i:void 0,toolChoice:convertToolChoice(e.tool_choice),providerOptions:r.providerOptions}),o=a.toolCalls.map(e=>({id:e.toolCallId,type:`function`,function:{name:e.toolName,arguments:JSON.stringify(e.input??{})}}));return{choices:[{index:0,finish_reason:o.length>0?`tool_calls`:`stop`,message:{role:`assistant`,content:a.text||null,tool_calls:o.length>0?o:void 0}}]}}function convertMessages(e){return e.map(e=>{let t=contentToText(e.content);switch(e.role){case`assistant`:return{role:`assistant`,content:t};case`developer`:case`system`:return{role:`system`,content:t};default:return{role:`user`,content:t}}})}function contentToText(e){return e==null?``:typeof e==`string`?e:e.map(e=>e.text??``).filter(Boolean).join(`
2
2
  `)}function convertTools(t){let n={};for(let r of t??[])r.type!==`function`||r.function?.name===void 0||(n[r.function.name]={description:r.function.description,inputSchema:toInputSchema(r.function.parameters??{})});return n}function convertToolChoice(e){if(e!==void 0)return typeof e==`string`?e:{type:`tool`,toolName:e.function.name}}export{createAutoevalsClient};
@@ -1,4 +1,4 @@
1
- import{basename,join}from"node:path";import{readFile}from"node:fs/promises";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{shutdownActiveSandboxHandles}from"#execution/sandbox/active-handles.js";import{createDevelopmentServer}from"#internal/nitro/host.js";import{createEvalClient}from"#evals/cli/eval-client.js";import{discoverAndImportEvals,discoverEvalConfig,findMisplacedEvalDirs}from"#evals/runner/discover.js";import{runEvals}from"#evals/runner/run-evals.js";import{Console}from"#evals/runner/reporters/console.js";import{JUnit}from"#evals/runner/reporters/junit.js";import{resolveEvalTargetHandle}from"#evals/target.js";async function runEvalCommand(e,t,n){let o=resolveApplicationRoot();loadDevelopmentEnvironmentFiles(o);let s=e.length>0?e:void 0,c=await discoverAndImportEvals(o,s);if(c.length===0){let e=await findMisplacedEvalDirs(o);e.length>0?n.error(`No evals found under evals/, but eval files are present inside agent/:
1
+ import{basename,join}from"node:path";import{readFile}from"node:fs/promises";import{createDevelopmentServer}from"#internal/nitro/host.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{shutdownActiveSandboxHandles}from"#execution/sandbox/active-handles.js";import{createEvalClient}from"#evals/cli/eval-client.js";import{discoverAndImportEvals,discoverEvalConfig,findMisplacedEvalDirs}from"#evals/runner/discover.js";import{runEvals}from"#evals/runner/run-evals.js";import{Console}from"#evals/runner/reporters/console.js";import{JUnit}from"#evals/runner/reporters/junit.js";import{resolveEvalTargetHandle}from"#evals/target.js";async function runEvalCommand(e,t,n){let s=resolveApplicationRoot();loadDevelopmentEnvironmentFiles(s);let c=e.length>0?e:void 0,l=await discoverAndImportEvals(s,c);if(l.length===0){let e=await findMisplacedEvalDirs(s);e.length>0?n.error(`No evals found under evals/, but eval files are present inside agent/:
2
2
  `+e.map(e=>` - ${e}`).join(`
3
3
  `)+`
4
- eve eval only scans the top-level evals/ directory (a sibling of agent/). Move these files there.`):s?n.error(`No evals found matching: ${s.join(`, `)}`):n.error(`No evals found. Create files under evals/ with the *.eval.ts extension.`),process.exitCode=2;return}let l=filterEvalsByTag(c,t.tag??[]);if(l.length===0){n.error(`No evals matched the provided tags (${(t.tag??[]).join(`, `)}).`),process.exitCode=2;return}let u,d;try{u=parsePositiveInteger(t.maxConcurrency,`--max-concurrency`),d=parseNonNegativeInteger(t.timeout,`--timeout`)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}if(t.list===!0){printEvalList(l,t.json===!0,n);return}let f;try{f=await discoverEvalConfig(o)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let p,m,h;try{if(t.url)h=await createEvalClient({kind:`remote`,url:t.url},{workspaceRoot:o}),m=await resolveEvalTargetHandle({client:h,expectedAgentName:await readExpectedAgentName(o),kind:`remote`,url:t.url});else{p=createDevelopmentServer(o,{host:`127.0.0.1`,port:0});let e=await p.start();h=await createEvalClient({kind:`local`,url:e.url}),m=await resolveEvalTargetHandle({client:h,expectedAgentName:await readExpectedAgentName(o),kind:`local`,url:e.url})}let e=t.json===!0?[]:[Console()];t.junit!==void 0&&e.push(JUnit({filePath:t.junit}));let r=await runEvals({evaluations:l,config:f,target:m,client:h,appRoot:o,reporters:e,includeEvalReporters:t.skipReport!==!0,maxConcurrency:u,timeoutMs:d,onEvalLog:t.verbose===!0?(e,t)=>n.log(`[${e}] ${t}`):void 0});t.json&&n.log(JSON.stringify(r,null,2));let i=r.failed>0,a=t.strict===!0&&r.scored>0;(i||a)&&(process.exitCode=1)}finally{p&&(await p.close(),await shutdownActiveSandboxHandles({log:e=>n.error(e)}))}let g=typeof process.exitCode==`number`?process.exitCode:0;process.exit(g)}function parsePositiveInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<1)throw Error(`${t} must be a positive integer; got "${e}".`);return n}function parseNonNegativeInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw Error(`${t} must be a non-negative integer; got "${e}".`);return n}function filterEvalsByTag(e,t){return t.length===0?[...e]:e.filter(e=>e.tags?.some(e=>t.includes(e))??!1)}function printEvalList(e,t,n){if(t){let t=e.map(e=>({id:e.id,description:e.description,tags:e.tags}));n.log(JSON.stringify(t,null,2));return}for(let t of e){let e=t.description===void 0?``:` — ${t.description}`,r=t.tags!==void 0&&t.tags.length>0?` [${t.tags.join(`, `)}]`:``;n.log(`${t.id}${r}${e}`)}}async function readExpectedAgentName(r){try{let i=JSON.parse(await readFile(join(r,`package.json`),`utf8`));return typeof i.name==`string`&&i.name.length>0?i.name:basename(r)}catch{return basename(r)}}export{runEvalCommand};
4
+ eve eval only scans the top-level evals/ directory (a sibling of agent/). Move these files there.`):c?n.error(`No evals found matching: ${c.join(`, `)}`):n.error(`No evals found. Create files under evals/ with the *.eval.ts extension.`),process.exitCode=2;return}let u=filterEvalsByTag(l,t.tag??[]);if(u.length===0){n.error(`No evals matched the provided tags (${(t.tag??[]).join(`, `)}).`),process.exitCode=2;return}let d,f;try{d=parsePositiveInteger(t.maxConcurrency,`--max-concurrency`),f=parseNonNegativeInteger(t.timeout,`--timeout`)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}if(t.list===!0){printEvalList(u,t.json===!0,n);return}let p;try{p=await discoverEvalConfig(s)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let m,h,g;try{if(t.url)g=await createEvalClient({kind:`remote`,url:t.url},{workspaceRoot:s}),h=await resolveEvalTargetHandle({client:g,expectedAgentName:await readExpectedAgentName(s),kind:`remote`,url:t.url});else{m=createDevelopmentServer(s,{host:`127.0.0.1`,port:0});let e=await m.start();g=await createEvalClient({kind:`local`,url:e.url}),h=await resolveEvalTargetHandle({client:g,expectedAgentName:await readExpectedAgentName(s),kind:`local`,url:e.url})}let e=t.json===!0?[]:[Console()];t.junit!==void 0&&e.push(JUnit({filePath:t.junit}));let i=await runEvals({evaluations:u,config:p,target:h,client:g,appRoot:s,reporters:e,includeEvalReporters:t.skipReport!==!0,maxConcurrency:d,timeoutMs:f,onEvalLog:t.verbose===!0?(e,t)=>n.log(`[${e}] ${t}`):void 0});t.json&&n.log(JSON.stringify(i,null,2));let a=i.failed>0,o=t.strict===!0&&i.scored>0;(a||o)&&(process.exitCode=1)}finally{m&&(await m.close(),await shutdownActiveSandboxHandles({log:e=>n.error(e)}))}let _=typeof process.exitCode==`number`?process.exitCode:0;process.exit(_)}function parsePositiveInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<1)throw Error(`${t} must be a positive integer; got "${e}".`);return n}function parseNonNegativeInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw Error(`${t} must be a non-negative integer; got "${e}".`);return n}function filterEvalsByTag(e,t){return t.length===0?[...e]:e.filter(e=>e.tags?.some(e=>t.includes(e))??!1)}function printEvalList(e,t,n){if(t){let t=e.map(e=>({id:e.id,description:e.description,tags:e.tags}));n.log(JSON.stringify(t,null,2));return}for(let t of e){let e=t.description===void 0?``:` — ${t.description}`,r=t.tags!==void 0&&t.tags.length>0?` [${t.tags.join(`, `)}]`:``;n.log(`${t.id}${r}${e}`)}}async function readExpectedAgentName(r){try{let i=JSON.parse(await readFile(join(r,`package.json`),`utf8`));return typeof i.name==`string`&&i.name.length>0?i.name:basename(r)}catch{return basename(r)}}export{runEvalCommand};
@@ -1 +1 @@
1
- import{Levenshtein}from"../../node_modules/.pnpm/autoevals@0.0.132_ws@8.21.1/node_modules/autoevals/jsdist/index.js";import{deepEquals,testRegExp}from"#evals/match.js";function makeAssertion(e){return{name:e.name,severity:e.severity,threshold:e.threshold,score:e.score,gate(t){return makeAssertion({...e,severity:`gate`,threshold:t})},soft(t){return makeAssertion({...e,severity:`soft`,threshold:t})},atLeast(t){return makeAssertion({...e,severity:`soft`,threshold:t})}}}function includes(e){return makeAssertion({name:`includes(${e})`,severity:`gate`,score:t=>{let r=String(t??``);return(typeof e==`string`?r.includes(e):testRegExp(e,r))?1:0}})}function satisfies(e,t){if(t.trim().length===0)throw Error(`satisfies() requires a non-empty label.`);return makeAssertion({name:`satisfies(${t})`,severity:`gate`,score:t=>+!!e(t)})}function equals(e){return makeAssertion({name:`equals`,severity:`gate`,score:n=>+!!deepEquals(n,e)})}function matches(e){return makeAssertion({name:`matches`,severity:`gate`,score:async t=>{let n=await e[`~standard`].validate(t);return+(!(`issues`in n)||n.issues===void 0)}})}function similarity(t){return makeAssertion({name:`similarity`,severity:`soft`,score:async n=>(await Levenshtein({output:String(n??``),expected:t})).score??0})}export{equals,includes,matches,satisfies,similarity};
1
+ import{Levenshtein}from"../../node_modules/.pnpm/autoevals@0.0.132_ws@8.21.1_bufferutil@4.1.0_/node_modules/autoevals/jsdist/index.js";import{deepEquals,testRegExp}from"#evals/match.js";function makeAssertion(e){return{name:e.name,severity:e.severity,threshold:e.threshold,score:e.score,gate(t){return makeAssertion({...e,severity:`gate`,threshold:t})},soft(t){return makeAssertion({...e,severity:`soft`,threshold:t})},atLeast(t){return makeAssertion({...e,severity:`soft`,threshold:t})}}}function includes(e){return makeAssertion({name:`includes(${e})`,severity:`gate`,score:t=>{let r=String(t??``);return(typeof e==`string`?r.includes(e):testRegExp(e,r))?1:0}})}function satisfies(e,t){if(t.trim().length===0)throw Error(`satisfies() requires a non-empty label.`);return makeAssertion({name:`satisfies(${t})`,severity:`gate`,score:t=>+!!e(t)})}function equals(e){return makeAssertion({name:`equals`,severity:`gate`,score:n=>+!!deepEquals(n,e)})}function matches(e){return makeAssertion({name:`matches`,severity:`gate`,score:async t=>{let n=await e[`~standard`].validate(t);return+(!(`issues`in n)||n.issues===void 0)}})}function similarity(t){return makeAssertion({name:`similarity`,severity:`soft`,score:async n=>(await Levenshtein({output:String(n??``),expected:t})).score??0})}export{equals,includes,matches,satisfies,similarity};
@@ -1 +1 @@
1
- import{ClosedQA,Factuality,Sql,Summary}from"../node_modules/.pnpm/autoevals@0.0.132_ws@8.21.1/node_modules/autoevals/jsdist/index.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{createAutoevalsClient}from"#evals/autoevals-client.js";function buildJudgeContext(a){function grade(e,t,n){let r=t?.on??a.getReply(),o=String(r??``),s=a.getInput(),c=t?.model??a.judge?.model,l=t?.modelOptions??a.judge?.modelOptions;return a.collector.recordValue({name:e,severity:`soft`,score:async()=>{if(c===void 0)throw Error(`${e} needs a judge model. Set \`judge\` on the eval or in evals.config.ts, or pass { model } to the call.`);return{score:(await n({input:s,output:o,model:c,modelOptions:l})).score??0,metadata:{judge:formatLanguageModelGatewayId(c)}}}})}return{autoevals:{factuality:(e,n)=>grade(`judge.autoevals.factuality`,n,({input:n,output:r,model:i,modelOptions:a})=>Factuality({input:n,output:r,expected:e,...client(i,a)})),summarizes:(e,t)=>grade(`judge.autoevals.summarizes`,t,({input:t,output:n,model:i,modelOptions:a})=>Summary({input:t,output:n,expected:e,...client(i,a)})),closedQA:(t,n)=>grade(`judge.autoevals.closedQA`,n,({input:n,output:r,model:i,modelOptions:a})=>ClosedQA({input:n,output:r,criteria:t,...client(i,a)})),sql:(e,t)=>grade(`judge.autoevals.sql`,t,({input:t,output:r,model:i,modelOptions:a})=>Sql({input:t,output:r,expected:e,...client(i,a)}))}}}function client(e,t){return{model:formatLanguageModelGatewayId(e),client:createAutoevalsClient({languageModel:e,providerOptions:t?.providerOptions})}}export{buildJudgeContext};
1
+ import{ClosedQA,Factuality,Sql,Summary}from"../node_modules/.pnpm/autoevals@0.0.132_ws@8.21.1_bufferutil@4.1.0_/node_modules/autoevals/jsdist/index.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{createAutoevalsClient}from"#evals/autoevals-client.js";function buildJudgeContext(a){function grade(e,t,n){let r=t?.on??a.getReply(),o=String(r??``),s=a.getInput(),c=t?.model??a.judge?.model,l=t?.modelOptions??a.judge?.modelOptions;return a.collector.recordValue({name:e,severity:`soft`,score:async()=>{if(c===void 0)throw Error(`${e} needs a judge model. Set \`judge\` on the eval or in evals.config.ts, or pass { model } to the call.`);return{score:(await n({input:s,output:o,model:c,modelOptions:l})).score??0,metadata:{judge:formatLanguageModelGatewayId(c)}}}})}return{autoevals:{factuality:(e,n)=>grade(`judge.autoevals.factuality`,n,({input:n,output:r,model:i,modelOptions:a})=>Factuality({input:n,output:r,expected:e,...client(i,a)})),summarizes:(e,t)=>grade(`judge.autoevals.summarizes`,t,({input:t,output:n,model:i,modelOptions:a})=>Summary({input:t,output:n,expected:e,...client(i,a)})),closedQA:(t,n)=>grade(`judge.autoevals.closedQA`,n,({input:n,output:r,model:i,modelOptions:a})=>ClosedQA({input:n,output:r,criteria:t,...client(i,a)})),sql:(e,t)=>grade(`judge.autoevals.sql`,t,({input:t,output:r,model:i,modelOptions:a})=>Sql({input:t,output:r,expected:e,...client(i,a)}))}}}function client(e,t){return{model:formatLanguageModelGatewayId(e),client:createAutoevalsClient({languageModel:e,providerOptions:t?.providerOptions})}}export{buildJudgeContext};
@@ -1 +1 @@
1
- import{createLogger,logError}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,InitiatorAuthKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{createSubagentCalledEvent,encodeMessageStreamEvent,timestampHandleMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{resolveRemoteAgentForAction,startRemoteAgentSession}from"#execution/remote-agent-dispatch.js";import{createWorkflowRuntime,workflowEntryReference}from"#execution/workflow-runtime.js";import{getPendingRuntimeActionBatch,recordPendingSubagentChild}from"#harness/runtime-actions.js";import{hydrateDurableSession}from"#execution/session.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{buildSubagentRunInput}from"#execution/subagent-tool.js";import{resolveSubagentDepth}from"#harness/subagent-depth.js";const log=createLogger(`execution.dispatch-runtime-actions`);async function dispatchRuntimeActionsStep(e){"use step";let f=await readDurableSession(e.sessionState),p=getPendingRuntimeActionBatch(f.state);if(p===void 0||p.actions.length===0)return{results:[],sessionState:e.sessionState};let m=await deserializeContext(e.serializedContext),h=m.require(BundleKey),g=hydrateDurableSession({compactionOverrides:{thresholdPercent:h.resolvedAgent.config.compaction?.thresholdPercent},durable:f,turnAgent:h.turnAgent}),_=m.require(ChannelKey),v=m.get(AuthKey)??null,y=m.get(CapabilitiesKey),b=m.get(ChannelInstrumentationKey),x=m.get(InitiatorAuthKey)??null,S=e.parentWritable.getWriter(),C=buildAdapterContext(_,m),w=resolveSubagentDepth(g),T=p.actions.filter(e=>e.kind===`subagent-call`).length,E=g,D=[];try{for(let r of p.actions){if(isRecursiveAgentAction(r,h.subagentRegistry.subagentsByNodeId)&&(g.rootSessionId!==void 0||w.currentDepth>0)){log.warn(`recursive agent call blocked outside the root session`,{callId:r.callId,currentDepth:w.currentDepth,nodeId:r.nodeId,subagentName:r.subagentName}),D.push(createRecursiveAgentRootOnlyResult(r));continue}let i,a,o,u;switch(r.kind){case`subagent-call`:{let n=h.subagentRegistry.subagentsByNodeId.get(r.nodeId),o=n?.definition.kind===`subagent`?{description:n.definition.description,type:`local`}:{type:`runtime`},s=createWorkflowRuntime({compiledArtifactsSource:h.compiledArtifactsSource,nodeId:r.nodeId}),{childContinuationToken:c,runInput:l}=buildSubagentRunInput({action:r,auth:v,batchEvent:p.event,capabilities:y,channelMetadata:b,fanoutSize:T,initiatorAuth:x,parentContinuationToken:e.parentContinuationToken,session:g,source:o});try{i=(await s.run(l)).sessionId}catch(e){logError(log,`local subagent start failed`,e,{callId:r.callId,nodeId:r.nodeId,subagentName:r.subagentName}),D.push({callId:r.callId,isError:!0,kind:`subagent-result`,output:{code:`SUBAGENT_START_FAILED`,message:toErrorMessage(e)},subagentName:r.subagentName});continue}E=recordPendingSubagentChild({callId:r.callId,child:{continuationToken:c,kind:`local`,sessionId:i},session:E}),a=r.name,u=r.subagentName;break}case`remote-agent-call`:{let n;try{n=resolveRemoteAgentForAction({nodeId:r.nodeId,remoteAgentName:r.remoteAgentName,registry:h.subagentRegistry.subagentsByNodeId}),i=await startRemoteAgentSession({action:r,callbackBaseUrl:e.callbackBaseUrl,callbackToken:e.parentContinuationToken,remote:n,session:g})}catch(e){logError(log,`remote agent start failed`,e,{remoteAgentName:r.remoteAgentName,nodeId:r.nodeId,callId:r.callId}),D.push(createRemoteAgentStartFailureResult({action:r,error:e}));continue}a=r.name,o={url:n.url},u=r.remoteAgentName,E=recordPendingSubagentChild({callId:r.callId,child:{kind:`remote`,sessionId:i},session:E});break}default:throw Error(`Unsupported runtime action kind "${r.kind}" in workflow runtime.`)}let d=await callAdapterEventHandler(_,createSubagentCalledEvent({callId:r.callId,childSessionId:i,name:a,remote:o,sequence:p.event.sequence,sessionId:g.sessionId,toolName:u,turnId:p.event.turnId,workflowId:workflowEntryReference.workflowId}),C);await S.write(encodeMessageStreamEvent(timestampHandleMessageStreamEvent(d)))}}finally{S.releaseLock()}return{results:D,sessionState:E===g?e.sessionState:createDurableSessionState({session:E})}}function createRemoteAgentStartFailureResult(e){return{callId:e.action.callId,isError:!0,kind:`subagent-result`,output:{code:`REMOTE_AGENT_START_FAILED`,message:toErrorMessage(e.error)},subagentName:e.action.remoteAgentName}}function createRecursiveAgentRootOnlyResult(e){return{callId:e.callId,isError:!0,kind:`subagent-result`,output:{code:`RECURSIVE_AGENT_ROOT_ONLY`,message:`The built-in "agent" tool is only available to the root session.`},subagentName:e.subagentName}}function isRecursiveAgentAction(e,t){return e.kind===`subagent-call`&&e.subagentName===`agent`&&!t.has(e.nodeId)}export{dispatchRuntimeActionsStep};
1
+ import{createLogger,logError}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,InitiatorAuthKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{createSubagentCalledEvent,encodeMessageStreamEvent,timestampHandleMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{resolveRemoteAgentForAction,startRemoteAgentSession}from"#execution/remote-agent-dispatch.js";import{createWorkflowRuntime,workflowEntryReference}from"#execution/workflow-runtime.js";import{getPendingRuntimeActionBatch,recordPendingSubagentChild}from"#harness/runtime-actions.js";import{hydrateDurableSession}from"#execution/session.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{buildSubagentRunInput}from"#execution/subagent-tool.js";import{resolveSubagentDepth}from"#harness/subagent-depth.js";const log=createLogger(`execution.dispatch-runtime-actions`);async function dispatchRuntimeActionsStep(e){"use step";let f=await readDurableSession(e.sessionState),p=getPendingRuntimeActionBatch(f.state);if(p===void 0||p.actions.length===0)return{results:[],sessionState:e.sessionState};let m=await deserializeContext(e.serializedContext),h=m.require(BundleKey),g=hydrateDurableSession({compactionOverrides:{thresholdPercent:h.resolvedAgent.config.compaction?.thresholdPercent},durable:f,turnAgent:h.turnAgent}),_=m.require(ChannelKey),v=m.get(AuthKey)??null,y=m.get(CapabilitiesKey),b=m.get(ChannelInstrumentationKey),x=m.get(InitiatorAuthKey)??null,S=e.parentWritable.getWriter(),C=buildAdapterContext(_,m),w=resolveSubagentDepth(g),T=p.actions.filter(e=>e.kind===`subagent-call`).length,E=g,D=[];try{for(let r of p.actions){if(isRecursiveAgentAction(r,h.subagentRegistry.subagentsByNodeId)&&(g.rootSessionId!==void 0||w.currentDepth>0)){log.warn(`recursive agent call blocked outside the root session`,{callId:r.callId,currentDepth:w.currentDepth,nodeId:r.nodeId,subagentName:r.subagentName}),D.push(createRecursiveAgentRootOnlyResult(r));continue}let i,a,o,u;switch(r.kind){case`subagent-call`:{let n=h.subagentRegistry.subagentsByNodeId.get(r.nodeId),o=n?.definition.kind===`subagent`?{description:n.definition.description,type:`local`}:{type:`runtime`},s=createWorkflowRuntime({compiledArtifactsSource:h.compiledArtifactsSource,nodeId:r.nodeId}),{childContinuationToken:c,runInput:l}=buildSubagentRunInput({action:r,auth:v,batchEvent:p.event,capabilities:y,channelMetadata:b,fanoutSize:T,initiatorAuth:x,parentContinuationToken:e.parentContinuationToken,session:g,source:o});try{i=(await s.run(l)).sessionId}catch(e){logError(log,`local subagent start failed`,e,{callId:r.callId,nodeId:r.nodeId,subagentName:r.subagentName}),D.push({callId:r.callId,isError:!0,kind:`subagent-result`,output:{code:`SUBAGENT_START_FAILED`,message:toErrorMessage(e)},subagentName:r.subagentName});continue}E=recordPendingSubagentChild({callId:r.callId,child:{continuationToken:c,kind:`local`,sessionId:i},session:E}),a=r.name,u=r.subagentName;break}case`remote-agent-call`:{let n;try{n=resolveRemoteAgentForAction({nodeId:r.nodeId,remoteAgentName:r.remoteAgentName,registry:h.subagentRegistry.subagentsByNodeId}),i=await startRemoteAgentSession({action:r,auth:v,callbackBaseUrl:e.callbackBaseUrl,callbackToken:e.parentContinuationToken,initiatorAuth:x,remote:n,session:g})}catch(e){logError(log,`remote agent start failed`,e,{remoteAgentName:r.remoteAgentName,nodeId:r.nodeId,callId:r.callId}),D.push(createRemoteAgentStartFailureResult({action:r,error:e}));continue}a=r.name,o={url:n.url},u=r.remoteAgentName,E=recordPendingSubagentChild({callId:r.callId,child:{kind:`remote`,sessionId:i},session:E});break}default:throw Error(`Unsupported runtime action kind "${r.kind}" in workflow runtime.`)}let d=await callAdapterEventHandler(_,createSubagentCalledEvent({callId:r.callId,childSessionId:i,name:a,remote:o,sequence:p.event.sequence,sessionId:g.sessionId,toolName:u,turnId:p.event.turnId,workflowId:workflowEntryReference.workflowId}),C);await S.write(encodeMessageStreamEvent(timestampHandleMessageStreamEvent(d)))}}finally{S.releaseLock()}return{results:D,sessionState:E===g?e.sessionState:createDurableSessionState({session:E})}}function createRemoteAgentStartFailureResult(e){return{callId:e.action.callId,isError:!0,kind:`subagent-result`,output:{code:`REMOTE_AGENT_START_FAILED`,message:toErrorMessage(e.error)},subagentName:e.action.remoteAgentName}}function createRecursiveAgentRootOnlyResult(e){return{callId:e.callId,isError:!0,kind:`subagent-result`,output:{code:`RECURSIVE_AGENT_ROOT_ONLY`,message:`The built-in "agent" tool is only available to the root session.`},subagentName:e.subagentName}}function isRecursiveAgentAction(e,t){return e.kind===`subagent-call`&&e.subagentName===`agent`&&!t.has(e.nodeId)}export{dispatchRuntimeActionsStep};
@@ -1,12 +1,16 @@
1
- import type { CancelTurnResult } from "#channel/types.js";
1
+ import type { CancelTurnResult, SessionAuthContext } from "#channel/types.js";
2
2
  import type { HarnessSession } from "#harness/types.js";
3
3
  import type { RuntimeRemoteAgentCallActionRequest } from "#runtime/actions/types.js";
4
4
  import type { RuntimeSubagentRegistry } from "#runtime/subagents/registry.js";
5
5
  import type { ResolvedRuntimeRemoteAgentNode } from "#runtime/types.js";
6
6
  export declare function startRemoteAgentSession(input: {
7
7
  readonly action: RuntimeRemoteAgentCallActionRequest;
8
+ /** The dispatching turn's session principal, forwarded when `remote.forwardPrincipal` is set. */
9
+ readonly auth?: SessionAuthContext | null;
8
10
  readonly callbackBaseUrl: string | undefined;
9
11
  readonly callbackToken?: string;
12
+ /** The root initiator's principal, forwarded alongside {@link auth}. */
13
+ readonly initiatorAuth?: SessionAuthContext | null;
10
14
  readonly remote: ResolvedRuntimeRemoteAgentNode;
11
15
  readonly session: HarnessSession;
12
16
  }): Promise<string>;
@@ -1 +1 @@
1
- import{createEveCallbackRoutePath,createEveCancelTurnRoutePath}from"#protocol/routes.js";import{EVE_SESSION_ID_HEADER}from"#protocol/message.js";import{CancelTurnResponseSchema}from"#protocol/cancel-turn.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{formatSubagentInput}from"#execution/subagent-invocation.js";var RemoteAgentCancelRequestError=class extends Error{retryable;constructor(e,t){super(e),this.name=`RemoteAgentCancelRequestError`,this.retryable=t.retryable}};async function startRemoteAgentSession(t){let r=t.callbackToken??t.session.continuationToken;if(!r)throw Error(`Cannot dispatch remote agent without a parent continuation token.`);if(!t.callbackBaseUrl)throw Error(`Cannot dispatch remote agent without a callback base URL.`);let a=await resolveRemoteAgentRequestHeaders(t.remote),o=await fetch(createRemoteAgentSessionUrl(t.remote),{body:JSON.stringify({callback:{callId:t.action.callId,subagentName:t.action.remoteAgentName,token:r,url:createWorkflowCallbackUrl(t.callbackBaseUrl,createEveCallbackRoutePath(r))},message:formatRemoteAgentCallInputMessage({action:t.action,remote:t.remote}),mode:`task`,outputSchema:t.action.input.outputSchema??t.remote.outputSchema}),headers:{"content-type":`application/json`,...a},method:`POST`});if(!o.ok)throw Error(`Remote agent "${t.action.remoteAgentName}" create-session request failed with HTTP ${o.status}.`);let s=o.headers.get(EVE_SESSION_ID_HEADER);if(s!==null&&s.length>0)return s;try{let e=await o.json();if(typeof e.sessionId==`string`&&e.sessionId.length>0)return e.sessionId}catch{}throw Error(`Remote agent "${t.action.remoteAgentName}" create-session response did not include a session id.`)}async function cancelRemoteAgentTurn(e){let t=await resolveRemoteAgentRequestHeaders(e.remote),n=await fetch(createRemoteAgentCancelTurnUrl(e.remote,e.sessionId),{headers:t,method:`POST`});if(!n.ok)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn request failed with HTTP ${n.status}.`,{retryable:isRetryableRemoteCancelStatus(n.status)});let i;try{i=await n.json()}catch{throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was not valid JSON.`,{retryable:!1})}let a=CancelTurnResponseSchema.safeParse(i);if(!a.success||a.data.sessionId!==e.sessionId)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was invalid.`,{retryable:!1});return{status:a.data.status}}function isRetryableRemoteAgentCancelError(e){return!(e instanceof RemoteAgentCancelRequestError)||e.retryable}function resolveRemoteAgentForAction(e){let t=e.registry.get(e.nodeId)?.definition;if(t?.kind!==`remote`)throw Error(`Missing remote agent "${e.remoteAgentName}" in runtime registry.`);return t}function createRemoteAgentSessionUrl(e){return new URL(e.path,`${trimTrailingSlash(e.url)}/`).toString()}function createRemoteAgentCancelTurnUrl(e,n){return new URL(createEveCancelTurnRoutePath(n),`${trimTrailingSlash(e.url)}/`).toString()}function isRetryableRemoteCancelStatus(e){return e===408||e===425||e===429||e>=500}async function resolveRemoteAgentRequestHeaders(e){let t={};return e.headers!==void 0&&Object.assign(t,typeof e.headers==`function`?await e.headers():e.headers),e.auth!==void 0&&Object.assign(t,(await e.auth()).headers),t}function formatRemoteAgentCallInputMessage(e){let t=typeof e.action.input.message==`string`?e.action.input.message:``;return formatSubagentInput({description:e.remote.description,message:t,name:e.action.remoteAgentName,type:`remote`}).message}function trimTrailingSlash(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{cancelRemoteAgentTurn,isRetryableRemoteAgentCancelError,resolveRemoteAgentForAction,startRemoteAgentSession};
1
+ import{createEveCallbackRoutePath,createEveCancelTurnRoutePath}from"#protocol/routes.js";import{EVE_SESSION_ID_HEADER}from"#protocol/message.js";import{CancelTurnResponseSchema}from"#protocol/cancel-turn.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{formatSubagentInput,normalizeRequestedOutputSchema}from"#execution/subagent-invocation.js";var RemoteAgentCancelRequestError=class extends Error{retryable;constructor(e,t){super(e),this.name=`RemoteAgentCancelRequestError`,this.retryable=t.retryable}};async function startRemoteAgentSession(t){let r=t.callbackToken??t.session.continuationToken;if(!r)throw Error(`Cannot dispatch remote agent without a parent continuation token.`);if(!t.callbackBaseUrl)throw Error(`Cannot dispatch remote agent without a callback base URL.`);let a=buildForwardedPrincipalField(t),o={callback:{callId:t.action.callId,subagentName:t.action.remoteAgentName,token:r,url:createWorkflowCallbackUrl(t.callbackBaseUrl,createEveCallbackRoutePath(r))},message:formatRemoteAgentCallInputMessage({action:t.action,remote:t.remote}),mode:`task`,outputSchema:normalizeRequestedOutputSchema(t.action.input.outputSchema)??t.remote.outputSchema};a!==void 0&&(o.forwardedPrincipal=a);let s=await resolveRemoteAgentRequestHeaders(t.remote),c=await fetch(createRemoteAgentSessionUrl(t.remote),{body:JSON.stringify(o),headers:{"content-type":`application/json`,...s},method:`POST`});if(!c.ok)throw Error(`Remote agent "${t.action.remoteAgentName}" create-session request failed with HTTP ${c.status}.`);let l=c.headers.get(EVE_SESSION_ID_HEADER);if(l!==null&&l.length>0)return l;try{let e=await c.json();if(typeof e.sessionId==`string`&&e.sessionId.length>0)return e.sessionId}catch{}throw Error(`Remote agent "${t.action.remoteAgentName}" create-session response did not include a session id.`)}function buildForwardedPrincipalField(e){if(e.remote.forwardPrincipal!==!0||e.auth===null||e.auth===void 0)return;let t={current:e.auth};return e.initiatorAuth!==null&&e.initiatorAuth!==void 0&&(t.initiator=e.initiatorAuth),t}async function cancelRemoteAgentTurn(e){let t=await resolveRemoteAgentRequestHeaders(e.remote),n=await fetch(createRemoteAgentCancelTurnUrl(e.remote,e.sessionId),{headers:t,method:`POST`});if(!n.ok)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn request failed with HTTP ${n.status}.`,{retryable:isRetryableRemoteCancelStatus(n.status)});let i;try{i=await n.json()}catch{throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was not valid JSON.`,{retryable:!1})}let a=CancelTurnResponseSchema.safeParse(i);if(!a.success||a.data.sessionId!==e.sessionId)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was invalid.`,{retryable:!1});return{status:a.data.status}}function isRetryableRemoteAgentCancelError(e){return!(e instanceof RemoteAgentCancelRequestError)||e.retryable}function resolveRemoteAgentForAction(e){let t=e.registry.get(e.nodeId)?.definition;if(t?.kind!==`remote`)throw Error(`Missing remote agent "${e.remoteAgentName}" in runtime registry.`);return t}function createRemoteAgentSessionUrl(e){return createRemoteAgentRouteUrl(e.url,e.path)}function createRemoteAgentCancelTurnUrl(e,n){return createRemoteAgentRouteUrl(e.url,createEveCancelTurnRoutePath(n))}function createRemoteAgentRouteUrl(e,t){return new URL(t.replace(/^\/+/,``),`${trimTrailingSlash(e)}/`).toString()}function isRetryableRemoteCancelStatus(e){return e===408||e===425||e===429||e>=500}async function resolveRemoteAgentRequestHeaders(e){let t={};return e.headers!==void 0&&Object.assign(t,typeof e.headers==`function`?await e.headers():e.headers),e.auth!==void 0&&Object.assign(t,(await e.auth()).headers),t}function formatRemoteAgentCallInputMessage(e){let t=typeof e.action.input.message==`string`?e.action.input.message:``;return formatSubagentInput({description:e.remote.description,message:t,name:e.action.remoteAgentName,type:`remote`}).message}function trimTrailingSlash(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{cancelRemoteAgentTurn,isRetryableRemoteAgentCancelError,resolveRemoteAgentForAction,startRemoteAgentSession};
@@ -1 +1 @@
1
- import{truncateTail}from"#execution/sandbox/truncate-output.js";import{isEveDevEnvironment}from"#internal/application/optional-package-install.js";async function executeBashOnSandbox(t,n){let r=await runWithDevelopmentSandboxProgress(t,n.command),i=truncateTail(r.stdout),a=truncateTail(r.stderr),o=i.truncated||a.truncated,s=i.output;i.truncated&&(s=`[stdout truncated: showing last ${i.outputLines} of ${i.totalLines} lines]\n`+s);let c=a.output;return a.truncated&&(c=`[stderr truncated: showing last ${a.outputLines} of ${a.totalLines} lines]\n`+c),{exitCode:r.exitCode,stderr:c,stdout:s,truncated:o}}async function runWithDevelopmentSandboxProgress(e,n){if(logDevelopmentSandboxCommand(`eve: starting sandbox command: ${formatCommand(n)}`),!isEveDevEnvironment())return await e.run({command:n});let r=Date.now(),i=setInterval(()=>{logDevelopmentSandboxCommand(`eve: waiting for sandbox command (${Math.round((Date.now()-r)/1e3)}s elapsed): ${formatCommand(n)}`)},5e3);i.unref?.();try{let t=await e.run({command:n});return logDevelopmentSandboxCommand(`eve: sandbox command finished (exit ${t.exitCode}): ${formatCommand(n)}`),t}catch(e){throw logDevelopmentSandboxCommand(`eve: sandbox command failed: ${formatCommand(n)}`),e}finally{clearInterval(i)}}function logDevelopmentSandboxCommand(e){isEveDevEnvironment()&&console.log(e)}function formatCommand(e){let t=e.replaceAll(/\s+/g,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}export{executeBashOnSandbox};
1
+ import{isEveDevEnvironment}from"#internal/application/optional-package-install.js";import{truncateTail}from"#execution/sandbox/truncate-output.js";async function executeBashOnSandbox(e,n){let r=await runWithDevelopmentSandboxProgress(e,n.command),i=truncateTail(r.stdout),a=truncateTail(r.stderr),o=i.truncated||a.truncated,s=i.output;i.truncated&&(s=`[stdout truncated: showing last ${i.outputLines} of ${i.totalLines} lines]\n`+s);let c=a.output;return a.truncated&&(c=`[stderr truncated: showing last ${a.outputLines} of ${a.totalLines} lines]\n`+c),{exitCode:r.exitCode,stderr:c,stdout:s,truncated:o}}async function runWithDevelopmentSandboxProgress(t,n){if(logDevelopmentSandboxCommand(`eve: starting sandbox command: ${formatCommand(n)}`),!isEveDevEnvironment())return await t.run({command:n});let r=Date.now(),i=setInterval(()=>{logDevelopmentSandboxCommand(`eve: waiting for sandbox command (${Math.round((Date.now()-r)/1e3)}s elapsed): ${formatCommand(n)}`)},5e3);i.unref?.();try{let e=await t.run({command:n});return logDevelopmentSandboxCommand(`eve: sandbox command finished (exit ${e.exitCode}): ${formatCommand(n)}`),e}catch(e){throw logDevelopmentSandboxCommand(`eve: sandbox command failed: ${formatCommand(n)}`),e}finally{clearInterval(i)}}function logDevelopmentSandboxCommand(t){isEveDevEnvironment()&&console.log(t)}function formatCommand(e){let t=e.replaceAll(/\s+/g,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}export{executeBashOnSandbox};
@@ -1 +1 @@
1
- import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{buildDockerBaseSetupScript}from"#execution/sandbox/bindings/docker-base-setup.js";import{expectDockerSuccess}from"#execution/sandbox/bindings/docker-utils.js";import{withDevelopmentSandboxTags}from"#execution/sandbox/development-run.js";const DOCKER_SANDBOX_LABEL=`eve.sandbox`,DOCKER_KEEPALIVE_ARGS=[`-c`,`sleep 2147483647`];async function startDockerContainer(t){let i=[`run`,`-d`,`--name`,t.containerName,`--label`,`${DOCKER_SANDBOX_LABEL}=1`,`--label`,`${DOCKER_SANDBOX_LABEL}.role=${t.role}`];for(let[e,n]of Object.entries(withDevelopmentSandboxTags(t.tags)??{}))i.push(`--label`,`${DOCKER_SANDBOX_LABEL}.tag.${e}=${n}`);for(let[e,n]of Object.entries(t.options.env))i.push(`-e`,`${e}=${n}`);t.initialNetworkPolicy===`deny-all`&&i.push(`--network`,`none`),i.push(`--workdir`,WORKSPACE_ROOT,`--entrypoint`,`/bin/sh`,t.image,...DOCKER_KEEPALIVE_ARGS),expectDockerSuccess(await t.cli.run(i),`start sandbox container "${t.containerName}" from "${t.image}"`)}async function runDockerBaseSetup(e,r){expectDockerSuccess(await e.run([`exec`,`--user`,`root`,r,`/bin/sh`,`-c`,buildDockerBaseSetupScript()]),`prepare base runtime in sandbox container "${r}"`)}async function stopDockerContainerIfRunning(e,t){await e.run([`stop`,`-t`,`0`,t]).catch(()=>{})}export{DOCKER_SANDBOX_LABEL,runDockerBaseSetup,startDockerContainer,stopDockerContainerIfRunning};
1
+ import{withDevelopmentSandboxTags}from"#execution/sandbox/development-run.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{buildDockerBaseSetupScript}from"#execution/sandbox/bindings/docker-base-setup.js";import{expectDockerSuccess}from"#execution/sandbox/bindings/docker-utils.js";const DOCKER_SANDBOX_LABEL=`eve.sandbox`,DOCKER_KEEPALIVE_ARGS=[`-c`,`sleep 2147483647`];async function startDockerContainer(n){let i=[`run`,`-d`,`--name`,n.containerName,`--label`,`${DOCKER_SANDBOX_LABEL}=1`,`--label`,`${DOCKER_SANDBOX_LABEL}.role=${n.role}`];for(let[t,r]of Object.entries(withDevelopmentSandboxTags(n.tags)??{}))i.push(`--label`,`${DOCKER_SANDBOX_LABEL}.tag.${t}=${r}`);for(let[e,t]of Object.entries(n.options.env))i.push(`-e`,`${e}=${t}`);n.initialNetworkPolicy===`deny-all`&&i.push(`--network`,`none`),i.push(`--workdir`,WORKSPACE_ROOT,`--entrypoint`,`/bin/sh`,n.image,...DOCKER_KEEPALIVE_ARGS),expectDockerSuccess(await n.cli.run(i),`start sandbox container "${n.containerName}" from "${n.image}"`)}async function runDockerBaseSetup(e,t){expectDockerSuccess(await e.run([`exec`,`--user`,`root`,t,`/bin/sh`,`-c`,buildDockerBaseSetupScript()]),`prepare base runtime in sandbox container "${t}"`)}async function stopDockerContainerIfRunning(e,t){await e.run([`stop`,`-t`,`0`,t]).catch(()=>{})}export{DOCKER_SANDBOX_LABEL,runDockerBaseSetup,startDockerContainer,stopDockerContainerIfRunning};
@@ -1 +1 @@
1
- import{dirname}from"node:path";import{mkdir,rename,rm}from"node:fs/promises";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{randomUUID}from"node:crypto";import{withDevelopmentSandboxMetadataPathTag}from"#execution/sandbox/development-run.js";import{createFileBackedInternalSandboxSession,touchDirectory,writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-backend-utils.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{MICROSANDBOX_METADATA_VERSION,readSessionMetadata,readSessionMetadataRecord,readTemplateMetadata,resolveMicrosandboxMetadataPath,writeTemplateMetadata}from"#execution/sandbox/bindings/microsandbox-metadata.js";import{connectMicrosandbox,createPreparedMicrosandbox,createProviderName,doesPathExist,isMicrosandboxNotFoundError,loadMicrosandboxModule,removeSnapshotIfExists,sandboxExists,snapshotExists}from"#execution/sandbox/bindings/microsandbox-runtime.js";import{resolveMicrosandboxSessionRootPath,resolveMicrosandboxTemplateRootPath}from"#execution/sandbox/bindings/microsandbox-templates.js";const activeMicrosandboxSessionHandles=new Map;async function prewarmMicrosandboxTemplate(i){i.prewarmInput.log?.(`loading microsandbox runtime`);let a=await loadMicrosandboxModule({appRoot:i.prewarmInput.runtimeContext.appRoot,log:i.prewarmInput.log,options:i.options}),u=resolveMicrosandboxTemplateRootPath(resolveSandboxCacheDirectory(i.prewarmInput.runtimeContext.appRoot),i.prewarmInput.templateKey),f=resolveMicrosandboxMetadataPath(u);i.prewarmInput.log?.(`checking cached snapshot`);let p=await readTemplateMetadata(f);if(p?.optionsHash===i.optionsHash&&await snapshotExists(a,p.snapshotName))return i.prewarmInput.log?.(`reusing cached snapshot`),await touchDirectory(u),{reused:!0};let h=createProviderName(`eve-sbx-tpl`,i.prewarmInput.templateKey,i.optionsHash),_=`${u}.${randomUUID()}.tmp`,v=createProviderName(`eve-sbx-tpl-tmp`,`${i.prewarmInput.templateKey}:${randomUUID()}`);await removeSnapshotIfExists(a,h),await rm(_,{force:!0,recursive:!0}),await mkdir(_,{recursive:!0}),i.prewarmInput.log?.(`creating template VM from image "${i.options.image}"`);let y=await createPreparedMicrosandbox({log:i.prewarmInput.log,module:a,name:v,networkPolicy:i.options.networkPolicy,options:i.options,sessionKey:i.prewarmInput.templateKey,setupBaseRuntime:!0,tags:void 0}),b=buildSandboxSession(createMicrosandboxInternalSession(y),async e=>{await y.setNetworkPolicy(e)});try{i.prewarmInput.seedFiles.length>0&&i.prewarmInput.log?.(`writing ${i.prewarmInput.seedFiles.length} seed file(s)`),await writeSandboxSeedFiles(b,i.prewarmInput.seedFiles),i.prewarmInput.bootstrap!==void 0&&(i.prewarmInput.log?.(`running sandbox bootstrap`),await i.prewarmInput.bootstrap({use:async e=>(e?.networkPolicy!==void 0&&await y.setNetworkPolicy(e.networkPolicy),createLoggingSandboxSession({log:i.prewarmInput.log,session:b}))})),i.prewarmInput.log?.(`snapshotting template VM`),await y.stopAndSnapshot(h),await writeTemplateMetadata(resolveMicrosandboxMetadataPath(_),{optionsHash:i.optionsHash,snapshotName:h,version:MICROSANDBOX_METADATA_VERSION}),await mkdir(dirname(u),{recursive:!0}),await rm(u,{force:!0,recursive:!0});try{await rename(_,u)}catch(e){if(await doesPathExist(u))return{reused:!0};throw e}}finally{await y.removePersisted(),await rm(_,{force:!0,recursive:!0}).catch(()=>{})}return{reused:!1}}async function createMicrosandboxHandle(e){let t=await loadMicrosandboxModule({appRoot:e.createInput.runtimeContext.appRoot,options:e.options}),n=resolveSandboxCacheDirectory(e.createInput.runtimeContext.appRoot),r=resolveMicrosandboxSessionRootPath(n,e.createInput.sessionKey),a=createActiveMicrosandboxSessionKey(r,e.optionsHash),o=activeMicrosandboxSessionHandles.get(a);if(o!==void 0)return o;let s=resolveMicrosandboxMetadataPath(r),c=readSessionMetadataRecord(e.createInput.existingMetadata)??await readSessionMetadata(s),l=withDevelopmentSandboxMetadataPathTag(e.createInput.tags,s);if(c?.optionsHash===e.optionsHash&&(await sandboxExists(t,c.sandboxName)||c.stateSnapshotName!==void 0&&await snapshotExists(t,c.stateSnapshotName))){let n=await connectMicrosandbox({metadata:c,metadataPath:s,module:t,options:e.options,sessionKey:e.createInput.sessionKey,tags:l});if(n!==null)return cacheHandle(a,createHandle(n,e.backendName,e.optionsHash,()=>{activeMicrosandboxSessionHandles.delete(a)}))}let d=null;if(e.createInput.templateKey!==null){let r=await readTemplateMetadata(resolveMicrosandboxMetadataPath(resolveMicrosandboxTemplateRootPath(n,e.createInput.templateKey)));if(r===null||r.optionsHash!==e.optionsHash||!await snapshotExists(t,r.snapshotName))throw new SandboxTemplateNotProvisionedError({backendName:e.backendName,templateKey:e.createInput.templateKey});d=r.snapshotName}let m=createProviderName(`eve-sbx-ses`,`${e.createInput.sessionKey}:${randomUUID()}`),g;try{g=await createPreparedMicrosandbox({fromSnapshot:d??void 0,module:t,name:m,networkPolicy:e.options.networkPolicy,options:e.options,sessionKey:e.createInput.sessionKey,setupBaseRuntime:d===null,tags:l})}catch(t){throw d!==null&&e.createInput.templateKey!==null&&isMicrosandboxNotFoundError(t)?new SandboxTemplateNotProvisionedError({backendName:e.backendName,templateKey:e.createInput.templateKey}):t}return await g.writeMetadata(s,e.optionsHash),cacheHandle(a,createHandle(g,e.backendName,e.optionsHash,()=>{activeMicrosandboxSessionHandles.delete(a)}))}function createHandle(e,t,n,r){return{session:buildSandboxSession(createMicrosandboxInternalSession(e),async t=>{await e.setNetworkPolicy(t)}),useSessionFn:async t=>(t?.networkPolicy!==void 0&&await e.setNetworkPolicy(t.networkPolicy),buildSandboxSession(createMicrosandboxInternalSession(e),async t=>{await e.setNetworkPolicy(t)})),async captureState(){return{backendName:t,metadata:{...await e.captureState(n)},sessionKey:e.id}},async shutdown(){r?.(),await e.shutdown()}}}function createMicrosandboxInternalSession(e){return createFileBackedInternalSandboxSession({id:e.id,sandbox:e})}function createActiveMicrosandboxSessionKey(e,t){return`${e}\0${t}`}function cacheHandle(e,t){return activeMicrosandboxSessionHandles.set(e,t),t}function clearActiveMicrosandboxSessionHandlesForTest(){activeMicrosandboxSessionHandles.clear()}export{clearActiveMicrosandboxSessionHandlesForTest,createMicrosandboxHandle,prewarmMicrosandboxTemplate};
1
+ import{dirname}from"node:path";import{mkdir,rename,rm}from"node:fs/promises";import{withDevelopmentSandboxMetadataPathTag}from"#execution/sandbox/development-run.js";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{randomUUID}from"node:crypto";import{createFileBackedInternalSandboxSession,touchDirectory,writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-backend-utils.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{MICROSANDBOX_METADATA_VERSION,readSessionMetadata,readSessionMetadataRecord,readTemplateMetadata,resolveMicrosandboxMetadataPath,writeTemplateMetadata}from"#execution/sandbox/bindings/microsandbox-metadata.js";import{connectMicrosandbox,createPreparedMicrosandbox,createProviderName,doesPathExist,isMicrosandboxNotFoundError,loadMicrosandboxModule,removeSnapshotIfExists,sandboxExists,snapshotExists}from"#execution/sandbox/bindings/microsandbox-runtime.js";import{resolveMicrosandboxSessionRootPath,resolveMicrosandboxTemplateRootPath}from"#execution/sandbox/bindings/microsandbox-templates.js";const activeMicrosandboxSessionHandles=new Map;async function prewarmMicrosandboxTemplate(i){i.prewarmInput.log?.(`loading microsandbox runtime`);let a=await loadMicrosandboxModule({appRoot:i.prewarmInput.runtimeContext.appRoot,log:i.prewarmInput.log,options:i.options}),u=resolveMicrosandboxTemplateRootPath(resolveSandboxCacheDirectory(i.prewarmInput.runtimeContext.appRoot),i.prewarmInput.templateKey),f=resolveMicrosandboxMetadataPath(u);i.prewarmInput.log?.(`checking cached snapshot`);let p=await readTemplateMetadata(f);if(p?.optionsHash===i.optionsHash&&await snapshotExists(a,p.snapshotName))return i.prewarmInput.log?.(`reusing cached snapshot`),await touchDirectory(u),{reused:!0};let h=createProviderName(`eve-sbx-tpl`,i.prewarmInput.templateKey,i.optionsHash),_=`${u}.${randomUUID()}.tmp`,v=createProviderName(`eve-sbx-tpl-tmp`,`${i.prewarmInput.templateKey}:${randomUUID()}`);await removeSnapshotIfExists(a,h),await rm(_,{force:!0,recursive:!0}),await mkdir(_,{recursive:!0}),i.prewarmInput.log?.(`creating template VM from image "${i.options.image}"`);let y=await createPreparedMicrosandbox({log:i.prewarmInput.log,module:a,name:v,networkPolicy:i.options.networkPolicy,options:i.options,sessionKey:i.prewarmInput.templateKey,setupBaseRuntime:!0,tags:void 0}),b=buildSandboxSession(createMicrosandboxInternalSession(y),async e=>{await y.setNetworkPolicy(e)});try{i.prewarmInput.seedFiles.length>0&&i.prewarmInput.log?.(`writing ${i.prewarmInput.seedFiles.length} seed file(s)`),await writeSandboxSeedFiles(b,i.prewarmInput.seedFiles),i.prewarmInput.bootstrap!==void 0&&(i.prewarmInput.log?.(`running sandbox bootstrap`),await i.prewarmInput.bootstrap({use:async e=>(e?.networkPolicy!==void 0&&await y.setNetworkPolicy(e.networkPolicy),createLoggingSandboxSession({log:i.prewarmInput.log,session:b}))})),i.prewarmInput.log?.(`snapshotting template VM`),await y.stopAndSnapshot(h),await writeTemplateMetadata(resolveMicrosandboxMetadataPath(_),{optionsHash:i.optionsHash,snapshotName:h,version:MICROSANDBOX_METADATA_VERSION}),await mkdir(dirname(u),{recursive:!0}),await rm(u,{force:!0,recursive:!0});try{await rename(_,u)}catch(e){if(await doesPathExist(u))return{reused:!0};throw e}}finally{await y.removePersisted(),await rm(_,{force:!0,recursive:!0}).catch(()=>{})}return{reused:!1}}async function createMicrosandboxHandle(e){let t=await loadMicrosandboxModule({appRoot:e.createInput.runtimeContext.appRoot,options:e.options}),n=resolveSandboxCacheDirectory(e.createInput.runtimeContext.appRoot),r=resolveMicrosandboxSessionRootPath(n,e.createInput.sessionKey),a=createActiveMicrosandboxSessionKey(r,e.optionsHash),o=activeMicrosandboxSessionHandles.get(a);if(o!==void 0)return o;let s=resolveMicrosandboxMetadataPath(r),c=readSessionMetadataRecord(e.createInput.existingMetadata)??await readSessionMetadata(s),l=withDevelopmentSandboxMetadataPathTag(e.createInput.tags,s);if(c?.optionsHash===e.optionsHash&&(await sandboxExists(t,c.sandboxName)||c.stateSnapshotName!==void 0&&await snapshotExists(t,c.stateSnapshotName))){let n=await connectMicrosandbox({metadata:c,metadataPath:s,module:t,options:e.options,sessionKey:e.createInput.sessionKey,tags:l});if(n!==null)return cacheHandle(a,createHandle(n,e.backendName,e.optionsHash,()=>{activeMicrosandboxSessionHandles.delete(a)}))}let d=null;if(e.createInput.templateKey!==null){let r=await readTemplateMetadata(resolveMicrosandboxMetadataPath(resolveMicrosandboxTemplateRootPath(n,e.createInput.templateKey)));if(r===null||r.optionsHash!==e.optionsHash||!await snapshotExists(t,r.snapshotName))throw new SandboxTemplateNotProvisionedError({backendName:e.backendName,templateKey:e.createInput.templateKey});d=r.snapshotName}let m=createProviderName(`eve-sbx-ses`,`${e.createInput.sessionKey}:${randomUUID()}`),g;try{g=await createPreparedMicrosandbox({fromSnapshot:d??void 0,module:t,name:m,networkPolicy:e.options.networkPolicy,options:e.options,sessionKey:e.createInput.sessionKey,setupBaseRuntime:d===null,tags:l})}catch(t){throw d!==null&&e.createInput.templateKey!==null&&isMicrosandboxNotFoundError(t)?new SandboxTemplateNotProvisionedError({backendName:e.backendName,templateKey:e.createInput.templateKey}):t}return await g.writeMetadata(s,e.optionsHash),cacheHandle(a,createHandle(g,e.backendName,e.optionsHash,()=>{activeMicrosandboxSessionHandles.delete(a)}))}function createHandle(e,t,n,r){return{session:buildSandboxSession(createMicrosandboxInternalSession(e),async t=>{await e.setNetworkPolicy(t)}),useSessionFn:async t=>(t?.networkPolicy!==void 0&&await e.setNetworkPolicy(t.networkPolicy),buildSandboxSession(createMicrosandboxInternalSession(e),async t=>{await e.setNetworkPolicy(t)})),async captureState(){return{backendName:t,metadata:{...await e.captureState(n)},sessionKey:e.id}},async shutdown(){r?.(),await e.shutdown()}}}function createMicrosandboxInternalSession(e){return createFileBackedInternalSandboxSession({id:e.id,sandbox:e})}function createActiveMicrosandboxSessionKey(e,t){return`${e}\0${t}`}function cacheHandle(e,t){return activeMicrosandboxSessionHandles.set(e,t),t}function clearActiveMicrosandboxSessionHandlesForTest(){activeMicrosandboxSessionHandles.clear()}export{clearActiveMicrosandboxSessionHandlesForTest,createMicrosandboxHandle,prewarmMicrosandboxTemplate};
@@ -1 +1 @@
1
- import{posix}from"node:path";import{access}from"node:fs/promises";import{createHash,randomUUID}from"node:crypto";import{importInstalledEnginePackage,isEveDevEnvironment,loadOptionalEnginePackage}from"#internal/application/optional-package-install.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{withDevelopmentSandboxTags}from"#execution/sandbox/development-run.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{assertMicrosandboxPlatformCandidate,ensureMicrosandboxBaseRuntime}from"#execution/sandbox/bindings/microsandbox-platform.js";import{MICROSANDBOX_METADATA_VERSION,writeSessionMetadata}from"#execution/sandbox/bindings/microsandbox-metadata.js";import{MICROSANDBOX_USER}from"#execution/sandbox/bindings/microsandbox-options.js";import{createMicrosandboxWithProgress}from"#execution/sandbox/bindings/microsandbox-create.js";import{applyMicrosandboxNetwork,createMicrosandboxNetworkPlan,createTransformBrokerEnvironment}from"#execution/sandbox/bindings/microsandbox-network.js";import{adaptMicrosandboxExecToSandboxProcess}from"#execution/sandbox/bindings/microsandbox-process.js";import{isMicrosandboxNotFoundError,isMicrosandboxNotFoundError as isMicrosandboxNotFoundError$1,isMicrosandboxSnapshotSourceRunningError,isMicrosandboxStillRunningError,removeSnapshotIfExists,removeSnapshotIfExists as removeSnapshotIfExists$1,sandboxExists,snapshotExists,snapshotExists as snapshotExists$1}from"#execution/sandbox/bindings/microsandbox-provider-state.js";const MICROSANDBOX_PACKAGE_NAME=`microsandbox`,MICROSANDBOX_STOP_TIMEOUT_MS=1e4;var MicrosandboxVm=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a,o){this.#e=e,this.#i=t,this.#a=n,this.#n=r,this.#t=i,this.#r=a,this.#o=o}get id(){return this.#e.sessionKey}async captureState(e){if(this.#r=e,isEveDevEnvironment())return this.#t!==void 0&&await this.writeMetadata(this.#t,e),{networkPolicy:this.#n,optionsHash:e,sandboxName:this.#a,stateSnapshotName:this.#o,version:MICROSANDBOX_METADATA_VERSION};let t=this.#o,n=createProviderName(`eve-sbx-state`,`${this.#e.sessionKey}:${randomUUID()}`);return await this.stopAndSnapshot(n),this.#o=n,this.#t!==void 0&&await this.writeMetadata(this.#t,e),t!==void 0&&await removeSnapshotIfExists$1(this.#e.module,t),{networkPolicy:this.#n,optionsHash:e,sandboxName:this.#a,stateSnapshotName:n,version:MICROSANDBOX_METADATA_VERSION}}async detach(){await this.#i.detach().catch(()=>{})}async shutdown(){await this.#i.stop().catch(()=>{}),await this.detach()}async readFileBytes(e){try{let t=this.#i.fs();return await t.exists(e)?Buffer.from(await t.read(e)):null}catch{return null}}async removePath(e){let t=`${e.force===!0?`f`:``}${e.recursive===!0?`r`:``}`,n=`${t.length>0?`rm -${t}`:`rm`} -- ${shellQuote(e.path)}`;await this.runInternalCommand({abortSignal:e.abortSignal,command:n,user:MICROSANDBOX_USER})}async removePersisted(){await removeSandboxIfExists(this.#e.module,this.#a),this.#o!==void 0&&await removeSnapshotIfExists$1(this.#e.module,this.#o)}async setNetworkPolicy(e){let t=this.#o,n=createProviderName(`eve-sbx-state`,`${this.#e.sessionKey}:${randomUUID()}`),i=this.#a;await this.stopAndSnapshot(n),await removeSandboxIfExists(this.#e.module,i);let a=createProviderName(`eve-sbx-ses`,`${this.#e.sessionKey}:${randomUUID()}`);this.#i=await createMicrosandbox({fromSnapshot:n,module:this.#e.module,name:a,networkPolicy:e,options:this.#e.options,tags:this.#e.tags,user:MICROSANDBOX_USER,workdir:WORKSPACE_ROOT}),this.#a=a,this.#n=e,this.#o=void 0,this.#t!==void 0&&this.#r!==void 0&&await this.writeMetadata(this.#t,this.#r),await removeSnapshotIfExists$1(this.#e.module,n),t!==void 0&&await removeSnapshotIfExists$1(this.#e.module,t)}async spawn(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t={...this.#e.options.env,...createTransformBrokerEnvironment(createMicrosandboxNetworkPlan(this.#n)),...e.env},n=await this.#i.execStreamWith(`bash`,n=>n.args([`-lc`,e.command]).cwd(e.workingDirectory??WORKSPACE_ROOT).envs(t).user(MICROSANDBOX_USER));return e.abortSignal!==void 0&&e.abortSignal.addEventListener(`abort`,()=>{n.kill().catch(()=>{})},{once:!0}),adaptMicrosandboxExecToSandboxProcess(n)}async stopAndSnapshot(e){await this.#i.stop().catch(()=>{}),await stopAndSnapshotMicrosandboxSandbox(this.#e.module,this.#a,e)}async writeFiles(t){let n=this.#i.fs();for(let r of t){let t=posix.dirname(r.path);await this.runInternalCommand({command:`mkdir -p ${shellQuote(t)}`,user:MICROSANDBOX_USER}),await n.write(r.path,r.content),await this.runInternalCommand({command:`chown ${MICROSANDBOX_USER}:${MICROSANDBOX_USER} ${shellQuote(r.path)}`,user:`root`})}}async writeMetadata(e,t){this.#t=e,this.#r=t,await writeSessionMetadata(e,{networkPolicy:this.#n,optionsHash:t,sandboxName:this.#a,stateSnapshotName:this.#o,version:MICROSANDBOX_METADATA_VERSION})}async runInternalCommand(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=await this.#i.execWith(`bash`,t=>t.args([`-lc`,e.command]).cwd(WORKSPACE_ROOT).user(e.user));if(t.code!==0){let n=e.failureMessage??`Microsandbox command failed.`;throw Error(`${n} ${t.stderr()}`.trim())}}};async function createPreparedMicrosandbox(e){let t=e.setupBaseRuntime?`allow-all`:e.networkPolicy,n=await createMicrosandbox({fromSnapshot:e.fromSnapshot,log:e.log,module:e.module,name:e.name,networkPolicy:t,options:e.options,tags:e.tags,user:e.setupBaseRuntime?void 0:MICROSANDBOX_USER,workdir:e.setupBaseRuntime?`/`:WORKSPACE_ROOT}),r=new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,e.name,t);return e.setupBaseRuntime&&(await withProgressHeartbeat(`preparing base runtime inside VM`,e.log,async()=>{await ensureMicrosandboxBaseRuntime(n,{log:e.log})}),e.networkPolicy!==void 0&&e.networkPolicy!==`allow-all`&&(e.log?.(`applying network policy`),await r.setNetworkPolicy(e.networkPolicy))),r}async function connectMicrosandbox(e){let t;try{t=await e.module.Sandbox.get(e.metadata.sandboxName)}catch(t){if(!isMicrosandboxNotFoundError$1(t))throw t;return e.metadata.stateSnapshotName===void 0?null:await restoreMicrosandboxSessionSnapshot(e)}if(t.status!==`running`&&t.status!==`draining`&&e.metadata.stateSnapshotName!==void 0)return await restoreMicrosandboxSessionSnapshot(e);let n=t.status===`running`||t.status===`draining`?await t.connectWithTimeout(1e4):await t.startDetached();return new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,e.metadata.sandboxName,e.metadata.networkPolicy,e.metadataPath,e.metadata.optionsHash,e.metadata.stateSnapshotName)}async function restoreMicrosandboxSessionSnapshot(e){if(e.metadata.stateSnapshotName===void 0||!await snapshotExists$1(e.module,e.metadata.stateSnapshotName))return null;let t=createProviderName(`eve-sbx-ses`,`${e.sessionKey}:${randomUUID()}`),n=await createMicrosandbox({fromSnapshot:e.metadata.stateSnapshotName,module:e.module,name:t,networkPolicy:e.metadata.networkPolicy,options:e.options,tags:e.tags,user:MICROSANDBOX_USER,workdir:WORKSPACE_ROOT});await removeSandboxIfExists(e.module,e.metadata.sandboxName);let i=new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,t,e.metadata.networkPolicy,e.metadataPath,e.metadata.optionsHash,e.metadata.stateSnapshotName);return await i.writeMetadata(e.metadataPath,e.metadata.optionsHash),i}async function loadMicrosandboxModule(e){e.log?.(`checking microsandbox platform support`),await assertMicrosandboxPlatformCandidate();let t=await withProgressHeartbeat(`loading microsandbox npm package`,e.log,()=>loadOptionalEnginePackage({appRoot:e.appRoot,autoInstall:e.options.setup.autoInstall,importModule:async()=>await import(`microsandbox`),missingMessage:"The microsandbox sandbox backend requires the `microsandbox` package, which is not bundled with eve. Install it in your application (for example `pnpm add -D microsandbox`), or use docker() / vercel() instead.",packageName:MICROSANDBOX_PACKAGE_NAME}));if(e.log?.(`checking microsandbox VM runtime`),!t.isInstalled()){if(!e.options.setup.autoInstall||!isEveDevEnvironment())throw Error("The microsandbox VM runtime is not installed. Run `npx microsandbox install`, set MSB_PATH for a custom install, or let `eve dev` install it automatically with microsandbox({ setup: { autoInstall: true } }).");await withProgressHeartbeat(`installing microsandbox VM runtime`,e.log,async()=>{await t.setup().skipVerify(e.options.setup.skipVerify).install()})}return e.log?.(`microsandbox runtime ready`),t}async function withProgressHeartbeat(e,t,n){if(t?.(e),t===void 0)return await n();let r=Date.now(),i=setInterval(()=>{t(`${e} (${Math.round((Date.now()-r)/1e3)}s elapsed)`)},1e4);i.unref?.();try{return await n()}finally{clearInterval(i)}}async function loadMicrosandboxWithoutInstall(e){try{let t=await importInstalledEnginePackage({appRoot:e,packageName:MICROSANDBOX_PACKAGE_NAME});return t.isInstalled()?t:null}catch{return null}}async function stopAndSnapshotMicrosandboxSandbox(e,t,n){for(let r=0;r<3;r+=1){let i=await e.Sandbox.get(t);await i.stopWithTimeout(r===0?MICROSANDBOX_STOP_TIMEOUT_MS:0).catch(()=>{});try{await i.snapshot(n);return}catch(e){if(!isMicrosandboxSnapshotSourceRunningError(e)||r===2)throw e;await i.kill().catch(()=>{}),await new Promise(e=>setTimeout(e,250))}}}function createProviderName(e,t,n=``){return`${e}-${createStableHash(`${t}:${n}`).slice(0,32)}`}function createStableHash(e){return createHash(`sha256`).update(e).digest(`hex`)}async function doesPathExist(e){try{return await access(e),!0}catch{return!1}}async function createMicrosandbox(e){let t=e.module.Sandbox.builder(e.name).cpus(e.options.cpus).detached(!0).envs(e.options.env).labels(resolveMicrosandboxLabels(e.tags)).memory(e.options.memoryMiB).pullPolicy(e.options.pullPolicy).replace().workdir(e.workdir);t=e.fromSnapshot===void 0?t.image(e.options.image):t.fromSnapshot(e.fromSnapshot),e.user!==void 0&&(t=t.user(e.user));let n=e.fromSnapshot===void 0?`image "${e.options.image}"`:`snapshot "${e.fromSnapshot}"`;return await createMicrosandboxWithProgress({builder:applyMicrosandboxNetwork(t,e.networkPolicy),errorType:e.module.MicrosandboxError,log:e.log,source:n})}async function removeSandboxIfExists(e,t){for(let n=0;n<3;n+=1)try{let r=await e.Sandbox.get(t);await r.stopWithTimeout(n===0?MICROSANDBOX_STOP_TIMEOUT_MS:0).catch(()=>{}),await r.remove();return}catch(r){if(isMicrosandboxNotFoundError$1(r))return;if(isMicrosandboxStillRunningError(r)&&n<2){await(await e.Sandbox.get(t).catch(()=>null))?.kill().catch(()=>{}),await new Promise(e=>setTimeout(e,250));continue}throw r}}function resolveMicrosandboxLabels(e){return{"eve.backend":`microsandbox`,...withDevelopmentSandboxTags(e)}}export{MicrosandboxVm,connectMicrosandbox,createPreparedMicrosandbox,createProviderName,createStableHash,doesPathExist,isMicrosandboxNotFoundError,loadMicrosandboxModule,loadMicrosandboxWithoutInstall,removeSnapshotIfExists,sandboxExists,snapshotExists,stopAndSnapshotMicrosandboxSandbox};
1
+ import{posix}from"node:path";import{access}from"node:fs/promises";import{withDevelopmentSandboxTags}from"#execution/sandbox/development-run.js";import{importInstalledEnginePackage,isEveDevEnvironment,loadOptionalEnginePackage}from"#internal/application/optional-package-install.js";import{createHash,randomUUID}from"node:crypto";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{assertMicrosandboxPlatformCandidate,ensureMicrosandboxBaseRuntime}from"#execution/sandbox/bindings/microsandbox-platform.js";import{MICROSANDBOX_METADATA_VERSION,writeSessionMetadata}from"#execution/sandbox/bindings/microsandbox-metadata.js";import{MICROSANDBOX_USER}from"#execution/sandbox/bindings/microsandbox-options.js";import{createMicrosandboxWithProgress}from"#execution/sandbox/bindings/microsandbox-create.js";import{applyMicrosandboxNetwork,createMicrosandboxNetworkPlan,createTransformBrokerEnvironment}from"#execution/sandbox/bindings/microsandbox-network.js";import{adaptMicrosandboxExecToSandboxProcess}from"#execution/sandbox/bindings/microsandbox-process.js";import{isMicrosandboxNotFoundError,isMicrosandboxNotFoundError as isMicrosandboxNotFoundError$1,isMicrosandboxSnapshotSourceRunningError,isMicrosandboxStillRunningError,removeSnapshotIfExists,removeSnapshotIfExists as removeSnapshotIfExists$1,sandboxExists,snapshotExists,snapshotExists as snapshotExists$1}from"#execution/sandbox/bindings/microsandbox-provider-state.js";const MICROSANDBOX_PACKAGE_NAME=`microsandbox`,MICROSANDBOX_STOP_TIMEOUT_MS=1e4;var MicrosandboxVm=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a,o){this.#e=e,this.#i=t,this.#a=n,this.#n=r,this.#t=i,this.#r=a,this.#o=o}get id(){return this.#e.sessionKey}async captureState(e){if(this.#r=e,isEveDevEnvironment())return this.#t!==void 0&&await this.writeMetadata(this.#t,e),{networkPolicy:this.#n,optionsHash:e,sandboxName:this.#a,stateSnapshotName:this.#o,version:MICROSANDBOX_METADATA_VERSION};let t=this.#o,n=createProviderName(`eve-sbx-state`,`${this.#e.sessionKey}:${randomUUID()}`);return await this.stopAndSnapshot(n),this.#o=n,this.#t!==void 0&&await this.writeMetadata(this.#t,e),t!==void 0&&await removeSnapshotIfExists$1(this.#e.module,t),{networkPolicy:this.#n,optionsHash:e,sandboxName:this.#a,stateSnapshotName:n,version:MICROSANDBOX_METADATA_VERSION}}async detach(){await this.#i.detach().catch(()=>{})}async shutdown(){await this.#i.stop().catch(()=>{}),await this.detach()}async readFileBytes(e){try{let t=this.#i.fs();return await t.exists(e)?Buffer.from(await t.read(e)):null}catch{return null}}async removePath(e){let t=`${e.force===!0?`f`:``}${e.recursive===!0?`r`:``}`,n=`${t.length>0?`rm -${t}`:`rm`} -- ${shellQuote(e.path)}`;await this.runInternalCommand({abortSignal:e.abortSignal,command:n,user:MICROSANDBOX_USER})}async removePersisted(){await removeSandboxIfExists(this.#e.module,this.#a),this.#o!==void 0&&await removeSnapshotIfExists$1(this.#e.module,this.#o)}async setNetworkPolicy(e){let t=this.#o,n=createProviderName(`eve-sbx-state`,`${this.#e.sessionKey}:${randomUUID()}`),r=this.#a;await this.stopAndSnapshot(n),await removeSandboxIfExists(this.#e.module,r);let i=createProviderName(`eve-sbx-ses`,`${this.#e.sessionKey}:${randomUUID()}`);this.#i=await createMicrosandbox({fromSnapshot:n,module:this.#e.module,name:i,networkPolicy:e,options:this.#e.options,tags:this.#e.tags,user:MICROSANDBOX_USER,workdir:WORKSPACE_ROOT}),this.#a=i,this.#n=e,this.#o=void 0,this.#t!==void 0&&this.#r!==void 0&&await this.writeMetadata(this.#t,this.#r),await removeSnapshotIfExists$1(this.#e.module,n),t!==void 0&&await removeSnapshotIfExists$1(this.#e.module,t)}async spawn(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t={...this.#e.options.env,...createTransformBrokerEnvironment(createMicrosandboxNetworkPlan(this.#n)),...e.env},n=await this.#i.execStreamWith(`bash`,n=>n.args([`-lc`,e.command]).cwd(e.workingDirectory??WORKSPACE_ROOT).envs(t).user(MICROSANDBOX_USER));return e.abortSignal!==void 0&&e.abortSignal.addEventListener(`abort`,()=>{n.kill().catch(()=>{})},{once:!0}),adaptMicrosandboxExecToSandboxProcess(n)}async stopAndSnapshot(e){await this.#i.stop().catch(()=>{}),await stopAndSnapshotMicrosandboxSandbox(this.#e.module,this.#a,e)}async writeFiles(t){let n=this.#i.fs();for(let r of t){let t=posix.dirname(r.path);await this.runInternalCommand({command:`mkdir -p ${shellQuote(t)}`,user:MICROSANDBOX_USER}),await n.write(r.path,r.content),await this.runInternalCommand({command:`chown ${MICROSANDBOX_USER}:${MICROSANDBOX_USER} ${shellQuote(r.path)}`,user:`root`})}}async writeMetadata(e,t){this.#t=e,this.#r=t,await writeSessionMetadata(e,{networkPolicy:this.#n,optionsHash:t,sandboxName:this.#a,stateSnapshotName:this.#o,version:MICROSANDBOX_METADATA_VERSION})}async runInternalCommand(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=await this.#i.execWith(`bash`,t=>t.args([`-lc`,e.command]).cwd(WORKSPACE_ROOT).user(e.user));if(t.code!==0){let n=e.failureMessage??`Microsandbox command failed.`;throw Error(`${n} ${t.stderr()}`.trim())}}};async function createPreparedMicrosandbox(e){let t=e.setupBaseRuntime?`allow-all`:e.networkPolicy,n=await createMicrosandbox({fromSnapshot:e.fromSnapshot,log:e.log,module:e.module,name:e.name,networkPolicy:t,options:e.options,tags:e.tags,user:e.setupBaseRuntime?void 0:MICROSANDBOX_USER,workdir:e.setupBaseRuntime?`/`:WORKSPACE_ROOT}),r=new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,e.name,t);return e.setupBaseRuntime&&(await withProgressHeartbeat(`preparing base runtime inside VM`,e.log,async()=>{await ensureMicrosandboxBaseRuntime(n,{log:e.log})}),e.networkPolicy!==void 0&&e.networkPolicy!==`allow-all`&&(e.log?.(`applying network policy`),await r.setNetworkPolicy(e.networkPolicy))),r}async function connectMicrosandbox(e){let t;try{t=await e.module.Sandbox.get(e.metadata.sandboxName)}catch(t){if(!isMicrosandboxNotFoundError$1(t))throw t;return e.metadata.stateSnapshotName===void 0?null:await restoreMicrosandboxSessionSnapshot(e)}if(t.status!==`running`&&t.status!==`draining`&&e.metadata.stateSnapshotName!==void 0)return await restoreMicrosandboxSessionSnapshot(e);let n=t.status===`running`||t.status===`draining`?await t.connectWithTimeout(1e4):await t.startDetached();return new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,e.metadata.sandboxName,e.metadata.networkPolicy,e.metadataPath,e.metadata.optionsHash,e.metadata.stateSnapshotName)}async function restoreMicrosandboxSessionSnapshot(e){if(e.metadata.stateSnapshotName===void 0||!await snapshotExists$1(e.module,e.metadata.stateSnapshotName))return null;let t=createProviderName(`eve-sbx-ses`,`${e.sessionKey}:${randomUUID()}`),n=await createMicrosandbox({fromSnapshot:e.metadata.stateSnapshotName,module:e.module,name:t,networkPolicy:e.metadata.networkPolicy,options:e.options,tags:e.tags,user:MICROSANDBOX_USER,workdir:WORKSPACE_ROOT});await removeSandboxIfExists(e.module,e.metadata.sandboxName);let r=new MicrosandboxVm({module:e.module,options:e.options,sessionKey:e.sessionKey,tags:e.tags},n,t,e.metadata.networkPolicy,e.metadataPath,e.metadata.optionsHash,e.metadata.stateSnapshotName);return await r.writeMetadata(e.metadataPath,e.metadata.optionsHash),r}async function loadMicrosandboxModule(e){e.log?.(`checking microsandbox platform support`),await assertMicrosandboxPlatformCandidate();let t=await withProgressHeartbeat(`loading microsandbox npm package`,e.log,()=>loadOptionalEnginePackage({appRoot:e.appRoot,autoInstall:e.options.setup.autoInstall,importModule:async()=>await import(`microsandbox`),missingMessage:"The microsandbox sandbox backend requires the `microsandbox` package, which is not bundled with eve. Install it in your application (for example `pnpm add -D microsandbox`), or use docker() / vercel() instead.",packageName:MICROSANDBOX_PACKAGE_NAME}));if(e.log?.(`checking microsandbox VM runtime`),!t.isInstalled()){if(!e.options.setup.autoInstall||!isEveDevEnvironment())throw Error("The microsandbox VM runtime is not installed. Run `npx microsandbox install`, set MSB_PATH for a custom install, or let `eve dev` install it automatically with microsandbox({ setup: { autoInstall: true } }).");await withProgressHeartbeat(`installing microsandbox VM runtime`,e.log,async()=>{await t.setup().skipVerify(e.options.setup.skipVerify).install()})}return e.log?.(`microsandbox runtime ready`),t}async function withProgressHeartbeat(e,t,n){if(t?.(e),t===void 0)return await n();let r=Date.now(),i=setInterval(()=>{t(`${e} (${Math.round((Date.now()-r)/1e3)}s elapsed)`)},1e4);i.unref?.();try{return await n()}finally{clearInterval(i)}}async function loadMicrosandboxWithoutInstall(e){try{let t=await importInstalledEnginePackage({appRoot:e,packageName:MICROSANDBOX_PACKAGE_NAME});return t.isInstalled()?t:null}catch{return null}}async function stopAndSnapshotMicrosandboxSandbox(e,t,n){for(let r=0;r<3;r+=1){let i=await e.Sandbox.get(t);await i.stopWithTimeout(r===0?MICROSANDBOX_STOP_TIMEOUT_MS:0).catch(()=>{});try{await i.snapshot(n);return}catch(e){if(!isMicrosandboxSnapshotSourceRunningError(e)||r===2)throw e;await i.kill().catch(()=>{}),await new Promise(e=>setTimeout(e,250))}}}function createProviderName(e,t,n=``){return`${e}-${createStableHash(`${t}:${n}`).slice(0,32)}`}function createStableHash(e){return createHash(`sha256`).update(e).digest(`hex`)}async function doesPathExist(e){try{return await access(e),!0}catch{return!1}}async function createMicrosandbox(e){let t=e.module.Sandbox.builder(e.name).cpus(e.options.cpus).detached(!0).envs(e.options.env).labels(resolveMicrosandboxLabels(e.tags)).memory(e.options.memoryMiB).pullPolicy(e.options.pullPolicy).replace().workdir(e.workdir);t=e.fromSnapshot===void 0?t.image(e.options.image):t.fromSnapshot(e.fromSnapshot),e.user!==void 0&&(t=t.user(e.user));let n=e.fromSnapshot===void 0?`image "${e.options.image}"`:`snapshot "${e.fromSnapshot}"`;return await createMicrosandboxWithProgress({builder:applyMicrosandboxNetwork(t,e.networkPolicy),errorType:e.module.MicrosandboxError,log:e.log,source:n})}async function removeSandboxIfExists(e,t){for(let n=0;n<3;n+=1)try{let r=await e.Sandbox.get(t);await r.stopWithTimeout(n===0?MICROSANDBOX_STOP_TIMEOUT_MS:0).catch(()=>{}),await r.remove();return}catch(r){if(isMicrosandboxNotFoundError$1(r))return;if(isMicrosandboxStillRunningError(r)&&n<2){await(await e.Sandbox.get(t).catch(()=>null))?.kill().catch(()=>{}),await new Promise(e=>setTimeout(e,250));continue}throw r}}function resolveMicrosandboxLabels(e){return{"eve.backend":`microsandbox`,...withDevelopmentSandboxTags(e)}}export{MicrosandboxVm,connectMicrosandbox,createPreparedMicrosandbox,createProviderName,createStableHash,doesPathExist,isMicrosandboxNotFoundError,loadMicrosandboxModule,loadMicrosandboxWithoutInstall,removeSnapshotIfExists,sandboxExists,snapshotExists,stopAndSnapshotMicrosandboxSandbox};