experimental-ash 0.23.0 → 0.24.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 +22 -0
- package/dist/docs/internals/hooks.md +13 -16
- package/dist/docs/internals/message-runtime.md +1 -1
- package/dist/docs/public/auth-and-route-protection.md +3 -3
- package/dist/docs/public/typescript-api.md +2 -2
- package/dist/src/channel/types.d.ts +10 -12
- package/dist/src/chunks/{dev-authored-source-watcher-d_35Mp8T.js → dev-authored-source-watcher-B4PaZGUr.js} +1 -1
- package/dist/src/chunks/host-DsW72Q-w.js +65 -0
- package/dist/src/chunks/{paths-YoCQlavu.js → paths-OknjaYR8.js} +24 -24
- package/dist/src/chunks/prewarm-B4YblQ5m.js +6 -0
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/run.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +2 -2
- package/dist/src/compiled/@workflow/core/classify-error.d.ts +4 -3
- package/dist/src/compiled/@workflow/core/encryption.d.ts +7 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/package.json +1 -1
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +47 -0
- package/dist/src/compiled/@workflow/core/runtime/replay-budget.d.ts +98 -0
- package/dist/src/compiled/@workflow/core/runtime.js +27 -27
- package/dist/src/compiled/@workflow/core/serialization/types.d.ts +14 -0
- package/dist/src/compiled/@workflow/core/serialization.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/symbols.d.ts +16 -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/errors/error-codes.d.ts +5 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +15 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/errors/package.json +1 -1
- package/dist/src/compiled/_chunks/workflow/{context-errors-zbKocOyk.js → context-errors-Bbvvp-li.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-0iNBqPYp.js → dist-C7wPwOI9.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-D774SUM4.js → dist-C_oiE-l7.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-C3VWUPii.js +12 -0
- package/dist/src/compiled/_chunks/workflow/sleep-QTkC1VFe.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{symbols-D-4tVV8x.js → symbols-QezhMuLg.js} +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/await-authorization-orchestrator.d.ts +2 -1
- package/dist/src/execution/await-authorization-orchestrator.js +4 -0
- package/dist/src/execution/connection-auth-steps.d.ts +4 -0
- package/dist/src/execution/connection-auth-steps.js +9 -11
- package/dist/src/execution/node-step.d.ts +4 -5
- package/dist/src/execution/subagent-adapter.d.ts +0 -27
- package/dist/src/execution/subagent-adapter.js +2 -66
- package/dist/src/execution/subagent-hitl-proxy.d.ts +2 -2
- package/dist/src/execution/subagent-hitl-proxy.js +2 -2
- package/dist/src/execution/task-mode.d.ts +3 -3
- package/dist/src/execution/task-mode.js +3 -3
- package/dist/src/execution/turn-workflow.d.ts +41 -0
- package/dist/src/execution/turn-workflow.js +96 -0
- package/dist/src/execution/workflow-entry.js +77 -87
- package/dist/src/execution/workflow-errors.d.ts +14 -0
- package/dist/src/execution/workflow-errors.js +54 -0
- package/dist/src/execution/workflow-runtime.d.ts +34 -3
- package/dist/src/execution/workflow-runtime.js +52 -10
- package/dist/src/execution/workflow-steps.d.ts +27 -2
- package/dist/src/execution/workflow-steps.js +31 -26
- package/dist/src/harness/instrumentation-config.js +14 -7
- package/dist/src/harness/messages.d.ts +7 -7
- package/dist/src/harness/messages.js +4 -4
- package/dist/src/harness/runtime-actions.d.ts +4 -4
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.js +20 -8
- package/dist/src/internal/workflow-bundle/workflow-transformer.d.ts +13 -0
- package/dist/src/internal/workflow-bundle/workflow-transformer.js +10 -4
- package/package.json +4 -4
- package/dist/src/chunks/host-tji7W0Nn.js +0 -65
- package/dist/src/chunks/prewarm-6duWvvb5.js +0 -6
- package/dist/src/compiled/_chunks/workflow/resume-hook-CL8Ed91K.js +0 -12
- package/dist/src/compiled/_chunks/workflow/sleep-Dn3i9nxI.js +0 -1
- package/dist/src/execution/continuous-entry.d.ts +0 -59
- package/dist/src/execution/continuous-entry.js +0 -487
- package/dist/src/execution/continuous-runtime.d.ts +0 -17
- package/dist/src/execution/continuous-runtime.js +0 -123
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./chunk-8L7ocgPr.js";import{C as t,T as n,i as r,r as i,w as a}from"./paths-YoCQlavu.js";import{a as o,i as s,n as c,r as l}from"./authored-module-loader-XcFLnl49.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./package-DmsQgn4v.js";import{g,m as ee,p as te}from"./types-MZUhN0Zy.js";import{a as ne,c as re,n as ie,o as ae,r as oe,t as se}from"./prewarm-6duWvvb5.js";import{builtinModules as ce}from"node:module";import{dirname as _,extname as le,isAbsolute as ue,join as v,relative as y,resolve as b,sep as de}from"node:path";import{cp as x,mkdir as S,readFile as C,readdir as w,realpath as fe,rename as T,rm as E,symlink as pe,writeFile as D}from"node:fs/promises";import{randomUUID as me}from"node:crypto";import{existsSync as he,readFileSync as ge}from"node:fs";import{fileURLToPath as _e}from"node:url";import{Buffer as ve}from"node:buffer";import{build as ye,copyPublicAssets as be,createDevServer as xe,createNitro as Se,prepare as Ce,prerender as we}from"nitro/builder";const Te=`ash-cache.json`;async function Ee(e){let t=await De(e),n=h().version;t!==null&&t===n||await E(e,{force:!0,recursive:!0})}async function O(e){await S(e,{recursive:!0}),await D(v(e,Te),`${JSON.stringify({ashVersion:h().version},null,2)}\n`)}async function De(e){try{let t=JSON.parse(await C(v(e,Te),`utf8`));return typeof t.ashVersion==`string`?t.ashVersion:null}catch(e){return e instanceof Error&&`code`in e&&e.code,null}}const Oe=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);async function ke(e){if(e.mode===!1)return{code:e.source,workflowManifest:{}};let t=await Ae(e.filename,e.source),n=Me(t);if(n.length===0)return{code:e.source,workflowManifest:{}};let r=e.moduleSpecifier??`./${qe(e.filename)}`,i={},a=[],o=[],s=!1;for(let t of n){if(t.directive===`use step`){let n=Je(r,t.name);i.steps??={};let c=i.steps[e.filename]??={};if(c[t.name]={stepId:n},e.mode===`workflow`){let e=t.exportPrefix.length>0?`export `:``;a.push({end:t.rangeEnd,start:t.rangeStart,text:`${e}var ${t.name} = globalThis[Symbol.for("WORKFLOW_USE_STEP")](${JSON.stringify(n)});`})}else a.push({end:t.directiveEnd,start:t.directiveStart,text:``}),e.mode===`step`?(s=!0,o.push(`registerStepFunction(${JSON.stringify(n)}, ${t.name});`)):o.push(`${t.name}.stepId = ${JSON.stringify(n)};`);continue}let n=`workflow//${r}//${t.name}`;i.workflows??={};let c=i.workflows[e.filename]??={};c[t.name]={workflowId:n},e.mode===`workflow`?(a.push({end:t.directiveEnd,start:t.directiveStart,text:``}),o.push(`${t.name}.workflowId = ${JSON.stringify(n)};`),o.push(`globalThis.__private_workflows.set(${JSON.stringify(n)}, ${t.name});`)):(a.push({end:t.directiveEnd,start:t.directiveStart,text:`throw new Error(${JSON.stringify(`You attempted to execute workflow ${t.name} function directly. To start a workflow, use start(${t.name}) from workflow/api`)});`}),o.push(`${t.name}.workflowId = ${JSON.stringify(n)};`))}let c=`/**__internal_workflows${JSON.stringify(i)}*/;`,l=n.some(e=>e.directive===`use workflow`);if(e.mode===`workflow`&&!l)return{code:`${c}\n${je(e.source,t,n,r)}`,workflowManifest:i};let u=Le(e.source,a),d=e.mode===`workflow`?await Re(e.filename,u):u;return{code:`${s?`import { registerStepFunction } from "workflow/internal/private";\n${c}\n`:`${c}\n`}${d}${o.length>0?`\n${o.join(`
|
|
2
|
-
`)}\n`:``}`,workflowManifest:i}}async function Ae(e,t){let{parseAst:n}=await o();return n(t,{astType:`ts`,lang:Ke(e),range:!0,sourceType:`module`},e)}function je(e,t,n,r){let i=ze(e,t),a=n.filter(e=>e.directive===`use step`).map(e=>{let t=e.exportPrefix.length>0?`export `:``,n=Je(r,e.name);return`${t}var ${e.name} = globalThis[Symbol.for("WORKFLOW_USE_STEP")](${JSON.stringify(n)});`}),o=[...i,...a];return o.length>0?`${o.join(`
|
|
3
|
-
`)}\n`:``}function Me(e){let t=[];for(let n of e.body??[]){let e=Ne(n);if(e===null)continue;let r=e.fn,i=r.id?.name,a=Fe(r.body);if(r.async!==!0||i===void 0||a===void 0)continue;let o=Ie(a[0]);o!==null&&t.push({directive:o.value,directiveEnd:o.end,directiveStart:o.start,exportPrefix:e.exported?`export `:``,name:i,rangeEnd:e.end,rangeStart:e.start})}return t}function Ne(e){return e.type===`FunctionDeclaration`?Pe(e,!1,e):e.type!==`ExportNamedDeclaration`||e.declaration?.type!==`FunctionDeclaration`?null:Pe(e.declaration,!0,e)}function Pe(e,t,n){return e.start===void 0||e.end===void 0||n.start===void 0||n.end===void 0?null:{end:n.end,exported:t,fn:e,start:n.start}}function Fe(e){return e===void 0||Array.isArray(e)?e:e.body}function Ie(e){let t=e?.directive??(e?.type===`ExpressionStatement`&&e.expression?.type===`Literal`?e.expression.value:void 0);return t!==`use workflow`&&t!==`use step`||e?.start===void 0||e.end===void 0?null:{end:e.end,start:e.start,value:t}}function Le(e,t){let n=``,r=0;for(let i of[...t].sort((e,t)=>e.start-t.start))n+=e.slice(r,i.start),n+=i.text,r=i.end;return n+e.slice(r)}async function Re(e,t){let n=await Ae(e,t),r=Ue(n),i=[];for(let e of n.body??[]){if(e.type!==`ImportDeclaration`||e.start===void 0||e.end===void 0)continue;let n=He(e);n.length>0&&n.every(e=>!r.has(e))&&i.push({end:Ge(t,e.end),start:e.start,text:``})}return i.length>0?Le(t,i):t}function ze(e,t){let n=[];for(let r of t.body??[])r.type===`ExportNamedDeclaration`&&r.declaration?.type===`VariableDeclaration`&&r.declaration.kind===`const`&&r.start!==void 0&&r.end!==void 0&&(r.declaration.declarations??[]).every(Be)&&n.push(e.slice(r.start,r.end).trim());return n}function Be(e){return Ve(e.init)}function Ve(e){return e==null?!1:e.type===`Literal`?e.value===null||typeof e.value==`boolean`||typeof e.value==`number`||typeof e.value==`string`:e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`||e.type===`TSNonNullExpression`||e.type===`TSTypeAssertion`?Ve(e.expression):e.type===`UnaryExpression`&&e.argument?.type===`Literal`?typeof e.argument.value==`number`:!1}function He(e){return e.importKind===`type`?[]:(e.specifiers??[]).filter(e=>e.importKind!==`type`).map(e=>e.local?.name).filter(e=>e!==void 0)}function Ue(e){let t=new Set;return k(e,e=>{e.type===`Identifier`&&typeof e.name==`string`&&t.add(e.name)}),t}function k(e,t){if(!(e.type===`ImportDeclaration`||e.type?.startsWith(`TS`))){t(e);for(let n of Object.values(e))if(Array.isArray(n))for(let e of n)We(e)&&k(e,t);else We(n)&&k(n,t)}}function We(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function Ge(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n+=1;return e[n]===`\r`&&e[n+1]===`
|
|
4
|
-
`?n+2:e[n]===`
|
|
5
|
-
`?n+1:n}function Ke(e){return e.endsWith(`.tsx`)?`tsx`:e.endsWith(`.jsx`)?`jsx`:/\.[cm]?ts$/.test(e)?`ts`:`js`}function qe(e){return e.replace(/\.(?:[cm]?[jt]sx?)$/,``)}function Je(e,t){return Oe.has(t)?t:`step//${e}//${t}`}const Ye={type:`queue/v2beta`,topic:`__wkf_workflow_*`,consumer:`default`,retryAfterSeconds:5,initialDelaySeconds:0},A=new Map,Xe=new Map;async function j(e,t,n,r,i){let a=i??process.cwd(),{moduleSpecifier:o}=$e(r===void 0?ue(e)?e:v(a,e):r,a);return ke({filename:e,mode:n,moduleSpecifier:o,source:t})}function Ze(e){return{hasSerde:e.includes(`workflow.serde`)||e.includes(`@serde`)||e.includes(`workflowSerde`)||e.includes(`__workflow_serde`),hasUseStep:/["']use step["']/.test(e),hasUseWorkflow:/["']use workflow["']/.test(e)}}function Qe(e,t){let n=P(e),r=!n&&rt(e,t);if(n||r){let n=M(e);if(n!==null){let i=nt(t).has(n.name);if(!(r||i))return{importPath:F(e,t),isPackage:!1};let a=et(e,n);return a?{importPath:`${n.name}${a}`,isPackage:!0}:ot(e,n)?{importPath:n.name,isPackage:!0}:{importPath:F(e,t),isPackage:!1}}}return{importPath:F(e,t),isPackage:!1}}function $e(e,t){let n=P(e),r=!n&&rt(e,t);if(!n&&!r)return{moduleSpecifier:void 0};let i=M(e);if(i===null)return{moduleSpecifier:void 0};let a=et(e,i);return{moduleSpecifier:a?`${i.name}${a}@${i.version}`:`${i.name}@${i.version}`}}function M(e){let t=_(e),n=[];for(;t!==_(t);){let e=A.get(t);if(e!==void 0){for(let t of n)A.set(t,e);return e}n.push(t);let r=v(t,`package.json`);if(he(r))try{let e=JSON.parse(ge(r,`utf8`));if(typeof e.name==`string`&&typeof e.version==`string`){let r={dir:t,exports:e.exports,main:e.main,module:e.module,name:e.name,version:e.version};A.set(t,r);for(let e of n)A.set(e,r);return r}}catch{}t=_(t)}for(let e of n)A.set(e,null);return null}function et(e,t){if(t.exports===null||typeof t.exports!=`object`||Array.isArray(t.exports))return``;let n=e.replace(/\\/g,`/`),r=t.dir.replace(/\\/g,`/`),i=n.startsWith(`${r}/`)?`./${n.substring(r.length+1)}`:null;if(i===null)return``;for(let[e,n]of Object.entries(t.exports)){let t=N(n);if(t!==null&&tt(t)===i)return e===`.`?``:e.substring(1)}return``}function N(e){if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=N(t);if(e!==null)return e}return null}if(typeof e==`object`&&e)for(let t of[`workflow`,`default`,`require`,`import`,`node`]){let n=e[t],r=N(n);if(r!==null)return r}return null}function tt(e){return e.startsWith(`./`)?e:`./${e}`}function P(e){return e.split(de).join(`/`).includes(`/node_modules/`)}function nt(e){let t=Xe.get(e);if(t!==void 0)return t;let n=new Set,r=v(e,`package.json`);if(he(r))try{let e=JSON.parse(ge(r,`utf8`));for(let t of[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`]){let r=e[t];if(typeof r==`object`&&r&&!Array.isArray(r))for(let e of Object.keys(r))n.add(e)}}catch{}return Xe.set(e,n),n}function rt(e,t){if(P(e))return!1;let n=M(e);return n===null||b(n.dir)===b(t)?!1:nt(t).has(n.name)}function F(e,t){let n=t.replace(/\\/g,`/`),r=e.replace(/\\/g,`/`),i=r.startsWith(`${n}/`)?r.substring(n.length+1):y(t,e).replace(/\\/g,`/`);return i.startsWith(`.`)||(i=`./${i}`),i}function it(e){if(typeof e==`string`||Array.isArray(e))return!0;if(typeof e!=`object`||!e)return!1;let t=Object.keys(e);return t.length>0&&t.every(e=>!e.startsWith(`.`))?!0:`.`in e}function at(e){let t=e.replace(/\\/g,`/`);return t.startsWith(`./`)?t.substring(2):t.startsWith(`/`)?t.substring(1):t}function ot(e,t){let n=e.replace(/\\/g,`/`),r=t.dir.replace(/\\/g,`/`);if(!n.startsWith(`${r}/`))return!1;let i=n.substring(r.length+1);if(t.exports!==void 0){let e;if(t.exports!==null&&typeof t.exports==`object`&&`.`in t.exports)e=t.exports[`.`];else if(it(t.exports))e=t.exports;else return!1;let n=N(e);return n!==null&&at(n)===i}return[t.module,t.main,`index.js`,`index.mjs`,`index.cjs`,`index.ts`,`index.mts`,`index.cts`].flatMap(e=>typeof e==`string`?[at(e)]:[]).includes(i)}const st=`\0ash-workflow-entry`,ct=new Set([`server-only`,`client-only`,`next/dist/compiled/server-only`,`next/dist/compiled/client-only`]);new Set([...ce,...ce.map(e=>`node:${e}`)]);const lt=new Set([`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`]),ut=new Set([`node_modules`,`.git`,`.next`,`.nuxt`,`.output`,`.vercel`,`.workflow-data`,`.workflow-vitest`,`.well-known`,`.svelte-kit`,`.turbo`,`.cache`,`.yarn`,`.pnpm-store`]);async function dt(e){let t=[];async function n(e){let r;try{r=await w(e,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}for(let i of r){if(i.isDirectory()){ut.has(i.name)||await n(v(e,i.name));continue}if(!i.isFile())continue;let r=i.name.match(/\.[^.]+$/)?.[0];r!==void 0&<.has(r)&&t.push(v(e,i.name))}}return await n(e),t}function ft(e,t){let{importPath:n,isPackage:r}=Qe(e,t);return r?`import ${JSON.stringify(n)};`:`import ${JSON.stringify(xt(t,e))};`}function pt(e){return{name:`ash-workflow-virtual-entry`,resolveId(e){if(e===`\0ash-workflow-entry`)return{id:e}},load(t){if(t===`\0ash-workflow-entry`)return{code:e,moduleSideEffects:!0,moduleType:`js`}}}}function mt(){return{name:`ash-workflow-pseudo-packages`,resolveId(e){if(ct.has(e))return{id:`\0ash-workflow-pseudo-package:${e}`}},load(e){if(e.startsWith(`\0ash-workflow-pseudo-package:`))return{code:``,moduleType:`js`}}}}function ht(e,t={}){return{name:`ash-package-imports`,resolveId(n){let r=n.match(/^#compiled\/(.+)$/)?.[1];if(r!==void 0)return t.workflowCondition===!0&&r===`@workflow/core/index.js`?I([v(e,`src`,`internal`,`workflow-bundle`,`workflow-core-shim.ts`),v(e,`dist`,`src`,`internal`,`workflow-bundle`,`workflow-core-shim.js`)]):I([v(e,`.generated`,`compiled`,r),v(e,`dist`,`src`,`compiled`,r)]);let i=n.match(/^#(.+)\.js$/)?.[1];if(i!==void 0)return I([`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`].flatMap(t=>[v(e,`src`,`${i}${t}`),v(e,`dist`,`src`,`${i}${t}`)]))}}}function gt(e){let t=new Set(e.sideEffectFiles?.map(e=>e.replaceAll(`\\`,`/`))??[]);return{name:`ash-workflow-transform`,async load(n){if(!Tt(n))return;let r=await C(n,`utf8`),i=await j(wt(e.workingDir,n),r.replace(/require\(\s*(['"])server-only\1\s*\)/g,`void 0`).replace(/require\(\s*(['"])client-only\1\s*\)/g,`void 0`),e.mode??`workflow`,n,e.projectRoot);return Ct(e.manifest,i.workflowManifest),{code:i.code,map:null,moduleSideEffects:t.has(n.replaceAll(`\\`,`/`))||void 0}}}}async function _t(e){let t=`// biome-ignore-all lint: generated file
|
|
6
|
-
/* eslint-disable */
|
|
7
|
-
import { workflowEntrypoint } from 'workflow/runtime';
|
|
8
|
-
|
|
9
|
-
const workflowCode = \`${(e.code.endsWith(`
|
|
10
|
-
`)?e.code:`${e.code}\n`).replace(/[\\`$]/g,`\\$&`)}\`;
|
|
11
|
-
|
|
12
|
-
export const POST = workflowEntrypoint(workflowCode);`;if(!e.bundleFinalOutput){await St(e.outfile,t);return}let n=s(await l({cwd:e.workingDir,input:st,external:e=>e===`@aws-sdk/credential-provider-web-identity`,platform:`node`,plugins:[pt(t)],write:!1,output:{comments:!1,format:e.format,sourcemap:!1}}),`final workflow bundle for "${e.outfile}"`);await St(e.outfile,n.code)}function vt(e){let t={};for(let[n,r]of Object.entries(e??{})){t[n]={};for(let[e,i]of Object.entries(r))t[n][e]={stepId:i.stepId}}return t}function yt(e){let t={};for(let[n,r]of Object.entries(e??{})){t[n]={};for(let[e,i]of Object.entries(r))t[n][e]={graph:{edges:[],nodes:[]},workflowId:i.workflowId}}return t}function bt(e){let t={};for(let[n,r]of Object.entries(e??{})){t[n]={};for(let[e,i]of Object.entries(r))t[n][e]={classId:i.classId}}return t}function xt(e,t){let n=y(e,t).replaceAll(`\\`,`/`);return n.startsWith(`./`)||n.startsWith(`../`)?n:`./${n}`}function I(e){for(let t of e)if(he(t))return{id:b(t)}}async function St(e,t){await S(_(e),{recursive:!0});let n=`${e}.${process.pid}.${Date.now()}.tmp`;await D(n,t),await T(n,e)}function Ct(e,t){e.steps=L(e.steps,t.steps),e.workflows=L(e.workflows,t.workflows),e.classes=L(e.classes,t.classes)}function L(e,t){if(t===void 0)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]={...n[e],...r};return n}function wt(e,t){let n=t.replaceAll(`\\`,`/`),r=y(e.replaceAll(`\\`,`/`),n).replaceAll(`\\`,`/`);return r.startsWith(`../`)&&(r=r.split(`/`).filter(e=>e!==`..`).join(`/`)),r}function Tt(e){return/\.(?:[cm]?[jt]sx?)$/.test(e)}async function R(e,t){let n=`${e}.tmp-${process.pid}-${Date.now().toString(36)}`;await D(n,t),await Et(n,e)}async function Et(e,t){if(process.platform!==`win32`){await T(e,t);return}for(let n=0;n<10;n+=1)try{await T(e,t);return}catch(e){if(!(e instanceof Error&&`code`in e&&(e.code===`EPERM`||e.code===`EACCES`||e.code===`EBUSY`))||n===9)throw e;await new Promise(e=>setTimeout(e,10*(n+1)))}}async function Dt(e){let t=[...e.discoveredEntries.discoveredSteps].sort(),n=new Set(t),r=[...e.discoveredEntries.discoveredSerdeFiles].sort().filter(e=>!n.has(e)),i=await kt({projectRoot:e.projectRoot,stepFiles:t,serdeOnlyFiles:r,workingDir:e.workingDir}),a=_(e.outfile),o=[`// Generated by Ash. Do not edit by hand.`,...Ot({builtinsImportSpecifier:e.builtinsPath===void 0?`workflow/internal/builtins`:z({outfileDirectory:a,preferAbsoluteFileImports:e.preferAbsoluteFileImports??!1,targetPath:e.builtinsPath}),outfileDirectory:a,preferAbsoluteFileImports:e.preferAbsoluteFileImports??!1,serdeOnlyFiles:r,stepFiles:t}),`export const __steps_registered = true;`,``].join(`
|
|
13
|
-
`);return await S(a,{recursive:!0}),await Nt(e.outfile)!==o&&await D(e.outfile,o),i}function Ot(e){return[e.builtinsImportSpecifier,...e.stepFiles.map(t=>z({outfileDirectory:e.outfileDirectory,preferAbsoluteFileImports:e.preferAbsoluteFileImports,targetPath:t})),...e.serdeOnlyFiles.map(t=>z({outfileDirectory:e.outfileDirectory,preferAbsoluteFileImports:e.preferAbsoluteFileImports,targetPath:t}))].map(e=>`import ${JSON.stringify(e)};`)}function z(e){return e.preferAbsoluteFileImports?t(e.targetPath):Mt(e.outfileDirectory,e.targetPath)}async function kt(e){let t={},n=[...e.stepFiles,...e.serdeOnlyFiles];for(let r of n){let n=await C(r,`utf8`);At(t,(await j(jt(e.workingDir,r),n,`step`,r,e.projectRoot)).workflowManifest)}return t}function At(e,t){e.steps=B(e.steps,t.steps),e.workflows=B(e.workflows,t.workflows),e.classes=B(e.classes,t.classes)}function B(e,t){if(t===void 0)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]={...n[e],...r};return n}function jt(e,t){let n=t.replaceAll(`\\`,`/`),r=y(e.replaceAll(`\\`,`/`),n).replaceAll(`\\`,`/`);return r.startsWith(`../`)&&(r=r.split(`/`).filter(e=>e!==`..`).join(`/`)),r}function Mt(e,t){let n=y(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function Nt(e){try{return await C(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}}const Pt=`index.__ash_service_route_prefix.mjs`,Ft=[`ash/`,`.well-known/workflow/`];function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function It(e){return Ft.some(t=>e.startsWith(t))}function Lt(e,t){return e.filter(Rt).map(e=>Bt(e,t))}function Rt(e){if(!V(e)||`handle`in e)return!0;let t=typeof e.src==`string`?e.src:``,n=typeof e.dest==`string`?e.dest:``;return H(t)||H(n)}function H(e){return e.includes(`/ash/v1`)||e.includes(`/.well-known/workflow/`)}function zt(e){return e.includes(`/ash/v1`)}function Bt(e,t){if(!V(e)||`handle`in e||typeof e.src!=`string`)return e;let n=zt(e.src)||typeof e.dest==`string`&&zt(e.dest),r={...e,src:Vt(e.src,t)};return n&&(r.dest=`/ash/__server`),r}function Vt(e,t){if(t===void 0||t===`/`||!H(e)||e.includes(t))return e;let n=t.endsWith(`/`)?t.slice(0,-1):t,r=n.replaceAll(`/`,`\\/`);return e.includes(r)?e:e.startsWith(`^(?:/`)?`^(?:${n}${e.slice(4)}`:e.startsWith(`^/`)?`^${n}${e.slice(1)}`:e.startsWith(`/`)?`${n}${e}`:e}async function Ht(e,t){let n=v(e,`.vc-config.json`),r=v(e,Pt),i=JSON.parse(await C(n,`utf8`)),a=V(i)?i:{};await D(r,Ut(t)),await D(n,`${JSON.stringify({...a,handler:Pt},null,2)}\n`)}function Ut(e){return`
|
|
14
|
-
import { Server } from "node:http";
|
|
15
|
-
|
|
16
|
-
const SERVICE_PREFIX = ${JSON.stringify(Wt(e))};
|
|
17
|
-
const PATCH_SYMBOL = Symbol.for("ash.service.route-prefix-strip.patch");
|
|
18
|
-
|
|
19
|
-
function stripServiceRoutePrefix(requestUrl) {
|
|
20
|
-
if (typeof requestUrl !== "string" || requestUrl === "*") {
|
|
21
|
-
return requestUrl;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const queryIndex = requestUrl.indexOf("?");
|
|
25
|
-
const rawPath = queryIndex === -1 ? requestUrl : requestUrl.slice(0, queryIndex);
|
|
26
|
-
const query = queryIndex === -1 ? "" : requestUrl.slice(queryIndex);
|
|
27
|
-
const path = rawPath.startsWith("/") ? rawPath : \`/\${rawPath}\`;
|
|
28
|
-
|
|
29
|
-
if (path === SERVICE_PREFIX) {
|
|
30
|
-
return \`/\${query}\`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (path.startsWith(\`\${SERVICE_PREFIX}/\`)) {
|
|
34
|
-
return path.slice(SERVICE_PREFIX.length) + query;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return path + query;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!globalThis[PATCH_SYMBOL]) {
|
|
41
|
-
globalThis[PATCH_SYMBOL] = true;
|
|
42
|
-
const originalEmit = Server.prototype.emit;
|
|
43
|
-
Server.prototype.emit = function patchedEmit(event, request, ...args) {
|
|
44
|
-
if (event === "request" && request && typeof request.url === "string") {
|
|
45
|
-
request.url = stripServiceRoutePrefix(request.url);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return originalEmit.call(this, event, request, ...args);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const originalModule = await import("./index.mjs");
|
|
53
|
-
const entrypoint = originalModule?.default ?? originalModule;
|
|
54
|
-
|
|
55
|
-
export default entrypoint;
|
|
56
|
-
`.trimStart()}function Wt(e){let t=(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``);return t.length===0?`/`:t}const Gt=[`@mongodb-js/zstd`,`node-liblzma`],Kt=[`@chat-adapter/slack`,`chat`];function qt(e){let t={};return Jt(e)&&Object.assign(t,e),t.NODE_OPTIONS=`--experimental-require-module`,t}function Jt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Yt(e){await E(e,{force:!0,recursive:!0}),await S(e,{recursive:!0})}async function Xt(e){try{return await fe(e.sourcePath)}catch{return await fe(e.fallbackPath)}}async function Zt(e){let t=await Xt({fallbackPath:e.fallbackPath,sourcePath:e.sourcePath});await Yt(e.targetPath),await x(t,e.targetPath,{dereference:!0,recursive:!0})}async function Qt(e,t={}){let n=v(e,`functions`),r=await $t(n);r!==null&&(t.servicePrefix!==void 0&&await Ht(r,t.servicePrefix),await en(n,r)),await nn(n,n),await rn(e,t.servicePrefix)}async function $t(e){let t=v(e,`__server.func`),n=v(e,`ash/__server.func`),r;try{r=await fe(t)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}let i=`${n}.ash-staging`;return await S(_(n),{recursive:!0}),await E(i,{force:!0,recursive:!0}),await x(r,i,{dereference:!0,recursive:!0}),await E(n,{force:!0,recursive:!0}),await T(i,n),n}async function en(e,t,n=e){let r;try{r=await w(e,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}await Promise.all(r.map(async r=>{let i=v(e,r.name),a=U(y(n,i));if(r.isSymbolicLink()){r.name.endsWith(`.func`)&&It(a)&&await tn(i,t);return}r.isDirectory()&&!r.name.endsWith(`.func`)&&await en(i,t,n)}))}async function tn(e,t){await E(e,{force:!0,recursive:!0}),await pe(U(y(_(e),t)),e,`dir`)}async function nn(e,t){let n;try{n=await w(t,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}await Promise.all(n.map(async n=>{let r=v(t,n.name),i=U(y(e,r));if(n.name.endsWith(`.func`)){It(i)||await E(r,{force:!0,recursive:!0});return}n.isDirectory()&&await nn(e,r)}))}async function rn(e,t){let n=v(e,`config.json`),r;try{r=JSON.parse(await C(n,`utf8`))}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}!Jt(r)||!Array.isArray(r.routes)||(r.routes=Lt(r.routes,t),await D(n,`${JSON.stringify(r,null,2)}\n`))}function U(e){return e.replaceAll(`\\`,`/`)}function an(e){let t=y(e.fromDirectoryPath,e.toFilePath).replaceAll(`\\`,`/`);return t.startsWith(`.`)?t:`./${t}`}function on(e){return[`import nitroHandler from ${JSON.stringify(e.delegateImportPath)};`,``,`function invokeNitroHandler(request, context) {`,` if (typeof nitroHandler === "function") {`,` return nitroHandler(request, context);`,` }`,``,` if (nitroHandler !== null && typeof nitroHandler === "object" && "fetch" in nitroHandler) {`,` const fetch = nitroHandler.fetch;`,` if (typeof fetch === "function") {`,` return fetch.call(nitroHandler, request, context);`,` }`,` }`,``,` throw new TypeError("Expected Nitro handler to export a function or an object with fetch(request, context).");`,`}`,``,`const workflowRoutePath = ${JSON.stringify(e.workflowRoutePath)};`,``,`function rewriteRequestToWorkflowRoute(request) {`,` const sourceUrl = new URL(request.url);`,` const routedUrl = new URL(workflowRoutePath, sourceUrl);`,` routedUrl.search = sourceUrl.search;`,` return new Request(routedUrl, request);`,`}`,``,`export default {`,` fetch(request, context) {`,` return invokeNitroHandler(rewriteRequestToWorkflowRoute(request), context);`,` },`,`};`,``].join(`
|
|
57
|
-
`)}async function sn(e){try{let t=JSON.parse(await C(v(e,`.vc-config.json`),`utf8`));if(typeof t.handler==`string`&&t.handler.length>0)return t.handler}catch{}return`index.mjs`}async function cn(e){let t=await sn(e.functionDirectoryPath),n=v(e.functionDirectoryPath,t),r=_(n),i=le(t),a=v(r,`__ash_nitro_handler__${i.length>0?i:`.mjs`}`),o=an({fromDirectoryPath:r,toFilePath:a});await T(n,a),await D(n,on({delegateImportPath:o,workflowRoutePath:e.workflowRoutePath}))}const ln=new Map;var un=class{#e;#t;config;#n=new WeakMap;constructor(e){this.config={buildTarget:`standalone`,dirs:[m(`src/execution`)],externalPackages:[...Gt,...Kt],projectRoot:e.appRoot,watch:e.watch,workingDir:e.rootDir},this.#e=e.compiledArtifactsBootstrapPath,this.#t=e.outDir}async build(e={}){let t=(ln.get(this.#t)??Promise.resolve()).then(()=>this.#r(e));ln.set(this.#t,t.catch(()=>{})),await t}async#r(e){await Ee(this.#t);let t=await this.#i();if(t.length===0)throw Error(`Expected the execution workflow source file under "${m(`src/execution`)}".`);let n=await this.findTsConfigPath();await S(this.#t,{recursive:!0});let r=await this.discoverEntries(t,this.#t,n),i=v(this.#t,`workflows.mjs`),{manifest:a}=await this.createWorkflowsBundle({discoveredEntries:r,keepInterimBundleContext:!1,outfile:i,bundleFinalOutput:!1,format:`esm`,inputFiles:t,tsconfigPath:n}),o=v(this.#t,`steps.mjs`),s=await Dt({builtinsPath:u(`workflow/internal/builtins`),discoveredEntries:r,outfile:o,preferAbsoluteFileImports:!0,projectRoot:this.config.projectRoot??this.config.workingDir,workingDir:this.config.workingDir}),c=e.nitroStepOutfile;c!==void 0&&c!==o&&await Dt({builtinsPath:u(`workflow/internal/builtins`),discoveredEntries:r,outfile:c,preferAbsoluteFileImports:!0,projectRoot:this.config.projectRoot??this.config.workingDir,workingDir:this.config.workingDir}),await dn(i,o),await fn(i),await pn(i);let l=e.nitroWorkflowOutfile;l!==void 0&&l!==i&&(await S(_(l),{recursive:!0}),await xn(i,l),c!==void 0&&(await dn(l,c),await fn(l),await pn(l))),await this.createManifest({workflowBundlePath:v(this.#t,`workflows.mjs`),manifestDir:this.#t,manifest:{steps:{...s.steps,...a.steps},workflows:{...s.workflows,...a.workflows},classes:{...s.classes,...a.classes}}}),await O(this.#t)}get transformProjectRoot(){return this.config.projectRoot??this.config.workingDir}async findTsConfigPath(){let e=this.config.workingDir;for(;;){for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=v(e,t);try{return await C(n),n}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}}let t=_(e);if(t===e)return;e=t}}async getInputFiles(){let e=this.config.dirs.map(e=>b(this.config.workingDir,e));return(await Promise.all(e.map(e=>dt(e)))).flat()}async discoverEntries(e,t,n){let r=this.#n.get(e);if(r!==void 0)return r;let i={discoveredSerdeFiles:[],discoveredSteps:[],discoveredWorkflows:[]};for(let t of e){let e=Ze(await C(t,`utf8`));e.hasUseStep&&i.discoveredSteps.push(t),e.hasUseWorkflow&&i.discoveredWorkflows.push(t),e.hasSerde&&i.discoveredSerdeFiles.push(t)}return this.#n.set(e,i),i}async createWorkflowsBundle({bundleFinalOutput:e=!0,discoveredEntries:t,format:n=`cjs`,inputFiles:r,keepInterimBundleContext:i=this.config.watch,outfile:a,tsconfigPath:o}){let c=t??await this.discoverEntries(r,_(a),o),u=[...c.discoveredWorkflows].sort(),d=new Set(u),f=[...c.discoveredSerdeFiles].sort().filter(e=>!d.has(e)),p={},m=[...u.map(e=>ft(e,this.config.workingDir)),...f.map(e=>ft(e,this.config.workingDir))].join(`
|
|
58
|
-
`);return await _t({bundleFinalOutput:e,code:s(await l({cwd:this.config.workingDir,input:st,platform:`neutral`,plugins:[pt(m),mt(),ht(this.config.workingDir,{workflowCondition:!0}),gt({manifest:p,projectRoot:this.transformProjectRoot,sideEffectFiles:[...u,...f],workingDir:this.config.workingDir})],resolve:{conditionNames:[`ash-source`,`workflow`,`node`,`import`,`default`],extensions:[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`],mainFields:[`module`,`main`]},tsconfig:o??!1,write:!1,output:{banner:`globalThis.__private_workflows = new Map();`,codeSplitting:!1,comments:!1,format:`cjs`,sourcemap:`inline`}}),`intermediate workflow bundle for "${a}"`).code,format:n,outfile:a,workingDir:this.config.workingDir}),i?{bundleFinal:async t=>{await _t({bundleFinalOutput:e,code:t,format:n,outfile:a,workingDir:this.config.workingDir})},interimBundleCtx:void 0,manifest:p}:{manifest:p}}async createManifest({manifest:e,manifestDir:t}){let n={version:`1.0.0`,steps:vt(e.steps),workflows:yt(e.workflows),classes:bt(e.classes)},r=JSON.stringify(n,null,2);return await S(t,{recursive:!0}),await D(v(t,`manifest.json`),r),r}async buildVercelOutput(e){await this.build();let t=v(this.#t,`vercel-build-output`,`functions`,`.well-known`,`workflow`,`v1`),n=v(t,`flow.func`),r=v(e.outputDir,`functions`,`.well-known`,`workflow`,`v1`),i=v(e.flowNitroOutputDir,`functions`,`__server.func`),a=v(e.flowNitroOutputDir,`functions`,`.well-known`,`workflow`,`v1`,`flow.func`),o=v(r,`flow.func`),s=v(r,`step.func`),c=v(r,`webhook`,`[token].func`);await Zt({fallbackPath:i,sourcePath:a,targetPath:n}),await Promise.all([this.#a(n,{experimentalTriggers:Array.from([Ye]),maxDuration:`max`,runtime:e.runtime??null,shouldAddHelpers:!1}),x(v(this.#t,`manifest.json`),v(t,`manifest.json`))]),await cn({functionDirectoryPath:n,workflowRoutePath:`/.well-known/workflow/v1/flow`}),await Promise.all([E(o,{force:!0,recursive:!0}),E(s,{force:!0,recursive:!0}),E(c,{force:!0,recursive:!0})]),await S(r,{recursive:!0}),await Promise.all([x(n,o,{recursive:!0}),x(v(t,`manifest.json`),v(r,`manifest.json`))])}async#i(){return[...await this.getInputFiles(),this.#e]}async#a(e,t){let n=v(e,`.vc-config.json`),r=await this.#o(n),i={...r};i.environment=qt(r.environment),t.runtime!==null&&(i.runtime=t.runtime),t.maxDuration!==void 0&&(i.maxDuration=t.maxDuration),t.shouldAddHelpers!==void 0&&(i.shouldAddHelpers=t.shouldAddHelpers),t.shouldAddSourcemapSupport!==void 0&&(i.shouldAddSourcemapSupport=t.shouldAddSourcemapSupport),t.experimentalTriggers!==void 0&&(i.experimentalTriggers=[...t.experimentalTriggers]),await D(n,`${JSON.stringify(i,null,2)}\n`)}async#o(e){try{let t=JSON.parse(await C(e,`utf8`));if(typeof t==`object`&&t)return t}catch{}return{}}};async function dn(e,t){let n=await yn(e);if(n===null||n.includes(`__ashWorkflowStepsRegistered`))return;let r=vn(_(e),t),i=[`import { __steps_registered as __ashWorkflowStepsRegistered } from ${JSON.stringify(r)};`,`void __ashWorkflowStepsRegistered;`,``].join(`
|
|
59
|
-
`),a=n.match(/^import\s.+?;\n/m);if(a===null||a.index===void 0){await R(e,`${i}${n}`);return}let o=a.index+a[0].length;await R(e,`${n.slice(0,o)}${i}${n.slice(o)}`)}async function fn(e){let t=await yn(e);if(t===null)return;let n=t;for(let e of[`workflow`,`workflow/api`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`]){let t=_n(u(e));n=gn(n,e,t)}n!==t&&await R(e,n)}async function pn(e){let t=await yn(e);if(t===null)return;let n=t.indexOf(`const workflowCode = `),r=t.lastIndexOf(`;
|
|
60
|
-
|
|
61
|
-
export const POST = workflowEntrypoint(workflowCode);`);if(n===-1||r===-1||r<=n)return;let i=n+21,a=t.slice(i,r);if(!a.trimStart().startsWith("`"))return;let o=hn(a,e),s=`${t.slice(0,i)}${mn(o)}${t.slice(r)}`;s!==t&&await R(e,s)}function mn(e){let t=ve.from(e,`utf8`).toString(`base64`).match(/.{1,16384}/g)??[``];return`Buffer.from(${JSON.stringify(t)}.join(""), "base64").toString("utf8")`}function hn(e,t){let n=e.trim();if(!n.startsWith("`")||!n.endsWith("`"))throw Error(`Expected generated workflow code literal in "${t}" to be a template.`);let r=n.slice(1,-1),i=``;for(let e=0;e<r.length;e+=1){let t=r[e];if(t!==`\\`){i+=t;continue}let n=r[e+1];if(n===`\\`||n==="`"||n===`$`){i+=n,e+=1;continue}i+=t}return i}function gn(e,t,n){return e.replaceAll(JSON.stringify(t),JSON.stringify(n)).replaceAll(`'${t}'`,JSON.stringify(n))}function _n(e){return t(e)}function vn(e,t){let n=y(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function yn(e){try{return await C(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}}async function bn(e){try{return await C(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}}async function xn(e,t){let n=await C(e),r=await bn(t);r!==null&&r.equals(n)||await R(t,n)}const Sn=`\0ash-pruned-local-sandbox-backend`,Cn=/[/\\]bindings[/\\]local\.js$/;function wn(){return{name:`ash-hosted-sandbox-backend-prune`,load(e){return e===Sn?[`export function createLocalSandboxBackend() {`,` throw new Error("The local sandbox backend is pruned from hosted server bundles.");`,`}`,``].join(`
|
|
62
|
-
`):null},resolveId(e){return Cn.test(e)?Sn:null}}}const Tn=`${g}/runs`,En=`${g}/runs/:runId`,Dn=`${g}/runs/:runId/steps`,On=`${g}/runs/:runId/events`;function kn(e){return e===`all`||e===`app`}function An(e){return W(e)}function W(e){return e===`all`||e===`flow`}function G(e,t){let r=`#ash-route-handler/${t.method??`ALL`} ${t.route}`,i=n(t.handlerPath);e.options.handlers.push({handler:r,method:t.method,route:t.route}),e.options.virtual[r]=[`import handler from ${i};`,`export default handler;`].join(`
|
|
63
|
-
`)}function K(e){return v(e.options.buildDir,`workflow`)}function jn(e,t){let n=y(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function Mn(e,t){let n=v(K(e),`${t.bundleName}-handler.mjs`),r=_(n),i=jn(r,t.bundlePath),a=(t.directHandlers??[]).map(e=>{let t=jn(r,e.bundlePath);return{importSpecifier:t,isOwnBundle:t===i,queuePrefix:e.queuePrefix}});await S(r,{recursive:!0}),await D(n,Nn({bundlePath:i,directHandlers:a,runtimeImportSpecifier:t.runtimeImportSpecifier})),e.options.handlers.push({handler:n,route:t.route})}function Nn(e){let t=[`// Generated by Ash. Do not edit by hand.`,`import { POST } from ${JSON.stringify(e.bundlePath)};`];if(e.directHandlers.length>0&&e.runtimeImportSpecifier!==void 0){let n=0,r=e.directHandlers.map(e=>{if(e.isOwnBundle)return{...e,binding:`POST`};let t=`__ashWorkflowDirectHandler${n}`;return n+=1,{...e,binding:t}});for(let e of r)e.isOwnBundle||t.push(`import { POST as ${e.binding} } from ${JSON.stringify(e.importSpecifier)};`);t.push(`import { getWorld as __ashGetWorkflowWorld } from ${JSON.stringify(e.runtimeImportSpecifier)};`,``,`try {`,` const __ashWorkflowWorld = await __ashGetWorkflowWorld();`,` if (typeof __ashWorkflowWorld?.registerHandler === "function") {`);for(let e of r)t.push(` __ashWorkflowWorld.registerHandler(${JSON.stringify(e.queuePrefix)}, ${e.binding});`);t.push(` }`,`} catch (err) {`,` console.warn("[ash] Failed to register direct workflow queue handlers:", err);`,`}`)}return t.push(``,`export default async ({ req }) => {`,` return await POST(req);`,`};`,``),t.join(`
|
|
64
|
-
`)}function Pn(e,t){let r=`#ash-route${t.route}`,i=n(t.modulePath);e.options.handlers.push({handler:r,method:t.method,route:t.route}),e.options.virtual[r]=[`import { ${t.handlerExport} } from ${i};`,`export default async (event) => ${t.handlerExport}(${t.args}, event.req);`].join(`
|
|
65
|
-
`)}async function Fn(e,n,r){if(An(r.surface)){let t=f(),i=new un({appRoot:n.appRoot,compiledArtifactsBootstrapPath:n.compiledArtifacts.bootstrapPath,outDir:n.workflowBuildDir,rootDir:t,watch:e.options.dev}),a=Promise.resolve(),o=async()=>{await i.build({nitroStepOutfile:W(r.surface)?v(K(e),`steps.mjs`):void 0,nitroWorkflowOutfile:e.options.dev&&W(r.surface)?v(K(e),`workflows.mjs`):void 0})},s=async()=>{let e=a.then(o);a=e.catch(()=>{}),await e},c=!0;await s(),e.hooks.hook(`build:before`,async()=>{if(c){c=!1;return}await s()}),e.options.dev&&e.hooks.hook(`dev:reload`,async()=>{await s()})}let i=re({appRoot:n.appRoot,dev:e.options.dev});kn(r.surface)&&(G(e,{handlerPath:d(`src/internal/nitro/routes/index.ts`),method:`GET`,route:`/`}),G(e,{handlerPath:d(`src/internal/nitro/routes/health.ts`),method:`GET`,route:te}),Pn(e,{args:JSON.stringify({appRoot:i.appRoot}),handlerExport:`handleAgentInfoRequest`,method:`GET`,modulePath:d(`src/internal/nitro/routes/info.ts`),route:ee}),G(e,{handlerPath:d(`src/internal/nitro/routes/workflow-runs.ts`),method:`GET`,route:Tn}),G(e,{handlerPath:d(`src/internal/nitro/routes/workflow-run.ts`),method:`GET`,route:En}),G(e,{handlerPath:d(`src/internal/nitro/routes/workflow-run-steps.ts`),method:`GET`,route:Dn}),G(e,{handlerPath:d(`src/internal/nitro/routes/workflow-run-events.ts`),method:`GET`,route:On}),ae(e,{artifactsConfig:i,registrations:ne(n)}));let a=K(e),o=W(r.surface)?e.options.dev?v(a,`workflows.mjs`):v(n.workflowBuildDir,`workflows.mjs`):void 0,s=e.options.dev&&o!==void 0?[{bundlePath:o,queuePrefix:`__wkf_workflow_`}]:[],c=s.length>0?t(u(`workflow/runtime`)):void 0;o&&await Mn(e,{bundleName:`workflows`,bundlePath:o,directHandlers:s,route:`/.well-known/workflow/v1/flow`,runtimeImportSpecifier:c}),e.routing.sync()}function In(){return`${g}/cron/${me()}`}function Ln(e){e.options.vercel!==void 0&&(e.options.vercel.cronHandlerRoute=In())}function Rn(e){return{plugins:[c(),...e]}}function zn(e){e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`ash:nitro-routing-import-specifiers`,transform(e,t){if(t!==`#nitro/virtual/routing`&&t!==`#nitro/virtual/routing-meta`)return null;let n=a(e);return n===e?null:{code:n,map:null}}})})}const Bn=`@alinea/generated.@appsignal/nodejs.@aws-sdk/client-s3.@aws-sdk/s3-presigned-post.@blockfrost/blockfrost-js.@highlight-run/node.@huggingface/transformers.@jpg-store/lucid-cardano.@libsql/client.@mikro-orm/core.@mikro-orm/knex.@node-rs/argon2.@node-rs/bcrypt.@prisma/client.@react-pdf/renderer.@sentry/profiling-node.@sparticuz/chromium.@sparticuz/chromium-min.@statsig/statsig-node-core.@swc/core.@xenova/transformers.@zenstackhq/runtime.argon2.autoprefixer.aws-crt.bcrypt.better-sqlite3.canvas.chromadb-default-embed.config.cpu-features.cypress.dd-trace.eslint.express.firebase-admin.htmlrewriter.import-in-the-middle.isolated-vm.jest.jsdom.keyv.libsql.mdx-bundler.mongodb.mongoose.newrelic.next-mdx-remote.next-seo.node-cron.node-pty.node-web-audio-api.onnxruntime-node.oslo.pg.pino.pino-pretty.pino-roll.playwright.playwright-core.postcss.prettier.prisma.puppeteer.puppeteer-core.ravendb.require-in-the-middle.rimraf.sharp.shiki.sqlite3.thread-stream.ts-morph.ts-node.typescript.vscode-oniguruma.webpack.websocket.zeromq`.split(`.`);function Vn(e){if(e)return{config:{version:3,framework:{version:h().version}}}}const Hn=[`workflow`,`workflow/api`,`workflow/errors`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`],Un=Symbol(`ash.workflow-transform-patched`),Wn=[`@napi-rs/keyring`];function Gn(){let e={};for(let t of Hn)e[t]=u(t);return e}function Kn(e){if(!e&&process.env.VERCEL)return`vercel`}function qn(e){return e===`all`||e===`app`}function Jn(e){return e===`all`||e===`flow`}function Yn(e){return Jn(e)}function Xn(e,t){return e.options.dev?v(e.options.buildDir,`workflow`,`steps.mjs`):v(t.workflowBuildDir,`steps.mjs`)}function Zn(e){let t=e.compileResult.manifest.config.build;return[...new Set([...Wn,...Bn,...t?.externalDependencies??[]])].filter(e=>e!==p)}function q(e){return e.replaceAll(`\\`,`/`)}function Qn(e){let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function $n(e){return e.startsWith(`/@fs/`)?e.slice(4):e}function J(e,t){return t.startsWith(`file://`)?q($n(Qn(_e(t)))):ue(t)?q($n(Qn(t))):q($n(Qn(b(e,t))))}function er(e,t){let n=q(e);return n.startsWith(t)||n.includes(`/.ash/workflow-cache/`)}function tr(e){let t=q(e);return process.platform===`win32`?t.toLowerCase():t}function nr(e){let t=/^\s*import\s+(?:.+?\s+from\s+)?["']([^"']+)["'];?\s*$/gm,n=[];for(let r of e.matchAll(t)){let e=r[1];e!==void 0&&n.push(e)}return n}function rr(e,t,n){return t.startsWith(`workflow`)?u(t):t.startsWith(`.`)||t.startsWith(`/`)||t.startsWith(`file://`)?J(n===void 0?e:_(J(e,n)),t):null}async function ir(e,t){let n=await C(e,`utf8`),r=new Set;for(let i of nr(n)){let n=rr(t,i,e);n!==null&&r.add(tr(n))}return r}async function ar(e,t){if(e.options.noExternals===!0)return;let n;try{n=await ir(t,e.options.rootDir)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let r=Array.isArray(e.options.noExternals)?[...e.options.noExternals]:[];e.options.noExternals=[...new Set([...r,...n])]}function or(e,t){let n=q(e).replace(/\/$/,``),r=q(t),i=n.toLowerCase(),a=r.toLowerCase();if(a.startsWith(`${i}/`))return r.slice(n.length+1);if(a===i)return`.`;let o=y(n,r).replaceAll(`\\`,`/`);if(o.startsWith(`../`)&&(o=o.split(`/`).filter(e=>e!==`..`).join(`/`)),o.includes(`:`)||o.startsWith(`/`)){let e=r.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return o}function sr(e,t){let n=[t,v(e.options.buildDir,`workflow`)].map(t=>J(e.options.rootDir,t));e.hooks.hook(`rollup:before`,(t,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`ash:workflow-module-side-effects`,resolveId(t,r){let i=rr(e.options.rootDir,t,r)??J(e.options.rootDir,t);return n.some(e=>er(i,e))?{id:i,moduleSideEffects:`no-treeshake`}:null}})})}function cr(e,t){let n=null,r=async()=>(n===null&&(n=await ir(t.stepEntrypointPath,e.options.rootDir)),n);e.hooks.hook(`build:before`,()=>{n=null}),e.options.dev&&e.hooks.hook(`dev:reload`,()=>{n=null}),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({name:`ash:workflow-step-module-side-effects`,async resolveId(t,n){let i=rr(e.options.rootDir,t,n);return i===null||!(await r()).has(tr(i))?null:{id:i,moduleSideEffects:`no-treeshake`}}})})}function lr(e,t){let n=null,r=async()=>(n===null&&(n=await ir(t.stepEntrypointPath,e.options.rootDir)),n);e.hooks.hook(`build:before`,()=>{n=null}),e.options.dev&&e.hooks.hook(`dev:reload`,()=>{n=null}),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({async transform(t,n){let i=await r(),a=J(e.options.rootDir,n);return i.has(tr(a))?{code:(await j(or(e.options.rootDir,a),t,`step`,a,e.options.rootDir)).code,map:null}:null},name:`ash:workflow-step-transform`})})}function ur(e,t){let n=q(t);e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`ash:instrumentation-module-side-effects`,resolveId(e){return q(e)===n?{id:e,moduleSideEffects:`no-treeshake`}:null}})})}function dr(e,t){let n=q(t);e.hooks.hook(`rollup:before`,(e,t)=>{if(Array.isArray(t.plugins))for(let e of t.plugins){if(typeof e!=`object`||!e)continue;let t=e;if(t.name!==`workflow:transform`||t[Un]===!0||typeof t.transform!=`function`)continue;let r=t.transform;t.transform=function(e,t,...i){return er(t,n)?null:r.call(this,e,t,...i)},t[Un]=!0}})}async function Y(e,t,n={}){let r=n.surface??`all`,a=(!t||n.schedules===!0)&&qn(r)&&e.scheduleRegistrations.length>0,o=Kn(t),s=o===`vercel`?wn():null,c=s===null?[]:[s],l=Rn(c),u=Rn(c),f=Zn(e),p=i(e.appRoot,r),h=e.compiledArtifacts.instrumentationPluginPath===void 0?[e.compiledArtifacts.bootstrapPath]:[e.compiledArtifacts.instrumentationPluginPath,e.compiledArtifacts.bootstrapPath];await Ee(p);let g=await Se({_cli:{command:t?`dev`:`build`},buildDir:p,dev:t,logLevel:t?1:void 0,output:n.outputDir===void 0?void 0:{dir:n.outputDir},preset:o,plugins:h,publicAssets:[],scanDirs:Yn(r)?[m(`src/execution`)]:void 0,rolldownConfig:l,rollupConfig:u,rootDir:e.appRoot,serverDir:!1,traceDeps:f,vercel:Vn(o===`vercel`&&qn(r))},t?{watch:!0}:void 0);if(await O(p),zn(g),Jn(r)){let t=Gn();for(let[e,n]of Object.entries(t))g.options.alias[e]=n;sr(g,e.workflowBuildDir),dr(g,e.workflowBuildDir)}if(Yn(r)){let t=Xn(g,e);cr(g,{stepEntrypointPath:t}),lr(g,{stepEntrypointPath:t})}if(e.compiledArtifacts.instrumentationSourcePath!==void 0&&ur(g,e.compiledArtifacts.instrumentationSourcePath),t&&Jn(r)){let t=e.workflowBuildDir,n=new Set([q(v(t,`workflows.mjs`))]);g.hooks.hook(`rollup:before`,(e,t)=>{let r=t.external;t.external=(e,...t)=>{if(n.has(q(e)))return!0;if(typeof r==`function`)return r(e,...t)}})}return a&&(Ln(g),oe(g,{artifactsConfig:re({appRoot:e.appRoot,dev:g.options.dev}),dispatchModulePath:d(`src/internal/nitro/routes/schedule-task.ts`),registrations:e.scheduleRegistrations})),await Fn(g,e,{surface:r}),Yn(r)&&await ar(g,Xn(g,e)),g}function fr(e){if(typeof e!=`string`||e.length===0)return`unknown`;let t=e.toLowerCase();return t===`slack`||t.includes(`slack`)?`slack`:t===`http`?`http`:t.includes(`webhook`)?`webhook`:`unknown`}function pr(e){let{manifest:t}=e;return{kind:`vercel-ash-agent-summary`,schemaVersion:2,generatorVersion:e.generatorVersion??h().version,agent:{name:t.config.name,description:t.config.description,modelId:t.config.model.id},instructions:t.instructions?gr(t.instructions):null,schedules:t.schedules.map(_r),tools:t.tools.map(vr),skills:t.skills.map(yr),connections:t.connections.map(br),channels:t.channels.filter(hr).map(xr),sandbox:t.sandbox===null?null:{logicalPath:t.sandbox.logicalPath},subagents:t.subagents.map(Sr),diagnostics:{errors:t.diagnosticsSummary.errors,warnings:t.diagnosticsSummary.warnings}}}async function mr(e){let t=pr({generatorVersion:e.generatorVersion,manifest:e.manifest}),n=v(e.appRoot,`.ash/agent-summary.json`);return await S(_(n),{recursive:!0}),await D(n,`${JSON.stringify(t,null,2)}\n`),n}function hr(e){return e.kind===`channel`}function gr(e){return{logicalPath:e.logicalPath,sourceKind:e.sourceKind,markdown:e.markdown}}function _r(e){return{name:e.name,cron:e.cron,logicalPath:e.logicalPath}}function vr(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function yr(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath,sourceKind:e.sourceKind}}function br(e){let t={name:e.connectionName,description:e.description,url:e.url,logicalPath:e.logicalPath,type:`mcp`};return e.vercelConnect===void 0?t:{...t,vercelConnect:{connector:e.vercelConnect.connector}}}function xr(e){let t={name:e.name,method:e.method,urlPath:e.urlPath,type:fr(e.adapterKind),logicalPath:e.logicalPath};return e.adapterKind===void 0?t:{...t,adapterKind:e.adapterKind}}function Sr(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function Cr(){let e=process.env.VERCEL?.trim(),t=process.env.VERCEL_DEPLOYMENT_ID?.trim();return typeof e==`string`&&e.length>0&&typeof t==`string`&&t.length>0}async function wr(e){return Cr()?(await se(e),!0):!1}function Tr(e){return e.replace(/[\\/]+$/,``)}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Er(e,t){return typeof t!=`string`||t.trim().length===0?null:b(e,t)}function Dr(e){if(!X(e.config)||!X(e.config.experimentalServices))return;let t=!1,n;for(let r of Object.values(e.config.experimentalServices)){if(!X(r))continue;if(r.framework===`nextjs`){t=!0;continue}if(r.framework!==`ash`)continue;let i=Er(e.configRoot,r.entrypoint),a=typeof r.routePrefix==`string`?r.routePrefix.trim():``;i===e.appRoot&&a.length>0&&a!==`/`&&(n=a)}return t?n:void 0}async function Or(e){let t=e;for(;;){try{let n=v(t,`vercel.json`),r=JSON.parse(await C(n,`utf8`)),i=Dr({appRoot:e,configRoot:t,config:r});if(i!==void 0)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let n=_(t);if(n===t)return;t=n}}async function kr(e){try{return JSON.parse(await C(v(e,`functions`,`__server.func`,`.vc-config.json`),`utf8`)).runtime}catch{return}}async function Ar(e){let t=new un({appRoot:e.appRoot,compiledArtifactsBootstrapPath:e.compiledArtifactsBootstrapPath,outDir:e.workflowBuildDir,rootDir:f(),watch:!1}),n=await kr(e.outputDir);await t.buildVercelOutput({flowNitroOutputDir:e.flowNitroOutputDir,outputDir:e.outputDir,runtime:n})}async function jr(e){let t=Tr(e.options.output.dir);return await Ee(t),await Ce(e),await be(e),await we(e),await ye(e),await O(t),t}async function Mr(e,t){let n=await Y(e,!1,{outputDir:r(e.appRoot,t),surface:t});try{return await jr(n)}finally{await n.close()}}async function Nr(e){let t=await ie(e);if(!process.env.VERCEL){let e=await Y(t,!1);try{let n=await jr(e);return await mr({manifest:t.compileResult.manifest,appRoot:t.appRoot}),n}finally{await e.close()}}let n=await Y(t,!1,{surface:`app`});try{let e=await jr(n);await wr({appRoot:t.appRoot,log(e){console.log(e)}});let r=await Mr(t,`flow`);await Ar({appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,flowNitroOutputDir:r,outputDir:e,workflowBuildDir:t.workflowBuildDir});let i=await Or(t.appRoot);return i!==void 0&&await Qt(e,{servicePrefix:i}),await mr({manifest:t.compileResult.manifest,appRoot:t.appRoot}),e}finally{await n.close()}}const Z=65535,Q=`WORKFLOW_LOCAL_BASE_URL`,$=`PORT`,Pr=new Set([`[::]`,`::`,`0.0.0.0`]);function Fr(e){let t=new URL(e);return Pr.has(t.hostname)?(t.hostname=`127.0.0.1`,t.toString()):e}function Ir(e){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`}function Lr(e){let t=typeof e==`string`?Number(e):e??3e3;if(!Number.isInteger(t)||t<0||t>Z)throw Error(`Invalid development server port "${String(e)}". Expected an integer between 0 and ${Z}.`);return t}function Rr(){let e=process.env[$];if(e===void 0||e.trim()===``)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>Z)throw Error(`Invalid ${$} environment variable "${e}". Expected an integer between 0 and ${Z}.`);return t}function zr(e){let t=Lr(e.port);if(t===0||!e.retryOnAddressInUse)return[t];let n=[];for(let e=0;e<10;e+=1){let r=t+e;if(r>65535)break;n.push(r)}return n}function Br(e){let t=process.env[Q],n=process.env[$],r=new URL(Fr(e));return process.env[Q]=r.origin,r.port&&(process.env[$]=r.port),()=>{t===void 0?delete process.env[Q]:process.env[Q]=t,n===void 0?delete process.env[$]:process.env[$]=n}}function Vr(e){let t=()=>{};return e.once(`error`,t),()=>{e.off(`error`,t)}}function Hr(e){let t=e.upgrade.bind(e);e.upgrade=async(e,n,r)=>{let i=Vr(n);try{await t(e,n,r)}catch{n.destroyed||n.destroy()}finally{i()}}}async function Ur(e){let t=zr({port:e.port,retryOnAddressInUse:e.retryOnAddressInUse}),n;for(let r of t){let t=e.devServer.listen({hostname:e.host,port:r,silent:!0});try{return await t.ready(),t}catch(r){if(n=r,await t.close().catch(()=>{}),!Ir(r)||!e.retryOnAddressInUse)throw r}}throw Error(`Failed to start Nitro dev server after ${t.length} attempts. Tried ports ${t.join(`, `)}.`,{cause:n})}async function Wr(e,t={}){let n=t.schedules===!0,r=await ie(e);await se({appRoot:r.appRoot,log:e=>console.log(e)});let i=await Y(r,!0,{schedules:n}),a=xe(i);Hr(a);let o=t.host??i.options.devServer.hostname,s=t.port??Rr(),c=s??i.options.devServer.port,l=s===void 0,u;try{let e=await Ur({devServer:a,host:o,port:c,retryOnAddressInUse:l});if(!e.url)throw Error(`Nitro dev server did not expose a URL.`);u=Br(e.url),await Ce(i),await ye(i);let{startAuthoredSourceWatcher:t}=await import(`./dev-authored-source-watcher-d_35Mp8T.js`),s=await t({nitro:i,preparedHost:r,schedulesEnabled:n}),d=u;if(d===void 0)throw Error(`Workflow local queue environment was not initialized.`);return{async close(){try{await s.close(),await a.close(),await i.close()}finally{d()}},url:Fr(e.url)}}catch(e){throw u?.(),await a.close().catch(()=>{}),await i.close().catch(()=>{}),e}}var Gr=e({buildHost:()=>Kr,startHost:()=>qr});async function Kr(e){return await Nr(e)}async function qr(e,t={}){return await Wr(e,t)}export{qr as n,Gr as t};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{E as e,S as t,T as n,_ as r,a as i,c as a,d as o,g as s,h as c,l,m as u,p as ee,s as te,u as d,x as f,y as p}from"./paths-YoCQlavu.js";import{t as m}from"./authored-module-loader-XcFLnl49.js";import{t as h}from"./errors-DsO9xmQL.js";import{i as g,t as _}from"./package-DmsQgn4v.js";import{join as v,posix as y}from"node:path";import{mkdir as ne,readFile as re,readdir as ie,realpath as b,writeFile as x}from"node:fs/promises";import{createHash as S}from"node:crypto";import{existsSync as C}from"node:fs";function w(e){return e.dev?{appRoot:e.appRoot,dev:e.dev,moduleMapLoaderPath:g(`src/internal/authored-module-map-loader.ts`)}:{appRoot:e.appRoot,dev:e.dev}}const T=`#ash-channel/`;function E(e){let t=e.compileResult.manifest.channels,n=new Set,r=[],i=new Set,o=a();for(let e of t){if(e.kind===`disabled`){if(!o.has(e.name))throw Error(`agent/channels/${e.name}.ts exports disableRoute() but "${e.name}" is not a framework channel. Rename the file to one of: ${[...o].sort().join(`, `)}.`);i.add(e.name);continue}n.add(e.name),r.push({method:e.method,route:e.urlPath})}let s=l().filter(e=>!n.has(e.name)&&!i.has(e.name)).map(e=>({method:e.method,route:e.urlPath})),c=new Set,u=[];for(let e of[...s,...r]){let t=k(e);c.has(t)||(c.add(t),u.push(e))}return u}function D(e,t){for(let n of t.registrations)A(e,{artifactsConfig:t.artifactsConfig,method:n.method,route:n.route})}function O(e,t){return N(t.previous,t.next)?!1:(j(e),D(e,{artifactsConfig:t.artifactsConfig,registrations:t.next}),e.routing.sync(),!0)}function k(e){return`${e.method.toUpperCase()} ${e.route}`}function A(e,t){let r=k(t),i=`${T}${r}`,a=n(g(`src/internal/nitro/routes/channel-dispatch.ts`));e.options.handlers.push({handler:i,method:t.method,route:t.route}),e.options.virtual[i]=[`import { dispatchChannelRequest } from ${a};`,`const config = ${JSON.stringify(t.artifactsConfig)};`,`export default (event) => dispatchChannelRequest(event, ${JSON.stringify(r)}, config);`].join(`
|
|
2
|
-
`)}function j(e){for(let t=e.options.handlers.length-1;t>=0;--t){let n=e.options.handlers[t];n!==void 0&&M(n)&&e.options.handlers.splice(t,1)}for(let t of Object.keys(e.options.virtual))t.startsWith(T)&&delete e.options.virtual[t]}function M(e){return e.handler.startsWith(T)}function N(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r===void 0||i===void 0||r.method!==i.method||r.route!==i.route)return!1}return!0}const P=`ash.schedule.`;var F=class extends Error{scheduleId;sourceId;taskName;constructor(e,t={}){super(e),this.name=`ScheduleRegistrationError`,t.scheduleId!==void 0&&(this.scheduleId=t.scheduleId),t.sourceId!==void 0&&(this.sourceId=t.sourceId),t.taskName!==void 0&&(this.taskName=t.taskName)}};function I(e){let t=e.map(e=>({cron:e.cron,description:`Run Ash schedule "${e.name}" from "${e.logicalPath}".`,logicalPath:e.logicalPath,scheduleId:e.name,sourceId:e.sourceId,taskName:R(e.sourceId)})).sort((e,t)=>e.sourceId.localeCompare(t.sourceId));return L(t),t}function L(e){let t=new Map;for(let n of e){let e=t.get(n.scheduleId);if(e===void 0){t.set(n.scheduleId,n);continue}throw new F(`Duplicate authored schedule id "${n.scheduleId}" found in "${e.logicalPath}" and "${n.logicalPath}".`,{scheduleId:n.scheduleId,sourceId:n.sourceId,taskName:n.taskName})}}function R(e){return`${P}${Buffer.from(e,`utf8`).toString(`base64url`)}`}const z=`#ash-schedule-task/`;function B(e,t){if(t.registrations.length!==0){e.options.experimental.tasks=!0;for(let n of t.registrations)U(e,{artifactsConfig:t.artifactsConfig,dispatchModulePath:t.dispatchModulePath,registration:n})}}function V(e,t){let n=!G(t.previous,t.next);return H(e),B(e,{artifactsConfig:t.artifactsConfig,dispatchModulePath:t.dispatchModulePath,registrations:t.next}),n}function H(e){for(let t of Object.keys(e.options.tasks))t.startsWith(`ash.schedule.`)&&delete e.options.tasks[t];for(let t of Object.keys(e.options.virtual))t.startsWith(z)&&delete e.options.virtual[t];for(let[t,n]of Object.entries(e.options.scheduledTasks)){let r=W(n).filter(e=>!e.startsWith(P));if(r.length===0){delete e.options.scheduledTasks[t];continue}if(r.length===1){let[n]=r;n!==void 0&&(e.options.scheduledTasks[t]=n);continue}e.options.scheduledTasks[t]=r}}function U(e,t){let r=`${z}${t.registration.taskName}`,i=n(t.dispatchModulePath);e.options.tasks[t.registration.taskName]={description:t.registration.description,handler:r},e.options.virtual[r]=[`import { dispatchScheduleTask } from ${i};`,`const config = ${JSON.stringify(t.artifactsConfig)};`,`export default {`,` meta: { description: ${JSON.stringify(t.registration.description)} },`,` async run(event) {`,` return { result: await dispatchScheduleTask(event.name, config) };`,` },`,`};`].join(`
|
|
3
|
-
`),ae(e,t.registration.cron,t.registration.taskName)}function ae(e,t,n){let r=e.options.scheduledTasks[t];if(r===void 0){e.options.scheduledTasks[t]=n;return}if(typeof r==`string`){e.options.scheduledTasks[t]=[r,n];return}r.includes(n)||r.push(n)}function W(e){return typeof e==`string`?[e]:[...e]}function G(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r===void 0||i===void 0||r.cron!==i.cron||r.description!==i.description||r.logicalPath!==i.logicalPath||r.scheduleId!==i.scheduleId||r.sourceId!==i.sourceId||r.taskName!==i.taskName)return!1}return!0}async function K(e){return[...e.manifest.schedules].map(e=>{let t={cron:e.cron,hasRun:e.hasRun,logicalPath:e.logicalPath,name:e.name,sourceId:e.sourceId,sourceKind:e.sourceKind};return e.markdown===void 0?t:{...t,markdown:e.markdown}})}async function q(e){return await K({manifest:await o({compiledArtifactsSource:e.compiledArtifactsSource})})}async function J(e){let t=v(e.outDir,`compiled-artifacts-bootstrap.mjs`),n=v(e.outDir,`compiled-artifacts-instrumentation.mjs`),r=se(e.compileResult.manifest.agentRoot);await ne(e.outDir,{recursive:!0}),await x(t,await le({compileResult:e.compileResult,installModulePath:g(`src/runtime/loaders/bundled-artifacts.ts`),moduleMapPath:t,metadata:e.compileResult.metadata})),r!==void 0&&await x(n,ue({agentName:e.compileResult.manifest.config.name,instrumentationPath:r,registerConfigPath:g(`src/harness/instrumentation-config.ts`)}));let i={bootstrapPath:t};return r!==void 0&&(i.instrumentationPluginPath=n,i.instrumentationSourcePath=r),i}const oe=[`.ts`,`.mts`,`.js`,`.mjs`];function se(e){for(let t of oe){let n=v(e,`instrumentation${t}`);if(C(n))return n}}function ce(e){return e.replace(/^export const moduleMap = /m,`const moduleMap = `).replace(/\nexport default moduleMap;\n?$/,`
|
|
4
|
-
`)}async function le(e){let r=ce(t({importSpecifierStyle:`absolute`,manifest:e.compileResult.manifest,moduleMapPath:e.moduleMapPath})).trim();return[`// Generated by Ash. Do not edit by hand.`,`import { installBundledCompiledArtifacts } from ${n(e.installModulePath)};`,``,r,``,`const metadata = ${JSON.stringify(e.metadata,null,2)};`,``,`const manifest = ${JSON.stringify(e.compileResult.manifest,null,2)};`,``,`export function installCompiledArtifactsBootstrap() {`,` installBundledCompiledArtifacts({`,` manifest,`,` metadata,`,` moduleMap,`,` });`,`}`,``,`installCompiledArtifactsBootstrap();`,``,`// Default export satisfies the Nitro plugin contract so this file`,`// can be used directly as a Nitro plugin without a separate wrapper.`,`export default function installCompiledArtifactsPlugin() {`,` // Already installed on import above.`,`}`,``,`export async function __ashInstallCompiledArtifactsStep() {`,` "use step";`,` return null;`,`}`,``].join(`
|
|
5
|
-
`)}function ue(e){return[`// Generated by Ash. Do not edit by hand.`,`import * as instrumentationModule from ${n(e.instrumentationPath)};`,`import { registerInstrumentationConfig } from ${n(e.registerConfigPath)};`,``,`if (instrumentationModule.default != null) {`,` registerInstrumentationConfig(instrumentationModule.default, { agentName: ${JSON.stringify(e.agentName)} });`,`}`,``,`// Default export satisfies the Nitro plugin contract so this file`,`// can be used directly as a Nitro plugin without a separate wrapper.`,`export default function installInstrumentationPlugin() {}`,``].join(`
|
|
6
|
-
`)}function Y(e){return c(e,{moduleMapLoaderPath:g(`src/internal/authored-module-map-loader.ts`),moduleMapLoadMode:`authored-source`})}async function de(e){let t=await p({startPath:e}),n=await q({compiledArtifactsSource:Y(t.project.appRoot)}),r=I(n),a=i(t.project.appRoot),o=await J({compileResult:t,outDir:t.paths.compileDirectoryPath});return{appRoot:t.project.appRoot,compileResult:t,compiledArtifacts:o,scheduleRegistrations:r,schedules:n,workflowBuildDir:a}}async function fe(e){return await pe(await o({compiledArtifactsSource:e.compiledArtifactsSource}))}async function pe(t){let n={},r=[{agentRoot:t.agentRoot,manifest:t,nodeId:e},...[...t.subagents].sort((e,t)=>e.nodeId.localeCompare(t.nodeId)).map(e=>({agentRoot:e.agent.agentRoot,manifest:e.agent,nodeId:e.nodeId}))];for(let e of r)n[e.nodeId]={modules:await me({agentRoot:e.agentRoot,manifest:e.manifest})};return{nodes:n}}async function me(e){let t=f(e.manifest).sort((e,t)=>e.sourceId.localeCompare(t.sourceId)),n={};for(let r of t){let t=v(e.agentRoot,r.logicalPath);n[r.sourceId]=await m(t)}return n}async function he(e){let t=await ge(e.backendName,e.compiledArtifactsSource),n=await _e({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:e.nodeId,sourceId:e.sourceId}),r=X(`${_().version}:2:${n}`).slice(0,20);return ve(`ash-sbx-tpl-${e.backendName}-${t}-${r}`)}async function ge(e,t){if(e===`vercel`){let e=process.env.VERCEL_DEPLOYMENT_ID?.trim();if(e!==void 0&&e.length>0)return X(e).slice(0,16)}let n=s(t);return n===void 0?X(r(t)).slice(0,16):X(await b(n)).slice(0,16)}async function _e(e){return X(`${(await ee({compiledArtifactsSource:e.compiledArtifactsSource}))?.discovery.sourceGraphHash??r(e.compiledArtifactsSource)}:${e.nodeId}:${e.sourceId}`)}function X(e){return S(`sha256`).update(e).digest(`hex`)}function ve(e){return e.replaceAll(/[^a-zA-Z0-9._-]+/g,`-`).slice(0,120)}async function ye(e){let t=[];return await Z({files:t,logicalDirectoryPath:`.`,sourceDirectoryPath:e}),t.sort((e,t)=>e.path.localeCompare(t.path)),t}async function Z(e){let t=await ie(e.sourceDirectoryPath,{withFileTypes:!0});for(let n of t){if(!n.isDirectory()&&!n.isFile())continue;let t=v(e.sourceDirectoryPath,n.name),r=y.join(e.logicalDirectoryPath,n.name);if(n.isDirectory()){await Z({files:e.files,logicalDirectoryPath:r,sourceDirectoryPath:t});continue}e.files.push({content:await re(t),path:y.join(d,r)})}}async function be(e){let t=await Q(e);if(t.length===0)return;e.log?.(`Ash: initializing ${t.length} sandbox ${$(t.length,`template`)}...`);let n=e.dispatch??(async({backend:e,input:t})=>{await e.prewarm(t)});await Promise.all(t.map(async({backend:t,label:r,input:i})=>{e.log?.(`Ash: initializing sandbox template "${r}"...`);try{await n({backend:t,input:i})}catch(n){throw e.log?.(`Ash: failed to initialize sandbox template "${r}" on backend "${t.name}": ${h(n)}`),n}e.log?.(`Ash: sandbox template "${r}" initialized.`)})),e.log?.(`Ash: initialized ${t.length} sandbox ${$(t.length,`template`)}.`)}async function xe(e){let t=Y(e.appRoot),n=await(e.loadAgentGraph??Ce)({compiledArtifactsSource:t});await be({compiledArtifactsSource:t,dispatch:e.dispatch,graph:n,log:e.log})}async function Q(e){let t=u(e.compiledArtifactsSource.appRoot).compileDirectoryPath,n={appRoot:e.compiledArtifactsSource.appRoot};return[...await Promise.all(we(e.graph).map(async({definition:r,nodeId:i,workspaceResourceRoot:a})=>{let o=await he({backendName:r.backend.name,compiledArtifactsSource:e.compiledArtifactsSource,nodeId:i,sourceId:r.sourceId});return{backend:r.backend,label:Te(i),input:{bootstrap:r.bootstrap,seedFiles:await Se({compileDirectoryPath:t,workspaceResourceRoot:a}),runtimeContext:n,templateKey:o}}}))].sort((e,t)=>e.label.localeCompare(t.label))}async function Se(e){return e.workspaceResourceRoot.rootEntries.length===0?[]:(await ye(`${e.compileDirectoryPath}/${e.workspaceResourceRoot.logicalPath}`)).map(e=>({content:e.content,path:e.path}))}async function Ce(e){let[t,n]=await Promise.all([o({compiledArtifactsSource:e.compiledArtifactsSource}),fe({compiledArtifactsSource:e.compiledArtifactsSource})]);return await te({manifest:t,moduleMap:n})}function we(e){return[...e.nodesByNodeId.entries()].flatMap(([e,t])=>{let n=t.sandboxRegistry.sandbox;return n===null?[]:[{...n,nodeId:e}]})}function $(e,t){return e===1?t:`${t}s`}function Te(e){return e===`__root__`?`root`:e}export{E as a,w as c,V as i,de as n,D as o,B as r,O as s,xe as t};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,t as n}from"./chunk-DHhdAPOb.js";import{A as r,D as i,M as a,N as o,O as s,a as c,j as l,k as u,l as d,o as f,r as p,t as m,x as h}from"./dist-0iNBqPYp.js";import{S as g,_,a as v,b as y,c as b,h as ee,i as x,l as S,n as te,o as C,r as w,s as T,t as E,u as ne,x as re}from"./symbols-D-4tVV8x.js";import{a as ie,p as ae,s as oe}from"./dist-D774SUM4.js";import{getStepFunction as se}from"../../@workflow/core/private.js";import{types as ce}from"node:util";import{AsyncLocalStorage as le}from"node:async_hooks";var ue=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,{CITY_HEADER_NAME:()=>u,COUNTRY_HEADER_NAME:()=>d,EMOJI_FLAG_UNICODE_STARTING_POSITION:()=>v,IP_HEADER_NAME:()=>f,LATITUDE_HEADER_NAME:()=>p,LONGITUDE_HEADER_NAME:()=>m,POSTAL_CODE_HEADER_NAME:()=>g,REGION_HEADER_NAME:()=>h,REQUEST_ID_HEADER_NAME:()=>_,geolocation:()=>te,ipAddress:()=>x}),t.exports=c(l);let u=`x-vercel-ip-city`,d=`x-vercel-ip-country`,f=`x-real-ip`,p=`x-vercel-ip-latitude`,m=`x-vercel-ip-longitude`,h=`x-vercel-ip-country-region`,g=`x-vercel-ip-postal-code`,_=`x-vercel-id`,v=127397;function y(e,t){return e.get(t)??void 0}function b(e,t){let n=y(e.headers,t);return n?decodeURIComponent(n):void 0}function ee(e){let t=RegExp(`^[A-Z]{2}$`).test(e);if(!(!e||!t))return String.fromCodePoint(...e.split(``).map(e=>v+e.charCodeAt(0)))}function x(e){return y(`headers`in e?e.headers:e,f)}function S(e){return e?e.split(`:`)[0]:`dev1`}function te(e){return{city:b(e,u),country:y(e.headers,d),flag:ee(y(e.headers,d)),countryRegion:y(e.headers,h),region:S(y(e.headers,_)),latitude:y(e.headers,p),longitude:y(e.headers,m),postalCode:y(e.headers,g)}}})),de=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,{getEnv:()=>u}),t.exports=c(l);let u=(e=process.env)=>({VERCEL:d(e,`VERCEL`),CI:d(e,`CI`),VERCEL_ENV:d(e,`VERCEL_ENV`),VERCEL_URL:d(e,`VERCEL_URL`),VERCEL_BRANCH_URL:d(e,`VERCEL_BRANCH_URL`),VERCEL_PROJECT_PRODUCTION_URL:d(e,`VERCEL_PROJECT_PRODUCTION_URL`),VERCEL_REGION:d(e,`VERCEL_REGION`),VERCEL_DEPLOYMENT_ID:d(e,`VERCEL_DEPLOYMENT_ID`),VERCEL_SKEW_PROTECTION_ENABLED:d(e,`VERCEL_SKEW_PROTECTION_ENABLED`),VERCEL_AUTOMATION_BYPASS_SECRET:d(e,`VERCEL_AUTOMATION_BYPASS_SECRET`),VERCEL_GIT_PROVIDER:d(e,`VERCEL_GIT_PROVIDER`),VERCEL_GIT_REPO_SLUG:d(e,`VERCEL_GIT_REPO_SLUG`),VERCEL_GIT_REPO_OWNER:d(e,`VERCEL_GIT_REPO_OWNER`),VERCEL_GIT_REPO_ID:d(e,`VERCEL_GIT_REPO_ID`),VERCEL_GIT_COMMIT_REF:d(e,`VERCEL_GIT_COMMIT_REF`),VERCEL_GIT_COMMIT_SHA:d(e,`VERCEL_GIT_COMMIT_SHA`),VERCEL_GIT_COMMIT_MESSAGE:d(e,`VERCEL_GIT_COMMIT_MESSAGE`),VERCEL_GIT_COMMIT_AUTHOR_LOGIN:d(e,`VERCEL_GIT_COMMIT_AUTHOR_LOGIN`),VERCEL_GIT_COMMIT_AUTHOR_NAME:d(e,`VERCEL_GIT_COMMIT_AUTHOR_NAME`),VERCEL_GIT_PREVIOUS_SHA:d(e,`VERCEL_GIT_PREVIOUS_SHA`),VERCEL_GIT_PULL_REQUEST_ID:d(e,`VERCEL_GIT_PULL_REQUEST_ID`)}),d=(e,t)=>{let n=e[t];return n===``?void 0:n}})),fe=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?.()??{}}})),pe=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,{waitUntil:()=>d}),t.exports=c(l);var u=fe();let d=e=>{if(typeof e!=`object`||!e||typeof e.then!=`function`)throw TypeError(`waitUntil can only be called with a Promise, got ${typeof e}`);return(0,u.getContext)().waitUntil?.(e)}})),me=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,{next:()=>f,rewrite:()=>d}),t.exports=c(l);function u(e,t){if(e?.request?.headers){if(!(e.request.headers instanceof Headers))throw Error(`request.headers must be an instance of Headers`);let n=[];for(let[r,i]of e.request.headers)t.set(`x-middleware-request-`+r,i),n.push(r);t.set(`x-middleware-override-headers`,n.join(`,`))}}function d(e,t){let n=new Headers(t?.headers??{});return n.set(`x-middleware-rewrite`,String(e)),u(t,n),new Response(null,{...t,headers:n})}function f(e){let t=new Headers(e?.headers??{});return t.set(`x-middleware-next`,`1`),u(e,t),new Response(null,{...e,headers:t})}})),he=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,{InMemoryCache:()=>u}),t.exports=c(l);var u=class{constructor(){this.cache={}}async get(e){let t=this.cache[e];return t?t.ttl&&t.lastModified+t.ttl*1e3<Date.now()?(await this.delete(e),null):JSON.parse(t.value):null}async set(e,t,n){let r=JSON.stringify(t??null);this.cache[e]={value:r,lastModified:Date.now(),ttl:n?.ttl,tags:new Set(n?.tags||[])}}async delete(e){delete this.cache[e]}async expireTag(e){let t=Array.isArray(e)?e:[e];for(let e in this.cache)if(Object.prototype.hasOwnProperty.call(this.cache,e)){let n=this.cache[e];t.some(e=>n.tags.has(e))&&delete this.cache[e]}}}})),ge=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,{BuildCache:()=>d}),t.exports=c(l);var u=_e(),d=class{constructor({endpoint:e,headers:t,onError:n,timeout:r=500}){this.get=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{headers:this.headers,method:`GET`,signal:t.signal});if(r.status===404)return clearTimeout(n),null;if(r.status===200){if(r.headers.get(u.HEADERS_VERCEL_CACHE_STATE)!==u.PkgCacheState.Fresh)return r.body?.cancel?.(),clearTimeout(n),null;let e=await r.json();return clearTimeout(n),e}else throw clearTimeout(n),Error(`Failed to get cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e);return null}},this.set=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeout);try{let a={};n?.ttl&&(a[u.HEADERS_VERCEL_REVALIDATE]=n.ttl.toString()),n?.tags&&n.tags.length>0&&(a[u.HEADERS_VERCEL_CACHE_TAGS]=n.tags.join(`,`)),n?.name&&(a[u.HEADERS_VERCEL_CACHE_ITEM_NAME]=n.name);let o=await fetch(`${this.endpoint}${e}`,{method:`POST`,headers:{...this.headers,...a},body:JSON.stringify(t),signal:r.signal});if(clearTimeout(i),o.status!==200)throw Error(`Failed to set cache: ${o.status} ${o.statusText}`)}catch(e){if(clearTimeout(i),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.delete=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{method:`DELETE`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to delete cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.expireTag=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{Array.isArray(e)&&(e=e.join(`,`));let r=await fetch(`${this.endpoint}revalidate?tags=${e}`,{method:`POST`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to revalidate tag: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.endpoint=e,this.headers=t,this.onError=n,this.timeout=r}}})),_e=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,{HEADERS_VERCEL_CACHE_ITEM_NAME:()=>C,HEADERS_VERCEL_CACHE_STATE:()=>x,HEADERS_VERCEL_CACHE_TAGS:()=>te,HEADERS_VERCEL_REVALIDATE:()=>S,PkgCacheState:()=>ee,getCache:()=>g}),t.exports=c(l);var u=fe(),d=he(),f=ge();let p=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)},m=null,h=null,g=e=>v(()=>{let e;return e=(0,u.getContext)().cache?(0,u.getContext)().cache:b(process.env.SUSPENSE_CACHE_DEBUG===`true`),e},_(e));function _(e){let t=e?.keyHashFunction||p;return n=>{if(!e?.namespace)return t(n);let r=e.namespaceSeparator||`$`;return`${e.namespace}${r}${t(n)}`}}function v(e,t){return{get:n=>e().get(t(n)),set:(n,r,i)=>e().set(t(n),r,i),delete:n=>e().delete(t(n)),expireTag:t=>e().expireTag(t)}}let y=!1;function b(e){if(m||=new d.InMemoryCache,process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE===`true`)return e&&console.log(`Using InMemoryCache as build cache is disabled`),m;let{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}=process.env;if(e&&console.log(`Runtime cache environment variables:`,{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}),!t||!n)return y||=(console.warn(`Runtime Cache unavailable in this environment. Falling back to in-memory cache.`),!0),m;if(!h){let e={};try{e=JSON.parse(n)}catch(e){return console.error(`Failed to parse RUNTIME_CACHE_HEADERS:`,e),m}let r=500;if(process.env.RUNTIME_CACHE_TIMEOUT){let e=parseInt(process.env.RUNTIME_CACHE_TIMEOUT,10);!isNaN(e)&&e>0?r=e:console.warn(`Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${r}ms`)}h=new f.BuildCache({endpoint:t,headers:e,onError:e=>console.error(e),timeout:r})}return h}var ee=(e=>(e.Fresh=`fresh`,e.Stale=`stale`,e.Expired=`expired`,e.NotFound=`notFound`,e.Error=`error`,e))(ee||{});let x=`x-vercel-cache-state`,S=`x-vercel-revalidate`,te=`x-vercel-cache-tags`,C=`x-vercel-cache-item-name`})),ve=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,{attachDatabasePool:()=>_,experimental_attachDatabasePool:()=>v}),t.exports=c(l);var u=fe();let d=!!process.env.DEBUG;function f(e){if(`options`in e&&e.options){if(`idleTimeoutMillis`in e.options)return typeof e.options.idleTimeoutMillis==`number`?e.options.idleTimeoutMillis:1e4;if(`maxIdleTimeMS`in e.options)return typeof e.options.maxIdleTimeMS==`number`?e.options.maxIdleTimeMS:0;if(`status`in e)return 5e3;if(`connect`in e&&`execute`in e)return 3e4}if(`config`in e&&e.config){if(`connectionConfig`in e.config&&e.config.connectionConfig)return e.config.connectionConfig.idleTimeout||6e4;if(`idleTimeout`in e.config)return typeof e.config.idleTimeout==`number`?e.config.idleTimeout:6e4}return`poolTimeout`in e?typeof e.poolTimeout==`number`?e.poolTimeout:6e4:`idleTimeout`in e?typeof e.idleTimeout==`number`?e.idleTimeout:0:1e4}let p=null,m=()=>{},h=Date.now();function g(e){if(!process.env.VERCEL_URL||!process.env.VERCEL_REGION)return;p&&(clearTimeout(p),m());let t=new Promise(e=>{m=e}),n=Math.min(f(e)+100,Math.max(100,899e3-(Date.now()-h)));p=setTimeout(()=>{m?.(),d&&console.log(`Database pool idle timeout reached. Releasing connections.`)},n);let r=(0,u.getContext)();r?.waitUntil?r.waitUntil(t):console.warn(`Pool release event triggered outside of request scope.`)}function _(e){if(p&&(m?.(),clearTimeout(p)),`on`in e&&e.on&&`options`in e&&`idleTimeoutMillis`in e.options){e.on(`release`,()=>{d&&console.log(`Client released from pool`),g(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`connectionConfig`in e.config){e.on(`release`,()=>{d&&console.log(`MySQL client released from pool`),g(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`idleTimeout`in e.config){e.on(`release`,()=>{d&&console.log(`MySQL2/MariaDB client released from pool`),g(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`maxIdleTimeMS`in e.options){e.on(`connectionCheckedOut`,()=>{d&&console.log(`MongoDB connection checked out`),g(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`socket`in e.options){e.on(`end`,()=>{d&&console.log(`Redis connection ended`),g(e)});return}throw Error(`Unsupported database pool type`)}let v=_})),ye=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,{dangerouslyDeleteBySrcImage:()=>m,dangerouslyDeleteByTag:()=>f,invalidateBySrcImage:()=>p,invalidateByTag:()=>d}),t.exports=c(l);var u=fe();let d=e=>{let t=(0,u.getContext)().purge;return t?t.invalidateByTag(e):Promise.resolve()},f=(e,t)=>{let n=(0,u.getContext)().purge;return n?n.dangerouslyDeleteByTag(e,t):Promise.resolve()},p=e=>{let t=(0,u.getContext)().purge;return t?t.invalidateBySrcImage(e):Promise.resolve()},m=(e,t)=>{let n=(0,u.getContext)().purge;return n?n.dangerouslyDeleteBySrcImage(e,t):Promise.resolve()}})),be=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,{addCacheTag:()=>d}),t.exports=c(l);var u=fe();let d=e=>{let t=(0,u.getContext)().addCacheTag;return t?t(e):Promise.resolve()}})),xe=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,{addCacheTag:()=>_.addCacheTag,attachDatabasePool:()=>h.attachDatabasePool,dangerouslyDeleteBySrcImage:()=>g.dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag:()=>g.dangerouslyDeleteByTag,experimental_attachDatabasePool:()=>h.experimental_attachDatabasePool,geolocation:()=>u.geolocation,getCache:()=>m.getCache,getEnv:()=>d.getEnv,invalidateBySrcImage:()=>g.invalidateBySrcImage,invalidateByTag:()=>g.invalidateByTag,ipAddress:()=>u.ipAddress,next:()=>p.next,rewrite:()=>p.rewrite,waitUntil:()=>f.waitUntil}),t.exports=c(l);var u=ue(),d=de(),f=pe(),p=me(),m=_e(),h=ve(),g=ye(),_=be()})),Se=n(((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}})),Ce=n(((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):()=>{}})),we=n(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=Se(),a=Ce();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*$`)})),Te=n(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),Ee=n(((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)}})),D=n(((e,t)=>{let n=Ce(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=Se(),{safeRe:a,t:o}=we(),s=Te(),{compareIdentifiers:c}=Ee();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),O=n(((e,t)=>{let n=D();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}}})),De=n(((e,t)=>{let n=O();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),Oe=n(((e,t)=>{let n=O();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),ke=n(((e,t)=>{let n=D();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}}})),Ae=n(((e,t)=>{let n=O();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),je=n(((e,t)=>{let n=D();t.exports=(e,t)=>new n(e,t).major})),Me=n(((e,t)=>{let n=D();t.exports=(e,t)=>new n(e,t).minor})),Ne=n(((e,t)=>{let n=D();t.exports=(e,t)=>new n(e,t).patch})),Pe=n(((e,t)=>{let n=O();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),k=n(((e,t)=>{let n=D();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Fe=n(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(t,e,r)})),Ie=n(((e,t)=>{let n=k();t.exports=(e,t)=>n(e,t,!0)})),Le=n(((e,t)=>{let n=D();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),Re=n(((e,t)=>{let n=Le();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),ze=n(((e,t)=>{let n=Le();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),Be=n(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)>0})),Ve=n(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)<0})),He=n(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)===0})),Ue=n(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)!==0})),We=n(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)>=0})),Ge=n(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)<=0})),Ke=n(((e,t)=>{let n=He(),r=Ue(),i=Be(),a=We(),o=Ve(),s=Ge();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}`)}}})),qe=n(((e,t)=>{let n=D(),r=O(),{safeRe:i,t:a}=we();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),Je=n(((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}}})),A=n(((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,E(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=>T(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(ne(this.set[t],e,this.options))return!0;return!1}};let r=new(Je()),i=Te(),a=Ye(),o=Ce(),s=D(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=we(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=Se(),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=te(e,t),o(`xrange`,e),e=w(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=>S(e,t)).join(` `),S=(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})},te=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>C(e,t)).join(` `)),C=(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})},w=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),T=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),E=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()),ne=(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}})),Ye=n(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=Te(),{safeRe:i,t:a}=we(),o=Ke(),s=Ce(),c=D(),l=A()})),Xe=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Ze=n(((e,t)=>{let n=A();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),Qe=n(((e,t)=>{let n=D(),r=A();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}})),$e=n(((e,t)=>{let n=D(),r=A();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}})),et=n(((e,t)=>{let n=D(),r=A(),i=Be();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}})),tt=n(((e,t)=>{let n=A();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),nt=n(((e,t)=>{let n=D(),r=Ye(),{ANY:i}=r,a=A(),o=Xe(),s=Be(),c=Ve(),l=Ge(),u=We();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}})),rt=n(((e,t)=>{let n=nt();t.exports=(e,t,r)=>n(e,t,`>`,r)})),it=n(((e,t)=>{let n=nt();t.exports=(e,t,r)=>n(e,t,`<`,r)})),at=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),ot=n(((e,t)=>{let n=Xe(),r=k();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}})),st=n(((e,t)=>{let n=A(),r=Ye(),{ANY:i}=r,a=Xe(),o=k(),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})),ct=n(((e,t)=>{let n=we(),r=Se(),i=D(),a=Ee();t.exports={parse:O(),valid:De(),clean:Oe(),inc:ke(),diff:Ae(),major:je(),minor:Me(),patch:Ne(),prerelease:Pe(),compare:k(),rcompare:Fe(),compareLoose:Ie(),compareBuild:Le(),sort:Re(),rsort:ze(),gt:Be(),lt:Ve(),eq:He(),neq:Ue(),gte:We(),lte:Ge(),cmp:Ke(),coerce:qe(),Comparator:Ye(),Range:A(),satisfies:Xe(),toComparators:Ze(),maxSatisfying:Qe(),minSatisfying:$e(),minVersion:et(),validRange:tt(),outside:nt(),gtr:rt(),ltr:it(),intersects:at(),simplifyRange:ot(),subset:st(),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}})),j=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}};function lt(e){return Object(e)!==e}const ut=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function dt(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===ut}function ft(e){return Object.prototype.toString.call(e).slice(8,-1)}function pt(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 M(e){let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let r=e[i],a=pt(r);a&&(t+=e.slice(n,i)+a,n=i+1)}return`"${n===0?e:t+e.slice(n)}"`}function mt(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)}const ht=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function gt(e){return ht.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function _t(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}let t=+e;return!(t>=2**32-1||t<0)}function vt(e){let t=Object.keys(e);for(var n=t.length-1;n>=0&&!_t(t[n]);n--);return t.length=n+1,t}function yt(e){let t=new DataView(e),n=``;for(let r=0;r<e.byteLength;r++)n+=String.fromCharCode(t.getUint8(r));return Ct(n)}function bt(e){let t=St(e),n=new ArrayBuffer(t.length),r=new DataView(n);for(let e=0;e<n.byteLength;e++)r.setUint8(e,t.charCodeAt(e));return n}const xt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function St(e){e.length%4==0&&(e=e.replace(/==?$/,``));let t=``,n=0,r=0;for(let i=0;i<e.length;i++)n<<=6,n|=xt.indexOf(e[i]),r+=6,r===24&&(t+=String.fromCharCode((n&16711680)>>16),t+=String.fromCharCode((n&65280)>>8),t+=String.fromCharCode(n&255),n=r=0);return r===12?(n>>=4,t+=String.fromCharCode(n)):r===18&&(n>>=2,t+=String.fromCharCode((n&65280)>>8),t+=String.fromCharCode(n&255)),t}function Ct(e){let t=``;for(let n=0;n<e.length;n+=3){let r=[void 0,void 0,void 0,void 0];r[0]=e.charCodeAt(n)>>2,r[1]=(e.charCodeAt(n)&3)<<4,e.length>n+1&&(r[1]|=e.charCodeAt(n+1)>>4,r[2]=(e.charCodeAt(n+1)&15)<<2),e.length>n+2&&(r[2]|=e.charCodeAt(n+2)>>6,r[3]=e.charCodeAt(n+2)&63);for(let e=0;e<r.length;e++)r[e]===void 0?t+=`=`:t+=xt[r[e]]}return t}function wt(e,t){return Tt(JSON.parse(e),t)}function Tt(e,t){if(typeof e==`number`)return a(e,!0);if(!Array.isArray(e)||e.length===0)throw Error(`Invalid input`);let n=e,r=Array(n.length),i=null;function a(e,o=!1){if(e===-1)return;if(e===-3)return NaN;if(e===-4)return 1/0;if(e===-5)return-1/0;if(e===-6)return-0;if(o||typeof e!=`number`)throw Error(`Invalid input`);if(e in r)return r[e];let s=n[e];if(!s||typeof s!=`object`)r[e]=s;else if(Array.isArray(s))if(typeof s[0]==`string`){let o=s[0],c=t&&Object.hasOwn(t,o)?t[o]:void 0;if(c){let t=s[1];if(typeof t!=`number`&&(t=n.push(s[1])-1),i??=new Set,i.has(t))throw Error(`Invalid circular reference`);return i.add(t),r[e]=c(a(t)),i.delete(t),r[e]}switch(o){case`Date`:r[e]=new Date(s[1]);break;case`Set`:let t=new Set;r[e]=t;for(let e=1;e<s.length;e+=1)t.add(a(s[e]));break;case`Map`:let i=new Map;r[e]=i;for(let e=1;e<s.length;e+=2)i.set(a(s[e]),a(s[e+1]));break;case`RegExp`:r[e]=new RegExp(s[1],s[2]);break;case`Object`:r[e]=Object(s[1]);break;case`BigInt`:r[e]=BigInt(s[1]);break;case`null`:let c=Object.create(null);r[e]=c;for(let e=1;e<s.length;e+=2)c[s[e]]=a(s[e+1]);break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{if(n[s[1]][0]!==`ArrayBuffer`)throw Error(`Invalid data`);let t=globalThis[o],i=new t(a(s[1]));r[e]=s[2]===void 0?i:i.subarray(s[2],s[3]);break}case`ArrayBuffer`:{let t=s[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);r[e]=bt(t);break}case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:{let t=o.slice(9);r[e]=Temporal[t].from(s[1]);break}case`URL`:r[e]=new URL(s[1]);break;case`URLSearchParams`:r[e]=new URLSearchParams(s[1]);break;default:throw Error(`Unknown type ${o}`)}}else if(s[0]===-7){let t=s[1],n=Array(t);r[e]=n;for(let e=2;e<s.length;e+=2){let t=s[e];n[t]=a(s[e+1])}}else{let t=Array(s.length);r[e]=t;for(let e=0;e<s.length;e+=1){let n=s[e];n!==-2&&(t[e]=a(n))}}else{let t={};r[e]=t;for(let e of Object.keys(s)){if(e===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");let n=s[e];t[e]=a(n)}}return r[e]}return a(0)}function N(e,t){let n=[],r=new Map,i=[];if(t)for(let e of Object.getOwnPropertyNames(t))i.push({key:e,fn:t[e]});let a=[],o=0;function s(t){if(t===void 0)return-1;if(Number.isNaN(t))return-3;if(t===1/0)return-4;if(t===-1/0)return-5;if(t===0&&1/t<0)return-6;if(r.has(t))return r.get(t);let c=o++;r.set(t,c);for(let{key:e,fn:r}of i){let i=r(t);if(i)return n[c]=`["${e}",${s(i)}]`,c}if(typeof t==`function`)throw new j(`Cannot stringify a function`,a,t,e);let l=``;if(lt(t))l=Et(t);else{let n=ft(t);switch(n){case`Number`:case`String`:case`Boolean`:l=`["Object",${Et(t)}]`;break;case`BigInt`:l=`["BigInt",${t}]`;break;case`Date`:l=`["Date","${isNaN(t.getDate())?``:t.toISOString()}"]`;break;case`URL`:l=`["URL",${M(t.toString())}]`;break;case`URLSearchParams`:l=`["URLSearchParams",${M(t.toString())}]`;break;case`RegExp`:let{source:r,flags:i}=t;l=i?`["RegExp",${M(r)},"${i}"]`:`["RegExp",${M(r)}]`;break;case`Array`:{let e=!1;l=`[`;for(let n=0;n<t.length;n+=1)if(n>0&&(l+=`,`),Object.hasOwn(t,n))a.push(`[${n}]`),l+=s(t[n]),a.pop();else if(e)l+=-2;else{let n=vt(t),r=n.length,i=String(t.length).length;if((t.length-r)*3>4+i+r*(i+1)){l=`[-7,`+t.length;for(let e=0;e<n.length;e++){let r=n[e];a.push(`[${r}]`),l+=`,`+r+`,`+s(t[r]),a.pop()}break}else e=!0,l+=-2}l+=`]`;break}case`Set`:l=`["Set"`;for(let e of t)l+=`,${s(e)}`;l+=`]`;break;case`Map`:l=`["Map"`;for(let[e,n]of t)a.push(`.get(${lt(e)?Et(e):`...`})`),l+=`,${s(e)},${s(n)}`,a.pop();l+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let e=t;l=`["`+n+`",`+s(e.buffer);let r=t.byteOffset,i=r+t.byteLength;if(r>0||i!==e.buffer.byteLength){let e=/(\d+)/.exec(n)[1]/8;l+=`,${r/e},${i/e}`}l+=`]`;break}case`ArrayBuffer`:l=`["ArrayBuffer","${yt(t)}"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:l=`["${n}",${M(t.toString())}]`;break;default:if(!dt(t))throw new j(`Cannot stringify arbitrary non-POJOs`,a,t,e);if(mt(t).length>0)throw new j(`Cannot stringify POJOs with symbolic keys`,a,t,e);if(Object.getPrototypeOf(t)===null){l=`["null"`;for(let n of Object.keys(t)){if(n===`__proto__`)throw new j(`Cannot stringify objects with __proto__ keys`,a,t,e);a.push(gt(n)),l+=`,${M(n)},${s(t[n])}`,a.pop()}l+=`]`}else{l=`{`;let n=!1;for(let r of Object.keys(t)){if(r===`__proto__`)throw new j(`Cannot stringify objects with __proto__ keys`,a,t,e);n&&(l+=`,`),n=!0,a.push(gt(r)),l+=`${M(r)}:${s(t[r])}`,a.pop()}l+=`}`}}}return n[c]=l,c}let c=s(e);return c<0?`${c}`:`[${n.join(`,`)}]`}function Et(e){let t=typeof e;return t===`string`?M(e):e instanceof String?M(e.toString()):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`["BigInt","${e}"]`:String(e)}var Dt=xe(),Ot=e(ct(),1);async function kt(e){if(e.byteLength!==32)throw new h(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,[`encrypt`,`decrypt`])}async function At(e,t){let n=globalThis.crypto.getRandomValues(new Uint8Array(12)),r=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:n,tagLength:128},e,t),i=new Uint8Array(12+r.byteLength);return i.set(n,0),i.set(new Uint8Array(r),12),i}async function jt(e,t){if(t.byteLength<28)throw new h(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`);let n=t.subarray(0,12),r=t.subarray(12),i=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:n,tagLength:128},e,r);return new Uint8Array(i)}function P(){return{...s(),pendingOps:0,doneResolved:!1,streamEnded:!1}}function Mt(e){if(e.locked)return!1;let t;try{t=e.getWriter()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Nt(e){if(e.locked)return!1;let t;try{t=e.getReader()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Pt(e,t){if(t.writablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.writablePollingInterval=void 0;return}Mt(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.writablePollingInterval=void 0)},10);t.writablePollingInterval=n}function Ft(e,t){if(t.readablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.readablePollingInterval=void 0;return}Nt(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.readablePollingInterval=void 0)},10);t.readablePollingInterval=n}async function F(e,t,n){let r=e.getReader(),i=t.getWriter(),a;try{for(;;){if(n.streamEnded)return;let e=await Promise.race([r.read(),i.closed.then(()=>{throw new h(`Writable stream closed prematurely`)})]);if(n.streamEnded)return;if(e.done){n.streamEnded=!0,await i.close(),n.doneResolved||(n.doneResolved=!0,n.resolve());return}n.pendingOps++;try{await i.write(e.value)}finally{n.pendingOps--}}}catch(e){throw n.streamEnded=!0,a=e,n.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{r.cancel(a).catch(()=>{}),r.releaseLock(),i.releaseLock()}}const It=Symbol.for(`@workflow/world//cache`),Lt=Symbol.for(`@workflow/world//cachePromise`),Rt=Symbol.for(`@workflow/world//getWorldFn`);async function I(){let e=globalThis;if(e[It])return e[It];if(e[Lt])return e[It]=await e[Lt],e[It];let t=e[Rt];if(t)return t();let{getWorld:n}=await import([`./world`,`js`].join(`.`));return n()}const zt=Symbol.for(`workflow-serialize`),Bt=Symbol.for(`workflow-deserialize`);function Vt(e=globalThis){let t=e,n=t[ne];return n||(n=new Map,t[ne]=n),n}function Ht(e,t){return Vt(t).get(e)}function Ut(){return{Class:e=>{if(typeof e!=`function`)return!1;let t=e.classId;return typeof t==`string`?{classId:t}:!1},Instance:e=>{if(typeof e!=`object`||!e)return!1;let t=e.constructor;if(!t||typeof t!=`function`)return!1;let n=t[zt];if(typeof n!=`function`)return!1;let r=t.classId;if(typeof r!=`string`)throw Error(`Class "${t.name}" with ${String(zt)} must have a static "classId" property.`);return{classId:r,data:n.call(t,e)}}}}function Wt(e=globalThis){return{Class:t=>{let n=t.classId,r=Ht(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=Ht(n,e);if(!i)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);let a=i[Bt];if(typeof a!=`function`)throw Error(`Class "${n}" does not have a static ${String(Bt)} method.`);return a.call(i,r)}}}function Gt(e,t,n){if(n===0)return`.`;let r=new Uint8Array(e,t,n);return Buffer.from(r).toString(`base64`)}function L(e){return Gt(e.buffer,e.byteOffset,e.byteLength)}function R(e,t){let n=e===`.`?``:e,r=Buffer.from(n,`base64`),i=new t.ArrayBuffer(r.length);return new t.Uint8Array(i).set(r),i}function Kt(e){return JSON.parse(e)}function qt(e){if(!ce.isNativeError(e))return!1;let t={message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t}function Jt(e,t){return!ce.isNativeError(t)||t.name!==e?!1:qt(t)}function z(e){return t=>Jt(e,t)||!1}function B(e,t){return n=>{let r=n,i=`cause`in r?{cause:r.cause}:void 0,a=e[t],o=new a(r.message,i);return r.stack!==void 0&&(o.stack=r.stack),o}}function Yt(e=globalThis){return{ArrayBuffer:t=>t instanceof e.ArrayBuffer&&Gt(t,0,t.byteLength),BigInt:e=>typeof e==`bigint`&&e.toString(),BigInt64Array:t=>t instanceof e.BigInt64Array&&L(t),BigUint64Array:t=>t instanceof e.BigUint64Array&&L(t),Date:t=>t instanceof e.Date?Number.isNaN(t.getDate())?`.`:t.toISOString():!1,DOMException:e=>{if(typeof e!=`object`||!e||e.constructor?.name!==`DOMException`)return!1;let t=e,n={message:t.message,name:t.name,stack:t.stack};return`cause`in t&&(n.cause=t.cause),n},EvalError:z(`EvalError`),FatalError:z(`FatalError`),RangeError:z(`RangeError`),ReferenceError:z(`ReferenceError`),RetryableError:e=>{let t=Jt(`RetryableError`,e);if(!t)return!1;let n=e.retryAfter,r;if(n&&typeof n==`object`&&typeof n.getTime==`function`){let e=n.getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else if(typeof n==`string`||typeof n==`number`){let e=new Date(n).getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else r=Date.now()+1e3;return{...t,retryAfter:r}},SyntaxError:z(`SyntaxError`),TypeError:z(`TypeError`),URIError:z(`URIError`),AggregateError:e=>{let t=Jt(`AggregateError`,e);return t?{...t,errors:e.errors}:!1},Error:e=>{if(!ce.isNativeError(e))return!1;let t={name:e.name,message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t},Float32Array:t=>t instanceof e.Float32Array&&L(t),Float64Array:t=>t instanceof e.Float64Array&&L(t),Headers:t=>t instanceof e.Headers&&Array.from(t),Int8Array:t=>t instanceof e.Int8Array&&L(t),Int16Array:t=>t instanceof e.Int16Array&&L(t),Int32Array:t=>t instanceof e.Int32Array&&L(t),Map:t=>t instanceof e.Map&&Array.from(t),RegExp:t=>t instanceof e.RegExp&&{source:t.source,flags:t.flags},Set:t=>t instanceof e.Set&&Array.from(t),URL:t=>t instanceof e.URL&&t.href,WorkflowFunction:e=>{if(typeof e!=`function`)return!1;let t=e.workflowId;return typeof t==`string`?{workflowId:t}:!1},URLSearchParams:t=>t instanceof e.URLSearchParams?t.size===0?`.`:String(t):!1,Uint8Array:t=>t instanceof e.Uint8Array&&L(t),Uint8ClampedArray:t=>t instanceof e.Uint8ClampedArray&&L(t),Uint16Array:t=>t instanceof e.Uint16Array&&L(t),Uint32Array:t=>t instanceof e.Uint32Array&&L(t)}}function Xt(e=globalThis){return{ArrayBuffer:t=>R(t,e),BigInt:t=>e.BigInt(t),BigInt64Array:t=>new e.BigInt64Array(R(t,e)),BigUint64Array:t=>new e.BigUint64Array(R(t,e)),Date:t=>new e.Date(t),DOMException:t=>{let n=new e.DOMException(t.message,t.name);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},EvalError:B(e,`EvalError`),FatalError:t=>{let n=new(e[Symbol.for(`@workflow/errors//FatalError`)]??p)(t.message);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RangeError:B(e,`RangeError`),ReferenceError:B(e,`ReferenceError`),RetryableError:t=>{let n=new(e[Symbol.for(`@workflow/errors//RetryableError`)]??f)(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},SyntaxError:B(e,`SyntaxError`),TypeError:B(e,`TypeError`),URIError:B(e,`URIError`),AggregateError:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.AggregateError(t.errors,t.message,n);return t.stack!==void 0&&(r.stack=t.stack),r},Error:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.Error(t.message,n);return r.name=t.name,t.stack!==void 0&&(r.stack=t.stack),r},Float32Array:t=>new e.Float32Array(R(t,e)),Float64Array:t=>new e.Float64Array(R(t,e)),Headers:t=>new e.Headers(t),Int8Array:t=>new e.Int8Array(R(t,e)),Int16Array:t=>new e.Int16Array(R(t,e)),Int32Array:t=>new e.Int32Array(R(t,e)),Map:t=>new e.Map(t),RegExp:t=>new e.RegExp(t.source,t.flags),Set:t=>new e.Set(t),URL:t=>new e.URL(t),WorkflowFunction:e=>Object.assign(()=>{throw Error(`Workflow functions cannot be called directly. Use start() to invoke them.`)},{workflowId:e.workflowId}),URLSearchParams:t=>new e.URLSearchParams(t===`.`?``:t),Uint8Array:t=>new e.Uint8Array(R(t,e)),Uint8ClampedArray:t=>new e.Uint8ClampedArray(R(t,e)),Uint16Array:t=>new e.Uint16Array(R(t,e)),Uint32Array:t=>new e.Uint32Array(R(t,e))}}function Zt(){return{StepFunction:e=>{if(typeof e!=`function`)return!1;let t=e.stepId;if(typeof t!=`string`)return!1;let n=e.__closureVarsFn,r=n&&typeof n==`function`?n():void 0,i=`__boundThis`in e,a=i?e.__boundThis:void 0,o=e.__boundArgs,s={stepId:t};return r!==void 0&&(s.closureVars=r),i&&(s.boundThis=a),Array.isArray(o)&&o.length>0&&(s.boundArgs=o),s}}}function Qt(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 $t(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const V={DEVALUE_V1:`devl`,ENCRYPTED:`encr`},en=new TextEncoder,tn=new TextDecoder;function nn(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Ut(),...Zt(),...Yt(t)};break;case`step`:r={...Ut(),...Yt(t)};break;case`client`:r={...Ut(),...Yt(t)};break}return n?{...r,...n}:r}function rn(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Wt(t),...Qt(t),...Xt(t)};break;case`step`:r={...Wt(t),...Xt(t)};break;case`client`:r={...Wt(t),...Xt(t),StepFunction:()=>{throw Error(`Step functions cannot be deserialized in client context.`)}};break}return n?{...r,...n}:r}const H={formatPrefix:V.DEVALUE_V1,serialize(e,t,n){let r=N(e,nn(t,n?.global,n?.extraReducers));return en.encode(r)},deserialize(e,t,n){let r=rn(t,n?.global,n?.extraRevivers);return wt(tn.decode(e),r)},deserializeLegacy(e,t,n){return Tt(e,rn(t,n?.global,n?.extraRevivers))}},an=new TextEncoder,on=new TextDecoder;function U(e,t){if(!(t instanceof Uint8Array))return t;let n=an.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function sn(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=on.decode(t);return $t(n)?n:null}function W(e){if(!(e instanceof Uint8Array))return{format:V.DEVALUE_V1,payload:new TextEncoder().encode(JSON.stringify(e))};if(e.length<4)throw Error(`Data too short to contain format prefix: expected at least 4 bytes, got ${e.length}`);let t=e.subarray(0,4),n=on.decode(t);if(!$t(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}async function cn(e,t){if(!t||!(e instanceof Uint8Array))return e;let n=await At(t,e);return U(V.ENCRYPTED,n)}async function ln(e,t){if(!(e instanceof Uint8Array))return e;let n=sn(e);if(n===V.ENCRYPTED&&!t)throw new h(`Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`);if(n!==V.ENCRYPTED)return e;let{payload:r}=W(e);return jt(t,r)}function un(e,t,n){let[r,...i]=t.split(`
|
|
3
|
-
`),a=i.join(`
|
|
4
|
-
`),o=dn(r??``,n),s=fn(a),c=[`${e} ${r??``}`];return o&&c.push(o),s&&c.push(s),c.join(`
|
|
5
|
-
`)}function dn(e,t){if(!t||Object.keys(t).length===0)return null;let n=new Set;n.add(`errorStack`),typeof t.errorMessage==`string`&&e.includes(t.errorMessage)&&n.add(`errorMessage`);let i=new Set([`workflowRunId`,`workflowName`,`stepId`,`stepName`,`errorAttribution`,`errorCode`,`errorName`,`errorMessage`,`errorStack`,`hint`,`attempt`,`retryCount`]),a=[],o=G(t,`errorName`),s=G(t,`errorAttribution`);if(o||s){let e=s?s===`sdk`?re(`sdk error`):g(`user error`):``,t=o?ee(o):``,n=e&&t?_(` · `):``;a.push(` ${e}${n}${t}`)}let c=G(t,`workflowRunId`),l=G(t,`workflowName`);c?a.push(hn(`run`,c,l,r)):l&&a.push(hn(`run`,null,l,r));let d=G(t,`stepId`),f=G(t,`stepName`);if((d||f)&&a.push(hn(`step`,d,f,u)),t.attempt!==void 0||t.retryCount!==void 0){let e=t.attempt,n=t.retryCount;e!==void 0&&n!==void 0?a.push(` ${mn(`retry`)} ${e} ${_(`attempts ·`)} ${n} ${_(`max retries`)}`):e!==void 0&&a.push(` ${mn(`retry`)} ${e} ${_(`attempts`)}`)}let p=G(t,`errorCode`);p&&p!==o&&a.push(` ${mn(`code`)} ${_(p)}`);let m=G(t,`hint`);m&&a.push(` ${y(m)}`);let h=Object.entries(t).filter(([e,t])=>!i.has(e)&&!n.has(e)&&t!=null).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of h)a.push(` ${mn(e)} ${gn(t)}`);return a.length?a.join(`
|
|
6
|
-
`):null}function fn(e){if(!e)return null;let t=e.split(`
|
|
7
|
-
`),n=[],r=0,i=0,a=0,o=()=>{r>0&&(n.push(_(` … ${r} more ${r===1?`frame`:`frames`} in framework internals`)),r=0)};for(let e of t){let t=e.trimStart().startsWith(`at `);if(t&&pn(e)){r++;continue}if(t&&i>=6){a++;continue}o(),n.push(e),t&&i++}return o(),a>0&&n.push(_(` … ${a} more ${a===1?`frame`:`frames`} (run \`pnpm wf inspect run <id>\` for the full stack)`)),n.join(`
|
|
8
|
-
`)}function pn(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 G(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function mn(e){return _(e.padEnd(6))}function hn(e,t,n,r){let i=t||_(`—`),o=n&&(e===`run`?a(n):l(n))?`${_(`·`)} ${r(n)}`:``;return` ${mn(e)} ${i}${o?` `+o:``}`}function gn(e){if(typeof e==`string`)return e.includes(`
|
|
9
|
-
`)?e.split(`
|
|
10
|
-
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
11
|
-
`):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var _n=class e extends Error{steps;globalThis;stepCount;hookCount;waitCount;hookDisposedCount;abortCount;constructor(e,t){let n=[...e.values()],r=0,i=0,a=0,s=0,c=0;for(let e of n)e.type===`step`?r++:e.type===`hook`?e.disposed?s++:e.abortRequested?c++:i++:e.type===`wait`&&a++;let l=[];r>0&&l.push(`${r} ${o(`step`,`steps`,r)}`),i>0&&l.push(`${i} ${o(`hook`,`hooks`,i)}`),a>0&&l.push(`${a} ${o(`wait`,`waits`,a)}`),s>0&&l.push(`${s} hook ${o(`disposal`,`disposals`,s)}`);let u=o(`has`,`have`,r+i+a+s),d=+(r>0)+ +(i>0)+ +(a>0)+ +(s>0),f;f=d>1?`processed`:r>0?`run`:i>0||a>0?`created`:s>0?`processed`:`received`;let p=l.length>0?`${l.join(` and `)} ${u} not been ${f} yet`:`0 steps have not been run yet`;super(p),this.name=`WorkflowSuspension`,this.steps=n,this.globalThis=t,this.stepCount=r,this.hookCount=i,this.waitCount=a,this.hookDisposedCount=s,this.abortCount=c}static is(t){return t instanceof e}};function vn(){throw new h(`This API is not available inside a workflow function. Workflow functions run in a deterministic VM; move the call to a step function for full Node.js access.`)}function K(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const yn=K(`workflow.name`),bn=K(`workflow.operation`),xn=K(`workflow.run.id`),Sn=K(`workflow.run.status`),Cn=K(`workflow.started_at`),wn=K(`workflow.events.count`),Tn=K(`workflow.arguments.count`),En=K(`workflow.result.type`),Dn=K(`workflow.trace.propagated`),On=K(`workflow.error.name`),kn=K(`workflow.error.message`),An=K(`workflow.error.code`),jn=K(`workflow.steps.created`),Mn=K(`workflow.hooks.created`),Nn=K(`workflow.waits.created`),Pn=K(`step.name`),Fn=K(`step.id`),In=K(`step.attempt`),Ln=K(`step.status`),Rn=K(`step.max_retries`),zn=K(`step.skipped`),Bn=K(`step.skip_reason`),Vn=K(`step.arguments.count`),Hn=K(`step.result.type`),Un=K(`step.error.name`),Wn=K(`step.error.message`),Gn=K(`step.fatal_error`),Kn=K(`step.retry.exhausted`),qn=K(`step.retry.timeout_seconds`),Jn=K(`step.retry.will_retry`),Yn=K(`messaging.system`),Xn=K(`messaging.destination.name`),Zn=K(`messaging.message.id`),Qn=K(`messaging.operation.type`),$n=K(`workflow.queue.overhead_ms`),er=K(`deployment.id`),tr=K(`workflow.hook.token`),nr=K(`workflow.hook.id`),rr=K(`workflow.hook.found`),ir=K(`workflow.suspension.state`),ar=K(`workflow.suspension.hook_count`),or=K(`workflow.suspension.step_count`),sr=K(`workflow.suspension.wait_count`),cr=K(`error.type`),lr=K(`workflow.events.pages_loaded`),ur=K(`workflow.queue.deserialize_time_ms`),dr=K(`workflow.queue.execution_time_ms`),fr=K(`workflow.queue.serialize_time_ms`),pr=K(`peer.service`),mr=K(`rpc.system`),hr=K(`rpc.service`),gr=K(`rpc.method`),_r=K(`error.retryable`),vr=K(`error.category`);async function yr(){let e=await q.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function br(e){let t=await q.value;if(t)return t.propagation.extract(t.context.active(),e)}async function xr(e,t){if(!e)return t();let n=await q.value;if(!n)return t();let r=await br(e);return r?n.context.with(r,async()=>await t()):t()}const q=i(async()=>{try{return await import(`./src-ClRYdO4-.js`).then(t=>e(t.t(),1))}catch{return Pr.info(`OpenTelemetry not available, tracing will be disabled`),null}}),Sr=i(async()=>{let e=await q.value;return e?e.trace.getTracer(`workflow`):null});async function Cr(e,...t){let[n,r]=await Promise.all([Sr.value,q.value]),{fn:i,opts:a}=typeof t[0]==`function`?{fn:t[0],opts:{}}:{fn:t[1],opts:t[0]};if(!i)throw Error(`Function to trace must be provided`);return!n||!r?await i():n.startActiveSpan(e,a,async e=>{try{let t=await i(e);return e.setStatus({code:r.SpanStatusCode.OK}),t}catch(t){throw e.setStatus({code:r.SpanStatusCode.ERROR,message:t.message}),wr(t,r,e),t}finally{e.end()}})}function wr(e,t,n){!e||!_n.is(e)||(n.setStatus({code:t.SpanStatusCode.OK}),n.setAttributes({...ir(`suspended`),...or(e.stepCount),...ar(e.hookCount),...sr(e.waitCount)}))}async function Tr(e){let[t,n]=await Promise.all([br(e),q.value]);if(!(!t||!n))return n.trace.getSpanContext(t)}async function Er(){return await Or(e=>e.trace.getActiveSpan())}async function Dr(e){return Or(t=>t.SpanKind[e])}async function Or(e){let t=await q.value;if(t)return await e(t)}function kr(){return Or(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function Ar(e,t){let n=await q.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 jr(e,t){if(!t)return!1;let n=!1;for(let r of t.split(`,`)){let t=r.trim();if(!t)continue;let i=t.startsWith(`-`),a=i?t.slice(1):t;RegExp(`^${a.replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`)}$`).test(e)&&(n=!i)}return n}function Mr(e){let t=n=>{let r=t=>{let r=`workflow:${e}:${t}`;return(i,a)=>{let o=Object.keys(n).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...n,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(un(`[workflow-sdk]`,i,c)),jr(r,process.env.DEBUG)&&(console.debug(`[${r}] ${i}`,c??``),Er().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:r(`debug`),info:r(`info`),warn:r(`warn`),error:r(`error`),child:e=>t({...n,...e}),forRun:(e,r,i)=>t({...n,workflowRunId:e,...r===void 0?{}:{workflowName:r},...i??{}})}};return t({})}const Nr=Mr(`step`),Pr=Mr(`runtime`),Fr=Mr(`webhook`),Ir=Mr(`events`);Mr(`adapter`);function J(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof j&&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 j&&t.value!==void 0&&Pr.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function Lr(e,t,n){try{let r=H.serialize(e,`client`,n);return cn(U(V.DEVALUE_V1,r),t)}catch(e){let{message:t,hint:n}=J(`client value`,e);throw new d(t,{hint:n,cause:e})}}async function Rr(e,t,n){let r=await ln(e,t);if(!(r instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(r,`client`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=W(r);if(i===V.DEVALUE_V1)return H.deserialize(a,`client`,n);throw Error(`Unsupported serialization format: ${i}`)}async function zr(e,t,n){try{let r=H.serialize(e,`step`,n);return cn(U(V.DEVALUE_V1,r),t)}catch(e){let{message:t,hint:n}=J(`step value`,e);throw new d(t,{hint:n,cause:e})}}async function Br(e,t,n){let r=await ln(e,t);if(!(r instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(r,`step`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=W(r);if(i===V.DEVALUE_V1)return H.deserialize(a,`step`,n);throw Error(`Unsupported serialization format: ${i}`)}function Vr(e,t){if(!(e instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(e,`workflow`,t);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:n,payload:r}=W(e);if(n===V.DEVALUE_V1)return H.deserialize(r,`workflow`,t);throw Error(`Unsupported serialization format: ${n}`)}const Hr=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),Ur=globalThis[Hr]??(globalThis[Hr]=new le);function Wr(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 Gr(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function Kr(e){return`strm_${e}_system_abort`}function qr(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return Kr(e.slice(5))}async function Jr(e){let t=e();return(0,Dt.waitUntil)(t.catch(()=>{})),t}var Y;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Y||={});var Yr=class{eventIndex;events=[];callbacks=[];onUnconsumedEvent;getPromiseQueue;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;constructor(e,t){this.events=e,this.eventIndex=0,this.onUnconsumedEvent=t.onUnconsumedEvent,this.getPromiseQueue=t.getPromiseQueue}subscribe(e){this.callbacks.push(e),this.pendingUnconsumedCheck!==null&&(this.unconsumedCheckVersion++,this.pendingUnconsumedCheck=null,this.pendingUnconsumedTimeout!==null&&(clearTimeout(this.pendingUnconsumedTimeout),this.pendingUnconsumedTimeout=null)),process.nextTick(this.consume)}consume=()=>{let e=this.events[this.eventIndex]??null;for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Y.NotConsumed;try{r=n(e)}catch(e){Ir.error(`EventConsumer callback threw an error`,{error:e})}if(r===Y.Consumed||r===Y.Finished){this.eventIndex++,r===Y.Finished&&this.callbacks.splice(t,1),process.nextTick(this.consume);return}}if(e!==null){let t=++this.unconsumedCheckVersion;this.pendingUnconsumedCheck=this.getPromiseQueue().then(()=>new Promise(e=>setTimeout(e,0))).then(()=>this.getPromiseQueue()).then(()=>{this.pendingUnconsumedTimeout=setTimeout(()=>{this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===t&&(this.pendingUnconsumedCheck=null,this.onUnconsumedEvent(e))},100)})}}},Xr=class{aborted=!1;reason=void 0;[x];[E];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[x]=e,this[E]=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 Zr(e){return class{signal;[x];[E];constructor(){let t=e.generateUlid(),n=Kr(t),r=`abrt_${t}`;this[x]=n,this[E]=r,this.signal=new Xr(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 Y.NotConsumed;if(t.eventType===`hook_created`){let t=e.invocationsQueue.get(i);return t&&t.type===`hook`&&(t.hasCreatedEvent=!0),Y.Consumed}if(t.eventType===`hook_received`){let n=t.eventData?.payload;return e.promiseQueue=e.promiseQueue.then(async()=>{let t;if(n!==void 0)try{let r=await ji(n,e.runId,e.encryptionKey,e.globalThis);r&&typeof r==`object`&&`reason`in r&&(t=r.reason)}catch{}this.signal._setAborted(t)}),e.invocationsQueue.delete(i),Y.Finished}return t.eventType===`hook_disposed`?(e.invocationsQueue.delete(i),Y.Finished):Y.NotConsumed})}abort(t){if(!this.signal.aborted){this.signal._setAborted(t);for(let[,n]of e.invocationsQueue)if(n.type===`hook`&&n.token===this[E]){n.abortRequested=!0,n.abortReason=t;break}}}}}function Qr(){return{abort(e){let t=new Xr(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new Xr(``,``),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 $r=ie();function ei(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function X(e){return e instanceof d&&e.cause!==void 0||e instanceof h&&e.cause!==void 0?e.cause:e}function ti(e,t){let n=new TextEncoder,r={resolved:!1,key:void 0};return new TransformStream({async transform(i,a){try{r.resolved||=(r.key=await t,!0);let o=N(i,e),s=n.encode(o),c=U(V.DEVALUE_V1,s);if(r.key){let e=await At(r.key,c);c=U(V.ENCRYPTED,e)}let l=new Uint8Array(4+c.length);new DataView(l.buffer).setUint32(0,c.length,!1),l.set(c,4),a.enqueue(l)}catch(e){let{message:t,hint:n}=J(`stream chunk`,e);a.error(new d(t,{hint:n,cause:e}))}}})}function ni(e,t){let n=new TextDecoder,r=new Uint8Array,i={resolved:!1,key:void 0};function a(e){let t=new Uint8Array(r.length+e.length);t.set(r,0),t.set(e,r.length),r=t}async function o(a){for(i.resolved||=(i.key=await t,!0);r.length>=4;){let t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,!1);if(r.length<4+t)break;let o=r.slice(4,4+t);r=r.slice(4+t);let{format:s,payload:c}=W(o);if(s===V.ENCRYPTED){if(!i.key){a.error(new h(`Encrypted stream data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`));return}let e=await jt(i.key,c);({format:s,payload:c}=W(e))}if(s===V.DEVALUE_V1){let t=n.decode(c);a.enqueue(wt(t,e))}}}return new TransformStream({async transform(t,i){if(r.length===0&&t.length>=4){let e=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!1);if(e>0&&e<1e8){a(t),await o(i);return}}else if(r.length>0){a(t),await o(i);return}let s=n.decode(t).split(`
|
|
12
|
-
`);for(let t of s)t.length>0&&i.enqueue(wt(t,e))},async flush(e){r.length>0&&await o(e)}})}var ri=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new h(`"name" is required, got "${t}"`);super({type:`bytes`,pull:async r=>{let i=this.#e;if(!i){let r=await(await I()).streams.get(e,t,n);i=this.#e=r.getReader()}if(!i){r.error(Error(`Failed to get reader`));return}let a=await i.read();a.done?(this.#e=void 0,r.close()):r.enqueue(a.value)},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}},Z=class extends WritableStream{constructor(e,t){if(typeof e!=`string`)throw new h(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new h(`"name" is required, got "${t}"`);let n=I(),r=[],i=null,a=null,o,s=async()=>{if(i&&=(clearTimeout(i),null),r.length===0)return;let a=r.slice(),s=await n;if(o===void 0&&(o=s.streamFlushIntervalMs??10),typeof s.streams.writeMulti==`function`&&a.length>1)await s.streams.writeMulti(e,t,a);else for(let n of a)await s.streams.write(e,t,n);r=[]},c=[],l=()=>{i||=setTimeout(()=>{i=null;let e=c;c=[],a=s().then(()=>{for(let t of e)t.resolve()},t=>{for(let n of e)n.reject(t)})},o??10)};super({async write(e){a&&=(await a,null),r.push(e),l(),await new Promise((e,t)=>{c.push({resolve:e,reject:t})})},async close(){a&&=(await a,null),await s(),await(await n).streams.close(e,t)},abort(e){i&&=(clearTimeout(i),null),r=[];let t=c;c=[];let n=e??Error(`Stream aborted`);for(let e of t)e.reject(n)}})}};function ii(e=globalThis){return{...Ut(),...Zt(),...Yt(e),Request:t=>{if(!(t instanceof e.Request))return!1;let n={method:t.method,url:t.url,headers:t.headers,body:t.body,duplex:t.duplex},r=t[S];return r&&(n.responseWritable=r),t.signal&&(t.signal.aborted||t.signal[x])&&(n.signal=t.signal),n},Response:t=>t instanceof e.Response?{type:t.type,url:t.url,status:t.status,statusText:t.statusText,headers:t.headers,body:t.body,redirected:t.redirected}:!1}}function ai(e,t,n,r,i,a){let o=t[x],s=t[E];if(!o){let e=(n[C]||$r)();o=Kr(e),s=`abrt_${e}`,t[x]=o,t[E]=s,t.signal&&(t.signal[x]=o,t.signal[E]=s)}return si(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function oi(e,t){let n=t[x]??t.signal?.[x],r=t[E]??t.signal?.[E];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 si(e,t,n,r,i){e.aborted||e[te]||(e[te]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await r,a=await wi({aborted:!0,reason:e.reason},n,i),o=new Z(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function Q(e=globalThis,t,n,r){return{...ii(e),ReadableStream:i=>{if(!(i instanceof e.ReadableStream))return!1;if(i.locked)throw new d(`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 a=`strm_${(e[C]||$r)()}`,o=ei(i),s=new Z(n,a);o===`bytes`?t.push(i.pipeTo(s)):t.push(i.pipeThrough(ti(Q(e,t,n,r),r)).pipeTo(s));let c={name:a};return o&&(c.type=o),c},WritableStream:r=>{if(!(r instanceof e.WritableStream))return!1;let i=`strm_${(e[C]||$r)()}`,a=new ri(n,i);return t.push(a.pipeTo(r)),{name:i}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:ai(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:ai(i,i,e,t,n,r)}}function ci(e=globalThis){return{...ii(e),ReadableStream:t=>{if(!(t instanceof e.ReadableStream))return!1;let n=t[v];if(n!==void 0)return{bodyInit:n};let r=t[T];if(!r)throw new h("ReadableStream `name` is not set");let i={name:r},a=t[b];return a&&(i.type=a),i},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let n=t[T];if(!n)throw new h("WritableStream `name` is not set");return{name:n}},AbortController:t=>{if(!t||!t.signal)return!1;let n=t,r=n[x]??n.signal?.[x],i=e.AbortController&&typeof e.AbortController==`function`&&t instanceof e.AbortController;return!r&&!i?!1:oi(t.signal,n)},AbortSignal:t=>{let n=t,r=n&&n[x],i=e.AbortSignal&&typeof e.AbortSignal==`function`&&t instanceof e.AbortSignal;return!r&&!i?!1:oi(t,t)}}}function li(e=globalThis,t,n,r){return{...ii(e),ReadableStream:i=>{if(!(i instanceof e.ReadableStream))return!1;if(i.locked)throw new d(`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 a=i[T],o=i[b];if(!a){a=`strm_${(e[C]||$r)()}`,o=ei(i);let s=new Z(n,a);o===`bytes`?t.push(i.pipeTo(s)):t.push(i.pipeThrough(ti(li(e,t,n,r),r)).pipeTo(s))}let s={name:a};return o&&(s.type=o),s},WritableStream:i=>{if(!(i instanceof e.WritableStream))return!1;let a=i[T];return a||(a=`strm_${(e[C]||$r)()}`,t.push(new ri(n,a).pipeThrough(ni(_i(e,t,n,r),r)).pipeTo(i))),{name:a}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:ai(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:ai(i,i,e,t,n,r)}}function ui(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new ri(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(r.releaseLock(),a.value&&!a.done)try{let n=Ur.getStore(),r=await Ti(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}catch{}})()),i}function $(e,t,n){let r=e,i=e.signal;r[x]=t.streamName,r[E]=t.hookToken,i[x]=t.streamName,i[E]=t.hookToken,n&&(r[w]=n,i[w]=n)}function di(e,t){let n=e,r=t;n[x]!==void 0&&(r[x]=n[x]),n[E]!==void 0&&(r[E]=n[E]),n[w]!==void 0&&(r[w]=n[w])}function fi(e,t,n){let r=new AbortController;e.aborted?($(r,e),r.abort(e.reason)):e.streamName?$(r,e,ui(r,n,e.streamName,t)):$(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=Ur.getStore();n&&(n.ops.push((async()=>{try{let r=await wi({aborted:!0,reason:t},n.workflowMetadata.workflowRunId,n.encryptionKey),i=new Z(n.workflowMetadata.workflowRunId,e.streamName).getWriter();await i.write(r),await i.close()}catch{}})()),e.hookToken&&n.ops.push((async()=>{try{let{resumeHook:n}=await Promise.resolve().then(()=>ta);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})()))},r}function pi(e,t,n){let r=new AbortController;return e.aborted?($(r,e),r.abort(e.reason)):e.streamName?$(r,e,ui(r,n,e.streamName,t)):$(r,e),r.signal}function mi(e=globalThis){return{...Wt(e),...Xt(e)}}function hi(e=globalThis,t,n,r){return{...mi(e),StepFunction:()=>{throw new d(`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 d(`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&&di(t.signal,r.signal),r},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}let a=new ri(n,i.name,i.startIndex);if(i.type===`bytes`){let n=P();t.push(n.promise);let{readable:r,writable:i}=new e.TransformStream;return F(a,i,n).catch(()=>{}),Ft(r,n),r}else{let i=ni(hi(e,t,n,r),r),o=P();return t.push(o.promise),F(a,i.writable,o).catch(()=>{}),Ft(i.readable,o),i.readable}},WritableStream:i=>{let a=ti(Q(e,t,n,r),r),o=new Z(n,i.name),s=P();return t.push(s.promise),F(a.readable,o,s).catch(()=>{}),Pt(a.writable,s),a.writable},AbortController:e=>fi(e,t,n),AbortSignal:e=>pi(e,t,n)}}function gi(e=globalThis){return{...mi(e),...Qt(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[S]=n,delete t.responseWritable,t.respondWith=()=>{throw new d("`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 d(`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,{[v]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[T]:{value:t.name,writable:!1},[b]:{value:t.type,writable:!1}}),WritableStream:t=>Object.create(e.WritableStream.prototype,{[T]:{value:t.name,writable:!1}}),AbortController:e=>{let t=new Xr(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[x]:e.streamName,[E]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new Xr(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function _i(e=globalThis,t,n,r){return{...mi(e),StepFunction:e=>{let t=e.stepId,n=e.closureVars,r=`boundThis`in e,i=r?e.boundThis:void 0,a=Array.isArray(e.boundArgs)?e.boundArgs:[],o=se(t);if(!o)throw new d(`Step function "${t}" not found. Make sure the step function is registered.`,{hint:`Make sure the step file is included in your build (i.e. it is listed in the workflow manifest), and that the SWC plugin is configured for the file.`});if(!n&&!r&&a.length===0)return o;let s=function(...e){let t=r?i:this,s=a.length>0?[...a,...e]:e;if(n){let e=Ur.getStore();if(!e)throw new h(`Cannot call step function with closure variables outside step context`);let r={...e,closureVars:n};return Ur.run(r,()=>o.apply(t,s))}return o.apply(t,s)};return Object.defineProperty(s,`name`,{value:o.name}),Object.defineProperty(s,`stepId`,{value:t,writable:!1,enumerable:!1,configurable:!1}),o.maxRetries!==void 0&&(s.maxRetries=o.maxRetries),s},WorkflowFunction:e=>Object.assign(()=>{throw new d(`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&&di(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:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}let a=new ri(n,i.name);if(i.type===`bytes`){let n=P();t.push(n.promise);let{readable:r,writable:i}=new e.TransformStream;return F(a,i,n).catch(()=>{}),Ft(r,n),r}else{let i=ni(_i(e,t,n,r),r),o=P();return t.push(o.promise),F(a,i.writable,o).catch(()=>{}),Ft(i.readable,o),i.readable}},WritableStream:i=>{let a=ti(li(e,t,n,r),r),o=new Z(n,i.name),s=P();return t.push(s.promise),F(a.readable,o,s).catch(()=>{}),Pt(a.writable,s),a.writable},AbortController:e=>fi(e,t,n),AbortSignal:e=>pi(e,t,n)}}async function vi(e,t){return await cn(e,t)}async function yi(e,t){return ln(e,t)}async function bi(e,t,n,r=[],i=globalThis,a=!1){if(a)return Kt(N(e,Q(i,r,t,n)));try{return await Lr(e,n,{global:i,extraReducers:Ni(Q(i,r,t,n))})}catch(e){let t=X(e),{message:n,hint:r}=J(`workflow arguments`,t);throw new d(n,{hint:r,cause:t})}}async function xi(e,t,n,r=globalThis,i={}){return Vr(await yi(e,n),{global:r,extraRevivers:{...Pi(gi(r)),...i}})}async function Si(e,t,n,r=globalThis,i=!1){if(i)return Kt(N(e,ci(r)));try{return await zr(e,n,{global:r,extraReducers:Ni(ci(r))})}catch(e){let t=X(e),{message:n,hint:r}=J(`workflow return value`,t);throw new d(n,{hint:r,cause:t})}}async function Ci(e,t,n,r=[],i=globalThis,a={}){return Rr(e,n,{global:i,extraRevivers:{...Pi(hi(i,r,t,n)),...a}})}async function wi(e,t,n,r=globalThis,i=!1){if(i)return Kt(N(e,ci(r)));try{return await zr(e,n,{global:r,extraReducers:Ni(ci(r))})}catch(e){let t=X(e),{message:n,hint:r}=J(`step arguments`,t);throw new d(n,{hint:r,cause:t})}}async function Ti(e,t,n,r=[],i=globalThis,a={}){return Br(e,n,{global:i,extraRevivers:{...Pi(_i(i,r,t,n)),...a}})}async function Ei(e,t,n,r=[],i=globalThis,a=!1){if(a)return Kt(N(e,li(i,r,t,n)));try{return await zr(e,n,{global:i,extraReducers:Ni(li(i,r,t,n))})}catch(e){let t=X(e),{message:n,hint:r}=J(`step return value`,t);throw new d(n,{hint:r,cause:t})}}async function Di(e,t,n,r=[],i=globalThis){try{let a=N(e,li(i,r,t,n)),o=new TextEncoder().encode(a);return await vi(U(V.DEVALUE_V1,o),n)}catch(e){let t=X(e),{message:n,hint:r}=J(`step error`,t);throw new d(n,{hint:r,cause:t})}}async function Oi(e,t,n,r=globalThis,i={}){let a=await yi(e,n);if(!(a instanceof Uint8Array))return Tt(a,{...gi(r),...i});let{format:o,payload:s}=W(a);if(o===V.DEVALUE_V1)return wt(new TextDecoder().decode(s),{...gi(r),...i});throw Error(`Unsupported serialization format: ${o}`)}async function ki(e,t,n,r=globalThis){try{let t=N(e,ci(r)),i=new TextEncoder().encode(t);return await vi(U(V.DEVALUE_V1,i),n)}catch(e){let t=X(e),{message:n,hint:r}=J(`run error`,t);throw new d(n,{hint:r,cause:t})}}async function Ai(e,t,n,r=[],i=globalThis,a={}){let o=await yi(e,n);if(!(o instanceof Uint8Array))return Tt(o,{...hi(i,r,t,n),...a});let{format:s,payload:c}=W(o);if(s===V.DEVALUE_V1)return wt(new TextDecoder().decode(c),{...hi(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${s}`)}async function ji(e,t,n,r=globalThis,i={}){return Vr(await yi(e,n),{global:r,extraRevivers:{...Pi(gi(r)),...i}})}const Mi=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function Ni(e){let t={};for(let n of Mi)n in e&&(t[n]=e[n]);return t}function Pi(e){let t={};for(let n of Mi)n in e&&(t[n]=e[n]);return t}const Fi=[{format:V.ENCRYPTED,minVersion:`4.2.0-beta.64`}],Ii=new Set([V.DEVALUE_V1]);function Li(e){if(!e||!Ot.default.valid(e))return{supportedFormats:Ii};let t=new Set(Ii);for(let{format:n,minVersion:r}of Fi)Ot.default.gte(e,r)&&t.add(n);return{supportedFormats:t}}const Ri=`5.0.0-beta.5`,zi=/^[a-zA-Z0-9_\-./@]+$/;function Bi(e){if(!zi.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`__wkf_workflow_${e}`}const Vi=ie();function Hi(e){return`__health_check__${e}`}function Ui(e){let t=ae.safeParse(e);if(t.success)return t.data}function Wi(e){return`wrun_hc_${e}`}async function Gi(e,t,n){let r=await I(),i=Hi(e.correlationId),a=JSON.stringify({healthy:!0,endpoint:t,correlationId:e.correlationId,specVersion:n??3,workflowCoreVersion:Ri,timestamp:Date.now()}),o=Wi(e.correlationId);await r.streams.write(o,i,a),await r.streams.close(o,i)}async function Ki(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 qi(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),s}async function Ji(e,t,n){let r=n?.timeout??3e4,i=Vi(),a=Hi(i),o=t===`workflow`?`__wkf_workflow_health_check`:`__wkf_step_health_check`,s=Date.now();try{for(await e.queue(o,{__healthCheck:!0,correlationId:i},{specVersion:1,deploymentId:n?.deploymentId});Date.now()-s<r;)try{let t=(await e.streams.get(Wi(i),a)).getReader(),{chunks:n,timedOut:r}=await Ki(t,500);if(r){try{t.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let o=qi(n);if(o)return{...o,latencyMs:Date.now()-s};await new Promise(e=>setTimeout(e,100))}catch{await new Promise(e=>setTimeout(e,100))}return{healthy:!1,error:`Health check timed out after ${r}ms`}}catch(e){return{healthy:!1,error:e instanceof Error?e.message:String(e)}}}async function Yi(e,t){let n=t!==void 0;return Cr(n?`workflow.loadNewEvents`:`workflow.loadEvents`,async r=>{r?.setAttributes({...xn(e)});let i=[],a=t??null,o=!0,s=0,c=await I(),l=Date.now();for(;o;){let t=Date.now(),r=await c.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:a??void 0}});i.push(...r.data),o=r.hasMore,a=r.cursor,s++,Pr.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:s,pageEvents:r.data.length,totalEvents:i.length,hasMore:o,pageMs:Date.now()-t})}return Pr.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:s,totalMs:Date.now()-l}),r?.setAttributes({...wn(i.length),...lr(s)}),{events:i,cursor:a}})}const Xi={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function Zi(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:Xi}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??3,workflowCoreVersion:Ri}),{status:200,headers:{"Content-Type":`application/json`,...Xi}}):await e(n)}}async function Qi(e,...t){let n=t[0];await Cr(`queue.publish`,{attributes:{...Yn(`vercel-queue`),...Xn(n),...Qn(`publish`),...pr(`vercel-queue`),...mr(`vercel-queue`),...hr(`vqs`),...gr(`publish`)},kind:await Dr(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(Zn(r))})}function $i(e){if(e.requestedAt)try{return $n(Date.now()-e.requestedAt.getTime())}catch{return}}function ea(e,t){let n;return()=>(n||=(async()=>{let n=await e.getEncryptionKeyForRun?.(t);return n?await kt(n):void 0})(),n)}var ta=t({getHookByToken:()=>ra,resumeHook:()=>ia,resumeWebhook:()=>aa});async function na(e){let t=await I(),n=await t.hooks.getByToken(e),r=await t.runs.get(n.runId),i=await t.getEncryptionKeyForRun?.(r),a=i?await kt(i):void 0;return n.metadata!==void 0&&(n.metadata=await Ti(n.metadata,n.runId,a)),{hook:n,run:r,encryptionKey:a}}async function ra(e){let{hook:t}=await na(e);return t}async function ia(e,t,n){return await Jr(()=>Cr(`hook.resume`,async r=>{let i=await I();try{let a,o,s;if(typeof e==`string`){let t=await na(e);a=t.hook,o=t.run,s=n??t.encryptionKey}else if(a=e,o=await i.runs.get(a.runId),n)s=n;else{let e=await i.getEncryptionKeyForRun?.(o);s=e?await kt(e):void 0}r?.setAttributes({...tr(a.token),...nr(a.hookId),...xn(a.runId)});let c=o.executionContext?.workflowCoreVersion,{supportedFormats:l}=Li(typeof c==`string`?c:void 0);l.has(V.ENCRYPTED)||(s=void 0);let u=[],d=oe(a.specVersion),f=await Ei(t,a.runId,s,u,globalThis,d);(0,Dt.waitUntil)(Promise.all(u).catch(e=>{if(e!==void 0)throw e})),await i.events.create(a.runId,{eventType:`hook_received`,specVersion:3,correlationId:a.hookId,eventData:{payload:f}},{v1Compat:d}),r?.setAttributes({...yn(o.workflowName)});let p=o.executionContext?.traceCarrier;if(p){let e=await Tr(p);e&&r?.addLink?.({context:e})}return await i.queue(Bi(o.workflowName),{runId:a.runId,traceCarrier:o.executionContext?.traceCarrier??void 0},{deploymentId:o.deploymentId,specVersion:o.specVersion??1}),a}catch(t){throw r?.setAttributes({...tr(typeof e==`string`?e:e.token),...rr(!1)}),t}}))}async function aa(e,t){let{hook:n,encryptionKey:r}=await na(e);if(n.isWebhook===!1)throw new c(e);let i,a;if(n.metadata&&typeof n.metadata==`object`&&`respondWith`in n.metadata)if(n.metadata.respondWith===`manual`){let{readable:e,writable:n}=new TransformStream;a=e,t[S]=n}else if(n.metadata.respondWith instanceof Response)i=n.metadata.respondWith;else throw new h(`Invalid \`respondWith\` value: ${n.metadata.respondWith}`,{slug:m.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else i=new Response(null,{status:202});if(await ia(n,t,r),a){let e=a.getReader(),t=await e.read();t.value&&(i=t.value),e.cancel()}if(!i)throw new h(`Workflow run did not send a response`,{slug:m.WEBHOOK_RESPONSE_NOT_SENT});return i}export{Zn as $,Ci as A,Sn as At,Pr as B,P as Bt,hi as C,On as Ct,Oi as D,bn as Dt,Ti as E,yn as Et,Wr as F,vn as Ft,Cr as G,Fr as H,Pt as Ht,qr as I,_n as It,er as J,xr as K,Gr as L,Bt as Lt,Zr as M,jn as Mt,Y as N,Dn as Nt,ji as O,En as Ot,Yr as P,Nn as Pt,Xn as Q,Jr as R,zt as Rt,Q as S,kn as St,Ai as T,Mn as Tt,kr as U,kt as Ut,Nr as V,F as Vt,yr as W,xe as Wt,_r as X,vr as Y,cr as Z,wi as _,Bn as _t,$i as a,Vn as at,bi as b,Tn as bt,Ji as c,Un as ct,Ui as d,Rn as dt,Qn as et,Qi as f,Pn as ft,ki as g,Jn as gt,Z as h,qn as ht,ta as i,fr as it,Qr as j,Cn as jt,xi as k,xn as kt,Yi as l,Gn as lt,Ri as m,Kn as mt,ia as n,ur as nt,Bi as o,In as ot,Zi as p,Hn as pt,Ar as q,aa as r,dr as rt,Gi as s,Wn as st,ra as t,Yn as tt,ea as u,Fn as ut,Di as v,zn as vt,ti as w,wn as wt,Si as x,An as xt,Ei as y,Ln as yt,Ur as z,I as zt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./context-errors-zbKocOyk.js";import{p as t}from"./symbols-D-4tVV8x.js";async function n(r){let i=globalThis[t];return i||e(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { UserContent } from "ai";
|
|
2
|
-
import type { DeliverPayload, SessionAuthContext, SubagentInputRequestHookPayload } from "#channel/types.js";
|
|
3
|
-
import { type ContextContainer } from "#context/container.js";
|
|
4
|
-
import type { HarnessEmitFn } from "#harness/types.js";
|
|
5
|
-
import type { RuntimeSubagentResultActionResult } from "#runtime/actions/types.js";
|
|
6
|
-
import { type CreateRuntime } from "#execution/node-step.js";
|
|
7
|
-
/**
|
|
8
|
-
* One queued delivery for a parked continuous session.
|
|
9
|
-
*/
|
|
10
|
-
export interface DeliverQueueItem {
|
|
11
|
-
readonly auth?: SessionAuthContext | null;
|
|
12
|
-
readonly kind: "deliver";
|
|
13
|
-
readonly payloads: readonly DeliverPayload[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* One runtime-action result resumed into a parked continuous session.
|
|
17
|
-
*/
|
|
18
|
-
export interface RuntimeActionResultQueueItem {
|
|
19
|
-
readonly kind: "runtime-action-result";
|
|
20
|
-
readonly results: readonly RuntimeSubagentResultActionResult[];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Proxy payload forwarded from a child subagent to its continuous-runtime
|
|
24
|
-
* parent when the child has parked on a pending HITL input batch.
|
|
25
|
-
*
|
|
26
|
-
* Identical in shape to {@link SubagentInputRequestHookPayload} — the
|
|
27
|
-
* continuous parent queue receives the same record that a workflow
|
|
28
|
-
* parent would receive via `resumeHook`.
|
|
29
|
-
*/
|
|
30
|
-
export type SubagentInputRequestQueueItem = SubagentInputRequestHookPayload;
|
|
31
|
-
/**
|
|
32
|
-
* One item in the continuous runtime's in-memory queue.
|
|
33
|
-
*/
|
|
34
|
-
export type QueueItem = DeliverQueueItem | RuntimeActionResultQueueItem | SubagentInputRequestQueueItem;
|
|
35
|
-
/**
|
|
36
|
-
* Input for the continuous (non-durable) entry.
|
|
37
|
-
*/
|
|
38
|
-
export interface ContinuousEntryInput {
|
|
39
|
-
readonly createRuntime: CreateRuntime;
|
|
40
|
-
readonly ctx: ContextContainer;
|
|
41
|
-
readonly emit: HarnessEmitFn;
|
|
42
|
-
readonly input: {
|
|
43
|
-
readonly message: string | UserContent;
|
|
44
|
-
};
|
|
45
|
-
readonly park: () => Promise<void>;
|
|
46
|
-
readonly queue: QueueItem[];
|
|
47
|
-
readonly wake: () => void;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Result returned when the continuous entry completes.
|
|
51
|
-
*/
|
|
52
|
-
export interface ContinuousEntryResult {
|
|
53
|
-
readonly output: string;
|
|
54
|
-
readonly status: "completed";
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Main body of a continuous (in-memory) run.
|
|
58
|
-
*/
|
|
59
|
-
export declare function continuousEntry(input: ContinuousEntryInput): Promise<ContinuousEntryResult>;
|