eve 0.60.1 → 0.61.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/src/chunks/{use-eve-agent-Dmc6sX4d.js → use-eve-agent-C5-yqRuq.js} +177 -85
- package/dist/src/chunks/{use-eve-agent-jSR8P4nK.js → use-eve-agent-CVWk5KKy.js} +177 -85
- package/dist/src/cli/agent-command.js +1 -1
- package/dist/src/cli/dev/local-server-child.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +2 -2
- package/dist/src/cli/dev/tui/setup-issues.js +1 -1
- package/dist/src/client/client.d.ts +3 -1
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/eve-agent-projection.d.ts +1 -0
- package/dist/src/client/eve-agent-projection.js +1 -1
- package/dist/src/client/eve-agent-store-helpers.js +1 -1
- package/dist/src/client/eve-agent-store-state.d.ts +4 -1
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/message-response.d.ts +5 -0
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/optimistic-message-submissions.d.ts +22 -0
- package/dist/src/client/optimistic-message-submissions.js +1 -0
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +7 -7
- package/dist/src/compiled/@eve/catalog/index.js +1 -1
- package/dist/src/compiled/@workflow/core/index.js +1 -1
- package/dist/src/compiled/@workflow/core/log-format.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +5 -3
- package/dist/src/compiled/@workflow/core/serialization.js +1 -1
- package/dist/src/compiled/@workflow/core/types.d.ts +22 -0
- 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/world/runs.d.ts +12 -1
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +7 -7
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-3SKHZsSX.js → attribute-changes-A6HfMNG3.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-DearXsdS.js → dist-D38gP7YF.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/frames-QcJfYHmh.js +3 -0
- package/dist/src/compiled/_chunks/workflow/helpers-6kObVbfS.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{logger-CxBCNokg.js → logger-NN5YHpYy.js} +6 -5
- package/dist/src/compiled/_chunks/workflow/{resume-hook-B7_MC7FC.js → resume-hook-CAqlhwic.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{run-jGFog1uQ.js → run-DJevv8zz.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{serialization-VRHEKI6l.js → serialization-C5KgPESk.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/sleep-CbUwdv6O.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{wait-until-DDJySKt-.js → wait-until-BMY_tOr-.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{ws-transport-CEFNBXPC.js → ws-transport-DSDcKH08.js} +1 -1
- package/dist/src/compiler/default-tool-policy.js +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +5 -2
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/compiler/project-sources.js +1 -1
- package/dist/src/compiler/validate-artifact.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-metadata.d.ts +1 -0
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/agent-router.js +1 -1
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
- package/dist/src/execution/tools/subagent/metadata.js +1 -1
- package/dist/src/execution/tools/workflow/step-execution.js +1 -1
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/authored-runtime-modules.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +1 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/development-generation.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/extension-distribution.js +1 -1
- package/dist/src/internal/nitro/host.js +1 -1
- package/dist/src/internal/node-esm-compat-banner.js +3 -3
- package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/builder-support.js +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/internal/workflow-bundle/nitro-step-entry.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/nitro-step-entry.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-directive-ast.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/workflow-directive-ast.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-transformer.js +1 -1
- package/dist/src/protocol/message.d.ts +4 -0
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/services/dev-client/agent-info-probe.d.ts +1 -0
- package/dist/src/services/dev-client/agent-info-probe.js +1 -1
- package/dist/src/setup/primitives/pm/pnpm.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/map-concurrent.d.ts +2 -0
- package/dist/src/shared/map-concurrent.js +1 -0
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/definition.d.ts +2 -0
- package/dist/src/tools/dynamic.d.ts +1 -0
- package/dist/src/tools/provided/agent-router.d.ts +1 -1
- package/dist/src/tools/provided/agent-router.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +5 -3
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/concepts/built-in-tools.md +1 -1
- package/docs/concepts/sessions-runs-and-streaming.md +32 -32
- package/docs/guides/client/overview.mdx +2 -0
- package/docs/guides/frontend/overview.mdx +7 -3
- package/docs/reference/typescript-api.md +1 -1
- package/docs/subagents/index.mdx +3 -3
- package/docs/tools/overview.mdx +17 -0
- package/docs/tools/workflows.mdx +46 -23
- package/package.json +7 -7
- package/dist/src/compiled/_chunks/workflow/frames-Bm_yZi8X.js +0 -3
- package/dist/src/compiled/_chunks/workflow/helpers-K7otPd_U.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-60eDbac6.js +0 -1
package/docs/tools/workflows.mdx
CHANGED
|
@@ -15,7 +15,7 @@ suspend in either execution mode; running in the background does not require a s
|
|
|
15
15
|
|
|
16
16
|
Workflow tools use the [Workflow SDK](https://workflow-sdk.dev): `"use workflow"`, `"use step"`, `createHook`,
|
|
17
17
|
`createWebhook`, `sleep`, retries, and replay. eve provides `ctx.ask` for questions answered through
|
|
18
|
-
the session's channel, `ctx.agents` for effective
|
|
18
|
+
the session's channel, `ctx.agents` for effective callable-agent descriptions, and `ctx.agent` for durable agent delegation. Use `yield` to report
|
|
19
19
|
progress and `await` on a workflow operation to wait durably. Values needed after a durable wait
|
|
20
20
|
stay in local variables in the workflow body.
|
|
21
21
|
|
|
@@ -79,14 +79,16 @@ or days later, the run resumes, deploys, and returns. The model sees one tool re
|
|
|
79
79
|
`start`, `getRun`, and `resumeHook` from `workflow/api` belong in steps. Your app does not install
|
|
80
80
|
the SDK; for types, new projects list `eve/workflow-modules` in the tsconfig `types`.
|
|
81
81
|
- In the body, `ctx` has `session`, `callId`, `toolName`, `abortSignal`, `agent`, `agents`, and `ask`.
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
A `"use step"` helper that receives `ctx` directly gets a restricted `WorkflowStepToolContext` with
|
|
83
|
+
`session`, `callId`, `toolName`, `abortSignal`, `getToken`, and `requireAuth`. Read `ctx.agents`, call
|
|
84
|
+
`ctx.agent()`, and call `ctx.ask()` in the workflow body; pass only the serializable values the step needs.
|
|
85
|
+
`getSandbox` and `getSkill` remain unavailable.
|
|
84
86
|
- The tool's input must be a JSON object. Workflow bodies are for static tools under `agent/tools/`,
|
|
85
87
|
not tools returned from `defineDynamic` resolvers.
|
|
86
88
|
|
|
87
|
-
`ctx.agent`, `ctx.agents`, and `ctx.ask` are available only on `WorkflowToolContext
|
|
88
|
-
handlers,
|
|
89
|
-
`
|
|
89
|
+
`ctx.agent`, `ctx.agents`, and `ctx.ask` are available only on `WorkflowToolContext` in the workflow body.
|
|
90
|
+
Ordinary tools, channel handlers, schedule handlers, and workflow steps do not receive these methods. Type
|
|
91
|
+
step helpers with `WorkflowStepToolContext` from `eve/tools` when they need step-safe context capabilities.
|
|
90
92
|
|
|
91
93
|
Workflow executors require `defineWorkflowTool`. Adding `"use workflow"` to `defineTool`, a bare
|
|
92
94
|
tool object, a channel handler, or a schedule handler fails the build. To start a session from a
|
|
@@ -217,9 +219,9 @@ The provider declaration and the API request both stay inside the step:
|
|
|
217
219
|
|
|
218
220
|
```ts
|
|
219
221
|
import { connect } from "@vercel/connect/eve";
|
|
220
|
-
import type {
|
|
222
|
+
import type { WorkflowStepToolContext } from "eve/tools";
|
|
221
223
|
|
|
222
|
-
async function readRepository(ctx:
|
|
224
|
+
async function readRepository(ctx: WorkflowStepToolContext, repository: string) {
|
|
223
225
|
"use step";
|
|
224
226
|
const provider = connect("github/my-agent");
|
|
225
227
|
const { token } = await ctx.getToken(provider);
|
|
@@ -317,13 +319,24 @@ const result = await ctx.agent("reviewer", {
|
|
|
317
319
|
});
|
|
318
320
|
```
|
|
319
321
|
|
|
320
|
-
The first argument is
|
|
322
|
+
The first argument is an available agent target. On the root agent, `"agent"` starts or continues a copy of the root agent. A declared subagent uses its path-derived name and remains callable when hidden with `tool: false` or `disableTool()`. Delegated root copies and declared subagent contexts do not expose the built-in root-copy target. The invocation name `agent` is reserved, so a declared subagent cannot shadow it. eve assigns each call a replay-stable invocation identity, including repeated and parallel calls to the same target. Pass `agentId` to
|
|
321
323
|
continue an existing child. An inline `outputSchema` requires structured output and determines the
|
|
322
324
|
return type, so `result` in the example is typed as `{ findings: string[] }`.
|
|
323
325
|
|
|
324
326
|
### Route to a hidden subagent with JEV
|
|
325
327
|
|
|
326
|
-
Use an authored workflow tool when the parent model should decide to delegate, but JEV should choose the specialist. Set `tool: false` on each specialist so the parent model sees only the routing tool. The specialists remain available through `ctx.agents` and callable through `ctx.agent()
|
|
328
|
+
Use an authored workflow tool when the parent model should decide to delegate, but JEV should choose the specialist. Set `tool: false` on each specialist so the parent model sees only the routing tool. The specialists remain available through `ctx.agents` and callable through `ctx.agent()`.
|
|
329
|
+
|
|
330
|
+
If the router may select the root-copy `agent`, author a root `description` that explains which work should stay with a copy of the root. `ctx.agents.agent` always exists in a top-level root workflow, but its `description` is an empty string when omitted from `agent.ts`. `agentRouter()` considers only entries with a non-empty description, so it does not route to an undescribed root copy.
|
|
331
|
+
|
|
332
|
+
```ts title="agent/agent.ts"
|
|
333
|
+
import { defineAgent } from "eve";
|
|
334
|
+
|
|
335
|
+
export default defineAgent({
|
|
336
|
+
description: "Coordinate cross-specialist tasks that need the root agent's complete toolset.",
|
|
337
|
+
model: "anthropic/claude-opus-4.8",
|
|
338
|
+
});
|
|
339
|
+
```
|
|
327
340
|
|
|
328
341
|
```ts title="agent/subagents/researcher/agent.ts"
|
|
329
342
|
import { defineAgent } from "eve";
|
|
@@ -349,23 +362,24 @@ Define the model-visible router under `agent/tools/`. Build the JEV criteria fro
|
|
|
349
362
|
|
|
350
363
|
```ts title="agent/tools/agent-router.ts"
|
|
351
364
|
import { evaluate } from "eve/ai";
|
|
352
|
-
import { defineWorkflowTool
|
|
365
|
+
import { defineWorkflowTool } from "eve/tools";
|
|
353
366
|
import { z } from "zod";
|
|
354
367
|
|
|
355
|
-
async function chooseTarget(
|
|
368
|
+
async function chooseTarget(
|
|
369
|
+
task: string,
|
|
370
|
+
criteria: Record<"researcher" | "operator", string>,
|
|
371
|
+
abortSignal: AbortSignal,
|
|
372
|
+
) {
|
|
356
373
|
"use step";
|
|
357
374
|
|
|
358
375
|
const result = await evaluate({
|
|
359
|
-
abortSignal
|
|
376
|
+
abortSignal,
|
|
360
377
|
state: { task },
|
|
361
378
|
questions: {
|
|
362
379
|
route: {
|
|
363
380
|
type: "choice",
|
|
364
381
|
instructions: "Which specialist should handle this task?",
|
|
365
|
-
criteria
|
|
366
|
-
researcher: ctx.agents.researcher.description,
|
|
367
|
-
operator: ctx.agents.operator.description,
|
|
368
|
-
},
|
|
382
|
+
criteria,
|
|
369
383
|
},
|
|
370
384
|
},
|
|
371
385
|
});
|
|
@@ -379,7 +393,14 @@ export default defineWorkflowTool({
|
|
|
379
393
|
async execute({ task }, ctx) {
|
|
380
394
|
"use workflow";
|
|
381
395
|
|
|
382
|
-
const target = await chooseTarget(
|
|
396
|
+
const target = await chooseTarget(
|
|
397
|
+
task,
|
|
398
|
+
{
|
|
399
|
+
researcher: ctx.agents.researcher.description,
|
|
400
|
+
operator: ctx.agents.operator.description,
|
|
401
|
+
},
|
|
402
|
+
ctx.abortSignal,
|
|
403
|
+
);
|
|
383
404
|
|
|
384
405
|
return ctx.agent(target, { message: task });
|
|
385
406
|
},
|
|
@@ -388,19 +409,21 @@ export default defineWorkflowTool({
|
|
|
388
409
|
|
|
389
410
|
The evaluation runs in a step so workflow replay records its result instead of making the routing request again. The parent model receives `agent-router`, but not `researcher` or `operator`. JEV returns the typed `"researcher" | "operator"` choice, and the selected subagent's result becomes the `agent-router` tool result.
|
|
390
411
|
|
|
391
|
-
`ctx.agents` is a replay-stable metadata snapshot taken when the workflow starts.
|
|
412
|
+
`ctx.agents` is a replay-stable metadata snapshot taken when the workflow starts. In a top-level root workflow, `ctx.agents.agent` always represents the root-copy target and carries the root's authored `description` when provided. The snapshot also includes declared agents hidden from the parent model with `tool: false` or `disableTool()`, but exposes no model definitions, credentials, or callbacks. A delegated root copy omits `agent`, so `agentRouter()` cannot select another root copy recursively. Invocation still checks each target's availability through `ctx.agent()`.
|
|
392
413
|
|
|
393
|
-
#### Route across every
|
|
414
|
+
#### Route across every agent target
|
|
394
415
|
|
|
395
|
-
|
|
416
|
+
To replace the model-facing `agent` tool with a router across every target in `ctx.agents`, export `agentRouter()` from the `agent` slot:
|
|
396
417
|
|
|
397
|
-
```ts title="agent/tools/agent
|
|
418
|
+
```ts title="agent/tools/agent.ts"
|
|
398
419
|
import { agentRouter } from "eve/tools/agent-router";
|
|
399
420
|
|
|
400
421
|
export default agentRouter();
|
|
401
422
|
```
|
|
402
423
|
|
|
403
|
-
Its input is `{ message: string, outputSchema?: object }`. With two or more
|
|
424
|
+
Its input is `{ message: string, outputSchema?: object }`. `agentRouter()` ignores entries without a non-empty description. With two or more described targets, it sends the message and effective descriptions to JEV, then invokes the selected name through `ctx.agent()`. It invokes a sole target without evaluation and forwards an optional `outputSchema` unchanged. In a top-level root session, the candidates include the root-copy `agent`; delegated root copies and declared subagent contexts include only their declared targets.
|
|
425
|
+
|
|
426
|
+
When an authored tool accepts a JSON Schema supplied by the model, represent that input with a permissive object such as `z.looseObject({})`. Avoid `z.record(z.string(), z.json())`: its generated JSON Schema uses `propertyNames`, which OpenAI does not support. Validate the supplied value at the point where your tool consumes it.
|
|
404
427
|
|
|
405
428
|
This pattern controls specialist selection, not whether the parent model delegates at all. Route before the parent model runs if every incoming request must go through JEV.
|
|
406
429
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eve",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Filesystem-first framework for durable backend AI agents that run anywhere.",
|
|
6
6
|
"keywords": [
|
|
@@ -496,14 +496,14 @@
|
|
|
496
496
|
"@vercel/otel": "2.1.3",
|
|
497
497
|
"@vercel/sandbox": "3.3.0",
|
|
498
498
|
"@vercel/sdk": "1.28.8",
|
|
499
|
-
"@workflow/builders": "5.0.0-beta.
|
|
500
|
-
"@workflow/core": "5.0.0-beta.
|
|
499
|
+
"@workflow/builders": "5.0.0-beta.53",
|
|
500
|
+
"@workflow/core": "5.0.0-beta.53",
|
|
501
501
|
"@workflow/errors": "5.0.0-beta.21",
|
|
502
502
|
"@workflow/serde": "5.0.0-beta.2",
|
|
503
503
|
"@workflow/utils": "5.0.0-beta.10",
|
|
504
|
-
"@workflow/world": "5.0.0-beta.
|
|
505
|
-
"@workflow/world-local": "5.0.0-beta.
|
|
506
|
-
"@workflow/world-vercel": "5.0.0-beta.
|
|
504
|
+
"@workflow/world": "5.0.0-beta.36",
|
|
505
|
+
"@workflow/world-local": "5.0.0-beta.45",
|
|
506
|
+
"@workflow/world-vercel": "5.0.0-beta.48",
|
|
507
507
|
"ai": "^7.0.105",
|
|
508
508
|
"autoevals": "0.0.132",
|
|
509
509
|
"chat": "4.34.0",
|
|
@@ -575,7 +575,7 @@
|
|
|
575
575
|
"clean": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\"",
|
|
576
576
|
"build": "pnpm run check:bin-runtime-dependencies && pnpm run build:js && node ./scripts/copy-docs.mjs && node ./scripts/stamp-version-tokens.mjs",
|
|
577
577
|
"build:compiled": "node ./scripts/vendor-compiled.mjs",
|
|
578
|
-
"build:js": "
|
|
578
|
+
"build:js": "node ./scripts/build-js.mjs",
|
|
579
579
|
"build:types": "pnpm run build:compiled && tsc -p tsconfig.build.json",
|
|
580
580
|
"check:bin-runtime-dependencies": "node ./scripts/check-bin-runtime-dependencies.mjs",
|
|
581
581
|
"dev": "pnpm run build:compiled && node ./scripts/copy-runtime-assets.mjs && tsc -p tsconfig.dev.json --watch --preserveWatchOutput",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e,i as t,t as n}from"./rolldown-runtime-DPpTSio4.js";import{A as r,C as i,T as a}from"./schemas-4CmFgxN_.js";import{dt as o,h as s,mt as c,pt as l}from"./dist-DearXsdS.js";import{A as u,_ as d,c as f,d as p,g as m,r as h,v as g,y as _}from"./dist-xTushGCp.js";import{a as v,n as y,r as b}from"./signal-exit-B9U6kH7R.js";import{n as x,r as S,t as C}from"./token-util-BkqzD0OM.js";import{createRequire as ee}from"module";import{inspect as te}from"node:util";import ne from"node:os";var re=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),ie=n(((t,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{getVercelOidcToken:()=>p,getVercelOidcTokenSync:()=>m}),n.exports=l(u);var d=re(),f=S();async function p(t){let n=``,r;try{n=m()}catch(e){r=e}try{let[{getTokenPayload:r,isExpired:i},{refreshToken:a}]=await Promise.all([await import(`./token-util-BkqzD0OM.js`).then(t=>e(t.t())),await import(`./token-CrFhCmWs.js`).then(t=>e(t.default))]);(!n||i(r(n),t?.expirationBufferMs))&&(await a(t),n=m())}catch(e){let t=r instanceof Error?r.message:``;throw e instanceof Error&&(t=`${t}
|
|
2
|
-
${e.message}`),t?new f.VercelOidcTokenError(t):e}return n}function m(){let e=(0,d.getContext)().headers?.[`x-vercel-oidc-token`]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error(`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`);return e}0&&(n.exports={getVercelOidcToken:p,getVercelOidcTokenSync:m})})),ae=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>f.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>f.RefreshAccessTokenFailedError,getContext:()=>d.getContext,getVercelOidcToken:()=>u.getVercelOidcToken,getVercelOidcTokenSync:()=>u.getVercelOidcTokenSync,getVercelToken:()=>p.getVercelToken}),t.exports=c(l);var u=ie(),d=re(),f=x(),p=C();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})})),oe=ae();let se;try{se=new TextDecoder}catch{}let w,T,E=0;const ce=[],le=57337,ue={};let de=11281e4,D=1681e4,O=ce,fe=0,k={},A,pe,me=0,j=0,M,N,P=[],he=[],F,I,ge,_e={useRecords:!1,mapsAsObjects:!0},ve=!1,ye=2;try{Function(``)}catch{ye=1/0}var be=class e{constructor(e){if(e&&((e.keyMap||e._keyMap)&&!e.useRecords&&(e.useRecords=!1,e.mapsAsObjects=!0),e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.getStructures&&(e.getShared=e.getStructures),e.getShared&&!e.structures&&((e.structures=[]).uninitialized=!0),e.keyMap)){this.mapKey=new Map;for(let[t,n]of Object.entries(e.keyMap))this.mapKey.set(n,t)}Object.assign(this,e)}decodeKey(e){return this.keyMap&&this.mapKey.get(e)||e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(e){if(!this._keyMap)return e;let t=new Map;for(let[n,r]of Object.entries(e))t.set(this._keyMap.hasOwnProperty(n)?this._keyMap[n]:n,r);return t}decodeKeys(e){if(!this._keyMap||e.constructor.name!=`Map`)return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let t={};return e.forEach((e,n)=>t[R(this._mapKey.has(n)?this._mapKey.get(n):n)]=e),t}mapDecode(e,t){let n=this.decode(e);if(this._keyMap)switch(n.constructor.name){case`Array`:return n.map(e=>this.decodeKeys(e))}return n}decode(t,n){if(w)return We(()=>(Ge(),this?this.decode(t,n):e.prototype.decode.call(_e,t,n)));T=n>-1?n:t.length,E=0,fe=0,j=0,pe=null,O=ce,M=null,w=t;try{I=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw w=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(k=this,F=this.sharedValues&&(this.pack?Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return A=this.structures,xe();(!A||A.length>0)&&(A=[])}else k=_e,(!A||A.length>0)&&(A=[]),F=null;return xe()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;ve=!0;let a=this?this.decode(e,i):qe.decode(e,i);if(t){if(t(a)===!1)return;for(;E<i;)if(r=E,t(xe())===!1)return}else{for(n=[a];E<i;)r=E,n.push(xe());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{ve=!1,Ge()}}};function xe(){try{let e=L();if(M){if(E>=M.postBundlePosition){let e=Error(`Unexpected bundle position`);throw e.incomplete=!0,e}E=M.postBundlePosition,M=null}if(E==T)A=null,w=null,N&&=null;else if(E>T){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!ve)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw Ge(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`))&&(e.incomplete=!0),e}}function L(){let e=w[E++],t=e>>5;if(e&=31,e>23)switch(e){case 24:e=w[E++];break;case 25:if(t==7)return Me();e=I.getUint16(E),E+=2;break;case 26:if(t==7){let e=I.getFloat32(E);if(k.useFloat32>2){let t=Ke[(w[E]&127)<<1|w[E+1]>>7];return E+=4,(t*e+(e>0?.5:-.5)>>0)/t}return E+=4,e}e=I.getUint32(E),E+=4;break;case 27:if(t==7){let e=I.getFloat64(E);return E+=8,e}if(t>1){if(I.getUint32(E)>0)throw Error(`JavaScript does not support arrays, maps, or strings with length over 4294967295`);e=I.getUint32(E+4)}else k.int64AsNumber?(e=I.getUint32(E)*4294967296,e+=I.getUint32(E+4)):e=I.getBigUint64(E);E+=8;break;case 31:switch(t){case 2:case 3:throw Error(`Indefinite length not supported for byte or text strings`);case 4:let e=[],n,r=0;for(;(n=L())!=ue;){if(r>=de)throw Error(`Array length exceeds ${de}`);e[r++]=n}return t==4?e:t==3?e.join(``):Buffer.concat(e);case 5:let i;if(k.mapsAsObjects){let e={},t=0;if(k.keyMap)for(;(i=L())!=ue;){if(t++>=D)throw Error(`Property count exceeds ${D}`);e[R(k.decodeKey(i))]=L()}else for(;(i=L())!=ue;){if(t++>=D)throw Error(`Property count exceeds ${D}`);e[R(i)]=L()}return e}{ge&&=(k.mapsAsObjects=!0,!1);let e=new Map;if(k.keyMap){let t=0;for(;(i=L())!=ue;){if(t++>=D)throw Error(`Map size exceeds ${D}`);e.set(k.decodeKey(i),L())}}else{let t=0;for(;(i=L())!=ue;){if(t++>=D)throw Error(`Map size exceeds ${D}`);e.set(i,L())}}return e}case 7:return ue;default:throw Error(`Invalid major type for indefinite length `+t)}default:throw Error(`Unknown token `+e)}switch(t){case 0:return e;case 1:return~e;case 2:return ke(e);case 3:if(j>=E)return pe.slice(E-me,(E+=e)-me);if(j==0&&T<140&&e<32){let t=e<16?Oe(e):De(e);if(t!=null)return t}return we(e);case 4:if(e>=de)throw Error(`Array length exceeds ${de}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=L();return t;case 5:if(e>=D)throw Error(`Map size exceeds ${de}`);if(k.mapsAsObjects){let t={};if(k.keyMap)for(let n=0;n<e;n++)t[R(k.decodeKey(L()))]=L();else for(let n=0;n<e;n++)t[R(L())]=L();return t}{ge&&=(k.mapsAsObjects=!0,!1);let t=new Map;if(k.keyMap)for(let n=0;n<e;n++)t.set(k.decodeKey(L()),L());else for(let n=0;n<e;n++)t.set(L(),L());return t}case 6:if(e>=le){let t=A[e&8191];if(t)return t.read||(t.read=Ce(t)),t.read();if(e<65536){if(e==57343){let e=He(),t=L(),n=L();Ne(t,n);let r={};if(k.keyMap)for(let t=2;t<e;t++){let e=k.decodeKey(n[t-2]);r[R(e)]=L()}else for(let t=2;t<e;t++){let e=n[t-2];r[R(e)]=L()}return r}if(e==57342){let e=He(),t=L();for(let n=2;n<e;n++)Ne(t++,L());return L()}if(e==le)return Ve();if(k.getShared&&(Ue(),t=A[e&8191],t))return t.read||(t.read=Ce(t)),t.read()}}let n=P[e];if(n)return n.handlesRead?n(L):n(L());{let t=L();for(let n=0;n<he.length;n++){let r=he[n](e,t);if(r!==void 0)return r}return new B(t,e)}case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:let t=(F||V())[e];if(t!==void 0)return t;throw Error(`Unknown token `+e)}default:if(isNaN(e)){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}throw Error(`Unknown CBOR token `+e)}}const Se=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ce(e){if(!e)throw Error(`Structure is required in record definition`);function t(){let e=w[E++];if(e&=31,e>23)switch(e){case 24:e=w[E++];break;case 25:e=I.getUint16(E),E+=2;break;case 26:e=I.getUint32(E),E+=4;break;default:throw Error(`Expected array header, but got `+w[E-1])}let t=this.compiledReader;for(;t;){if(t.propertyCount===e)return t(L);t=t.next}if(this.slowReads++>=ye){let n=this.length==e?this:this.slice(0,e);return t=k.keyMap?Function(`r`,`return {`+n.map(e=>k.decodeKey(e)).map(e=>Se.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>Se.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`),this.compiledReader&&(t.next=this.compiledReader),t.propertyCount=e,this.compiledReader=t,t(L)}let n={};if(k.keyMap)for(let t=0;t<e;t++)n[R(k.decodeKey(this[t]))]=L();else for(let t=0;t<e;t++)n[R(this[t])]=L();return n}return e.slowReads=0,t}function R(e){if(typeof e==`string`)return e===`__proto__`?`__proto_`:e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;throw Error(`Invalid property name type `+typeof e)}let we=Ee;function Te(e){we=t(1);function t(t){return function(t){let n=O[fe++];if(n==null){if(M)return Ee(t);let r=e(E,T,t,w);if(typeof r==`string`)n=r,O=ce;else if(O=r,fe=1,j=1,n=O[0],n===void 0)throw Error(`Unexpected end of buffer`)}let r=n.length;return r<=t?(E+=t,n):(pe=n,me=E,j=E+r,E+=t,n.slice(0,t))}}}function Ee(e){let t;if(e<16&&(t=Oe(e)))return t;if(e>64&&se)return se.decode(w.subarray(E,E+=e));let n=E+e,r=[];for(t=``;E<n;){let e=w[E++];if(!(e&128))r.push(e);else if((e&224)==192){let t=w[E++]&63;r.push((e&31)<<6|t)}else if((e&240)==224){let t=w[E++]&63,n=w[E++]&63;r.push((e&31)<<12|t<<6|n)}else if((e&248)==240){let t=w[E++]&63,n=w[E++]&63,i=w[E++]&63,a=(e&7)<<18|t<<12|n<<6|i;a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a)}else r.push(e);r.length>=4096&&(t+=z.apply(String,r),r.length=0)}return r.length>0&&(t+=z.apply(String,r)),t}let z=String.fromCharCode;function De(e){let t=E,n=Array(e);for(let r=0;r<e;r++){let e=w[E++];if((e&128)>0){E=t;return}n[r]=e}return z.apply(String,n)}function Oe(e){if(e<4){if(e<2){if(e===0)return``;{let e=w[E++];if((e&128)>1){--E;return}return z(e)}}{let t=w[E++],n=w[E++];if((t&128)>0||(n&128)>0){E-=2;return}if(e<3)return z(t,n);let r=w[E++];if((r&128)>0){E-=3;return}return z(t,n,r)}}{let t=w[E++],n=w[E++],r=w[E++],i=w[E++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){E-=4;return}if(e<6){if(e===4)return z(t,n,r,i);{let e=w[E++];if((e&128)>0){E-=5;return}return z(t,n,r,i,e)}}if(e<8){let a=w[E++],o=w[E++];if((a&128)>0||(o&128)>0){E-=6;return}if(e<7)return z(t,n,r,i,a,o);let s=w[E++];if((s&128)>0){E-=7;return}return z(t,n,r,i,a,o,s)}{let a=w[E++],o=w[E++],s=w[E++],c=w[E++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){E-=8;return}if(e<10){if(e===8)return z(t,n,r,i,a,o,s,c);{let e=w[E++];if((e&128)>0){E-=9;return}return z(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=w[E++],u=w[E++];if((l&128)>0||(u&128)>0){E-=10;return}if(e<11)return z(t,n,r,i,a,o,s,c,l,u);let d=w[E++];if((d&128)>0){E-=11;return}return z(t,n,r,i,a,o,s,c,l,u,d)}{let l=w[E++],u=w[E++],d=w[E++],f=w[E++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){E-=12;return}if(e<14){if(e===12)return z(t,n,r,i,a,o,s,c,l,u,d,f);{let e=w[E++];if((e&128)>0){E-=13;return}return z(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=w[E++],m=w[E++];if((p&128)>0||(m&128)>0){E-=14;return}if(e<15)return z(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=w[E++];if((h&128)>0){E-=15;return}return z(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function ke(e){return k.copyBuffers?Uint8Array.prototype.slice.call(w,E,E+=e):w.subarray(E,E+=e)}let Ae=new Float32Array(1),je=new Uint8Array(Ae.buffer,0,4);function Me(){let e=w[E++],t=w[E++],n=(e&127)>>2;if(n===31)return t||e&3?NaN:e&128?-1/0:1/0;if(n===0){let n=((e&3)<<8|t)/(1<<24);return e&128?-n:n}return je[3]=e&128|(n>>1)+56,je[2]=(e&7)<<5|t>>3,je[1]=t<<5,je[0]=0,Ae[0]}Array(4096);var B=class{constructor(e,t){this.value=e,this.tag=t}};P[0]=e=>new Date(e),P[1]=e=>new Date(Math.round(e*1e3)),P[2]=e=>{let t=BigInt(0);for(let n=0,r=e.byteLength;n<r;n++)t=BigInt(e[n])+(t<<BigInt(8));return t},P[3]=e=>BigInt(-1)-P[2](e),P[4]=e=>+(e[1]+`e`+e[0]),P[5]=e=>e[1]*Math.exp(e[0]*Math.log(2));const Ne=(e,t)=>{e-=57344;let n=A[e];n&&n.isShared&&((A.restoreStructures||(A.restoreStructures=[]))[e]=n),A[e]=t,t.read=Ce(t)};P[105]=e=>{let t=e.length,n=e[1];Ne(e[0],n);let r={};for(let i=2;i<t;i++){let t=n[i-2];r[R(t)]=e[i]}return r},P[14]=e=>M?M[0].slice(M.position0,M.position0+=e):new B(e,14),P[15]=e=>M?M[1].slice(M.position1,M.position1+=e):new B(e,15);let Pe={Error,RegExp};P[27]=e=>(Pe[e[0]]||Error)(e[1],e[2]);const Fe=e=>{if(w[E++]!=132){let e=Error(`Packed values structure must be followed by a 4 element array`);throw w.length<E&&(e.incomplete=!0),e}let t=e();if(!t||!t.length){let e=Error(`Packed values structure must be followed by a 4 element array`);throw e.incomplete=!0,e}return F=F?t.concat(F.slice(t.length)):t,F.prefixes=e(),F.suffixes=e(),e()};Fe.handlesRead=!0,P[51]=Fe,P[6]=e=>{if(!F){if(k.getShared)Ue();else return new B(e,6)}if(typeof e==`number`)return F[16+(e>=0?2*e:-2*e-1)];let t=Error(`No support for non-integer packed references yet`);throw e===void 0&&(t.incomplete=!0),t},P[28]=e=>{N||(N=new Map,N.id=0);let t=N.id++,n=E,r=w[E],i;i=r>>5==4?[]:{};let a={target:i};N.set(t,a);let o=e();return a.used?(Object.getPrototypeOf(i)!==Object.getPrototypeOf(o)&&(E=n,i=o,N.set(t,{target:i}),o=e()),Object.assign(i,o)):(a.target=o,o)},P[28].handlesRead=!0,P[29]=e=>{let t=N.get(e);return t.used=!0,t.target},P[258]=e=>new Set(e),(P[259]=e=>(k.mapsAsObjects&&(k.mapsAsObjects=!1,ge=!0),e())).handlesRead=!0;function Ie(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function V(){if(!F){if(k.getShared)Ue();else throw Error(`No packed values available`)}return F}he.push((e,t)=>{if(e>=225&&e<=255)return Ie(V().prefixes[e-224],t);if(e>=28704&&e<=32767)return Ie(V().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return Ie(V().prefixes[e-1879048192],t);if(e>=216&&e<=223)return Ie(t,V().suffixes[e-216]);if(e>=27647&&e<=28671)return Ie(t,V().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return Ie(t,V().suffixes[e-1811939328]);if(e==1399353956)return{packedValues:F,structures:A.slice(0),version:t};if(e==55799)return t});const Le=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,Re=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],ze=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<Re.length;e++)Be(Re[e],ze[e]);function Be(e,t){let n=`get`+e.name.slice(0,-5),r;typeof e==`function`?r=e.BYTES_PER_ELEMENT:e=null;for(let i=0;i<2;i++){if(!i&&r==1)continue;let a=r==2?1:r==4?2:r==8?3:0;P[i?t:t-4]=r==1||i==Le?n=>{if(!e)throw Error(`Could not find typed array for code `+t);return!k.copyBuffers&&(r===1||r===2&&!(n.byteOffset&1)||r===4&&!(n.byteOffset&3)||r===8&&!(n.byteOffset&7))?new e(n.buffer,n.byteOffset,n.byteLength>>a):new e(Uint8Array.prototype.slice.call(n,0).buffer)}:r=>{if(!e)throw Error(`Could not find typed array for code `+t);let o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=r.length>>a,c=new e(s),l=o[n];for(let e=0;e<s;e++)c[e]=l.call(o,e<<a,i);return c}}}function Ve(){let e=He(),t=E+L();for(let t=2;t<e;t++){let e=He();E+=e}let n=E;return E=t,M=[Ee(He()),Ee(He())],M.position0=0,M.position1=0,M.postBundlePosition=E,E=n,L()}function He(){let e=w[E++]&31;if(e>23)switch(e){case 24:e=w[E++];break;case 25:e=I.getUint16(E),E+=2;break;case 26:e=I.getUint32(E),E+=4}return e}function Ue(){if(k.getShared){let e=We(()=>(w=null,k.getShared()))||{},t=e.structures||[];k.sharedVersion=e.version,F=k.sharedValues=e.packedValues,A===!0?k.structures=A=t:A.splice.apply(A,[0,t.length].concat(t))}}function We(e){let t=T,n=E,r=fe,i=me,a=j,o=pe,s=O,c=N,l=M,u=new Uint8Array(w.slice(0,T)),d=A,f=k,p=ve,m=e();return T=t,E=n,fe=r,me=i,j=a,pe=o,O=s,N=c,M=l,w=u,ve=p,A=d,k=f,I=new DataView(w.buffer,w.byteOffset,w.byteLength),m}function Ge(){w=null,N=null,A=null}const Ke=Array(147);for(let e=0;e<256;e++)Ke[e]=+(`1e`+Math.floor(45.15-e*.30103));let qe=new be({useRecords:!1});const Je=qe.decode;qe.decodeMultiple;const Ye={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let Xe;try{Xe=new TextEncoder}catch{}let Ze,Qe;const $e=typeof globalThis==`object`&&globalThis.Buffer,et=$e!==void 0,tt=et?$e.allocUnsafeSlow:Uint8Array,nt=et?$e:Uint8Array,rt=et?4294967296:2144337920;let it,H,U,W=0,G,K=null;const at=/[\u0080-\uFFFF]/,q=Symbol(`record-id`);var ot=class extends be{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=nt.prototype.utf8Write?function(e,t,n){return H.utf8Write(e,t,n)}:Xe&&Xe.encodeInto?function(e,t){return Xe.encodeInto(e,H.subarray(t)).written}:!1,s=this,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?128:0,l>8190)throw Error(`Maximum maxSharedStructure is 8190`);let u=e.sequential;u&&(l=0),this.structures||=[],this.saveStructures&&(this.saveShared=this.saveStructures);let d,f,p=e.sharedValues,m;if(p){m=Object.create(null);for(let e=0,t=p.length;e<t;e++)m[p[e]]=e}let h=[],g=0,_=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e))}return this.encode(e,t)},this.encode=function(o,c){if(H||(H=new tt(8192),U=new DataView(H.buffer,0,8192),W=0),G=H.length-10,G-W<2048?(H=new tt(H.length),U=new DataView(H.buffer,0,H.length),G=H.length-10,W=0):c===512&&(W=W+7&2147483640),t=W,s.useSelfDescribedHeader&&(U.setUint32(W,3654940416),W+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(K=[],K.size=1/0):K=null,n=s.structures,n){if(n.uninitialized){let e=s.getShared()||{};s.structures=n=e.structures||[],s.sharedVersion=e.version;let t=s.sharedValues=e.packedValues;if(t){m={};for(let e=0,n=t.length;e<n;e++)m[t[e]]=e}}let e=n.length;if(e>l&&!u&&(e=l),!n.transitions){n.transitions=Object.create(null);for(let t=0;t<e;t++){let e=n[t];if(!e)continue;let r,i=n.transitions;for(let n=0,a=e.length;n<a;n++){i[q]===void 0&&(i[q]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[q]=t|1048576}}u||(n.nextId=e)}if(r&&=!1,i=n||[],f=m,e.pack){let t=new Map;if(t.values=[],t.encoder=s,t.maxValues=e.maxPrivatePackedValues||(m?16:1/0),t.objectMap=m||!1,t.samplingPackedValues=d,dt(o,t),t.values.length>0){H[W++]=216,H[W++]=51,J(4);let e=t.values;v(e),J(0),J(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}it=c&St;try{if(it)return;if(v(o),K&&ht(t,v),s.offset=W,a&&a.idsToInsert){W+=a.idsToInsert.length*2,W>G&&b(W),s.offset=W;let e=mt(H.subarray(t,W),a.idsToInsert);return a=null,e}return c&512?(H.start=t,H.end=W,H):H.subarray(t,W)}finally{if(n){if(_<10&&_++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,_=0,g=0,h.length>0&&(h=[]);else if(h.length>0&&!u){for(let e=0,t=h.length;e<t;e++)h[e][q]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=H.subarray(t,W);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(W=t)}},this.findCommonStringsToPack=()=>(d=new Map,m||=Object.create(null),e=>{let t=e&&e.threshold||4,n=this.pack?e.maxPrivatePackedValues||16:0;p||=this.sharedValues=[];for(let[e,i]of d)i.count>t&&(m[e]=n++,p.push(e),r=!0);for(;this.saveShared&&this.updateSharedData()===!1;);d=null});let v=n=>{W>G&&(H=b(W));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?H[W++]=t+224:(H[W++]=198,t&1?v(15-t>>1):v(t-16>>1));return}if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(K&&r>=4&&r<1024){if((K.size+=r)>61440){let e,n=(K[0]?K[0].length*3+K[1].length:0)+10;W+n>G&&(H=b(W+n)),H[W++]=217,H[W++]=223,H[W++]=249,H[W++]=K.position?132:130,H[W++]=26,e=W-t,W+=4,K.position&&ht(t,v),K=[``,``],K.size=0,K.position=e}let e=at.test(n);K[+!e]+=n,H[W++]=e?206:207,v(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(W+s>G&&(H=b(W+s)),r<64||!o){let e,t,o,s=W+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?H[s++]=t:t<2048?(H[s++]=t>>6|192,H[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,H[s++]=t>>18|240,H[s++]=t>>12&63|128,H[s++]=t>>6&63|128,H[s++]=t&63|128):(H[s++]=t>>12|224,H[s++]=t>>6&63|128,H[s++]=t&63|128);i=s-W-a}else i=o(n,W+a,s);i<24?H[W++]=96|i:i<256?(a<2&&H.copyWithin(W+2,W+1,W+1+i),H[W++]=120,H[W++]=i):i<65536?(a<3&&H.copyWithin(W+3,W+2,W+2+i),H[W++]=121,H[W++]=i>>8,H[W++]=i&255):(a<5&&H.copyWithin(W+5,W+3,W+3+i),H[W++]=122,U.setUint32(W,i),W+=4),W+=i}else if(r===`number`){if(!this.alwaysUseFloat&&n>>>0===n)n<24?H[W++]=n:n<256?(H[W++]=24,H[W++]=n):n<65536?(H[W++]=25,H[W++]=n>>8,H[W++]=n&255):(H[W++]=26,U.setUint32(W,n),W+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?H[W++]=31-n:n>=-256?(H[W++]=56,H[W++]=~n):n>=-65536?(H[W++]=57,U.setUint16(W,~n),W+=2):(H[W++]=58,U.setUint32(W,~n),W+=4);else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){H[W++]=250,U.setFloat32(W,n);let t;if(e<4||(t=n*Ke[(H[W]&127)<<1|H[W+1]>>7])>>0===t){W+=4;return}W--}H[W++]=251,U.setFloat64(W,n),W+=8}}else if(r===`object`){if(!n)H[W++]=246;else{if(a){let e=a.get(n);if(e){if(H[W++]=216,H[W++]=29,H[W++]=25,!e.references){let t=a.idsToInsert||(a.idsToInsert=[]);e.references=[],t.push(e)}e.references.push(W-t),W+=2;return}a.set(n,{offset:W-t})}let e=n.constructor;if(e===Object)y(n);else if(e===Array){i=n.length,i<24?H[W++]=128|i:J(i);for(let e=0;e<i;e++)v(n[e])}else if(e===Map){if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(H[W++]=217,H[W++]=1,H[W++]=3),i=n.size,i<24?H[W++]=160|i:i<256?(H[W++]=184,H[W++]=i):i<65536?(H[W++]=185,H[W++]=i>>8,H[W++]=i&255):(H[W++]=186,U.setUint32(W,i),W+=4),s.keyMap)for(let[e,t]of n)v(s.encodeKey(e)),v(t);else for(let[e,t]of n)v(e),v(t)}else{for(let e=0,t=Ze.length;e<t;e++){let t=Qe[e];if(n instanceof t){let t=Ze[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?H[W++]=192|r:r<256?(H[W++]=216,H[W++]=r):r<65536?(H[W++]=217,H[W++]=r>>8,H[W++]=r&255):r>-1&&(H[W++]=218,U.setUint32(W,r),W+=4),t.encode.call(this,n,v,b);return}}if(n[Symbol.iterator]){if(it){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}H[W++]=159;for(let e of n)v(e);H[W++]=255;return}if(n[Symbol.asyncIterator]||ut(n)){let e=Error(`Iterable/blob should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}if(this.useToJSON&&n.toJSON){let e=n.toJSON();if(e!==n)return v(e)}y(n)}}}else if(r===`boolean`)H[W++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)H[W++]=27,U.setBigUint64(W,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)H[W++]=59,U.setBigUint64(W,-n-BigInt(1));else if(this.largeBigIntToFloat)H[W++]=251,U.setFloat64(W,Number(n));else{n>=BigInt(0)?H[W++]=194:(H[W++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);pt(new Uint8Array(e.reverse()),b);return}W+=8}else if(r===`undefined`)H[W++]=247;else throw Error(`Unknown type: `+r)},y=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?H[W++]=160|r:r<256?(H[W++]=184,H[W++]=r):r<65536?(H[W++]=185,H[W++]=r>>8,H[W++]=r&255):(H[W++]=186,U.setUint32(W,r),W+=4),s.keyMap)for(let e=0;e<r;e++)v(s.encodeKey(t[e])),v(n[e]);else for(let e=0;e<r;e++)v(t[e]),v(n[e])}:e=>{H[W++]=185;let n=W-t;W+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(s.encodeKey(t)),v(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(t),v(e[t]),r++);H[n+++t]=r>>8,H[n+t]=r&255}:(e,t)=>{let n,a=i.transitions||(i.transitions=Object.create(null)),o=0,s=0,c,u;if(this.keyMap){u=Object.keys(e).map(e=>this.encodeKey(e)),s=u.length;for(let e=0;e<s;e++){let t=u[e];n=a[t],n||(n=a[t]=Object.create(null),o++),a=n}}else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(n=a[t],n||(a[q]&1048576&&(c=a[q]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[q];if(d!==void 0)d&=65535,H[W++]=217,H[W++]=d>>8|224,H[W++]=d&255;else if(u||=a.__keys__||(a.__keys__=Object.keys(e)),c===void 0?(d=i.nextId++,d||(d=0,i.nextId=1),d>=256&&(i.nextId=(d=l)+1)):d=c,i[d]=u,d<l){H[W++]=217,H[W++]=d>>8|224,H[W++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[q]===void 0||a[q]&1048576)&&(a[q]=d),a=a[u[e]];a[q]=d|1048576,r=!0}else{if(a[q]=d,U.setUint32(W,3655335680),W+=3,o&&(g+=_*o),h.length>=256-l&&(h.shift()[q]=void 0),h.push(a),J(s+2),v(57344+d),v(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t]);return}if(s<24?H[W++]=128|s:J(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t])},b=e=>{let n;if(e>16777216){if(e-t>rt)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(rt,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,H.length-1)>>12)+1<<12;let r=new tt(n);return U=new DataView(r.buffer,0,n),H.copy?H.copy(r,0,t,e):r.set(H.slice(t,e)),W-=t,t=0,G=r.length-10,H=r},x=100,S=1e3;this.encodeAsIterable=function(e,t){return ne(e,t,C)},this.encodeAsAsyncIterable=function(e,t){return ne(e,t,re)};function*C(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?y(e,!0):st(Object.keys(e).length,160);for(let r in e){let i=e[r];t||v(r),i&&typeof i==`object`?n[r]?yield*C(i,n[r]):yield*ee(i,n,r):v(i)}}else if(i===Array){let r=e.length;J(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||W-t>x)?n.element?yield*C(r,n.element):yield*ee(r,n,`element`):v(r)}}else if(e[Symbol.iterator]&&!e.buffer){H[W++]=159;for(let r of e)r&&(typeof r==`object`||W-t>x)?n.element?yield*C(r,n.element):yield*ee(r,n,`element`):v(r);H[W++]=255}else ut(e)?(st(e.size,64),yield H.subarray(t,W),yield e,te()):e[Symbol.asyncIterator]?(H[W++]=159,yield H.subarray(t,W),yield e,te(),H[W++]=255):v(e);r&&W>t?yield H.subarray(t,W):W-t>x&&(yield H.subarray(t,W),te())}function*ee(e,n,r){let i=W-t;try{v(e),W-t>x&&(yield H.subarray(t,W),te())}catch(a){if(a.iteratorNotHandled)n[r]={},W=t+i,yield*C.call(this,e,n[r]);else throw a}}function te(){x=S,s.encode(null,St)}function ne(e,t,n){return x=t&&t.chunkThreshold?S=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,St),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*re(e,t){for(let n of C(e,t,!0)){let e=n.constructor;if(e===nt||e===Uint8Array)yield n;else if(ut(n)){let e=n.stream().getReader(),t;for(;!(t=await e.read()).done;)yield t.value}else if(n[Symbol.asyncIterator])for await(let e of n)te(),e?yield*re(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){H=e,U=new DataView(H.buffer,H.byteOffset,H.byteLength),W=0}clearSharedData(){this.structures&&=[],this.sharedValues&&=void 0}updateSharedData(){let e=this.sharedVersion||0;this.sharedVersion=e+1;let t=this.structures.slice(0),n=new ct(t,this.sharedValues,this.sharedVersion),r=this.saveShared(n,t=>(t&&t.version||0)==e);return r===!1?(n=this.getShared()||{},this.structures=n.structures||[],this.sharedValues=n.packedValues,this.sharedVersion=n.version,this.structures.nextId=this.structures.length):t.forEach((e,t)=>this.structures[t]=e),r}};function st(e,t){e<24?H[W++]=t|e:e<256?(H[W++]=t|24,H[W++]=e):e<65536?(H[W++]=t|25,H[W++]=e>>8,H[W++]=e&255):(H[W++]=t|26,U.setUint32(W,e),W+=4)}var ct=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function J(e){e<24?H[W++]=128|e:e<256?(H[W++]=152,H[W++]=e):e<65536?(H[W++]=153,H[W++]=e>>8,H[W++]=e&255):(H[W++]=154,U.setUint32(W,e),W+=4)}const lt=typeof Blob>`u`?function(){}:Blob;function ut(e){if(e instanceof lt)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function dt(e,t){switch(typeof e){case`string`:if(e.length>3){if(t.objectMap[e]>-1||t.values.length>=t.maxValues)return;let n=t.get(e);if(n)++n.count==2&&t.values.push(e);else if(t.set(e,{count:1}),t.samplingPackedValues){let n=t.samplingPackedValues.get(e);n?n.count++:t.samplingPackedValues.set(e,{count:1})}}break;case`object`:if(e){if(e instanceof Array)for(let n=0,r=e.length;n<r;n++)dt(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&dt(n,t),dt(e[n],t))}}break;case`function`:console.log(e)}}const ft=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;Qe=[Date,Set,Error,RegExp,B,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,ct],Ze=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(H[W++]=26,U.setUint32(W,n),W+=4):(H[W++]=251,U.setFloat64(W,n),W+=8)}},{tag:258,encode(e,t){t(Array.from(e))}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t([`RegExp`,e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,n){pt(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||et&&this.tagUint8Array!==!1))return 64},encode(e,t,n){pt(e,n)}},Y(68,1),Y(69,2),Y(70,4),Y(71,8),Y(72,1),Y(77,2),Y(78,4),Y(79,8),Y(85,4),Y(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){H[W++]=216,H[W++]=51,J(4);let e=n.values;t(e),J(0),J(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){U.setUint32(W,3655335424),W+=3;let n=r.slice(0);n.unshift(57344),n.push(new B(e.version,1399353956)),t(n)}else t(new B(e.version,1399353956))}}];function Y(e,t){return!ft&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(et?$e.from(i,r,n):new Uint8Array(i,r,n))}}}function pt(e,t){let n=e.byteLength;n<24?H[W++]=64+n:n<256?(H[W++]=88,H[W++]=n):n<65536?(H[W++]=89,H[W++]=n>>8,H[W++]=n&255):(H[W++]=90,U.setUint32(W,n),W+=4),W+n>=H.length&&t(W+n),H.set(e.buffer?e:new Uint8Array(e),W),W+=n}function mt(e,t){let n,r=t.length*2,i=e.length-r;t.sort((e,t)=>e.offset>t.offset?1:-1);for(let n=0;n<t.length;n++){let r=t[n];r.id=n;for(let t of r.references)e[t++]=n>>8,e[t]=n&255}for(;n=t.pop();){let t=n.offset;e.copyWithin(t+r,t,i),r-=2;let a=t+r;e[a++]=216,e[a++]=28,i=t}return e}function ht(e,t){U.setUint32(K.position+e,W-K.position-e+1);let n=K;K=null,t(n[0]),t(n[1])}let gt=new ot({useRecords:!1});const _t=gt.encode;gt.encodeAsIterable,gt.encodeAsAsyncIterable;const{NEVER:vt,ALWAYS:yt,DECIMAL_ROUND:bt,DECIMAL_FIT:xt}=Ye,St=2048;if(process.env.CBOR_NATIVE_ACCELERATION_DISABLED===void 0||process.env.CBOR_NATIVE_ACCELERATION_DISABLED.toLowerCase()!==`true`){let e;try{e=typeof t==`function`?t(`cbor-extract`):ee(import.meta.url)(`cbor-extract`),e&&Te(e.extractStrings)}catch{}}var X=y();const Ct=`5.0.0-beta.46`,Z=l(`@workflow/world-vercel//httpPools`,1,()=>({dispatcher:void 0,queueDispatcher:void 0,streamDispatcher:void 0,streamCloseDispatcher:void 0,nodeHttpAgents:void 0})),wt={connections:8,keepAliveTimeout:1e4},Tt=3e5,Et=3e5,Dt={...wt,allowH2:!1,pipelining:1},Ot=()=>o(`WORKFLOW_VERCEL_QUEUE_TIMEOUT_MS`,3e4,{integer:!0,min:5e3,max:12e4});function kt(){let e=Ot();return{...Dt,connections:o(`WORKFLOW_VERCEL_QUEUE_CONNECTIONS`,64,{integer:!0,min:1,max:1024}),headersTimeout:e,bodyTimeout:e}}const At=X.DecoratorHandler;function jt(e){class t extends At{#e=!1;#t;#n;constructor(t){super(t),this.#n=setTimeout(()=>{this.#e=!0,this.#r()},e),this.#n.unref?.()}#r(){this.#t?.abort(Error(`Queue request exceeded its ${e}ms deadline`))}onRequestStart(e,t){this.#t=e,super.onRequestStart(e,t),this.#e&&this.#r()}onResponseEnd(e,t){clearTimeout(this.#n),super.onResponseEnd(e,t)}onResponseError(e,t){clearTimeout(this.#n),super.onResponseError(e,t)}}return e=>(n,r)=>e(n,new t(r))}const Mt={...wt,allowH2:!0,pipelining:100,initialWindowSize:4194304,connectionWindowSize:16777216},Nt={...wt,allowH2:!1,pipelining:1},Pt={...wt,allowH2:!0,pipelining:1},Ft={retryAfter:!0,statusCodes:[500,502,503,504]},It={retryAfter:!0,methods:[`PUT`],statusCodes:[429]},Lt={retryAfter:!0,methods:[`PUT`],statusCodes:[429,500,502,503,504]};function Rt(){return process.env.WORKFLOW_H2_MULTIPLEX!==`0`}function zt(e){if(!e||typeof e!=`object`||Array.isArray(e))return NaN;let t=e,n=t[`content-length`]??t[`Content-Length`];return typeof n==`string`||typeof n==`number`?Number(n):NaN}function Bt(e){return(t,n)=>{let r=t.body,i=!!r&&typeof r!=`string`&&!Buffer.isBuffer(r)&&typeof r[Symbol.asyncIterator]==`function`,a=zt(t.headers);return!i||!(a>=0)||a>1048576?e({...t,idempotent:!0},n):((async()=>{try{let i=[];for await(let e of r)i.push(Buffer.from(e));e({...t,body:Buffer.concat(i),idempotent:!0},n)}catch(e){n.onError?.(e)}})(),!0)}}const Vt=new Set([`UND_ERR_INFO`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`]);function Ht(e){let t=e;for(let e=0;t&&e<8;e++){let e=t.code;if(typeof e==`string`&&Vt.has(e))return!0;t=t.cause}return!1}function Ut(e,t){let n,r=0,i=0;function a(e){let t=setTimeout(()=>{Promise.resolve(e.close?.()).catch(()=>void 0)},5e3),n=setTimeout(()=>{Promise.resolve(e.destroy?.()).catch(()=>void 0)},6e4);t.unref?.(),n.unref?.()}return{get(){return n??=e(),n},note(e,o){if(!n||e!==n)return;if(o===void 0){r=0;return}if(!Ht(o)||(r++,r<3))return;let s=Date.now();if(s-i<5e3)return;i=s,r=0;let c=n;n=void 0,console.warn(`[workflow] ${t}: rebuilding connection pool after 3 consecutive transport failures`),a(c)}}}const Wt=l(`@workflow/world-vercel//eventsDispatcherRecycler@${Ct}`,1,()=>Ut(()=>en(),`events transport`));function Gt(e,t){Wt.note(e,t)}function Kt(e,t){return e?.dispatcher?e.dispatcher:s()?void 0:t()}function qt(e){if(!e?.dispatcher&&s())return Z.nodeHttpAgents??=b({maxSockets:wt.connections,keepAliveMs:wt.keepAliveTimeout}),Z.nodeHttpAgents}function Jt(e){return Kt(e,on)}function Yt(e){return Kt(e,an)}function Xt(e){return Kt(e,()=>Wt.get())}function Zt(e){return Kt(e,sn)}function Qt(e){return Kt(e,cn)}function $t(e,t){return new X.RetryAgent(new X.Agent(e),t)}function en(e){let t=Rt(),n=new X.RetryAgent(new X.Agent({...t?Mt:Nt,...e}),Ft);return t?tn(n,n.compose(Bt)):n}function tn(e,t){return new Proxy(t,{get:(t,n)=>n===`close`||n===`destroy`?e[n].bind(e):t[n]})}function nn(e,t){return new X.RetryAgent(new X.Agent({...Pt,...t}),e)}function rn(){return new X.RetryAgent(new X.Agent(kt()).compose(jt(Ot())),Ft)}function an(){return Z.queueDispatcher??=rn(),Z.queueDispatcher}function on(){return Z.dispatcher??=$t(Dt,Ft),Z.dispatcher}function sn(){return Z.streamDispatcher??=nn(It),Z.streamDispatcher}function cn(){return Z.streamCloseDispatcher??=nn(Lt),Z.streamCloseDispatcher}const ln=l(`@workflow/world-vercel//telemetry`,1,()=>({apiPromise:null,tracerPromise:null}));async function un(){return ln.apiPromise||=import(`../../@opentelemetry/api/index.js`).catch(e=>(typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)&&console.warn(`[workflow] @opentelemetry/api unavailable — world-vercel spans disabled:`,e instanceof Error?e.message:e),null)),ln.apiPromise}function dn(){return typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)}let fn=!1;function pn(e,t){if(!fn&&dn()){fn=!0;try{let n=globalThis[Symbol.for(`opentelemetry.js.api.1`)],r=e.trace.getTracerProvider(),i=r.getDelegate?.()??r,a=t.startSpan(`workflow.otel.probe.world_vercel`);console.warn(`[workflow:otel-diag] world-vercel`,JSON.stringify({globalRegistrationVersion:n?.version??null,providerCtor:r?.constructor?.name??null,delegateCtor:i?.constructor?.name??null,tracerCtor:t?.constructor?.name??null,probeCtor:a?.constructor?.name??null,probeRecording:a.isRecording()})),a.end()}catch(e){console.warn(`[workflow:otel-diag] world-vercel failed:`,e instanceof Error?e.message:e)}}}async function mn(){return ln.tracerPromise||=un().then(e=>{if(!e)return null;let t=e.trace.getTracer(`workflow`);return pn(e,t),t}),ln.tracerPromise}async function hn(e,...t){let[n,r]=await Promise.all([mn(),un()]),{fn:i,opts:a}=typeof t[0]==`function`?{fn:t[0],opts:{}}:{fn:t[1],opts:t[0]};if(!i)throw Error(`Function to trace must be provided`);return!n||!r?await i():n.startActiveSpan(e,a,async e=>{try{let t=await i(e);return e.setStatus({code:r.SpanStatusCode.OK}),t}catch(t){throw e.setStatus({code:r.SpanStatusCode.ERROR,message:t.message}),t}finally{e.end()}})}async function gn(e){let t=await un();if(t)return t.SpanKind[e]}async function _n(e){for(let[t,n]of Object.entries(await vn()))e.set(t,n)}async function vn(){let e=await un();if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}function Q(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const yn=Q(`http.request.method`),bn=Q(`url.full`),xn=Q(`server.address`),Sn=Q(`server.port`),Cn=Q(`http.response.status_code`),$=Q(`error.type`),wn=Q(`network.protocol.name`),Tn=Q(`workflow.world.parse.format`),En=Q(`peer.service`),Dn=Q(`rpc.system`),On=Q(`rpc.service`),kn=Q(`rpc.method`),An=Q(`workflow.run.id`),jn=Q(`step.id`),Mn=Q(`workflow.stream.name`),Nn=Q(`workflow.stream.operation`),Pn=Q(`workflow.stream.start_index`),Fn=Q(`workflow.events.transport`),In=Q(`workflow.http.transport`),Ln=Q(`workflow.event.type`),Rn=Q(`workflow.step_start.mode`),zn=Q(`workflow.step_start.owner_stamped`),Bn=Q(`workflow.client.version`),Vn=Q(`step.stso_ms`),Hn=Q(`step.latency_optimizations`),Un=Q(`workflow.events.ws.url`),Wn=Q(`workflow.events.ws.req_id`),Gn=Q(`workflow.events.ws.reconnect_attempt`),Kn=new Set([`UND_ERR_INFO`,`UND_ERR_REQ_RETRY`,`UND_ERR_SOCKET`,`UND_ERR_CONNECT`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CLOSED`,`ECONNRESET`,`ECONNREFUSED`,`ENOTFOUND`,`EAI_AGAIN`,`EPIPE`,`ETIMEDOUT`]);function qn(e){let t=e;for(let e=0;t&&e<8;e++){let e=t.code;if(typeof e==`string`&&Kn.has(e))return e;t=t.cause}}const Jn=()=>o(`WORKFLOW_REQUEST_TIMEOUT_MS`,6e4,{integer:!0,min:1e4,max:12e4}),Yn=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`),Xn=[`x-vercel-id`,`x-vercel-error`,`x-vercel-mitigated`];function Zn(e){return Xn.flatMap(t=>{let n=e.get(t);return n?[`${t}=${n}`]:[]})}function Qn(e){let t=Zn(e);return t.length>0?` (${t.join(`; `)})`:``}function $n(e,t,n,r){if(!Yn)return;let i=Zn(n.headers),a=i.length>0?`; ${i.join(`; `)}`:``;console.debug(`[workflow:world-vercel:http] ${e} ${t} -> ${n.status} (${r}ms${a})`)}function er(e,t,n){if(!process.env.DEBUG)return;let r=Array.from(n.entries()).filter(([e])=>e.toLowerCase()!==`authorization`).map(([e,t])=>`-H "${e}: ${t}"`).join(` `);console.error(`Failed to fetch, reproduce with:\ncurl -X ${e} ${r} "${t}"`)}function tr(e){if(!e)return;let t=parseInt(e,10);return Number.isNaN(t)?void 0:t}function nr(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function rr(e,t,n={}){let{retryAfter:r,code:i,url:a,mitigated:o,details:s}=n;if(e===409)return new h(t);if(e===410){if(i===`stream-expired`){let e=s&&typeof s==`object`?s:void 0,n=typeof e?.expiredAt==`string`?new Date(e.expiredAt):void 0;return new d(t,typeof e?.runId==`string`?e.runId:void 0,typeof e?.streamId==`string`?e.streamId:void 0,n&&!Number.isNaN(n.getTime())?n:void 0)}return new p(t)}return e===412?new f(t,{retryAfter:r,details:s}):e===425?new _(t,{retryAfter:r}):e===429?ir(e,o)?new u(`${t} (x-vercel-mitigated=challenge)`,{url:a,status:e,code:`TRANSPORT`,retryAfter:r}):new g(t,{retryAfter:r}):new u(t,{url:a,status:e,code:i,retryAfter:r})}function ir(e,t){return e===429&&t===`challenge`}async function ar(e){return e?.token??process.env.VERCEL_TOKEN??await(0,oe.getVercelOidcToken)().catch(()=>null)}function or(e){try{let t=new URL(e),n=t.protocol===`https:`||t.protocol===`wss:`;return{serverAddress:t.hostname,serverPort:t.port?parseInt(t.port,10):n?443:80}}catch{return{}}}function sr(e){let{method:t,url:n,peerService:r}=e,{serverAddress:i,serverPort:a}=or(n);return{...yn(t),...bn(n),...i?xn(i):{},...a?Sn(a):{},...En(r),...Dn(`http`),...On(r)}}async function cr(e,t){let{method:n,url:r,peerService:i=`workflow-server`,spanName:a,attributes:o}=e;return hn(a??`http ${n}`,{kind:await gn(`CLIENT`)},async e=>{if(a&&Yn&&e){let t=e.spanContext();console.warn(`[workflow:otel-diag] span-open`,JSON.stringify({spanName:a,traceId:t.traceId,spanId:t.spanId,recording:e.isRecording()}))}return e?.setAttributes(sr({method:n,url:r,peerService:i})),o&&e?.setAttributes(o),t(e)})}function lr(e,t){e?.setAttributes({...Cn(t)}),(t<200||t>=300)&&e?.setAttributes({...$(`HTTP ${t}`)})}async function ur(e){let{method:t,url:n,headers:r,body:i,dispatcher:a,peerService:o,timeoutMs:s=Jn(),signal:c,injectTraceContext:l=!0,cacheBust:d=!0,logLabel:f,buildError:p,spanName:h,attributes:g,durationAttribute:_,onTransportOutcome:y,deferTransportSuccessUntilBody:b=!1,onRequestDispatched:x,transportErrorCode:S=`TRANSPORT`}=e,C=f??n;return cr({method:t,url:n,peerService:o,spanName:h,attributes:g},async e=>{l&&await _n(r),d&&r.set(`X-Request-Time`,Date.now().toString());let o=s==null?void 0:AbortSignal.timeout(s),f=c&&o?AbortSignal.any([c,o]):c??o,h=Date.now(),g;try{let o=a?void 0:qt();e?.setAttributes({...In(o?`node-http`:`undici`)});let s=o?v(n,{method:t,headers:r,body:i,signal:f,agents:o,headersTimeoutMs:Tt,bodyTimeoutMs:Et}):fetch(n,{method:t,headers:r,body:i,signal:f,dispatcher:a});x?.(),g=await s}catch(r){let i=Date.now()-h;if(y?.(r),r instanceof Error&&(r.name===`TimeoutError`||r.name===`AbortError`)){let a=`${t} ${C} timed out after ${i}ms`,o=S===`STREAM_ERROR`?`STREAM_ERROR`:`TIMEOUT`,s=o===`STREAM_ERROR`?new m(a,{url:n,cause:r}):new u(a,{url:n,code:o,cause:r});throw e?.setAttributes({...$(o)}),e?.recordException?.(s),s}let a=qn(r);if(a){let o=`${t} ${C} transport failure after ${i}ms (${a})`,s=S===`STREAM_ERROR`?`STREAM_ERROR`:`TRANSPORT`,c=s===`STREAM_ERROR`?new m(o,{url:n,cause:r}):new u(o,{url:n,code:s,cause:r});throw e?.setAttributes({...$(s)}),e?.recordException?.(c),c}throw r}let ee=Date.now()-h;if(g.ok&&!b&&y?.(void 0,g),$n(t,C,g,ee),lr(e,g.status),_&&e?.setAttributes({[_]:ee}),!g.ok){if(er(t,n,r),p){let r;try{r=await p(g)}catch(r){let i=qn(r);if(i){y?.(r,g);let a=`${t} ${C} response body transport failure (${i})`,o=S===`STREAM_ERROR`?new m(a,{url:n,cause:r}):new u(a,{url:n,code:`TRANSPORT`,cause:r});throw e?.setAttributes({...$(S)}),e?.recordException?.(o),o}throw y?.(void 0,g),r}throw y?.(void 0,g),e?.recordException?.(r),r}let i=``;try{i=await g.text(),y?.(void 0,g)}catch(e){y?.(e,g)}let a=rr(g.status,`${t} ${C} -> HTTP ${g.status}: ${g.statusText}${i?` ${i}`:``}${Qn(g.headers)}`,{url:n,retryAfter:tr(g.headers.get(`Retry-After`))});throw e?.recordException?.(a),a}return g})}const dr=new Set([`GET`,`HEAD`]),fr=()=>process.env.VERCEL_WORKFLOW_SERVER_URL||``,pr=()=>process.env.WORKFLOW_TEST_LIMIT_OVERRIDES?.trim()||``;function mr(e){return e}const hr=(...e)=>e.filter(Boolean).join(` `),gr=()=>{let e=process.env.VERCEL_DEPLOYMENT_ID;return e?`@workflow/world-vercel/${Ct} node-${process.version} ${ne.platform()} (${ne.arch()}) ${e}`:`@workflow/world-vercel/${Ct} node-${process.version} ${ne.platform()} (${ne.arch()})`},_r=e=>{let t=e?.projectConfig,n=fr()||`https://vercel-workflow.com`,r=process.env.WORKFLOW_VERCEL_BACKEND_URL,i=!!(t?.projectId&&t?.teamId);return{baseUrl:i?r||`https://api.vercel.com/v1/workflow`:`${n}/api`,usingProxy:i}},vr=e=>{let t=e?.projectConfig;return t?t.environment||`production`:process.env.VERCEL_TARGET_ENV||process.env.VERCEL_ENV||void 0},yr=(e,t)=>{let n=e?.projectConfig,r=new Headers(e?.headers);r.set(`User-Agent`,hr(gr(),r.get(`User-Agent`)));let i=pr();i&&r.set(`x-workflow-test-limit-overrides`,i),n&&(r.set(`x-vercel-environment`,vr(e)),n.projectId&&r.set(`x-vercel-project-id`,n.projectId),n.teamId&&r.set(`x-vercel-team-id`,n.teamId));let a=fr();return a&&t.usingProxy&&r.set(`x-vercel-workflow-api-url`,a),r};async function br(e){let{baseUrl:t,usingProxy:n}=_r(e),r=yr(e,{usingProxy:n});if(n){if(!e?.token)throw Error(`world-vercel: api-workflow proxy requested (${t}) but no Vercel auth token was provided. Pass one as \`config.token\` (the SDK reads it from \`WORKFLOW_VERCEL_AUTH_TOKEN\`).`);r.set(`Authorization`,`Bearer ${e.token}`)}else{let t;try{t=await(0,oe.getVercelOidcToken)()}catch{}let n=e?.token??t;n&&r.set(`Authorization`,`Bearer ${n}`),t&&r.set(`x-vercel-trusted-oidc-idp-token`,t)}return{baseUrl:t,headers:r,usingProxy:n}}async function xr({endpoint:e,options:t={},config:n={},schema:r,data:i,onResponse:a,retryConnectTimeout:o=!1}){let s=(t.method||`GET`).toUpperCase(),{baseUrl:c,headers:l}=await br(n),d=`${c}${e}`;return hn(`http ${s}`,{kind:await gn(`CLIENT`)},async c=>{c?.setAttributes(sr({method:s,url:d,peerService:`workflow-server`})),l.set(`Accept`,`application/cbor`),await _n(l);let f;i!==void 0&&(l.set(`Content-Type`,`application/cbor`),f=_t(i));let p=dr.has(s),m,h=``;for(let r=0;;r++){l.set(`X-Request-Time`,Date.now().toString());let i=AbortSignal.timeout(Jn()),g=t.signal?AbortSignal.any([t.signal,i]):i,_=Date.now(),y;try{let e=qt(n);c?.setAttributes({...In(e?`node-http`:`undici`)}),y=e?await v(d,{method:s,headers:l,body:f,signal:g,agents:e,headersTimeoutMs:Tt,bodyTimeoutMs:Et}):await fetch(new Request(d,{...t,body:f,headers:l,signal:g}),{dispatcher:Jt(n)})}catch(t){let n=Date.now()-_;if(t instanceof Error&&(t.name===`TimeoutError`||t.name===`AbortError`)){let r=new u(`${s} ${e} timed out after ${n}ms`,{url:d,code:`TIMEOUT`,cause:t});throw c?.setAttributes({...$(`TIMEOUT`)}),c?.recordException?.(r),r}let i=qn(t);if(i){if(o&&p&&i===`UND_ERR_CONNECT_TIMEOUT`&&r===0){await new Promise(e=>setTimeout(e,100));continue}let a=new u(`${s} ${e} transport failure after ${n}ms (${i})`,{url:d,code:`TRANSPORT`,cause:t});throw c?.setAttributes({...$(`TRANSPORT`)}),c?.recordException?.(a),a}throw t}let b=Date.now()-_;if(h=Qn(y.headers),$n(s,e,y,b),c?.setAttributes({...Cn(y.status)}),!y.ok){let t=await Cr(y).then(e=>e.data).catch(()=>({})),n=t.code??t.error;er(s,d,l);let r=tr(y.headers.get(`Retry-After`)),i=(t.message||`${s} ${e} -> HTTP ${y.status}: ${y.statusText}`)+h,a=rr(y.status,i,{url:d,code:n,retryAfter:r,mitigated:y.headers.get(`x-vercel-mitigated`),details:t.details});throw c?.setAttributes({...$(n||`HTTP ${y.status}`)}),c?.recordException?.(a),a}a?.(y);try{m=await hn(`world.parse`,async e=>{let t=await Cr(y),n=(y.headers.get(`Content-Type`)||``).includes(`application/cbor`);return e?.setAttributes({...Tn(n?`cbor`:`json`)}),t});break}catch(t){if(p&&r<2){let n=100*2**r;c?.setAttributes({...$(`PARSE_ERROR_RETRYING`)}),Yn&&console.debug(`[workflow:world-vercel:http] ${s} ${e} body parse failed (attempt ${r+1}/3); retrying in ${n}ms: ${t}`),await new Promise(e=>setTimeout(e,n));continue}let n=y.headers.get(`Content-Type`)||`unknown`;throw new u(`Failed to parse response body for ${s} ${e}${h} (Content-Type: ${n}):\n\n${t}`,{url:d,code:`PARSE_ERROR`,cause:t})}}return await hn(`world.validate`,async()=>{let t=r.safeParse(m.data);if(!t.success){let n=t.error.issues.map(e=>` ${e.path.length>0?e.path.join(`.`):`<root>`}: ${e.message}`).join(`
|
|
3
|
-
`),r=process.env.DEBUG?`\n\nResponse context: ${m.getDebugContext()}`:``;throw new u(`Schema validation failed for ${s} ${e}${h}:\n${n}${r}`,{url:d,code:`SCHEMA_VALIDATION`,cause:t.error})}return t.data})})}function Sr(e){let t=te(e,{depth:3,maxArrayLength:10,breakLength:120});return t.length>500?`${t.slice(0,500)}...`:t}async function Cr(e){let t=e.headers.get(`Content-Type`)||``;if(t.includes(`application/cbor`)){let n=await e.arrayBuffer(),r=Je(new Uint8Array(n));return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.byteLength} bytes (CBOR), preview: ${Sr(r)}`}}let n=await e.text(),r=JSON.parse(n);return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.length} bytes, preview: ${Sr(r)}`}}function wr(){return process.env.WORKFLOW_EVENTS_TRANSPORT?.trim().toLowerCase()!==`http`}function Tr(){let e=process.env.WORKFLOW_INTERNAL_EVENTS_TRANSPORT_STRICT;return e===`1`||e===`true`}function Er(){return process.env.WORKFLOW_STREAMS_TRANSPORT===`ws`}const Dr=`application/vnd.workflow.v4-frames`;var Or=class extends Error{};const kr=c(i(a(),r()));function Ar(e,t){let n=new Uint8Array(_t(e)),r=new Uint8Array(4+n.byteLength+4+t.byteLength),i=new DataView(r.buffer);return i.setUint32(0,n.byteLength,!1),r.set(n,4),i.setUint32(4+n.byteLength,t.byteLength,!1),r.set(t,4+n.byteLength+4),r}async function*jr(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():Nr(e.getReader()),n=new Uint8Array,r=async e=>{if(n.byteLength>=e)return!0;let r=[n],i=n.byteLength;for(;i<e;){let e;try{e=await t.next()}catch(e){throw new Or(`decodeFrames: source stream failed`,{cause:e})}if(e.done)return!1;e.value.byteLength!==0&&(r.push(e.value),i+=e.value.byteLength)}n=new Uint8Array(i);let a=0;for(let e of r)n.set(e,a),a+=e.byteLength;return!0},i=e=>{let t=n.subarray(0,e);return n=n.subarray(e),t};try{for(;;){if(!await r(4))return;let e=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),!await r(e))throw new Or(`decodeFrames: truncated meta block`);let t=kr.parse(Je(i(e)));if(!await r(4))throw new Or(`decodeFrames: truncated body length`);let a=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),a>0&&!await r(a))throw new Or(`decodeFrames: truncated body bytes`);if(yield{meta:t,body:n.slice(0,a)},i(a),t._end===1)return}}finally{Mr(()=>t.return?.())}}function Mr(e){try{Promise.resolve(e()).catch(()=>{})}catch{}}async function*Nr(e){try{for(;;){let{done:t,value:n}=await e.read();if(t)return;n&&(yield n)}}finally{Mr(()=>e.cancel())}}export{Qt as $,Dn as A,Mn as B,ar as C,En as D,wn as E,Ln as F,Un as G,Pn as H,Fn as I,_n as J,gn as K,An as L,Hn as M,Vn as N,kn as O,Bn as P,Yt as Q,Rn as R,lr as S,$ as T,Gn as U,Nn as V,Wn as W,Jt as X,hn as Y,Xt as Z,Zn as _,wr as a,ae as at,ur as b,mr as c,_r as d,Zt as et,xr as f,qn as g,Jn as h,Ar as i,Je as it,jn as j,On as k,yr as l,rr as m,Dr as n,Ct as nt,Tr as o,vr as p,vn as q,jr as r,_t as rt,Er as s,Or as t,Gt as tt,br as u,nr as v,cr as w,tr as x,$n as y,zn as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,_ as t,it as n,lt as r,u as i,w as a}from"./dist-DearXsdS.js";import{B as o,G as s,Gn as c,H as l,Kn as u,L as d,On as f,R as p,V as m,Vn as h,Xt as g,Yt as _,an as ee,at as v,d as y,fn as b,n as x,ot as S,st as C,y as w,z as T}from"./logger-CxBCNokg.js";import{A as E,c as D,j as O}from"./dist-xTushGCp.js";const k=`5.0.0-beta.51`,te=/^[a-zA-Z0-9_\-./@]+$/;function ne(t,n){if(!te.test(t))throw Error(`Invalid workflow name "${t}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`${e(`workflow`,a(n))}${t}`}const re=r();function A(e){return`__health_check__${e}`}function ie(e){let n=t.safeParse(e);if(n.success)return n.data}function j(e){return`wrun_hc_${e}`}async function M(e,t){let n=await u(),r=A(e.correlationId),i;if(e.runId)try{let t=await n.getEncryptionKeyForRun?.(e.runId);t&&(i=h((await c(t)).publicKey))}catch(t){x.warn(`Health check could not derive a run public key; the caller will fall back to a key lookup`,{correlationId:e.correlationId,error:t instanceof Error?t.message:String(t)})}let a=JSON.stringify({healthy:!0,correlationId:e.correlationId,specVersion:t??7,workflowCoreVersion:k,hookResumeInputVersion:1,...i?{encryptionPublicKey:i}:{},timestamp:Date.now()}),o=j(e.correlationId);await n.streams.write(o,r,a),await n.streams.close(o,r)}function N(e,t){let n;return Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(Error(`Operation timed out after ${t}ms`)),t)})]).finally(()=>clearTimeout(n))}async function P(e,t){let n=[],r=!1,i=!1;for(;!r&&!i;){let a=e.read(),o=new Promise(e=>setTimeout(()=>{i=!0,e({done:!0,value:void 0})},t)),s=await Promise.race([a,o]);r=s.done,s.value&&n.push(s.value)}return{chunks:n,timedOut:i}}function F(e){if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;let i=new TextDecoder().decode(n),a;try{a=JSON.parse(i)}catch{return i.length>0?{healthy:!0}:null}if(typeof a!=`object`||!a||!(`healthy`in a)||typeof a.healthy!=`boolean`)return null;let o=a,s={healthy:o.healthy};return typeof o.specVersion==`number`&&(s.specVersion=o.specVersion),typeof o.workflowCoreVersion==`string`&&(s.workflowCoreVersion=o.workflowCoreVersion),typeof o.encryptionPublicKey==`string`&&(s.encryptionPublicKey=o.encryptionPublicKey),typeof o.hookResumeInputVersion==`number`&&(s.hookResumeInputVersion=o.hookResumeInputVersion),s}async function I(t,n){let r=n?.timeout??3e4,i=t.createRunId?.()??re(),o=A(i),s=`${e(`workflow`,a(n?.namespace))}health_check`,c=Date.now();try{for(await t.queue(s,{__healthCheck:!0,correlationId:i,...n?.runId?{runId:n.runId}:{}},{specVersion:1,deploymentId:n?.deploymentId});Date.now()-c<r;)try{let e=r-(Date.now()-c),n=(await N(t.streams.get(j(i),o),e)).getReader(),{chunks:a,timedOut:s}=await P(n,500);if(s){try{n.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=F(a);if(l)return{...l,latencyMs:Date.now()-c};await new Promise(e=>setTimeout(e,100))}catch{await new Promise(e=>setTimeout(e,100))}return{healthy:!1,error:`Health check timed out after ${r}ms`}}catch(e){return{healthy:!1,error:e instanceof Error?e.message:String(e)}}}function L(e,t){return new E(`Event pagination ${t} for workflow run "${e}".`,{code:O.WORLD_CONTRACT_ERROR})}function R(e,t,n){if(t){if(n.has(t))throw L(e,`did not advance`);n.add(t)}}function z(e,t,n){if(t.length===0)return;let r=n??new Set(e.map(e=>e.eventId));for(let n of t)r.has(n.eventId)||(r.add(n.eventId),e.push(n))}function B(e,t){let n=e.length;for(;n>0;){let r=e[n-1];if(r.eventId===t.eventId)return;if(r.eventId<t.eventId)break;n--}e.splice(n,0,t)}function V(e,t,n,r){if(t){if(n===null)throw L(e,`returned more pages without a cursor`);if(r.has(n))throw L(e,`repeated a cursor`)}}function H(e,t,n){return t!==null&&!n&&E.is(e)&&e.status===400}async function U(e,t){let n=t!==void 0;return w(`workflow.replay.load`,async r=>{r?.setAttributes({...b(e),...ee(n?`events_list_incremental`:`events_list`)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,d=!1,f=await u(),p=Date.now();for(;c;){let t=Date.now(),r=s;R(e,r,o);let u;try{u=await f.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(H(t,r,d)){x.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,d=!0;continue}throw t}z(i,u.data,a),c=u.hasMore,V(e,c,u.cursor,o),s=u.cursor??s,l++,x.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:u.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return x.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-p}),r?.setAttributes({..._(i.length),...g(l)}),{events:i,cursor:s}})}function W(e,t){z(e.events,t.events),e.cursor=t.cursor??e.cursor}function G(){return process.env.WORKFLOW_SLOT_GAP_CHECK!==`0`}function K(e,t){let n=e.length;z(e,t);let r=e.length-n;return r>0&&e.sort((e,t)=>e.eventId<t.eventId?-1:+(e.eventId>t.eventId)),r}function ae(e,t){let n=t.events?.length??0;return n===0?{added:0,offered:0,truncated:!1}:t.hasMore===!0?{added:0,offered:n,truncated:!0}:{added:K(e,t.events??[]),offered:n,truncated:!1}}function q(e){let t;for(let n of e){let e=i(n.eventId);(t===void 0||e>t)&&(t=e)}return t}function J(e){let t=new Set,n=0;for(let r of e){let e=i(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 a,o=0;for(let e=r;e<=n;e++)t.has(e)||(a??=e,o++);if(a!==void 0)return{firstMissingSlot:a,missingCount:o,maxSlot:n}}const oe=3;async function se(e,t){let n=t,r=J(n.events);for(let t=0;r!==void 0&&t<3;t++)await new Promise(e=>setTimeout(e,25*2**t)),n=await U(e),r=J(n.events);return{log:n,gap:r}}function ce(e){let t=q(e);return t===void 0?{}:{eventCount:t}}function le(e,t){if(!D.is(e))return null;let n=e.details;if(typeof n!=`object`||!n)return null;let{events:r,cursor:i}=n;if(!Array.isArray(r)||r.length===0)return null;for(let e of r)if(typeof e!=`object`||!e||typeof e.eventId!=`string`||e.runId!==t)return null;return{events:r,cursor:typeof i==`string`?i:null}}const Y={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function X(e,t){return async n=>{let r=new URL(n.url);return r.searchParams.has(`__health`)?n.method===`OPTIONS`?new Response(null,{status:204,headers:Y}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??7,workflowCoreVersion:k}),{status:200,headers:{"Content-Type":`application/json`,...Y}}):await e(n)}}function Z(e,t){return e?.[n]??t}function ue(e){return{deploymentId:e.deploymentId,specVersion:e.specVersion??0,...e.startedAt?{startedAt:+e.startedAt}:{},rootRunId:Z(e.attributes,e.runId)}}function de(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function fe(e,t){return`${e}:${de(t)}`}async function Q(e,...t){let n=t[0];await w(`queue.publish`,{attributes:{...m(`vercel-queue`),...p(n),...o(`publish`),...l(`vercel-queue`),...C(`vercel-queue`),...S(`vqs`),...v(`publish`)},kind:await y(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(T(r))})}async function pe(e,t,n){if(n.length===0)return;let r=e.queueBatch?.bind(e);if(!r){await Promise.all(n.map(n=>Q(e,t,n.message,n.opts)));return}await w(`queue.publish`,{attributes:{...m(`vercel-queue`),...p(t),...o(`publish`),...d(n.length),...l(`vercel-queue`),...C(`vercel-queue`),...S(`vqs`),...v(`publishBatch`)},kind:await y(`PRODUCER`)},async()=>{let e=await r(t,n);if(e.length!==n.length)throw Object.assign(Error(`Queue batch for ${t} returned ${e.length} result(s) for ${n.length} message(s)`),{retryable:!0});let i=e.filter(e=>e.error!==void 0);if(i.length===0)return;let a=i.some(e=>e.error!==void 0&&e.retryable),o=Error(`Failed to publish ${i.length} of ${n.length} queue message(s) to ${t}: ${i[0]?.error}`);throw Object.assign(o,{retryable:a}),o})}function me(e){if(e.requestedAt)try{return s(Date.now()-e.requestedAt.getTime())}catch{return}}async function $(e,t,n){let r=typeof t==`string`?await e.getEncryptionKeyForRun?.(t,n):await e.getEncryptionKeyForRun?.(t);return r?await f(r):void 0}function he(e,t){let n;return()=>(n||=$(e,t),n)}export{se as C,k as D,X as E,ue as S,fe as T,le as _,J as a,$ as b,M as c,G as d,U as f,ie as g,K as h,z as i,I as l,he as m,ae as n,me as o,q as p,W as r,ne as s,oe as t,B as u,Q as v,ce as w,Z as x,pe as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ht as e}from"./serialization-VRHEKI6l.js";import{i as t}from"./attribute-changes-3SKHZsSX.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};
|