experimental-ash 0.22.1 → 0.23.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 +20 -0
- package/dist/docs/public/faqs.md +67 -0
- package/dist/docs/public/meta.json +1 -0
- package/dist/docs/public/sandbox.md +25 -0
- package/dist/docs/public/schedules.md +11 -0
- package/dist/docs/public/session-context.md +46 -89
- package/dist/docs/public/skills.md +13 -0
- package/dist/docs/public/subagents.md +12 -6
- package/dist/docs/public/tools.md +9 -13
- package/dist/docs/public/typescript-api.md +2 -2
- package/dist/src/chunks/{client-CKsU8Li3.js → client-nshDsWNF.js} +1 -1
- package/dist/src/chunks/{dev-authored-source-watcher-Bj0TDis0.js → dev-authored-source-watcher-d_35Mp8T.js} +1 -1
- package/dist/src/chunks/{host-BDf7A9G7.js → host-tji7W0Nn.js} +54 -11
- package/dist/src/chunks/paths-YoCQlavu.js +89 -0
- package/dist/src/chunks/{prewarm-xQtl6kAD.js → prewarm-6duWvvb5.js} +1 -1
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/dev/repl.js +2 -2
- package/dist/src/cli/run.js +1 -1
- package/dist/src/client/session.js +8 -0
- package/dist/src/client/types.d.ts +12 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiled/@workflow/core/_ms.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/_workflow-serde.d.ts +5 -0
- package/dist/src/compiled/@workflow/core/_workflow-utils.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/_workflow-world.d.ts +59 -0
- package/dist/src/compiled/@workflow/core/capabilities.d.ts +45 -0
- package/dist/src/compiled/@workflow/core/capture-stack.d.ts +16 -0
- package/dist/src/compiled/@workflow/core/class-serialization.d.ts +31 -0
- package/dist/src/compiled/@workflow/core/classify-error.d.ts +19 -0
- package/dist/src/compiled/@workflow/core/context-errors.d.ts +27 -0
- package/dist/src/compiled/@workflow/core/context-violation-error.d.ts +97 -0
- package/dist/src/compiled/@workflow/core/create-hook.d.ts +179 -0
- package/dist/src/compiled/@workflow/core/define-hook.d.ts +68 -0
- package/dist/src/compiled/@workflow/core/describe-error.d.ts +70 -0
- package/dist/src/compiled/@workflow/core/encryption.d.ts +45 -0
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +64 -0
- package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +82 -0
- package/dist/src/compiled/@workflow/core/global.d.ts +48 -0
- package/dist/src/compiled/@workflow/core/index.d.ts +19 -38
- package/dist/src/compiled/@workflow/core/log-format.d.ts +25 -0
- package/dist/src/compiled/@workflow/core/logger.d.ts +29 -0
- package/dist/src/compiled/@workflow/core/private.d.ts +59 -10
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/runtime/get-port-lazy.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/runtime/get-world-lazy.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +97 -0
- package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +77 -0
- package/dist/src/compiled/@workflow/core/runtime/run.d.ts +134 -0
- package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +50 -0
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +59 -0
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +40 -0
- package/dist/src/compiled/@workflow/core/runtime/step-handler.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +42 -0
- package/dist/src/compiled/@workflow/core/runtime/world-init.d.ts +75 -0
- package/dist/src/compiled/@workflow/core/runtime/world.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/runtime.d.ts +22 -67
- package/dist/src/compiled/@workflow/core/schemas.d.ts +15 -0
- package/dist/src/compiled/@workflow/core/serialization/client.d.ts +17 -0
- package/dist/src/compiled/@workflow/core/serialization/codec-devalue.d.ts +14 -0
- package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +90 -0
- package/dist/src/compiled/@workflow/core/serialization/encryption.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/serialization/errors.d.ts +21 -0
- package/dist/src/compiled/@workflow/core/serialization/format.d.ts +60 -0
- package/dist/src/compiled/@workflow/core/serialization/index.d.ts +18 -0
- package/dist/src/compiled/@workflow/core/serialization/reducers/class.d.ts +11 -0
- package/dist/src/compiled/@workflow/core/serialization/reducers/common.d.ts +16 -0
- package/dist/src/compiled/@workflow/core/serialization/reducers/step-function.d.ts +35 -0
- package/dist/src/compiled/@workflow/core/serialization/step.d.ts +17 -0
- package/dist/src/compiled/@workflow/core/serialization/types.d.ts +201 -0
- package/dist/src/compiled/@workflow/core/serialization/workflow.d.ts +29 -0
- package/dist/src/compiled/@workflow/core/serialization-format.d.ts +171 -0
- package/dist/src/compiled/@workflow/core/serialization.d.ts +329 -0
- package/dist/src/compiled/@workflow/core/sleep.d.ts +33 -0
- package/dist/src/compiled/@workflow/core/source-map.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +13 -0
- package/dist/src/compiled/@workflow/core/step/get-closure-vars.d.ts +9 -0
- package/dist/src/compiled/@workflow/core/step/get-step-metadata.d.ts +42 -0
- package/dist/src/compiled/@workflow/core/step/get-workflow-metadata.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/step/writable-stream.d.ts +22 -0
- package/dist/src/compiled/@workflow/core/step.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/symbols.d.ts +20 -0
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +283 -0
- package/dist/src/compiled/@workflow/core/telemetry.d.ts +53 -0
- package/dist/src/compiled/@workflow/core/types.d.ts +14 -0
- package/dist/src/compiled/@workflow/core/util.d.ts +40 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/vm/index.d.ts +17 -0
- package/dist/src/compiled/@workflow/core/vm/uint8array-base64.d.ts +21 -0
- package/dist/src/compiled/@workflow/core/vm/uuid.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/workflow/abort-controller.d.ts +65 -0
- package/dist/src/compiled/@workflow/core/workflow/create-hook.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/workflow/define-hook.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/workflow/get-workflow-metadata.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/workflow/hook.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/workflow/index.d.ts +11 -0
- package/dist/src/compiled/@workflow/core/workflow/sleep.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/workflow/world-init-stub.d.ts +15 -0
- package/dist/src/compiled/@workflow/core/workflow/writable-stream.d.ts +3 -0
- package/dist/src/compiled/@workflow/core/workflow.d.ts +1 -38
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.js +38 -6
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +14 -12
- package/dist/src/internal/workflow-bundle/ash-service-route-output.d.ts +4 -0
- package/dist/src/internal/workflow-bundle/ash-service-route-output.js +134 -0
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.d.ts +3 -1
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +8 -23
- package/dist/src/protocol/message.d.ts +6 -1
- package/dist/src/public/channels/ash.js +50 -3
- package/dist/src/public/context/index.d.ts +4 -7
- package/dist/src/public/context/index.js +4 -5
- package/dist/src/public/definitions/state.d.ts +33 -0
- package/dist/src/public/definitions/state.js +34 -0
- package/dist/src/public/next/index.d.ts +7 -0
- package/dist/src/public/next/index.js +9 -2
- package/dist/src/public/next/vercel-json.d.ts +1 -0
- package/dist/src/public/next/vercel-json.js +1 -0
- package/dist/src/public/sandbox/backends/vercel.d.ts +7 -0
- package/dist/src/public/sandbox/backends/vercel.js +7 -0
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +14 -4
- package/dist/src/react/index.d.ts +1 -1
- package/dist/src/react/use-ash-agent.d.ts +8 -0
- package/dist/src/react/use-ash-agent.js +26 -4
- package/dist/src/services/dev-client.d.ts +4 -1
- package/dist/src/services/dev-client.js +1 -0
- package/package.json +1 -1
- package/dist/src/chunks/paths-DxgjK2PI.js +0 -88
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
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
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
4
|
`?n+2:e[n]===`
|
|
@@ -10,13 +10,56 @@ const workflowCode = \`${(e.code.endsWith(`
|
|
|
10
10
|
`)?e.code:`${e.code}\n`).replace(/[\\`$]/g,`\\$&`)}\`;
|
|
11
11
|
|
|
12
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`)}async function En(e,n,r){if(xn(r.surface)){let t=f(),i=new tn({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});bn(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}),Tn(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:gn}),G(e,{handlerPath:d(`src/internal/nitro/routes/workflow-run.ts`),method:`GET`,route:_n}),G(e,{handlerPath:d(`src/internal/nitro/routes/workflow-run-steps.ts`),method:`GET`,route:vn}),G(e,{handlerPath:d(`src/internal/nitro/routes/workflow-run-events.ts`),method:`GET`,route:yn}),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 Cn(e,{bundleName:`workflows`,bundlePath:o,directHandlers:s,route:`/.well-known/workflow/v1/flow`,runtimeImportSpecifier:c}),e.routing.sync()}function Dn(){return`${g}/cron/${me()}`}function On(e){e.options.vercel!==void 0&&(e.options.vercel.cronHandlerRoute=Dn())}function kn(e){return{plugins:[c(),...e]}}function An(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 jn=`@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 Mn(e){if(e)return{config:{version:3,framework:{version:h().version}}}}const Nn=[`workflow`,`workflow/api`,`workflow/errors`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`],Pn=Symbol(`ash.workflow-transform-patched`),Fn=[`@napi-rs/keyring`];function In(){let e={};for(let t of Nn)e[t]=u(t);return e}function Ln(e){if(!e&&process.env.VERCEL)return`vercel`}function Rn(e){return e===`all`||e===`app`}function zn(e){return e===`all`||e===`flow`}function Bn(e){return zn(e)}function Vn(e,t){return e.options.dev?v(e.options.buildDir,`workflow`,`steps.mjs`):v(t.workflowBuildDir,`steps.mjs`)}function Hn(e){let t=e.compileResult.manifest.config.build;return[...new Set([...Fn,...jn,...t?.externalDependencies??[]])].filter(e=>e!==p)}function q(e){return e.replaceAll(`\\`,`/`)}function Un(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 Wn(e){return e.startsWith(`/@fs/`)?e.slice(4):e}function J(e,t){return t.startsWith(`file://`)?q(Wn(Un(_e(t)))):ue(t)?q(Wn(Un(t))):q(Wn(Un(b(e,t))))}function Gn(e,t){let n=q(e);return n.startsWith(t)||n.includes(`/.ash/workflow-cache/`)}function Kn(e){let t=q(e);return process.platform===`win32`?t.toLowerCase():t}function qn(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 Y(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 Jn(e,t){let n=await C(e,`utf8`),r=new Set;for(let i of qn(n)){let n=Y(t,i,e);n!==null&&r.add(Kn(n))}return r}async function Yn(e,t){if(e.options.noExternals===!0)return;let n;try{n=await Jn(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 Xn(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 Zn(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=Y(e.options.rootDir,t,r)??J(e.options.rootDir,t);return n.some(e=>Gn(i,e))?{id:i,moduleSideEffects:`no-treeshake`}:null}})})}function Qn(e,t){let n=null,r=async()=>(n===null&&(n=await Jn(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=Y(e.options.rootDir,t,n);return i===null||!(await r()).has(Kn(i))?null:{id:i,moduleSideEffects:`no-treeshake`}}})})}function $n(e,t){let n=null,r=async()=>(n===null&&(n=await Jn(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(Kn(a))?{code:(await j(Xn(e.options.rootDir,a),t,`step`,a,e.options.rootDir)).code,map:null}:null},name:`ash:workflow-step-transform`})})}function er(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 tr(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[Pn]===!0||typeof t.transform!=`function`)continue;let r=t.transform;t.transform=function(e,t,...i){return Gn(t,n)?null:r.call(this,e,t,...i)},t[Pn]=!0}})}async function X(e,t,n={}){let r=n.surface??`all`,a=(!t||n.schedules===!0)&&Rn(r)&&e.scheduleRegistrations.length>0,o=Ln(t),s=o===`vercel`?hn():null,c=s===null?[]:[s],l=kn(c),u=kn(c),f=Hn(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:Bn(r)?[m(`src/execution`)]:void 0,rolldownConfig:l,rollupConfig:u,rootDir:e.appRoot,serverDir:!1,traceDeps:f,vercel:Mn(o===`vercel`&&Rn(r))},t?{watch:!0}:void 0);if(await O(p),An(g),zn(r)){let t=In();for(let[e,n]of Object.entries(t))g.options.alias[e]=n;Zn(g,e.workflowBuildDir),tr(g,e.workflowBuildDir)}if(Bn(r)){let t=Vn(g,e);Qn(g,{stepEntrypointPath:t}),$n(g,{stepEntrypointPath:t})}if(e.compiledArtifacts.instrumentationSourcePath!==void 0&&er(g,e.compiledArtifacts.instrumentationSourcePath),t&&zn(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&&(On(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 En(g,e,{surface:r}),Bn(r)&&await Yn(g,Vn(g,e)),g}function nr(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 rr(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?or(t.instructions):null,schedules:t.schedules.map(sr),tools:t.tools.map(cr),skills:t.skills.map(lr),connections:t.connections.map(ur),channels:t.channels.filter(ar).map(dr),sandbox:t.sandbox===null?null:{logicalPath:t.sandbox.logicalPath},subagents:t.subagents.map(fr),diagnostics:{errors:t.diagnosticsSummary.errors,warnings:t.diagnosticsSummary.warnings}}}async function ir(e){let t=rr({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 ar(e){return e.kind===`channel`}function or(e){return{logicalPath:e.logicalPath,sourceKind:e.sourceKind,markdown:e.markdown}}function sr(e){return{name:e.name,cron:e.cron,logicalPath:e.logicalPath}}function cr(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function lr(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath,sourceKind:e.sourceKind}}function ur(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 dr(e){let t={name:e.name,method:e.method,urlPath:e.urlPath,type:nr(e.adapterKind),logicalPath:e.logicalPath};return e.adapterKind===void 0?t:{...t,adapterKind:e.adapterKind}}function fr(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function pr(){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 mr(e){return pr()?(await se(e),!0):!1}function hr(e){return e.replace(/[\\/]+$/,``)}function gr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _r(e,t){return typeof t!=`string`||t.trim().length===0?null:b(e,t)}function vr(e){if(!gr(e.config)||!gr(e.config.experimentalServices))return!1;let t=!1,n=!1;for(let r of Object.values(e.config.experimentalServices)){if(!gr(r))continue;if(r.framework===`nextjs`){t=!0;continue}if(r.framework!==`ash`)continue;let i=_r(e.configRoot,r.entrypoint),a=typeof r.routePrefix==`string`?r.routePrefix.trim():``;i===e.appRoot&&a.length>0&&a!==`/`&&(n=!0)}return t&&n}async function yr(e){let t=e;for(;;){try{let n=v(t,`vercel.json`),r=JSON.parse(await C(n,`utf8`));if(vr({appRoot:e,configRoot:t,config:r}))return!0}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let n=_(t);if(n===t)return!1;t=n}}async function br(e){try{return JSON.parse(await C(v(e,`functions`,`__server.func`,`.vc-config.json`),`utf8`)).runtime}catch{return}}async function xr(e){let t=new tn({appRoot:e.appRoot,compiledArtifactsBootstrapPath:e.compiledArtifactsBootstrapPath,outDir:e.workflowBuildDir,rootDir:f(),watch:!1}),n=await br(e.outputDir);await t.buildVercelOutput({flowNitroOutputDir:e.flowNitroOutputDir,outputDir:e.outputDir,runtime:n})}async function Sr(e){let t=hr(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 Cr(e,t){let n=await X(e,!1,{outputDir:r(e.appRoot,t),surface:t});try{return await Sr(n)}finally{await n.close()}}async function wr(e){let t=await ie(e);if(!process.env.VERCEL){let e=await X(t,!1);try{let n=await Sr(e);return await ir({manifest:t.compileResult.manifest,appRoot:t.appRoot}),n}finally{await e.close()}}let n=await X(t,!1,{surface:`app`});try{let e=await Sr(n);await mr({appRoot:t.appRoot,log(e){console.log(e)}});let r=await Cr(t,`flow`);return await xr({appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,flowNitroOutputDir:r,outputDir:e,workflowBuildDir:t.workflowBuildDir}),await yr(t.appRoot)&&await Vt(e),await ir({manifest:t.compileResult.manifest,appRoot:t.appRoot}),e}finally{await n.close()}}const Z=65535,Q=`WORKFLOW_LOCAL_BASE_URL`,$=`PORT`,Tr=new Set([`[::]`,`::`,`0.0.0.0`]);function Er(e){let t=new URL(e);return Tr.has(t.hostname)?(t.hostname=`127.0.0.1`,t.toString()):e}function Dr(e){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`}function Or(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 kr(){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 Ar(e){let t=Or(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 jr(e){let t=process.env[Q],n=process.env[$],r=new URL(Er(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 Mr(e){let t=()=>{};return e.once(`error`,t),()=>{e.off(`error`,t)}}function Nr(e){let t=e.upgrade.bind(e);e.upgrade=async(e,n,r)=>{let i=Mr(n);try{await t(e,n,r)}catch{n.destroyed||n.destroy()}finally{i()}}}async function Pr(e){let t=Ar({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(()=>{}),!Dr(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 Fr(e,t={}){let n=t.schedules===!0,r=await ie(e);await se({appRoot:r.appRoot,log:e=>console.log(e)});let i=await X(r,!0,{schedules:n}),a=xe(i);Nr(a);let o=t.host??i.options.devServer.hostname,s=t.port??kr(),c=s??i.options.devServer.port,l=s===void 0,u;try{let e=await Pr({devServer:a,host:o,port:c,retryOnAddressInUse:l});if(!e.url)throw Error(`Nitro dev server did not expose a URL.`);u=jr(e.url),await Ce(i),await ye(i);let{startAuthoredSourceWatcher:t}=await import(`./dev-authored-source-watcher-Bj0TDis0.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:Er(e.url)}}catch(e){throw u?.(),await a.close().catch(()=>{}),await i.close().catch(()=>{}),e}}var Ir=e({buildHost:()=>Lr,startHost:()=>Rr});async function Lr(e){return await wr(e)}async function Rr(e,t={}){return await Fr(e,t)}export{Rr as n,Ir as t};
|
|
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};
|