experimental-ash 0.29.0 → 0.30.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 +34 -0
- package/dist/src/context/hook-lifecycle.d.ts +23 -67
- package/dist/src/context/hook-lifecycle.js +1 -1
- package/dist/src/execution/await-authorization-orchestrator.d.ts +18 -29
- package/dist/src/execution/await-authorization-orchestrator.js +1 -1
- package/dist/src/execution/connection-auth-steps.d.ts +28 -65
- package/dist/src/execution/connection-auth-steps.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +15 -0
- package/dist/src/execution/create-session-step.js +1 -0
- package/dist/src/execution/delegated-parent-notification.d.ts +15 -0
- package/dist/src/execution/delegated-parent-notification.js +1 -0
- package/dist/src/execution/delegated-parent-result.d.ts +14 -0
- package/dist/src/execution/delegated-parent-result.js +1 -0
- package/dist/src/execution/dispatch-runtime-actions-step.d.ts +20 -0
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -0
- package/dist/src/execution/durable-session-migrations/chain.d.ts +31 -0
- package/dist/src/execution/durable-session-migrations/chain.js +1 -0
- package/dist/src/execution/durable-session-migrations/snapshot.d.ts +22 -0
- package/dist/src/execution/durable-session-migrations/snapshot.js +1 -0
- package/dist/src/execution/durable-session-store.d.ts +104 -0
- package/dist/src/execution/durable-session-store.js +1 -0
- package/dist/src/execution/next-driver-action.d.ts +30 -0
- package/dist/src/execution/next-driver-action.js +1 -0
- package/dist/src/execution/session.d.ts +29 -28
- package/dist/src/execution/session.js +1 -1
- package/dist/src/execution/subagent-hitl-proxy.d.ts +8 -25
- package/dist/src/execution/subagent-hitl-proxy.js +1 -1
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/execution/turn-workflow.d.ts +21 -21
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-entry.d.ts +12 -16
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.d.ts +36 -91
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/emission.d.ts +3 -5
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/input-requests.d.ts +3 -3
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +12 -16
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/runtime-actions.d.ts +17 -24
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/types.d.ts +3 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/routes/info.js +1 -1
- package/dist/src/internal/workflow-bundle/builder.d.ts +2 -0
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/runtime/framework-channels/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildAgentInfoResponse}from"#internal/nitro/routes/agent-info/build-agent-info-response.js";import{loadAgentInfoData,resolveAgentInfoCompiledArtifactsSource}from"#internal/nitro/routes/agent-info/load-agent-info-data.js";import{createUnauthorizedResponse,none,vercelOidc}from"#public/channels/auth.js";function resolveAgentInfoAuth(){return process.env.VERCEL
|
|
1
|
+
import{buildAgentInfoResponse}from"#internal/nitro/routes/agent-info/build-agent-info-response.js";import{loadAgentInfoData,resolveAgentInfoCompiledArtifactsSource}from"#internal/nitro/routes/agent-info/load-agent-info-data.js";import{createUnauthorizedResponse,none,vercelOidc}from"#public/channels/auth.js";function resolveAgentInfoAuth(){return process.env.VERCEL&&process.env.VERCEL_ENV!==`development`?vercelOidc():none()}async function createAgentInfoPayload(n){return buildAgentInfoResponse(await loadAgentInfoData({compiledArtifactsSource:resolveAgentInfoCompiledArtifactsSource({appRoot:n.appRoot})}))}async function handleAgentInfoRequest(e,t){return await resolveAgentInfoAuth()(t)===null?createUnauthorizedResponse({challenges:[{scheme:`Bearer`}]}):new Response(JSON.stringify(await createAgentInfoPayload(e)),{headers:{"cache-control":`no-store`,"content-type":`application/json; charset=utf-8`}})}export{handleAgentInfoRequest};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{dirname,join,relative,resolve}from"node:path";import{cp,mkdir,readFile,rm,writeFile}from"node:fs/promises";import{resolvePackageSourceDirectoryPath,resolveWorkflowModulePath}from"#internal/application/package.js";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";import{buildWithNitroRolldown,getSingleRolldownChunk}from"#internal/bundler/nitro-rolldown.js";import{prepareAshVersionedCacheDirectory,writeAshVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{WORKFLOW_BUILDER_DEFERRED_PACKAGES,WORKFLOW_STEP_EXTERNAL_PACKAGES,copyNitroFunctionDirectory,createWorkflowFunctionEnvironment,retargetNitroFunctionDirectoryToWorkflowRoute}from"#internal/workflow-bundle/vercel-workflow-output.js";import{WORKFLOW_QUEUE_TRIGGER,detectWorkflowPatterns}from"#internal/workflow-bundle/workflow-builders.js";import{Buffer}from"node:buffer";import{WORKFLOW_VIRTUAL_ENTRY_ID,atomicWriteFile,bundleFinalWorkflowOutput,collectWorkflowInputFiles,convertClassesManifest,convertStepsManifest,convertWorkflowsManifest,createAshPackageImportsPlugin,createWorkflowImport,createWorkflowPseudoPackagePlugin,createWorkflowTransformPlugin,createWorkflowVirtualEntryPlugin}from"#internal/workflow-bundle/builder-support.js";import{writeNitroStepEntrypoint}from"#internal/workflow-bundle/nitro-step-entry.js";const workflowBundleBuildLocks=new Map;var WorkflowBundleBuilder=class{#e;#t;config;#n=new WeakMap;constructor(e){
|
|
1
|
+
import{dirname,join,relative,resolve}from"node:path";import{cp,mkdir,readFile,rm,writeFile}from"node:fs/promises";import{resolvePackageSourceDirectoryPath,resolveWorkflowModulePath}from"#internal/application/package.js";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";import{buildWithNitroRolldown,getSingleRolldownChunk}from"#internal/bundler/nitro-rolldown.js";import{prepareAshVersionedCacheDirectory,writeAshVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{WORKFLOW_BUILDER_DEFERRED_PACKAGES,WORKFLOW_STEP_EXTERNAL_PACKAGES,copyNitroFunctionDirectory,createWorkflowFunctionEnvironment,retargetNitroFunctionDirectoryToWorkflowRoute}from"#internal/workflow-bundle/vercel-workflow-output.js";import{WORKFLOW_QUEUE_TRIGGER,detectWorkflowPatterns}from"#internal/workflow-bundle/workflow-builders.js";import{Buffer}from"node:buffer";import{WORKFLOW_VIRTUAL_ENTRY_ID,atomicWriteFile,bundleFinalWorkflowOutput,collectWorkflowInputFiles,convertClassesManifest,convertStepsManifest,convertWorkflowsManifest,createAshPackageImportsPlugin,createWorkflowImport,createWorkflowPseudoPackagePlugin,createWorkflowTransformPlugin,createWorkflowVirtualEntryPlugin}from"#internal/workflow-bundle/builder-support.js";import{writeNitroStepEntrypoint}from"#internal/workflow-bundle/nitro-step-entry.js";const workflowBundleBuildLocks=new Map;var WorkflowBundleBuilder=class{#e;#t;config;#n=new WeakMap;constructor(e){let t=[resolvePackageSourceDirectoryPath(`src/execution`)];e.includeTestFixtures===!0&&t.push(resolvePackageSourceDirectoryPath(`src/internal/testing`)),this.config={buildTarget:`standalone`,dirs:t,externalPackages:[...WORKFLOW_STEP_EXTERNAL_PACKAGES,...WORKFLOW_BUILDER_DEFERRED_PACKAGES],projectRoot:e.appRoot,watch:e.watch,workingDir:e.rootDir},this.#e=e.compiledArtifactsBootstrapPath,this.#t=e.outDir}async build(e={}){let t=(workflowBundleBuildLocks.get(this.#t)??Promise.resolve()).then(()=>this.#r(e));workflowBundleBuildLocks.set(this.#t,t.catch(()=>{})),await t}async#r(n){await prepareAshVersionedCacheDirectory(this.#t);let r=await this.#i();if(r.length===0)throw Error(`Expected the execution workflow source file under "${resolvePackageSourceDirectoryPath(`src/execution`)}".`);let i=await this.findTsConfigPath();await mkdir(this.#t,{recursive:!0});let o=await this.discoverEntries(r,this.#t,i),s=join(this.#t,`workflows.mjs`),{manifest:c}=await this.createWorkflowsBundle({discoveredEntries:o,keepInterimBundleContext:!1,outfile:s,bundleFinalOutput:!1,format:`esm`,inputFiles:r,tsconfigPath:i}),d=join(this.#t,`steps.mjs`),f=await writeNitroStepEntrypoint({builtinsPath:resolveWorkflowModulePath(`workflow/internal/builtins`),discoveredEntries:o,outfile:d,preferAbsoluteFileImports:!0,projectRoot:this.config.projectRoot??this.config.workingDir,workingDir:this.config.workingDir}),p=n.nitroStepOutfile;p!==void 0&&p!==d&&await writeNitroStepEntrypoint({builtinsPath:resolveWorkflowModulePath(`workflow/internal/builtins`),discoveredEntries:o,outfile:p,preferAbsoluteFileImports:!0,projectRoot:this.config.projectRoot??this.config.workingDir,workingDir:this.config.workingDir}),await addStepRegistrationsImport(s,d),await rewriteWorkflowRuntimeImports(s),await rewriteWorkflowCodeLiteral(s);let g=n.nitroWorkflowOutfile;g!==void 0&&g!==s&&(await mkdir(dirname(g),{recursive:!0}),await mirrorFileBypassingUnlink(s,g),p!==void 0&&(await addStepRegistrationsImport(g,p),await rewriteWorkflowRuntimeImports(g),await rewriteWorkflowCodeLiteral(g))),await this.createManifest({workflowBundlePath:join(this.#t,`workflows.mjs`),manifestDir:this.#t,manifest:{steps:{...f.steps,...c.steps},workflows:{...f.workflows,...c.workflows},classes:{...f.classes,...c.classes}}}),await writeAshVersionedCacheMetadata(this.#t)}get transformProjectRoot(){return this.config.projectRoot??this.config.workingDir}async findTsConfigPath(){let n=this.config.workingDir;for(;;){for(let e of[`tsconfig.json`,`jsconfig.json`]){let r=join(n,e);try{return await readFile(r),r}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}}let r=dirname(n);if(r===n)return;n=r}}async getInputFiles(){let e=this.config.dirs.map(e=>resolve(this.config.workingDir,e));return(await Promise.all(e.map(e=>collectWorkflowInputFiles(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=detectWorkflowPatterns(await readFile(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:t=!0,discoveredEntries:n,format:r=`cjs`,inputFiles:i,keepInterimBundleContext:a=this.config.watch,outfile:o,tsconfigPath:s}){let c=n??await this.discoverEntries(i,dirname(o),s),l=[...c.discoveredWorkflows].sort(),u=new Set(l),d=[...c.discoveredSerdeFiles].sort().filter(e=>!u.has(e)),m={},h=[...l.map(e=>createWorkflowImport(e,this.config.workingDir)),...d.map(e=>createWorkflowImport(e,this.config.workingDir))].join(`
|
|
2
2
|
`);return await bundleFinalWorkflowOutput({bundleFinalOutput:t,code:getSingleRolldownChunk(await buildWithNitroRolldown({cwd:this.config.workingDir,input:WORKFLOW_VIRTUAL_ENTRY_ID,platform:`neutral`,plugins:[createWorkflowVirtualEntryPlugin(h),createWorkflowPseudoPackagePlugin(),createAshPackageImportsPlugin(this.config.workingDir,{workflowCondition:!0}),createWorkflowTransformPlugin({manifest:m,projectRoot:this.transformProjectRoot,sideEffectFiles:[...l,...d],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:s??!1,write:!1,output:{banner:`globalThis.__private_workflows = new Map();`,codeSplitting:!1,comments:!1,format:`cjs`,sourcemap:`inline`}}),`intermediate workflow bundle for "${o}"`).code,format:r,outfile:o,workingDir:this.config.workingDir}),a?{bundleFinal:async e=>{await bundleFinalWorkflowOutput({bundleFinalOutput:t,code:e,format:r,outfile:o,workingDir:this.config.workingDir})},interimBundleCtx:void 0,manifest:m}:{manifest:m}}async createManifest({manifest:e,manifestDir:n}){let r={version:`1.0.0`,steps:convertStepsManifest(e.steps),workflows:convertWorkflowsManifest(e.workflows),classes:convertClassesManifest(e.classes)},i=JSON.stringify(r,null,2);return await mkdir(n,{recursive:!0}),await writeFile(join(n,`manifest.json`),i),i}async buildVercelOutput(e){await this.build();let n=join(this.#t,`vercel-build-output`,`functions`,`.well-known`,`workflow`,`v1`),r=join(n,`flow.func`),o=join(e.outputDir,`functions`,`.well-known`,`workflow`,`v1`),c=join(e.flowNitroOutputDir,`functions`,`__server.func`),l=join(e.flowNitroOutputDir,`functions`,`.well-known`,`workflow`,`v1`,`flow.func`),u=join(o,`flow.func`),d=join(o,`step.func`),f=join(o,`webhook`,`[token].func`);await copyNitroFunctionDirectory({fallbackPath:c,sourcePath:l,targetPath:r}),await Promise.all([this.#a(r,{experimentalTriggers:Array.from([WORKFLOW_QUEUE_TRIGGER]),maxDuration:`max`,runtime:e.runtime??null,shouldAddHelpers:!1}),cp(join(this.#t,`manifest.json`),join(n,`manifest.json`))]),await retargetNitroFunctionDirectoryToWorkflowRoute({functionDirectoryPath:r,workflowRoutePath:`/.well-known/workflow/v1/flow`}),await Promise.all([rm(u,{force:!0,recursive:!0}),rm(d,{force:!0,recursive:!0}),rm(f,{force:!0,recursive:!0})]),await mkdir(o,{recursive:!0}),await Promise.all([cp(r,u,{recursive:!0}),cp(join(n,`manifest.json`),join(o,`manifest.json`))])}async#i(){return[...await this.getInputFiles(),this.#e]}async#a(e,n){let r=join(e,`.vc-config.json`),i=await this.#o(r),a={...i};a.environment=createWorkflowFunctionEnvironment(i.environment),n.runtime!==null&&(a.runtime=n.runtime),n.maxDuration!==void 0&&(a.maxDuration=n.maxDuration),n.shouldAddHelpers!==void 0&&(a.shouldAddHelpers=n.shouldAddHelpers),n.shouldAddSourcemapSupport!==void 0&&(a.shouldAddSourcemapSupport=n.shouldAddSourcemapSupport),n.experimentalTriggers!==void 0&&(a.experimentalTriggers=[...n.experimentalTriggers]),await writeFile(r,`${JSON.stringify(a,null,2)}\n`)}async#o(e){try{let t=JSON.parse(await readFile(e,`utf8`));if(typeof t==`object`&&t)return t}catch{}return{}}};async function addStepRegistrationsImport(t,n){let r=await readTextFileIfPresent(t);if(r===null||r.includes(`__ashWorkflowStepsRegistered`))return;let i=createRelativeImportSpecifier(dirname(t),n),a=[`import { __steps_registered as __ashWorkflowStepsRegistered } from ${JSON.stringify(i)};`,`void __ashWorkflowStepsRegistered;`,``].join(`
|
|
3
3
|
`),o=r.match(/^import\s.+?;\n/m);if(o===null||o.index===void 0){await atomicWriteFile(t,`${a}${r}`);return}let s=o.index+o[0].length;await atomicWriteFile(t,`${r.slice(0,s)}${a}${r.slice(s)}`)}async function rewriteWorkflowRuntimeImports(e){let t=await readTextFileIfPresent(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=normalizeImportSpecifierPath(resolveWorkflowModulePath(e));n=replaceStringLiteralSpecifier(n,e,t)}n!==t&&await atomicWriteFile(e,n)}async function rewriteWorkflowCodeLiteral(e){let t=await readTextFileIfPresent(e);if(t===null)return;let n=t.indexOf(`const workflowCode = `),r=t.lastIndexOf(`;
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{none,vercelOidc}from"#public/channels/auth.js";import{ashChannel}from"#public/channels/ash.js";import{getConnectionCallbackChannelDefinitions,getConnectionCallbackChannelNames}from"#runtime/connections/callback-route.js";import{getSessionCallbackChannelDefinitions,getSessionCallbackChannelNames}from"#runtime/session-callback-route.js";function getFrameworkChannelDefinitions(){let e=ashChannel({auth:resolveFrameworkAshAuth()}),t=[];for(let n of e.routes)t.push({name:`ash`,method:n.method.toUpperCase(),urlPath:n.path,fetch:async(e,t)=>n.handler(e,t),handler:n.handler,adapter:e.adapter,logicalPath:`framework://channels/${n.path}`,sourceId:`ash:framework:${n.method.toLowerCase()}-${n.path}`,sourceKind:`module`});return t.push(...getConnectionCallbackChannelDefinitions(),...getSessionCallbackChannelDefinitions()),t}function getAllFrameworkChannelNames(){return new Set([`ash`,...getConnectionCallbackChannelNames(),...getSessionCallbackChannelNames()])}function resolveFrameworkAshAuth(){return process.env.VERCEL
|
|
1
|
+
import{none,vercelOidc}from"#public/channels/auth.js";import{ashChannel}from"#public/channels/ash.js";import{getConnectionCallbackChannelDefinitions,getConnectionCallbackChannelNames}from"#runtime/connections/callback-route.js";import{getSessionCallbackChannelDefinitions,getSessionCallbackChannelNames}from"#runtime/session-callback-route.js";function getFrameworkChannelDefinitions(){let e=ashChannel({auth:resolveFrameworkAshAuth()}),t=[];for(let n of e.routes)t.push({name:`ash`,method:n.method.toUpperCase(),urlPath:n.path,fetch:async(e,t)=>n.handler(e,t),handler:n.handler,adapter:e.adapter,logicalPath:`framework://channels/${n.path}`,sourceId:`ash:framework:${n.method.toLowerCase()}-${n.path}`,sourceKind:`module`});return t.push(...getConnectionCallbackChannelDefinitions(),...getSessionCallbackChannelDefinitions()),t}function getAllFrameworkChannelNames(){return new Set([`ash`,...getConnectionCallbackChannelNames(),...getSessionCallbackChannelNames()])}function resolveFrameworkAshAuth(){return process.env.VERCEL&&process.env.VERCEL_ENV!==`development`?vercelOidc():none()}export{getAllFrameworkChannelNames,getFrameworkChannelDefinitions};
|