eve 0.82.0 → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/NOTICE +1 -1
- package/dist/src/channel/pending-authorization.d.ts +5 -0
- package/dist/src/channel/pending-authorization.js +1 -1
- package/dist/src/channel/session.d.ts +2 -0
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +5 -0
- package/dist/src/chunks/{use-eve-agent-DlznYwQk.js → use-eve-agent-3-WRmJkd.js} +40 -5
- package/dist/src/chunks/{use-eve-agent-DTu78IAF.js → use-eve-agent-Ci5dr0aR.js} +40 -5
- package/dist/src/cli/dev/local-server-child.js +1 -1
- package/dist/src/cli/dev/local-server-cleanup.js +1 -1
- package/dist/src/cli/dev/tui/question-panel.d.ts +4 -1
- package/dist/src/cli/dev/tui/question-panel.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +4 -4
- package/dist/src/client/eve-agent-store.d.ts +1 -1
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/index.d.ts +1 -0
- package/dist/src/client/session-controls.d.ts +6 -0
- package/dist/src/client/session-controls.js +1 -1
- package/dist/src/client/session.d.ts +4 -0
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +8 -8
- package/dist/src/compiled/@eve/catalog/index.js +1 -1
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.d.ts +5 -3
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +1 -37
- package/dist/src/compiled/@workflow/core/runtime/event-limit-warning.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +5 -6
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +16 -0
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +15 -18
- package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +20 -0
- package/dist/src/compiled/@workflow/core/runtime.js +4 -4
- package/dist/src/compiled/@workflow/core/seeded-nanoid.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +14 -3
- package/dist/src/compiled/@workflow/core/serialization.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization.js +1 -1
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +0 -18
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +48 -0
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/env-config.d.ts +24 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +126 -7
- package/dist/src/compiled/@workflow/world/index.d.ts +3 -3
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +59 -8
- package/dist/src/compiled/@workflow/world/queue.d.ts +71 -9
- package/dist/src/compiled/@workflow/world/recovery.d.ts +6 -0
- package/dist/src/compiled/@workflow/world/test-support/duplicate-event-fixtures.d.ts +3 -0
- package/dist/src/compiled/@workflow/world/test-support/in-band-fence-conformance.d.ts +46 -0
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +18 -18
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-BW-kbMMn.js → attribute-changes-7se_SE2q.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/dist-CcnNPAp4.js +1 -0
- package/dist/src/compiled/_chunks/workflow/dist-S9cZRway.js +3 -0
- package/dist/src/compiled/_chunks/workflow/helpers-CxNRXH0a.js +1 -0
- package/dist/src/compiled/_chunks/workflow/private-DLYTSBbu.js +1 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-CPiIfe8r.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{run-DzdAqdb1.js → run-BJSLCXR4.js} +6 -6
- package/dist/src/compiled/_chunks/workflow/serialization-B9gneT9Z.js +15 -0
- package/dist/src/compiled/_chunks/workflow/sleep-BL0oQs3R.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{wait-until-xbRRDuUf.js → wait-until-BPou0RGO.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/workflow-routes-BaljomCk.js +1 -0
- package/dist/src/compiled/{@ai-sdk/code-mode → run}/LICENSE +1 -1
- package/dist/src/compiled/run/index.d.ts +384 -0
- package/dist/src/compiled/run/index.js +650 -0
- package/dist/src/compiler/extension-compatibility.d.ts +21 -14
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-sandbox.js +1 -1
- package/dist/src/compiler/workspace-resources.js +1 -1
- package/dist/src/context/build-callback-context.js +1 -1
- package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
- package/dist/src/context/providers/sandbox.js +1 -1
- package/dist/src/discover/extension-specifier.d.ts +1 -0
- package/dist/src/discover/extension-specifier.js +1 -1
- package/dist/src/evals/cli/eval.js +2 -2
- package/dist/src/evals/runner/artifacts.js +1 -1
- package/dist/src/evals/runner/derive-run-facts.d.ts +12 -0
- package/dist/src/evals/runner/derive-run-facts.js +1 -1
- package/dist/src/evals/runner/execute-task.js +1 -1
- package/dist/src/evals/types.d.ts +3 -2
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.d.ts +0 -1
- package/dist/src/eve-channel/request.js +2 -2
- package/dist/src/execution/agent-sessions/context.d.ts +1 -1
- package/dist/src/execution/agent-sessions/context.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +3 -0
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/dynamic-workflow/program-step.d.ts +7 -7
- package/dist/src/execution/dynamic-workflow/program-step.js +1 -1
- package/dist/src/execution/dynamic-workflow/schema.d.ts +18 -11
- package/dist/src/execution/dynamic-workflow/schema.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/dynamic-workflow/workflow.js +1 -1
- package/dist/src/execution/eve-workflow-attributes.d.ts +3 -1
- package/dist/src/execution/eve-workflow-attributes.js +1 -1
- package/dist/src/execution/invoke-tool.js +1 -1
- package/dist/src/execution/sandbox/abort-bound-session.js +1 -1
- package/dist/src/execution/sandbox/active-connections.d.ts +28 -0
- package/dist/src/execution/sandbox/active-connections.js +1 -0
- package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +10 -2
- package/dist/src/execution/sandbox/bindings/docker-cli.js +2 -2
- package/dist/src/execution/sandbox/bindings/docker-connection.d.ts +15 -0
- package/dist/src/execution/sandbox/bindings/docker-connection.js +2 -0
- package/dist/src/execution/sandbox/bindings/docker-container.d.ts +2 -0
- package/dist/src/execution/sandbox/bindings/docker-container.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-network.d.ts +5 -0
- package/dist/src/execution/sandbox/bindings/docker-network.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-templates.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker.d.ts +12 -15
- package/dist/src/execution/sandbox/bindings/docker.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.d.ts +19 -29
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.d.ts +2 -4
- package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
- package/dist/src/execution/sandbox/bindings/local-provider-utils.d.ts +0 -20
- package/dist/src/execution/sandbox/bindings/local-provider-utils.js +1 -1
- package/dist/src/execution/sandbox/bindings/local.d.ts +4 -6
- package/dist/src/execution/sandbox/bindings/local.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-base-runtime.d.ts +2 -0
- package/dist/src/execution/sandbox/bindings/vercel-base-runtime.js +2 -2
- package/dist/src/execution/sandbox/bindings/vercel-errors.js +2 -2
- package/dist/src/execution/sandbox/bindings/vercel-lifecycle.d.ts +7 -5
- package/dist/src/execution/sandbox/bindings/vercel-lifecycle.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +5 -11
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -2
- package/dist/src/execution/sandbox/development-cleanup.d.ts +0 -1
- package/dist/src/execution/sandbox/development-cleanup.js +1 -1
- package/dist/src/execution/sandbox/development-lazy-prewarm.js +1 -1
- package/dist/src/execution/sandbox/development-run.d.ts +0 -2
- package/dist/src/execution/sandbox/development-run.js +1 -1
- package/dist/src/execution/sandbox/dockerfile.d.ts +0 -4
- package/dist/src/execution/sandbox/dockerfile.js +1 -1
- package/dist/src/execution/sandbox/ensure.d.ts +23 -11
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/sandbox/glob-tool.js +3 -3
- package/dist/src/execution/sandbox/grep-tool.js +1 -1
- package/dist/src/execution/sandbox/logging-session.js +1 -1
- package/dist/src/execution/sandbox/prewarm.d.ts +23 -3
- package/dist/src/execution/sandbox/prewarm.js +2 -1
- package/dist/src/execution/sandbox/read-file.js +1 -1
- package/dist/src/execution/sandbox/require-sandbox.d.ts +3 -2
- package/dist/src/execution/sandbox/require-sandbox.js +1 -1
- package/dist/src/execution/sandbox/ripgrep-probe.js +1 -1
- package/dist/src/execution/sandbox/session.d.ts +10 -20
- package/dist/src/execution/sandbox/session.js +2 -2
- package/dist/src/execution/session/admission.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/entry-input.d.ts +5 -4
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/handoff-state.d.ts +5 -0
- package/dist/src/execution/session/handoff-state.js +1 -0
- package/dist/src/execution/session/handoff-steps.d.ts +0 -5
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +2 -1
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +3 -0
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/next-input.d.ts +3 -0
- package/dist/src/execution/session/next-input.js +1 -1
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/timeout-control.d.ts +4 -0
- package/dist/src/execution/session/timeout-control.js +1 -1
- package/dist/src/execution/session/turn-control.d.ts +5 -2
- package/dist/src/execution/session/turn-control.js +1 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-inbox/inbox.d.ts +9 -1
- package/dist/src/execution/session-inbox/inbox.js +1 -1
- package/dist/src/execution/session-inbox/protocol.d.ts +2 -1
- package/dist/src/execution/session-inbox/protocol.js +1 -1
- package/dist/src/execution/session-inbox/resume.d.ts +2 -1
- package/dist/src/execution/session-inbox/resume.js +1 -1
- package/dist/src/execution/session-prewarm.d.ts +8 -0
- package/dist/src/execution/session-prewarm.js +1 -0
- package/dist/src/execution/skills/instructions.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/step-context.d.ts +11 -0
- package/dist/src/execution/tools/workflow/step-execution.js +1 -1
- package/dist/src/execution/tools/workflow/step.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/extensions/git/extension/lib/github-shell-schema.js +1 -1
- package/dist/src/framework/sources/modules/sandbox.d.ts +1 -1
- package/dist/src/harness/attachment-staging.d.ts +0 -7
- package/dist/src/harness/attachment-staging.js +1 -1
- package/dist/src/harness/hitl/index.d.ts +2 -1
- package/dist/src/harness/hitl/index.js +1 -1
- package/dist/src/harness/hitl/view.d.ts +1 -0
- package/dist/src/harness/hitl/view.js +1 -0
- package/dist/src/harness/model-call/run.js +1 -1
- package/dist/src/harness/semantic-errors/rules/sandbox.d.ts +3 -5
- package/dist/src/harness/semantic-errors/rules/sandbox.js +1 -1
- package/dist/src/harness/step/prompt.js +1 -1
- package/dist/src/harness/tool-history-repair.d.ts +9 -0
- package/dist/src/harness/tool-history-repair.js +1 -0
- package/dist/src/harness/tool-model-output.d.ts +19 -3
- package/dist/src/harness/tool-model-output.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +8 -4
- package/dist/src/internal/application/optional-package-import.d.ts +10 -0
- package/dist/src/internal/application/optional-package-import.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/attachments/limited-read.d.ts +2 -2
- package/dist/src/internal/authored-module-build-options.d.ts +6 -0
- package/dist/src/internal/authored-module-build-options.js +1 -1
- package/dist/src/internal/authored-module-cache.d.ts +10 -0
- package/dist/src/internal/authored-module-cache.js +1 -0
- package/dist/src/internal/authored-module-graph.js +1 -1
- package/dist/src/internal/authored-module-loader.js +1 -1
- package/dist/src/internal/authored-relative-extension-resolver.js +1 -1
- package/dist/src/internal/bundler/nitro-rolldown.d.ts +3 -1
- package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
- package/dist/src/internal/bundler/pseudo-packages.d.ts +11 -0
- package/dist/src/internal/bundler/pseudo-packages.js +1 -0
- package/dist/src/internal/nitro/host/build-extension.d.ts +6 -0
- package/dist/src/internal/nitro/host/build-extension.js +2 -2
- package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.d.ts +3 -1
- package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.js +3 -5
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +2 -3
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.d.ts +2 -0
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-build-host.d.ts +83 -0
- package/dist/src/internal/nitro/host/dev-build-host.js +1 -0
- package/dist/src/internal/nitro/host/dev-build-operations.d.ts +6 -0
- package/dist/src/internal/nitro/host/dev-build-operations.js +1 -0
- package/dist/src/internal/nitro/host/dev-build-process.d.ts +1 -0
- package/dist/src/internal/nitro/host/dev-build-process.js +1 -0
- package/dist/src/internal/nitro/host/development-runtime-prune-plugin.d.ts +4 -1
- package/dist/src/internal/nitro/host/development-runtime-prune-plugin.js +3 -2
- package/dist/src/internal/nitro/host/drained-nitro-dev-server.d.ts +13 -0
- package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -1
- package/dist/src/internal/nitro/host/optional-engine-dependency-plugin.js +1 -1
- package/dist/src/internal/nitro/host/prepare-application-host.d.ts +3 -0
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/internal/nitro/host/sandbox-shutdown-plugin.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/start-production-server.js +3 -3
- package/dist/src/internal/nitro/host/workflow-sandbox-runtime-plugin.js +1 -1
- package/dist/src/internal/nitro/host.js +1 -1
- package/dist/src/internal/workflow/local-world-delivery-auth.d.ts +17 -0
- package/dist/src/internal/workflow/local-world-delivery-auth.js +1 -0
- package/dist/src/internal/workflow/queue-namespace.d.ts +2 -0
- package/dist/src/internal/workflow/queue-namespace.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +0 -1
- package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
- package/dist/src/internal/workflow-bundle/builder.js +2 -2
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
- package/dist/src/protocol/prewarm-session.d.ts +14 -0
- package/dist/src/protocol/prewarm-session.js +1 -0
- package/dist/src/protocol/routes.d.ts +2 -2
- package/dist/src/public/channels/discord/authorization.d.ts +45 -0
- package/dist/src/public/channels/discord/authorization.js +3 -0
- package/dist/src/public/channels/discord/defaults.d.ts +14 -3
- package/dist/src/public/channels/discord/defaults.js +2 -2
- package/dist/src/public/channels/discord/discordChannel.d.ts +15 -1
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/discord/gateway/connection.d.ts +26 -0
- package/dist/src/public/channels/discord/gateway/connection.js +1 -0
- package/dist/src/public/channels/discord/gateway/forwarder.d.ts +14 -0
- package/dist/src/public/channels/discord/gateway/forwarder.js +1 -0
- package/dist/src/public/channels/discord/gateway/index.d.ts +59 -0
- package/dist/src/public/channels/discord/gateway/index.js +1 -0
- package/dist/src/public/channels/discord/inbound.d.ts +10 -3
- package/dist/src/public/channels/discord/inbound.js +2 -2
- package/dist/src/public/channels/discord/index.d.ts +3 -2
- package/dist/src/public/channels/discord/index.js +1 -1
- package/dist/src/public/channels/discord/messages.d.ts +116 -0
- package/dist/src/public/channels/discord/messages.js +2 -0
- package/dist/src/public/channels/github/checkout.js +1 -1
- package/dist/src/public/channels/linq/linqChannel.d.ts +4 -1
- package/dist/src/public/channels/linq/linqChannel.js +1 -1
- package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
- package/dist/src/public/channels/same-environment-oidc.d.ts +7 -0
- package/dist/src/public/channels/same-environment-oidc.js +1 -0
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/sandbox.d.ts +1 -1
- package/dist/src/public/next/server.js +1 -1
- package/dist/src/public/sandbox/docker-sandbox.d.ts +6 -1
- package/dist/src/public/sandbox/docker.d.ts +1 -8
- package/dist/src/public/sandbox/index.d.ts +3 -3
- package/dist/src/public/sandbox/just-bash-sandbox.d.ts +87 -7
- package/dist/src/public/sandbox/just-bash.d.ts +1 -1
- package/dist/src/public/sandbox/provider.d.ts +5 -1
- package/dist/src/public/sandbox/provider.js +1 -1
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +16 -9
- package/dist/src/public/sandbox/vercel.d.ts +0 -1
- package/dist/src/public/sandbox/vercel.js +1 -1
- package/dist/src/public/tools/agent.d.ts +8 -1
- package/dist/src/public/tools/agent.js +1 -1
- package/dist/src/react/use-eve-agent.d.ts +1 -1
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/connections/openapi-client.d.ts +2 -0
- package/dist/src/runtime/connections/openapi-client.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/resolve-channel.js +1 -1
- package/dist/src/runtime/resolve-sandbox.js +1 -1
- package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -1
- package/dist/src/runtime/sandbox/registry.d.ts +2 -0
- package/dist/src/runtime/sandbox/registry.js +1 -1
- package/dist/src/runtime/subagents/workflow.d.ts +6 -0
- package/dist/src/runtime/subagents/workflow.js +1 -1
- package/dist/src/runtime/workspace/seed-files.d.ts +9 -12
- package/dist/src/runtime/workspace/seed-files.js +1 -1
- package/dist/src/runtime/workspace/spec.d.ts +1 -1
- package/dist/src/runtime/workspace/spec.js +1 -1
- package/dist/src/runtime/workspace/types.d.ts +2 -6
- package/dist/src/sandbox/provider.d.ts +185 -0
- package/dist/src/sandbox/provider.js +1 -0
- package/dist/src/sandbox/providers/default.d.ts +20 -19
- package/dist/src/sandbox/providers/default.js +1 -1
- package/dist/src/sandbox/providers/docker.d.ts +5 -2
- package/dist/src/sandbox/providers/docker.js +1 -1
- package/dist/src/sandbox/providers/just-bash.d.ts +4 -3
- package/dist/src/sandbox/providers/just-bash.js +1 -1
- package/dist/src/sandbox/providers/vercel.d.ts +4 -10
- package/dist/src/sandbox/providers/vercel.js +1 -1
- package/dist/src/sandbox/providers.d.ts +0 -1
- package/dist/src/sandbox/providers.js +1 -1
- package/dist/src/sandbox/state.d.ts +44 -0
- package/dist/src/sandbox/state.js +1 -1
- package/dist/src/self-modification/deployed-sandbox.d.ts +4 -9
- package/dist/src/self-modification/deployed-sandbox.js +1 -1
- package/dist/src/self-modification/filesystem.d.ts +3 -3
- package/dist/src/self-modification/remote/config.d.ts +2 -2
- package/dist/src/self-modification/remote/config.js +1 -1
- package/dist/src/self-modification/setup.d.ts +0 -1
- package/dist/src/self-modification/setup.js +8 -8
- package/dist/src/setup/integrations/discord/api.d.ts +7 -0
- package/dist/src/setup/integrations/discord/api.js +1 -1
- package/dist/src/setup/integrations/discord/daemon.d.ts +18 -0
- package/dist/src/setup/integrations/discord/daemon.js +21 -0
- package/dist/src/setup/integrations/discord/setup.d.ts +24 -4
- package/dist/src/setup/integrations/discord/setup.js +5 -4
- package/dist/src/setup/integrations/self-modification/setup.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/update/web-options.js +1 -1
- package/dist/src/setup/scaffold/version-tokens.d.ts +0 -1
- package/dist/src/setup/scaffold/version-tokens.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +2 -0
- package/dist/src/shared/built-server-start-failure.d.ts +12 -0
- package/dist/src/shared/built-server-start-failure.js +3 -0
- package/dist/src/shared/framework-eve-server.d.ts +2 -0
- package/dist/src/shared/framework-eve-server.js +2 -2
- package/dist/src/shared/sandbox-environment.d.ts +4 -10
- package/dist/src/shared/sandbox-environment.js +1 -1
- package/dist/src/shared/sandbox-network-policy.d.ts +45 -9
- package/dist/src/shared/sandbox-provider.d.ts +0 -103
- package/dist/src/shared/sandbox-provider.js +1 -1
- package/dist/src/shared/sandbox-recorded-data-error.d.ts +4 -0
- package/dist/src/shared/sandbox-recorded-data-error.js +1 -0
- package/dist/src/shared/sandbox-session-gone-error.d.ts +12 -0
- package/dist/src/shared/sandbox-session-gone-error.js +1 -0
- package/dist/src/shared/sandbox-session.d.ts +97 -83
- package/dist/src/shared/sandbox-template-error.d.ts +19 -4
- package/dist/src/shared/sandbox-template-error.js +1 -1
- package/dist/src/shared/sandbox-tool-session-error.d.ts +4 -0
- package/dist/src/shared/sandbox-tool-session-error.js +1 -0
- package/dist/src/shared/skill-package.js +1 -1
- package/dist/src/shared/skill-paths.d.ts +4 -5
- package/dist/src/shared/skill-paths.js +2 -2
- package/dist/src/shared/workflow-sandbox.d.ts +4 -41
- package/dist/src/shared/workflow-sandbox.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/model-output.d.ts +23 -5
- package/dist/src/tools/model-output.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/glob.js +1 -1
- package/dist/src/tools/provided/grep.js +1 -1
- package/dist/src/tools/provided/read-file.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tools/provided/workflow.js +1 -1
- package/dist/src/tools/provided/write-file.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +19 -4
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/custom.mdx +3 -3
- package/docs/channels/discord.mdx +279 -7
- package/docs/channels/eve.mdx +13 -2
- package/docs/channels/linq.mdx +2 -2
- package/docs/channels/mcp.mdx +2 -2
- package/docs/channels/overview.mdx +1 -1
- package/docs/channels/photon.mdx +1 -1
- package/docs/concepts/built-in-tools.md +31 -8
- package/docs/concepts/execution-model-and-durability.mdx +6 -101
- package/docs/concepts/security-model.md +2 -0
- package/docs/concepts/sessions-runs-and-streaming.md +44 -36
- package/docs/connections/openapi.mdx +2 -0
- package/docs/evals/reporters.mdx +1 -1
- package/docs/evals/running.mdx +1 -1
- package/docs/guides/client/messages.mdx +1 -1
- package/docs/guides/deployment/overview.md +4 -4
- package/docs/guides/deployment/self-hosting.md +50 -1
- package/docs/guides/dev-tui.md +1 -1
- package/docs/guides/dynamic-capabilities.md +1 -1
- package/docs/guides/frontend/overview.mdx +26 -6
- package/docs/guides/instrumentation/agent-runs.mdx +16 -0
- package/docs/guides/self-modification.md +1 -1
- package/docs/guides/session-context.md +1 -1
- package/docs/instructions.mdx +1 -1
- package/docs/reference/agent-files.md +3 -3
- package/docs/reference/cli.md +7 -2
- package/docs/reference/typescript-api.md +9 -3
- package/docs/sandbox/custom-providers.mdx +254 -0
- package/docs/sandbox/default.mdx +71 -4
- package/docs/sandbox/docker.mdx +15 -3
- package/docs/sandbox/index.mdx +27 -103
- package/docs/sandbox/just-bash.mdx +54 -0
- package/docs/sandbox/meta.json +9 -1
- package/docs/sandbox/troubleshooting.mdx +215 -0
- package/docs/sandbox/vercel.mdx +48 -7
- package/docs/skills.mdx +1 -1
- package/docs/subagents/index.mdx +2 -2
- package/docs/tools/overview.mdx +19 -0
- package/docs/tools/workflows.mdx +73 -5
- package/docs/tutorial/run-analysis.mdx +2 -2
- package/package.json +14 -20
- package/dist/src/compiled/@ai-sdk/code-mode/_run.d.ts +0 -1
- package/dist/src/compiled/@ai-sdk/code-mode/index.d.ts +0 -325
- package/dist/src/compiled/@ai-sdk/code-mode/index.js +0 -660
- package/dist/src/compiled/_chunks/workflow/dist-CyBgVS7g.js +0 -1
- package/dist/src/compiled/_chunks/workflow/dist-T5NnW-0k.js +0 -3
- package/dist/src/compiled/_chunks/workflow/helpers-DlLD3ov_.js +0 -1
- package/dist/src/compiled/_chunks/workflow/private-tQUuwBoQ.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-DMsV_b4n.js +0 -1
- package/dist/src/compiled/_chunks/workflow/serialization-DPdYS_w2.js +0 -16
- package/dist/src/compiled/_chunks/workflow/sleep-BY6leHh8.js +0 -1
- package/dist/src/compiled/_chunks/workflow/workflow-routes-CwqB063q.js +0 -1
- package/dist/src/execution/sandbox/active-handles.d.ts +0 -32
- package/dist/src/execution/sandbox/active-handles.js +0 -1
- package/dist/src/execution/sandbox/bindings/docker-session.d.ts +0 -6
- package/dist/src/execution/sandbox/bindings/docker-session.js +0 -2
- package/dist/src/execution/sandbox/bindings/immutable-resources.d.ts +0 -15
- package/dist/src/execution/sandbox/bindings/immutable-resources.js +0 -2
- package/dist/src/execution/sandbox/bindings/microsandbox-create.d.ts +0 -12
- package/dist/src/execution/sandbox/bindings/microsandbox-create.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.d.ts +0 -42
- package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-metadata.d.ts +0 -29
- package/dist/src/execution/sandbox/bindings/microsandbox-metadata.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-network.d.ts +0 -18
- package/dist/src/execution/sandbox/bindings/microsandbox-network.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +0 -37
- package/dist/src/execution/sandbox/bindings/microsandbox-options.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.d.ts +0 -21
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +0 -21
- package/dist/src/execution/sandbox/bindings/microsandbox-process.d.ts +0 -3
- package/dist/src/execution/sandbox/bindings/microsandbox-process.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-provider-state.d.ts +0 -11
- package/dist/src/execution/sandbox/bindings/microsandbox-provider-state.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.d.ts +0 -82
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-templates.d.ts +0 -12
- package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox.d.ts +0 -16
- package/dist/src/execution/sandbox/bindings/microsandbox.js +0 -1
- package/dist/src/execution/sandbox/provider-host-development.d.ts +0 -2
- package/dist/src/execution/sandbox/provider-host-development.js +0 -1
- package/dist/src/execution/sandbox/provider-host.d.ts +0 -2
- package/dist/src/execution/sandbox/provider-host.js +0 -1
- package/dist/src/execution/tool-session/sandbox.d.ts +0 -22
- package/dist/src/execution/tool-session/sandbox.js +0 -1
- package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +0 -48
- package/dist/src/public/sandbox/microsandbox-sandbox.js +0 -1
- package/dist/src/public/sandbox/microsandbox.d.ts +0 -9
- package/dist/src/public/sandbox/microsandbox.js +0 -1
- package/dist/src/sandbox/providers/microsandbox.d.ts +0 -12
- package/dist/src/sandbox/providers/microsandbox.js +0 -1
- package/docs/sandbox/microsandbox.mdx +0 -31
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-B_knIduE.js";import*as t from"#compiled/zod/index.js";import{z as n}from"#compiled/zod/index.js";import r from"node:crypto";function i(e,t,n){let r=Symbol.for(`${e}/v${t}`),i=globalThis,a=i[r];if(a!==void 0)return a;let o=n();return i[r]=o,o}const a=Symbol.for(`@workflow/world//warnedEnvValues/v1`),o=globalThis,s=o[a]??=new Set;function c(e,t){s.has(e)||(s.add(e),console.warn(`[workflow] ${t}`))}function l(e,t,n={}){let r=process.env[e];if(r===void 0||r===``)return t;let{min:i=0,max:a,integer:o=!1}=n,s=Number(r);return!Number.isFinite(s)||o&&!Number.isInteger(s)?(c(`${e}=${r}`,`Ignoring ${e}: not a ${o?`finite integer`:`finite number`}; using default ${t}`),t):s<i?(c(`${e}=${r}`,`${e} below minimum ${i}; clamped`),i):a!==void 0&&s>a?(c(`${e}=${r}`,`${e} above maximum ${a}; clamped`),a):s}function u(e,t,n=process.env){let r=n[e];if(r===void 0||r===``)return t;let i=r.toLowerCase();return i===`0`||i===`false`?!1:i===`1`||i===`true`||(c(`${e}=${r}`,`Ignoring ${e}: expected 0/1/true/false; using default ${t}`),t)}const d=25e3;function ee(){let e=l(`WORKFLOW_MAX_EVENTS`,d,{integer:!0});return e>0?e:d}const f=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`;var p;(function(e){e.Base32IncorrectEncoding=`B32_ENC_INVALID`,e.DecodeTimeInvalidCharacter=`DEC_TIME_CHAR`,e.DecodeTimeValueMalformed=`DEC_TIME_MALFORMED`,e.EncodeTimeNegative=`ENC_TIME_NEG`,e.EncodeTimeSizeExceeded=`ENC_TIME_SIZE_EXCEED`,e.EncodeTimeValueMalformed=`ENC_TIME_MALFORMED`,e.PRNGDetectFailure=`PRNG_DETECT`,e.ULIDInvalid=`ULID_INVALID`,e.Unexpected=`UNEXPECTED`,e.UUIDInvalid=`UUID_INVALID`})(p||={});var m=class extends Error{constructor(e,t){super(`${t} (${e})`),this.name=`ULIDError`,this.code=e}};function te(e){let t=Math.floor(e()*32)%32;return f.charAt(t)}function h(e,t,n){return t>e.length-1?e:e.substr(0,t)+n+e.substr(t+1)}function ne(e){let t,n=e.length,r,i,a=e;for(;!t&&n-->=0;){if(r=a[n],i=f.indexOf(r),i===-1)throw new m(p.Base32IncorrectEncoding,`Incorrectly encoded string`);if(i===31){a=h(a,n,f[0]);continue}t=h(a,n,f[i+1])}if(typeof t==`string`)return t;throw new m(p.Base32IncorrectEncoding,`Failed incrementing string`)}function re(e){if(e.length!==26)throw new m(p.DecodeTimeValueMalformed,`Malformed ULID`);let t=e.substr(0,10).toUpperCase().split(``).reverse().reduce((e,t,n)=>{let r=f.indexOf(t);if(r===-1)throw new m(p.DecodeTimeInvalidCharacter,`Time decode error: Invalid character: ${t}`);return e+=r*32**n},0);if(t>0xffffffffffff)throw new m(p.DecodeTimeValueMalformed,`Malformed ULID: timestamp too large: ${t}`);return t}function ie(e){let t=ae(),n=t&&(t.crypto||t.msCrypto)||(r===void 0?null:r);if(typeof n?.getRandomValues==`function`)return()=>{let e=new Uint8Array(1);return n.getRandomValues(e),e[0]/256};if(typeof n?.randomBytes==`function`)return()=>n.randomBytes(1).readUInt8()/256;if(r?.randomBytes)return()=>r.randomBytes(1).readUInt8()/256;throw new m(p.PRNGDetectFailure,`Failed to find a reliable PRNG`)}function ae(){return se()?self:typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:null}function oe(e,t){let n=``;for(;e>0;e--)n=te(t)+n;return n}function g(e,t=10){if(isNaN(e))throw new m(p.EncodeTimeValueMalformed,`Time must be a number: ${e}`);if(e>0xffffffffffff)throw new m(p.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${e}`);if(e<0)throw new m(p.EncodeTimeNegative,`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new m(p.EncodeTimeValueMalformed,`Time must be an integer: ${e}`);let n,r=``;for(let i=t;i>0;i--)n=e%32,r=f.charAt(n)+r,e=(e-n)/32;return r}function se(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function ce(e){let t=e||ie(),n=0,r;return function(e){let i=!e||isNaN(e)?Date.now():e;if(i<=n){let e=r=ne(r);return g(n,10)+e}n=i;let a=r=oe(16,t);return g(i,10)+a}}function le(e,t){let n=t||ie();return g(!e||isNaN(e)?Date.now():e,10)+oe(16,n)}const ue=`$rootRunId`,de=`$parentRunId`,_=`$retention`,v=`default`,fe=/^(?:0|[1-9]\d*)$/;function pe(e){let t=e?.[_];return t===void 0?{mode:`default`,wellFormed:!1,unsupported:!1}:fe.test(t)?t===`0`?{mode:`none`,raw:t,wellFormed:!0,unsupported:!1}:{mode:`default`,raw:t,wellFormed:!0,unsupported:!0}:{mode:`default`,raw:t,wellFormed:!1,unsupported:t!==v}}const y=8192,b=new TextEncoder;var x=class extends Error{constructor(e){super(e),this.name=`AttributeValidationError`}};function me(e){let t=b.encode(JSON.stringify(e)).length;if(t>8192)throw new x(`Attribute eventData exceeds limit ${y} UTF-8 JSON bytes (received ${t} bytes). Split the changes into smaller setAttributes() calls.`)}function he(e,t){if(typeof e!=`string`)throw new x(`Attribute key must be a string, got ${typeof e}`);if(e.length===0)throw new x(`Attribute key must not be empty`);if(e.length>256)throw new x(`Attribute key length ${e.length} exceeds limit 256: ${JSON.stringify(e.slice(0,32))}…`);if(!t&&e.startsWith(`$`))throw new x(`Attribute key ${JSON.stringify(e)} starts with reserved prefix "\$" — that namespace is reserved for framework/library code. Set { allowReservedAttributes: true } only if your caller is framework-level.`)}function ge(e){if(e!==null&&typeof e!=`string`)throw new x(`Attribute value must be a string or null, got ${typeof e}`);if(e===null)return;let t=b.encode(e).length;if(t>256)throw new x(`Attribute value byte length ${t} exceeds limit 256`)}function _e(e,t,n){return t===null?n?.has(e)?-1:0:+(n===void 0||!n.has(e))}function S(e,t={}){let n=new Set,r=t.existingKeys===void 0?void 0:t.existingKeys instanceof Set?t.existingKeys:new Set(t.existingKeys),i=r?.size??0;for(let{key:t,value:a}of e){if(n.has(t))throw new x(`Attribute key ${JSON.stringify(t)} appears more than once in the same batch`);n.add(t),i+=_e(t,a,r)}if(i>64)throw new x(`Run attribute count would exceed limit 64 (post-merge ${i})`)}function ve(e,t={}){for(let{key:n,value:r}of e)he(n,t.allowReservedAttributes===!0),ge(r);S(e,t)}function ye(e,t){let n={...e??{}};for(let{key:e,value:r}of t)r===null?delete n[e]:n[e]=r;return n}const be=new TextEncoder,C=t.compile(t.string().min(1,{error:`Attribute key must not be empty`}).max(256,{error:`Attribute key exceeds limit 256`})),w=t.compile(t.string().refine(e=>be.encode(e).length<=256,{error:`Attribute value exceeds limit 256 UTF-8 bytes`}).nullable()),xe=t.compile(t.object({key:C,value:w})),Se=t.compile(t.array(xe).superRefine((e,t)=>{try{S(e)}catch(n){if(!(n instanceof x))throw n;t.addIssue({code:`custom`,message:n.message,input:e})}}));function T(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Ce(e){return e.eventType===`noop`}const we={attr_set:`attr_set`,step_created:`step_created`,step_started:`step_started`,step_retrying:`step_retrying`,step_completed:`step_terminal`,step_failed:`step_terminal`,wait_created:`wait_created`,wait_completed:`wait_completed`,hook_created:`hook_created`,hook_disposed:`hook_disposed`,run_started:`run_started`};function Te(e){return T(we,e)}function Ee(e){let t=Te(e.eventType);if(t!==void 0)return t===`run_started`?{eventClass:t,entity:``}:e.correlationId?{eventClass:t,entity:e.correlationId}:void 0}const De={run_created:[`input`],run_started:[`input`],run_completed:[`output`],run_failed:[`error`],step_created:[`input`],step_started:[`input`],step_completed:[`result`],step_failed:[`error`],step_retrying:[`error`],hook_created:[`metadata`],hook_received:[`payload`]},Oe=[];function E(e){return T(De,e)??Oe}function ke(e){return E(e)[0]}const Ae=n.compile(n.instanceof(Uint8Array)),je=n.compile(n.any()),D=n.compile(n.union([Ae,je])),O=n.compile(n.enum([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`,`attr_set`,`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`,`hook_created`,`hook_received`,`hook_disposed`,`hook_conflict`,`wait_created`,`wait_completed`,`noop`]));O.extract([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`]).options;const Me=n.compile(O.extract([`run_completed`,`run_failed`,`run_cancelled`])).options;function Ne(e){return Me.includes(e)}const Pe=O.extract([`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`]).options;function Fe(e){return Pe.includes(e)}O.extract([`step_completed`,`step_failed`]).options;const Ie=O.extract([`hook_created`,`hook_received`,`hook_disposed`]).options;function Le(e){return Ie.includes(e)}const Re=O.extract([`hook_disposed`,`hook_received`]).options;function ze(e){return Re.includes(e)}O.extract([`wait_created`,`wait_completed`]).options;const Be=O.extract([`step_created`,`hook_created`,`wait_created`]).options;function Ve(e){return Be.includes(e)}function He(e,t){if(t!==`none`||!(`eventData`in e))return e;let n=e.eventData;if(!n||typeof n!=`object`){let{eventData:t,...n}=e;return n}let r=E(e.eventType);if(r.length===0)return e;let i={...n};for(let e of r)delete i[e];let{eventData:a,...o}=e;return{...o,...Object.keys(i).length>0?{eventData:i}:{}}}const k=n.compile(n.object({eventType:O,correlationId:n.string().optional(),specVersion:n.number().optional()})),A={ttfs:n.number().optional(),stso:n.number().optional(),stepCount:n.number().int().positive().optional(),eventCount:n.number().int().positive().optional(),rsfs:n.number().optional(),finalSchedulingReplay:n.number().optional(),optimizations:n.array(n.string()).optional()},j=k.extend({eventType:n.literal(`step_completed`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),workflowName:n.string().optional(),result:D,...A})}),M=k.extend({eventType:n.literal(`step_failed`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),error:D,...A})}),N=k.extend({eventType:n.literal(`step_retrying`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),error:D,retryAfter:n.coerce.date().optional()})}),P=k.extend({eventType:n.literal(`step_started`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),attempt:n.number().optional(),workflowName:n.string().optional(),input:D.optional(),ownerMessageId:n.string().optional()}).optional()}),F=k.extend({eventType:n.literal(`step_created`),correlationId:n.string(),eventData:n.object({stepName:n.string(),workflowName:n.string().optional(),input:D})}),I=n.compile(k.extend({eventType:n.literal(`hook_created`),correlationId:n.string(),eventData:n.object({token:n.string(),tokenRetentionUntil:n.coerce.date().optional(),metadata:D.optional(),isWebhook:n.boolean().optional(),isSystem:n.boolean().optional(),force:n.boolean().optional(),forceClaimedFrom:n.object({runId:n.string(),hookId:n.string(),workflowName:n.string().optional(),deploymentId:n.string().optional(),runSpecVersion:n.number().optional()}).optional()})})),L=k.extend({eventType:n.literal(`hook_received`),correlationId:n.string(),eventData:n.object({token:n.string().optional(),payload:D})}),R=k.extend({eventType:n.literal(`hook_disposed`),correlationId:n.string(),eventData:n.object({token:n.string().optional(),forceClaimedBy:n.object({runId:n.string(),hookId:n.string()}).optional()}).optional()}),Ue=k.extend({eventType:n.literal(`hook_conflict`),correlationId:n.string(),eventData:n.object({token:n.string(),conflictingRunId:n.string().optional(),forceRefusedReason:n.literal(`victim-spec-version`).optional()})}),We=k.extend({eventType:n.literal(`noop`),eventData:n.object({sealed:n.boolean().optional()}).passthrough().optional()}),z=k.extend({eventType:n.literal(`wait_created`),correlationId:n.string(),eventData:n.object({resumeAt:n.coerce.date()})}),B=k.extend({eventType:n.literal(`wait_completed`),correlationId:n.string(),eventData:n.object({resumeAt:n.coerce.date().optional()}).optional()}),Ge=n.discriminatedUnion(`type`,[n.object({type:n.literal(`workflow`)}),n.object({type:n.literal(`step`),stepId:n.string(),attempt:n.number()})]),V=k.extend({eventType:n.literal(`attr_set`),correlationId:n.string().optional(),eventData:n.object({changes:Se,writer:Ge,allowReservedAttributes:n.literal(!0).optional()})}),Ke=k.extend({eventType:n.literal(`run_created`),eventData:n.object({deploymentId:n.string(),workflowName:n.string(),input:D,executionContext:n.record(n.string(),n.any()).optional(),attributes:n.record(n.string(),n.string()).optional(),allowReservedAttributes:n.literal(!0).optional(),dynamicWorkflowCode:D.optional(),dynamicWorkflowCodeRef:n.string().optional(),encryptionPublicKey:n.string().optional()}).refine(e=>e.dynamicWorkflowCode===void 0||e.dynamicWorkflowCodeRef===void 0,{path:[`dynamicWorkflowCodeRef`],message:`dynamicWorkflowCode and dynamicWorkflowCodeRef are mutually exclusive`})}),H=k.extend({eventType:n.literal(`run_started`),eventData:n.object({input:D.optional(),deploymentId:n.string().optional(),workflowName:n.string().optional(),executionContext:n.record(n.string(),n.any()).optional(),attributes:n.record(n.string(),n.string()).optional(),allowReservedAttributes:n.literal(!0).optional(),encryptionPublicKey:n.string().optional(),dynamicWorkflowCode:D.optional(),dynamicWorkflowCodeRef:n.string().optional()}).refine(e=>e.dynamicWorkflowCode===void 0||e.dynamicWorkflowCodeRef===void 0,{path:[`dynamicWorkflowCodeRef`],message:`dynamicWorkflowCode and dynamicWorkflowCodeRef are mutually exclusive`}).optional()}),U=k.extend({eventType:n.literal(`run_completed`),eventData:n.object({output:D.optional()})}),qe=k.extend({eventType:n.literal(`run_failed`),eventData:n.object({error:D,errorCode:n.string().optional()})}),Je=k.extend({eventType:n.literal(`run_cancelled`),eventData:n.object({cancelReason:n.string().max(512).optional()}).optional()});n.compile(n.discriminatedUnion(`eventType`,[Ke,H,U,qe,Je,V,F,j,M,N,P,I,L,R,z,B]));const Ye=n.discriminatedUnion(`eventType`,[Ke,H,U,qe,Je,V,F,j,M,N,P,I,L,R,Ue,z,B,We]),Xe=n.compile(Ye.and(n.object({runId:n.string(),eventId:n.string(),createdAt:n.coerce.date(),occurredAt:n.coerce.date().optional(),specVersion:n.number().optional(),resumeId:n.string().optional()})));function Ze(e){return Ve(e.eventType)?!0:e.eventType===`step_started`&&typeof e.eventData?.stepName==`string`&&e.eventData.input!==void 0}const W=n.compile(n.enum([`pending`,`running`,`completed`,`failed`,`cancelled`])),Qe=n.compile(W.extract([`completed`,`failed`,`cancelled`])).options;function $e(e){return Qe.includes(e)}const G=n.compile(n.object({runId:n.string(),status:W,deploymentId:n.string(),workflowName:n.string(),specVersion:n.number().optional(),executionContext:n.record(n.string(),n.any()).optional(),input:D.optional(),output:D.optional(),dynamicWorkflowCode:D.optional(),error:D.optional(),errorCode:n.string().optional(),attributes:n.record(n.string(),n.string()).default({}),encryptionPublicKey:n.string().optional(),expiredAt:n.coerce.date().optional(),startedAt:n.coerce.date().optional(),completedAt:n.coerce.date().optional(),createdAt:n.coerce.date(),updatedAt:n.coerce.date()})),et=n.compile(n.discriminatedUnion(`status`,[G.extend({status:n.enum([`pending`,`running`]),output:n.undefined().optional(),error:n.undefined().optional(),completedAt:n.undefined().optional()}),G.extend({status:n.literal(`cancelled`),output:n.undefined().optional(),error:n.undefined().optional(),completedAt:n.coerce.date()}),G.extend({status:n.literal(`completed`),output:D.optional(),error:n.undefined().optional(),completedAt:n.coerce.date()}),G.extend({status:n.literal(`failed`),output:n.undefined().optional(),error:D.optional(),completedAt:n.coerce.date()})])),tt=n.compile(n.object({runIds:n.array(n.string()).min(1).max(500).refine(e=>new Set(e).size===e.length,{message:`runIds must not contain duplicates`}),cancelReason:n.string().max(512).optional()})),nt=n.compile(n.discriminatedUnion(`outcome`,[n.object({runId:n.string(),outcome:n.literal(`cancelled`)}),n.object({runId:n.string(),outcome:n.literal(`already_cancelled`)}),n.object({runId:n.string(),outcome:n.literal(`not_cancellable`),status:n.string()}),n.object({runId:n.string(),outcome:n.literal(`not_found`)}),n.object({runId:n.string(),outcome:n.literal(`failed`),code:n.string(),retryable:n.boolean()})])),rt=n.compile(n.object({summary:n.object({requested:n.number(),cancelled:n.number(),alreadyCancelled:n.number(),notCancellable:n.number(),notFound:n.number(),failed:n.number()}),results:n.array(nt)})),K=n.compile(n.enum([`pending`,`running`,`completed`,`failed`,`cancelled`])),it=n.compile(n.object({runId:n.string(),stepId:n.string(),stepName:n.string(),status:K,input:D.optional(),output:D.optional(),error:D.optional(),attempt:n.number(),startedAt:n.coerce.date().optional(),completedAt:n.coerce.date().optional(),createdAt:n.coerce.date(),updatedAt:n.coerce.date(),retryAfter:n.coerce.date().optional(),specVersion:n.number().optional()})),at=n.compile(K.extract([`completed`,`failed`,`cancelled`])).options;function ot(e){return at.includes(e)}const st=n.compile(n.enum([`waiting`,`completed`])),ct=n.compile(n.object({waitId:n.string(),runId:n.string(),status:st,resumeAt:n.coerce.date().optional(),completedAt:n.coerce.date().optional(),createdAt:n.coerce.date(),updatedAt:n.coerce.date(),specVersion:n.number().optional()})),lt=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/,q=n.compile(n.preprocess(e=>typeof e==`string`&<.test(e)?`${e.replace(` `,`T`)}Z`:e,n.coerce.date())),J=n.compile(q.nullable().optional()),Y=n.compile(n.string().nullable().optional()),X=n.compile(n.boolean().nullable().optional()),ut=n.compile(n.object({runId:n.string(),status:W,deploymentId:n.string(),workflowName:n.string(),specVersion:n.coerce.number().optional(),attributes:n.record(n.string(),n.string()).default({}),createdAt:q,updatedAt:q,startedAt:J,completedAt:J,errorCode:Y,workflowCoreVersion:Y,workflowEncryptionEnabled:X})),dt=n.compile(n.object({runId:n.string(),stepId:n.string(),stepName:Y,status:K,attempt:n.number().optional(),createdAt:q,updatedAt:q,startedAt:J,completedAt:J,retryAfter:J,errorCode:Y,workflowCoreVersion:Y,workflowEncryptionEnabled:X,computeInstanceId:Y})),ft=n.compile(n.object({runId:n.string(),eventId:n.string(),eventType:O,correlationId:Y,entityId:Y,stepName:Y,workflowName:n.string(),deploymentId:n.string(),specVersion:n.coerce.number().optional(),runCreatedAt:q,createdAt:q,region:Y,vercelId:Y,requestId:Y,computeInstanceId:Y,resumeAt:J,retryAfter:J,errorCode:Y,workflowCoreVersion:Y,isWebhook:X,isSystem:X,workflowEncryptionEnabled:X})),pt=n.compile(n.object({runId:n.string(),hookId:n.string(),status:n.enum([`created`,`received`,`disposed`,`conflict`]),createdAt:q,updatedAt:q,receivedAt:J,disposedAt:J,isWebhook:X,isSystem:X,workflowCoreVersion:Y,workflowEncryptionEnabled:X})),mt=n.compile(n.object({runId:n.string(),waitId:n.string(),status:st,resumeAt:J,createdAt:q,updatedAt:q,completedAt:J,workflowCoreVersion:Y,workflowEncryptionEnabled:X})),ht=n.compile(n.object({key:n.string(),runCount:n.coerce.number(),firstSeenAt:q,lastSeenAt:q})),gt=1e3,_t=n.compile(n.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/,`Must match __wkf_workflow_ or __{namespace}_wkf_workflow_`)),vt=n.compile(n.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/,`Must be a valid queue name with a recognized prefix`)),yt=n.compile(n.string().regex(/^[a-z][a-z0-9]*$/,`Must be lowercase alphanumeric, starting with a letter`));function bt(e){return e??process.env.WORKFLOW_QUEUE_NAMESPACE??void 0}function xt(e,t){if(e!==`workflow`)throw Error(`Unsupported queue kind: ${e}`);return t===void 0?`__wkf_workflow_`:(yt.parse(t),`__${t}_wkf_workflow_`)}function St(e){let t=e.match(/^(__(?:[a-z][a-z0-9]*_)?wkf_workflow_)(.+)$/);if(!t)throw Error(`Invalid queue name: ${e}`);return{prefix:_t.parse(t[1]),id:t[2]}}const Ct=n.compile(n.string().brand().describe(`A stored queue message ID`)),wt=n.compile(n.record(n.string(),n.string())),Tt=n.compile(n.object({input:n.unknown(),deploymentId:n.string(),workflowName:n.string(),specVersion:n.number(),executionContext:n.record(n.string(),n.any()).optional(),dynamicWorkflowCode:D.optional(),dynamicWorkflowCodeRef:n.string().optional(),attributes:n.record(n.string(),n.string()).optional(),allowReservedAttributes:n.literal(!0).optional(),environment:n.string().optional()}).refine(e=>e.dynamicWorkflowCode===void 0||e.dynamicWorkflowCodeRef===void 0,{path:[`dynamicWorkflowCodeRef`],message:`dynamicWorkflowCode and dynamicWorkflowCodeRef are mutually exclusive`})),Et=n.compile(n.object({input:n.custom(e=>e instanceof Uint8Array,{message:`stepInput.input must be a Uint8Array`})})),Dt=n.compile(n.object({deploymentId:n.string(),specVersion:n.number(),startedAt:n.number().optional(),rootRunId:n.string().optional()})),Ot=n.compile(n.object({resumeId:n.string(),hookId:n.string(),token:n.string(),payload:n.unknown(),payloadDigest:n.string(),deploymentId:n.string().optional()})),kt=n.compile(n.object({resumeRequestedAtMs:n.number(),queuePublishRequestedAtMs:n.number(),strategy:n.string().optional(),consumerStartedAtMs:n.number().optional(),replayStartedAtMs:n.number().optional(),nextStepEncounteredAtMs:n.number().optional(),setupSource:n.string().optional()})),At=n.compile(n.object({runId:n.string(),invoke:n.literal(!0).optional(),requestId:n.string().optional(),input:n.unknown().optional(),traceCarrier:wt.optional(),requestedAt:n.coerce.date().optional(),replayDivergence:n.object({eventId:n.string(),count:n.number().int().positive(),eventIds:n.array(n.string()).optional().catch(void 0)}).optional(),preconditionReinvocations:n.number().int().positive().optional(),serverErrorRetryCount:n.number().int().optional(),deploymentMismatchRetryCount:n.number().int().nonnegative().optional(),waitContinuation:n.object({correlationId:n.string(),attempt:n.number().int().nonnegative()}).optional().catch(void 0),stepId:n.string().optional(),stepName:n.string().optional(),runInput:Tt.optional(),hookInput:Ot.optional(),stepInput:Et.optional(),runContext:Dt.optional(),hookResumeTiming:kt.optional().catch(void 0)})),jt=n.compile(n.object({__healthCheck:n.literal(!0),correlationId:n.string(),runId:n.string().optional()})),Mt=n.compile(n.union([jt,At])),Nt=n.compile(n.object({deploymentId:n.string(),workflowName:n.string(),runSpecVersion:n.number().optional(),workflowCoreVersion:n.string().optional(),nodeVersion:n.string().optional(),traceCarrier:wt.optional(),encryptionPublicKey:n.string().optional(),hookResumeInputVersion:n.number().optional()})),Pt=n.compile(n.object({hookResumeDedupVersion:n.number()})),Ft=n.compile(n.object({runId:n.string(),hookId:n.string(),workflowName:n.string().optional(),deploymentId:n.string().optional(),runSpecVersion:n.number().optional()})),It=n.compile(n.object({runId:n.string(),hookId:n.string(),token:n.string(),ownerId:n.string(),projectId:n.string(),environment:n.string(),metadata:D.optional(),createdAt:n.coerce.date(),specVersion:n.number().optional(),isWebhook:n.boolean().optional(),isSystem:n.boolean().optional(),tokenRetentionUntil:n.coerce.date().optional(),resumeContext:Nt.optional(),resumeCapabilities:Pt.optional(),claimedFrom:Ft.optional()})),Lt=`WORKFLOW_NODE_HTTP`;function Rt(e=process.env){return u(Lt,!1,e)}async function zt(e,t,n,r){let i=xt(`workflow`,bt(r)),a=0,o,s=!0;for(;s;){let r=await e.list({status:[`pending`,`running`],resolveData:`none`,pagination:{cursor:o}});for(let e of r.data)try{await t(`${i}${e.workflowName}`,{runId:e.runId}),a++}catch(t){console.warn(`[${n}] Failed to re-enqueue run ${e.runId}: ${t}`)}s=r.hasMore,o=r.cursor??void 0}a>0&&Bt()&&console.debug(`[${n}] Re-enqueued ${a} active run(s) on startup`)}function Bt(){let e=typeof process<`u`?process.env.DEBUG:void 0;return typeof e==`string`?e.includes(`workflow:`)||e===`*`:!1}const Vt=n.lazy(()=>n.union([n.string(),n.number(),n.boolean(),n.null(),n.array(Vt),n.record(n.string(),Vt)])),Ht=n.compile(n.object({currentLookbackDays:n.number(),maxLookbackDays:n.number(),currentWindowStart:n.coerce.date(),maxWindowStart:n.coerce.date(),upgradeAvailable:n.boolean()})),Ut=new WeakMap;function Wt(e){return n.compile(n.object({data:n.array(e),cursor:n.string().nullable(),hasMore:n.boolean(),pageInfo:Ht.optional()}))}const Gt=e=>{let t=Ut.get(e);if(t)return t;let n=Wt(e);return Ut.set(e,n),n};function Kt(e){return e===`skip-step-inputs`?`all`:e}const qt=n.compile(n.object({message:n.string(),stack:n.string().optional(),code:n.string().optional()})),Jt=`evnt_`;function Z(e){if(e.length!==26)return!1;for(let t=0;t<10;t++)if(e[t]!==`0`)return!1;for(let t=10;t<26;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function Q(e){let t=e.indexOf(`_`);return t===-1?e:e.slice(t+1)}function Yt(e){return Z(Q(e))}function Xt(e){if(!Number.isSafeInteger(e)||e<1)throw RangeError(`Invalid event slot: ${e}`);return`${Jt}${String(e).padStart(26,`0`)}`}function Zt(e){let t=Q(e);if(!Z(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=1?n:null}function Qt(e){let t=Zt(e);if(t===null)throw Error(`Event id is not slot-numbered: ${e}. This World allocates event positions the runtime cannot read.`);return t}const $t=n.object({eventsCursor:n.string().nullable(),createdAt:n.coerce.date(),eventCount:n.number().int().nonnegative().optional(),rngDraws:n.number().int().nonnegative().optional(),serdeRootPtr:n.number().int().optional(),lastUlid:n.string().optional(),engineVersion:n.string().optional(),clockMs:n.number().optional(),formatVersion:n.number().int().optional()}),$=[87,83,78,80];function en(e,t){let n=new TextEncoder().encode(JSON.stringify(e)),r=new Uint8Array(9+n.length+t.length);return r.set($,0),r[4]=1,new DataView(r.buffer).setUint32(5,n.length,!0),r.set(n,9),r.set(t,9+n.length),r}function tn(e){if(e.length<9)return null;for(let t=0;t<$.length;t++)if(e[t]!==$[t])return null;if(e[4]!==1)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(5,!0);if(9+t>e.length)return null;try{let n=new TextDecoder().decode(e.subarray(9,9+t));return{metadata:$t.passthrough().parse(JSON.parse(n)),data:e.subarray(9+t)}}catch{return null}}function nn(e=process.env){return u(`WORKFLOW_SEALED_LOG`,!0,e)?8:6}function rn(e){return e==null||e<=1}function an(e){return e!=null&&e>8}const on=n.compile(n.string().ulid()),sn=n.compile(n.templateLiteral([`wrun_`,n.ulid()])),cn=864e5,ln=3e5;function un(e){if(Z(e))return null;let t=on.safeParse(e);return t.success?new Date(re(t.data)):null}function dn(e,t,n=cn,r=ln){let i=un(e.startsWith(t)?e.slice(t.length):e);if(!i)return`Invalid runId: "${e}" is not a valid ULID`;let a=new Date().getTime()-i.getTime();return a>0&&a<=n||a<=0&&-a<=r?null:`Invalid runId timestamp: embedded timestamp is ${Math.round(Math.abs(a)/1e3)}s in the ${a>0?`past`:`future`} (threshold: ${Math.round((a>0?n:r)/1e3)}s)`}var fn=e({ANALYTICS_EVENTS_GET_MANY_LIMIT:()=>100,ANALYTICS_MAX_ATTRIBUTE_FILTERS:()=>8,ANALYTICS_PAGE_LIMIT:()=>100,ANALYTICS_RUN_SCOPED_PAGE_LIMIT:()=>gt,ATTRIBUTE_EVENT_DATA_MAX_BYTES:()=>y,ATTRIBUTE_KEY_MAX_LENGTH:()=>256,ATTRIBUTE_MAX_PER_RUN:()=>64,ATTRIBUTE_VALUE_MAX_BYTES:()=>256,BULK_CANCEL_MAX_RUN_IDS:()=>500,DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS:()=>ln,DEFAULT_TIMESTAMP_THRESHOLD_MS:()=>DEFAULT_TIMESTAMP_THRESHOLD_MS,DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS:()=>cn,EVENT_ID_BODY_LENGTH:()=>26,EVENT_ID_PREFIX:()=>Jt,FIRST_EVENT_SLOT:()=>1,HOOK_RESUME_DEDUP_VERSION:()=>1,HOOK_RESUME_INPUT_VERSION:()=>1,HookSchema:()=>It,NODE_HTTP_DEFAULT:()=>!1,NODE_HTTP_ENV_VAR:()=>Lt,RESERVED_ATTRIBUTE_KEY_PREFIX:()=>`$`,RETENTION_DEFAULT:()=>v,RETENTION_ZERO:()=>`0`,RUN_ENTITY_KEY:()=>``,SEALED_LOG_ENV_VAR:()=>`WORKFLOW_SEALED_LOG`,SNAPSHOT_FORMAT_VERSION:()=>3,SPEC_VERSION_CURRENT:()=>8,SPEC_VERSION_LEGACY:()=>1,SPEC_VERSION_MAX_SUPPORTED:()=>8,SPEC_VERSION_SUPPORTS_ATTRIBUTES:()=>4,SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT:()=>3,SPEC_VERSION_SUPPORTS_COMPRESSION:()=>5,SPEC_VERSION_SUPPORTS_EVENT_SOURCING:()=>2,SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM:()=>8,SPEC_VERSION_SUPPORTS_SEALED_LOG:()=>7,SPEC_VERSION_SUPPORTS_SLOT_IDENTITY:()=>6});export{ke as $,ft as A,G as B,vt as C,bt as D,St as E,ct as F,Ze as G,$e as H,it as I,Fe as J,ze as K,ot as L,ut as M,dt as N,gt as O,mt as P,Ee as Q,tt as R,Mt as S,xt as T,Xe as U,et as V,O as W,He as X,Ne as Y,D as Z,zt as _,i as _t,rn as a,de as at,jt as b,tn as c,ye as ct,Yt as d,me as dt,E as et,Qt as f,re as ft,Kt as g,ee as gt,qt as h,l as ht,sn as i,x as it,pt as j,ht as k,en as l,pe as lt,Gt as m,le as mt,un as n,C as nt,nn as o,_ as ot,Xt as p,ce as pt,Le as q,dn as r,w as rt,an as s,ue as st,fn as t,Ce as tt,Zt as u,ve as ut,Rt as v,At as w,Ct as x,It as y,rt as z};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./rolldown-runtime-B_knIduE.js";function n(e,t,n){return n===1?e:t}var r=t(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),i=e(r(),1);function a(e){let t=o(e);if(Number.isNaN(t.getTime()))throw Error(typeof e==`object`?`Invalid date: the Date object does not hold a valid time.`:`Invalid duration: ${JSON.stringify(e)} ends past the latest time a Date can represent.`);return t}function o(e){if(typeof e==`string`){let t=(0,i.default)(e);if(typeof t!=`number`||t<0)throw Error(`Invalid duration: "${e}". Expected a valid duration string like "1s", "1m", "1h", etc.`);return new Date(Date.now()+t)}if(typeof e==`number`){if(e<0||!Number.isFinite(e))throw Error(`Invalid duration: ${e}. Expected a non-negative finite number of milliseconds.`);return new Date(Date.now()+e)}if(e instanceof Date||e&&typeof e==`object`&&typeof e.getTime==`function`)return e instanceof Date?e:new Date(e.getTime());throw Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`)}const s={USER_ERROR:`USER_ERROR`,RUNTIME_ERROR:`RUNTIME_ERROR`,CORRUPTED_EVENT_LOG:`CORRUPTED_EVENT_LOG`,REPLAY_DIVERGENCE:`REPLAY_DIVERGENCE`,MAX_DELIVERIES_EXCEEDED:`MAX_DELIVERIES_EXCEEDED`,MAX_EVENTS_EXCEEDED:`MAX_EVENTS_EXCEEDED`,REPLAY_TIMEOUT:`REPLAY_TIMEOUT`,STREAM_ERROR:`STREAM_ERROR`,WORLD_CONTRACT_ERROR:`WORLD_CONTRACT_ERROR`,DEPLOYMENT_MISMATCH:`DEPLOYMENT_MISMATCH`};function c(e){return typeof e==`object`&&!!e&&`name`in e&&`message`in e}function l(e,t){if(t.length===0)return e;let n=[e];return t.forEach((e,r)=>{let i=r===t.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;`${e.label}: ${e.value}`.split(`
|
|
2
|
-
`).forEach((e,t)=>{n.push(`${t===0?a:o}${e}`)})}),n.join(`
|
|
3
|
-
`)}function u(e,t){let n=[];return e&&n.push({label:`hint`,value:e}),t&&n.push({label:`docs`,value:`https://workflow-sdk.dev/err/${t}`}),n}const d={NODE_JS_MODULE_IN_WORKFLOW:`node-js-module-in-workflow`,START_INVALID_WORKFLOW_FUNCTION:`start-invalid-workflow-function`,SERIALIZATION_FAILED:`serialization-failed`,WEBHOOK_INVALID_RESPOND_WITH_VALUE:`webhook-invalid-respond-with-value`,WEBHOOK_RESPONSE_NOT_SENT:`webhook-response-not-sent`,FETCH_IN_WORKFLOW_FUNCTION:`fetch-in-workflow`,TIMEOUT_FUNCTIONS_IN_WORKFLOW:`timeout-in-workflow`,HOOK_CONFLICT:`hook-conflict`,HOOK_FORCE_CLAIMED:`hook-force-claimed`,CORRUPTED_EVENT_LOG:`corrupted-event-log`,REPLAY_DIVERGENCE:`replay-divergence`,STEP_NOT_REGISTERED:`step-not-registered`,WORKFLOW_NOT_REGISTERED:`workflow-not-registered`,RUNTIME_DECRYPTION_FAILED:`runtime-decryption-failed`,DEPLOYMENT_MISMATCH:`deployment-mismatch`};var f=class extends Error{cause;constructor(e,t){let n=l(e,u(void 0,t?.slug));super(n,{cause:t?.cause}),t?.cause!==void 0&&(this.cause=t.cause),t?.cause instanceof Error&&(this.stack=`${this.stack}\nCaused by: ${t.cause.stack}`)}static is(e){return c(e)&&e.name===`WorkflowError`}},p=class extends f{status;code;url;retryAfter;field;constructor(e,t){super(e,{cause:t?.cause}),this.name=`WorkflowWorldError`,this.status=t?.status,this.code=t?.code,this.url=t?.url,this.retryAfter=t?.retryAfter,this.field=t?.field}static is(e){return c(e)&&e.name===`WorkflowWorldError`}},m=class extends f{fatal=!0;runId;errorCode;constructor(e,t,n={}){let r=t instanceof Error?t.message:typeof t==`string`?t:t&&typeof t==`object`&&`message`in t?String(t.message):`Unknown error`;super(`Workflow run "${e}" failed: ${r}`,{cause:t}),this.name=`WorkflowRunFailedError`,this.runId=e,n.errorCode!==void 0&&(this.errorCode=n.errorCode)}static is(e){return c(e)&&e.name===`WorkflowRunFailedError`}},h=class extends f{runId;status;constructor(e,t){super(`Workflow run "${e}" has not completed`,{}),this.name=`WorkflowRunNotCompletedError`,this.runId=e,this.status=t}static is(e){return c(e)&&e.name===`WorkflowRunNotCompletedError`}},g=class extends f{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return c(e)&&e.name===`WorkflowRuntimeError`}},_=class extends g{constructor(e,t){super(e,{...t,slug:d.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return c(e)&&e.name===`CorruptedEventLogError`}},v=class extends g{eventId;constructor(e,t){super(e,{...t,slug:d.REPLAY_DIVERGENCE}),this.name=`ReplayDivergenceError`,this.eventId=t.eventId}static is(e){return c(e)&&e.name===`ReplayDivergenceError`&&typeof e.eventId==`string`}},y=class extends f{eventCount;limit;constructor(e,t,n){super(`Workflow exceeded the maximum of ${t} events per run`,n),this.name=`MaxEventsExceededError`,this.eventCount=e,this.limit=t}static is(e){return c(e)&&e.name===`MaxEventsExceededError`}},b=class extends g{constructor(e,t){super(e,{cause:t?.cause,slug:d.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return c(e)&&e.name===`RuntimeDecryptionError`}},x=class extends f{hint;constructor(e,t){let n=l(e,u(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return c(e)&&e.name===`WorkflowBuildError`}},S=class extends f{hint;fatal=!0;constructor(e,t){let n=l(e,u(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return c(e)&&e.name===`SerializationError`}},C=class extends g{stepName;constructor(e){super(`Step "${e}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`,{slug:d.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return c(e)&&e.name===`StepNotRegisteredError`}},w=class extends g{workflowName;constructor(e){super(`Workflow "${e}" is not registered in the current deployment. This usually means a run was started against a deployment that does not have this workflow, or there was a build/bundling issue.`,{slug:d.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return c(e)&&e.name===`WorkflowNotRegisteredError`}},T=class extends g{runId;expectedDeploymentId;actualDeploymentId;recoveryAttempts;constructor(e,t,r,i){let a=i?.recoveryAttempts??0,o=a>0?` The runtime re-routed the message to "${t}" ${a} ${n(`time`,`times`,a)} and it kept arriving elsewhere, so the run was stopped to protect against code-skew errors.`:` The run was stopped to protect against code-skew errors.`;super(`Workflow run "${e}" is pinned to deployment "${t}", but was received by deployment "${r}".${o} Verify that the run's deployment is still available and that queue callbacks are routed to it.`,{slug:d.DEPLOYMENT_MISMATCH,cause:i?.cause}),this.name=`WorkflowDeploymentMismatchError`,this.runId=e,this.expectedDeploymentId=t,this.actualDeploymentId=r,this.recoveryAttempts=a}static is(e){return c(e)&&e.name===`WorkflowDeploymentMismatchError`}},E=class extends f{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return c(e)&&e.name===`WorkflowRunNotFoundError`}},D=class extends f{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:d.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return c(e)&&e.name===`HookConflictError`}},O=class extends f{token;claimedByRunId;claimedByHookId;constructor(e,t,n){super(`Hook token "${e}" was force-claimed by another workflow (run "${t}")`,{slug:d.HOOK_FORCE_CLAIMED}),this.name=`HookForceClaimedError`,this.token=e,this.claimedByRunId=t,n!==void 0&&(this.claimedByHookId=n)}static is(e){return c(e)&&e.name===`HookForceClaimedError`}},k=class extends f{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return c(e)&&e.name===`HookNotFoundError`}},A=class extends p{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return c(e)&&e.name===`EntityConflictError`}},j=class extends p{runId;runStatus;expiredAt;constructor(e,t,n,r){super(e,{status:410,code:`run-expired`}),this.runId=t,this.runStatus=n,this.expiredAt=r,this.name=`RunExpiredError`}static is(e){return c(e)&&e.name===`RunExpiredError`}},M=class extends p{constructor(e,t){super(e,{code:s.STREAM_ERROR,cause:t?.cause,url:t?.url,status:t?.status}),this.name=`StreamError`}static is(e){return c(e)&&e.name===`StreamError`}},N=class extends p{runId;streamId;expiredAt;constructor(e,t,n,r){super(e,{status:410,code:`stream-expired`}),this.runId=t,this.streamId=n,this.expiredAt=r,this.name=`StreamExpiredError`}static is(e){return c(e)&&e.name===`StreamExpiredError`}},P=class extends p{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return c(e)&&e.name===`TooEarlyError`}},F=class extends p{retryAfter;constructor(e,t){super(e),this.name=`ThrottleError`,this.retryAfter=t?.retryAfter}static is(e){return c(e)&&e.name===`ThrottleError`}},I=class extends p{details;constructor(e,t){super(e,{status:412,retryAfter:t?.retryAfter}),this.name=`PreconditionFailedError`,this.details=t?.details}static is(e){return c(e)&&e.name===`PreconditionFailedError`}},L=class extends f{fatal=!0;runId;constructor(e){super(`Workflow run "${e}" cancelled`,{}),this.name=`WorkflowRunCancelledError`,this.runId=e}static is(e){return c(e)&&e.name===`WorkflowRunCancelledError`}},R=class extends f{runSpecVersion;worldSpecVersion;constructor(e,t){super(`Run requires spec version ${e}, but world supports version ${t}. Please upgrade 'workflow' package.`),this.name=`RunNotSupportedError`,this.runSpecVersion=e,this.worldSpecVersion=t}static is(e){return c(e)&&e.name===`RunNotSupportedError`}},z=class extends Error{fatal=!0;constructor(e){super(e),this.name=`FatalError`}static is(e){return c(e)?e.name===`FatalError`||e.fatal===!0:!1}},B=class extends Error{retryAfter;constructor(e,t={}){super(e),this.name=`RetryableError`,this.retryAfter=t.retryAfter===void 0?new Date(Date.now()+1e3):a(t.retryAfter)}static is(e){return c(e)&&e.name===`RetryableError`}};const V="Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account.",H=Symbol.for(`@workflow/errors//FatalError`),U=Symbol.for(`@workflow/errors//RetryableError`),W=Symbol.for(`@workflow/errors//HookConflictError`),G=Symbol.for(`@workflow/errors//HookForceClaimedError`),K=Symbol.for(`@workflow/errors//RuntimeDecryptionError`),q=Symbol.for(`@workflow/errors//StreamError`);typeof globalThis<`u`&&(Object.hasOwn(globalThis,H)||Object.defineProperty(globalThis,H,{value:z,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,U)||Object.defineProperty(globalThis,U,{value:B,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,W)||Object.defineProperty(globalThis,W,{value:D,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,G)||Object.defineProperty(globalThis,G,{value:O,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,K)||Object.defineProperty(globalThis,K,{value:b,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,q)||Object.defineProperty(globalThis,q,{value:M,writable:!1,enumerable:!1,configurable:!1}));export{g as A,T as C,m as D,L as E,n as F,s as M,a as N,h as O,r as P,x as S,w as T,M as _,D as a,P as b,y as c,B as d,j as f,C as g,S as h,z as i,p as j,E as k,I as l,b as m,d as n,O as o,R as p,A as r,k as s,_ as t,v as u,N as v,f as w,V as x,F as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./rolldown-runtime-B_knIduE.js";import{D as n,T as r,_t as i,b as a,f as o,ht as s,pt as c,st as l}from"./dist-CyBgVS7g.js";import{At as u,Bn as d,Br as f,Hr as p,It as m,Mr as h,Mt as g,Nt as _,Ot as v,Qt as y,Ur as b,Xt as ee,Y as x,Yn as te,Zt as S,br as ne,jt as C,kt as w,nr as re,rt as T,ut as E,zn as ie}from"./serialization-DPdYS_w2.js";import{M as ae,j as oe,l as se}from"./dist-T5NnW-0k.js";var D=t(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),O=t(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),k=t(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=D(),a=O();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),A=t(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),ce=t(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),j=t(((e,t)=>{let n=O(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=D(),{safeRe:a,t:o}=k(),s=A(),{compareIdentifiers:c}=ce();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);this.prerelease=l[4]?l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),M=t(((e,t)=>{let n=j();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),le=t(((e,t)=>{let n=M();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),ue=t(((e,t)=>{let n=M();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),de=t(((e,t)=>{let n=j();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),fe=t(((e,t)=>{let n=M();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),pe=t(((e,t)=>{let n=j();t.exports=(e,t)=>new n(e,t).major})),me=t(((e,t)=>{let n=j();t.exports=(e,t)=>new n(e,t).minor})),he=t(((e,t)=>{let n=j();t.exports=(e,t)=>new n(e,t).patch})),ge=t(((e,t)=>{let n=M();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),N=t(((e,t)=>{let n=j();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),_e=t(((e,t)=>{let n=N();t.exports=(e,t,r)=>n(t,e,r)})),ve=t(((e,t)=>{let n=N();t.exports=(e,t)=>n(e,t,!0)})),P=t(((e,t)=>{let n=j();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),ye=t(((e,t)=>{let n=P();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),be=t(((e,t)=>{let n=P();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),F=t(((e,t)=>{let n=N();t.exports=(e,t,r)=>n(e,t,r)>0})),I=t(((e,t)=>{let n=N();t.exports=(e,t,r)=>n(e,t,r)<0})),xe=t(((e,t)=>{let n=N();t.exports=(e,t,r)=>n(e,t,r)===0})),Se=t(((e,t)=>{let n=N();t.exports=(e,t,r)=>n(e,t,r)!==0})),L=t(((e,t)=>{let n=N();t.exports=(e,t,r)=>n(e,t,r)>=0})),R=t(((e,t)=>{let n=N();t.exports=(e,t,r)=>n(e,t,r)<=0})),Ce=t(((e,t)=>{let n=xe(),r=Se(),i=F(),a=L(),o=I(),s=R();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),we=t(((e,t)=>{let n=j(),r=M(),{safeRe:i,t:a}=k();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2],c=o[3]||`0`,l=o[4]||`0`,u=t.includePrerelease&&o[5]?`-${o[5]}`:``,d=t.includePrerelease&&o[6]?`+${o[6]}`:``;return r(`${s}.${c}.${l}${u}${d}`,t)}})),Te=t(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),z=t(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,re(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>w(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(T(this.set[t],e,this.options))return!0;return!1}};let r=new(Te()),i=A(),a=B(),o=O(),s=j(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=k(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=D(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=x(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=S(e,t),o(`xrange`,e),e=C(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>ee(e,t)).join(` `),ee=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},x=(e,t)=>e.trim().split(/\s+/).map(e=>te(e,t)).join(` `),te=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},S=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>ne(e,t)).join(` `)),ne=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},C=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),w=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),re=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),T=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),B=t(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.value=this.semver===n?``:this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),this.semver=r[2]?new c(r[2],this.options.loose):n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``||new l(t.value,n).test(this.value):t.operator===``?t.value===``||new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=A(),{safeRe:i,t:a}=k(),o=Ce(),s=O(),c=j(),l=z()})),V=t(((e,t)=>{let n=z();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Ee=t(((e,t)=>{let n=z();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),De=t(((e,t)=>{let n=j(),r=z();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Oe=t(((e,t)=>{let n=j(),r=z();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),ke=t(((e,t)=>{let n=j(),r=z(),i=F();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),Ae=t(((e,t)=>{let n=z();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),H=t(((e,t)=>{let n=j(),r=B(),{ANY:i}=r,a=z(),o=V(),s=F(),c=I(),l=R(),u=L();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),je=t(((e,t)=>{let n=H();t.exports=(e,t,r)=>n(e,t,`>`,r)})),Me=t(((e,t)=>{let n=H();t.exports=(e,t,r)=>n(e,t,`<`,r)})),Ne=t(((e,t)=>{let n=z();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),Pe=t(((e,t)=>{let n=V(),r=N();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),Fe=t(((e,t)=>{let n=z(),r=B(),{ANY:i}=r,a=V(),o=N(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),U=e(t(((e,t)=>{let n=k(),r=D(),i=j(),a=ce();t.exports={parse:M(),valid:le(),clean:ue(),inc:de(),diff:fe(),major:pe(),minor:me(),patch:he(),prerelease:ge(),compare:N(),rcompare:_e(),compareLoose:ve(),compareBuild:P(),sort:ye(),rsort:be(),gt:F(),lt:I(),eq:xe(),neq:Se(),gte:L(),lte:R(),cmp:Ce(),coerce:we(),Comparator:B(),Range:z(),satisfies:V(),toComparators:Ee(),maxSatisfying:De(),minSatisfying:Oe(),minVersion:ke(),validRange:Ae(),outside:H(),gtr:je(),ltr:Me(),intersects:Ne(),simplifyRange:Pe(),subset:Fe(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}))(),1);const Ie=[{format:h.ENCRYPTED,minVersion:`4.2.0-beta.64`},{format:h.GZIP,minVersion:`5.0.0-beta.18`},{format:h.ZSTD,minVersion:`5.0.0-beta.18`},{format:h.SEALED,minVersion:`5.0.0-beta.37`}],Le=[{capability:`framedByteStreams`,minVersion:`5.0.0-beta.15`}],Re=new Set([h.DEVALUE_V1]);function ze(e){return typeof e!=`string`||!U.default.valid(e)?!1:U.default.satisfies(e,`^22.15.0 || >=23.8.0`)}function W(){try{let e=globalThis.process?.versions;return!e||e.bun||e.deno?void 0:typeof e.node==`string`?e.node:void 0}catch{return}}function Be(e,t){if(!e||!U.default.valid(e))return{supportedFormats:Re,framedByteStreams:!1};let n=new Set(Re);for(let{format:t,minVersion:r}of Ie)U.default.gte(e,r)&&n.add(t);ze(t)||n.delete(h.ZSTD);let r={supportedFormats:n,framedByteStreams:!1};for(let{capability:t,minVersion:n}of Le)U.default.gte(e,n)&&(r[t]=!0);return r}function Ve(e){return e.supportedFormats.has(h.GZIP)?e.supportedFormats.has(h.ZSTD)?!0:`gzip`:!1}const G=`5.2.0`;function He(){return s(`WORKFLOW_MAX_QUEUE_DELIVERIES`,48,{integer:!0,min:1,max:48})}const K=24e4,q=3e4,J=78e4,Y=i(`@workflow/core//envWarnings`,1,()=>({replayTimeoutValues:new Set,maxInlineStepsValues:new Set,maxEventsValues:new Set}));function X(e,t,n){Y.replayTimeoutValues.has(e)||(Y.replayTimeoutValues.add(e),x.warn(t,n))}function Ue(){let e=process.env.WORKFLOW_REPLAY_TIMEOUT_MS;if(!e)return K;let t=Number(e);return!Number.isFinite(t)||t<=0?(X(e,`Ignoring WORKFLOW_REPLAY_TIMEOUT_MS: not a positive finite number; using default`,{raw:e,defaultMs:K}),K):t<3e4?(X(e,`WORKFLOW_REPLAY_TIMEOUT_MS below minimum; clamped`,{raw:e,clampedMs:q,minMs:q}),q):t>78e4?(X(e,`WORKFLOW_REPLAY_TIMEOUT_MS above maximum; clamped`,{raw:e,clampedMs:J,maxMs:J}),J):t}function We(){return s(`WORKFLOW_REPLAY_TIMEOUT_MAX_RETRIES`,3,{integer:!0})}function Ge(){let e=process.env.WORKFLOW_MAX_INLINE_STEPS;if(!e)return 3;let t=Number(e);return!Number.isInteger(t)||t<=0?(Y.maxInlineStepsValues.has(e)||(Y.maxInlineStepsValues.add(e),x.warn(`Ignoring WORKFLOW_MAX_INLINE_STEPS: not a positive integer; using default`,{raw:e,defaultValue:3})),3):t<1?1:t>16?(Y.maxInlineStepsValues.has(e)||(Y.maxInlineStepsValues.add(e),x.warn(`WORKFLOW_MAX_INLINE_STEPS above maximum; clamped`,{raw:e,clampedValue:16,maxValue:16})),16):t}const Ke=131072;function qe(){return process.env.WORKFLOW_RESILIENT_STEP_DISPATCH===`1`}function Je(){let e=process.env.WORKFLOW_BATCH_TRANSITIONS;return e===void 0||e===``||e!==`0`&&e.toLowerCase()!==`false`}function Ye(){let e=process.env.WORKFLOW_MAX_EVENTS_OVERRIDE;if(!e)return;let t=Number(e);if(!Number.isInteger(t)||t<=0){Y.maxEventsValues.has(e)||(Y.maxEventsValues.add(e),x.warn(`Ignoring WORKFLOW_MAX_EVENTS_OVERRIDE: not a positive integer; using server limit`,{raw:e}));return}return t}function Xe(){let e=process.env.WORKFLOW_OPTIMISTIC_INLINE_START;return e===void 0||e===``?!1:e===`1`||e.toLowerCase()===`true`}function Ze(){let e=process.env.WORKFLOW_OPTIMISTIC_INLINE_START;return e===void 0||e===``?!1:e===`0`||e.toLowerCase()===`false`}function Qe(){let e=process.env.WORKFLOW_TURBO;return e===void 0||e===``||e!==`0`&&e.toLowerCase()!==`false`}function $e(){let e=process.env.WORKFLOW_RETAINED_VM;return e===void 0||e===``||e!==`0`&&e.toLowerCase()!==`false`}const et=`WORKFLOW_EXPERIMENTAL_DYNAMIC_WORKFLOWS`;function tt(){let e=process.env[et];return e===void 0?!1:e===`1`||e.toLowerCase()===`true`}function nt(){let e=process.env.WORKFLOW_INLINE_OWNERSHIP;return e===void 0||e===``||e!==`0`&&e.toLowerCase()!==`false`}function rt(){return s(`WORKFLOW_INLINE_OWNERSHIP_LEASE_SECONDS`,860,{integer:!0,min:1,max:900})}function it(){return s(`WORKFLOW_REPLAY_DIVERGENCE_MAX_RETRIES`,3,{integer:!0})}function at(){return s(`WORKFLOW_OPEN_WAIT_CLOCK_SKEW_MS`,3e4,{integer:!0})}function ot(){return s(`WORKFLOW_PRECONDITION_MAX_INPROCESS_RESTARTS`,3,{integer:!0})}function st(){return s(`WORKFLOW_PRECONDITION_MAX_REINVOCATIONS`,5,{integer:!0})}function ct(){return s(`WORKFLOW_PRECONDITION_REINVOKE_DELAY_SECONDS`,2,{integer:!0})}function lt(){return s(`WORKFLOW_DEPLOYMENT_MISMATCH_MAX_RETRIES`,3,{integer:!0,min:0})}const ut=/^[a-zA-Z0-9_\-./@()[\]]+$/;function dt(e,t){if(!ut.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, at signs, parentheses, or square brackets`);return`${r(`workflow`,n(t))}${e}`}const ft=c();function pt(e){return`__health_check__${e}`}const mt=1;function ht(e){let t=a.safeParse(e);if(t.success)return t.data}function gt(e){return`wrun_hc_${e}`}async function _t(e,t){let n=await b(),r=pt(e.correlationId),i;if(e.runId)try{let t=await n.getEncryptionKeyForRun?.(e.runId);t&&(i=f((await p(t)).publicKey))}catch(t){x.warn(`Health check could not derive a run public key; the caller will fall back to a key lookup`,{correlationId:e.correlationId,error:t instanceof Error?t.message:String(t)})}let a=JSON.stringify({healthy:!0,correlationId:e.correlationId,specVersion:t??8,workflowCoreVersion:G,nodeVersion:W(),hookResumeInputVersion:1,...tt()?{dynamicWorkflowVersion:1}:{},...i?{encryptionPublicKey:i}:{},timestamp:Date.now()}),o=gt(e.correlationId);await n.streams.write(o,r,a),await n.streams.close(o,r)}function vt(e,t){let n;return Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(Error(`Operation timed out after ${t}ms`)),t)})]).finally(()=>clearTimeout(n))}async function yt(e,t){let n=[],r=!1,i=!1;for(;!r&&!i;){let a=e.read(),o=new Promise(e=>setTimeout(()=>{i=!0,e({done:!0,value:void 0})},t)),s=await Promise.race([a,o]);r=s.done,s.value&&n.push(s.value)}return{chunks:n,timedOut:i}}function bt(e){if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;let i=new TextDecoder().decode(n),a;try{a=JSON.parse(i)}catch{return i.length>0?{healthy:!0,format:`text`}:null}if(typeof a!=`object`||!a||!(`healthy`in a)||typeof a.healthy!=`boolean`)return null;let o=a,s={healthy:o.healthy,format:`json`};return typeof o.specVersion==`number`&&(s.specVersion=o.specVersion),typeof o.workflowCoreVersion==`string`&&(s.workflowCoreVersion=o.workflowCoreVersion),typeof o.nodeVersion==`string`&&(s.nodeVersion=o.nodeVersion),typeof o.encryptionPublicKey==`string`&&(s.encryptionPublicKey=o.encryptionPublicKey),typeof o.hookResumeInputVersion==`number`&&(s.hookResumeInputVersion=o.hookResumeInputVersion),typeof o.dynamicWorkflowVersion==`number`&&(s.dynamicWorkflowVersion=o.dynamicWorkflowVersion),s}async function xt(e,t){let i=t?.timeout??3e4,a=e.createRunId?.()??ft(),o=pt(a),s=`${r(`workflow`,n(t?.namespace))}health_check`,c=Date.now();try{for(await e.queue(s,{__healthCheck:!0,correlationId:a,...t?.runId?{runId:t.runId}:{}},{specVersion:1,deploymentId:t?.deploymentId});Date.now()-c<i;)try{let t=i-(Date.now()-c),n=(await vt(e.streams.get(gt(a),o),t)).getReader(),{chunks:r,timedOut:s}=await yt(n,500);if(s){try{n.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=bt(r);if(l)return{...l,latencyMs:Date.now()-c};await new Promise(e=>setTimeout(e,100))}catch{await new Promise(e=>setTimeout(e,100))}return{healthy:!1,error:`Health check timed out after ${i}ms`}}catch(e){return{healthy:!1,error:e instanceof Error?e.message:String(e)}}}function Z(e,t){return new oe(`Event pagination ${t} for workflow run "${e}".`,{code:ae.WORLD_CONTRACT_ERROR})}function St(e,t,n){if(t){if(n.has(t))throw Z(e,`did not advance`);n.add(t)}}function Q(e,t,n){if(t.length===0)return;let r=n??new Set(e.map(e=>e.eventId));for(let n of t)r.has(n.eventId)||(r.add(n.eventId),e.push(n))}function Ct(e,t){let n=e.length;for(;n>0;){let r=e[n-1];if(r.eventId===t.eventId)return;if(r.eventId<t.eventId)break;n--}e.splice(n,0,t)}function wt(e,t,n,r){if(t){if(n===null)throw Z(e,`returned more pages without a cursor`);if(r.has(n))throw Z(e,`repeated a cursor`)}}function Tt(e,t,n){return t!==null&&!n&&oe.is(e)&&e.status===400}const $=`skip-step-inputs`;function Et(e){return e?.sinceCursor===void 0?e:{resolveData:$,...e}}async function Dt(e,t){let n=t!==void 0;return E(`workflow.replay.load`,async r=>{r?.setAttributes({...re(e),...te(n?`events_list_incremental`:`events_list`)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,u=!1,f=await b(),p=Date.now();for(;c;){let t=Date.now(),r=s;St(e,r,o);let d;try{d=await f.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0},resolveData:$})}catch(t){if(Tt(t,r,u)){x.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,u=!0;continue}throw t}Q(i,d.data,a),c=d.hasMore,wt(e,c,d.cursor,o),s=d.cursor??s,l++,x.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:d.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return x.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-p}),r?.setAttributes({...ie(i.length),...d(l)}),{events:i,cursor:s}})}function Ot(e,t){Q(e.events,t.events),e.cursor=t.cursor??e.cursor}function kt(){return process.env.WORKFLOW_SLOT_GAP_CHECK!==`0`}function At(e,t){let n=e.length;Q(e,t);let r=e.length-n;return r>0&&e.sort((e,t)=>e.eventId<t.eventId?-1:+(e.eventId>t.eventId)),r}function jt(e,t){let n=t.events?.length??0;return n===0?{added:0,offered:0,truncated:!1}:t.hasMore===!0?{added:0,offered:n,truncated:!0}:{added:At(e,t.events??[]),offered:n,truncated:!1}}function Mt(e){let t;for(let n of e){let e=o(n.eventId);(t===void 0||e>t)&&(t=e)}return t}function Nt(e){let t=new Set,n=0;for(let r of e){let e=o(r.eventId);t.add(e),e>n&&(n=e)}if(n===0)return;let r=t.has(1)?1:2;if(t.size===n-r+1)return;let i,a=0;for(let e=r;e<=n;e++)t.has(e)||(i??=e,a++);if(i!==void 0)return{firstMissingSlot:i,missingCount:a,maxSlot:n}}const Pt=3;async function Ft(e,t){let n=t,r=Nt(n.events);for(let t=0;r!==void 0&&t<3;t++)await new Promise(e=>setTimeout(e,25*2**t)),n=await Dt(e),r=Nt(n.events);return{log:n,gap:r}}function It(e){let t=Mt(e);return t===void 0?{}:{eventCount:t}}function Lt(e,t){if(!se.is(e))return null;let n=e.details;if(typeof n!=`object`||!n)return null;let{events:r,cursor:i}=n;if(!Array.isArray(r)||r.length===0)return null;for(let e of r)if(typeof e!=`object`||!e||typeof e.eventId!=`string`||e.runId!==t)return null;return{events:r,cursor:typeof i==`string`?i:null}}const Rt={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function zt(e,t){return async n=>{let r=new URL(n.url);return r.searchParams.has(`__health`)?n.method===`OPTIONS`?new Response(null,{status:204,headers:Rt}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??8,workflowCoreVersion:G,nodeVersion:W()}),{status:200,headers:{"Content-Type":`application/json`,...Rt}}):await e(n)}}function Bt(e,t){return e?.[l]??t}function Vt(e){return{deploymentId:e.deploymentId,specVersion:e.specVersion??0,...e.startedAt?{startedAt:+e.startedAt}:{},rootRunId:Bt(e.attributes,e.runId)}}function Ht(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function Ut(e,t){return`${e}:${Ht(t)}`}async function Wt(e,...t){let n=t[0];await E(`queue.publish`,{attributes:{...g(`vercel-queue`),...w(n),...C(`publish`),..._(`vercel-queue`),...y(`vercel-queue`),...S(`vqs`),...ee(`publish`)},kind:await T(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(u(r))})}async function Gt(e,t,n){if(n.length===0)return;let r=e.queueBatch?.bind(e);if(!r){await Promise.all(n.map(n=>Wt(e,t,n.message,n.opts)));return}await E(`queue.publish`,{attributes:{...g(`vercel-queue`),...w(t),...C(`publish`),...v(n.length),..._(`vercel-queue`),...y(`vercel-queue`),...S(`vqs`),...ee(`publishBatch`)},kind:await T(`PRODUCER`)},async()=>{let e=await r(t,n);if(e.length!==n.length)throw Object.assign(Error(`Queue batch for ${t} returned ${e.length} result(s) for ${n.length} message(s)`),{retryable:!0});let i=e.filter(e=>e.error!==void 0);if(i.length===0)return;let a=i.some(e=>e.error!==void 0&&e.retryable),o=Error(`Failed to publish ${i.length} of ${n.length} queue message(s) to ${t}: ${i[0]?.error}`);throw Object.assign(o,{retryable:a}),o})}function Kt(e){if(e.requestedAt)try{return m(Date.now()-e.requestedAt.getTime())}catch{return}}async function qt(e,t,n){let r=typeof t==`string`?await e.getEncryptionKeyForRun?.(t,n):await e.getEncryptionKeyForRun?.(t);return r?await ne(r):void 0}function Jt(e,t){let n;return()=>(n||=qt(e,t),n)}export{Ve as $,et as A,ct as B,Bt as C,Ut as D,It as E,Ge as F,tt as G,We as H,He as I,Ze as J,nt as K,at as L,lt as M,rt as N,zt as O,Ye as P,G as Q,ot as R,qt as S,Ft as T,Ue as U,it as V,Je as W,Qe as X,qe as Y,$e as Z,At as _,Ot as a,Wt as b,Kt as c,xt as d,W as et,Ct as f,Jt as g,Mt as h,jt as i,Ke as j,Et as k,dt as l,Dt as m,$ as n,Q as o,kt as p,Xe as q,Pt as r,Nt as s,mt as t,Be as tt,_t as u,ht as v,Vt as w,Gt as x,Lt as y,st as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as e,F as t}from"./dist-T5NnW-0k.js";function n(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function r(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}var i=class e extends Error{items;steps;globalThis;stepCount;hookCount;waitCount;attributeCount;hookDisposedCount;abortCount;observedHookIds;constructor(e,n){let r=[...e.values()],i=0,a=0,o=0,s=0,c=0,l=0;for(let e of r)e.type===`step`?i++:e.type===`hook`?e.disposed?c++:e.abortRequested?l++:a++:e.type===`wait`?o++:e.type===`attribute`&&s++;let u=[];i>0&&u.push(`${i} ${t(`step`,`steps`,i)}`),a>0&&u.push(`${a} ${t(`hook`,`hooks`,a)}`),o>0&&u.push(`${o} ${t(`wait`,`waits`,o)}`),s>0&&u.push(`${s} ${t(`attribute write`,`attribute writes`,s)}`),c>0&&u.push(`${c} hook ${t(`disposal`,`disposals`,c)}`);let d=i+a+o+s+c,f=t(`has`,`have`,d),p=+(i>0)+ +(a>0)+ +(o>0)+ +(s>0)+ +(c>0),m;m=p>1?`processed`:i>0?`run`:a>0||o>0?`created`:s>0?`written`:c>0?`processed`:`received`;let h=u.length>0?`${u.join(` and `)} ${f} not been ${m} yet`:`0 steps have not been run yet`;super(h),this.name=`WorkflowSuspension`,this.items=r,this.steps=r,this.globalThis=n,this.stepCount=i,this.hookCount=a,this.waitCount=o,this.attributeCount=s,this.hookDisposedCount=c,this.abortCount=l}static is(t){return t instanceof e}};function a(){throw new e(`This API is not available inside a workflow function. Workflow functions run in a deterministic VM; move the call to a step function for full Node.js access.`)}const o=Symbol.for(`@workflow/core//registeredSteps`),s=globalThis,c=s[o]??=new Map,l=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);function u(e){let t=e.split(`//`);if(t.length!==3||t[0]!==`step`)return[];let n=t[1],r=t[2],i=new Set,a=e=>{e!==n&&i.add(e)};if(n.startsWith(`./workflows/`)){let e=n.slice(2);a(`./example/${e}`),a(`./src/${e}`)}else if(n.startsWith(`./example/workflows/`)){let e=n.slice(10);a(`./${e}`),a(`./src/${e}`)}else if(n.startsWith(`./src/workflows/`)){let e=n.slice(6);a(`./${e}`),a(`./example/${e}`)}return Array.from(i,e=>`step//${e}//${r}`)}function d(e){if(l.has(e)){for(let[t,n]of c.entries())if(t.endsWith(`//${e}`))return n}}function f(e,t){c.set(e,t),t.stepId=e}function p(e){let t=c.get(e);if(t)return t;for(let t of u(e)){let e=c.get(t);if(e)return e}let n=d(e);if(n)return n}const m={hook:[`hook`,`wait`,`step`],wait:[`hook`,`step`],step:[`wait`,`hook`,`step`]};function h(e,t,n,r){return n>=t||!m[e].includes(r.kind)?!1:!(e===`step`&&!r.armed)}function g(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=_(e,t,n,r);return r.set(t,a),a}function _(e,t,n,r){if(!n.armed)return!1;for(let[i,a]of e)if(h(n.kind,t,i,a)&&!g(e,i,a,r))return!1;return!0}function v(){return process.env.WORKFLOW_LOG_ORDER_DRAWS!==`0`}function y(e){return e===0&&typeof setImmediate==`function`?new Promise(e=>setImmediate(e)):new Promise(t=>setTimeout(t,e))}async function b(e,t){for(;;){let n=e.mintCount??0,r=e.pendingDeliveries;if(await y(await e.promiseQueue.then(()=>!1,()=>!0)?50:0),(e.mintCount??0)!==n||r!==0||e.pendingDeliveries!==0)continue;let i=!1;for(let[n,r]of e.pendingDeliveryBarriers??[])if(n<t&&r.armed){i=!0;break}if(!i)return}}async function x(e,t,n){if(t===void 0||!e.pendingDeliveryBarriers)return;let r=e.pendingDeliveryBarriers,i=[];for(let[e,a]of r)h(n,t,e,a)&&i.push(a.released);if(i.length>0&&await Promise.all(i),v()){await b(e,t);return}i.length>0&&await new Promise(e=>setTimeout(e,0))}function S(t,r,i,a){let o=!1,s=()=>!o&&(o=!0,t.advanceClock?.(a.deliveredAt),!0),c=t.pendingDeliveryBarriers;if(!c||r===void 0)return{markDelivered:()=>{s()},arm:()=>{}};let l=a=>{if(c.has(r))throw new e(`Delivery barrier already registered at event index ${r}`);let{promise:o,resolve:s}=n(),l={kind:i,released:o,armed:a,retired:!1,retire:()=>{l.retired||(l.retired=!0,c.get(r)===l&&c.delete(r),s())}};return c.set(r,l),w(t),l},u=l(a.armed??!0);return{markDelivered:()=>{s()&&u.retire()},arm:()=>{if(!o){if(u.retired){u=l(!0);return}if(c.get(r)!==u)throw new e(`Delivery barrier lost ownership of event index ${r}`);u.armed=!0}}}}const C=new WeakSet;function w(e){let t=e.pendingDeliveryBarriers;if(!t||C.has(e))return;C.add(e);let n=()=>{setTimeout(i,0)},r=()=>{setTimeout(i,50)},i=()=>{if(t.size===0){C.delete(e);return}if(!T(e)){e.promiseQueue.then(n,r);return}for(;t.size>0&&T(e);){let e,n;for(let[r,i]of t)(e===void 0||r<e)&&(e=r,n=i);n?.retire()}setTimeout(i,0)};setTimeout(i,0)}function T(e){return e.pendingDeliveries===0&&!E(e)}function E(e){let t=e.pendingDeliveryBarriers;if(!t||t.size===0)return!1;let n=new Map;for(let[e,r]of t)if(g(t,e,r,n))return!0;return!1}function D(e){return e.pendingDeliveries===0&&(!e.pendingDeliveryBarriers||e.pendingDeliveryBarriers.size===0)}function O(e,t){let n=()=>{D(e)?t():e.promiseQueue.then(()=>{setTimeout(n,0)})};setTimeout(n,0)}function k(e){let t=e.suspensionGeneration;O(e,()=>{if(t!==e.suspensionGeneration)return;let n=new i(e.invocationsQueue,e.globalThis);if(e.hookPayloadAwaiters){let t=new Set;for(let[n,r]of e.hookPayloadAwaiters)r()&&t.add(n);n.observedHookIds=t}e.onWorkflowError(n)})}export{S as a,k as c,r as d,n as f,D as i,a as l,p as n,f as o,E as r,O as s,x as t,i as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-B_knIduE.js";import{H as t,a as n,b as r,lt as i,pt as a,w as o}from"./dist-CyBgVS7g.js";import{Ct as s,Mr as c,Tr as l,Un as u,Ur as d,Vr as f,Y as p,br as m,f as h,j as g,nr as _,ot as ee,si as v,ti as y,ut as b,vt as x,wt as te,xt as S,yt as ne}from"./serialization-DPdYS_w2.js";import{A as C,f as w,j as T,k as E,n as D,o as O,s as k}from"./dist-T5NnW-0k.js";import{$ as re,l as A,tt as ie}from"./helpers-DlLD3ov_.js";import{n as j,r as ae,t as oe}from"./wait-until-xbRRDuUf.js";import{z as M}from"#compiled/zod/index.js";const N=[25,100];function P(e,t){if(t?.(e))return!1;let n=e??{},r=n.status??n.statusCode;if(typeof r==`number`)return r>=500||r===408||r===429;let i=e?.name;return i!==`BadRequestError`&&i!==`UnauthorizedError`&&i!==`ForbiddenError`}async function F(e,t){let n;for(let r=0;r<=N.length;r++)try{await e();return}catch(e){if(n=e,!P(e,t))break;let i=N[r];i!==void 0&&await new Promise(e=>setTimeout(e,i))}throw k.is(n)?new C(`The hook resume was committed, but its workflow wake could not be published`,{cause:n}):n}async function I(e,t,n){let r=n.claimedFrom;if(!r||r.runId===t)return`skipped`;if(r.workflowName===void 0)return p.warn(`Force-claimed a hook from a run whose workflow name is unknown; not waking it`,{workflowRunId:t,victimRunId:r.runId}),`skipped`;try{return await F(()=>e.queue(A(r.workflowName),{runId:r.runId},{...r.deploymentId!==void 0&&{deploymentId:r.deploymentId},specVersion:r.runSpecVersion??1,idempotencyKey:`hook-force-claim-${n.hookId}`}),e.isDeploymentUnavailableError?.bind(e)),`published`}catch(e){return p.error(`Force-claimed a hook token but could not wake the run it was taken from; it will read the disposal on its next invocation`,{workflowRunId:t,victimRunId:r.runId,error:e instanceof Error?e.message:String(e)}),`failed`}}function L(e,t=Date.now()){let n=[];if(!e)return n;for(let r of e){if(r.eventType!==`hook_created`||r.eventData?.forceClaimedFrom===void 0)continue;let e=new Date(r.createdAt).getTime();(Number.isNaN(e)||t-e<864e5)&&n.push(r)}return n}async function R(e,t,n,r={}){let{alreadyWoken:i}=r,a=L(n,r.nowMs).filter(e=>{let n=e.eventData.forceClaimedFrom;return n.runId!==t&&n.workflowName!==void 0&&!i?.has(e.correlationId)});a.length!==0&&await Promise.all(a.map(async n=>{i?.add(n.correlationId);let r=n.eventData.forceClaimedFrom,a=await I(e,t,{hookId:n.correlationId,claimedFrom:r});p.debug(`Republished the wake of a force-claimed hook victim`,{workflowRunId:t,hookId:n.correlationId,victimRunId:r.runId,victimWake:a})}))}const z=M.object({type:M.literal(`hook_resume`),version:M.literal(1),hookId:M.string(),token:M.string(),payload:M.instanceof(Uint8Array)}),se=M.discriminatedUnion(`status`,[M.object({status:M.literal(`accepted`)}),M.object({status:M.literal(`rejected`),code:M.enum([`HOOK_NOT_FOUND`,`INVALID_INPUT`])})]);async function B(e,n,r,a){let o=z.safeParse(a);if(!o.success||!r)throw new T(`Invalid invocation input`,{status:400,code:`INVALID_INPUT`});let s=o.data,c=Buffer.from(await crypto.subtle.digest(`SHA-256`,s.payload)).toString(`hex`);try{let r=await e.hooks.get(s.hookId);if(r.runId!==n||r.token!==s.token)throw new k(s.token);let i=await e.runs.get(n,{resolveData:`none`});if(t(i.status))throw new k(s.token)}catch(a){if(!V(a))throw a;let o=await e.runs.get(n,{resolveData:`none`});if(o.expiredAt||t(o.status)&&i(o.attributes).mode===`none`)throw new T(`Invocation data has expired under the run retention policy`,{status:410,code:`INVOCATION_DATA_EXPIRED`});if(!e.capabilities?.hookResumeDedup||!await H(e,n,s.hookId,r))throw a}return await e.events.create(n,{eventType:`hook_received`,correlationId:s.hookId,specVersion:8,eventData:{token:s.token,payload:s.payload}},{...e.capabilities?.hookResumeDedup?{resumeId:r,resumePayloadDigest:c}:{}}),{status:`accepted`}}function V(e){return k.is(e)||w.is(e)||E.is(e)}async function H(e,t,n,r){let i=null;do{let a=await e.events.listByCorrelationId({runId:t,correlationId:n,resolveData:`none`,pagination:{limit:100,...i?{cursor:i}:{}}});if(a.data.some(e=>e.eventType===`hook_received`&&e.resumeId===r))return!0;i=a.hasMore?a.cursor:null}while(i);return!1}var U=class{revision=0;listeners=new Set;notify(){this.revision++;for(let e of this.listeners)e()}async waitForActivity(e,t=100){return this.revision!==e||(await new Promise(e=>{let n=()=>{clearTimeout(r),this.listeners.delete(n),e()},r=setTimeout(n,t);this.listeners.add(n)}),this.revision!==e)}};function W(e){return t=>{let n=new Map;return async(i,a)=>{if(r.safeParse(i).success)return t(i,a);let s=o.safeParse(i);if(!e.capabilities?.invoke||!s.success||s.data.stepId)return t(i,a);let c=s.data,l=n.get(c.runId);l||(l={activity:new U,admission:Promise.resolve(),references:0},n.set(c.runId,l));let u=l;u.references++;try{if(c.invoke){if(!c.requestId)throw new C(`Invocation requestId is required`);let t=c.requestId,n=u.admission.then(()=>b(`workflow.invoke.receive`,async n=>{n?.setAttributes({..._(c.runId),"workflow.invocation.id":t});let r=await B(e,c.runId,t,c.input);return r.status===`accepted`&&u.activity.notify(),r}));return u.admission=n.catch(()=>{}),await n}if(u.execution)return await u.execution;let n=t(i,a,u.activity);u.execution=n;try{return await n}finally{u.execution===n&&(u.execution=void 0)}}finally{u.references--,u.references===0&&n.get(c.runId)===u&&n.delete(c.runId)}}}}var G=e({getHookByToken:()=>X,resumeHook:()=>Z,resumeWebhook:()=>pe});const K=a();async function ce(e){let t=await crypto.subtle.digest(`SHA-256`,e),n=new Uint8Array(t),r=``;for(let e of n)r+=e.toString(16).padStart(2,`0`);return r}function le(e){let t=e.executionContext?.workflowCoreVersion,n=e.executionContext?.traceCarrier,r=e.executionContext?.hookResumeInputVersion,i=e.executionContext?.nodeVersion;return{deploymentId:e.deploymentId,workflowName:e.workflowName,runSpecVersion:e.specVersion,workflowCoreVersion:typeof t==`string`?t:void 0,nodeVersion:typeof i==`string`?i:void 0,traceCarrier:n&&typeof n==`object`?n:void 0,encryptionPublicKey:e.encryptionPublicKey,hookResumeInputVersion:typeof r==`number`?r:void 0}}async function q(e){if(e.resumeContext)return{resumeContext:e.resumeContext,source:`hook`};let t=await(await d()).runs.get(e.runId);return{resumeContext:le(t),source:`run_fallback`,run:t}}async function ue(e,t){let n=await d(),r=t.run?await n.getEncryptionKeyForRun?.(t.run):await n.getEncryptionKeyForRun?.(e.runId,{deploymentId:t.resumeContext.deploymentId});return r?await v(r):void 0}function de(e){let t=Object.getOwnPropertyDescriptor(e,`metadata`);return t!==void 0&&typeof t.get==`function`}function J(e){let t=e.metadata,n,r,i=async()=>{let n=await d(),i=await q(e),a=i.run?await n.getEncryptionKeyForRun?.(i.run):await n.getEncryptionKeyForRun?.(e.runId,{deploymentId:i.resumeContext.deploymentId});return r=a?await m(a):void 0,await g(t,e.runId,r)},a=e;return Object.defineProperty(a,"metadata",{get:()=>n??=t===void 0?Promise.resolve(void 0):i(),enumerable:!1,configurable:!0}),{hook:a,metadataEncryptionKey:()=>r}}function Y(e){return de(e)?e:J(e).hook}async function X(e){return J(await(await d()).hooks.getByToken(e)).hook}async function Z(e,t,n){return $(e,t,n,!1,Date.now())}const Q=new WeakMap;async function $(e,t,n,r,i,a=!1){return await j(()=>b(`hook.resume`,async o=>{let s=await d(),c=typeof e==`string`?e:e.token,l=e,u=r,f=n,m=0,h=0,g=K(),_=e=>{if(t instanceof Request&&t.body!==null&&t.bodyUsed)throw o?.setAttributes({"workflow.hook.resume_redirect_unresendable":!0}),new C(`Hook token "${c}" changed owner while this webhook request was being delivered; a request body can be sent only once and it was not delivered anywhere — retry the request, which will reach the token's new owner`,{cause:e})};for(;;)try{return await fe(s,o,l,t,f,u,i,g,a)}catch(e){if(typeof e==`object`&&e&&Q.get(e)===`not-webhook`)throw e;if(m>=3)throw O.is(e)?(o?.setAttributes({"workflow.hook.resume_redirects_exhausted":!0}),new C(`Hook token "${c}" changed owner ${m} times while this resume was in flight; nothing was delivered — retry the resume`,{cause:e})):e;if(O.is(e)){_(e),m++,o?.setAttributes({"workflow.hook.resume_redirects":m,"workflow.hook.resume_redirect_to_run":e.claimedByRunId}),l=c,u=!0,f=void 0,h=0;continue}if(k.is(e)&&m>0&&typeof l==`string`&&h<5){_(e),h++,await new Promise(e=>setTimeout(e,50));continue}if(k.is(e)&&Q.get(e)!==`lookup`){let t=typeof l==`string`?void 0:l.hookId,n;try{n=await s.hooks.getByToken(c)}catch(e){k.is(e)||p.warn(`Hook resume: re-resolving the token after a not-found failed; surfacing the original error`,{token:c,error:e instanceof Error?e.message:String(e)})}if(n?.claimedFrom!==void 0&&n.hookId!==t&&(t===void 0||n.claimedFrom.hookId===t)&&!(a&&n.isWebhook===!1)){_(e),m++,o?.setAttributes({"workflow.hook.resume_redirects":m,"workflow.hook.resume_redirect_to_run":n.runId}),l=n,u=!0,f=void 0;continue}}throw e}}))}async function fe(e,r,i,a,o,d,m,g,v){try{let y=typeof i==`string`,b;if(y)try{b=await e.hooks.getByToken(i)}catch(e){throw k.is(e)&&Q.set(e,`lookup`),e}else b=i;if(v&&b.isWebhook===!1){let e=new k(b.token);throw Q.set(e,`not-webhook`),e}let x=y||d,T=await q(b),{resumeContext:E}=T;if(r?.setAttributes({...s(b.token),...ne(b.hookId),..._(b.runId),"workflow.hook.resume_context_source":T.source}),T.run&&t(T.run.status))throw new k(b.token);let D=ie(E.workflowCoreVersion,E.nodeVersion),j,M=o?void 0:f(E.encryptionPublicKey);if(M)j=l(M);else{let e=o??await ue(b,T);D.supportedFormats.has(c.ENCRYPTED)||(e=void 0),j=e}let N=(E.runSpecVersion??0)>=5&&re(D),P=[],I=[],L=n(b.specVersion),R=await h(a,b.runId,j,P,globalThis,L,D.framedByteStreams,N,void 0,I);if(await Promise.all(P.map(e=>e.catch(e=>{if(e!==void 0)throw e}))),oe(Promise.all(I),e=>{e!==void 0&&p.warn(`Background readback of hook payload failed`,{workflowRunId:b.runId,hookId:b.hookId,error:e instanceof Error?e.message:String(e)})}),e.capabilities?.invoke===!0&&!L&&R instanceof Uint8Array){if(!e.invoke)throw new C(`World advertises invoke without implementing it`);r?.setAttributes({"workflow.hook.resume_strategy":`invoke`});let t=se.parse(await e.invoke(b.runId,{type:`hook_resume`,version:1,hookId:b.hookId,token:b.token,payload:R},{idempotencyKey:g}));if(t.status===`rejected`)throw t.code===`HOOK_NOT_FOUND`?new k(b.token):new C(`Executor rejected the hook invocation input`);return r?.setAttributes(S(!0)),Y(b)}r?.setAttributes({...u(E.workflowName)});let z=await ee(E.traceCarrier);z&&r?.addLink?.(z);let B=A(E.workflowName),V={deploymentId:E.deploymentId,specVersion:E.runSpecVersion??1},H=((x?b.resumeCapabilities?.hookResumeDedupVersion??0:0)>=1||e.capabilities?.hookResumeDedup===!0)&&!L&&R instanceof Uint8Array;r?.setAttributes({"workflow.hook.resume_strategy":`sequential`});let U=H?g:void 0,W=H?await ce(R):void 0;U&&r?.setAttributes({"workflow.hook.resume_id":U});let G=e=>k.is(e)||w.is(e);try{await e.events.create(b.runId,{eventType:`hook_received`,specVersion:ae(E.runSpecVersion),correlationId:b.hookId,eventData:{...L?{}:{token:b.token},payload:R}},{v1Compat:L,...U&&W?{resumeId:U,resumePayloadDigest:W}:{}})}catch(e){throw O.is(e)?e:G(e)?new k(b.token):e}r?.setAttributes(S(!0));let K=Date.now();return await F(()=>e.queue(B,{runId:b.runId,traceCarrier:E.traceCarrier??void 0,hookResumeTiming:{resumeRequestedAtMs:m,queuePublishRequestedAtMs:K,strategy:`sequential`}},{...V,...U?{idempotencyKey:`hook-${U}`}:{}}),e.isDeploymentUnavailableError?.bind(e)),r?.setAttributes(te(!0)),Y(b)}catch(e){throw r?.setAttributes({...s(typeof i==`string`?i:i.token),...x(!1)}),e}}async function pe(e,t){let n=Date.now(),{hook:r,metadataEncryptionKey:i}=J(await(await d()).hooks.getByToken(e));if(r.isWebhook===!1)throw new k(e);let a=await r.metadata,o,s;if(a&&typeof a==`object`&&`respondWith`in a){if(a.respondWith===`manual`){let{readable:e,writable:n}=new TransformStream;s=e,t[y]=n}else if(a.respondWith instanceof Response)o=a.respondWith;else throw new C(`Invalid \`respondWith\` value: ${a.respondWith}`,{slug:D.WEBHOOK_INVALID_RESPOND_WITH_VALUE})}else o=new Response(null,{status:202});if(await $(r,t,i(),!0,n,!0),s){let e=s.getReader(),t=await e.read();t.value&&(o=t.value),e.cancel()}if(!o)throw new C(`Workflow run did not send a response`,{slug:D.WEBHOOK_RESPONSE_NOT_SENT});return o}export{W as a,G as i,Z as n,I as o,pe as r,R as s,X as t};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{Q as e,_t as t,ht as n,pt as r,tt as i}from"./dist-CyBgVS7g.js";import{A as a,F as o,_ as s,a as c,d as l,h as u,i as d,m as f,o as p,u as m,v as h}from"./dist-T5NnW-0k.js";import{a as g,d as _,f as ee,n as te,t as ne,u as re}from"./private-tQUuwBoQ.js";import{types as v}from"node:util";import{AsyncLocalStorage as y}from"node:async_hooks";function b(e,t){if(typeof t!=`string`)return null;let[n,r,...i]=t.split(`//`);if(n!==e||!r||i.length===0)return null;let a=i.join(`//`),o=a.split(`/`).at(-1)??``,s=``;return s=r.startsWith(`./`)?r.split(`/`).at(-1)??``:(r.split(`@`).slice(0,-1).join(`@`)||r.split(`@`)[0])?.split(`/`).at(-1)??``,[`default`,`__default`].includes(o)&&s&&(o=s),{shortName:o,moduleSpecifier:r,functionName:a}}function x(e){return b(`workflow`,e)}function ie(e){return b(`step`,e)}function ae(e){return ue(ie(e),e)}function oe(e){return ue(x(e),e)}function se(e){return x(e)?.shortName??le(`workflow`,e)??e}function ce(e){return ie(e)?.shortName??le(`step`,e)??e}function le(e,t){if(!t.startsWith(`${e}--`))return null;let n=t.split(`--`).filter(Boolean),r=n.at(-1)?.split(`-`).filter(Boolean).at(-1)??``;if([`default`,`__default`].includes(r)){let t=n.at(-2)?.split(`-`).filter(Boolean).at(-1);t&&t!==e&&(r=t)}return r||null}function ue(e,t){return e?`${e.shortName} (${e.moduleSpecifier})`:t}const de=2**32-1,fe=de-1;var S=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}};const pe=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function me(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===pe}function he(e){return Object.prototype.toString.call(e).slice(8,-1)}function ge(e){switch(e){case`"`:return`\\"`;case`<`:return`\\u003C`;case`\\`:return`\\\\`;case`
|
|
2
|
-
`:return`\\n`;case`\r`:return`\\r`;case` `:return`\\t`;case`\b`:return`\\b`;case`\f`:return`\\f`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:return e<` `?`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}function C(e){let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let r=e[i],a=ge(r);a&&(t+=e.slice(n,i)+a,n=i+1)}return`"${n===0?e:t+e.slice(n)}"`}function _e(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)}const ve=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function ye(e){return ve.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function be(e){return!(!Number.isInteger(e)||e<0||e>fe)}function xe(e){return!(!Number.isInteger(e)||e<0||e>de)}function Se(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return be(+e)}function Ce(e){for(var t=e.length-1;t>=0&&!Se(e[t]);t--);return t+1}function we(e){let t=Object.keys(e);return t.length=Ce(t),t}function Te(e){return new Uint8Array(e).toBase64()}function Ee(e){return Uint8Array.fromBase64(e).buffer}function De(e){return Buffer.from(e).toString(`base64`)}function Oe(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function ke(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function Ae(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}const je=typeof Uint8Array.fromBase64==`function`,Me=typeof process==`object`&&process.versions?.node!==void 0,Ne=je?Te:Me?De:ke,Pe=je?Ee:Me?Oe:Ae;function Fe(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}const Ie=Object.freeze({kind:`not-plain`}),Le=Object.freeze({kind:`symbol-keys`}),Re=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>he(e),isThenable:e=>typeof e.then==`function`,toPromise:e=>Promise.resolve(e),unbox:e=>e.valueOf(),toISOString:e=>isNaN(e.getDate())?``:e.toISOString(),toStringValue:e=>e.toString(),regExpInfo:e=>({source:e.source,flags:e.flags}),valuesOf:e=>e,entriesOf:e=>e,viewInfo:e=>({buffer:e.buffer,byteOffset:e.byteOffset,byteLength:e.byteLength,length:e.length,bufferByteLength:e.buffer.byteLength}),toArrayBuffer:e=>e,lengthOf:e=>e.length,hasOwn:(e,t)=>Object.hasOwn(e,t),indicesOf:e=>we(e),shapeOf:e=>me(e)?_e(e).length>0?Le:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:Ie,get:(e,t)=>e[t]}),ze=Object.freeze({fromPrimitive:e=>e,fromISOString:e=>new Date(e),fromStringValue:(e,t)=>e===`URL`?new URL(t):e===`URLSearchParams`?new URLSearchParams(t):Temporal[e.slice(9)].from(t),fromArrayBuffer:e=>e,fromRegExpInfo:(e,t)=>new RegExp(e,t),fromViewInfo:(e,t,n,r)=>{let i=globalThis[e];return n===void 0?new i(t):new i(t,n,r)},box:e=>Object(e),createArray:e=>Array(e),createSparseArray:e=>{let t=[];return t[fe]=void 0,delete t[fe],t.length=e,t},createObject:()=>({}),createNullPrototypeObject:()=>Object.create(null),createSet:()=>new Set,createMap:()=>new Map,set:(e,t,n)=>{e[t]=n},addValue:(e,t)=>{e.add(t)},addEntry:(e,t,n)=>{e.set(t,n)}});function Be(e,t,n){return Ve(JSON.parse(e),t,n)}function Ve(e,t,n){let r=Fe(ze,n?.operations);if(typeof e==`number`)return s(e,!0);if(!Array.isArray(e)||e.length===0)throw Error(`Invalid input`);let i=e,a=Array(i.length),o=null;function s(e,n=!1){if(e===-1)return r.fromPrimitive(void 0);if(e===-3)return r.fromPrimitive(NaN);if(e===-4)return r.fromPrimitive(1/0);if(e===-5)return r.fromPrimitive(-1/0);if(e===-6)return r.fromPrimitive(-0);if(n||typeof e!=`number`)throw Error(`Invalid input`);if(e in a)return a[e];if(e>=i.length)throw Error(`Invalid input`);let c=i[e];if(!c||typeof c!=`object`)a[e]=r.fromPrimitive(c);else if(Array.isArray(c)){if(typeof c[0]==`string`){let n=c[0],l=t&&Object.hasOwn(t,n)?t[n]:void 0;if(l){let t=c[1];if(typeof t!=`number`&&(t=i.push(c[1])-1),Object.hasOwn(a,t))return a[e]=l(a[t]);if(o??=new Set,o.has(t))throw Error(`Invalid circular reference`);return o.add(t),a[e]=l(s(t)),o.delete(t),a[e]}switch(n){case`Date`:a[e]=r.fromISOString(c[1]);break;case`Set`:let t=r.createSet();a[e]=t;for(let e=1;e<c.length;e+=1)r.addValue(t,s(c[e]));break;case`Map`:let o=r.createMap();a[e]=o;for(let e=1;e<c.length;e+=2)r.addEntry(o,s(c[e]),s(c[e+1]));break;case`RegExp`:a[e]=r.fromRegExpInfo(c[1],c[2]);break;case`Object`:{let t=c[1];if(typeof i[t]==`object`&&i[t][0]!==`BigInt`)throw Error(`Invalid input`);a[e]=r.box(s(t));break}case`BigInt`:a[e]=r.fromPrimitive(BigInt(c[1]));break;case`null`:let l=r.createNullPrototypeObject();a[e]=l;for(let e=1;e<c.length;e+=2){if(c[e]===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");r.set(l,c[e],s(c[e+1]))}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{if(i[c[1]][0]!==`ArrayBuffer`)throw Error(`Invalid data`);let t=s(c[1]);a[e]=r.fromViewInfo(n,t,c[2],c[3]);break}case`ArrayBuffer`:{let t=c[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);a[e]=r.fromArrayBuffer(Pe(t));break}case`URL`:case`URLSearchParams`:case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:a[e]=r.fromStringValue(n,c[1]);break;default:throw Error(`Unknown type ${n}`)}}else if(c[0]===-7){let t=c[1];if(!xe(t))throw Error(`Invalid input`);let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<c.length;e+=2){let i=c[e];if(!be(i)||i>=t)throw Error(`Invalid input`);r.set(n,i,s(c[e+1]))}}else{let t=r.createArray(c.length);a[e]=t;for(let e=0;e<c.length;e+=1){let n=c[e];n!==-2&&r.set(t,e,s(n))}}}else{let t=r.createObject();a[e]=t;for(let e of Object.keys(c)){if(e===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");r.set(t,e,s(c[e]))}}return a[e]}return s(0)}function w(e,t,n){let r=He(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function He(e,t,n,r){let i=Fe(Re,r?.operations),a=[],o=new Map,s=[];if(n)for(let e of Object.getOwnPropertyNames(n))s.push({key:e,fn:n[e]});let c=[],l=0;function u(n,r){let d=i.typeOf(n);if(d===`undefined`)return-1;let f;if(d===`number`){if(f=i.toPrimitive(n),Number.isNaN(f))return-3;if(f===1/0)return-4;if(f===-1/0)return-5;if(f===0&&1/f<0)return-6}let p=i.identify(n);if(o.has(p))return o.get(p);r??=l++,o.set(p,r);for(let{key:e,fn:t}of s){let i=t(n);if(i)return a[r]=`["${e}",${u(i)}]`,r}if(d===`function`)throw new S(`Cannot stringify a function`,c,n,t);if(d===`symbol`)throw new S(`Cannot stringify a Symbol primitive`,c,n,t);let m=``;if(d!==`object`)m=Ue(d===`number`?f:i.toPrimitive(n));else if(i.isThenable(n)){if(!e)throw new S(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,c,n,t);m=i.toPromise(n).then(e=>{let t=u(e,r);t<0&&(a[r]=t)})}else{let e=i.tagOf(n);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:m=`["Object",${u(i.unbox(n))}]`;break;case`Date`:m=`["Date","${i.toISOString(n)}"]`;break;case`URL`:m=`["URL",${C(i.toStringValue(n))}]`;break;case`URLSearchParams`:m=`["URLSearchParams",${C(i.toStringValue(n))}]`;break;case`RegExp`:let{source:r,flags:a}=i.regExpInfo(n);m=a?`["RegExp",${C(r)},"${a}"]`:`["RegExp",${C(r)}]`;break;case`Array`:{let e=!1,t=i.lengthOf(n);m=`[`;for(let r=0;r<t;r+=1)if(r>0&&(m+=`,`),i.hasOwn(n,r))c.push(`[${r}]`),m+=u(i.get(n,r)),c.pop();else if(e)m+=-2;else{let r=i.indicesOf(n),a=r.length,o=String(t).length;if((t-a)*3>4+o+a*(o+1)){m=`[-7,`+t;for(let e=0;e<r.length;e++){let t=r[e];c.push(`[${t}]`),m+=`,`+t+`,`+u(i.get(n,t)),c.pop()}break}e=!0,m+=-2}m+=`]`;break}case`Set`:m=`["Set"`;for(let e of i.valuesOf(n))m+=`,${u(e)}`;m+=`]`;break;case`Map`:m=`["Map"`;for(let[e,t]of i.entriesOf(n)){let n=i.typeOf(e),r=n!==`object`&&n!==`function`&&n!==`symbol`;c.push(`.get(${r?Ue(i.toPrimitive(e)):`...`})`),m+=`,${u(e)},${u(t)}`,c.pop()}m+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let t=i.viewInfo(n);m=`["`+e+`",`+u(t.buffer),t.byteLength!==t.bufferByteLength&&(m+=`,${t.byteOffset},${t.length}`),m+=`]`;break}case`DataView`:{let t=i.viewInfo(n);m=`["`+e+`",`+u(t.buffer),t.byteLength!==t.bufferByteLength&&(m+=`,${t.byteOffset},${t.byteLength}`),m+=`]`;break}case`ArrayBuffer`:m=`["ArrayBuffer","${Ne(i.toArrayBuffer(n))}"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:m=`["${e}",${C(i.toStringValue(n))}]`;break;default:{let e=i.shapeOf(n);if(e.kind===`not-plain`)throw new S(`Cannot stringify arbitrary non-POJOs`,c,n,t);if(e.kind===`symbol-keys`)throw new S(`Cannot stringify POJOs with symbolic keys`,c,n,t);if(e.kind===`null-proto`){m=`["null"`;for(let r of e.keys){if(r===`__proto__`)throw new S(`Cannot stringify objects with __proto__ keys`,c,n,t);c.push(ye(r)),m+=`,${C(r)},${u(i.get(n,r))}`,c.pop()}m+=`]`}else{m=`{`;let r=!1;for(let a of e.keys){if(a===`__proto__`)throw new S(`Cannot stringify objects with __proto__ keys`,c,n,t);r&&(m+=`,`),r=!0,c.push(ye(a)),m+=`${C(a)}:${u(i.get(n,a))}`,c.pop()}m+=`}`}}}}return a[r]=m,r}let d=u(t);return d<0?`${d}`:a}function Ue(e){let t=typeof e;return t===`string`?C(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`["BigInt","${e}"]`:String(e)}async function We(e,t=[`encrypt`,`decrypt`]){if(e.byteLength!==32)throw new a(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,t)}async function Ge(e,t,n){let r=globalThis.crypto.getRandomValues(new Uint8Array(12)),i;try{i=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:r,tagLength:128,...n?{additionalData:n}:{}},e,t)}catch(e){throw new f(`AES-256-GCM encryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`encrypt`,byteLength:t.byteLength}})}let a=new Uint8Array(12+i.byteLength);return a.set(r,0),a.set(new Uint8Array(i),12),a}async function Ke(e,t,n){if(t.byteLength<28)throw new f(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r=t.subarray(0,12),i=t.subarray(12),a;try{a=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:r,tagLength:128,...n?{additionalData:n}:{}},e,i)}catch(e){let n=e instanceof Error?e.message:String(e);throw new f(`AES-256-GCM decryption failed: ${n}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return new Uint8Array(a)}const qe=Symbol.for(`WORKFLOW_USE_STEP`),Je=Symbol.for(`WORKFLOW_SET_ATTRIBUTES`),Ye=Symbol.for(`WORKFLOW_CREATE_HOOK`),Xe=Symbol.for(`WORKFLOW_SLEEP`),Ze=Symbol.for(`WORKFLOW_GET_STREAM_ID`),Qe=Symbol.for(`WORKFLOW_STABLE_ULID`),T=Symbol.for(`WORKFLOW_STREAM_NAME`),$e=Symbol.for(`WORKFLOW_STREAM_TYPE`),et=Symbol.for(`WORKFLOW_STREAM_FRAMING`),tt=Symbol.for(`WORKFLOW_STREAM_SERVER_RUN_ID`),nt=Symbol.for(`WORKFLOW_STREAM_SERVER_DEPLOYMENT_ID`),E=Symbol.for(`WORKFLOW_STREAM_SERVER_PUBLIC_KEY`),rt=Symbol.for(`WORKFLOW_STREAM_DRAIN`),it=Symbol.for(`WORKFLOW_STREAM_RELEASE`),at=Symbol.for(`BODY_INIT`),ot=Symbol.for(`WEBHOOK_RESPONSE_WRITABLE`),st=Symbol.for(`workflow-class-registry`),D=Symbol.for(`WORKFLOW_ABORT_STREAM_NAME`),O=Symbol.for(`WORKFLOW_ABORT_HOOK_TOKEN`),ct=Symbol.for(`WORKFLOW_ABORT_LISTENER_ATTACHED`),lt=Symbol.for(`WORKFLOW_ABORT_READER_CANCEL`),ut=()=>n(`WORKFLOW_STREAM_MAX_INFLIGHT_CHUNKS`,1e3,{integer:!0,min:1}),dt=()=>n(`WORKFLOW_STREAM_MAX_CHUNKS_PER_BATCH`,1e3,{integer:!0,min:1}),ft=()=>n(`WORKFLOW_STREAM_MAX_BYTES_PER_BATCH`,1048576,{integer:!0,min:1}),pt=()=>n(`WORKFLOW_STREAM_MAX_BUFFERED_BYTES`,8388608,{integer:!0,min:1}),mt=()=>n(`WORKFLOW_LOCK_POLL_INTERVAL_MS`,10,{integer:!0,min:1});function ht(){let e={...ee(),pendingOps:0,producedFrames:0,acceptedFrames:0,frameWaiters:[],doneResolved:!1,streamEnded:!1};return e.promise.catch(()=>{}),e}function gt(e){if(e.locked)return!1;let t;try{t=e.getWriter()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function _t(e){if(e.locked)return!1;let t;try{t=e.getReader()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function vt(e){(async()=>{await e.drainBarrier?.(),await e.releaseTransport?.()})().then(()=>e.resolve(),t=>e.reject(t))}function yt(e){e.producedFrames++}async function bt(e){let t=async t=>{throw await e.drainBarrier?.().catch(()=>{}),t},n=e.producedFrames;if(e.acceptedFrames<n){if(e.pipeError!==void 0)return t(e.pipeError);try{await new Promise((t,r)=>{e.frameWaiters.push({target:n,resolve:t,reject:r})})}catch(e){return t(e)}}if(e.pipeError!==void 0)return t(e.pipeError);await e.drainBarrier?.()}function xt(e,t,n=WritableStream){let r=e.getWriter(),i=Symbol(`workflow-stream-release-checkpoint`),a,o=new n({start(e){a=e},async write(e){e!==i&&(yt(t),await r.write(e))},async close(){t.userWritableClosing=!0;try{await r.close()}finally{r.releaseLock()}},async abort(e){try{await r.abort(e)}finally{r.releaseLock()}}});r.closed.catch(e=>{a.error(e)});let s;return t.settleReleasedWrites=()=>{if(t.releaseSettlementArmed=!0,s)return s;if(o.locked)return Promise.resolve(!1);if(t.userWritableClosing)return s=t.promise.then(()=>!0),s;let e;try{e=o.getWriter()}catch{return Promise.resolve(!1)}return s=(async()=>{try{try{await e.write(i)}catch(e){try{return await t.promise,!0}catch(t){throw t??e}}return await bt(t),await t.releaseTransport?.(),t.doneResolved||(t.doneResolved=!0,t.resolve()),!0}catch(e){throw t.doneResolved||(t.doneResolved=!0,t.reject(e)),e}finally{e.releaseLock()}})(),s},o}function St(e,t){if(t.writablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.writablePollingInterval=void 0;return}if(t.settleReleasedWrites){(!t.deferReleaseSettlement||t.releaseSettlementArmed)&&!e.locked&&(clearInterval(n),t.writablePollingInterval=void 0,t.settleReleasedWrites().catch(()=>{}));return}gt(e)&&t.pendingOps===0&&(t.doneResolved=!0,clearInterval(n),t.writablePollingInterval=void 0,vt(t))},mt());t.writablePollingInterval=n}function Ct(e,t){if(t.readablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.readablePollingInterval=void 0;return}_t(e)&&t.pendingOps===0&&(t.doneResolved=!0,clearInterval(n),t.readablePollingInterval=void 0,vt(t))},mt());t.readablePollingInterval=n}function wt(e,t,n){let r=t[rt];typeof r==`function`&&(n.drainBarrier=r);let i=t[it];return typeof i==`function`&&(n.releaseTransport=i),Tt(e,t,n)}async function Tt(e,t,n){let r=e.getReader(),i=t.getWriter(),o;try{for(;;){if(n.streamEnded)return;let e=await Promise.race([r.read(),i.closed.then(()=>{throw new a(`Writable stream closed prematurely`)})]);if(n.streamEnded)return;if(e.done){n.streamEnded=!0,await i.close(),n.doneResolved||(n.doneResolved=!0,n.resolve());return}n.pendingOps++;try{await i.write(e.value),n.acceptedFrames++;let t=n.frameWaiters.filter(e=>e.target<=n.acceptedFrames);n.frameWaiters=n.frameWaiters.filter(e=>e.target>n.acceptedFrames);for(let e of t)e.resolve()}finally{n.pendingOps--}}}catch(e){n.streamEnded=!0,n.pipeError=e,o=e;let t=n.frameWaiters;n.frameWaiters=[];for(let n of t)n.reject(e);throw n.drainBarrier&&await n.drainBarrier().catch(()=>{}),await i.abort(e).catch(()=>{}),n.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{r.cancel(o).catch(()=>{}),r.releaseLock(),i.releaseLock()}}function Et(e){let t=e.specVersion;if(!(t!=null&&t>=6&&t<=8))throw new a(`This Workflow runtime supports Worlds with spec version 6 through 8, but the configured World declares spec version ${t??`none`}. Install a World package version compatible with the current Workflow runtime.`)}const Dt=Symbol.for(`@workflow/world//cache`),Ot=Symbol.for(`@workflow/world//cachePromise`),kt=Symbol.for(`@workflow/world//getWorldFn`);async function At(){let e=globalThis;if(e[Dt])return Et(e[Dt]),e[Dt];if(e[Ot])return e[Dt]=await e[Ot],Et(e[Dt]),e[Dt];let t=e[kt];if(t){let e=await t();return Et(e),e}throw Error("Workflow world runtime was not initialized. Import from the host workflow entrypoints (`workflow`, `workflow/api`, or `workflow/runtime`) so @workflow/core/runtime/world-init can register getWorld before getWorldLazy() is used.")}const jt=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]),Mt=new TextEncoder;function Nt(e){if(e.byteLength!==32)throw new a(`Run key material must be exactly 32 bytes, got ${e.byteLength}`)}function Pt(e,t){if(e.byteLength!==32)throw new a(`${t} must be exactly 32 bytes, got ${e.byteLength}`)}async function Ft(e){Nt(e);let t=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),n=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:Mt.encode(`workflow/encp/x25519/v1`)},t,256),r=new Uint8Array(n);return{scalar:r,publicKey:await It(r)}}async function It(e){let t=await Lt(e,!0),n=await globalThis.crypto.subtle.exportKey(`jwk`,t);if(!n.x)throw new a(`X25519 JWK export did not include a public key component ("x")`);let r=Ht(n.x);if(r.byteLength!==32)throw new a(`X25519 JWK export produced a ${r.byteLength}-byte public key, expected 32`);return r}async function Lt(e,t){let n=new Uint8Array(jt.length+e.byteLength);return n.set(jt,0),n.set(e,jt.length),globalThis.crypto.subtle.importKey(`pkcs8`,n,{name:`X25519`},t,[`deriveBits`])}function Rt(e){return globalThis.crypto.subtle.importKey(`raw`,e,{name:`X25519`},!0,[])}const zt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function Bt(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:0,a=n+2<e.length?e[n+2]:0;t+=zt[r>>2&63],t+=zt[(r&3)<<4|i>>4&15],t+=n+1<e.length?zt[(i&15)<<2|a>>6&3]:`=`,t+=n+2<e.length?zt[a&63]:`=`}return t}function Vt(e){let t=e.length;for(;t>0&&e[t-1]===`=`;)t--;let n=e.slice(0,t);if(n.includes(`=`)||n.length%4==1||t!==e.length&&e.length%4!=0)return;let r=0,i=0,a=[];for(let e=0;e<n.length;e++){let t=zt.indexOf(n[e]);if(t===-1)return;r=r<<6|t,i+=6,i>=8&&(i-=8,a.push(r>>i&255))}if(!(i>0&&r&(1<<i)-1))return new Uint8Array(a)}function Ht(e){let t=0,n=0,r=[];for(let i=0;i<e.length;i++){let o=e[i];if(o===`=`)break;let s=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`.indexOf(o);if(s===-1)throw new a(`Invalid base64url character "${o}" in X25519 JWK key component`);t=t<<6|s,n+=6,n>=8&&(n-=8,r.push(t>>n&255))}return new Uint8Array(r)}async function Ut(e,t,n,r){let i=Mt.encode(`workflow/encp/aes256gcm/v1`),a=new Uint8Array(i.length+t.length+n.length);a.set(i,0),a.set(t,i.length),a.set(n,i.length+t.length);let o=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),s=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:a},o,256);return globalThis.crypto.subtle.importKey(`raw`,new Uint8Array(s),`AES-GCM`,!1,r)}async function Wt(e){Pt(e,`Recipient public key`);let t;try{t=await Rt(e)}catch(e){throw new a(`Invalid X25519 recipient public key: ${e instanceof Error?e.message:String(e)}`,{cause:e})}let n=await globalThis.crypto.subtle.generateKey({name:`X25519`},!0,[`deriveBits`]),r=new Uint8Array(await globalThis.crypto.subtle.exportKey(`raw`,n.publicKey)),i;try{i=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:t},n.privateKey,256)}catch(e){throw new a(`X25519 key agreement failed: the recipient public key is not a valid curve point (low-order point or corrupted key material)`,{cause:e})}return{ephemeralPublicKey:r,contentKey:await Ut(new Uint8Array(i),r,e,[`encrypt`])}}async function Gt(e,t){if(t.byteLength!==32)throw new f(`Sealed payload has a malformed ephemeral public key: expected 32 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let n;try{let[r,i]=await Promise.all([Lt(e.scalar,!1),Rt(t)]);n=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:i},r,256)}catch(e){throw new f(`X25519 key agreement failed while opening a sealed payload: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return Ut(new Uint8Array(n),t,e.publicKey,[`decrypt`])}async function Kt(e,t,n){let{ephemeralPublicKey:r,contentKey:i}=await Wt(e),a=await Ge(i,t,n),o=new Uint8Array(r.byteLength+a.byteLength);return o.set(r,0),o.set(a,r.byteLength),o}async function qt(e,t,n){if(t.byteLength<60)throw new f(`Sealed payload too short: expected at least 60 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r=t.subarray(0,32),i=t.subarray(32);return Ke(await Gt(e,r),i,n)}function Jt(e,t){let n;return{async seal(r){n??=Wt(e);let{ephemeralPublicKey:i,contentKey:a}=await n,o=await Ge(a,r,t),s=new Uint8Array(i.byteLength+o.byteLength);return s.set(i,0),s.set(o,i.byteLength),s}}}function Yt(e,t){let n,r;return{async open(i){if(i.byteLength<60)throw new f(`Sealed payload too short: expected at least 60 bytes, got ${i.byteLength}`,{context:{operation:`decrypt`,byteLength:i.byteLength}});let a=i.subarray(0,32),o=i.subarray(32),s=Xt(a);(s!==n||!r)&&(n=s,r=Gt(e,a));let c;try{c=await r}catch(e){throw n=void 0,r=void 0,e}return Ke(c,o,t)}}}function Xt(e){let t=``;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t}function Zt(e){if(!e)return;let t=Vt(e);if(t&&t.byteLength===32)return t}let k=null,Qt=null;function $t(e,t){let n=k,r=Qt;k=e??null,Qt=e?new WeakSet:null;try{return t()}finally{k=n,Qt=r}}const en=t(`@workflow/core//useStepClosures.fns`,1,()=>({fns:new WeakSet}));function tn(e){return en.fns.add(e),e}function nn(e){return typeof e==`function`&&en.fns.has(e)}function A(e,t){if(!k||(k.totalExecutions=(k.totalExecutions??k.executions.length)+1,k.executions.length>=5))return;let n={kind:e};t!==void 0&&(n.detail=t),k.executions.push(n)}function j(e){k&&Qt&&(Qt.has(e)||(Qt.add(e),A(`proxy`)))}const M=Function.prototype.bind.bind(Function.prototype.call);function N(e,t){let n=Object.getOwnPropertyDescriptor(e,t)?.get;if(!n)throw Error(`Missing intrinsic getter: ${String(t)}`);return M(n)}const rn=M(Date.prototype.getDate),an=M(Date.prototype.getTime),on=M(Date.prototype.toISOString),sn=N(RegExp.prototype,`source`),cn=N(RegExp.prototype,`flags`),ln=N(ArrayBuffer.prototype,`byteLength`),un=M(Map.prototype.entries),dn=M(Set.prototype.values),fn=M(Number.prototype.valueOf),pn=M(String.prototype.valueOf),mn=M(Boolean.prototype.valueOf),hn=M(BigInt.prototype.valueOf),gn=Object.getPrototypeOf(Uint8Array.prototype),_n=N(gn,Symbol.toStringTag),vn=N(gn,`buffer`),yn=N(gn,`byteOffset`),bn=N(gn,`byteLength`),xn=N(gn,`length`),Sn=M(gn.set),Cn=ArrayBuffer,wn=Uint8Array,Tn=N(DataView.prototype,`buffer`),En=N(DataView.prototype,`byteOffset`),Dn=N(DataView.prototype,`byteLength`),On=N(SharedArrayBuffer.prototype,`byteLength`),kn=M(Headers.prototype[Symbol.iterator]),An=N(URL.prototype,`href`),jn=M(URLSearchParams.prototype.toString),{isProxy:P}=v,Mn=M(Function.prototype.toString);function Nn(e){if(P(e))return!1;let t=Object.getOwnPropertyDescriptor(e,`name`)?.value;return typeof t==`string`&&t.startsWith(`bound `)?!1:Mn(e).endsWith(`{ [native code] }`)||Reflect.getPrototypeOf(e)===Function.prototype}function F(e,t){if(e===null||typeof e!=`object`&&typeof e!=`function`)return;if(P(e))return j(e),e[t];let n=e;for(;n!==null;){if(P(n))return j(n),e[t];let r=Object.getOwnPropertyDescriptor(n,t);if(r)return`value`in r?r.value:r.get?(Nn(r.get)||A(`getter`,String(t)),r.get.call(e)):void 0;n=Reflect.getPrototypeOf(n)}}function Pn(e,t){if(e===null||typeof e!=`object`&&typeof e!=`function`)return!1;if(P(e))return j(e),t in e;let n=e;for(;n!==null;){if(P(n))return j(n),t in e;if(Object.getOwnPropertyDescriptor(n,t))return!0;n=Reflect.getPrototypeOf(n)}return!1}function I(e,t){if(!t||typeof e!=`object`||!e)return!1;P(e)&&j(e);let n=Reflect.getPrototypeOf(e);for(;n!==null;){if(n===t)return!0;P(n)&&j(n),n=Reflect.getPrototypeOf(n)}return!1}function Fn(e){return P(e)?(j(e),e.href):An(e)}function In(e){return P(e)?(j(e),String(e)):jn(e)}function Ln(e){if(P(e))return j(e),Array.from(e);try{return[...kn(e)]}catch(t){if(!(t instanceof TypeError))throw t;return A(`method`,`Headers[Symbol.iterator]`),Array.from(e)}}function Rn(e){return[...un(e)]}function zn(e){return[...dn(e)]}function Bn(e){return v.isDataView(e)?{buffer:Tn(e),byteOffset:En(e),byteLength:Dn(e)}:{buffer:vn(e),byteOffset:yn(e),byteLength:bn(e)}}const Vn=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Float16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),Hn=new Set([`Date`,`RegExp`,`Map`,`Set`,`Array`,`DataView`,`ArrayBuffer`,`SharedArrayBuffer`,`Number`,`String`,`Boolean`,`BigInt`,`URL`,`URLSearchParams`,...Vn]);function Un(e){if(v.isDate(e))return`Date`;if(v.isRegExp(e))return`RegExp`;if(v.isMap(e))return`Map`;if(v.isSet(e))return`Set`;if(Array.isArray(e))return`Array`;if(v.isTypedArray(e)){let t=_n(e);return t!==void 0&&Vn.has(t)?t:void 0}if(v.isDataView(e))return`DataView`;if(v.isArrayBuffer(e))return`ArrayBuffer`;if(v.isSharedArrayBuffer(e))return`SharedArrayBuffer`;if(v.isNumberObject(e))return`Number`;if(v.isStringObject(e))return`String`;if(v.isBooleanObject(e))return`Boolean`;if(v.isBigIntObject(e))return`BigInt`;if(I(e,URL.prototype))return`URL`;if(I(e,URLSearchParams.prototype))return`URLSearchParams`}function Wn(e){let t=F(e,Symbol.toStringTag);return typeof t==`string`?t:void 0}const Gn={tagOf:e=>{if(P(e))return j(e),Re.tagOf(e);let t=Un(e);if(t!==void 0)return t;let n=Wn(e);return n===void 0||Hn.has(n)?`Object`:n},isThenable:e=>v.isPromise(e)?!0:typeof F(e,`then`)==`function`,unbox:e=>v.isNumberObject(e)?fn(e):v.isStringObject(e)?pn(e):v.isBooleanObject(e)?mn(e):hn(e),toISOString:e=>Number.isNaN(rn(e))?``:on(e),toStringValue:e=>I(e,URL.prototype)?Fn(e):I(e,URLSearchParams.prototype)?In(e):(A(`method`,`toString (${Wn(e)??`unknown`})`),e.toString()),regExpInfo:e=>({source:sn(e),flags:cn(e)}),valuesOf:e=>zn(e),entriesOf:e=>Rn(e),viewInfo:e=>{let t=Bn(e),n=v.isDataView(e)?0:xn(e),r=v.isSharedArrayBuffer(t.buffer)?On(t.buffer):ln(t.buffer);if(t.byteLength===r)return{...t,length:n,bufferByteLength:r};let i=new Cn(t.byteLength);return Sn(new wn(i),new wn(t.buffer,t.byteOffset,t.byteLength)),{buffer:i,byteOffset:0,byteLength:t.byteLength,length:n,bufferByteLength:t.byteLength}},shapeOf:e=>(P(e)&&j(e),Re.shapeOf(e)),get:(e,t)=>F(e,t)},Kn=Symbol.for(`workflow-serialize`),qn=Symbol.for(`workflow-deserialize`);function Jn(e=globalThis){let t=e,n=t[st];return n||(n=new Map,t[st]=n),n}const Yn=`class//workflow//Run`;function Xn(e,t,n=globalThis){Jn(n).set(e,t)}function Zn(e,t){return Jn(t).get(e)}function Qn(){return{Class:e=>{if(typeof e!=`function`)return!1;let t=F(e,`classId`);return typeof t==`string`&&{classId:t}},Instance:e=>{if(typeof e!=`object`||!e)return!1;let t=F(e,`constructor`);if(!t||typeof t!=`function`)return!1;let n=F(t,Kn);if(typeof n!=`function`)return!1;let r=F(t,`classId`);if(typeof r!=`string`)throw Error(`Class "${String(F(t,`name`))}" with ${String(Kn)} must have a static "classId" property.`);return A(`method`,`[WORKFLOW_SERIALIZE] (${r})`),{classId:r,data:n.call(t,e)}}}}function $n(e=globalThis){return{Class:t=>{let n=t.classId,r=Zn(n,e);if(!r)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);return r},Instance:t=>{let n=t.classId,r=t.data,i=Zn(n,e);if(!i)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);let a=i[qn];if(typeof a!=`function`)throw Error(`Class "${n}" does not have a static ${String(qn)} method.`);return a.call(i,r)}}}function er(e,t,n){if(n===0)return`.`;let r=new Uint8Array(e,t,n);return Buffer.from(r).toString(`base64`)}function L(e){let t=Bn(e);return er(t.buffer,t.byteOffset,t.byteLength)}function R(e,t){let n=e===`.`?``:e,r=Buffer.from(n,`base64`),i=new t.ArrayBuffer(r.length);return new t.Uint8Array(i).set(r),i}function tr(e){return JSON.parse(e)}function nr(e){let t=Object.getOwnPropertyDescriptor(e,`stack`);return t&&`value`in t?t.value:(A(`getter`,`stack`),t?.get?t.get.call(e):F(e,`stack`))}function rr(e){if(!v.isNativeError(e))return!1;let t={message:F(e,`message`),stack:nr(e)};return Pn(e,`cause`)&&(t.cause=F(e,`cause`)),t}function ir(e,t){return!v.isNativeError(t)||F(t,`name`)!==e?!1:rr(t)}function ar(e){return t=>ir(e,t)||!1}function or(e,t){return n=>{let r=n,i=`cause`in r?{cause:r.cause}:void 0,a=e[t],o=new a(r.message,i);return r.stack!==void 0&&(o.stack=r.stack),o}}function sr(e=globalThis){return{ArrayBuffer:e=>v.isArrayBuffer(e)&&er(e,0,ln(e)),BigInt:e=>typeof e==`bigint`&&String(e),BigInt64Array:e=>v.isBigInt64Array(e)&&L(e),BigUint64Array:e=>v.isBigUint64Array(e)&&L(e),DataViewBytes:e=>v.isDataView(e)&&L(e),Date:e=>v.isDate(e)?Number.isNaN(rn(e))?`.`:on(e):!1,DOMException:e=>{if(typeof e!=`object`||!e)return!1;let t=F(e,`constructor`);if(!t||F(t,`name`)!==`DOMException`)return!1;let n={message:F(e,`message`),name:F(e,`name`),stack:nr(e)};return Pn(e,`cause`)&&(n.cause=F(e,`cause`)),n},EvalError:ar(`EvalError`),FatalError:ar(`FatalError`),HookConflictError:e=>{let t=ir(`HookConflictError`,e);if(!t)return!1;let n={...t,token:F(e,`token`)},r=F(e,`conflictingRunId`);return r!==void 0&&(n.conflictingRunId=r),n},HookForceClaimedError:e=>{let t=ir(`HookForceClaimedError`,e);if(!t)return!1;let n={...t,token:F(e,`token`),claimedByRunId:F(e,`claimedByRunId`)},r=F(e,`claimedByHookId`);return r!==void 0&&(n.claimedByHookId=r),n},RangeError:ar(`RangeError`),ReferenceError:ar(`ReferenceError`),RetryableError:e=>{let t=ir(`RetryableError`,e);if(!t)return!1;let n=F(e,`retryAfter`),r;if(v.isDate(n)){let e=an(n);r=Number.isNaN(e)?Date.now()+1e3:e}else if(n&&typeof n==`object`){let e=F(n,`getTime`);if(typeof e==`function`){A(`method`,`getTime`);let t=e.call(n);r=Number.isNaN(t)?Date.now()+1e3:t}else r=Date.now()+1e3}else if(typeof n==`string`||typeof n==`number`){let e=new Date(n).getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else r=Date.now()+1e3;return{...t,retryAfter:r}},RuntimeDecryptionError:e=>{let t=ir(`RuntimeDecryptionError`,e);if(!t)return!1;let n={...t},r=F(e,`context`);return r!==void 0&&(n.context=r),n},StreamError:e=>{let t=ir(`StreamError`,e);if(!t)return!1;let n={...t},r=F(e,`status`),i=F(e,`url`);return typeof r==`number`&&(n.status=r),typeof i==`string`&&(n.url=i),n},SyntaxError:ar(`SyntaxError`),TypeError:ar(`TypeError`),URIError:ar(`URIError`),AggregateError:e=>{let t=ir(`AggregateError`,e);return t?{...t,errors:F(e,`errors`)}:!1},Error:e=>{if(!v.isNativeError(e))return!1;let t={name:F(e,`name`),message:F(e,`message`),stack:nr(e)};return Pn(e,`cause`)&&(t.cause=F(e,`cause`)),t},Float32Array:e=>v.isFloat32Array(e)&&L(e),Float64Array:e=>v.isFloat64Array(e)&&L(e),Headers:e=>I(e,Headers.prototype)&&Ln(e),Int8Array:e=>v.isInt8Array(e)&&L(e),Int16Array:e=>v.isInt16Array(e)&&L(e),Int32Array:e=>v.isInt32Array(e)&&L(e),Map:e=>v.isMap(e)&&Rn(e),RegExp:e=>v.isRegExp(e)&&{source:sn(e),flags:cn(e)},Set:e=>v.isSet(e)&&zn(e),URL:e=>I(e,URL.prototype)&&Fn(e),WorkflowFunction:e=>{if(typeof e!=`function`)return!1;let t=F(e,`workflowId`);return typeof t==`string`&&{workflowId:t}},URLSearchParams:e=>{if(!I(e,URLSearchParams.prototype))return!1;let t=In(e);return t===``?`.`:t},Uint8Array:e=>v.isUint8Array(e)&&L(e),Uint8ClampedArray:e=>v.isUint8ClampedArray(e)&&L(e),Uint16Array:e=>v.isUint16Array(e)&&L(e),Uint32Array:e=>v.isUint32Array(e)&&L(e)}}function cr(e=globalThis){return{ArrayBuffer:t=>R(t,e),BigInt:t=>e.BigInt(t),BigInt64Array:t=>new e.BigInt64Array(R(t,e)),BigUint64Array:t=>new e.BigUint64Array(R(t,e)),DataViewBytes:t=>new e.DataView(R(t,e)),Date:t=>new e.Date(t),DOMException:t=>{let n=new e.DOMException(t.message,t.name);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},EvalError:or(e,`EvalError`),FatalError:t=>{let n=new(e[Symbol.for(`@workflow/errors//FatalError`)]??d)(t.message);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},HookConflictError:t=>{let n=new(e[Symbol.for(`@workflow/errors//HookConflictError`)]??c)(t.token,t.conflictingRunId);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},HookForceClaimedError:t=>{let n=new(e[Symbol.for(`@workflow/errors//HookForceClaimedError`)]??p)(t.token,t.claimedByRunId,t.claimedByHookId);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RangeError:or(e,`RangeError`),ReferenceError:or(e,`ReferenceError`),RetryableError:t=>{let n=new(e[Symbol.for(`@workflow/errors//RetryableError`)]??l)(t.message,{retryAfter:new e.Date(t.retryAfter)});return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RuntimeDecryptionError:t=>{let n=e[Symbol.for(`@workflow/errors//RuntimeDecryptionError`)]??f,r={};`cause`in t&&(r.cause=t.cause),t.context!==void 0&&(r.context=t.context);let i=new n(t.message,r);return t.stack!==void 0&&(i.stack=t.stack),i},StreamError:t=>{let n=new(e[Symbol.for(`@workflow/errors//StreamError`)]??s)(t.message,{...`cause`in t?{cause:t.cause}:{},status:t.status,url:t.url});return t.stack!==void 0&&(n.stack=t.stack),n},SyntaxError:or(e,`SyntaxError`),TypeError:or(e,`TypeError`),URIError:or(e,`URIError`),AggregateError:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.AggregateError(t.errors,t.message,n);return t.stack!==void 0&&(r.stack=t.stack),r},Error:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.Error(t.message,n);return r.name=t.name,t.stack!==void 0&&(r.stack=t.stack),r},Float32Array:t=>new e.Float32Array(R(t,e)),Float64Array:t=>new e.Float64Array(R(t,e)),Headers:t=>new e.Headers(t),Int8Array:t=>new e.Int8Array(R(t,e)),Int16Array:t=>new e.Int16Array(R(t,e)),Int32Array:t=>new e.Int32Array(R(t,e)),Map:t=>new e.Map(t),RegExp:t=>new e.RegExp(t.source,t.flags),Set:t=>new e.Set(t),URL:t=>new e.URL(t),WorkflowFunction:e=>Object.assign(()=>{throw Error(`Workflow functions cannot be called directly. Use start() to invoke them.`)},{workflowId:e.workflowId}),URLSearchParams:t=>new e.URLSearchParams(t===`.`?``:t),Uint8Array:t=>new e.Uint8Array(R(t,e)),Uint8ClampedArray:t=>new e.Uint8ClampedArray(R(t,e)),Uint16Array:t=>new e.Uint16Array(R(t,e)),Uint32Array:t=>new e.Uint32Array(R(t,e))}}function lr(){return{StepFunction:e=>{if(typeof e!=`function`)return!1;let t=F(e,`stepId`);if(typeof t!=`string`)return!1;let n=F(e,`__closureVarsFn`),r;typeof n==`function`&&(nn(n)||A(`method`,`__closureVarsFn`),r=n());let i=Pn(e,`__boundThis`),a=i?F(e,`__boundThis`):void 0,o=F(e,`__boundArgs`),s={stepId:t};return r!==void 0&&(s.closureVars=r),i&&(s.boundThis=a),Array.isArray(o)&&o.length>0&&(s.boundArgs=o),s}}}function ur(e=globalThis){let t=e[Symbol.for(`WORKFLOW_USE_STEP`)];return{StepFunction:e=>{let n=e.stepId,r=e.closureVars;if(!t)throw Error(`WORKFLOW_USE_STEP not found on global object. Step functions cannot be deserialized outside workflow context.`);let i=r?t(n,()=>r):t(n);if(`boundThis`in e){let t=Array.isArray(e.boundArgs)?e.boundArgs:[];return i.bind(e.boundThis,...t)}return i}}}function dr(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const z={DEVALUE_V1:`devl`,ENCRYPTED:`encr`,SEALED:`encp`,GZIP:`gzip`,ZSTD:`zstd`},fr=new TextEncoder,pr=new TextDecoder,mr=1e5,hr={operations:{createSparseArray(e){if(e>mr)throw RangeError(`Sparse array length ${e} exceeds the maximum of ${mr}`);return ze.createSparseArray(e)}}};function gr(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Qn(),...lr(),...sr(t)};break;case`step`:r={...Qn(),...sr(t)};break;case`client`:r={...Qn(),...sr(t)}}return n?{...r,...n}:r}function _r(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...$n(t),...ur(t),...cr(t)};break;case`step`:r={...$n(t),...cr(t)};break;case`client`:r={...$n(t),...cr(t),StepFunction:()=>{throw Error(`Step functions cannot be deserialized in client context.`)}}}return n?{...r,...n}:r}const B={formatPrefix:z.DEVALUE_V1,serialize(e,t,n){let r=gr(t,n?.global,n?.extraReducers),i=$t(n?.guestCodeStats,()=>w(e,r,{operations:Gn}));return fr.encode(i)},deserialize(e,t,n){let r=_r(t,n?.global,n?.extraRevivers);return Be(pr.decode(e),r,hr)},deserializeLegacy(e,t,n){return Ve(e,_r(t,n?.global,n?.extraRevivers),hr)}},vr=new TextEncoder,yr=new TextDecoder;function V(e,t){if(!(t instanceof Uint8Array))return t;let n=vr.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function br(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=yr.decode(t);return dr(n)?n:null}function xr(e){return br(e)===z.ENCRYPTED}function H(e){if(!(e instanceof Uint8Array))return{format:z.DEVALUE_V1,payload:new TextEncoder().encode(JSON.stringify(e))};if(e.length<4)throw Error(`Data too short to contain format prefix: expected at least 4 bytes, got ${e.length}`);let t=e.subarray(0,4),n=yr.decode(t);if(!dr(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}function Sr(){try{return typeof process<`u`&&process.env?.WORKFLOW_DISABLE_COMPRESSION===`1`}catch{return!1}}function Cr(){try{let e=process.env?.WORKFLOW_COMPRESSION_CODEC;return e===`gzip`||e===`zstd`?e:void 0}catch{return}}function wr(){try{return globalThis.process?.getBuiltinModule?.(`node:zlib`)}catch{return}}function Tr(){let e=wr();return typeof e?.zstdCompressSync==`function`&&typeof e?.zstdDecompressSync==`function`}function Er(){return typeof CompressionStream==`function`&&typeof DecompressionStream==`function`}async function Dr(e,t,n){let r=t.writable.getWriter(),i=r.write(e).then(()=>r.close());i.catch(()=>{});let a=[],o=0,s=t.readable.getReader();for(;;){let{done:e,value:t}=await s.read();if(e)break;if(a.push(t),o+=t.length,n!==void 0&&o>n)throw await s.cancel().catch(()=>{}),new Ar(n)}await i;let c=new Uint8Array(o),l=0;for(let e of a)c.set(e,l),l+=e.length;return c}async function Or(e){return Dr(e,new CompressionStream(`gzip`))}async function kr(e,t){return Dr(e,new DecompressionStream(`gzip`),t)}var Ar=class extends Error{maxOutputBytes;constructor(e){super(`Decompressed payload exceeds ${e} bytes`),this.maxOutputBytes=e,this.name=`DecompressedSizeLimitError`}};function jr(e){let t=e?.constants?.ZSTD_c_compressionLevel;return t===void 0?void 0:{params:{[t]:3}}}function Mr(e){let t=wr();return new Uint8Array(t.zstdCompressSync(e,jr(t)))}function Nr(e){let t=wr();return typeof t?.zstdCompress==`function`?new Promise((n,r)=>{t.zstdCompress(e,jr(t),(e,t)=>{e?r(e):n(new Uint8Array(t))})}):Promise.resolve(Mr(e))}function Pr(e,t){let n=wr();if(!n?.zstdDecompressSync)throw Error(`Compressed (zstd) workflow data encountered but node:zlib zstd support is not available in this runtime (requires Node.js 22.15+). In the browser, register a zstd decoder via registerZstdDecoder (serialization-format.ts).`);if(t===void 0)return new Uint8Array(n.zstdDecompressSync(e));try{return new Uint8Array(n.zstdDecompressSync(e,{maxOutputLength:t}))}catch(e){throw e?.code===`ERR_BUFFER_TOO_LARGE`?new Ar(t):e}}function Fr(e,t,n,r){e&&(e.recorded=!0,e.compressed=t!==`none`,e.codec=t,e.uncompressedBytes=n,e.storedBytes=r)}function Ir(e){let t=Cr();return e===`gzip`||t===`gzip`?Er()?`gzip`:`none`:Tr()?`zstd`:Er()?`gzip`:`none`}async function Lr(e,t,n,r){if(!(e instanceof Uint8Array))return e;if(!t||e.length<1024||Sr())return Fr(n,`none`,e.length,e.length),e;let i=Ir(t);if(i===`none`)return Fr(n,`none`,e.length,e.length),e;let a=i===`zstd`?r?.preferAsync?await Nr(e):Mr(e):await Or(e),o=i===`zstd`?z.ZSTD:z.GZIP,s=4+a.length;return s>=e.length*.95?(Fr(n,`none`,e.length,e.length),e):(Fr(n,i,e.length,s),V(o,a))}async function Rr(e,t,n){if(!(e instanceof Uint8Array))return e;let r=br(e);if(r===z.ZSTD){let{payload:r}=H(e),i=Pr(r,n?.maxOutputBytes);return Fr(t,`zstd`,i.length,e.length),i}if(r===z.GZIP){if(!Er())throw Error(`Compressed (gzip) workflow data encountered but DecompressionStream is not available in this runtime. Node.js 18+, browsers, and edge runtimes all support it.`);let{payload:r}=H(e),i=await kr(r,n?.maxOutputBytes);return Fr(t,`gzip`,i.length,e.length),i}return Fr(t,`none`,e.length,e.length),e}const zr=Symbol.for(`workflow.serialization.sealTarget`),Br=Symbol.for(`workflow.serialization.runKeys`);function Vr(e,t){return{[zr]:!0,recipientPublicKey:e,aad:t}}function Hr(e,t,n){return{[Br]:!0,aes:e,keyPair:t,aad:n}}async function Ur(e){let[t,n]=await Promise.all([We(e),Ft(e)]);return Hr(t,n)}function Wr(e){return typeof e==`object`&&!!e&&e[zr]===!0}function Gr(e){return typeof e==`object`&&!!e&&e[Br]===!0}function Kr(e){if(e){if(Gr(e))return e.aes;if(!Wr(e))return e}}async function qr(e){return typeof e==`function`?e():e}async function Jr(e,t){if(!t||!(e instanceof Uint8Array))return e;if(Wr(t)){let n=await Kt(t.recipientPublicKey,e,t.aad);return V(z.SEALED,n)}let n=await Ge(Gr(t)?t.aes:t,e);return V(z.ENCRYPTED,n)}async function Yr(e,t){if(!Gr(t))throw new f(`Sealed data encountered but no run keypair is available. Opening a sealed payload requires the run's own encryption key material; a symmetric key or a seal-only target cannot decrypt it.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encp`}});let{payload:n}=H(e);try{return await qt(t.keyPair,n,t.aad)}catch(e){throw f.is(e)&&e.context&&(e.context.formatPrefix=z.SEALED),e}}async function U(e,t){if(!(e instanceof Uint8Array))return e;let n=br(e);if(n===z.SEALED)return Yr(e,t);if(n!==z.ENCRYPTED)return e;let r=Kr(t);if(!r)throw new f(`Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encr`}});let{payload:i}=H(e);try{return await Ke(r,i)}catch(e){throw f.is(e)&&e.context&&(e.context.formatPrefix=n),e}}const Xr=(()=>{let e=globalThis.process;return e?.env?e.env.FORCE_COLOR&&e.env.FORCE_COLOR!==`0`?!0:!e.env.NO_COLOR&&!!e.stdout?.isTTY:!1})(),W=(e,t)=>n=>Xr?`\x1b[${e}m${n}\x1b[${t}m`:n,G={bold:W(1,22),dim:W(2,22),italic:W(3,23),red:W(31,39),blue:W(34,39),cyan:W(36,39),yellow:W(33,39),magenta:W(35,39)},Zr={info:G.blue,help:G.cyan,warn:G.yellow,error:G.red};function Qr(e){let t=Array.isArray(e)?e.join(`
|
|
3
|
-
`):e;return Zr.info(`${G.bold(`hint:`)} ${t}`)}function $r(e){return Zr.info(`${G.bold(`docs:`)} ${e}`)}function ei(e){return G.italic(`${G.dim("`")}${e}${G.dim("`")}`)}function K(e){return G.dim(e)}function ti(e){return G.bold(e)}function ni(e){return G.red(e)}function ri(e){return G.magenta(e)}function ii(e,t){let n=[e];return t.forEach((e,r)=>{let i=e.split(`
|
|
4
|
-
`),a=r===t.length-1,o=a?`╰▶ `:`├▶ `,s=a?` `:`│ `,c=i.map((e,t)=>`${t===0?o:s}${e}`);n.push(...c)}),n.join(`
|
|
5
|
-
`)}function ai(e,t,n){let[r,...i]=t.split(`
|
|
6
|
-
`),a=i.join(`
|
|
7
|
-
`),o=a.trim()?a:q(n??{},`errorStack`)??``,s=oi(r??``,o,n),c=si(o),l=[`${e} ${r??``}`];return s&&l.push(s),c&&l.push(c),l.join(`
|
|
8
|
-
`)}function oi(e,t,n){if(!n||Object.keys(n).length===0)return null;let r=new Set;r.add(`errorStack`);let i=q(n,`errorMessage`);i&&(e.includes(i)||t.includes(i))&&r.add(`errorMessage`);let a=new Set([`workflowRunId`,`workflowName`,`stepId`,`stepName`,`errorAttribution`,`errorCode`,`errorName`,`errorMessage`,`errorStack`,`errorCause`,`hint`,`attempt`,`retryCount`]),o=[],s=q(n,`errorName`),c=q(n,`errorAttribution`),l=s!==null&&li(t,s);if(c||s&&!l){let e=c?c===`sdk`?ri(`sdk error`):ni(`user error`):``,t=s?ti(s):``,n=e&&t?K(` · `):``;o.push(` ${e}${n}${t}`)}let u=q(n,`workflowRunId`),d=q(n,`workflowName`);u?o.push(di(`run`,u,d,oe)):d&&o.push(di(`run`,null,d,oe));let f=q(n,`stepId`),p=q(n,`stepName`);if((f||p)&&o.push(di(`step`,f,p,ae)),n.attempt!==void 0||n.retryCount!==void 0){let e=n.attempt,t=n.retryCount;e!==void 0&&t!==void 0?o.push(` ${ui(`retry`)} ${e} ${K(`attempts ·`)} ${t} ${K(`max retries`)}`):e!==void 0&&o.push(` ${ui(`retry`)} ${e} ${K(`attempts`)}`)}let m=q(n,`errorCode`);m&&m!==s&&o.push(` ${ui(`code`)} ${K(m)}`),i&&!r.has(`errorMessage`)&&o.push(` ${ui(`error`)} ${fi(i)}`);let h=q(n,`errorCause`);h&&!t.includes(h)&&o.push(` ${ui(`cause`)} ${fi(h)}`);let g=q(n,`hint`);g&&o.push(` ${Qr(g)}`);let _=Object.entries(n).filter(([e,t])=>!a.has(e)&&!r.has(e)&&t!=null).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of _)o.push(` ${ui(e)} ${fi(t)}`);return o.length?o.join(`
|
|
9
|
-
`):null}function si(e){if(!e)return null;let t=e.split(`
|
|
10
|
-
`),n=[],r=0,i=0,a=0,o=()=>{r>0&&(n.push(K(` … ${r} more ${r===1?`frame`:`frames`} in framework internals`)),r=0)};for(let e of t){let t=e.trimStart().startsWith(`at `);if(t&&ci(e)){r++;continue}if(t&&i>=6){a++;continue}o(),n.push(e),t&&i++}return o(),a>0&&n.push(K(` … ${a} more ${a===1?`frame`:`frames`} (run \`pnpm wf inspect run <id>\` for the full stack)`)),n.join(`
|
|
11
|
-
`)}function ci(e){let t=e.trimStart();return t.startsWith(`at `)?!!(t.includes(`node:internal/`)||t.includes(`node_modules/.pnpm/`)||t.includes(`node_modules__pnpm_`)||t.includes(`_next_dist_`)||t.includes(`node_modules/next/`)||t.includes(`node_modules/@opentelemetry/`)||t.includes(`node_modules/vitest/`)||t.includes(`node_modules/@vitest/`)):!1}function li(e,t){let n=e.split(`
|
|
12
|
-
`,1)[0]?.trim()??``;return n===t||n.startsWith(`${t}:`)}function q(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function ui(e){return K(e.padEnd(6))}function di(e,t,n,r){let i=t||K(`—`),a=n&&(e===`run`?x(n):ie(n))?`${K(`·`)} ${r(n)}`:``;return` ${ui(e)} ${i}${a?` `+a:``}`}function fi(e){if(typeof e==`string`)return e.includes(`
|
|
13
|
-
`)?e.split(`
|
|
14
|
-
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
15
|
-
`):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function J(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const pi=J(`workflow.name`),mi=J(`workflow.operation`),hi=J(`workflow.run.id`),gi=J(`workflow.run.status`),_i=J(`workflow.started_at`),vi=J(`workflow.events.count`),yi=J(`workflow.execution.mode`),bi=J(`workflow.dynamic`),xi=J(`workflow.dynamic.source_hash`),Si=J(`workflow.dynamic.code_bytes`),Ci=J(`workflow.dynamic.code_storage`),wi=J(`workflow.bundle.compile.cache_hit`),Ti=J(`workflow.replay.load.source`),Ei=J(`workflow.events.parked.count`),Di=J(`workflow.events.parked.event_id`),Oi=J(`workflow.events.parked.event_type`),ki=J(`workflow.arguments.count`),Ai=J(`workflow.result.type`),ji=J(`workflow.trace.propagated`),Mi=J(`workflow.trace.mode`),Ni=J(`workflow.turbo`),Pi=J(`workflow.error.name`),Fi=J(`workflow.error.message`),Ii=J(`workflow.error.code`),Li=J(`workflow.steps.created`),Ri=J(`workflow.hooks.created`),zi=J(`workflow.waits.created`),Bi=J(`workflow.steps.failed_serialization`),Vi=J(`workflow.inline_ownership.owned_recovery_steps`),Hi=J(`workflow.inline_ownership.backstop_wakes_armed`),Ui=J(`workflow.dispatch.republish_skipped`),Wi=J(`workflow.route.type`),Gi=J(`workflow.route.handler_cached`),Ki=J(`workflow.route.invocation_count`),qi=J(`workflow.route.entrypoint_age_ms`),Ji=J(`workflow.route.module_body_init_ms`),Yi=J(`faas.instance`),Xi=J(`step.name`),Zi=J(`step.id`),Qi=J(`step.attempt`),$i=J(`step.status`),ea=J(`step.max_retries`),ta=J(`step.ttfs_ms`),na=J(`step.stso_ms`),ra=J(`step.rsfs_ms`),ia=J(`step.final_scheduling_replay_ms`),aa=J(`step.latency_optimizations`),oa=J(`workflow.step_start.strategy`),sa=J(`step.skipped`),ca=J(`step.skip_reason`),la=J(`step.arguments.count`),ua=J(`step.result.type`),da=J(`step.error.name`),fa=J(`step.error.message`),pa=J(`step.fatal_error`),ma=J(`step.retry.exhausted`),ha=J(`step.retry.timeout_seconds`),ga=J(`step.retry.will_retry`),_a=J(`messaging.system`),va=J(`messaging.destination.name`),ya=J(`messaging.message.id`),ba=J(`messaging.operation.type`),xa=J(`messaging.batch.message_count`),Sa=J(`workflow.queue.overhead_ms`),Ca=J(`deployment.id`),wa=J(`workflow.deployment.pinned_id`),Ta=J(`workflow.deployment_mismatch.retry_count`),Ea=J(`workflow.deployment_mismatch.recovered`),Da=J(`workflow.run.spec_version`),Oa=J(`workflow.run.spec_version_source`),ka=J(`workflow.capability_probe.latency_ms`),Aa=J(`workflow.capability_probe.cached`),ja=J(`workflow.capability_probe.error`),Ma=J(`workflow.hook.token`),Na=J(`workflow.hook.id`),Pa=J(`workflow.hook.found`),Fa=J(`workflow.hook.resume_committed`),Ia=J(`workflow.hook.wake_published`),La=J(`workflow.hook.resilient_resume_materialized`),Ra=J(`workflow.resume_setup_source`),za=J(`workflow.step.resilient_dispatch_recovered`),Ba=J(`workflow.step.resilient_dispatch_materialized`),Va=J(`workflow.step.dispatch_prologue`),Ha=J(`workflow.resume.total_ms`),Ua=J(`workflow.resume.phase.producer_prep_ms`),Wa=J(`workflow.resume.phase.queue_delivery_ms`),Ga=J(`workflow.resume.phase.resume_setup_ms`),Ka=J(`workflow.resume.phase.replay_ms`),qa=J(`workflow.resume.phase.step_dispatch_ms`),Ja=J(`workflow.resume.phase.step_claim_ms`),Ya=J(`workflow.resume.phase.step_prepare_ms`),Xa=J(`workflow.resume.trigger`),Za=J(`workflow.resume.strategy`),Qa=J(`workflow.resume.setup_source`),$a=J(`workflow.resume.step_execution`),eo=J(`workflow.suspension.state`),to=J(`workflow.suspension.hook_count`),no=J(`workflow.suspension.step_count`),ro=J(`workflow.suspension.wait_count`),io=J(`http.request.method`),ao=J(`http.route`),oo=J(`http.response.status_code`),so=J(`error.type`),co=J(`workflow.events.pages_loaded`),lo=J(`workflow.queue.deserialize_time_ms`),uo=J(`workflow.queue.execution_time_ms`),fo=J(`workflow.queue.serialize_time_ms`),po=J(`workflow.serialization.operation`),mo=J(`workflow.serialization.compressed`),ho=J(`workflow.serialization.codec`),go=J(`workflow.serialization.uncompressed_bytes`),_o=J(`workflow.serialization.stored_bytes`),vo=J(`workflow.serialization.compression_ratio`),yo=J(`workflow.serialization.guest_code_executions`),bo=J(`workflow.serialization.guest_code_details`),xo=J(`peer.service`),So=J(`rpc.system`),Co=J(`rpc.service`),wo=J(`rpc.method`),To=J(`error.retryable`),Eo=J(`error.category`),Do=t(`@workflow/core//traceModeWarnings`,1,()=>({unrecognized:new Set}));function Oo(){let e=process.env.WORKFLOW_TRACE_MODE;return e===`continuous`?`continuous`:(e&&e!==`linked`&&!Do.unrecognized.has(e)&&(Do.unrecognized.add(e),rs.warn(`Unrecognized WORKFLOW_TRACE_MODE value "${e}"; expected "linked" or "continuous". Falling back to "linked".`)),`linked`)}function ko(e){return e!==void 0&&Object.keys(e).length>0}function Ao(e,t){return e===`linked`&&ko(t)?Promise.resolve(t):Mo()}async function jo(e,t){if(e!==`linked`)return Zo();let n=await Qo(ko(t)?t:void 0);return n?[n]:void 0}async function Mo(){let e=await Y.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function No(e){let t=await Y.value;if(t)return t.propagation.extract(t.context.active(),e)}async function Po(e,t){if(!e)return t();let n=await Y.value;if(!n)return t();let r=await No(e);return r?n.context.with(r,async()=>await t()):t()}const Y=_(async()=>{try{return await import(`../../@opentelemetry/api/index.js`)}catch{return rs.info(`OpenTelemetry not available, tracing will be disabled`),null}}),Fo=_(async()=>{let e=await Y.value;if(!e)return null;let t=e.trace.getTracer(`workflow`);return zo(e,t),t}),Io=_(async()=>{let e=await Y.value;return e?e.metrics.getMeter(`workflow`).createHistogram(`workflow.step.execute.duration`,{description:`Duration of user step execution`,unit:`ms`}):null});let Lo=!1;function Ro(e){try{return typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?e.message:String(e)}catch{return`Unknown error`}}function zo(e,t){let n=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`);if(!Lo&&n){Lo=!0;try{let n=globalThis[Symbol.for(`opentelemetry.js.api.1`)],r=e.trace.getTracerProvider(),i=r.getDelegate?.()??r,a=t.startSpan(`workflow.otel.probe.core`);console.warn(`[workflow:otel-diag] core`,JSON.stringify({globalRegistrationVersion:n?.version??null,providerCtor:r?.constructor?.name??null,delegateCtor:i?.constructor?.name??null,tracerCtor:t?.constructor?.name??null,probeCtor:a?.constructor?.name??null,probeRecording:a.isRecording()})),a.end()}catch(e){console.warn(`[workflow:otel-diag] core failed:`,e instanceof Error?e.message:e)}}}async function Bo(e,...t){let[n,r]=await Promise.all([Fo.value,Y.value]),{fn:i,opts:a}=typeof t[0]==`function`?{fn:t[0],opts:{}}:{fn:t[1],opts:t[0]};if(!i)throw Error(`Function to trace must be provided`);return!n||!r?await i():n.startActiveSpan(e,a,async e=>{try{let t=await i(e);return e.setStatus({code:r.SpanStatusCode.OK}),t}catch(t){throw re.is(t)?(e.setStatus({code:r.SpanStatusCode.OK}),Ko(t,e)):e.setStatus({code:r.SpanStatusCode.ERROR,message:Ro(t)}),t}finally{e.end()}})}async function Vo(e){let[t,n]=await Promise.all([Fo.value,Y.value]);if(!t||!n)return{end(){},fail(){}};let r=t.startSpan(e),i=!1,a=e=>{i||(i=!0,r.setStatus(e),r.end())};return{end:()=>a({code:n.SpanStatusCode.OK}),fail:e=>a({code:n.SpanStatusCode.ERROR,message:Ro(e)})}}async function Ho(e){let t=await Y.value;return t?t.context.bind(t.context.active(),e):e}async function Uo(){let e=await Y.value;if(!e)return{refresh(){},run:e=>e()};let t=e.context.active(),n={getValue:e=>t.getValue(e),setValue:(e,n)=>t.setValue(e,n),deleteValue:e=>t.deleteValue(e)};return{refresh:()=>{t=e.context.active()},run:t=>e.context.with(n,t)}}async function Wo(e,t,n){let r=await Fo.value;r&&r.startSpan(e,{...n,startTime:t}).end()}async function Go(e,t){(await Io.value)?.record(e,{"workflow.step.status":t})}function Ko(e,t){t.setAttributes({...eo(`suspended`),...no(e.stepCount),...to(e.hookCount),...ro(e.waitCount)})}async function qo(e){let[t,n]=await Promise.all([No(e),Y.value]);if(t&&n)return n.trace.getSpanContext(t)}async function Jo(){return await Xo(e=>e.trace.getActiveSpan())}async function Yo(e){return Xo(t=>t.SpanKind[e])}async function Xo(e){let t=await Y.value;if(t)return await e(t)}function Zo(){return Xo(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function Qo(e){if(!e)return;let[t,n]=await Promise.all([qo(e),Y.value]);if(t&&n&&n.trace.isSpanContextValid(t))return{context:t}}async function $o(e,t){let n=await Y.value;if(!n)return t();let r=n.propagation.createBaggage({"workflow.run_id":{value:e.workflowRunId},"workflow.name":{value:e.workflowName}}),i=n.propagation.setBaggage(n.context.active(),r);return n.context.with(i,()=>t())}function es(e,t){if(typeof t!=`string`||!t)return!1;let n=!1;for(let r of t.split(`,`)){let t=r.trim();if(!t)continue;let i=t.startsWith(`-`),a=i?t.slice(1):t;RegExp(`^${a.replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`)}$`).test(e)&&(n=!i)}return n}function ts(e,t={}){let n=r=>{let i=n=>t.debugNamespace??`workflow:${e}:${n}`,a=t=>{let n=i(t);return(i,a)=>{let o=Object.keys(r).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...r,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(ai(`[workflow-sdk]`,i,c)),es(n,process.env.DEBUG)&&(console.debug(`[${n}] ${i}`,c??``),Jo().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:a(`debug`),info:a(`info`),warn:a(`warn`),error:a(`error`),child:e=>n({...r,...e}),forRun:(e,t,i)=>n({...r,workflowRunId:e,...t===void 0?{}:{workflowName:t},...i??{}})}};return n({})}const ns=ts(`step`),rs=ts(`runtime`),is=ts(`webhook`),X=ts(`events`);ts(`adapter`),ts(`build`,{debugNamespace:`workflow:build`});function as(e){if(f.is(e))throw e}function Z(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof S&&t.path&&(r+=` at path "${t.path}"`);let i=`Ensure you're ${n} workflow serializable types. Check the serialization docs to see what's serializable: https://workflow-sdk.dev/docs/foundations/serialization`;return t instanceof S&&t.value!==void 0&&rs.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function os(e,t,n){try{let r=B.serialize(e,`client`,n);return Jr(await Lr(V(z.DEVALUE_V1,r),n?.compression??!1,n?.compressionStats),t)}catch(e){as(e);let{message:t,hint:n}=Z(`client value`,e);throw new u(t,{hint:n,cause:e})}}async function ss(e,t,n){let r=await Rr(await U(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(B.deserializeLegacy)return B.deserializeLegacy(r,`client`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=H(r);if(i===z.DEVALUE_V1)return B.deserialize(a,`client`,n);throw Error(`Unsupported serialization format: ${i}`)}async function cs(e,t,n){try{let r=B.serialize(e,`step`,n);return Jr(await Lr(V(z.DEVALUE_V1,r),n?.compression??!1,n?.compressionStats),t)}catch(e){as(e);let{message:t,hint:n}=Z(`step value`,e);throw new u(t,{hint:n,cause:e})}}async function ls(e,t,n){let r=await Rr(await U(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(B.deserializeLegacy)return B.deserializeLegacy(r,`step`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=H(r);if(i===z.DEVALUE_V1)return B.deserialize(a,`step`,n);throw Error(`Unsupported serialization format: ${i}`)}function us(e,t){if(!(e instanceof Uint8Array)){if(B.deserializeLegacy)return B.deserializeLegacy(e,`workflow`,t);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:n,payload:r}=H(e);if(n===z.DEVALUE_V1)return B.deserialize(r,`workflow`,t);throw Error(`Unsupported serialization format: ${n}`)}const ds=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),fs=(()=>{let e=globalThis;return e[ds]??=new y,e[ds]})();function ps(e,t,n){if(e===0&&t===0&&n===0)return null;let r=[];e>0&&r.push(`${e} ${o(`step`,`steps`,e)}`),t>0&&r.push(`${t} ${o(`hook`,`hooks`,t)}`),n>0&&r.push(`${n} ${o(`timer`,`timers`,n)}`);let i=[];e>0&&i.push(`steps are completed`),t>0&&i.push(`hooks are received`),n>0&&i.push(`timers have elapsed`);let a=i.join(` and `);return`${r.join(` and `)} to be enqueued\n Workflow will suspend and resume when ${a}`}function ms(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function hs(e){return`strm_${e}_system_abort`}function gs(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return hs(e.slice(5))}const _s=()=>n(`WORKFLOW_DEFERRED_CHECK_DELAY_MS`,100,{integer:!0,min:10}),vs=new Set([`hook_received`,`hook_conflict`,`wait_completed`,`attr_set`,`run_cancelled`]),ys=new Set([`wait_completed`]);function bs(e,t){return`${e}:${t}`}const xs=new Set([`run_completed`,`run_failed`,`run_cancelled`]);var Q;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Q||={});var Ss=class{eventIndex;events;callbacks=[];parked=[];resolved=new Set;seenEventClasses=new Map;onConsumedEvent;onUnconsumedEvent;onDuplicateEvent;getPromiseQueue;isDeliveryIdle;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;lastConsumed;constructor(e,t){this.events=[...e],this.eventIndex=0,this.onConsumedEvent=t.onConsumedEvent,this.onUnconsumedEvent=t.onUnconsumedEvent,this.onDuplicateEvent=t.onDuplicateEvent,this.getPromiseQueue=t.getPromiseQueue,this.isDeliveryIdle=t.isDeliveryIdle}get strandedEvent(){return this.parked[0]?.event}get parkedSummary(){let e=this.parked[0]?.event;if(e)return{count:this.parked.length,eventId:e.eventId,eventType:e.eventType}}describe(){return{index:this.eventIndex,length:this.events.length,parked:this.parked.length,lastConsumedEventId:this.lastConsumed?.eventId}}append(e){for(let t of e)this.events.push(t);process.nextTick(this.consume)}subscribe(e){this.callbacks.push(e),this.pendingUnconsumedCheck!==null&&(this.unconsumedCheckVersion++,this.pendingUnconsumedCheck=null,this.pendingUnconsumedTimeout!==null&&(clearTimeout(this.pendingUnconsumedTimeout),this.pendingUnconsumedTimeout=null)),process.nextTick(this.consume)}notifyConsumedEvent(e){if(this.onConsumedEvent)try{this.onConsumedEvent(e)}catch(e){X.error(`onConsumedEvent callback threw an error`,{error:e})}}consume=()=>{for(;;){this.drainParked();let e=this.events[this.eventIndex]??null;if(e!==null&&i(e)){this.skipSealedNoop(e);continue}let t=this.offer(e);if(t&&this.eventIndex++,e===null){t||this.handleEndOfLog();return}if(!t){let t=this.firstEventTypeOfClass(e);if(t!==void 0){this.skipDuplicateEvent(e,t);continue}this.scheduleUnconsumedCheck(e,!0);return}}};offer(e){for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Q.NotConsumed;try{r=n(e)}catch(e){X.error(`EventConsumer callback threw an error`,{error:e})}if(r===Q.Consumed||r===Q.Finished)return e!==null&&(e.correlationId&&ys.has(e.eventType)&&this.resolved.add(bs(e.eventType,e.correlationId)),this.recordEventClass(e),this.lastConsumed=e,this.notifyConsumedEvent(e)),r===Q.Finished&&this.callbacks.splice(t,1),!0}return!1}drainParked(){let e=this.parked.length>0;for(;e;){e=!1,this.dropParkedDuplicates();for(let t=0;t<this.parked.length;t++){let n=this.parked[t],r=this.eventIndex;this.eventIndex=n.index;let i;try{i=this.offer(n.event)}finally{this.eventIndex=r}if(i){this.parked.splice(t,1),e=this.parked.length>0;break}}}}dropParkedDuplicates(){for(let e=this.parked.length-1;e>=0;e--){let t=this.parked[e].event,n=this.firstEventTypeOfClass(t);if(n!==void 0){this.parked.splice(e,1),X.debug(`Releasing a parked event that repeats a class already in the log`,{eventId:t.eventId,eventType:t.eventType,firstEventType:n,correlationId:t.correlationId});try{this.onDuplicateEvent?.(t,n)}catch(e){X.error(`onDuplicateEvent callback threw an error`,{error:e})}}}}park(e){return!vs.has(e.eventType)||e.correlationId&&this.resolved.has(bs(e.eventType,e.correlationId))?!1:(this.parked.push({event:e,index:this.eventIndex}),this.eventIndex++,X.debug(`Parked an unclaimed event for later delivery`,{eventId:e.eventId,eventType:e.eventType,correlationId:e.correlationId,parked:this.parked.length}),!0)}eventClassKey(t){let n=e(t);return n===void 0?void 0:`${n.eventClass}:${n.entity}`}recordEventClass(e){let t=this.eventClassKey(e);t!==void 0&&!this.seenEventClasses.has(t)&&this.seenEventClasses.set(t,e.eventType)}firstEventTypeOfClass(e){let t=this.eventClassKey(e);return t===void 0?void 0:this.seenEventClasses.get(t)}skipSealedNoop(e){this.eventIndex++,X.debug(`Skipping sealed-log noop event`,{eventId:e.eventId})}skipDuplicateEvent(e,t){this.eventIndex++,X.debug(`Skipping event that repeats a class already in the log`,{eventId:e.eventId,eventType:e.eventType,firstEventType:t,correlationId:e.correlationId});try{this.onDuplicateEvent?.(e,t)}catch(e){X.error(`onDuplicateEvent callback threw an error`,{error:e})}}handleEndOfLog(){if(this.parked.length===0)return;let e=this.events.at(-1);if(!e||!xs.has(e.eventType)){X.debug(`Reached the end of the log still holding events`,{eventId:this.parked[0].event.eventId,eventType:this.parked[0].event.eventType,correlationId:this.parked[0].event.correlationId,parked:this.parked.length});return}this.scheduleUnconsumedCheck(this.parked[0].event,!1)}scheduleUnconsumedCheck(e,t){let n=++this.unconsumedCheckVersion;this.pendingUnconsumedCheck=this.getPromiseQueue().then(()=>new Promise(e=>setTimeout(e,0))).then(()=>this.getPromiseQueue()).then(()=>{this.whenDeliveryIdle(n,()=>{this.pendingUnconsumedTimeout=setTimeout(()=>{this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===n&&(this.pendingUnconsumedCheck=null,this.resolveUnconsumedEvent(e,t))},_s())})})}resolveUnconsumedEvent(e,t){if(t){if(this.events[this.eventIndex]!==e)return;if(this.park(e)){this.consume();return}}this.onUnconsumedEvent(e)}whenDeliveryIdle(e,t){let n=()=>{if(this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===e){if(this.isDeliveryIdle()){t();return}this.getPromiseQueue().then(()=>{this.unconsumedCheckVersion===e&&(this.pendingUnconsumedTimeout=setTimeout(n,0))})}};n()}},Cs=class{aborted=!1;reason=void 0;[D];[O];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[D]=e,this[O]=t}_setAborted(e){if(!this.aborted){this.aborted=!0,this.reason=e,this.#t&&this.#t.call(this);for(let e of this.#e)e();this.#e=[]}}addEventListener(e,t){if(e===`abort`){if(this.aborted){t();return}this.#e.push(t)}}removeEventListener(e,t){e===`abort`&&(this.#e=this.#e.filter(e=>e!==t))}throwIfAborted(){if(this.aborted)throw this.reason??new DOMException(`The operation was aborted.`,`AbortError`)}};function ws(e){return class{signal;[D];[O];constructor(){let t=e.generateUlid(),n=hs(t),r=`abrt_${t}`;this[D]=n,this[O]=r,this.signal=new Cs(n,r);let i=`hook_${e.generateUlid()}`;e.invocationsQueue.set(i,{type:`hook`,correlationId:i,token:r,isWebhook:!1,isSystem:!0}),e.eventsConsumer.subscribe(t=>{if(!t||t.correlationId!==i)return Q.NotConsumed;let n=`eventData`in t&&t.eventData&&`token`in t.eventData?t.eventData.token:void 0;if(typeof n==`string`&&n!==this[O])return e.promiseQueue=e.promiseQueue.then(()=>{e.onWorkflowError(new m(`Replay divergence: abort hook event ${t.eventType} for ${i} belongs to token "${n}", but the current abort hook expects "${this[O]}"`,{eventId:t.eventId}))}),Q.Finished;if(t.eventType===`hook_created`){let t=e.invocationsQueue.get(i);return t&&t.type===`hook`&&(t.hasCreatedEvent=!0),Q.Consumed}if(t.eventType===`hook_received`){let n=t.eventData?.payload,r=e.eventsConsumer.eventIndex,a=g(e,r,`hook`,{deliveredAt:+t.createdAt}),o=ne(e,r,`hook`);return e.pendingDeliveries++,e.promiseQueue=e.promiseQueue.then(async()=>{let r;try{if(n!==void 0)try{let i=await e.replayPayloadCache.prepareEventPayload(t.eventId,`payload`,n),a=await Ic(n,e.runId,e.encryptionKey,e.globalThis,{},i);a&&typeof a==`object`&&`reason`in a&&(r=a.reason)}catch{}}finally{e.pendingDeliveries--}o.then(()=>{a.markDelivered(),this.signal._setAborted(r)})}),e.invocationsQueue.delete(i),Q.Consumed}return t.eventType===`hook_disposed`?(e.invocationsQueue.delete(i),Q.Finished):Q.NotConsumed})}abort(t){if(!this.signal.aborted){this.signal._setAborted(t);for(let[,n]of e.invocationsQueue)if(n.type===`hook`&&n.token===this[O]){n.abortRequested=!0,n.abortReason=t;break}}}}}function Ts(){return{abort(e){let t=new Cs(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new Cs(``,``),n=Array.from(e);for(let e of n)if(e.aborted)return t._setAborted(e.reason),t;let r=[],i=()=>{for(let{signal:e,listener:t}of r)e.removeEventListener&&e.removeEventListener(`abort`,t);r.length=0};for(let e of n){if(!e.addEventListener)continue;let n=()=>{t.aborted||(t._setAborted(e.reason),i())};r.push({signal:e,listener:n}),e.addEventListener(`abort`,n)}return t},timeout(){throw Error(`AbortSignal.timeout() is not supported in workflow functions. Use sleep() with an AbortController instead. See: /docs/errors/abort-signal-timeout-in-workflow`)}}}const Es=r();function Ds(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function Os(e){return as(e),e instanceof u&&e.cause!==void 0||e instanceof a&&e.cause!==void 0?e.cause:e}async function $(e,t){if(e.recorded)try{let n=await Jo();if(!n)return;let r=e.uncompressedBytes??0,i=e.storedBytes??0;n.setAttributes({...po(t),...mo(e.compressed??!1),...ho(e.codec??`none`),...go(r),..._o(i),...e.compressed&&r>0?vo(1-i/r):{}})}catch{}}async function ks(e){let t=e.totalExecutions??e.executions.length;if(t!==0)try{let n=await Jo();if(!n)return;let r=[...new Set(e.executions.map(e=>e.detail?`${e.kind} (${e.detail})`:e.kind))];n.setAttributes({...yo(t),...bo(r)})}catch{}}function As(e,t){let n=new TextEncoder,r={resolved:!1,key:void 0},i;return new TransformStream({async transform(a,o){try{r.resolved||(r.key=await qr(t),r.resolved=!0,Wr(r.key)&&(i=Jt(r.key.recipientPublicKey,r.key.aad)));let s=w(a,e),c=n.encode(s),l=V(z.DEVALUE_V1,c);i?l=V(z.SEALED,await i.seal(l)):r.key&&(l=await Jr(l,r.key));let u=new Uint8Array(4+l.length);new DataView(u.buffer).setUint32(0,l.length,!1),u.set(l,4),o.enqueue(u)}catch(e){if(f.is(e)){o.error(e);return}let{message:t,hint:n}=Z(`stream chunk`,e);o.error(new u(t,{hint:n,cause:e}))}}})}function js(e,t){let n=new TextDecoder,r=new Uint8Array,i={resolved:!1,key:void 0},a;function o(e){let t=new Uint8Array(r.length+e.length);t.set(r,0),t.set(e,r.length),r=t}async function s(o){for(i.resolved||(i.key=await qr(t),i.resolved=!0,Gr(i.key)&&(a=Yt(i.key.keyPair,i.key.aad)));r.length>=4;){let t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,!1);if(r.length<4+t)break;let s=r.slice(4,4+t);r=r.slice(4+t);let{format:c,payload:l}=H(s);if(c===z.ENCRYPTED||c===z.SEALED){let e=c===z.SEALED;if(!(e?Gr(i.key):Kr(i.key)!==void 0)){o.error(new f(e?`Sealed stream data encountered but no run keypair is available. Opening a sealed frame requires the run's own encryption key material.`:`Encrypted stream data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:l.byteLength,formatPrefix:e?`encp`:`encr`}}));return}let t;try{t=e?await a.open(H(s).payload):await U(s,i.key)}catch(e){throw f.is(e)&&e.context&&(e.context.formatPrefix=c),e}({format:c,payload:l}=H(t))}if(c===z.DEVALUE_V1){let t=n.decode(l);o.enqueue(Be(t,e))}}}return new TransformStream({async transform(t,i){if(r.length===0&&t.length>=4){let e=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!1);if(e>0&&e<1e8){o(t),await s(i);return}}else if(r.length>0){o(t),await s(i);return}let a=n.decode(t).split(`
|
|
16
|
-
`);for(let t of a)t.length>0&&i.enqueue(Be(t,e))},async flush(e){r.length>0&&await s(e)}})}const Ms=1e8;function Ns(){return new TransformStream({transform(e,t){if(e.length===0)return;if(e.length>Ms){t.error(new a(`Byte-stream chunk of ${e.length} bytes exceeds the maximum framed chunk size (${Ms}). Split the data into smaller chunks before writing.`,{slug:`serialization-failed`}));return}let n=new Uint8Array(4+e.length);new DataView(n.buffer).setUint32(0,e.length,!1),n.set(e,4),t.enqueue(n)}})}function Ps(){let e=new Uint8Array;function t(t){let n=new Uint8Array(e.length+t.length);n.set(e,0),n.set(t,e.length),e=n}return new TransformStream({transform(n,r){for(n.length>0&&t(n);e.length>=4;){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(t>Ms){r.error(new a(`Byte-stream frame length ${t} exceeds maximum (${Ms}). This usually means a non-framed byte stream is being read as framed.`,{slug:`serialization-failed`}));return}let n=4+t;if(e.length<n)break;r.enqueue(e.slice(4,n)),e=e.slice(n)}},flush(t){e.length>0&&t.error(new a(`Byte-stream ended with ${e.length} bytes of incomplete frame data. The stream was truncated mid-frame.`,{slug:`serialization-failed`}))}})}function Fs(e,t,n,r,i){(async()=>{await Wo(`workflow.stream.read`,e,{kind:await Yo(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read`,"workflow.stream.read.ttfc_ms":Date.now()-e,...typeof i==`number`?{"workflow.stream.read.connect_ms":i}:{},...typeof r==`number`?{"workflow.stream.start_index":r}:{}}})})()}function Is(e,t,n,r){(async()=>{await Wo(`workflow.stream.read.resolve_key`,e,{kind:await Yo(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.read.key_succeeded":r}})})()}function Ls(e,t,n,r,i,a){(async()=>{await Wo(`workflow.stream.read.complete`,e,{kind:await Yo(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read_complete`,"workflow.stream.read.total_ms":Date.now()-e,"workflow.stream.read.chunks":r,"workflow.stream.read.bytes":i,...typeof a==`number`?{"workflow.stream.read.reconnects":a}:{}}})})()}var Rs=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new a(`"name" is required, got "${t}"`);let r,i=!1,o,s=0,c=0;super({type:`bytes`,pull:async a=>{let l=this.#e;if(!l){r===void 0&&(r=Date.now());let i=await At(),a=Date.now(),s=await i.streams.get(e,t,n);o=Date.now()-a,l=this.#e=s.getReader()}if(!l){a.error(Error(`Failed to get reader`));return}let u=await l.read();u.done?(this.#e=void 0,r!==void 0&&Ls(r,e,t,s,c),a.close()):(!i&&u.value.byteLength>0&&r!==void 0&&(i=!0,Fs(r,e,t,n,o)),s+=1,c+=u.value.byteLength,a.enqueue(u.value))},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}};const zs=50,Bs=()=>n(`WORKFLOW_FRAMED_STREAM_MAX_RECONNECTS`,50,{integer:!0,min:1}),Vs=1e3,Hs=()=>n(`WORKFLOW_FRAMED_STREAM_MAX_TOTAL_RECONNECTS`,Vs,{integer:!0,min:1});function Us(e,t,n,r=async()=>void 0){let i=n===void 0||n>=0,a=n??0,o=0,c=0,l=0,u,d=!1,f,p=new Uint8Array,m,g,_=!1,ee=0,te=0,ne=!1;function re(){if(ne)return;ne=!0;let n=Date.now();r().then(r=>{r&&Is(n,e,t,!0)},()=>Is(n,e,t,!1))}async function v(){if(d)return!1;let r=await At();if(d)return!1;let s=i?a+o:n,c=Date.now(),l=await r.streams.get(e,t,s);return d?(await l.cancel(f).catch(()=>{}),!1):(g===void 0&&(g=Date.now()-c),u=l.getReader(),!0)}async function y(){try{let n=await(await At()).streams.getInfo(e,t);return n.done&&a+o>n.tailIndex}catch{return!0}}async function b(){if(d||(u&&=(await u.cancel().catch(()=>{}),void 0),d))return!1;a+=o,o=0,p=new Uint8Array;let e=Bs(),n=Hs();for(;;){if(c++,l++,c>e)throw new s(`Stream "${t}" exceeded maximum reconnection attempts (${e})`);if(l>n)throw new s(`Stream "${t}" exceeded maximum total reconnection attempts (${n})`);try{return!!await v()}catch(e){if(d)return!1;if(h.is(e))throw e}}}return new ReadableStream({pull:async r=>{if(!d)for(m===void 0&&(m=Date.now()),re();;){if(!u)try{if(!await v())return}catch(e){if(d)return;r.error(e);return}let a;try{a=await u.read()}catch(e){if(d)return;if(!i){r.error(e);return}try{if(!await b())return}catch(e){r.error(e);return}continue}if(d)return;if(a.done||!a.value){u=void 0;let n=!i||await y();if(d)return;if(!n){try{if(!await b())return}catch(e){r.error(e);return}continue}m!==void 0&&Ls(m,e,t,ee,te,l),r.close();return}let s=a.value;if(s.length>0){let e=new Uint8Array(p.length+s.length);e.set(p,0),e.set(s,p.length),p=e}let f=!1;for(;p.length>=4;){let i=4+new DataView(p.buffer,p.byteOffset,p.byteLength).getUint32(0,!1);if(p.length<i)break;r.enqueue(p.slice(0,i)),p=p.slice(i),o++,ee++,te+=i,!_&&m!==void 0&&(_=!0,Fs(m,e,t,n,g)),f=!0}if(f){c=0;return}}},cancel:async e=>{d=!0,f=e;let t=u;u=void 0,t&&await t.cancel(e).catch(e=>{console.warn(`Error closing ReadableStream reader:`,e)})}})}const Ws=()=>{let e=n(`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`,NaN,{integer:!0});return Number.isNaN(e)?void 0:e};function Gs(e,t,n,r,i,a,o){(async()=>{await Wo(`workflow.stream.flush`,e,{kind:await Yo(`CLIENT`),attributes:{"workflow.run.id":n,"workflow.stream.name":r,"workflow.stream.operation":`flush`,"workflow.stream.flush.buffer_dwell_ms":t-e,"workflow.stream.flush.chunks":i,"workflow.stream.flush.bytes":a,"workflow.stream.write.chunk_rtt":o}})})()}function Ks(e,t,n){(async()=>{await Wo(`workflow.stream.close`,e,{kind:await Yo(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`close`,"workflow.stream.close.rpc_ms":Date.now()-e}})})()}var qs=class extends WritableStream{constructor(e,t,n){if(typeof e!=`string`)throw new a(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new a(`"name" is required, got "${t}"`);let r=At(),i=n,o=async()=>{if(i){try{await i}catch{}i=void 0}},s=`wrtr_${Es()}`,c=o().then(async()=>(await r).streams.createWriteSession?.(e,t,{writerId:s})),l=0,u=[],d=0,f=0,p=0,m=null,h=null,g,_=Ws(),ee=null,te=dt(),ne=ft(),re=ut(),v=pt(),y,b=[],x=[],ie=e=>{let t=[...b,...x];b=[],x=[];for(let n of t)n.reject(e)},ae=()=>{let e=0,t=0;for(let n of u){if(e>=te||e>0&&t+n.byteLength>ne)break;e++,t+=n.byteLength}let n=u.slice(0,e);return u=u.slice(e),d-=t,{group:n,bytes:t}},oe=async(n,i,a)=>{await o();let s=await r,u=await c,d=Date.now();if(u)await u.write(l,n);else if(typeof s.streams.writeMulti==`function`&&n.length>1)await s.streams.writeMulti(e,t,n);else for(let r of n)await s.streams.write(e,t,r);l+=n.length,a!==void 0&&Gs(a,d,e,t,n.length,i,Date.now()-d)},se=async()=>{for(;u.length>0;){m&&=(clearTimeout(m),null);let e=y,t=Date.now(),{group:n,bytes:r}=ae();f=n.length,p=r,y=u.length>0?t:void 0;try{await oe(n,r,e),f=0,p=0}catch(t){throw u=n.concat(u),d+=r,f=0,p=0,y=e!==void 0&&y!==void 0?Math.min(e,y):e??y,t}let i=b;b=[];for(let e of i)e.resolve()}},ce=()=>{h||g!==void 0||u.length===0||(h=se().then(()=>{if(h=null,u.length>0){ce();return}let e=x;x=[];for(let t of e)t.resolve()},e=>{h=null,g??=e,ie(g)}))},le=()=>{if(!(m||h)){if(_===void 0){ee??=Promise.resolve(r).then(e=>{_=e.streamFlushIntervalMs??0},()=>{_=0}).then(()=>{u.length>0&&le()});return}if(_<=0){ce();return}m=setTimeout(()=>{m=null,ce()},_)}},ue=async()=>{for(;;){if(g!==void 0)throw g;if(u.length===0&&!h)return;ce(),await new Promise((e,t)=>{x.push({resolve:e,reject:t})})}};super({async write(e){if(g!==void 0)throw g;for(y===void 0&&(y=Date.now()),u.push(e),d+=e.byteLength,u.length>=te||d>=ne?ce():le();g===void 0&&(u.length+f>=re||d+p>=v);)ce(),await new Promise((e,t)=>{b.push({resolve:e,reject:t})});if(g!==void 0)throw g},async close(){await ue(),await o();let n=await r,i=await c,a=Date.now();i?await i.close():await n.streams.close(e,t),Ks(a,e,t)},async abort(e){try{await ue()}catch{}m&&=(clearTimeout(m),null),u=[],d=0,g??=e??Error(`Stream aborted`),ie(g),await(await c.catch(()=>void 0))?.dispose?.()}}),Object.defineProperty(this,rt,{value:ue,enumerable:!1,writable:!1}),Object.defineProperty(this,it,{value:async()=>{await(await c.catch(()=>void 0))?.release?.()},enumerable:!1,writable:!1})}};function Js(e=globalThis){let t=_(()=>$s(e,`Request`)),n=_(()=>$s(e,`Response`));return{...Qn(),...lr(),...sr(e),Request:e=>{if(!I(e,t.value))return!1;let n={method:F(e,`method`),url:F(e,`url`),headers:F(e,`headers`),body:F(e,`body`),duplex:F(e,`duplex`)},r=F(e,ot);r&&(n.responseWritable=r);let i=F(e,`signal`);return i&&(F(i,`aborted`)||F(i,D))&&(n.signal=i),n},Response:e=>I(e,n.value)?{type:F(e,`type`),url:F(e,`url`),status:F(e,`status`),statusText:F(e,`statusText`),headers:F(e,`headers`),body:F(e,`body`),redirected:F(e,`redirected`)}:!1}}function Ys(e,t,n,r,i,a){let o=t[D],s=t[O];if(!o){let e=(n[Qe]||Es)();o=hs(e),s=`abrt_${e}`,t[D]=o,t[O]=s,t.signal&&(t.signal[D]=o,t.signal[O]=s)}return Zs(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function Xs(e,t){let n=t[D]??t.signal?.[D],r=t[O]??t.signal?.[O];if(!n)throw Error(`AbortController/AbortSignal stream name is not set`);return{streamName:n,hookToken:r,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function Zs(e,t,n,r,i){e.aborted||e[ct]||(e[ct]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await qr(r),a=await Dc({aborted:!0,reason:e.reason},n,i),o=new qs(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function Qs(e=globalThis,t,n,r,i=!1,a,o=t){return{...Js(e),ReadableStream:s=>{if(!(s instanceof e.ReadableStream))return!1;if(s.locked)throw new u(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let c=`strm_${(e[Qe]||Es)()}`,l=Ds(s),d=new qs(n,c,a);l===`bytes`?i?t.push(s.pipeThrough(Ns()).pipeTo(d)):t.push(s.pipeTo(d)):t.push(s.pipeThrough(As(Qs(e,t,n,r,i,a,o),r)).pipeTo(d));let f={name:c};return l&&(f.type=l),l===`bytes`&&i&&(f.framing=`framed-v1`),f},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let r=t[T],i=t[tt];if(typeof r==`string`&&typeof i==`string`){let e={name:r,runId:i},n=t[E];typeof n==`string`&&(e.encryptionPublicKey=n);let a=t[nt];return typeof a==`string`&&(e.deploymentId=a),e}let a=`strm_${(e[Qe]||Es)()}`,s=new Rs(n,a);return o.push(s.pipeTo(t)),{name:a}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Ys(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Ys(i,i,e,t,n,r)}}function $s(e,t){let n=F(e,t)??F(globalThis,t);if(typeof n==`function`)return F(n,`prototype`)}function ec(e=globalThis){let t=_(()=>$s(e,`ReadableStream`)),n=_(()=>$s(e,`WritableStream`)),r=_(()=>$s(e,`AbortController`)),i=_(()=>$s(e,`AbortSignal`));return{...Js(e),ReadableStream:e=>{if(!I(e,t.value))return!1;let n=F(e,at);if(n!==void 0)return{bodyInit:n};let r=F(e,T);if(!r)throw new a("ReadableStream `name` is not set");let i={name:r},o=F(e,$e);o&&(i.type=o);let s=F(e,et);return s&&(i.framing=s),i},WritableStream:e=>{if(!I(e,n.value))return!1;let t=F(e,T);if(!t)throw new a("WritableStream `name` is not set");let r={name:t},i=F(e,tt);typeof i==`string`&&(r.runId=i);let o=F(e,nt);typeof o==`string`&&(r.deploymentId=o);let s=F(e,E);return typeof s==`string`&&(r.encryptionPublicKey=s),r},AbortController:e=>{if(typeof e!=`object`||!e)return!1;let t=e,n=F(e,D),i=I(e,r.value);if(n===void 0&&!i){let t=F(e,`signal`);if(typeof t!=`object`||!t||F(t,D)===void 0)return!1}let a=F(e,`signal`);return a?Xs(a,t):!1},AbortSignal:e=>{if(typeof e!=`object`||!e)return!1;let t=F(e,D)!==void 0,n=I(e,i.value);return!t&&!n?!1:Xs(e,e)}}}function tc(e=globalThis,t,n,r,i=!1,a,o=t){return{...Js(e),ReadableStream:s=>{if(!(s instanceof e.ReadableStream))return!1;if(s.locked)throw new u(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let c=s[T],l=s[$e],d=s[et];if(!c){c=`strm_${(e[Qe]||Es)()}`,l=Ds(s),d=l===`bytes`&&i?`framed-v1`:d;let u=new qs(n,c,a);l===`bytes`?d===`framed-v1`?t.push(s.pipeThrough(Ns()).pipeTo(u)):t.push(s.pipeTo(u)):t.push(s.pipeThrough(As(tc(e,t,n,r,i,a,o),r)).pipeTo(u))}let f={name:c};return l&&(f.type=l),d&&(f.framing=d),f},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let i=t[T],a=t[tt];i||(i=`strm_${(e[Qe]||Es)()}`,o.push(new Rs(n,i).pipeThrough(js(_c(e,o,n,r),r)).pipeTo(t)));let s={name:i};typeof a==`string`&&(s.runId=a);let c=t[E];typeof c==`string`&&(s.encryptionPublicKey=c);let l=t[nt];return typeof l==`string`&&(s.deploymentId=l),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Ys(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Ys(i,i,e,t,n,r)}}function nc(...e){let t=new WeakSet;function n(e){let t=e[lt];t&&!t.signal.aborted&&t.abort()}function r(e){if(typeof e==`object`&&e&&!t.has(e)){if(t.add(e),e instanceof AbortController){n(e),n(e.signal);return}if(e instanceof AbortSignal){n(e);return}if(Array.isArray(e)){for(let t of e)r(t);return}if(e instanceof Map){for(let t of e.values())r(t);return}if(e instanceof Set){for(let t of e)r(t);return}if(typeof Request<`u`&&e instanceof Request){r(e.signal);return}for(let t of Object.values(e))r(t)}}for(let t of e)r(t)}function rc(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new Rs(t,n).getReader(),a=await Promise.race([r.read(),new Promise(e=>{if(i.signal.aborted){e({value:void 0,done:!0});return}i.signal.addEventListener(`abort`,()=>e({value:void 0,done:!0}),{once:!0})})]);if(a.value&&!a.done){try{r.releaseLock()}catch{}try{let n=fs.getStore(),r=await Oc(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}else r.cancel().catch(()=>{})}catch{}})()),i}function ic(e,t,n){let r=e,i=e.signal;r[D]=t.streamName,r[O]=t.hookToken,i[D]=t.streamName,i[O]=t.hookToken,n&&(r[lt]=n,i[lt]=n)}function ac(e,t){let n=e,r=t;n[D]!==void 0&&(r[D]=n[D]),n[O]!==void 0&&(r[O]=n[O]),n[lt]!==void 0&&(r[lt]=n[lt])}function oc(e,t,n){let r=new AbortController;e.aborted?(ic(r,e),r.abort(e.reason)):e.streamName?ic(r,e,rc(r,n,e.streamName,t)):ic(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=fs.getStore();if(n&&(n.ops.push((async()=>{try{let r=await Dc({aborted:!0,reason:t},n.workflowMetadata.workflowRunId,n.encryptionKey),i=new qs(n.workflowMetadata.workflowRunId,e.streamName).getWriter();await i.write(r),await i.close()}catch{}})()),e.hookToken)){let r=(async()=>{try{let{resumeHook:n}=await import(`./resume-hook-DMsV_b4n.js`).then(e=>e.i);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})();n.preCompletionOps.push(r)}},r}function sc(e,t,n){let r=new AbortController;return e.aborted?(ic(r,e),r.abort(e.reason)):e.streamName?ic(r,e,rc(r,n,e.streamName,t)):ic(r,e),r.signal}function cc(e=globalThis){return{...$n(e),...cr(e)}}async function lc(e,t,n){let r=Zt(n);if(r)return Vr(r);let i=await At();if(!i.getEncryptionKeyForRun)return;let a=t?await i.getEncryptionKeyForRun(e,{deploymentId:t}):await i.getEncryptionKeyForRun(await i.runs.get(e));return a?await We(a,[`encrypt`]):void 0}function uc(e,t,n){let r;return()=>(r??=lc(e,t,n),r)}function dc(e,{deploymentId:t,encryptionPublicKey:n}){typeof t==`string`&&Object.defineProperty(e,nt,{value:t,writable:!1}),typeof n==`string`&&Object.defineProperty(e,E,{value:n,writable:!1})}function fc({global:e,ops:t,runId:n,name:r,key:i,deploymentId:a,encryptionPublicKey:o,runReadyBarrier:s}){let c=As(Qs(e,t,n,i),i),l=new qs(n,r,s),u=ht();return t.push(u.promise),wt(c.readable,l,u).catch(()=>{}),St(c.writable,u),Object.defineProperty(c.writable,T,{value:r,writable:!1}),Object.defineProperty(c.writable,tt,{value:n,writable:!1}),dc(c.writable,{deploymentId:a,encryptionPublicKey:o}),c.writable}function pc(e,t,n,r,i,a){return mc(o=>hc(e,t,n,a,{onReadableState:o}).ReadableStream({name:r,startIndex:i}))}function mc(e,t){let n,r,i=!1,a;return a=new ReadableStream({async pull(o){try{n||(n=e(e=>{r=e}).getReader(),r&&!i&&(i=!0,t?t(r):Ct(a,r)));let s=await n.read();s.done?o.close():o.enqueue(s.value)}catch(e){o.error(e)}},async cancel(e){await n?.cancel(e).catch(()=>{})}},{highWaterMark:0}),a}function hc(e=globalThis,t,n,r,i){function a(a,o=i?.onReadableState){if(a.type===`bytes`){let r=new Rs(n,a.name,a.startIndex),i=ht();t.push(i.promise);let{readable:s,writable:c}=a.framing===`framed-v1`?Ps():new e.TransformStream;return wt(r,c,i).catch(()=>{}),o?o(i):Ct(s,i),s}let s,c=()=>(s??=qr(r),s),l=Us(n,a.name,a.startIndex,c),u=js(hc(e,t,n,c,{lazyStreams:i?.lazyStreams,liveAbortSignals:i?.liveAbortSignals}),c),d=ht();return t.push(d.promise),wt(l,u.writable,d).catch(()=>{}),o?o(d):Ct(u.readable,d),u.readable}function o(e){let t=new AbortController;return e.aborted&&t.abort(e.reason),t}return{...cc(e),StepFunction:()=>{throw new u(`Step functions cannot be deserialized in client context. Step functions should not be returned from workflows.`,{hint:`A step function reference reached the client. Return a serializable value (e.g. the step result) instead of the step itself.`})},WorkflowFunction:e=>Object.assign(()=>{throw new u(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(n.signal=t.signal);let r=new e.Request(t.url,n);return t.signal&&ac(t.signal,r.signal),r},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:t=>{if(`bodyInit`in t){let n=t.bodyInit;return new e.Response(n).body}return i?.lazyStreams?mc(e=>a(t,e),i.onReadableState):a(t)},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:uc(a,i.deploymentId,i.encryptionPublicKey);return fc({global:e,ops:t,runId:a,name:i.name,key:o,deploymentId:i.deploymentId,encryptionPublicKey:i.encryptionPublicKey})},AbortController:e=>i?.liveAbortSignals===!1?o(e):oc(e,t,n),AbortSignal:e=>i?.liveAbortSignals===!1?o(e).signal:sc(e,t,n)}}function gc(e=globalThis){return{...cc(e),...ur(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[ot]=n,delete t.responseWritable,t.respondWith=()=>{throw new u("`respondWith()` must be called from within a step function.",{hint:'Move the `respondWith(...)` call inside a `"use step"` function — it cannot be invoked from a workflow context.'})}),t},WorkflowFunction:e=>Object.assign(()=>{throw new u(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Response:t=>(Object.setPrototypeOf(t,e.Response.prototype),t),ReadableStream:t=>`bodyInit`in t?Object.create(e.ReadableStream.prototype,{[at]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[T]:{value:t.name,writable:!1},[$e]:{value:t.type,writable:!1},[et]:{value:t.framing,writable:!1}}),WritableStream:t=>{let n={[T]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[tt]={value:t.runId,writable:!1}),typeof t.deploymentId==`string`&&(n[nt]={value:t.deploymentId,writable:!1}),typeof t.encryptionPublicKey==`string`&&(n[E]={value:t.encryptionPublicKey,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new Cs(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[D]:e.streamName,[O]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new Cs(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function _c(e=globalThis,t,n,r,i,o,s){return{...cc(e),StepFunction:e=>{let t=e.stepId,n=e.closureVars,r=`boundThis`in e,i=r?e.boundThis:void 0,o=Array.isArray(e.boundArgs)?e.boundArgs:[],s=te(t);if(!s)throw new u(`Step function "${t}" not found. Make sure the step function is registered.`,{hint:`Make sure the step file is included in your build (i.e. it is listed in the workflow manifest), and that the SWC plugin is configured for the file.`});if(!n&&!r&&o.length===0)return s;let c=function(...e){let t=r?i:this,c=o.length>0?[...o,...e]:e;if(n){let e=fs.getStore();if(!e)throw new a(`Cannot call step function with closure variables outside step context`);let r={...e,closureVars:n};return fs.run(r,()=>s.apply(t,c))}return s.apply(t,c)};return Object.defineProperty(c,"name",{value:s.name}),Object.defineProperty(c,"stepId",{value:t,writable:!1,enumerable:!1,configurable:!1}),s.maxRetries!==void 0&&(c.maxRetries=s.maxRetries),c},WorkflowFunction:e=>Object.assign(()=>{throw new u(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n=t.responseWritable,r={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(r.signal=t.signal);let i=new e.Request(t.url,r);return t.signal&&ac(t.signal,i.signal),n&&(i.respondWith=async e=>{let t=n.getWriter();await t.write(e),await t.close()}),i},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:a=>{if(`bodyInit`in a){let t=a.bodyInit;return new e.Response(t).body}let c=new Rs(n,a.name);if(a.type===`bytes`){let n=ht();t.push(n.promise);let{readable:r,writable:i}=a.framing===`framed-v1`?Ps():new e.TransformStream;return wt(c,i,n).catch(()=>{}),Ct(r,n),r}{let a=js(_c(e,t,n,r,i,o,s),r),l=ht();return t.push(l.promise),wt(c,a.writable,l).catch(()=>{}),Ct(a.readable,l),a.readable}},WritableStream:a=>{let c=typeof a.runId==`string`?a.runId:n,l=typeof a.deploymentId==`string`?a.deploymentId:c===n?i:void 0,u=c===n?r:uc(c,l,a.encryptionPublicKey),d=c===n?s:void 0,f=As(tc(e,t,c,u,!1,d),u),p=new qs(c,a.name,d),m=ht();m.deferReleaseSettlement=o!==void 0,o?.push(m),t.push(m.promise),wt(f.readable,p,m).catch(()=>{});let h=xt(f.writable,m,e.WritableStream);return St(h,m),Object.defineProperty(h,T,{value:a.name,writable:!1}),Object.defineProperty(h,tt,{value:c,writable:!1}),l&&Object.defineProperty(h,nt,{value:l,writable:!1}),typeof a.encryptionPublicKey!=`string`&&c===n&&Gr(r)&&Object.defineProperty(h,E,{value:Bt(r.keyPair.publicKey),writable:!1}),typeof a.encryptionPublicKey==`string`&&Object.defineProperty(h,E,{value:a.encryptionPublicKey,writable:!1}),h},AbortController:e=>oc(e,t,n),AbortSignal:e=>sc(e,t,n)}}async function vc(e,t){return await Jr(e,t)}async function yc(e,t){return U(e,t)}const bc=async(e,t)=>{let n={},r=await Rr(await U(e,t),n);return await $(n,`deserialize`),{data:r}};function xc(e,t=globalThis,n={}){return us(e.data,{global:t,extraRevivers:{...zc(gc(t)),...n}})}function Sc(e,t=globalThis,n={}){let{data:r}=e;if(!(r instanceof Uint8Array))return Ve(r,{...gc(t),...n});let{format:i,payload:a}=H(r);if(i===z.DEVALUE_V1)return Be(new TextDecoder().decode(a),{...gc(t),...n});throw Error(`Unsupported serialization format: ${i}`)}async function Cc(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c=r){if(a)return tr(w(e,Qs(i,r,t,n,o,void 0,c)));try{let a={},l=await os(e,n,{global:i,extraReducers:Rc(Qs(i,r,t,n,o,void 0,c)),compression:s,compressionStats:a});return await $(a,`serialize`),l}catch(e){let t=Os(e),{message:n,hint:r}=Z(`workflow arguments`,t);throw new u(n,{hint:r,cause:t})}}async function wc(e,t,n,r=globalThis,i={},a){return xc(a??await bc(e,n),r,i)}async function Tc(e,t,n,r=globalThis,i=!1,a=!1,o){if(i)return tr(w(e,ec(r)));try{let t={},i=o??{executions:[]},s=await cs(e,n,{global:r,extraReducers:Rc(ec(r)),compression:a,compressionStats:t,guestCodeStats:i});return await $(t,`serialize`),await ks(i),s}catch(e){let t=Os(e),{message:n,hint:r}=Z(`workflow return value`,t);throw new u(n,{hint:r,cause:t})}}async function Ec(e,t,n,r=[],i=globalThis,a={}){let o={},s=await ss(e,n,{global:i,extraRevivers:{...zc(hc(i,r,t,n)),...a},compressionStats:o});return await $(o,`deserialize`),s}async function Dc(e,t,n,r=globalThis,i=!1,a=!1,o){if(i)return tr(w(e,ec(r)));try{let t={},i=o??{executions:[]},s=await cs(e,n,{global:r,extraReducers:Rc(ec(r)),compression:a,compressionStats:t,guestCodeStats:i});return await $(t,`serialize`),await ks(i),s}catch(e){let t=Os(e),{message:n,hint:r}=Z(`step arguments`,t);throw new u(n,{hint:r,cause:t})}}async function Oc(e,t,n,r=[],i=globalThis,a={},o,s,c){let l={},u=await ls(e,n,{global:i,extraRevivers:{...zc(_c(i,r,t,n,o,s,c)),...a},compressionStats:l});return await $(l,`deserialize`),u}async function kc(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c,l=r){if(a)return tr(w(e,tc(i,r,t,n,o,c,l)));try{let a={},u=await cs(e,n,{global:i,extraReducers:Rc(tc(i,r,t,n,o,c,l)),compression:s,compressionStats:a});return await $(a,`serialize`),u}catch(e){let t=Os(e),{message:n,hint:r}=Z(`step return value`,t);throw new u(n,{hint:r,cause:t})}}async function Ac(e,t,n,r=[],i=globalThis,a=!1){try{let o=w(e,tc(i,r,t,n)),s=new TextEncoder().encode(o),c=V(z.DEVALUE_V1,s),l={},u=await vc(await Lr(c,a,l),n);return await $(l,`serialize`),u}catch(e){let t=Os(e),{message:n,hint:r}=Z(`step error`,t);throw new u(n,{hint:r,cause:t})}}async function jc(e,t,n,r=globalThis,i={},a){return Sc(a??await bc(e,n),r,i)}async function Mc(e,t,n=!1){try{let r=new TextEncoder().encode(w(e)),i=V(z.DEVALUE_V1,r),a={},o=await vc(await Lr(i,n,a),t);return await $(a,`serialize`),o}catch(e){let t=Os(e),{message:n,hint:r}=Z(`dynamic workflow code`,t);throw new u(n,{hint:r,cause:t})}}async function Nc(e,t,n={}){if(t!==void 0||n.encryptionRequired===!0){let t=br(e);if(t!==z.ENCRYPTED)throw new u(`Dynamic workflow code must be encrypted with the run's key ("${z.ENCRYPTED}"), but the stored payload is ${t?`"${t}"`:`not a recognized format`}.`)}let r={},i=await Rr(await U(e,t),r);if(await $(r,`deserialize`),!(i instanceof Uint8Array))throw new u(`Dynamic workflow code did not decode to binary data.`);let{format:a,payload:o}=H(i);if(a!==z.DEVALUE_V1)throw new u(`Unsupported serialization format for dynamic workflow code: ${a}`);let s;try{s=Be(new TextDecoder().decode(o))}catch(e){throw new u(`Dynamic workflow code payload is not valid devalue.`,{cause:e})}if(typeof s!=`string`)throw new u(`Dynamic workflow code decoded to ${typeof s}, expected a string.`);return s}async function Pc(e,t,n,r=globalThis,i=!1){try{let t=w(e,ec(r)),a=new TextEncoder().encode(t),o=V(z.DEVALUE_V1,a),s={},c=await vc(await Lr(o,i,s),n);return await $(s,`serialize`),c}catch(e){let t=Os(e),{message:n,hint:r}=Z(`run error`,t);throw new u(n,{hint:r,cause:t})}}async function Fc(e,t,n,r=[],i=globalThis,a={},o){let s={},c=await Rr(await U(e,n),s);if(await $(s,`deserialize`),!(c instanceof Uint8Array))return Ve(c,{...hc(i,r,t,n,o),...a});let{format:l,payload:u}=H(c);if(l===z.DEVALUE_V1)return Be(new TextDecoder().decode(u),{...hc(i,r,t,n,o),...a});throw Error(`Unsupported serialization format: ${l}`)}async function Ic(e,t,n,r=globalThis,i={},a){return xc(a??await bc(e,n),r,i)}const Lc=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function Rc(e){let t={};for(let n of Lc)n in e&&(t[n]=e[n]);return t}function zc(e){let t={};for(let n of Lc)n in e&&(t[n]=e[n]);return t}export{Ho as $,Ki as $n,E as $r,la as $t,Fc as A,Ta as An,xr as Ar,ya as At,Ts as B,co as Bn,Bt as Br,Ka as Bt,lc as C,ki as Cn,Wr as Cr,Ma as Ct,ec as D,ja as Dn,Rr as Dr,ao as Dt,Ds as E,Aa as En,Lr as Er,oo as Et,Ec as F,xi as Fn,Xn as Fr,uo as Ft,gs as G,Vi as Gn,ht as Gr,$a as Gt,Q as H,Ri as Hn,Ft as Hr,Qa as Ht,yc as I,Ii as In,Zn as Ir,Sa as It,Z as J,Ei as Jn,xt as Jr,Ha as Jt,ms as K,Di as Kn,wt as Kr,Ya as Kt,vc as L,Fi as Ln,qn as Lr,fo as Lt,jc as M,bi as Mn,z as Mr,_a as Mt,Ic as N,Si as Nn,dr as Nr,xo as Nt,gc as O,ka as On,H as Or,xa as Ot,wc as P,Ci as Pn,Yn as Pr,lo as Pt,Ko as Q,Gi as Qn,nt as Qr,So as Qt,bc as R,Pi as Rn,Kn as Rr,Ua as Rt,hc as S,ta as Sn,Gr as Sr,Ra as St,As as T,wi as Tn,Vr as Tr,io as Tt,Ss as U,pi as Un,At as Ur,Ja as Ut,ws as V,yi as Vn,Zt as Vr,Ga as Vt,ps as W,mi as Wn,Et as Wr,qa as Wt,ns as X,Ai as Xn,Qe as Xr,wo as Xt,rs as Y,Ti as Yn,at as Yr,Xa as Yt,is as Z,qi as Zn,T as Zr,Co as Zt,Ns as _,ca as _n,ii as _r,Yi as _t,nc as a,Xe as ai,ia as an,Oa as ar,ko as at,js as b,$i as bn,Ur as br,La as bt,Mc as c,x as ci,ea as cn,Li as cr,Mo as ct,Ac as d,za as dn,ji as dr,Po as dt,tt as ei,Qi as en,Ji as er,jo as et,kc as f,ua as fn,Ni as fr,$o as ft,Sc as g,ra as gn,$r as gr,so as gt,xc as h,ga as hn,K as hr,To as ht,qs as i,Je as ii,pa as in,Da as ir,Oo as it,Oc as j,Ui as jn,br as jr,ba as jt,Nc as k,Ea as kn,V as kr,va as kt,Pc as l,ce as li,Xi as ln,Bi as lr,Vo as lt,Tc as m,ha as mn,ei as mr,Eo as mt,Vs as n,Ye as ni,fa as nn,hi as nr,Ao as nt,fc as o,qe as oi,Zi as on,gi as or,Qo as ot,Cc as p,ma as pn,zi as pr,Ca as pt,fs as q,Oi as qn,St as qr,Za as qt,Rs as r,Ze as ri,da as rn,wa as rr,Yo as rt,Us as s,We as si,aa as sn,_i as sr,Go as st,zs as t,ot as ti,Va as tn,Wi as tr,Uo as tt,Dc as u,se as ui,Ba as un,Mi as ur,Bo as ut,Ps as v,sa as vn,Kr as vr,Pa as vt,pc as w,Hi as wn,Hr as wr,Ia as wt,Qs as x,na as xn,Jr as xr,Fa as xt,cc as y,oa as yn,U as yr,Na as yt,dc as z,vi as zn,tn as zr,Wa as zt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ai as e}from"./serialization-DPdYS_w2.js";import{i as t}from"./attribute-changes-BW-kbMMn.js";async function n(r){let i=globalThis[e];return i||t(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=`/.well-known/workflow/v1`,t=Symbol.for(`@workflow/core/basePath`),n=globalThis;function r(e){n[t]=e??``}function i(){return n[t]??``}function a(e){return new URL(e),`${e.replace(/[?#].*$/,``).replace(/\/+$/,``)}${i()}`}function o(t,n){let r=new URL(t);return r.pathname=`${r.pathname.replace(/\/+$/,``)}${e}/${s(n)}`,r.search=n.type===`health`?`__health`:``,r.hash=``,r.toString()}function s(e){switch(e.type){case`flow`:case`health`:return`flow`;case`manifest`:return`manifest.json`;case`webhook`:return`webhook/${encodeURIComponent(e.token)}`}throw Error(`Unsupported workflow route: ${String(e.type)}`)}function c(){return`${i()}${e}/flow?__health`}export{r as a,o as i,a as n,c as r,e as t};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The provider handle capability the shutdown registry needs.
|
|
3
|
-
* Structural so handles of any session-options generic register without
|
|
4
|
-
* variance friction.
|
|
5
|
-
*/
|
|
6
|
-
interface ShutdownCapableSandboxHandle {
|
|
7
|
-
onRuntimeShutdown(): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Registers a live sandbox handle for shutdown tracking. A later handle
|
|
11
|
-
* for the same provider and durable session replaces the previous entry.
|
|
12
|
-
*/
|
|
13
|
-
export declare function trackActiveSandboxHandle(input: {
|
|
14
|
-
readonly providerName: string;
|
|
15
|
-
readonly handle: ShutdownCapableSandboxHandle;
|
|
16
|
-
readonly sessionId: string;
|
|
17
|
-
}): void;
|
|
18
|
-
/** Drops a handle from shutdown tracking, unless a newer handle replaced it. */
|
|
19
|
-
export declare function untrackActiveSandboxHandle(input: {
|
|
20
|
-
readonly providerName: string;
|
|
21
|
-
readonly handle: ShutdownCapableSandboxHandle;
|
|
22
|
-
readonly sessionId: string;
|
|
23
|
-
}): void;
|
|
24
|
-
/**
|
|
25
|
-
* Stops every tracked sandbox by invoking its runtime-shutdown hook in
|
|
26
|
-
* parallel, then clears the registry. Failures are logged and never
|
|
27
|
-
* thrown so one misbehaving sandbox cannot block server shutdown.
|
|
28
|
-
*/
|
|
29
|
-
export declare function shutdownActiveSandboxHandles(input?: {
|
|
30
|
-
readonly log?: (message: string) => void;
|
|
31
|
-
}): Promise<void>;
|
|
32
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{toErrorMessage}from"#shared/errors.js";const activeSandboxHandles=new Map;function createActiveSandboxHandleKey(e,t){return`${e}\0${t}`}function trackActiveSandboxHandle(e){activeSandboxHandles.set(createActiveSandboxHandleKey(e.providerName,e.sessionId),e.handle)}function untrackActiveSandboxHandle(e){let t=createActiveSandboxHandleKey(e.providerName,e.sessionId);activeSandboxHandles.get(t)===e.handle&&activeSandboxHandles.delete(t)}async function shutdownActiveSandboxHandles(e){let t=[...activeSandboxHandles.entries()];activeSandboxHandles.clear();let n=await Promise.allSettled(t.map(([,e])=>e.onRuntimeShutdown()));for(let[r,i]of n.entries())if(i.status===`rejected`){let n=t[r];e?.log?.(`failed to shut down sandbox "${n?.[0]??`unknown`}": ${toErrorMessage(i.reason)}`)}}export{shutdownActiveSandboxHandles,trackActiveSandboxHandle,untrackActiveSandboxHandle};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { DockerCli } from "#execution/sandbox/bindings/docker-cli.js";
|
|
2
|
-
import type { InternalSandboxSession } from "#shared/sandbox-session.js";
|
|
3
|
-
export declare function createDockerInternalSession(input: {
|
|
4
|
-
readonly cli: DockerCli;
|
|
5
|
-
readonly containerIdentity: string;
|
|
6
|
-
}): InternalSandboxSession;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{randomUUID}from"node:crypto";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{bufferToStream,streamToBuffer}from"#execution/sandbox/stream-utils.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{expectDockerSuccess}from"#execution/sandbox/bindings/docker-utils.js";import{dirname}from"node:path/posix";import{resolveWorkspacePath}from"#execution/sandbox/bindings/local-provider-utils.js";const DOCKER_KILL_TREE_SCRIPT=[`pid_file="$1"`,`target="$(cat "$pid_file" 2>/dev/null)" || exit 0`,`[ -n "$target" ] || exit 0`,`kill_tree() {`,` local parent="$1" dir child ppid line`,` for dir in /proc/[0-9]*; do`,' child="${dir#/proc/}"',` ppid=""`,` while IFS= read -r line; do`,` case "$line" in`,' PPid:*) ppid="${line#PPid:}"; ppid="${ppid//[^0-9]/}"; break ;;',` esac`,` done < "$dir/status" 2>/dev/null`,` [ "$ppid" = "$parent" ] && kill_tree "$child"`,` done`,` kill -9 "$parent" 2>/dev/null`,`}`,`kill_tree "$target"`,`rm -f "$pid_file"`,`exit 0`].join(`
|
|
2
|
-
`);function createDockerInternalSession(e){let{cli:t,containerIdentity:n}=e;async function killSpawnTree(e){await t.run([`exec`,n,`bash`,`-c`,DOCKER_KILL_TREE_SCRIPT,`eve-kill-tree`,e]).catch(()=>{})}return{resolvePath:resolveWorkspacePath,async spawn(e){let r=[`exec`,`-w`,resolveWorkspacePath(e.workingDirectory??WORKSPACE_ROOT)];for(let[t,n]of Object.entries(e.env??{}))r.push(`-e`,`${t}=${n}`);let i=`/tmp/.eve-sbx-spawn-${randomUUID()}.pid`,a=`echo "$$" > ${shellQuote(i)}; bash -lc ${shellQuote(e.command)}; status=$?; rm -f ${shellQuote(i)}; exit $status`;r.push(n,`bash`,`-c`,a);let o=t.stream(r,{signal:e.abortSignal});return e.abortSignal?.addEventListener(`abort`,()=>void killSpawnTree(i),{once:!0}),{stdout:o.stdout,stderr:o.stderr,async wait(){return await o.wait()},async kill(){await killSpawnTree(i),await o.kill()}}},async readFile(e){let r=shellQuote(e.path),i=await t.run([`exec`,n,`bash`,`-lc`,`if [ -e ${r} ]; then exec cat ${r}; else exit 43; fi`],{signal:e.abortSignal});return i.exitCode===43?null:(expectDockerSuccess(i,`read "${e.path}" from sandbox container`),bufferToStream(i.stdoutBytes))},async removePath(e){let r=`${e.recursive===!0?`r`:``}${e.force===!0?`f`:``}`,i=[`exec`,n,`rm`,...r.length>0?[`-${r}`]:[],`--`,e.path],a=await t.run(i,{signal:e.abortSignal});expectDockerSuccess(a,`remove "${e.path}" from sandbox container`)},async writeFile(e){let r=await streamToBuffer(e.content),i=await t.run([`exec`,`-i`,n,`bash`,`-lc`,`mkdir -p ${shellQuote(dirname(e.path))} && cat > ${shellQuote(e.path)}`],{signal:e.abortSignal,stdin:r});expectDockerSuccess(i,`write "${e.path}" into sandbox container`)}}}export{createDockerInternalSession};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type SandboxProviderResources } from "#shared/sandbox-provider.js";
|
|
2
|
-
import type { SandboxSession } from "#shared/sandbox-session.js";
|
|
3
|
-
export declare function prepareImmutableResources(input: {
|
|
4
|
-
readonly storagePath: string;
|
|
5
|
-
readonly provider: string;
|
|
6
|
-
readonly resourcesKey: string;
|
|
7
|
-
readonly sourcePath: string;
|
|
8
|
-
}): Promise<string>;
|
|
9
|
-
export declare function hydrateSandboxProviderResources(input: {
|
|
10
|
-
readonly copySkills?: boolean;
|
|
11
|
-
readonly log?: (message: string) => void;
|
|
12
|
-
readonly resources: SandboxProviderResources;
|
|
13
|
-
readonly session: SandboxSession;
|
|
14
|
-
}): Promise<void>;
|
|
15
|
-
export declare function hydrateSandboxFromImmutableResources(session: SandboxSession, copySkills?: boolean): Promise<void>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{join}from"node:path";import{copyDirectoryAtomically,writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-provider-utils.js";import{providerResourceTargetFiles}from"#shared/sandbox-provider.js";const SANDBOX_RESOURCES_ROOT=`/eve/resources`;function resolveImmutableResourcesPath(e){return join(e.storagePath,e.provider,`resources`,e.resourcesKey)}async function prepareImmutableResources(e){let t=resolveImmutableResourcesPath(e);return await copyDirectoryAtomically(e.sourcePath,t),t}async function hydrateSandboxProviderResources(e){switch(e.resources.source.kind){case`none`:case`inline`:await writeSandboxSeedFiles(e.session,providerResourceTargetFiles(e.resources));return;case`materialized`:e.log?.(`hydrating workspace and skills from read-only resources`),await hydrateSandboxFromImmutableResources(e.session,e.copySkills);return}}async function hydrateSandboxFromImmutableResources(e,t=!1){let n=t?[` mkdir -p "$HOME/.agents/skills"`,` cp -a ${SANDBOX_RESOURCES_ROOT}/skills/. "$HOME/.agents/skills/"`]:[` ln -s ${SANDBOX_RESOURCES_ROOT}/skills "$HOME/.agents/skills"`],r=await e.run({command:[`set -e`,`if [ -d ${SANDBOX_RESOURCES_ROOT}/workspace ]; then cp -a ${SANDBOX_RESOURCES_ROOT}/workspace/. /workspace/; fi`,`if [ -d ${SANDBOX_RESOURCES_ROOT}/skills ]; then`,` mkdir -p "$HOME/.agents"`,` rm -rf "$HOME/.agents/skills"`,...n,`fi`].join(`
|
|
2
|
-
`)});if(r.exitCode!==0)throw Error(`Failed to hydrate sandbox resources: ${r.stderr||r.stdout}`)}export{hydrateSandboxFromImmutableResources,hydrateSandboxProviderResources,prepareImmutableResources};
|