experimental-ash 0.25.1 → 0.25.2
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 +6 -0
- package/dist/src/channel/routes.d.ts +6 -1
- package/dist/src/channel/send.js +5 -2
- package/dist/src/channel/session-callback.d.ts +10 -0
- package/dist/src/channel/session-callback.js +65 -0
- package/dist/src/channel/types.d.ts +19 -0
- package/dist/src/chunks/{client-BShLWzR6.js → client-ZqNLLMZB.js} +3 -3
- package/dist/src/chunks/{compile-agent-CyP6FrL8.js → compile-agent-C4OrJW6C.js} +1 -1
- package/dist/src/chunks/{dev-authored-source-watcher-DIWfVUsu.js → dev-authored-source-watcher-PwAxalwl.js} +1 -1
- package/dist/src/chunks/host-F-DkwYJK.js +70 -0
- package/dist/src/chunks/paths-DnlVBqHu.js +85 -0
- package/dist/src/chunks/{token-BOkIxJeV.js → token-YW4VSeBB.js} +1 -1
- package/dist/src/chunks/types-BJSR0JNV.js +1 -0
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/dev/repl.js +3 -3
- package/dist/src/cli/run.js +1 -1
- package/dist/src/client/message-reducer.js +6 -0
- package/dist/src/context/keys.d.ts +1 -1
- package/dist/src/context/keys.js +1 -1
- package/dist/src/context/seed-keys.d.ts +5 -1
- package/dist/src/context/seed-keys.js +4 -0
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/await-authorization-orchestrator.js +1 -1
- package/dist/src/execution/node-step.js +13 -0
- package/dist/src/execution/remote-agent-dispatch.d.ts +15 -0
- package/dist/src/execution/remote-agent-dispatch.js +79 -0
- package/dist/src/execution/runtime-context.js +4 -1
- package/dist/src/execution/session-callback-step.d.ts +16 -0
- package/dist/src/execution/session-callback-step.js +72 -0
- package/dist/src/execution/subagent-invocation.d.ts +16 -0
- package/dist/src/execution/subagent-invocation.js +16 -0
- package/dist/src/execution/subagent-tool.js +5 -8
- package/dist/src/execution/workflow-entry.js +21 -1
- package/dist/src/execution/workflow-steps.d.ts +6 -1
- package/dist/src/execution/workflow-steps.js +76 -25
- package/dist/src/harness/execute-tool.d.ts +3 -3
- package/dist/src/harness/runtime-actions.d.ts +1 -0
- package/dist/src/harness/runtime-actions.js +18 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/protocol/message.d.ts +6 -0
- package/dist/src/protocol/message.js +1 -0
- package/dist/src/protocol/routes.d.ts +11 -0
- package/dist/src/protocol/routes.js +13 -0
- package/dist/src/public/channels/ash.js +25 -1
- package/dist/src/runtime/actions/keys.js +2 -0
- package/dist/src/runtime/actions/types.d.ts +47 -1
- package/dist/src/runtime/actions/types.js +23 -0
- package/dist/src/runtime/connections/callback-route.d.ts +1 -1
- package/dist/src/runtime/connections/callback-route.js +1 -1
- package/dist/src/runtime/connections/mcp-client.d.ts +1 -2
- package/dist/src/runtime/connections/mcp-client.js +69 -3
- package/dist/src/runtime/framework-channels/index.js +7 -2
- package/dist/src/runtime/session-callback-route.d.ts +6 -0
- package/dist/src/runtime/session-callback-route.js +87 -0
- package/package.json +1 -1
- package/dist/src/chunks/host-BxT35q6K.js +0 -70
- package/dist/src/chunks/paths-B2hLA0Fn.js +0 -85
- package/dist/src/chunks/types-CjIyrcYo.js +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import{c as e,d as t,f as n,l as r,o as i,p as a,s as o,t as s,u as c}from"./authored-module-loader-DcCfCiBm.js";import{n as l,t as u}from"./guards-26p6sOw3.js";import{t as d}from"./errors-HYWjHxV6.js";import{_ as f,a as p,b as m,f as h,i as g,l as _,n as ee,o as te,r as ne,s as re,t as ie,u as ae,x as oe}from"./types-BJSR0JNV.js";import{t as se}from"./runtime-model-Dh0Nz64z.js";import{createRequire as ce}from"node:module";import{z as v}from"#compiled/zod/index.js";import{basename as le,dirname as y,join as b,posix as ue,relative as de,resolve as x,sep as fe}from"node:path";import{access as pe,cp as me,mkdir as S,readFile as he,rm as ge,writeFile as C}from"node:fs/promises";import{createHash as _e}from"node:crypto";import{existsSync as w,readFileSync as ve,readdirSync as ye,realpathSync as be,rmSync as xe}from"node:fs";import{fileURLToPath as Se,pathToFileURL as Ce}from"node:url";import{Buffer as we}from"node:buffer";import"#compiled/@workflow/errors/index.js";import{resumeHook as Te}from"#compiled/@workflow/core/runtime.js";import{AsyncLocalStorage as Ee}from"node:async_hooks";import{SpanStatusCode as De,trace as Oe}from"#compiled/@opentelemetry/api/index.js";import{getErrorMessage as ke}from"#compiled/@ai-sdk/provider/index.js";import{inspect as Ae}from"node:util";import{fromError as je}from"#compiled/zod-validation-error/index.js";import{createRemoteJWKSet as Me,decodeJwt as Ne,jwtVerify as Pe}from"#compiled/jose/index.js";import"ai";import Fe from"#compiled/turndown/index.js";const Ie=v.union([v.literal(`error`),v.literal(`warning`)]);v.object({code:v.string(),message:v.string(),severity:Ie,sourcePath:v.string()}).strict();const Le=v.object({errors:v.number().finite(),warnings:v.number().finite()}).strict(),Re=`discover/project-not-found`;function ze(e){return{...e,severity:`error`}}function Be(e){return{...e,severity:`warning`}}function Ve(e){return e.reduce((e,t)=>(t.severity===`error`?e.errors+=1:e.warnings+=1,e),{errors:0,warnings:0})}function He(e){return e.some(e=>e.severity===`error`)}const Ue=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],We=new Set([`package.json`,`vercel.json`]);function Ge(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function Ke(e,t){return t===`file`&&We.has(e)}function qe(e,t){if(t===`file`)return E(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:E(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:E(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(e===`channels`)return`channels-directory`;if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`lib`)return`lib-directory`;if(e===`skills`)return`skills-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`tools`)return`tools-directory`;if(e===`schedules`)return`schedules-directory`;if(e===`subagents`)return`subagents-directory`}return`unknown`}function Je(e,t){if(t===`file`)return E(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:E(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:E(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`lib`)return`lib-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`skills`)return`skills-directory`;if(e===`tools`)return`tools-directory`;if(e===`subagents`)return`subagents-directory`;if(e===`schedules`)return`invalid-schedules-directory`}return`unknown`}function Ye(e,t){if(t===`file`)return e===`SKILL.md`?`skill-markdown`:`skill-resource`;if(t===`directory`){if(e===`scripts`)return`skill-scripts-directory`;if(e===`references`)return`skill-references-directory`;if(e===`assets`)return`skill-assets-directory`}return`skill-resource`}function Xe(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(e.endsWith(`.md`))return`flat-skill-markdown`;if(Ze(e)!==null)return`flat-skill-module`}return`unknown`}function T(e){return e.replaceAll(fe,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function Ze(e){for(let t of Ue)if(e.endsWith(t)&&e.length>t.length)return e.slice(0,-t.length);return null}function E(e,t){return Ze(e)===t}function D(e){let t=T(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}function Qe(t,r){let i=o(t,r);if(e(i,[`build`,`compaction`,`description`,`metadata`,`model`,`modelContextWindowTokens`,`modelOptions`],r),i.model===void 0)throw Error(`${r} The "model" field is required.`);let a={model:i.model};i.description!==void 0&&(a.description=c(i.description,r));let s=n(i,`metadata`,r);return s!==void 0&&(a.metadata=s),i.compaction!==void 0&&(a.compaction=nt(i.compaction,r)),i.build!==void 0&&(a.build=et(i.build,r)),i.modelOptions!==void 0&&(a.modelOptions=tt(i.modelOptions,r)),i.modelContextWindowTokens!==void 0&&(a.modelContextWindowTokens=$e(i.modelContextWindowTokens,r)),a}function $e(e,t){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(t);return e}function et(t,n){let r=o(t,n);e(r,[`externalDependencies`],n);let i={};if(r.externalDependencies!==void 0){if(!Array.isArray(r.externalDependencies))throw Error(n);i.externalDependencies=Object.freeze(r.externalDependencies.map(e=>c(e,n)))}return i}function tt(t,n){let i=o(t,n);e(i,[`providerOptions`],n);let a=i.providerOptions;return a===void 0?{}:{providerOptions:r(a,n)}}function nt(t,n){let r=o(t,n);e(r,[`model`,`modelContextWindowTokens`,`thresholdPercent`],n);let i={};if(r.model!==void 0&&(i.model=r.model),r.modelContextWindowTokens!==void 0&&(i.modelContextWindowTokens=$e(r.modelContextWindowTokens,n)),r.thresholdPercent!==void 0){let e=r.thresholdPercent;if(typeof e!=`number`||!Number.isFinite(e)||e<0||e>1)throw Error(n);i.thresholdPercent=e}return i}function rt(t,n){let r=o(t,n);return e(r,[`markdown`],n),{markdown:c(r.markdown,n)}}function it(t,r){let i=o(t,r);e(i,[`description`,`files`,`license`,`markdown`,`metadata`],r);let a={description:c(i.description,r),markdown:c(i.markdown,r)},s=i.license,l=n(i,`metadata`,r);return s!==void 0&&(a.license=c(s,r)),l!==void 0&&(a.metadata=l),i.files!==void 0&&(a.files=at(i.files,r)),a}function at(e,t){let n=o(e,t),r={};for(let[e,i]of Object.entries(n)){if(typeof i==`string`||i instanceof Uint8Array){r[e]=i;continue}throw Error(`${t} Expected skill file "${e}" to be a string or Uint8Array.`)}return r}function ot(t,n){let r=o(t,n);e(r,[`cron`,`markdown`,`run`],n);let a=c(r.cron,n),s=r.markdown!==void 0,l=r.run!==void 0;if(s&&l)throw Error(`${n} Pass either "markdown" (fire-and-forget) or "run" (handler) — not both.`);if(!s&&!l)throw Error(`${n} Must provide either "markdown" (fire-and-forget) or "run" (handler).`);let u={cron:a};return s?u.markdown=c(r.markdown,n):u.run=i(r.run,n),u}function st(e){let t=x(e.appRoot),n=x(e.agentRoot),r={agentId:e.agentId??ct(t,n,e.packageName),agentRoot:n,appRoot:t,channels:[...e.channels??[]],connections:[...e.connections??[]],diagnosticsSummary:Ve(e.diagnostics??[]),hooks:[...e.hooks??[]],lib:[...e.lib??[]],kind:`ash-agent-discovery-manifest`,sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],version:12,subagents:[...e.subagents??[]]};return e.configModule!==void 0&&(r.configModule=e.configModule),e.instructions!==void 0&&(r.instructions=e.instructions),r}function ct(e,t,n){let r=T(de(e,t));return r===``||r===`.`||r===`agent`?n??le(e):le(t)}function lt(e){return T(e)}function ut(e){let t=T(e.logicalPath),n={sourceKind:`module`,logicalPath:t,sourceId:e.sourceId??lt(t)};return e.exportName!==void 0&&(n.exportName=e.exportName),n}function dt(e){return{...ut(e),connectionName:e.connectionName}}function ft(e){let t=T(e.logicalPath);return{entryPath:e.entryPath,logicalPath:t,manifest:e.manifest,rootPath:e.rootPath,sourceId:e.sourceId??lt(t),subagentId:e.subagentId}}function pt(e){let t={description:e.description,sourceKind:`skill-package`,logicalPath:T(e.logicalPath),markdown:e.markdown,name:e.name,rootPath:e.rootPath,skillFilePath:e.skillFilePath,skillId:e.skillId,sourceId:e.sourceId};return e.assetsPath!==void 0&&(t.assetsPath=e.assetsPath),e.license!==void 0&&(t.license=e.license),e.metadata!==void 0&&(t.metadata={...e.metadata}),e.referencesPath!==void 0&&(t.referencesPath=e.referencesPath),e.scriptsPath!==void 0&&(t.scriptsPath=e.scriptsPath),t}const O=`experimental-ash`;let k;const mt={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function ht(){return`__ASH_PACKAGE_VERSION__`}const gt={name:O,version:ht()};function _t(){return typeof __filename==`string`?__filename:vt()}function vt(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?Se(e):e}finally{Error.prepareStackTrace=e}}const yt=ce(_t());function bt(e){return le(e)===`dist`&&w(b(y(e),`package.json`))}function xt(){let e=y(be(_t()));for(;;){if(bt(e))return e;let t=y(e);if(t===e)return null;e=t}}function St(e){let t=e;for(;;){if(w(b(t,`package.json`))&&!bt(t))return t;let n=y(t);if(n===t)throw Error(`Failed to resolve package root from "${e}".`);t=n}}function A(){return St(y(be(_t())))}function Ct(){try{return A()}catch{return}}function wt(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function Tt(e){let t=xt();return t===null?b(A(),e):b(t,wt(e))}function Et(e){let t=xt();return b(t===null?A():t,e)}function Dt(e){let t=xt();return t===null?b(A(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):b(t,e)}function Ot(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function kt(e,t){let n=Ot(JSON.parse(ve(e,`utf8`)));if(n?.name===t)return n}function At(){if(k)return k;let e=Ct(),t=e===void 0?void 0:kt(b(e,`package.json`),O);if(t)return k=t,k;try{let e=kt(yt.resolve(`${O}/package.json`),O);if(e)return k=e,k}catch{}return k={...gt},k}function jt(e){if(e===`workflow`)return Tt(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return Tt(`src/internal/workflow/builtins.ts`);let t=mt[e];return t===void 0?yt.resolve(e):Dt(t)}const Mt=v.object({description:v.string(),entryPath:v.string(),exportName:v.string().optional(),logicalPath:v.string(),name:v.string(),nodeId:v.string(),path:v.string(),rootPath:v.string(),sourceId:v.string(),sourceKind:v.literal(`module`),url:v.string()}).strict(),Nt=`ash-agent-compiled-manifest`,j=`__root__`,Pt=v.object({exportName:v.string().optional(),sourceKind:v.literal(`module`),logicalPath:v.string(),sourceId:v.string()}).strict(),Ft=v.union([v.literal(`GET`),v.literal(`POST`),v.literal(`PUT`),v.literal(`PATCH`),v.literal(`DELETE`)]),It=v.object({kind:v.literal(`channel`),name:v.string(),logicalPath:v.string(),method:Ft,urlPath:v.string(),sourceId:v.string(),sourceKind:v.literal(`module`),exportName:v.string().optional(),adapterKind:v.string().optional()}).strict(),Lt=v.object({kind:v.literal(`disabled`),name:v.string(),logicalPath:v.string()}).strict(),Rt=v.union([It,Lt]),zt=v.object({contextWindowTokens:v.number().int().positive().optional(),id:v.string(),source:Pt.optional(),providerOptions:v.record(v.string(),m).optional()}).strict(),Bt=v.object({externalDependencies:v.array(v.string()).optional()}).strict(),Vt=v.object({model:zt.optional(),thresholdPercent:v.number().finite().min(0).max(1).optional()}).strict(),Ht=v.object({build:Bt.optional(),compaction:Vt.optional(),description:v.string().optional(),metadata:v.record(v.string(),v.string()),model:zt,name:v.string(),source:Pt.optional()}).strict(),Ut=v.object({name:v.string(),logicalPath:v.string(),markdown:v.string(),sourceId:v.string(),sourceKind:v.union([v.literal(`markdown`),v.literal(`module`)])}).strict(),Wt={name:v.string(),description:v.string(),license:v.string().optional(),markdown:v.string(),metadata:v.record(v.string(),v.string()).optional(),sourceId:v.string(),logicalPath:v.string()},Gt=v.discriminatedUnion(`sourceKind`,[v.object({...Wt,sourceKind:v.literal(`markdown`)}).strict(),v.object({...Wt,sourceKind:v.literal(`module`),exportName:v.string().optional()}).strict(),v.object({...Wt,sourceKind:v.literal(`skill-package`),skillId:v.string(),skillFilePath:v.string(),rootPath:v.string(),assetsPath:v.string().optional(),referencesPath:v.string().optional(),scriptsPath:v.string().optional()}).strict()]),Kt=v.object({cron:v.string(),hasRun:v.boolean(),name:v.string(),logicalPath:v.string(),markdown:v.string().optional(),sourceId:v.string(),sourceKind:v.union([v.literal(`markdown`),v.literal(`module`)])}).strict(),qt=v.object({description:v.string().optional(),exportName:v.string().optional(),logicalPath:v.string(),sourceId:v.string(),sourceKind:v.literal(`module`)}).strict(),Jt=v.object({logicalPath:v.string(),rootEntries:v.array(v.string()).readonly(),sourceId:v.string(),sourcePath:v.string()}).strict(),Yt=v.object({logicalPath:v.string(),rootEntries:v.array(v.string()).readonly()}).strict(),Xt=v.object({connectionName:v.string(),description:v.string(),exportName:v.string().optional(),logicalPath:v.string(),sourceId:v.string(),sourceKind:v.literal(`module`),url:v.string(),vercelConnect:v.object({connector:v.string()}).strict().optional()}).strict(),Zt=v.object({description:v.string(),exportName:v.string().optional(),inputSchema:m.nullable(),logicalPath:v.string(),name:v.string(),sourceId:v.string(),sourceKind:v.literal(`module`)}).strict(),Qt=v.object({exportName:v.string().optional(),logicalPath:v.string(),slug:v.string(),sourceId:v.string(),sourceKind:v.literal(`module`)}).strict(),$t=v.object({agentRoot:v.string(),appRoot:v.string(),channels:v.array(Rt),config:Ht,connections:v.array(Xt),diagnosticsSummary:Le,disabledFrameworkTools:v.array(v.string()).readonly(),hooks:v.array(Qt),sandbox:qt.nullable(),sandboxWorkspaces:v.array(Jt),schedules:v.array(Kt),remoteAgents:v.array(Mt),skills:v.array(Gt).readonly(),instructions:Ut.optional(),tools:v.array(Zt),workspaceResourceRoot:Yt}).strict(),en=v.object({agent:$t,description:v.string(),entryPath:v.string(),logicalPath:v.string(),name:v.string(),nodeId:v.string(),rootPath:v.string(),sourceId:v.string(),sourceKind:v.literal(`module`),exportName:v.string().optional()}).strict(),tn=v.object({childNodeId:v.string(),parentNodeId:v.string()}).strict(),nn=v.object({agentRoot:v.string(),appRoot:v.string(),channels:v.array(Rt),config:Ht,connections:v.array(Xt),diagnosticsSummary:Le,disabledFrameworkTools:v.array(v.string()).readonly(),hooks:v.array(Qt),kind:v.literal(Nt),remoteAgents:v.array(Mt),sandbox:qt.nullable(),sandboxWorkspaces:v.array(Jt),schedules:v.array(Kt),skills:v.array(Gt).readonly(),subagentEdges:v.array(tn),subagents:v.array(en),instructions:Ut.optional(),tools:v.array(Zt),version:v.literal(24),workspaceResourceRoot:Yt}).strict();function rn(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cn(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,metadata:{...e.config.metadata},model:cn(e.config.model),name:e.config.name,source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:an({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function an(e){let t=new Set;(e.skills??[]).length>0&&t.add(`skills/`);for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function on(e,t){return e===`__root__`?t:`${e}::${t}`}function sn(e){return{...rn(e),kind:Nt,subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:24}}function cn(e){return e.contextWindowTokens===void 0&&e.source===void 0&&e.providerOptions===void 0?{id:e.id}:e.source===void 0?e.providerOptions===void 0?{contextWindowTokens:e.contextWindowTokens,id:e.id}:{contextWindowTokens:e.contextWindowTokens,id:e.id,providerOptions:{...e.providerOptions}}:e.contextWindowTokens===void 0&&e.providerOptions===void 0?{id:e.id,source:{...e.source}}:{contextWindowTokens:e.contextWindowTokens,id:e.id,providerOptions:e.providerOptions===void 0?void 0:{...e.providerOptions},source:{...e.source}}}const ln=/^\/?[A-Za-z]:[\\/]/,un=/^\\\\[^\\]/,dn=/(\b(?:from|import)\s*(?:\(\s*)?)(["'])([A-Za-z]:[\\/][^"'\n\r]*)\2/g;function fn(e){return ln.test(e)||un.test(e)}function pn(e){let t=e.replaceAll(`\\`,`/`);return t.startsWith(`//`)?new URL(`file:${t}`).href:(/^\/[A-Za-z]:\//.test(t)&&(t=t.slice(1)),new URL(`file:///${t}`).href)}function mn(e){let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?{path:e,suffix:``}:{path:e.slice(0,r),suffix:e.slice(r)}}function hn(e){if(e.startsWith(`file://`))return e;let{path:t,suffix:n}=mn(e);return fn(t)?`${pn(t)}${n}`:e.replaceAll(`\\`,`/`)}function gn(e){return JSON.stringify(hn(e))}function _n(e){return e.replace(dn,(e,t,n,r)=>`${t}${n}${hn(r)}${n}`)}const vn=v.object({modules:v.record(v.string(),v.object({}).passthrough())}).strict(),yn=v.object({nodes:v.record(v.string(),vn)}).strict();function bn(e){let t=En(e.moduleMapPath),n=e.importSpecifierStyle??`relative`,r=0,i=[xn({agentRoot:e.manifest.agentRoot,importSpecifierStyle:n,manifest:e.manifest,moduleMapDirectory:t,nextBindingName(){return`module_${r++}`},nodeId:j}),...[...e.manifest.subagents].sort((e,t)=>e.nodeId.localeCompare(t.nodeId)).map(e=>xn({agentRoot:e.agent.agentRoot,importSpecifierStyle:n,manifest:e.agent,moduleMapDirectory:t,nextBindingName(){return`module_${r++}`},nodeId:e.nodeId}))],a=i.flatMap(e=>e.modules.map(e=>`import * as ${e.bindingName} from ${JSON.stringify(e.importSpecifier)};`));return[`// Generated by Ash. Do not edit by hand.`,``,...a,...a.length>0?[``]:[],`export const moduleMap = ${wn(i)};`,``,`export default moduleMap;`,``].join(`
|
|
2
|
+
`)}function xn(e){return{modules:Sn(e.manifest).sort((e,t)=>e.sourceId.localeCompare(t.sourceId)).map(t=>({bindingName:e.nextBindingName(),importSpecifier:Cn({fromDirectory:e.moduleMapDirectory,importSpecifierStyle:e.importSpecifierStyle,targetPath:Dn(e.agentRoot,t.logicalPath)}),sourceId:t.sourceId})),nodeId:e.nodeId}}function Sn(e){let t=new Map;e.config.source!==void 0&&t.set(e.config.source.sourceId,e.config.source),e.config.model.source!==void 0&&t.set(e.config.model.source.sourceId,e.config.model.source);for(let n of e.channels)n.kind!==`disabled`&&t.set(n.sourceId,{exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId});for(let n of e.connections)t.set(n.sourceId,{exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId});for(let n of e.tools)t.set(n.sourceId,{exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId});for(let n of e.remoteAgents)t.set(n.sourceId,{exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId});for(let n of e.hooks)t.set(n.sourceId,{exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId});for(let n of e.schedules)n.sourceKind!==`module`||!n.hasRun||t.set(n.sourceId,{sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId});return e.sandbox!==null&&t.set(e.sandbox.sourceId,{exportName:e.sandbox.exportName,sourceKind:`module`,logicalPath:e.sandbox.logicalPath,sourceId:e.sandbox.sourceId}),[...t.values()]}function Cn(e){if(e.importSpecifierStyle===`absolute`)return hn(kn(e.targetPath));let t=On(e.fromDirectory,e.targetPath);return t.startsWith(`.`)?t:`./${t}`}function wn(e){return Tn([{key:`nodes`,value:Tn(e.map(e=>({key:e.nodeId,value:Tn([{key:`modules`,value:Tn(e.modules.map(e=>({key:e.sourceId,value:e.bindingName})))}],3)})))}],0)}function Tn(e,t=1){if(e.length===0)return`Object.freeze({})`;let n=` `.repeat(t),r=` `.repeat(t+1);return[`Object.freeze({`,e.map(e=>`${r}${JSON.stringify(e.key)}: ${e.value.replaceAll(`
|
|
3
|
+
`,`\n${r}`)}`).join(`,
|
|
4
|
+
`),`${n}})`].join(`
|
|
5
|
+
`)}function En(e){let t=M(e);return t.segments.length===0?t.root.length===0?`.`:t.root:An(t.root,t.segments.slice(0,-1))}function Dn(e,t){let n=M(e),r=M(t);return r.root.length>0?An(r.root,r.segments):An(n.root,[...n.segments,...r.segments])}function On(e,t){let n=M(e),r=M(t);if(n.root!==r.root)return kn(t);let i=0;for(;i<n.segments.length&&i<r.segments.length&&n.segments[i]===r.segments[i];)i+=1;let a=[...Array.from({length:n.segments.length-i},()=>`..`),...r.segments.slice(i)];return a.length===0?`.`:a.join(`/`)}function kn(e){let t=M(e);return An(t.root,t.segments)}function M(e){let t=e.replaceAll(`\\`,`/`),n=``,r=t,i=t.match(/^[A-Za-z]:/);i===null?t.startsWith(`/`)&&(n=`/`,r=t.slice(1)):(n=i[0],r=t.slice(n.length),r.startsWith(`/`)&&(n=`${n}/`,r=r.slice(1)));let a=[];for(let e of r.split(`/`))if(!(e.length===0||e===`.`)){if(e===`..`){if(a.length>0&&a[a.length-1]!==`..`){a.pop();continue}n.length===0&&a.push(e);continue}a.push(e)}return{root:n,segments:a}}function An(e,t){return e===`/`?t.length===0?`/`:`/${t.join(`/`)}`:e.endsWith(`/`)?t.length===0?e:`${e}${t.join(`/`)}`:e.length>0?t.length===0?e:`${e}/${t.join(`/`)}`:t.length===0?`.`:t.join(`/`)}const jn=`ash-model-catalog-cache`,Mn=v.object({provider:v.string().min(1),providerModelId:v.string().min(1),contextWindowTokens:v.number().int().nonnegative().optional(),maxOutputTokens:v.number().int().nonnegative().optional()}).passthrough(),Nn=v.object({slug:v.string().min(1),providers:v.array(Mn).min(1)}).passthrough(),Pn=v.object({models:v.array(Nn),providerAliases:v.record(v.string(),v.string())}).passthrough();v.object({contextWindowTokens:v.number().int().positive(),maxOutputTokens:v.number().int().positive().optional()}).strict();const Fn=v.object({fetchedAt:v.string(),kind:v.literal(jn),models:v.array(Nn),providerAliases:v.record(v.string(),v.string()),version:v.literal(2)}).strict(),In=new Map([[`anthropic/claude-opus-4.7`,{contextWindowTokens:2e5,maxOutputTokens:32e3}],[`openai/gpt-5.4`,{contextWindowTokens:4e5,maxOutputTokens:128e3}],[`openai/gpt-5.4-mini`,{contextWindowTokens:4e5,maxOutputTokens:128e3}]]);function Ln(e){return b(e,`.ash`,`cache`,`model-catalog.json`)}function Rn(e){let t=null,n=null,r=null,i=async()=>(t??=Bn(e),await t),a=async()=>{if(n!==null)throw n;if(r!==null)return await r;r=zn(e).then(e=>(t=Promise.resolve(e),e));try{return await r}catch(e){throw n=e,e}},o=async()=>{let e=await i();if(e!==null&&Un(e))return e;try{return await a()}catch{return e===null?null:e}};return{async getModelLimits(e){let t=Wn(e),n=await o();if(n!==null){let e=Vn(n.models,t);if(e)for(let t of e.providers){let e=Hn(t);if(e!==null)return e}}return In.get(t)??null},async getByProviderModelId(e,t){let n=await o();if(n===null)return null;let r=e.split(`.`)[0],i=n.providerAliases[r]??r,a=Wn(t);for(let e of n.models)for(let t of e.providers)if(t.provider===i&&Wn(t.providerModelId)===a){let n=Hn(t);if(n!==null)return{slug:e.slug,limits:n}}return null}}}async function zn(e){let t=await fetch(`https://ai-gateway.vercel.sh/v1/models/catalog`);if(!t.ok)throw Error(`AI Gateway model catalog request failed with HTTP ${t.status} ${t.statusText}.`);let n=Pn.safeParse(await t.json());if(!n.success)throw Error(`AI Gateway model catalog response did not match the expected schema.`);let r={fetchedAt:new Date().toISOString(),kind:jn,models:n.data.models,providerAliases:n.data.providerAliases,version:2};try{let t=Ln(e);await S(b(e,`.ash`,`cache`),{recursive:!0}),await C(t,`${JSON.stringify(r,null,2)}\n`,`utf8`)}catch{}return r}async function Bn(e){try{let t=await he(Ln(e),`utf8`),n=Fn.safeParse(JSON.parse(t));return n.success?n.data:null}catch(e){return e instanceof Error&&`code`in e&&typeof e.code==`string`&&e.code,null}}function Vn(e,t){return e.find(e=>e.slug===t)}function Hn(e){return e.contextWindowTokens===void 0||e.contextWindowTokens<=0?null:{contextWindowTokens:e.contextWindowTokens,...e.maxOutputTokens!==void 0&&e.maxOutputTokens>0&&{maxOutputTokens:e.maxOutputTokens}}}function Un(e){let t=Date.parse(e.fetchedAt);return Number.isFinite(t)?Date.now()-t<=864e5:!1}function Wn(e){return e.endsWith(`-thinking`)?e.slice(0,-9):e}async function N(e){let n=t(await s(b(e.agentRoot,e.source.logicalPath)),e.source);try{return await a(n)}catch(t){throw Error(`Failed to execute the ${e.kind} export "${e.source.exportName??`default`}" from "${e.source.logicalPath}": ${d(t)}`)}}var Gn=class extends Error{agentId;constructor(e){super(`Agent "${e}" does not have an agent.ts config module. The "model" field is required.`),this.name=`MissingAgentConfigModuleError`,this.agentId=e}};async function Kn(e,t){if(e.configModule===void 0)throw new Gn(e.agentId);let n=Qe(await N({agentRoot:e.agentRoot,kind:`agent config`,source:e.configModule}),`Expected the agent config export "${e.configModule.exportName??`default`}" from "${e.configModule.logicalPath}" to match the public Ash shape.`),r=await qn({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:n.modelContextWindowTokens,providerOptions:n.modelOptions?.providerOptions,source:e.configModule,value:n.model}),i={},a={compaction:i,metadata:n.metadata??{},model:r,name:e.agentId};return n.description!==void 0&&(a.description=n.description),n.build!==void 0&&(a.build={externalDependencies:n.build.externalDependencies===void 0?void 0:[...n.build.externalDependencies]}),a.source={exportName:e.configModule.exportName,sourceKind:`module`,logicalPath:e.configModule.logicalPath,sourceId:e.configModule.sourceId},n.compaction?.model!==void 0&&(i.model=await qn({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:n.compaction.modelContextWindowTokens,providerOptions:n.modelOptions?.providerOptions,source:e.configModule,value:n.compaction.model})),n.compaction?.thresholdPercent!==void 0&&(i.thresholdPercent=n.compaction.thresholdPercent),a}async function qn(e){if(typeof e.value==`string`)return await Jn({id:se(e.value),providerOptions:Yn(e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:se(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:Yn(e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await Jn(i,e)}async function Jn(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${d(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function Yn(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=oe(r);return t}function Xn(e){return typeof e==`object`&&!!e&&e.__kind===`ash:channel`}function Zn(e,t){if(!Xn(e))throw Error(`${t} Use \`defineChannel({ routes, ... })\` (or a wrapper like \`slackChannel\` / \`ashChannel\`) — bare \`{ fetch, receive? }\` channel objects are no longer supported.`);return e}function Qn(e){return typeof e==`object`&&!!e&&e.kind===`ash:disabled-channel`}async function $n(e,t){let n=await N({agentRoot:e,kind:`channel`,source:t}),r=D(t.logicalPath).replace(/^channels\//,``);if(Qn(n))return{kind:`disabled`,name:r,logicalPath:t.logicalPath};let i=Zn(n,`Expected the channel export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public Ash shape.`);return i.routes.map(e=>({kind:`channel`,name:r,logicalPath:t.logicalPath,method:e.method.toUpperCase(),urlPath:e.path,sourceId:t.sourceId,sourceKind:`module`,exportName:t.exportName,adapterKind:er(i.adapter)}))}function er(e){if(typeof e!=`object`||!e)return;let t=e.kind;return typeof t==`string`&&t.length>0?t:void 0}function tr(e,t=`auth`){if(typeof e!=`object`||!e)return`The "${t}" field must be an object with a "getToken" method.`;let n=e;if(typeof n.getToken!=`function`)return`The "${t}.getToken" field must be a function returning Promise<{ token }>.`;let r=n.startAuthorization!==void 0,i=n.completeAuthorization!==void 0;if(!r&&!i&&n.principalType!==void 0&&n.principalType!==`app`&&n.principalType!==`user`)return`The "${t}.principalType" field must be "app" or "user".`;if(r!==i)return`The "${t}" field must provide either both "startAuthorization" and "completeAuthorization" (interactive OAuth) or neither (getToken-only). Got only "${r?`startAuthorization`:`completeAuthorization`}".`;if(r&&typeof n.startAuthorization!=`function`)return`The "${t}.startAuthorization" field must be a function when provided.`;if(i&&typeof n.completeAuthorization!=`function`)return`The "${t}.completeAuthorization" field must be a function when provided.`;if(r&&n.principalType!==`user`)return`Interactive authorization (startAuthorization + completeAuthorization) is restricted to "principalType": "user" in v1. See D10 of research/connections/connection-principal-model.md for the rationale.`}function nr(e,t,n=`auth`){let r=tr(e,n);if(r!==void 0)throw Error(`${t} ${r}`);let i=e,a=rr(i.vercelConnect);if(i.startAuthorization!==void 0&&i.completeAuthorization!==void 0){let e={completeAuthorization:i.completeAuthorization,getToken:i.getToken,principalType:`user`,startAuthorization:i.startAuthorization};return a===void 0?e:{...e,vercelConnect:a}}let o={getToken:i.getToken,principalType:i.principalType??`app`};return a===void 0?o:{...o,vercelConnect:a}}function rr(e){if(typeof e!=`object`||!e)return;let t=e.connector;if(!(typeof t!=`string`||t.length===0))return{connector:t}}const ir=[`approval`,`auth`,`description`,`headers`,`tools`,`url`],ar=[`completeAuthorization`,`getToken`,`principalType`,`startAuthorization`,`vercelConnect`];function or(t,n){let r=o(t,n);e(r,ir,n),sr(r,n),cr(r,n);let i=lr(r,n),a=ur(r,n),s=dr(r,n);if(i!==void 0&&a!==void 0&&typeof a!=`function`&&Object.keys(a).some(e=>e.toLowerCase()===`authorization`))throw Error(`${n} "headers" must not include an "Authorization" key when "auth" is also provided.`);let c={description:r.description,url:r.url};if(i!==void 0&&(c.auth=i),a!==void 0&&(c.headers=a),s!==void 0&&(c.tools=s),r.approval!==void 0){if(typeof r.approval!=`function`)throw Error(`${n} The "approval" field must be a function when provided.`);c.approval=r.approval}return c}function sr(e,t){if(typeof e.url!=`string`||!URL.canParse(e.url))throw Error(`${t} The "url" field must be a valid URL.`);let n=new URL(e.url);if(n.protocol!==`https:`&&n.protocol!==`http:`)throw Error(`${t} The "url" field must use the http or https protocol, got "${n.protocol}".`)}function cr(e,t){if(typeof e.description!=`string`||e.description.length===0)throw Error(`${t} The "description" field must be a non-empty string.`)}function lr(t,n){if(t.auth===void 0)return;let r=o(t.auth,`${n} The "auth" field must be an object with a "getToken" method.`);return e(r,ar,`${n} The "auth" field`),nr(r,n)}function ur(e,t){if(e.headers===void 0)return;if(typeof e.headers==`function`)return e.headers;if(typeof e.headers!=`object`||e.headers===null||Array.isArray(e.headers))throw Error(`${t} The "headers" field must be a plain object or a function.`);let n=e.headers;for(let[e,r]of Object.entries(n)){let n=typeof r;if(n!==`string`&&n!==`function`&&n!==`object`||n===`object`&&(r===null||typeof r.then!=`function`))throw Error(`${t} The "headers.${e}" value must be a string, Promise, or function.`)}return n}function dr(e,t){if(e.tools===void 0)return;if(typeof e.tools!=`object`||e.tools===null||Array.isArray(e.tools))throw Error(`${t} The "tools" field must specify either "allow" or "block".`);let n=e.tools,r=`allow`in n,i=`block`in n;if(r&&i)throw Error(`${t} The "tools" field must specify either "allow" or "block", not both.`);if(!r&&!i)throw Error(`${t} The "tools" field must specify either "allow" or "block".`);return r?(fr(n.allow,`${t} The "tools.allow"`),{allow:n.allow}):(fr(n.block,`${t} The "tools.block"`),{block:n.block})}function fr(e,t){if(!Array.isArray(e))throw Error(`${t} field must be an array of strings.`);for(let n=0;n<e.length;n++)if(typeof e[n]!=`string`)throw Error(`${t}[${n}] must be a string.`)}async function pr(e,t){let n=or(await N({agentRoot:e,kind:`connection`,source:t}),`Expected the connection export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public Ash shape.`),r={connectionName:t.connectionName,description:n.description,exportName:t.exportName,logicalPath:t.logicalPath,sourceId:t.sourceId,sourceKind:`module`,url:n.url},i=mr(n.auth);return i!==void 0&&(r.vercelConnect=i),r}function mr(e){if(typeof e!=`object`||!e)return;let t=e.vercelConnect;if(typeof t!=`object`||!t)return;let n=t.connector;if(!(typeof n!=`string`||n.length===0))return{connector:n}}function hr(e){return{exportName:e.exportName,logicalPath:e.logicalPath,slug:D(e.logicalPath).replace(/^hooks\//,``),sourceId:e.sourceId,sourceKind:`module`}}function gr(e){let t;function n(){return t===void 0&&(t=e()),t}return{get name(){return n().name},create(e){return n().create(e)},async prewarm(e){await n().prewarm(e)}}}function _r(t,n){let r=o(t,n);e(r,[`backend`,`bootstrap`,`description`,`onSession`],n);let a={};if(r.backend!==void 0&&(a.backend=vr(r.backend,n)),r.description!==void 0){if(typeof r.description!=`string`)throw Error(`${n} The "description" field must be a string when set.`);a.description=r.description}return r.bootstrap!==void 0&&(a.bootstrap=i(r.bootstrap,n)),r.onSession!==void 0&&(a.onSession=i(r.onSession,n)),a}function vr(e,t){if(typeof e==`function`)return gr(e);let n=o(e,`${t} The "backend" field must be a SandboxBackend value (use vercelBackend(), localBackend(), or your own factory) or a zero-arg function returning one.`);if(typeof n.name!=`string`||n.name.length===0)throw Error(`${t} The "backend" value must expose a non-empty string "name" identifier.`);if(typeof n.create!=`function`)throw Error(`${t} The "backend" value must expose a "create" function.`);if(n.prewarm!==void 0&&typeof n.prewarm!=`function`)throw Error(`${t} The "backend.prewarm" property must be a function when set.`);return n}async function yr(e,t){return{description:_r(await N({agentRoot:e,kind:`sandbox`,source:t}),`Expected the sandbox export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public Ash shape.`).description,exportName:t.exportName,logicalPath:t.logicalPath,sourceId:t.sourceId,sourceKind:`module`}}async function br(e,t){let n=t.sourceKind===`markdown`?rt(t.definition,`Expected the compiled instructions definition at "${t.logicalPath}" to match the public Ash shape.`):rt(await N({agentRoot:e,kind:`instructions`,source:t}),`Expected the instructions export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public Ash shape.`);return{name:D(t.logicalPath),logicalPath:t.logicalPath,markdown:n.markdown,sourceId:t.sourceId,sourceKind:t.sourceKind}}async function xr(e,t){let n=t.sourceKind===`markdown`?ot(t.definition,`Expected the compiled schedule definition at "${t.logicalPath}" to match the public Ash shape.`):ot(await N({agentRoot:e,kind:`schedule`,source:t}),`Expected the schedule export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public Ash shape.`),r={cron:n.cron,hasRun:n.run!==void 0,logicalPath:t.logicalPath,name:Sr(t.logicalPath),sourceId:t.sourceId,sourceKind:t.sourceKind};return n.markdown===void 0?r:{...r,markdown:n.markdown.trim()}}function Sr(e){return D(e).replace(/^schedules\//,``)}async function Cr(e,t){if(t.sourceKind===`skill-package`)return wr(t);let n=t.sourceKind===`markdown`?it(t.definition,`Expected the compiled skill definition at "${t.logicalPath}" to match the public Ash shape.`):it(await N({agentRoot:e,kind:`skill`,source:t}),`Expected the skill export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public Ash shape.`),r={description:n.description,license:n.license,logicalPath:t.logicalPath,markdown:n.markdown,metadata:n.metadata===void 0?void 0:{...n.metadata},name:D(t.logicalPath).replace(/^skills\//,``),sourceId:t.sourceId,sourceKind:t.sourceKind};return n.files!==void 0&&(r.files=n.files),r}function wr(e){return{assetsPath:e.assetsPath,description:e.description,license:e.license,logicalPath:e.logicalPath,markdown:e.markdown,metadata:e.metadata===void 0?void 0:{...e.metadata},name:e.name,referencesPath:e.referencesPath,rootPath:e.rootPath,scriptsPath:e.scriptsPath,skillId:e.skillId,skillFilePath:e.skillFilePath,sourceId:e.sourceId,sourceKind:`skill-package`}}async function Tr(e){let t=[],n=[],r=[];for(let i of e.subagents){let a=await Er({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,parentNodeId:e.parentNodeId,source:i});if(a.kind===`remote`){r.push(a.node);continue}t.push(a.node,...a.descendants.nodes),n.push({childNodeId:a.node.nodeId,parentNodeId:e.parentNodeId},...a.descendants.edges)}return{edges:n,nodes:t,remoteAgents:r}}async function Er(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Subagent "${e.source.logicalPath}" is missing an agent config module.`);let n=await N({agentRoot:e.source.manifest.agentRoot,kind:`subagent config`,source:t});return jr(n)===`remote`?{kind:`remote`,node:kr({source:e.source,value:n})}:{kind:`local`,...await Or(e)}}async function Dr(e){let t=on(e.parentNodeId,e.source.sourceId),n=e.source.subagentId,r=await e.compileAgentNodeManifest({...e.source.manifest,appRoot:e.appRoot},e.context),i=r.config.description;if(!i)throw Error(`Local subagent "${e.source.logicalPath}" is missing a "description" field on its agent config. Add \`description\` to \`defineAgent({ ... })\` so the parent agent can decide when to delegate to this subagent.`);let a=await Tr({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,parentNodeId:t,subagents:e.source.manifest.subagents});return{descendants:a,node:{agent:{...r,remoteAgents:[...a.remoteAgents]},description:i,entryPath:e.source.entryPath,logicalPath:e.source.logicalPath,name:n,nodeId:t,rootPath:e.source.rootPath,sourceId:e.source.sourceId,sourceKind:`module`}}}const Or=Dr;function kr(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Remote agent "${e.source.logicalPath}" is missing a config module.`);Nr(e.source);let n=Mr(e.value,`Expected the remote agent config export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public Ash shape.`);return{...Ar(e.source,t),description:n.description,entryPath:e.source.entryPath,name:e.source.subagentId,nodeId:e.source.sourceId,path:n.path,rootPath:e.source.rootPath,url:n.url}}function Ar(e,t){let n=e.logicalPath===t.logicalPath?t.logicalPath:`${e.logicalPath}/${t.logicalPath}`,r={logicalPath:n,sourceId:lt(n),sourceKind:`module`};return t.exportName!==void 0&&(r.exportName=t.exportName),r}function jr(e){return typeof e!=`object`||!e?`local`:e.kind===`remote`?`remote`:`local`}function Mr(t,n){let r=o(t,n);if(e(r,[`auth`,`description`,`headers`,`kind`,`path`,`url`],n),r.kind!==`remote`)throw Error(`${n} Expected "kind" to be "remote".`);return{description:c(r.description,n),path:r.path===void 0?h:c(r.path,n),url:c(r.url,n)}}function Nr(e){let t=e.manifest,n=[t.connections.length>0?`connections/`:void 0,t.hooks.length>0?`hooks/`:void 0,t.instructions===void 0?void 0:`instructions`,t.lib.length>0?`lib/`:void 0,t.sandbox===null?void 0:`sandbox/`,t.sandboxWorkspaces.length>0?`sandbox/workspace/`:void 0,t.schedules.length>0?`schedules/`:void 0,t.skills.length>0?`skills/`:void 0,t.subagents.length>0?`subagents/`:void 0,t.tools.length>0?`tools/`:void 0].filter(e=>e!==void 0);if(n.length!==0)throw Error(`Remote subagent definition "${e.logicalPath}" cannot include local package entries. Remove unsupported entries: ${n.join(`, `)}.`)}const Pr=Symbol.for(`experimental-ash.definition-source-registry`),Fr=globalThis;Fr[Pr]===void 0&&(Fr[Pr]=new Map);const Ir=Fr[Pr];function Lr(e,t){Ir.set(e,t)}function Rr(e){return typeof e==`object`&&!!e&&e.kind===`ash:disabled-tool`}function zr(e){return e&&typeof e==`object`&&`~standard`in e?e[`~standard`].jsonSchema.input({target:`draft-07`}):JSON.parse(JSON.stringify(e))}function Br(t,n){if(Rr(t))return{kind:`disabled`};let r=o(t,n);e(r,[`description`,`execute`,`inputSchema`,`needsApproval`,`onCompact`,`retentionPolicy`,`toModelOutput`],n);let a=r.inputSchema===void 0?null:zr(r.inputSchema),s={description:c(r.description,n),execute:i(r.execute,n),inputSchema:a};if(r.onCompact!==void 0&&i(r.onCompact,n),r.needsApproval!==void 0&&i(r.needsApproval,n),r.retentionPolicy!==void 0){let e=r.retentionPolicy;if(e!==`auto`&&e!==`keep`&&typeof e!=`function`)throw Error(`${n} Expected \`retentionPolicy\` to be "auto", "keep", or a function.`)}return r.toModelOutput!==void 0&&i(r.toModelOutput,n),{kind:`tool`,definition:s}}async function Vr(e,t){let n=Br(await N({agentRoot:e,kind:`tool`,source:t}),`Expected the tool export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public Ash shape.`),r=D(t.logicalPath).replace(/^tools\//,``).replaceAll(`/`,`-`);return n.kind===`disabled`?{kind:`disabled`,name:r}:{kind:`tool`,definition:{description:n.definition.description,exportName:t.exportName,inputSchema:n.definition.inputSchema??null,logicalPath:t.logicalPath,name:r,sourceId:t.sourceId,sourceKind:`module`}}}async function Hr(e){let t={modelCatalog:Rn(e.appRoot)},[n,r]=await Promise.all([Ur(e,t),Tr({appRoot:e.appRoot,compileAgentNodeManifest:Ur,context:t,parentNodeId:j,subagents:e.subagents})]);return sn({...n,remoteAgents:r.remoteAgents,subagentEdges:r.edges,subagents:r.nodes})}async function Ur(e,t){let n=await Promise.all(e.tools.map(t=>Vr(e.agentRoot,t))),r=[],i=[];for(let e of n)e.kind===`tool`?r.push(e.definition):i.push(e.name);let a=(await Promise.all(e.channels.map(t=>$n(e.agentRoot,t)))).flat();return rn({agentRoot:e.agentRoot,appRoot:e.appRoot,channels:a,config:await Kn(e,t),connections:await Promise.all(e.connections.map(t=>pr(e.agentRoot,t))),diagnosticsSummary:e.diagnosticsSummary,disabledFrameworkTools:i,hooks:e.hooks.map(e=>hr(e)),sandbox:e.sandbox===null?null:await yr(e.agentRoot,e.sandbox),sandboxWorkspaces:e.sandboxWorkspaces.map(e=>({logicalPath:e.logicalPath,rootEntries:[...e.rootEntries],sourceId:e.sourceId,sourcePath:e.sourcePath})),schedules:await Promise.all(e.schedules.map(t=>xr(e.agentRoot,t))),skills:await Promise.all(e.skills.map(t=>Cr(e.agentRoot,t))),instructions:e.instructions===void 0?void 0:await br(e.agentRoot,e.instructions),tools:r})}function Wr(e){Kr(e.name);let t=[{content:we.from(e.markdown,`utf8`),relativePath:`SKILL.md`}];for(let[n,r]of Object.entries(e.files??{}))qr(n),t.push({content:Jr(r),relativePath:n});return t.sort((e,t)=>Yr(e.relativePath,t.relativePath)),{description:e.description,files:t,license:e.license,markdown:e.markdown,metadata:e.metadata===void 0?void 0:{...e.metadata},name:e.name}}async function Gr(e){for(let t of e.skill.files){let n=b(e.rootPath,`skills`,e.skill.name,t.relativePath);await S(y(n),{recursive:!0}),await C(n,t.content)}}function Kr(e){if(e.length===0||e.trim()!==e||e.startsWith(`.`)||e.includes(`/`)||e.includes(`\\`)||e.includes(`..`)||/^[A-Za-z]:/.test(e))throw Error(`Expected skill name to be a non-empty safe path segment without whitespace, separators, "." prefix, or "..".`)}function qr(e){if(e===`SKILL.md`)throw Error(`Skill package files must not include "SKILL.md"; Ash generates it.`);if(e.length===0||e.startsWith(`/`)||e.includes(`\\`)||/^[A-Za-z]:/.test(e)||e.split(`/`).some(e=>e.length===0||e===`.`||e===`..`))throw Error(`Expected skill package file paths to be relative POSIX paths.`)}function Jr(e){return typeof e==`string`?we.from(e,`utf8`):we.from(e)}function Yr(e,t){return e<t?-1:+(e>t)}const Xr=`workspace-resources`;async function Zr(e){let t=b(e.compileDirectoryPath,Xr);await ge(t,{force:!0,recursive:!0});let n=await $r({nodeId:j,resourcesRoot:t,manifest:e.manifest}),r=await Promise.all(e.manifest.subagents.map(async e=>({...e,agent:await $r({nodeId:e.nodeId,resourcesRoot:t,manifest:e.agent})})));return{...n,kind:e.manifest.kind,subagentEdges:e.manifest.subagentEdges,subagents:r,version:e.manifest.version}}function Qr(e,t){return{logicalPath:T(b(Xr,t)),rootEntries:an({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}}async function $r(e){for(let t of e.manifest.sandboxWorkspaces)if(t.rootEntries.some(e=>e===`skills/`||e===`skills`))throw Error(`Sandbox workspace "${t.logicalPath}" cannot define "skills" because Ash manages that workspace entry.`);let t=b(e.resourcesRoot,e.nodeId);await S(t,{recursive:!0});for(let n of e.manifest.sandboxWorkspaces)await me(n.sourcePath,t,{recursive:!0});for(let n of e.manifest.skills)await ei({nodeRoot:t,skill:n});return{...e.manifest,skills:e.manifest.skills.map(ti),workspaceResourceRoot:Qr(e.manifest,e.nodeId)}}async function ei(e){let t=b(e.nodeRoot,`skills`,e.skill.name);if(e.skill.sourceKind===`skill-package`){await me(e.skill.rootPath,t,{recursive:!0});return}await Gr({rootPath:e.nodeRoot,skill:Wr(e.skill)})}function ti(e){let{files:t,...n}=e;return n}const ni=`ash-compile-metadata`;function ri(e){let t=x(e),n=b(t,`.ash`,`discovery`),r=b(t,`.ash`,`compile`);return{appRoot:t,compiledManifestPath:b(r,`compiled-agent-manifest.json`),compileDirectoryPath:r,compileMetadataPath:b(r,`compile-metadata.json`),diagnosticsPath:b(n,`diagnostics.json`),discoveryManifestPath:b(n,`agent-discovery-manifest.json`),discoveryDirectoryPath:n,moduleMapPath:b(r,`module-map.mjs`)}}function ii(e){return{diagnostics:[...e],kind:`ash-discovery-diagnostics`,summary:Ve(e),version:1}}function ai(e){let t=At(),n=P(e.discoveryManifestJson),r=P(e.diagnosticsArtifactJson),i=P(e.moduleMapSource);return{compile:{moduleMap:{path:si(e.appRoot,e.paths.moduleMapPath),sha256:i}},discovery:{diagnostics:{path:si(e.appRoot,e.paths.diagnosticsPath),sha256:r},manifest:{path:si(e.appRoot,e.paths.discoveryManifestPath),sha256:n},sourceGraphHash:P(`${n}:${r}:${i}`),summary:e.diagnosticsSummary},generator:{name:t.name,version:t.version},kind:ni,status:e.diagnosticsSummary.errors>0?`failed`:`ready`,version:5}}async function oi(e){let t=ri(e.appRoot),n=ii(e.diagnostics),r=await Zr({compileDirectoryPath:t.compileDirectoryPath,manifest:await Hr(e.manifest)}),i=F(r),a=F(e.manifest),o=F(n),s=bn({manifest:r,moduleMapPath:t.moduleMapPath}),c=ai({appRoot:e.appRoot,diagnosticsArtifactJson:o,diagnosticsSummary:n.summary,discoveryManifestJson:a,moduleMapSource:s,paths:t}),l=F(c);return await S(t.discoveryDirectoryPath,{recursive:!0}),await S(t.compileDirectoryPath,{recursive:!0}),await Promise.all([C(t.compiledManifestPath,i),C(t.diagnosticsPath,o),C(t.discoveryManifestPath,a),C(t.moduleMapPath,s),C(t.compileMetadataPath,l)]),{compiledManifest:r,diagnosticsArtifact:n,metadata:c,moduleMapSource:s,paths:t}}function P(e){return _e(`sha256`).update(e).digest(`hex`)}function F(e){return`${JSON.stringify(e,null,2)}\n`}function si(e,t){return T(de(x(e),t))}const ci=Symbol.for(`experimental-ash.context-key-registry`),li=globalThis;li[ci]===void 0&&(li[ci]=new Map);const ui=li[ci];var I=class{name;codec;constructor(e,t={}){this.name=e,this.codec=t.codec,ui.set(e,this)}};const di=Symbol.for(`experimental-ash.context-storage`),fi=globalThis;fi[di]===void 0&&(fi[di]=new Ee);const pi=fi[di];function L(){let e=pi.getStore();if(e===void 0)throw Error(`No active Ash context. Call this function only from authored runtime code such as tools, steps, and model callbacks.`);return e}function mi(e){return{debug(t,n){R(`debug`,e,t,n)},info(t,n){R(`info`,e,t,n)},warn(t,n){R(`warn`,e,t,n)},error(t,n){R(`error`,e,t,n),xi(t,n)}}}function hi(){return crypto.randomUUID()}function gi(e,t){let n={errorId:t??hi(),message:vi(e)},r=_i(e);return r!==void 0&&(n.name=r),n.detail=Si(e),n}function _i(e){if(e instanceof Error)return e.name===`Error`?void 0:e.name;if(l(e)&&u(e.name)&&e.name!==`Error`)return e.name}function vi(e){return l(e)&&!(e instanceof Error)&&typeof e.message==`string`?e.message:ke(e)}function yi(e,t){let n=t instanceof Error?t.message:ke(t),r=t instanceof Error?t.name:`Error`;e.setStatus({code:De.ERROR,message:n}),e.recordException({message:n,name:r,stack:Si(t)})}function R(e,t,n,r){let i=e===`error`?console.error:e===`warn`?console.warn:console.log,a=`[ash:${t}] ${n}`;if(r===void 0){i(a);return}i(a,bi(r))}function bi(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(r instanceof Error){t[n]=gi(r);continue}t[n]=r}return t}function xi(e,t){let n=Oe.getActiveSpan();if(n===void 0)return;let r=t?.error;if(r instanceof Error){yi(n,r);return}n.addEvent(e,t?bi(t):void 0)}function Si(e){return Ci(Ae(e,{breakLength:1/0,compact:!1,depth:10,maxStringLength:8192}),16384)}function Ci(e,t){if(Buffer.byteLength(e,`utf8`)<=t)return e;let n=e.slice(0,t);for(;Buffer.byteLength(n,`utf8`)>t&&n.length>0;)n=n.slice(0,-1);return`${n}<…truncated>`}function wi(e){if(e.message!==void 0)return{inputResponses:e.inputResponses,message:e.message,modelContext:e.modelContext};if(e.inputResponses!==void 0&&e.inputResponses.length>0)return{inputResponses:e.inputResponses,modelContext:e.modelContext};if(e.modelContext!==void 0&&e.modelContext.length>0)return{modelContext:e.modelContext}}function Ti(e){return e.kind}const Ei={kind:`http`};new I(`ash.auth`),new I(`ash.initiatorAuth`);const Di=new I(`ash.sessionId`),Oi=new I(`ash.continuationToken`);new I(`ash.mode`),new I(`ash.parentSession`),new I(`ash.capabilities`),new I(`ash.sessionCallback`),new I(`ash.sessionPrepared`);const ki={kind:`schedule`},Ai=mi(`execution.subagent-adapter`);function ji(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.callId==`string`&&t.callId.length>0&&typeof t.parentContinuationToken==`string`&&t.parentContinuationToken.length>0&&typeof t.parentSessionId==`string`&&typeof t.subagentName==`string`&&t.subagentName.length>0}const Mi={kind:`subagent`,async"input.requested"(e,t){let n=t.state;ji(n)&&await Ni({hookPayload:{callId:n.callId,childContinuationToken:t.ctx.require(Oi),childSessionId:t.ctx.require(Di),event:{requests:e.requests,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},kind:`subagent-input-request`,subagentName:n.subagentName},parentContinuationToken:n.parentContinuationToken})}};async function Ni(e){"use step";try{await Te(e.parentContinuationToken,e.hookPayload)}catch(t){let n=hi();throw Ai.warn(`failed to forward proxied HITL batch to parent`,{callId:e.hookPayload.callId,childContinuationToken:e.hookPayload.childContinuationToken,childSessionId:e.hookPayload.childSessionId,errorId:n,parentContinuationToken:e.parentContinuationToken,subagentName:e.hookPayload.subagentName,error:t}),t}}var z=class extends Error{registry;entryName;logicalPath;sourceId;constructor(e,t,n={}){super(t),this.name=`RuntimeRegistryError`,this.registry=e,n.entryName!==void 0&&(this.entryName=n.entryName),n.logicalPath!==void 0&&(this.logicalPath=n.logicalPath),n.sourceId!==void 0&&(this.sourceId=n.sourceId)}},Pi=class{registry;_entries=new Map;_reserved;constructor(e,t=[]){this.registry=e,this._reserved=new Set(t)}get size(){return this._entries.size}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)??null}asMap(){return this._entries}register(e,t,n={}){if(this._entries.has(e))throw new z(this.registry,n.duplicateMessage??`Duplicate ${this.registry} name "${e}".`,{...n.location,entryName:e});if(this._reserved.has(e))throw new z(this.registry,n.reservedMessage??`${Fi(this.registry)} "${e}" collides with another runtime-visible name.`,{...n.location,entryName:e});this._entries.set(e,t),this._reserved.add(e)}set(e,t){this._entries.set(e,t),this._reserved.add(e)}};function Fi(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}const Ii=[Ei,Mi,ki],Li=new Set([`kind`,`state`,`deliver`,`createAdapterContext`,`fetchFile`]);function Ri(e){let t=new Map,n=new Set;for(let e of Ii){let r=Bi(e);n.add(r),t.set(r,e)}for(let r of e.channels){if(r.adapter===void 0)continue;let e={logicalPath:r.logicalPath,sourceId:r.sourceId},i=r.adapter,a=Bi(i,e);if(n.has(a)){if(Vi(i))throw new z(`adapter`,`Channel adapter kind "${a}" is reserved by the framework. A route-declared adapter may share a framework kind only as a pass-through with no \`deliver\` hook, event handlers, \`attachments\` resolver, or \`createAdapterContext\` factory. Use a custom \`kind\` to add channel-specific behavior.`,{...e,entryName:a});continue}t.set(a,i)}return{adaptersByKind:t}}function zi(e,t){let n=t,r=e.adaptersByKind.get(n.kind);if(r===void 0)throw Error(`Unknown adapter kind: "${n.kind}". Declare the adapter on the route that starts this session so the runtime can rehydrate it.`);return{...r,state:n.state}}function Bi(e,t){let n=Ti(e);if(typeof n!=`string`||n.length===0)throw new z(`adapter`,"Adapters must declare a non-empty `kind` field.",{entryName:`unknown`,logicalPath:t?.logicalPath,sourceId:t?.sourceId});return n}function Vi(e){if(e.deliver!==void 0||e.fetchFile!==void 0||e.createAdapterContext!==void 0)return!0;for(let[t,n]of Object.entries(e))if(!Li.has(t)&&typeof n==`function`)return!0;return!1}function Hi(e,t={}){return t.moduleMapLoaderPath===void 0?{appRoot:e,kind:`disk`}:{appRoot:e,kind:`disk`,moduleMapLoaderPath:t.moduleMapLoaderPath}}function Ui(e){return e.kind===`disk`?e.appRoot:void 0}function Wi(e){return e.kind===`disk`?e.moduleMapLoaderPath===void 0?`disk:${e.appRoot}`:`disk:${e.appRoot}:authored-source:${e.moduleMapLoaderPath}`:`bundled`}function B(e){let t=Gi(e),n=`${t}/.ash/discovery`,r=`${t}/.ash/compile`;return{appRoot:t,compiledManifestPath:`${r}/compiled-agent-manifest.json`,compileDirectoryPath:r,compileMetadataPath:`${r}/compile-metadata.json`,diagnosticsPath:`${n}/diagnostics.json`,discoveryDirectoryPath:n,discoveryManifestPath:`${n}/agent-discovery-manifest.json`,moduleMapPath:`${r}/module-map.mjs`}}function Gi(e){let t=e.replaceAll(`\\`,`/`);return t===`/`?t:t.replace(/\/+$/,``)}function Ki(e){return je(e,{prefix:void 0}).message}function qi(e=`test-session`){return{bundleCache:new Map,bundleCacheKeyBySourceKey:new Map,compiledArtifacts:null,id:e}}const Ji=Symbol.for(`experimental-ash.runtime-session-storage`),Yi=Symbol.for(`experimental-ash.runtime-session-default`),V=globalThis;V[Ji]===void 0&&(V[Ji]=new Ee);const Xi=V[Ji];function Zi(){return V[Yi]===void 0&&(V[Yi]=qi(`process-default`)),V[Yi]}function Qi(){return Xi.getStore()??Zi()}function $i(){return Qi().compiledArtifacts}const ea=v.object({path:v.string(),sha256:v.string()}).strict(),ta=v.object({compile:v.object({moduleMap:ea}).strict(),discovery:v.object({diagnostics:ea,manifest:ea,sourceGraphHash:v.string(),summary:v.object({errors:v.number().finite(),warnings:v.number().finite()}).strict()}).strict(),generator:v.object({name:v.string(),version:v.string()}).strict(),kind:v.literal(ni),status:v.union([v.literal(`failed`),v.literal(`ready`)]),version:v.literal(5)}).strict();var na=class extends Error{metadataPath;constructor(e,t){super(e),this.name=`LoadCompileMetadataError`,t!==void 0&&(this.metadataPath=t)}};async function ra(e){let t=e.compiledArtifactsSource.kind===`disk`?B(e.compiledArtifactsSource.appRoot).compileMetadataPath:void 0;if(t!==void 0){let{readFile:e}=await import(`node:fs/promises`),n;try{n=JSON.parse(await e(t,`utf8`))}catch(e){throw new na(aa(e),t)}return ia(n,t)}let n=$i()?.metadata;return n===void 0?null:ia(n,`bundled compile metadata`)}function ia(e,t){let n=ta.safeParse(e);if(!n.success)throw new na(`Expected "${t}" to contain valid Ash compile metadata. ${Ki(n.error)}`,t);return n.data}function aa(e){return e instanceof Error?e.message:`Unknown compile metadata load failure.`}async function oa(e){let t=Wi(e),n=await sa(e);try{let r=(await ra({compiledArtifactsSource:e}))?.discovery.sourceGraphHash;return r===void 0||r.length===0?n===void 0?t:`${t}:mtime-${ca(n)}`:n===void 0?`${t}:${r}`:`${t}:${r}:mtime-${ca(n)}`}catch{return n===void 0?t:`${t}:mtime-${ca(n)}`}}async function sa(e){if(e.kind!==`disk`)return;let{stat:t}=await import(`node:fs/promises`),{compileMetadataPath:n}=B(e.appRoot);try{return(await t(n)).mtimeMs}catch{return}}function ca(e){return Math.floor(e).toString(36)}const la=`__root__`;function ua(e,t){if(t===void 0||t===`__root__`)return e.root;let n=e.nodesByNodeId.get(t);if(n===void 0)throw Error(`Missing runtime agent node for node id "${t}".`);return n}const da=`bundled compiled manifest`;var fa=class extends Error{manifestPath;constructor(e,t){super(e),this.name=`LoadCompiledManifestError`,t!==void 0&&(this.manifestPath=t)}};async function pa(e){let t=e.compiledArtifactsSource.kind===`disk`?B(e.compiledArtifactsSource.appRoot).compiledManifestPath:void 0;if(t!==void 0){let{readFile:e}=await import(`node:fs/promises`),n;try{n=JSON.parse(await e(t,`utf8`))}catch(e){throw new fa(ha(e),t)}return ma(n,t)}let n=$i();if(n!==null)return ma(n.manifest,da);throw new fa(`Compiled manifest is unavailable without an app root or bundled compiled artifacts.`,da)}function ma(e,t){let n=nn.safeParse(e);if(!n.success)throw new fa(`Expected "${t}" to contain a valid compiled Ash agent manifest. ${Ki(n.error)}`,t);return n.data}function ha(e){return e instanceof Error?e.message:`Unknown manifest load failure.`}const ga=`bundled compiled module map`;var _a=class extends Error{moduleMapPath;constructor(e,t){super(e),this.name=`LoadCompiledModuleMapError`,t!==void 0&&(this.moduleMapPath=t)}};async function va(e){let t=e.compiledArtifactsSource.kind===`disk`?B(e.compiledArtifactsSource.appRoot).moduleMapPath:void 0;if(t!==void 0){let e=xa(t);try{let n=await import(e);return ya(n.moduleMap??n.default,t)}catch(e){throw new _a(ba(e),t)}}let n=$i();if(n!==null)return ya(n.moduleMap,ga);throw new _a(`Compiled module map is unavailable without an app root or bundled compiled artifacts.`,ga)}function ya(e,t){let n=yn.safeParse(e);if(!n.success)throw new _a(`Expected "${t}" to export a valid compiled Ash module map. ${Ki(n.error)}`,t);return n.data}function ba(e){return e instanceof Error?e.message:`Unknown module-map load failure.`}function xa(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}const H=`/workspace`;function Sa(e){return e.length===0?null:[`Available skills`,`Listed skills are available in this run. Do not claim a listed skill is inaccessible unless activation or workspace inspection actually fails.`,`If the user names a skill or the request clearly matches one of the descriptions below, call load_skill before proceeding.`,`If multiple skills match, activate the minimal set that covers the task. After activation, follow the returned instructions instead of improvising around them.`,`If activation fails, say so briefly and continue with the best fallback. Packaged sibling files under a skill path can be inspected with bash or read_file when needed.`,...e.map(e=>Ca(e))].join(`
|
|
6
|
+
`)}function Ca(e){return`- ${e.name}: ${e.description} (path: ${H}/skills/${e.name}/SKILL.md)`}function wa(e){if(e.rootEntries.length!==0)return[`Workspace`,`- You have access to authored files mounted at the workspace root for this run.`,`- The live workspace root visible to \`bash\` in this run is \`${H}\`.`,`- Root entries under ${H}/:`,...e.rootEntries.map(e=>` - ${e}`),`- Treat \`${H}\` as the workspace root for this run unless a \`bash\` call shows otherwise.`,"- For questions about workspace paths or file availability, verify with `bash` first using commands like `pwd`, `ls`, and `find`.","- Use the `bash` tool with `ls`, `find`, and `rg` to inspect deeper contents when needed.",`- Do not claim these files are unavailable unless a workspace or tool call actually fails.`].join(`
|
|
7
|
+
`)}function Ta(e){return e instanceof Error&&e.name===`ConnectionAuthorizationRequiredError`}function Ea(e){return e instanceof Error&&e.name===`ConnectionAuthorizationFailedError`}function Da(e){return e?.startAuthorization!==void 0}const Oa=Object.freeze({__ashPlaceholder:`connection-authorization`}),ka=new I(`ash.pendingConnectionToolCalls`);function Aa(e,t){if(t.length===0)return e??[];let n=new Set,r=e??[];for(let e of r)n.add(e.toolCallId);let i=[...r];for(let e of t)n.has(e.toolCallId)||(n.add(e.toolCallId),i.push(e));return i}function ja(e,t){return`${e}__${t}`}const Ma=mi(`framework.connection-search`),Na=new I(`ash.connectionRegistry`),Pa=new I(`ash.discoveredConnectionTools`),U={description:`Search for tools across your connections. Discovered tools become directly callable by their qualified name (e.g. linear__list_issues) in your next response.`,execute:async(e,t)=>{let n=typeof t==`object`&&t&&`toolCallId`in t?t.toolCallId:void 0;return Fa(e,{toolCallId:typeof n==`string`?n:void 0})},inputSchema:{additionalProperties:!1,properties:{connection:{description:`Optional: limit search to a specific connection name.`,type:`string`},limit:{description:`Max results to return. Default 10.`,type:`number`},keywords:{description:`Search keywords and expanded aliases. Distill intent into keywords; avoid stop words like 'a', 'the', 'in'.`,type:`string`}},required:[`keywords`],type:`object`},logicalPath:`ash:framework/connection-search`,name:`connection_search`,onCompact({ctx:e}){return e.set(Pa,{byConnection:{}}),e.set(ka,[]),{}},sourceId:`ash:connection-search-tool`,sourceKind:`module`};async function Fa(e,t){let n=L(),r=n.get(Na);if(r===void 0)return[];let i=e.limit??10,a=Ia(e.keywords),o=[],s=[],c=e.connection!==void 0&&e.connection!==``?r.getConnections().filter(t=>t.connectionName===e.connection):r.getConnections(),l={...n.get(Pa)?.byConnection},u=[];for(let e of c){let t;try{t=await r.getClient(e.connectionName).getToolMetadata()}catch(t){if(Ta(t)){u.push(e.connectionName),s.push({connection:e.connectionName,description:e.description,needsAuthorization:!0});continue}if(Ea(t)){Ma.warn(`connection authorization failed`,{connection:e.connectionName,reason:t.reason,retryable:t.retryable,error:t}),s.push({connection:e.connectionName,description:e.description,error:`Authorization failed for ${e.connectionName}: ${t.message}`});continue}let n=t instanceof Error?t.message:`unknown error`;Ma.warn(`failed to load connection tools`,{connection:e.connectionName,error:t instanceof Error?t:Error(n)}),s.push({connection:e.connectionName,description:e.description,error:`Failed to load tools for "${e.connectionName}": ${n}`});continue}l[e.connectionName]=t;for(let n of t){let t=La(a,n);t>0&&o.push({item:{connection:e.connectionName,description:n.description,inputSchema:n.inputSchema,qualifiedName:ja(e.connectionName,n.name),tool:n.name},score:t})}}n.set(Pa,{byConnection:l});let d=u.filter(e=>Ra(r,e));if(d.length>0&&t?.toolCallId!==void 0){let r=n.get(ka);return n.set(ka,Aa(r,[{args:e,connectionNames:d,kind:`connection-discover`,toolCallId:t.toolCallId,toolName:`connection_search`}])),Oa}o.sort((e,t)=>t.score-e.score);let f=o.slice(0,i).map(e=>e.item);return f.length>0?[...f,...s]:c.map(e=>s.find(t=>t.connection===e.connectionName)||{connection:e.connectionName,description:e.description})}function Ia(e){return e.toLowerCase().split(/[\s_\-./]+/).filter(e=>e.length>1)}function La(e,t){let n=Ia(t.name),r=Ia(t.description),i=0;for(let t of e){for(let e of n)(e.includes(t)||t.includes(e))&&(i+=3);for(let e of r)(e.includes(t)||t.includes(e))&&(i+=1)}return i}function Ra(e,t){return e===void 0?!1:Da(e.getConnections().find(e=>e.connectionName===t)?.authorization)}const za=U.name;function Ba(e){return[`## Connections`,``,`You have direct access to the following external services through connected MCP servers.`,`When the user's request relates to any of these services, use them instead of web search or general knowledge.`,``,`Available connections:`,...e.map(e=>`- ${e.connectionName}: ${e.description}`),``,`Use ${za} to discover specific tools within a connection. Discovered tools become directly callable by their qualified name (e.g. linear__list_issues) in your next response.`].join(`
|
|
8
|
+
`)}function Va(e){return[...Ha(e.instructions),...Ua(e.workspaceSpec),...e.toolsAvailable?[`Tool execution
|
|
9
|
+
A single tool or subagent call runs as one serial action. If you call multiple independent tools or subagents in one response, Ash treats that batch as parallel work. Only batch work that is independent and does not rely on another call in the same response.`]:[],...Wa(e.connections),...Ga(e.skills)]}function Ha(e){if(e===void 0)return[];let t=e.markdown.trim();return t.length===0?[]:[`Instructions (${e.name})\n${t}`]}function Ua(e){if(e===void 0)return[];let t=wa(e);return t===void 0?[]:[t]}function Wa(e){return!e||e.length===0?[]:[Ba(e)]}function Ga(e){if(!e||e.length===0)return[];let t=Sa(e);return t===null?[]:[t]}function Ka(e){let t=e.agent,n=qa(t);return{id:t.config.name,instructions:Va({connections:t.connections,instructions:t.instructions,skills:t.skills,toolsAvailable:e.tools.length>0,workspaceSpec:t.workspaceSpec}),compactionModel:t.config.compaction?.model,model:t.config.model,nodeId:e.nodeId,turnMetadata:n,tools:[...e.tools],workspaceSpec:t.workspaceSpec}}function qa(e){let t={};return Object.keys(e.config.metadata).length>0&&(t.configMetadata={...e.config.metadata}),e.instructions!==void 0&&(t.instructionsName=e.instructions.name),e.skills.length>0&&(t.skillNames=e.skills.map(e=>e.name)),Object.keys(t).length>0?t:void 0}const Ja=new Set([`aud`,`exp`,`iat`,`iss`,`jti`,`nbf`,`sub`]);function Ya(e){let t={};for(let[n,r]of Object.entries(e)){if(typeof r==`string`){t[n]=r;continue}Array.isArray(r)&&r.every(e=>typeof e==`string`)&&(t[n]=Object.freeze([...r]))}return Object.freeze(t)}function Xa(e){let t=Ya(e);return Object.freeze(Object.fromEntries(Object.entries(t).filter(([e])=>!Ja.has(e))))}function Za(e,t){let n=Ya(e);if(t.subjects!==void 0){let n=typeof e.sub==`string`?e.sub:null;if(n===null||!t.subjects.some(e=>$a(e,n)))return!1}return t.claims===void 0?!0:Object.entries(t.claims).every(([e,t])=>{let r=n[e];return r===void 0?!1:typeof r==`string`?t.includes(r):r.some(e=>t.includes(e))})}function Qa(e){let t=typeof e.payload.iss==`string`?e.payload.iss:void 0,n=typeof e.payload.sub==`string`?e.payload.sub:void 0;if(t===void 0||n===void 0)throw Error(`Expected verified JWT payloads to include string iss and sub claims.`);let r=Ya(e.payload);return{attributes:Xa(e.payload),authenticator:e.authenticator,claims:r,issuer:t,principalId:`${t}:${n}`,principalType:e.principalType,subject:n}}function $a(e,t){if(!e.includes(`*`))return e===t;let n=e.replaceAll(/[.+?^${}()|[\]\\]/g,`\\$&`).replaceAll(`*`,`.*`);return RegExp(`^${n}$`).test(t)}const eo=v.object({issuer:v.string().optional(),jwks_uri:v.string().url()}).passthrough(),to=new Map,no=new Map;async function ro(e){let t;try{t=await io(e.strategy)}catch(e){return{kind:`misconfigured`,message:`Failed to load OIDC discovery metadata. ${e instanceof Error?e.message:`Unknown discovery failure.`}`}}try{let n=await Pe(e.token,t,{audience:[...e.strategy.audiences],clockTolerance:e.strategy.clockSkewSeconds,issuer:e.strategy.issuer});if(typeof n.payload.sub!=`string`||n.payload.sub.length===0)return{kind:`not-authenticated`};let r=e.strategy.acceptCurrentVercelProject&&oo({issuer:e.strategy.issuer,payload:n.payload}),i=r&&so({payload:n.payload});return!r&&!Za(n.payload,e.strategy)?{kind:`caller-not-allowed`}:{kind:`authenticated`,principal:Qa({authenticator:`oidc`,payload:n.payload,principalType:i?`runtime`:`service`})}}catch{return{kind:`not-authenticated`}}}async function io(e){let t=await ao(e.discoveryUrl),n=no.get(t.jwks_uri);if(n!==void 0)return n;let r=Me(new URL(t.jwks_uri));return no.set(t.jwks_uri,r),r}async function ao(e){let t=to.get(e);if(t!==void 0)return await t;let n=fetch(e,{headers:{accept:`application/json`}}).then(async e=>{if(!e.ok)throw Error(`Discovery route returned HTTP ${e.status}.`);return eo.parse(await e.json())}).catch(t=>{throw to.delete(e),t});return to.set(e,n),await n}function oo(e){if(!e.issuer.startsWith(`https://oidc.vercel.com`))return!1;let t=process.env.VERCEL_PROJECT_ID?.trim();return t===void 0||t.length===0?!1:typeof e.payload.project_id==`string`&&e.payload.project_id===t}function so(e){let t=(process.env.VERCEL_TARGET_ENV?.trim()??process.env.VERCEL_ENV?.trim())?.trim();return t===void 0||t.length===0?!1:typeof e.payload.environment==`string`&&e.payload.environment===t}function co(e){return{attributes:e.attributes,authenticator:e.authenticator,issuer:e.issuer,principalId:e.principalId,principalType:e.principalType,subject:e.subject}}const W=mi(`auth.vercel-oidc`);async function lo(e,t){return e===null||e.length===0?{kind:`not-authenticated`}:await ro({strategy:{acceptCurrentVercelProject:t.acceptCurrentVercelProject,audiences:[...t.audiences],clockSkewSeconds:t.clockSkewSeconds??30,discoveryUrl:t.discoveryUrl??`${t.issuer.replace(/\/$/,``)}/.well-known/openid-configuration`,issuer:t.issuer,kind:`oidc`,...t.claims===void 0?{}:{claims:t.claims},...t.subjects===void 0?{}:{subjects:t.subjects}},token:e})}function uo(e){if(e===null)return null;let t=/^Bearer\s+(.+)$/i.exec(e)?.[1]?.trim();return t===void 0||t.length===0?null:t}function fo(e={}){let t=e.status??401,n=e.code??(t===403?`forbidden`:`unauthorized`),r=e.message??(t===403?`Forbidden.`:`Authorization is required for this route.`),i=e.challenges??[],a=new Headers({"cache-control":`no-store`});for(let e of i)a.append(`www-authenticate`,po(e));return Response.json({code:n,error:r,ok:!1},{headers:a,status:t})}function po(e){if(e.parameters===void 0||Object.keys(e.parameters).length===0)return e.scheme;let t=Object.entries(e.parameters).map(([e,t])=>`${e}="${mo(t)}"`).join(`, `);return`${e.scheme} ${t}`}function mo(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}function ho(){return()=>void 0}async function go(e,t={}){if(e===null||e.length===0)return W.debug(`Rejected request without a bearer token.`),{ok:!1};let n=vo(e);if(n===null)return W.debug(`Rejected token that failed to decode as a JWT.`),{ok:!1};if(!n.issuer.startsWith(`https://oidc.vercel.com/`))return W.debug(`Rejected token whose issuer is not a Vercel OIDC issuer.`,{issuer:n.issuer}),{ok:!1};if(n.audiences.length===0)return W.debug(`Rejected token with no audience claim.`,{issuer:n.issuer}),{ok:!1};let r=await lo(e,{acceptCurrentVercelProject:!0,audiences:n.audiences,issuer:n.issuer,subjects:t.subjects??[]});return r.kind===`authenticated`?(W.debug(`Accepted Vercel OIDC token.`,{issuer:n.issuer,principalType:r.principal.principalType,subject:r.principal.subject}),{ok:!0,sessionAuth:co(r.principal)}):(W.debug(`Rejected Vercel OIDC token after verification.`,{audiences:n.audiences,issuer:n.issuer,reason:r.kind,subjectsConfigured:(t.subjects??[]).length>0,...r.kind===`misconfigured`?{detail:r.message}:{}}),{ok:!1})}function _o(e={}){return async t=>{let n=await go(uo(t.headers.get(`authorization`)),e);return n.ok?n.sessionAuth:null}}function vo(e){let t;try{t=Ne(e)}catch{return null}return typeof t.iss!=`string`||t.iss.length===0?null:{audiences:typeof t.aud==`string`?[t.aud]:Array.isArray(t.aud)?t.aud.filter(e=>typeof e==`string`):[],issuer:t.iss}}const yo=v.object({callId:v.string().min(1),subagentName:v.string().min(1),token:v.string().min(1),url:v.string().min(1)}).strict().superRefine((e,t)=>{let n;try{n=new URL(e.url)}catch{t.addIssue({code:`custom`,message:`Callback url must be absolute.`,path:[`url`]});return}xo(n)!==e.token&&t.addIssue({code:`custom`,message:`Callback url token must match callback token.`,path:[`url`]})});function bo(e){let t=yo.safeParse(e);return t.success?{callback:t.data,ok:!0}:{cause:t.error,message:So(t.error),ok:!1}}function xo(e){let t=f(``);if(!e.pathname.startsWith(t))return null;let n=e.pathname.slice(t.length);if(n.length===0||n.includes(`/`))return null;try{return decodeURIComponent(n)}catch{return null}}function So(e){return`Invalid callback metadata: ${e.issues.map(e=>`${e.path.length===0?`callback`:`callback.${e.path.join(`.`)}`}: ${e.message}`).join(`; `)}`}function Co(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=0}function wo(e){if(e.protocol!==`ash-attachment:`)throw Error(`AttachmentRef URL must use scheme "ash-attachment:". Got: "${e.protocol}".`);let t=e.searchParams.get(`v`);if(t!==`1`)throw Error(`AttachmentRef wire format version must be "1". Got: ${t===null?`missing`:JSON.stringify(t)}.`);let n=e.searchParams.get(`p`);if(n===null||n===``)throw Error(`AttachmentRef URL is missing the required "p" payload query param.`);let r;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);r=JSON.parse(e)}catch(e){throw Error(`AttachmentRef payload is not valid base64url-encoded JSON: ${d(e)}`)}if(typeof r!=`object`||!r||Array.isArray(r))throw Error(`AttachmentRef payload must decode to a JSON object.`);let i=r;if(!(`params`in i))throw Error(`AttachmentRef payload is missing the required "params" field.`);let a=i.params;if(!(`size`in i))return{params:a};let o=i.size;if(typeof o!=`number`||!Co(o))throw Error(`AttachmentRef payload "size" must be a non-negative integer. Got: ${JSON.stringify(o)}.`);return{params:a,size:o}}function To(e){return e instanceof URL&&e.protocol===`ash-attachment:`}function Eo(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)||e instanceof Uint8Array||e instanceof ArrayBuffer?e.byteLength:typeof e==`string`?Do(e):To(e)?wo(e).size??null:e instanceof URL&&e.protocol===`data:`?Do(e.href):null}function Do(e){if(e.startsWith(`data:`)){let t=e.indexOf(`,`);if(t===-1)return null;let n=e.slice(5,t),r=e.slice(t+1);if(n.endsWith(`;base64`))return Oo(r);try{return Buffer.byteLength(decodeURIComponent(r),`utf8`)}catch{return Buffer.byteLength(r,`utf8`)}}return/^https?:\/\//.test(e)?null:Oo(e)}function Oo(e){let t=e.trimEnd();if(t.length===0)return 0;let n=0;return t.endsWith(`==`)?n=2:t.endsWith(`=`)&&(n=1),Math.max(0,Math.floor(t.length*3/4)-n)}const ko=Object.freeze({allowedMediaTypes:`*`,maxBytes:25*1024*1024});function Ao(e,t=ko){if(e===`disabled`)return`disabled`;if(e===void 0)return t;let n=e.maxBytes??t.maxBytes,r=e.allowedMediaTypes??t.allowedMediaTypes;if(n<0||!Number.isFinite(n))throw RangeError(`UploadPolicy.maxBytes must be a non-negative finite number. Received: ${String(n)}.`);return{allowedMediaTypes:r,maxBytes:n}}function jo(e,t){if(t===`disabled`)return!1;if(t.allowedMediaTypes===`*`)return!0;let n=e.toLowerCase();for(let e of t.allowedMediaTypes){let t=e.toLowerCase();if(t===n)return!0;if(t.endsWith(`/*`)){let e=t.slice(0,-1);if(n.startsWith(e))return!0}}return!1}function Mo(e,t){if(t===`disabled`||!jo(e.mediaType,t)){let n={allowedMediaTypes:t===`disabled`||t.allowedMediaTypes===`*`?[]:[...t.allowedMediaTypes],kind:`disallowed-media-type`,mediaType:e.mediaType};return e.filename===void 0?n:{...n,filename:e.filename}}let n=Eo(e.data);if(n!==null&&n>t.maxBytes){let r={byteLength:n,kind:`too-large`,limit:t.maxBytes,mediaType:e.mediaType};return e.filename===void 0?r:{...r,filename:e.filename}}return null}function No(e,t){if(typeof e==`string`)return[];let n=[];for(let r of e){if(r.type!==`file`)continue;let e=Mo(r,t);e!==null&&n.push(e)}return n}function Po(e){let t=e.filename??e.mediaType;if(e.kind===`too-large`)return`${t} (${e.byteLength} bytes) exceeds the ${e.limit}-byte upload limit.`;let n=e.allowedMediaTypes.length>0?` Allowed: ${e.allowedMediaTypes.join(`, `)}.`:``;return`${t} has media type "${e.mediaType}" which is not allowed by this route.${n}`}function Fo(e,t){return{method:`GET`,path:e,handler:t}}function Io(e,t){return{method:`POST`,path:e,handler:t}}function Lo(e){let t=Ro(e);return{__kind:`ash:channel`,routes:e.routes,adapter:t,receive:e.receive}}function Ro(e){let t=e.state!=null,n=e.context!=null,r=e.fetchFile!==void 0,i=t||n,a={},o=!1,s=[`turn.started`,`actions.requested`,`action.result`,`message.completed`,`message.appended`,`input.requested`,`turn.failed`,`turn.completed`,`session.failed`,`session.completed`,`session.waiting`,`connection.authorization_required`,`connection.authorization_pending`,`connection.authorization_completed`],c=e.events;for(let e of s){let t=c?.[e];t&&(o=!0,a[e]=(e,n)=>t(e,n))}return!i&&!o&&!r?{kind:e.kindHint??`http`}:{kind:e.kindHint??`defineChannel`,state:t?{...e.state}:{},fetchFile:e.fetchFile,createAdapterContext(t){let r=t.state,i=t.session;return{...n?e.context(r,i):{},state:r,ctx:t.ctx,session:i}},deliver(e){return wi(e)},...a}}function zo(e){let t=Ao(e.uploadPolicy);return Lo({routes:[Io(`/ash/v1/session`,async(n,{send:r})=>{let i=await Bo(e.auth,n);if(i instanceof Response)return i;let a=i,o;try{o=await n.json()}catch{return Response.json({error:`Invalid JSON body.`,ok:!1},{status:400})}if(typeof o!=`object`||!o)return Response.json({error:`Expected a JSON object.`,ok:!1},{status:400});let s=Vo(o);if(s instanceof Response)return s;let c=Jo(s,t);if(c!==null)return c;let l=`ash:${crypto.randomUUID()}`,u=await r(Uo(s),{auth:a,callback:s.callback,continuationToken:l,mode:s.mode});return Response.json({continuationToken:u.continuationToken,ok:!0,sessionId:u.id},{headers:{"cache-control":`no-store`,[p]:u.id},status:202})}),Io(`/ash/v1/session/:sessionId`,async(n,{send:r,getSession:i,params:a})=>{let o=await Bo(e.auth,n);if(o instanceof Response)return o;let s=o,c=a.sessionId;if(!c)return Response.json({error:`Missing session id.`,ok:!1},{status:400});try{i(c)}catch{return Response.json({error:`Session not found.`,ok:!1},{status:404})}let l;try{l=await n.json()}catch{return Response.json({error:`Invalid JSON body.`,ok:!1},{status:400})}if(typeof l!=`object`||!l)return Response.json({error:`Expected a JSON object.`,ok:!1},{status:400});let u=Ho(l);if(u instanceof Response)return u;let d=Jo(u,t);if(d!==null)return d;let f=await r({inputResponses:u.inputResponses,message:u.message,modelContext:u.modelContext},{auth:s,continuationToken:u.continuationToken});return Response.json({ok:!0,sessionId:f.id},{headers:{"cache-control":`no-store`,[p]:f.id},status:200})}),Fo(`/ash/v1/session/:sessionId/stream`,async(t,{getSession:n,params:r})=>{let i=await Bo(e.auth,t);if(i instanceof Response)return i;let a=r.sessionId;if(!a)return Response.json({error:`Missing session id.`,ok:!1},{status:400});let o=Qo(t);if(o instanceof Response)return o;try{let e=$o(await n(a).getEventStream({startIndex:o}));return new Response(e,{headers:{"cache-control":`no-store`,"content-type":ne,[p]:a,[te]:g,[re]:`14`}})}catch{return Response.json({error:`Session not found.`,ok:!1},{status:404})}})]})}async function Bo(e,t){let n=await e(t);return n===null?fo({challenges:[{scheme:`Bearer`}]}):n??null}function Vo(e){let t=Ko(e.message);if(t instanceof Response)return t;let n=Xo(e.clientContext);if(n instanceof Response)return n;let r=Wo(e.callback);if(r instanceof Response)return r;let i=Go(e.mode);return i instanceof Response?i:t===void 0?Response.json({error:`Missing or empty 'message' field.`,ok:!1},{status:400}):{callback:r,message:t,mode:i,modelContext:n}}function Ho(e){let t=typeof e.continuationToken==`string`&&e.continuationToken.length>0?e.continuationToken:void 0;if(t===void 0)return Response.json({error:`Missing or empty 'continuationToken' field.`,ok:!1},{status:400});let n=Ko(e.message);if(n instanceof Response)return n;let r=Yo(e.inputResponses);if(r instanceof Response)return r;let i=Xo(e.clientContext);return i instanceof Response?i:n===void 0&&r===void 0?Response.json({error:`Expected a non-empty 'message', a non-empty 'inputResponses' array, or both.`,ok:!1},{status:400}):{message:n,continuationToken:t,inputResponses:r,modelContext:i}}function Uo(e){return e.modelContext===void 0?e.message:{message:e.message,modelContext:e.modelContext}}function Wo(e){if(e===void 0)return;let t=bo(e);return t.ok?t.callback:Response.json({error:t.message,ok:!1},{status:400})}function Go(e){if(e!==void 0)return e===`conversation`||e===`task`?e:Response.json({error:`Expected 'mode' to be either 'conversation' or 'task'.`,ok:!1},{status:400})}function Ko(e){if(e===void 0)return;if(typeof e==`string`)return e.length>0?e:void 0;if(!Array.isArray(e))return Response.json({error:`Expected 'message' to be a string or an array of text/file parts.`,ok:!1},{status:400});if(e.length===0)return;let t=[];for(let n of e){let e=qo(n);if(e instanceof Response)return e;t.push(e)}return t}function qo(e){if(typeof e!=`object`||!e)return Response.json({error:`Expected each message part to be an object.`,ok:!1},{status:400});let t=e;if(t.type===`text`)return typeof t.text!=`string`||t.text.length===0?Response.json({error:`Text parts require a non-empty 'text' string.`,ok:!1},{status:400}):{type:`text`,text:t.text};if(t.type===`file`){if(typeof t.mediaType!=`string`||t.mediaType.length===0)return Response.json({error:`File parts require a non-empty 'mediaType' string.`,ok:!1},{status:400});if(typeof t.data!=`string`)return Response.json({error:`File parts require a 'data' string (base64, data URL, or URL).`,ok:!1},{status:400});let e={type:`file`,mediaType:t.mediaType,data:t.data};return typeof t.filename==`string`&&t.filename.length>0&&(e.filename=t.filename),e}return Response.json({error:`Unsupported message part type "${String(t.type)}". Use 'text' or 'file'.`,ok:!1},{status:400})}function Jo(e,t){if(!e.message)return null;let n=No(e.message,t);if(n.length===0)return null;let[r]=n;if(!r)return null;let i=r.kind===`too-large`?413:415;return Response.json({error:Po(r),ok:!1,violations:n.map(e=>e.kind===`too-large`?{byteLength:e.byteLength,filename:e.filename,kind:e.kind,limit:e.limit,mediaType:e.mediaType}:{allowedMediaTypes:e.allowedMediaTypes,filename:e.filename,kind:e.kind,mediaType:e.mediaType})},{status:i})}function Yo(e){if(e===void 0)return;if(!Array.isArray(e)||e.length===0)return Response.json({error:`Expected 'inputResponses' to be a non-empty array.`,ok:!1},{status:400});let t=e.filter(ee);return t.length===e.length?t:Response.json({error:`Expected every 'inputResponses' entry to match the HITL response schema.`,ok:!1},{status:400})}function Xo(e){if(e!==void 0){if(typeof e==`string`)return e.length>0?[Zo(e)]:void 0;if(Array.isArray(e))return e.length===0?void 0:e.every(e=>typeof e==`string`&&e.length>0)?e.map(e=>Zo(e)):Response.json({error:`Expected 'clientContext' array entries to be non-empty strings.`,ok:!1},{status:400});if(typeof e!=`object`||!e)return Response.json({error:`Expected 'clientContext' to be a string, string array, or JSON object.`,ok:!1},{status:400});try{let t=oe(e);return[Zo(JSON.stringify(t))]}catch{return Response.json({error:`Expected 'clientContext' to be a JSON-serializable object.`,ok:!1},{status:400})}}}function Zo(e){return{role:`user`,content:`Ephemeral client context:
|
|
10
|
+
${e}`}}function Qo(e){let t=new URL(e.url).searchParams.get(`startIndex`);if(t===null)return;let n=Number.parseInt(t,10);return!Number.isSafeInteger(n)||n<0?Response.json({error:`Expected startIndex to be a non-negative integer.`,ok:!1},{status:400}):n}function $o(e){let t=new TextEncoder;return e.pipeThrough(new TransformStream({transform(e,n){n.enqueue(t.encode(`${JSON.stringify(e)}\n`))}}))}function es(){return new Response(`<!doctype html>
|
|
11
|
+
<html lang="en">
|
|
12
|
+
<head>
|
|
13
|
+
<meta charset="utf-8" />
|
|
14
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
15
|
+
<title>Authorization complete</title>
|
|
16
|
+
<style>
|
|
17
|
+
:root {
|
|
18
|
+
color-scheme: light dark;
|
|
19
|
+
--bg: #fafafa;
|
|
20
|
+
--fg: #111111;
|
|
21
|
+
--muted: #525252;
|
|
22
|
+
--card-bg: #ffffff;
|
|
23
|
+
--card-border: #e5e5e5;
|
|
24
|
+
}
|
|
25
|
+
@media (prefers-color-scheme: dark) {
|
|
26
|
+
:root {
|
|
27
|
+
--bg: #0a0a0a;
|
|
28
|
+
--fg: #fafafa;
|
|
29
|
+
--muted: #a3a3a3;
|
|
30
|
+
--card-bg: #171717;
|
|
31
|
+
--card-border: #262626;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
body {
|
|
35
|
+
margin: 0;
|
|
36
|
+
min-height: 100vh;
|
|
37
|
+
display: grid;
|
|
38
|
+
place-items: center;
|
|
39
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
|
|
40
|
+
background: var(--bg);
|
|
41
|
+
color: var(--fg);
|
|
42
|
+
}
|
|
43
|
+
.card {
|
|
44
|
+
max-width: 28rem;
|
|
45
|
+
padding: 2rem 2.25rem;
|
|
46
|
+
border: 1px solid var(--card-border);
|
|
47
|
+
border-radius: 12px;
|
|
48
|
+
background: var(--card-bg);
|
|
49
|
+
color: var(--fg);
|
|
50
|
+
text-align: center;
|
|
51
|
+
}
|
|
52
|
+
h1 { font-size: 1.25rem; margin: 0 0 0.5rem; color: var(--fg); }
|
|
53
|
+
p { margin: 0; color: var(--muted); line-height: 1.5; }
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
<body>
|
|
57
|
+
<main class="card">
|
|
58
|
+
<h1>Authorization complete</h1>
|
|
59
|
+
<p>You can close this tab and return to your app.</p>
|
|
60
|
+
</main>
|
|
61
|
+
</body>
|
|
62
|
+
</html>`,{headers:{"cache-control":`no-store`,"content-type":`text/html; charset=utf-8`},status:200})}const ts=[`GET`,`POST`];function ns(){return ts.map(e=>is(e))}function rs(){return new Set(ts.map(as))}function is(e){let t=as(e);return{name:t,method:e,urlPath:ae,fetch:os,logicalPath:`framework://channels/${t}`,sourceId:`ash:framework:connection-callback-${e.toLowerCase()}`,sourceKind:`module`}}function as(e){return`ash/v1/connections/callback/${e.toLowerCase()}`}async function os(e,t){let n=t.params.name,r=t.params.token;if(typeof n!=`string`||n.length===0)return Response.json({error:`Missing connection name.`,ok:!1},{status:400});if(typeof r!=`string`||r.length===0)return Response.json({error:`Missing callback token.`,ok:!1},{status:400});let i=await ss(e);try{await Te(r,i)}catch{return Response.json({error:`Connection callback not pending.`,ok:!1},{status:404})}return es()}async function ss(e){let t={};e.headers.forEach((e,n)=>{t[n]=e});let n=``;if(e.method!==`GET`&&e.method!==`HEAD`)try{n=await e.text()}catch{n=``}return{body:n,headers:t,method:e.method,url:e.url}}const cs=[`POST`];function ls(){return cs.map(e=>ds(e))}function us(){return new Set(cs.map(fs))}function ds(e){let t=fs(e);return{name:t,method:e,urlPath:_,fetch:ps,logicalPath:`framework://channels/${t}`,sourceId:`ash:framework:session-callback-${e.toLowerCase()}`,sourceKind:`module`}}function fs(e){return`ash/v1/callback/${e.toLowerCase()}`}async function ps(e,t){let n=t.params.token;if(typeof n!=`string`||n.length===0)return Response.json({error:`Missing callback token.`,ok:!1},{status:400});let r;try{r=await e.json()}catch{return Response.json({error:`Invalid JSON body.`,ok:!1},{status:400})}let i=ms(r);if(i instanceof Response)return i;try{await Te(n,{kind:`runtime-action-result`,results:[i]})}catch{return Response.json({error:`Session callback not pending.`,ok:!1},{status:404})}return Response.json({ok:!0},{status:202})}function ms(e){if(typeof e!=`object`||!e)return Response.json({error:`Expected a JSON object.`,ok:!1},{status:400});let t=e;return typeof t.callId!=`string`||t.callId.length===0?Response.json({error:`Missing callback callId.`,ok:!1},{status:400}):typeof t.subagentName!=`string`||t.subagentName.length===0?Response.json({error:`Missing callback subagentName.`,ok:!1},{status:400}):t.kind===`session.completed`?{callId:t.callId,kind:`subagent-result`,output:typeof t.output==`string`?t.output:``,subagentName:t.subagentName}:t.kind===`session.failed`?{callId:t.callId,isError:!0,kind:`subagent-result`,output:t.error===void 0?{code:`REMOTE_AGENT_FAILED`,message:`Remote agent failed.`}:t.error,subagentName:t.subagentName}:Response.json({error:`Unsupported callback kind.`,ok:!1},{status:400})}function hs(){let e=zo({auth:_s()}),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(...ns(),...ls()),t}function gs(){return new Set([`ash`,...rs(),...us()])}function _s(){return process.env.VERCEL?_o():ho()}const vs=ie.omit({action:!0,display:!0,requestId:!0}),{$schema:ys,...bs}=v.toJSONSchema(vs),xs={description:`Ask the user a question and wait for their response before continuing. Use this when you need clarification or a choice from the user.`,inputSchema:bs,logicalPath:`ash:framework/ask-question`,name:`ask_question`,sourceId:`ash:ask-question-tool`,sourceKind:`module`};async function G(){let e=L().get(gu);if(e===void 0)throw Error(`This tool requires sandbox access on the runtime context. Ensure the step is running inside a managed runtime context with sandbox support.`);let t=await e.get();if(t===null)throw Error(`The sandbox is not available in the current runtime context.`);return t}function K(e){if(!e.startsWith(`/`))throw Error(`filePath must be an absolute path. Received: "${e}". Use an absolute path such as /workspace/foo.ts.`)}function Ss(e){return ws(e,`head`)}function Cs(e){return ws(e,`tail`)}function ws(e,t){let n=e.split(`
|
|
63
|
+
`),r=Es(n),i=t===`head`,a=[],o=0,s=i?0:n.length-1,c=i?1:-1;for(let e=s;e>=0&&e<n.length&&a.length<2e3;e+=c){let t=Ts(n[e]??``),r=Buffer.byteLength(t,`utf8`)+1;if(o+r>51200&&a.length>0)break;a.push(t),o+=r}return i||a.reverse(),{output:a.join(`
|
|
64
|
+
`),outputLines:a.length,totalLines:r,truncated:a.length<r}}function Ts(e){return e.length<=2e3?e:e.slice(0,2e3)+` [truncated]`}function Es(e){return e.length>0&&e[e.length-1]===``?e.length-1:e.length}async function Ds(e){let t=await(await G()).runCommand({command:e.command}),n=Cs(t.stdout),r=Cs(t.stderr),i=n.truncated||r.truncated,a=n.output;n.truncated&&(a=`[stdout truncated: showing last ${n.outputLines} of ${n.totalLines} lines]\n`+a);let o=r.output;return r.truncated&&(o=`[stderr truncated: showing last ${r.outputLines} of ${r.totalLines} lines]\n`+o),{exitCode:t.exitCode,stderr:o,stdout:a,truncated:i}}const Os={additionalProperties:!1,properties:{command:{description:`The shell command to execute.`,type:`string`}},required:[`command`],type:`object`};async function ks(e){return Ds(e)}const As={description:`Execute a shell command in the shared workspace environment.`,execute:ks,inputSchema:Os,logicalPath:`ash:framework/bash`,name:`bash`,sourceId:`ash:bash-tool`,sourceKind:`module`},js=new I(`ash.readFile`);function q(e){return ue.normalize(e)}function Ms(e){return e}function Ns(e){let t=_e(`sha256`).update(e.content,`utf8`).digest(`hex`);return{byteLength:Buffer.byteLength(e.content,`utf8`),contentHash:t,filePath:e.filePath}}function Ps(e,t,n){let r=e.ensure(js,()=>({byTarget:{}}));e.set(js,{byTarget:{...r.byTarget,[t]:n}})}function Fs(e){e.set(js,{byTarget:{}})}const Is=new Map;async function Ls(e){let t=Is.get(e.id);if(t!==void 0)return t;let n=Rs(e);Is.set(e.id,n);try{return await n}catch{return Is.delete(e.id),!1}}async function Rs(e){return(await e.runCommand({command:`command -v rg >/dev/null 2>&1`})).exitCode===0}function J(e){return`'${e.replace(/'/g,`'\\''`)}'`}async function zs(e){let t=e.path??`/workspace`;K(t);let n=q(t),r=Math.min(Math.max(1,e.limit??100),1e3),i=await G(),a=await Ls(i)?Bs({normalizedPath:n,pattern:e.pattern}):Vs({normalizedPath:n,pattern:e.pattern}),o=await i.runCommand({command:a});if(o.exitCode!==0&&o.exitCode!==1)throw Us(a,o.exitCode,o.stderr);let s=o.stdout.split(`
|
|
65
|
+
`).filter(e=>e.length>0),c=s.length>r,l=c?s.slice(0,r):s,u=[],d=0,f=!1;for(let e of l){let t=q(e),n=Buffer.byteLength(t,`utf8`)+1;if(d+n>51200&&u.length>0){f=!0;break}u.push(t),d+=n}if(u.length===0)return{content:`No files found`,count:0,path:n,truncated:!1};let p=c||f,m=[...u];return p&&(m.push(``),m.push(`(Results truncated: showing first ${u.length} results out of more. Use a more specific path or pattern to narrow results.)`)),{content:m.join(`
|
|
66
|
+
`),count:u.length,path:n,truncated:p}}function Bs(e){return[`rg --files --hidden`,`--glob '!.git/*'`,`--glob ${J(e.pattern)}`,`-- ${J(e.normalizedPath)}`].join(` `)}function Vs(e){let t=Hs(e.pattern),n=t.includes(`/`)?`-path ${J(`*/${t}`)}`:`-name ${J(t)}`;return[`find ${J(e.normalizedPath)}`,`-type f`,`-not -path '*/.git/*'`,n].join(` `)}function Hs(e){let t=e.replaceAll(`**`,`*`);for(;t.startsWith(`*/`);)t=t.slice(2);return t}function Us(e,t,n){let r=n.trim(),i=r.length>0?r:`no stderr output`;return Error(`glob failed (exit ${t}): ${i}\nCommand: ${e}`)}const Ws={additionalProperties:!1,properties:{limit:{description:`Maximum number of results to return. Defaults to 100.`,maximum:1e3,minimum:1,type:`integer`},path:{description:`The directory to search in. Defaults to /workspace. Must be an absolute path. Omit to use the default.`,type:`string`},pattern:{description:`The glob pattern to match files against (e.g. "**/*.ts", "src/**/*.js").`,type:`string`}},required:[`pattern`],type:`object`};async function Gs(e){return zs(e)}const Ks={description:[`Fast file pattern matching tool that works with any codebase size.`,``,`Usage:`,`- Supports glob patterns like "**/*.js" or "src/**/*.ts".`,`- Returns matching file paths.`,`- Use this tool when you need to find files by name patterns.`,`- If you are unsure of the correct file path, use the glob tool to look up filenames by glob pattern.`,`- Use the grep tool instead if you need to search file contents.`,`- Call this tool in parallel when you know there are multiple patterns to search for.`].join(`
|
|
67
|
+
`),execute:Gs,inputSchema:Ws,logicalPath:`ash:framework/glob`,name:`glob`,sourceId:`ash:glob-tool`,sourceKind:`module`};async function qs(e){let t=e.path??`/workspace`;K(t);let n=q(t),r=Math.min(Math.max(1,e.limit??100),1e3),i=e.context!==void 0&&e.context>0?e.context:0,a=await G(),o=await Ls(a)?Js({contextLines:i,effectiveLimit:r,glob:e.glob,ignoreCase:e.ignoreCase??!1,literal:e.literal??!1,normalizedPath:n,pattern:e.pattern}):Ys({contextLines:i,effectiveLimit:r,glob:e.glob,ignoreCase:e.ignoreCase??!1,literal:e.literal??!1,normalizedPath:n,pattern:e.pattern}),s=await a.runCommand({command:o});if(s.exitCode!==0&&s.exitCode!==1)throw Zs(o,s.exitCode,s.stderr);let c=s.stdout;return c.trim().length===0?{content:`No matches found`,matchCount:0,path:n,truncated:!1}:Xs({effectiveLimit:r,normalizedPath:n,stdout:c})}function Js(e){let t=[`rg`,`--line-number`,`--color=never`,`--hidden`,`--glob '!.git/*'`];return e.ignoreCase&&t.push(`--ignore-case`),e.literal&&t.push(`--fixed-strings`),e.glob!==void 0&&t.push(`--glob ${J(e.glob)}`),e.contextLines>0&&t.push(`--context ${e.contextLines}`),t.push(`--max-count ${e.effectiveLimit}`),t.push(`--`),t.push(J(e.pattern)),t.push(J(e.normalizedPath)),t.join(` `)}function Ys(e){let t=[`grep`,`-r`,`-n`,`--color=never`,`--exclude-dir=.git`];return e.ignoreCase&&t.push(`-i`),e.literal?t.push(`-F`):t.push(`-E`),e.glob!==void 0&&t.push(`--include=${J(e.glob)}`),e.contextLines>0&&t.push(`-C ${e.contextLines}`),t.push(`-m ${e.effectiveLimit}`),t.push(`--`),t.push(J(e.pattern)),t.push(J(e.normalizedPath)),t.join(` `)}function Xs(e){let t=e.stdout.split(`
|
|
68
|
+
`),n=[],r=0,i=0,a=!1;for(let e of t){if(e.length===0&&t.indexOf(e)===t.length-1)continue;e!==`--`&&e.length>0&&/^.+:\d+:/.test(e)&&i++;let o=Ts(e),s=Buffer.byteLength(o,`utf8`)+1;if(r+s>51200&&n.length>0){a=!0;break}n.push(o),r+=s}let o=a||i>=e.effectiveLimit,s=n.join(`
|
|
69
|
+
`);if(o){let t=[];i>=e.effectiveLimit&&t.push(`Match limit reached (${e.effectiveLimit}). Use a larger limit or more specific pattern.`),a&&t.push(`Output truncated due to size. Use a more specific path or pattern.`),s+=`\n\n[${t.join(` `)}]`}return{content:s,matchCount:i,path:e.normalizedPath,truncated:o}}function Zs(e,t,n){let r=n.trim(),i=r.length>0?r:`no stderr output`;return Error(`grep failed (exit ${t}): ${i}\nCommand: ${e}`)}const Qs={additionalProperties:!1,properties:{context:{description:`Number of surrounding context lines to include before and after each match. Defaults to 0.`,minimum:0,type:`integer`},glob:{description:`Filter files by glob pattern (e.g. "*.ts", "*.{ts,tsx}").`,type:`string`},ignoreCase:{description:`Perform case-insensitive search. Defaults to false.`,type:`boolean`},limit:{description:`Maximum number of matches to return per file. Defaults to 100.`,maximum:1e3,minimum:1,type:`integer`},literal:{description:`Treat the pattern as a literal string instead of a regular expression. Defaults to false.`,type:`boolean`},path:{description:`The directory or file to search in. Defaults to /workspace. Must be an absolute path. Omit to use the default.`,type:`string`},pattern:{description:`The regex pattern to search for in file contents (e.g. "log.*Error", "function\\s+\\w+").`,type:`string`}},required:[`pattern`],type:`object`};async function $s(e){return qs(e)}const ec={description:[`Fast content search tool that works with any codebase size.`,``,`Usage:`,`- Searches file contents using regular expressions.`,`- Supports full regex syntax (e.g. "log.*Error", "function\\s+\\w+").`,`- Filter files by pattern with the glob parameter (e.g. "*.js", "*.{ts,tsx}").`,`- Returns matching lines with file paths and line numbers.`,`- Use this tool when you need to find files containing specific patterns.`,`- Use the glob tool instead if you only need to find files by name.`,`- Call this tool in parallel when you have multiple independent searches.`,`- Any line longer than 2000 characters is truncated.`].join(`
|
|
70
|
+
`),execute:$s,inputSchema:Qs,logicalPath:`ash:framework/grep`,name:`grep`,sourceId:`ash:grep-tool`,sourceKind:`module`};async function tc(e){let{filePath:t,offset:n,limit:r}=e;K(t);let i=await G(),a=q(t),o=n??1,s=r??2e3;if(o<1)throw Error(`offset must be >= 1. Received: ${o}.`);let c=await i.readTextFile({path:t});if(c===null)throw Error(`File not found: ${t}. Verify the path exists and is accessible in the sandbox.`);if(c.includes(`\0`))throw Error(`File "${t}" contains NUL bytes and appears to be a binary file. read_file only supports text files.`);let l=c.split(`
|
|
71
|
+
`),u=l.length>0&&l[l.length-1]===``?l.length-1:l.length;if(u===0){if(o>1)throw Error(`offset ${o} is past the end of the file (0 lines). Use the default offset to read an empty file.`);return{content:``,path:a,totalLines:0,truncated:!1}}if(o>u)throw Error(`offset ${o} is past the end of the file (${u} lines).`);let d=Ns({content:c,filePath:a}),f=Ms(a);Ps(L(),f,d);let p=o-1,m=Math.min(p+s,u),h=l.slice(p,m),g=[],_=0,ee=!1;for(let e=0;e<h.length;e++){let t=`${o+e}: ${Ts(h[e]??``)}`,n=Buffer.byteLength(t,`utf8`)+1;if(_+n>51200&&g.length>0){ee=!0;break}g.push(t),_+=n}let te=g.join(`
|
|
72
|
+
`),ne=o+g.length-1;return ne<u||ee?{content:te,nextOffset:ne+1,path:a,totalLines:u,truncated:!0}:{content:te,path:a,totalLines:u,truncated:!1}}const nc={additionalProperties:!1,properties:{filePath:{description:`The absolute path to the file to read.`,type:`string`},limit:{description:`Maximum number of lines to return. Defaults to 2000.`,minimum:1,type:`integer`},offset:{description:`1-based line number to start from. Defaults to 1.`,minimum:1,type:`integer`}},required:[`filePath`],type:`object`};async function rc(e){return tc(e)}const ic={description:[`Read a file from the local filesystem. If the path does not exist, an error is returned.`,``,`Usage:`,`- The filePath parameter should be an absolute path.`,`- By default, this tool returns up to 2000 lines from the start of the file.`,`- The offset parameter is the line number to start from (1-indexed).`,`- To read later sections, call this tool again with a larger offset.`,`- Use the grep tool to find specific content in large files or files with long lines.`,`- If you are unsure of the correct file path, use the glob tool to look up filenames by glob pattern.`,'- Contents are returned with each line prefixed by its line number as `<line>: <content>`. For example, if a file has contents "foo\\n", you will receive "1: foo\\n".',`- Any line longer than 2000 characters is truncated.`,`- Call this tool in parallel when you know there are multiple files you want to read.`,`- Avoid tiny repeated slices (30 line chunks). If you need more context, read a larger window.`].join(`
|
|
73
|
+
`),execute:rc,inputSchema:nc,logicalPath:`ash:framework/read-file`,name:`read_file`,onCompact({ctx:e}){return Fs(e),{}},sourceId:`ash:read-file-tool`,sourceKind:`module`},ac=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;function oc(e){if(e.length===0||e.trim()!==e||e.startsWith(`.`)||e.includes(`/`)||e.includes(`\\`)||e.includes(`..`)||/^[A-Za-z]:/.test(e))throw Error(`Expected skill id to be a non-empty safe path segment without whitespace, separators, "." prefix, or "..".`)}async function sc(e,t){oc(t);let n=await cc(e),r=lc(t,`SKILL.md`),i=await n.readTextFile({path:r});if(i===null)throw Error(`No skill named "${t}" at ${r}.`);return i.replace(ac,``)}async function cc(e){let t=await e.get();if(t===null)throw Error(`The sandbox is not available in the current authored runtime context.`);return t}function lc(e,t){return`${H}/skills/${e}/${t}`}async function uc(e){let t=L().get(gu);if(t===void 0)throw Error(`The load_skill tool requires sandbox access on the runtime context. Ensure the step is running inside a managed runtime context with sandbox support.`);let{skill:n}=e;return await sc(t,n)}const dc={description:[`Load the full instructions for one available skill by name or id.`,`Use this tool when the request clearly matches a listed skill description or when the user explicitly asks for that skill.`,`Loading adds the skill instructions to the current turn.`,`Choose the "skill" value from the Available skills block.`].join(` `),execute:e=>uc(e),inputSchema:{additionalProperties:!1,properties:{skill:{description:`Available skill name or id.`,type:`string`}},required:[`skill`],type:`object`},logicalPath:`ash:framework/load-skill`,name:`load_skill`,retentionPolicy:`keep`,sourceId:`ash:load-skill-tool`,sourceKind:`module`},fc=new I(`ash.todo`);function pc(e){if(e.items.length!==0)return`[Your task list was preserved across context compaction]\n${e.items.map(e=>`- [${e.status===`completed`?`x`:e.status===`cancelled`?`-`:` `}] [${e.priority}] ${e.content}`).join(`
|
|
74
|
+
`)}`}function mc(e){let{items:t}=e,n={cancelled:0,completed:0,in_progress:0,pending:0,total:t.length};for(let e of t)n[e.status]++;return{counts:n,todos:t}}function hc(e){let t=L(),{todos:n}=e??{};if(n!==void 0){let e={items:[...n]};return t.set(fc,e),mc(e)}return mc(t.ensure(fc,()=>({items:[]})))}const gc={description:[`Use this tool to create and manage a structured task list for the current session.`,`This helps you track progress, organize complex tasks, and demonstrate thoroughness.`,``,`When to use:`,`- Complex multistep tasks requiring 3 or more distinct steps`,`- When the user provides multiple tasks or a numbered list`,`- After receiving new instructions, to capture requirements`,`- After completing a task, to mark it complete and add follow-ups`,``,`When NOT to use:`,`- Single, straightforward tasks that need no tracking`,`- Purely conversational or informational requests`,``,`Usage:`,"- Call with `todos` to replace the entire list (full replacement write)","- Call without `todos` to read the current list",`- Both return the full current list with status counts`,`- Mark tasks in_progress when you start, completed when done`,`- Only have ONE task in_progress at a time`].join(`
|
|
75
|
+
`),execute:async e=>hc(e??{}),inputSchema:{additionalProperties:!1,properties:{todos:{description:`The updated todo list. Omit to read the current list without modifying it.`,items:{additionalProperties:!1,properties:{content:{description:`Brief description of the task.`,type:`string`},priority:{description:`Priority level of the task.`,enum:[`high`,`medium`,`low`],type:`string`},status:{description:`Current status of the task.`,enum:[`pending`,`in_progress`,`completed`,`cancelled`],type:`string`}},required:[`content`,`status`,`priority`],type:`object`},type:`array`}},type:`object`},logicalPath:`ash:framework/todo`,name:`todo`,onCompact({ctx:e}){let t=e.get(fc);if(t===void 0||t.items.length===0)return{};let n=pc(t);return n===void 0?{}:{messages:[{content:n,role:`user`}]}},sourceId:`ash:todo-tool`,sourceKind:`module`};function _c(e){let t=new Fe({bulletListMarker:`-`,codeBlockStyle:`fenced`,emDelimiter:`*`,headingStyle:`atx`,hr:`---`});return t.remove([`script`,`style`,`meta`,`link`]),t.turndown(e)}function vc(e){let t=e;return t=t.replace(/<(script|style|noscript)\b[^>]*>[\s\S]*?<\/\1>/gi,``),t=t.replace(/<\/(p|div|br|h[1-6]|li|tr|blockquote|pre|section|article|header|footer|nav|aside|main|figure|figcaption|details|summary)>/gi,`
|
|
76
|
+
`),t=t.replace(/<br\s*\/?>/gi,`
|
|
77
|
+
`),t=t.replace(/<[^>]+>/g,``),t=xc(t),t=t.split(`
|
|
78
|
+
`).map(e=>e.replace(/[ \t]+/g,` `).trim()).join(`
|
|
79
|
+
`).replace(/\n{3,}/g,`
|
|
80
|
+
|
|
81
|
+
`).trim(),t}const yc={"&":`&`,">":`>`,"<":`<`," ":` `,""":`"`,"'":`'`,"'":`'`,"/":`/`},bc=new RegExp(Object.keys(yc).join(`|`),`gi`);function xc(e){return e.replace(bc,e=>yc[e.toLowerCase()]??e)}const Sc=5*1024*1024;async function Cc(e){let{url:t,format:n=`markdown`,timeout:r}=e;if(!t.startsWith(`http://`)&&!t.startsWith(`https://`))throw Error(`URL must start with http:// or https://`);let i=Math.min(r===void 0?3e4:r*1e3,12e4),a=AbortSignal.timeout(i),o=wc(n),s=await fetch(t,{headers:o,signal:a}),c=s.status===403&&s.headers.get(`cf-mitigated`)===`challenge`?await fetch(t,{headers:{...o,"User-Agent":O},signal:a}):s;if(!c.ok)throw Error(`Request failed with status code: ${c.status}`);let l=c.headers.get(`content-length`);if(l!==null&&parseInt(l,10)>Sc)throw Error(`Response too large (exceeds 5 MB limit).`);let u=await c.arrayBuffer();if(u.byteLength>Sc)throw Error(`Response too large (exceeds 5 MB limit).`);let d=c.headers.get(`content-type`)??``,f=d.includes(`text/html`),p=new TextDecoder().decode(u),m;m=n===`markdown`&&f?_c(p):n===`text`&&f?vc(p):p;let{output:h,truncated:g}=Ss(m);return{content:h,contentType:d,truncated:g,url:t}}function wc(e){let t;return t=e===`markdown`?`text/markdown;q=1.0, text/x-markdown;q=0.9, text/plain;q=0.8, text/html;q=0.7, */*;q=0.1`:e===`text`?`text/plain;q=1.0, text/markdown;q=0.9, text/html;q=0.8, */*;q=0.1`:`text/html;q=1.0, application/xhtml+xml;q=0.9, text/plain;q=0.8, text/markdown;q=0.7, */*;q=0.1`,{Accept:t,"Accept-Language":`en-US,en;q=0.9`,"User-Agent":`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36`}}async function Tc(e){return Cc(e)}const Ec={description:[`Fetch a webpage and return its content in the requested format. Use this to retrieve and analyze content from URLs.`,``,`Usage notes:`,`- The URL must be a fully-formed valid URL starting with http:// or https://`,`- HTML responses are automatically converted to markdown or plain text based on the requested format`,`- Format options: "markdown" (default), "text", or "html"`,`- Default timeout is 30 seconds (max 120 seconds)`,`- Maximum response size is 5 MB; content is further capped at the shared tool-output budget (50 KB / 2000 lines)`,`- This tool is read-only and does not modify any files`].join(`
|
|
82
|
+
`),execute:Tc,inputSchema:{additionalProperties:!1,properties:{format:{description:`The format to return the content in (text, markdown, or html). HTML responses are automatically converted to the requested format. Defaults to "markdown".`,enum:[`markdown`,`text`,`html`],type:`string`},timeout:{description:`Optional timeout in seconds. Defaults to 30, max 120.`,type:`number`},url:{description:`The fully-formed URL to fetch content from. Must start with http:// or https://.`,type:`string`}},required:[`url`],type:`object`},logicalPath:`ash:framework/web-fetch`,name:`web_fetch`,sourceId:`ash:web-fetch-tool`,sourceKind:`module`},Dc={description:`Search the web for real-time information. Use this to find up-to-date information about current events, recent developments, or topics that may have changed since the knowledge cutoff.`,inputSchema:null,logicalPath:`ash:framework/web-search`,name:`web_search`,sourceId:`ash:web-search-tool`,sourceKind:`module`};async function Oc(e){let{filePath:t,content:n}=e;K(t);let r=await G(),i=L(),a=q(t),o=Ms(a),s=await r.readTextFile({path:t});if(s===null)return await r.writeTextFile({content:n,path:t}),Ps(i,o,Ns({content:n,filePath:a})),{existed:!1,path:a};let c=i.ensure(js,()=>({byTarget:{}})).byTarget[o];if(c===void 0)throw Error(`You must read file ${t} before overwriting it. Use the read_file tool first.`);let l=Ns({content:s,filePath:a});if(l.contentHash!==c.contentHash||l.byteLength!==c.byteLength)throw Error(`File ${t} has been modified since it was last read. Please read the file again before modifying it.`);return await r.writeTextFile({content:n,path:t}),Ps(i,o,Ns({content:n,filePath:a})),{existed:!0,path:a}}const kc={additionalProperties:!1,properties:{content:{description:`Complete replacement file contents.`,type:`string`},filePath:{description:`The absolute path to the file to write (must be absolute, not relative).`,type:`string`}},required:[`filePath`,`content`],type:`object`};async function Ac(e){return Oc(e)}const jc=[xs,As,Ks,ec,ic,{description:[`Writes a file to the local filesystem.`,``,`Usage:`,`- This tool will overwrite the existing file if there is one at the provided path.`,`- If this is an existing file, you MUST use the read_file tool first to read the file's contents. This tool will fail if you did not read the file first.`,`- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.`,`- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.`,`- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`].join(`
|
|
83
|
+
`),execute:Ac,inputSchema:kc,logicalPath:`ash:framework/write-file`,name:`write_file`,sourceId:`ash:write-file-tool`,sourceKind:`module`},gc,Ec,Dc,dc,U],Mc=new Map([[U,e=>e.hasConnections]]);function Nc(e){return jc.filter(t=>{let n=Mc.get(t);return n===void 0||n(e)})}function Pc(){return new Set(jc.map(e=>e.name))}function Fc(e){let t=[],n=[],r=new Map,i=[];for(let a of e){let e=a.lifecycle.session;e!==void 0&&t.push({slug:a.slug,handler:e});let o=a.lifecycle.turn;o!==void 0&&n.push({slug:a.slug,handler:o});for(let[e,t]of Object.entries(a.events)){let n={slug:a.slug,handler:t,eventType:e};if(e===`*`)i.push(n);else{let t=r.get(e)??[];t.push(n),r.set(e,t)}}}return{session:t,turn:n,streamEventsByType:r,streamEventsWildcard:i}}var Y=class extends Error{logicalPath;sourceId;constructor(e,t={}){super(e),this.name=`ResolveAgentError`,t.logicalPath!==void 0&&(this.logicalPath=t.logicalPath),t.sourceId!==void 0&&(this.sourceId=t.sourceId)}};function Ic(e){return{exportName:e.exportName,logicalPath:e.logicalPath,sourceId:e.sourceId,sourceKind:`module`}}async function X(e){let n=e.nodeId??`__root__`,r=e.moduleMap.nodes[n]?.modules[e.definition.sourceId];if(r===void 0)throw new Y(`Missing compiled module namespace for ${e.kindLabel} source "${e.definition.sourceId}" in node "${n}".`,{logicalPath:e.definition.logicalPath,sourceId:e.definition.sourceId});return await a(t(o(r,`Missing compiled module namespace for ${e.kindLabel} source "${e.definition.sourceId}" in node "${n}".`),{exportName:e.definition.exportName,logicalPath:e.definition.logicalPath}))}async function Lc(e,t,n){try{let r=Zn(await X({definition:e,kindLabel:`channel`,moduleMap:t,nodeId:n}),`Expected the channel export "${e.exportName??`default`}" from "${e.logicalPath}" to match the public Ash shape.`),i=Ic({exportName:e.exportName,logicalPath:e.logicalPath,sourceId:e.sourceId}),a=r.routes.find(t=>t.method.toUpperCase()===e.method.toUpperCase()&&t.path===e.urlPath),o=r.adapter;return o&&o.kind!==`http`&&(o.kind=`channel:${e.name}`),{name:e.name,method:e.method,urlPath:e.urlPath,fetch:async(e,t)=>a?a.handler(e,t):Response.json({error:`No matching route handler.`,ok:!1},{status:404}),handler:a?.handler,receive:r.receive,definition:r,adapter:o,...i}}catch(t){throw t instanceof Y?t:new Y(`Failed to attach the channel definition from "${e.logicalPath}": ${d(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}async function Rc(e,t,n){try{let r=o(await X({definition:e,kindLabel:`connection`,moduleMap:t,nodeId:n}),`Expected the connection export "${e.exportName??`default`}" from "${e.logicalPath}" to return an object.`);Lr(`connection:${r.url}`,{kind:`connection`,name:e.connectionName});let i=r.auth!==void 0,a=r.headers!==void 0,s={connectionName:e.connectionName,description:e.description,exportName:e.exportName,logicalPath:e.logicalPath,sourceId:e.sourceId,sourceKind:`module`,url:e.url};if(i)try{s.authorization=nr(r.auth,`Connection "${e.connectionName}" at "${e.logicalPath}":`)}catch(t){throw new Y(d(t),{logicalPath:e.logicalPath,sourceId:e.sourceId})}return a&&(s.headers=r.headers),r.tools!==void 0&&(s.tools=r.tools),typeof r.approval==`function`&&(s.approval=r.approval),s}catch(t){throw t instanceof Y?t:new Y(`Failed to resolve connection "${e.connectionName}" from "${e.logicalPath}": ${d(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}async function zc(e,t,n){try{let r=o(await X({definition:e,kindLabel:`hook`,moduleMap:t,nodeId:n}),Z(e,`to return an object`)),a={},s={},c=r.lifecycle;if(c!==void 0){let t=o(c,Z(e,"to expose `lifecycle` as an object"));for(let n of[`session`,`turn`]){let r=t[n];r!==void 0&&(a[n]=i(r,Z(e,`to provide a function for "lifecycle.${n}"`)))}}let l=r.events;if(l!==void 0){let t=o(l,Z(e,"to expose `events` as an object"));for(let[n,r]of Object.entries(t))r!==void 0&&(s[n]=i(r,Z(e,`to provide a function for "events.${n}"`)))}return{events:s,exportName:e.exportName,lifecycle:a,logicalPath:e.logicalPath,slug:e.slug,sourceId:e.sourceId,sourceKind:`module`}}catch(t){throw t instanceof Y?t:new Y(`Failed to attach hook handlers from "${e.logicalPath}": ${d(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}function Z(e,t){return`Expected the hook export "${e.exportName??`default`}" from "${e.logicalPath}" ${t}.`}var Bc=class e extends Error{backendName;templateKey;constructor(e){super(`Sandbox template "${e.templateKey}" is not provisioned for backend "${e.backendName}". Run \`ash build\` or invoke \`prewarmAppSandboxes()\` before serving traffic.`),this.name=`SandboxTemplateNotProvisionedError`,this.backendName=e.backendName,this.templateKey=e.templateKey}static is(t){return t instanceof e}};async function Vc(e){let t=[];for await(let n of e)t.push(n);return Buffer.concat(t)}function Hc(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}function Q(e){return{id:e.id,resolvePath(t){return e.resolvePath(t)},async runCommand(t){return await e.runCommand(t)},async readFile(t){return await e.readFile({abortSignal:t.abortSignal,path:e.resolvePath(t.path)})},async readBinaryFile(t){let n=await e.readFile({abortSignal:t.abortSignal,path:e.resolvePath(t.path)});return n===null?null:await Vc(n)},async readTextFile(t){Uc(t);let n=await e.readFile({abortSignal:t.abortSignal,path:e.resolvePath(t.path)});return n===null?null:Gc(Kc(await Vc(n),t.encoding??`utf-8`),t)},async writeFile(t){await e.writeFile({abortSignal:t.abortSignal,content:t.content,path:e.resolvePath(t.path)})},async writeBinaryFile(t){await e.writeFile({abortSignal:t.abortSignal,content:Hc(t.content),path:e.resolvePath(t.path)})},async writeTextFile(t){let n=qc(t.content,t.encoding??`utf-8`);await e.writeFile({abortSignal:t.abortSignal,content:Hc(n),path:e.resolvePath(t.path)})}}}function Uc(e){let{startLine:t,endLine:n}=e;if(t!==void 0&&(!Number.isInteger(t)||t<1))throw Error(`startLine must be a positive integer (1-based).`);if(n!==void 0&&(!Number.isInteger(n)||n<1))throw Error(`endLine must be a positive integer (1-based).`);if(t!==void 0&&n!==void 0&&t>n)throw Error(`startLine must not be greater than endLine.`)}function Wc(e){let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`\r`?r+1<e.length&&e[r+1]===`
|
|
84
|
+
`?(t.push(e.slice(n,r+2)),n=r+2,r++):(t.push(e.slice(n,r+1)),n=r+1):e[r]===`
|
|
85
|
+
`&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}function Gc(e,t){if(t.startLine===void 0&&t.endLine===void 0)return e;let n=Wc(e),r=n.length,i=t.startLine??1,a=Math.min(t.endLine??r,r);return i>r?``:n.slice(i-1,a).join(``)}function Kc(e,t){return t===`utf-8`||t===`utf8`?new TextDecoder(`utf-8`,{fatal:!0}).decode(e):Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(t)}function qc(e,t){return t===`utf-8`||t===`utf8`?new TextEncoder().encode(e):Buffer.from(e,t)}function Jc(e={}){return{name:`local`,async prewarm(e){let t=el(ku(e.runtimeContext.appRoot),e.templateKey);if(await cl(t))return;let n=await Yc({sessionKey:e.templateKey,snapshotPath:t}),r=Q(Zc(n));try{e.bootstrap!==void 0&&await e.bootstrap({use:async()=>r});for(let t of e.seedFiles)typeof t.content==`string`?await r.writeTextFile({content:t.content,path:t.path}):await r.writeBinaryFile({content:t.content,path:t.path});if(await n.captureSnapshot()===null)throw Error(`Failed to capture local sandbox template state for "${e.templateKey}".`)}finally{await n.dispose()}},async create(e){let t=ku(e.runtimeContext.appRoot),n=await ol(el(t,e.templateKey));if(n===null)throw new Bc({backendName:`local`,templateKey:e.templateKey});let r=ll(e.existingMetadata)??tl(t,e.sessionKey);return await cl(r)||await sl(r,n),Xc(await Yc({sessionKey:e.sessionKey,snapshotPath:r}))}}}async function Yc(e){let{Bash:t,InMemoryFs:n}=await import(`#compiled/just-bash/index.js`),r=await ol(e.snapshotPath),i=new n(nl(r));await rl(i),await il(i,r?.entries??[]);let a=new t({cwd:H,env:r?.env,fs:i,network:{dangerouslyAllowFullInternetAccess:!0}});return{async captureSnapshot(){let t=await al({filesystem:i,sandbox:a});return await sl(e.snapshotPath,t),{snapshotPath:e.snapshotPath}},async dispose(){await a.dispose?.()},async executeCommand(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=e.workingDirectory===void 0?e.command:`( cd ${J(e.workingDirectory)} && ${e.command} )`,n=a.exec(t),r=e.abortSignal?await Qc(n,e.abortSignal):await n;return{exitCode:r.exitCode,stderr:r.stderr,stdout:r.stdout}},async readFileBytes(e){let t;try{t=await i.readFileBuffer(e)}catch{return null}return Buffer.from(t)},async readFileText(e){let t;try{t=await i.readFileBuffer(e)}catch{return null}return new TextDecoder(`utf-8`,{fatal:!0}).decode(t)},sessionKey:e.sessionKey,snapshotPath:e.snapshotPath,async writeFiles(e){for(let t of e){let e=y(t.path);await i.mkdir(e,{recursive:!0}),await i.writeFile(t.path,t.content)}}}}function Xc(e){let t=Q(Zc(e));return{session:t,useSessionFn:async()=>t,async captureState(){return{backendName:`local`,metadata:await e.captureSnapshot()??{},sessionKey:e.sessionKey}},async dispose(){await e.dispose()}}}function Zc(e){return{id:e.sessionKey,resolvePath:$c,async runCommand(t){return await e.executeCommand(t)},async readFile(t){let n=await e.readFileBytes(t.path);return n===null?null:Hc(n)},async writeFile(t){let n=await Vc(t.content);await e.writeFiles([{content:n,path:t.path}])}}}async function Qc(e,t){return await new Promise((n,r)=>{let i=()=>{r(new DOMException(`The operation was aborted.`,`AbortError`))};if(t.aborted){i();return}t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}function $c(e){return e.startsWith(`/`)?e:`${H}/${e}`}function el(e,t){return b(e,`local`,`templates`,`${t}.json`)}function tl(e,t){return b(e,`local`,`sessions`,`${t}.json`)}function nl(e){let t={};for(let n of e?.entries??[])n.kind===`file`&&(t[n.path]=Buffer.from(n.contentBase64,`base64`));return t}async function rl(e){await e.mkdir(H,{recursive:!0})}async function il(e,t){let n=t.filter(e=>e.kind===`directory`).map(e=>e.path).sort((e,t)=>e.localeCompare(t));for(let t of n)t!==`/workspace`&&await e.mkdir(t,{recursive:!0})}async function al(e){let t=[],n=e.filesystem.getAllPaths().sort((e,t)=>e.localeCompare(t));for(let r of n){let n=await e.filesystem.stat(r);if(n.isSymbolicLink)continue;if(n.isDirectory){t.push({kind:`directory`,path:r});continue}if(!n.isFile)continue;let i=await e.filesystem.readFileBuffer(r);t.push({contentBase64:Buffer.from(i).toString(`base64`),kind:`file`,path:r})}return{entries:t,env:{...e.sandbox.getEnv()},version:1}}async function ol(e){if(!await cl(e))return null;let t=JSON.parse(await he(e,`utf8`));return t.version===1?t:null}async function sl(e,t){await S(y(e),{recursive:!0}),await C(e,`${JSON.stringify(t,null,2)}\n`)}async function cl(e){try{return await pe(e),!0}catch{return!1}}function ll(e){let t=e?.snapshotPath;return typeof t==`string`?t:void 0}function ul(e){return Jc({createOptions:e})}function dl(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n={timeout:kl,...e.createOptions},r=new Map;return{name:`vercel`,async create(e){let i=Tl(n.tags,e.tags),a;try{a=await fl({loadSandboxModule:t,prewarmedTemplates:r,templateKey:e.templateKey})}catch(t){throw Bc.is(t)?t:Error(`Failed to read sandbox template "${e.templateKey}": ${Ol(t)}`,{cause:t})}let o;try{o=await ml({createOptions:n,existingMetadata:e.existingMetadata,sandboxModule:await t(),sessionKey:e.sessionKey,snapshotId:a.snapshotId,tags:i})}catch(t){throw Error(`Failed to create sandbox session "${e.sessionKey}": ${Ol(t)}`,{cause:t})}return hl(o,e.sessionKey)},async prewarm(e){let i;try{i=await pl({bootstrap:e.bootstrap,createOptions:n,loadSandboxModule:t,seedFiles:e.seedFiles,templateKey:e.templateKey})}catch(t){throw Error(`Failed to prewarm Vercel sandbox template "${e.templateKey}": ${Ol(t)}. Run \`vercel login\` and \`vercel link\` so the SDK can authenticate, or set VERCEL_TOKEN.`,{cause:t})}r.set(e.templateKey,i)}}}async function fl(e){let t=e.prewarmedTemplates.get(e.templateKey);if(t!==void 0)return t;let n=await xl(await e.loadSandboxModule(),e.templateKey);if(n===null||typeof n.currentSnapshotId!=`string`)throw new Bc({backendName:`vercel`,templateKey:e.templateKey});return{sandboxName:n.name,snapshotId:n.currentSnapshotId,templateKey:e.templateKey}}async function pl(e){let t=await e.loadSandboxModule(),n=await xl(t,e.templateKey),r=Tl(e.createOptions.tags,e.tags);if(n===null){let i={...e.createOptions,name:e.templateKey,persistent:!1};r!==void 0&&(i.tags=r),n=await t.Sandbox.create(i)}else await El(n,r);let i=Cl(e.createOptions);if(typeof n.currentSnapshotId==`string`&&n.currentSnapshotId.length>0&&n.currentSnapshotId!==i)return{sandboxName:n.name,snapshotId:n.currentSnapshotId,templateKey:e.templateKey};await vl(n,e.createOptions);let a=Q(gl(n,e.templateKey));e.bootstrap!==void 0&&await e.bootstrap({use:async e=>(e!==void 0&&await n.update(e),a)});for(let t of e.seedFiles)typeof t.content==`string`?await a.writeTextFile({content:t.content,path:t.path}):await a.writeBinaryFile({content:t.content,path:t.path});let o=await n.snapshot();return{sandboxName:n.name,snapshotId:o.snapshotId,templateKey:e.templateKey}}async function ml(e){let t=wl(e.existingMetadata)??e.sessionKey,n=await xl(e.sandboxModule,t);if(n!==null)return await El(n,e.tags),n;let{runtime:r,source:i,...a}=e.createOptions,o={...a,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}};return e.tags!==void 0&&(o.tags=e.tags),await e.sandboxModule.Sandbox.create(o)}function hl(e,t){return{session:Q(gl(e,t)),useSessionFn:async n=>(n!==void 0&&await e.update(n),Q(gl(e,t))),async captureState(){return{backendName:`vercel`,metadata:{sandboxName:e.name},sessionKey:t}},async dispose(){}}}function gl(e,t){return{id:t,resolvePath:_l,async runCommand(t){let n=await e.runCommand({args:[`-lc`,t.command],cmd:`bash`,cwd:t.workingDirectory??`/workspace`,signal:t.abortSignal}),[r,i]=await Promise.all([n.stdout(),n.stderr()]);return{exitCode:n.exitCode,stderr:i,stdout:r}},async readFile(t){return await e.readFile({path:t.path})??null},async writeFile(t){let n=await Vc(t.content);await e.writeFiles([{content:n,path:t.path}])}}}function _l(e){return e.startsWith(`/`)?e:`${H}/${e}`}async function vl(e,t){await yl(e,{failureMessage:`Failed to initialize Vercel sandbox workspace.`,script:`mkdir -p ${H} && chown ${bl}:${bl} ${H}`}),t.networkPolicy!==`deny-all`&&await yl(e,{failureMessage:`Failed to install ripgrep in Vercel sandbox.`,script:`command -v rg >/dev/null 2>&1 || { dnf install -y spal-release && dnf install -y ripgrep; }`})}async function yl(e,t){let n=await e.runCommand({args:[`-lc`,t.script],cmd:`bash`,sudo:!0});if(n.exitCode!==0){let e=await n.stderr();throw Error(`${t.failureMessage} ${e}`.trim())}}const bl=`vercel-sandbox`;async function xl(e,t){try{return await e.Sandbox.get({name:t})}catch(e){if(Sl(e))return null;throw Error(`Failed to look up Vercel sandbox "${t}": ${Ol(e)}`,{cause:e})}}function Sl(e){return e instanceof Error?(e.response?.status??e.cause?.response?.status)===404:!1}function Cl(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}function wl(e){let t=e?.sandboxName;return typeof t==`string`?t:void 0}function Tl(e,t){let n={};if(e!==void 0)for(let[t,r]of Object.entries(e))n[t]=r;if(t!==void 0)for(let[e,r]of Object.entries(t))n[e]=r;let r=Object.keys(n).length;if(r!==0){if(r>Al)throw Error(`Vercel Sandbox supports at most ${Al} tags. Ash reserves "agent", "channel", and "sessionId"; remove or consolidate custom tags passed to vercelBackend().`);return n}}async function El(e,t){t===void 0||Dl(e.tags,t)||await e.update({tags:t})}function Dl(e,t){let n=e??{},r=Object.entries(n),i=Object.entries(t);return r.length===i.length?i.every(([e,t])=>n[e]===t):!1}function Ol(e){return e instanceof Error?e.message:String(e)}const kl=1800*1e3,Al=5;function jl(e){return dl({createOptions:e})}function Ml(e){return gr(()=>process.env.VERCEL?jl(e?.vercel):ul(e?.local))}async function Nl(e,t,n){try{let r=o(await X({definition:e,kindLabel:`sandbox`,moduleMap:t,nodeId:n}),`Expected the sandbox export "${e.exportName??`default`}" from "${e.logicalPath}" to return an object.`);return{backend:Pl(r.backend,e.logicalPath),bootstrap:r.bootstrap,description:e.description,exportName:e.exportName,logicalPath:e.logicalPath,onSession:r.onSession,sourceId:e.sourceId,sourceKind:`module`}}catch(t){throw t instanceof Y?t:new Y(`Failed to attach the sandbox lifecycle handlers from "${e.logicalPath}": ${d(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}function Pl(e,t){if(e===void 0)return Ml();if(typeof e==`function`)return gr(e);if(typeof e!=`object`||!e)throw new Y(`Sandbox "${t}" exposed a non-object "backend" field. Use vercelBackend(), localBackend(), another factory that returns a SandboxBackend value, or a zero-arg callback returning one.`,{logicalPath:t});let n=e;if(typeof n.name!=`string`||n.name.length===0)throw new Y(`Sandbox "${t}" backend is missing a non-empty string "name" identifier.`,{logicalPath:t});if(typeof n.create!=`function`)throw new Y(`Sandbox "${t}" backend is missing a "create" function.`,{logicalPath:t});return n}async function Fl(e,t,n){try{let r=o(await X({definition:e,kindLabel:`tool`,moduleMap:t,nodeId:n}),$(e,`to return an object`));Lr(`tool:${r.description}`,{kind:`tool`,name:e.name});let a=i(r.execute,$(e,`to provide an execute function`));return{description:e.description,execute:a,exportName:e.exportName,inputSchema:e.inputSchema,logicalPath:e.logicalPath,name:e.name,sourceId:e.sourceId,sourceKind:`module`,...Il(r,e)}}catch(t){throw t instanceof Y?t:new Y(`Failed to attach the tool execute function from "${e.logicalPath}": ${d(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}function Il(e,t){let n={};e.onCompact!==void 0&&(n.onCompact=i(e.onCompact,$(t,`to provide an onCompact function`))),e.needsApproval!==void 0&&(n.needsApproval=i(e.needsApproval,$(t,`to provide a needsApproval function`)));let r=Ll(e,t);return r!==void 0&&(n.retentionPolicy=r),e.toModelOutput!==void 0&&(n.toModelOutput=i(e.toModelOutput,$(t,`to provide a toModelOutput function`))),e.inputSchema!==void 0&&Rl(e.inputSchema)&&(n.inputStandardSchema=e.inputSchema),n}function Ll(e,t){let n=e.retentionPolicy;if(n!==void 0){if(n===`auto`||n===`keep`||typeof n==`function`)return n;throw new Y($(t,`to set retentionPolicy to "auto", "keep", or a function`),{logicalPath:t.logicalPath,sourceId:t.sourceId})}}function $(e,t){return`Expected the tool export "${e.exportName??`default`}" from "${e.logicalPath}" ${t}.`}function Rl(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}async function zl(e){let t=e.manifest.skills.map(e=>({...e,metadata:e.metadata===void 0?void 0:{...e.metadata}})),n=[],r=[];for(let t of e.manifest.channels){if(t.kind===`disabled`){r.push(t.name);continue}n.push(await Lc(t,e.moduleMap,e.nodeId))}let i=await Promise.all(e.manifest.tools.map(t=>Fl(t,e.moduleMap,e.nodeId))),a=await Promise.all(e.manifest.hooks.map(t=>zc(t,e.moduleMap,e.nodeId))),o=await Promise.all(e.manifest.connections.map(t=>Rc(t,e.moduleMap,e.nodeId))),s=e.manifest.sandbox===null?null:await Nl(e.manifest.sandbox,e.moduleMap,e.nodeId),c=Bl(e.manifest.instructions),l=e.manifest.workspaceResourceRoot,u={channels:n,config:Vl(e.manifest),connections:o,disabledFrameworkChannels:r,disabledFrameworkTools:[...e.manifest.disabledFrameworkTools],hooks:a,metadata:{agentRoot:e.manifest.agentRoot,appRoot:e.manifest.appRoot,diagnosticsSummary:e.manifest.diagnosticsSummary},sandbox:s,workspaceResourceRoot:l,skills:t,tools:i,workspaceSpec:{rootEntries:[...l.rootEntries]}};return c===void 0?u:{...u,instructions:c}}function Bl(e){if(e!==void 0)return{name:e.name,logicalPath:e.logicalPath,markdown:e.markdown,sourceId:e.sourceId,sourceKind:e.sourceKind}}function Vl(e){let t={metadata:{...e.config.metadata},model:e.config.model.source===void 0?{id:e.config.model.id,contextWindowTokens:e.config.model.contextWindowTokens,providerOptions:e.config.model.providerOptions}:{contextWindowTokens:e.config.model.contextWindowTokens,id:e.config.model.id,providerOptions:e.config.model.providerOptions,source:{exportName:e.config.model.source.exportName,sourceKind:`module`,logicalPath:e.config.model.source.logicalPath,sourceId:e.config.model.source.sourceId}},name:e.config.name};if(e.config.compaction!==void 0){let n={};e.config.compaction.model!==void 0&&(n.model=e.config.compaction.model.source===void 0?{contextWindowTokens:e.config.compaction.model.contextWindowTokens,id:e.config.compaction.model.id,providerOptions:e.config.compaction.model.providerOptions}:{contextWindowTokens:e.config.compaction.model.contextWindowTokens,id:e.config.compaction.model.id,providerOptions:e.config.compaction.model.providerOptions,source:{exportName:e.config.compaction.model.source.exportName,sourceKind:`module`,logicalPath:e.config.compaction.model.source.logicalPath,sourceId:e.config.compaction.model.source.sourceId}}),e.config.compaction.thresholdPercent!==void 0&&(n.thresholdPercent=e.config.compaction.thresholdPercent),t.compaction=n}return e.config.source!==void 0&&(t.source=Ic(e.config.source)),t}function Hl(e){return{sandbox:{definition:e.authoredSandbox??Ul(),workspaceResourceRoot:e.workspaceResourceRoot}}}function Ul(){return{backend:Ml(),logicalPath:`ash:framework/default-sandbox`,sourceId:`ash:default-sandbox`,sourceKind:`module`}}const Wl=`load_skill`,Gl=Object.freeze({type:`object`,properties:Object.freeze({message:Object.freeze({type:`string`,description:`The message to send to the subagent. Provide all context the subagent needs to complete the task; the subagent does not see the parent's history.`})}),required:Object.freeze([`message`]),additionalProperties:!1});function Kl(e){let t=[],n=new Pi(`subagent`,e.reservedToolNames??[]),r=new Map;for(let i of e.subagents){let e={logicalPath:i.logicalPath,sourceId:i.sourceId};if(r.has(i.nodeId))throw new z(`subagent`,`Found multiple runtime subagents mapped to node id "${i.nodeId}".`,{...e,entryName:i.name});let a=ql(i),o={definition:i,prepared:a};n.register(i.name,o,{location:e,duplicateMessage:`Found multiple subagents named "${i.name}". Subagent names must be unique at runtime.`,reservedMessage:`Subagent "${i.name}" collides with another runtime-visible tool name.`}),t.push(a),r.set(i.nodeId,o)}return{preparedTools:t,subagentsByName:n.asMap(),subagentsByNodeId:r}}function ql(e){return{description:e.description,inputSchema:Gl,kind:e.kind,logicalPath:e.logicalPath,name:e.name,nodeId:e.nodeId,sourceId:e.sourceId}}async function Jl(e,t={}){let n=[],r=new Pi(`tool`,t.reservedToolNames??[]);for(let t of e.tools){let e=await Yl(t);r.register(t.name,{definition:t,prepared:e},{location:{logicalPath:t.logicalPath,sourceId:t.sourceId},duplicateMessage:`Found multiple authored tools named "${t.name}". Tool names must be unique at runtime.`,reservedMessage:`Tool "${t.name}" collides with another runtime-visible tool name.`}),n.push(e)}return{preparedTools:n,toolsByName:r.asMap()}}async function Yl(e){return{description:e.description,inputSchema:e.inputSchema,kind:`authored-tool`,logicalPath:e.logicalPath,name:e.name,sourceId:e.sourceId}}var Xl=class extends Error{logicalPath;nodeId;sourceId;constructor(e,t={}){super(e),this.name=`ResolveRuntimeAgentGraphError`,t.logicalPath!==void 0&&(this.logicalPath=t.logicalPath),t.nodeId!==void 0&&(this.nodeId=t.nodeId),t.sourceId!==void 0&&(this.sourceId=t.sourceId)}};async function Zl(e){let t=new Map,n=ru(e.manifest),r=new Map(e.manifest.subagents.map(e=>[e.nodeId,e]));return{nodesByNodeId:t,root:await Ql({childNodeIdsByParentNodeId:n,manifest:e.manifest,moduleMap:e.moduleMap,nodeId:j,nodesByNodeId:t,subagentNodesById:r})}}async function Ql(e){let t=iu(e.nodeId);if(e.nodesByNodeId.has(t))throw new Xl(`Found multiple runtime agent nodes for node id "${t}".`,{nodeId:t,sourceId:e.sourceId});let n=await zl({manifest:e.manifest,moduleMap:e.moduleMap,nodeId:e.nodeId}),r=n.connections.length>0,i=Nc({hasConnections:r}),a=r?ou(i,n.connections):i,o=new Set(a.map(e=>e.name)),s=Pc(),c=new Set(n.tools.map(e=>e.name));for(let r of n.disabledFrameworkTools)if(!s.has(r))throw new Xl(`agent/tools/${r}.ts exports disableTool() but "${r}" is not a framework tool. Rename the file to one of: ${[...s].sort().join(`, `)}.`,{nodeId:t,sourceId:e.sourceId});let l=new Set(n.disabledFrameworkTools),u=await Jl({tools:[...a.filter(e=>!c.has(e.name)&&!l.has(e.name)),...n.tools]},{reservedToolNames:o.has(`load_skill`)||c.has(`load_skill`)?[]:[Wl]}),d=new Set(n.channels.map(e=>e.name)),f=gs();for(let r of n.disabledFrameworkChannels)if(!f.has(r))throw new Xl(`agent/channels/${r}.ts exports disableRoute() but "${r}" is not a framework channel. Rename the file to one of: ${[...f].sort().join(`, `)}.`,{nodeId:t,sourceId:e.sourceId});let p=new Set(n.disabledFrameworkChannels),m=[...hs().filter(e=>!d.has(e.name)&&!p.has(e.name)),...n.channels],h=Hl({authoredSandbox:n.sandbox,workspaceResourceRoot:n.workspaceResourceRoot}),g=Kl({reservedToolNames:[Wl,...u.preparedTools.map(e=>e.name)],subagents:await $l({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,manifest:e.manifest,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,parentNodeId:e.nodeId,subagentNodesById:e.subagentNodesById})}),_={agent:n,channels:m,hookRegistry:Fc(n.hooks),nodeId:t,sandboxRegistry:h,sourceId:e.sourceId,subagentRegistry:g,toolRegistry:u,turnAgent:Ka({agent:n,nodeId:t,tools:[...u.preparedTools,...g.preparedTools]})};return e.nodesByNodeId.set(t,_),_}async function $l(e){let t=[],n=e.childNodeIdsByParentNodeId.get(e.parentNodeId)??[];for(let r of n){let n=e.subagentNodesById.get(r);if(n===void 0)throw new Xl(`Missing compiled subagent node "${r}" while resolving runtime subagents.`,{nodeId:iu(e.parentNodeId),sourceId:r});t.push(await eu({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,sourceRef:n,subagentNodesById:e.subagentNodesById}))}for(let n of e.manifest.remoteAgents)t.push(await tu({moduleMap:e.moduleMap,nodeScopeId:e.parentNodeId,sourceRef:n}));return t}async function eu(e){let t={description:e.sourceRef.description,kind:`subagent`,logicalPath:e.sourceRef.logicalPath,name:e.sourceRef.name,nodeId:iu(e.sourceRef.nodeId),sourceId:e.sourceRef.sourceId,sourceKind:`module`};return await Ql({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,manifest:e.sourceRef.agent,moduleMap:e.moduleMap,nodeId:e.sourceRef.nodeId,nodesByNodeId:e.nodesByNodeId,sourceId:e.sourceRef.sourceId,subagentNodesById:e.subagentNodesById}),t}async function tu(e){let t=o(await X({definition:e.sourceRef,kindLabel:`remote agent`,moduleMap:e.moduleMap,nodeId:e.nodeScopeId}),`Expected remote agent source "${e.sourceRef.logicalPath}" to export an object.`),n={description:e.sourceRef.description,kind:`remote`,logicalPath:e.sourceRef.logicalPath,name:e.sourceRef.name,nodeId:iu(e.sourceRef.nodeId),path:e.sourceRef.path,sourceId:e.sourceRef.sourceId,sourceKind:`module`,url:e.sourceRef.url};typeof t.auth==`function`&&(n.auth=t.auth);let r=nu(t.headers);return r!==void 0&&(n.headers=r),n}function nu(e){if(e===void 0)return;if(typeof e==`function`)return e;if(typeof e!=`object`||!e||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}function ru(e){let t=new Map;for(let n of e.subagentEdges){let e=t.get(n.parentNodeId);if(e===void 0){t.set(n.parentNodeId,[n.childNodeId]);continue}e.push(n.childNodeId)}return t}function iu(e){return e===`__root__`?la:e}const au=U.name;function ou(e,t){let n=t.map(e=>e.connectionName).join(`, `);return e.map(e=>e.name===au?{...e,description:`${e.description} Available connections: ${n}.`}:e)}const su=process.env.ASH_DISABLE_AGENT_CACHE===`1`;async function cu(e){let[t,n]=await Promise.all([pa({compiledArtifactsSource:e}),lu(e)]),r=await Zl({manifest:t,moduleMap:n}),i=r.root;return{adapterRegistry:Ri({channels:mu(r)}),compiledArtifactsSource:e,graph:r,hookRegistry:i.hookRegistry,moduleMap:n,resolvedAgent:i.agent,subagentRegistry:i.subagentRegistry,toolRegistry:i.toolRegistry,turnAgent:i.turnAgent}}async function lu(e){return e.kind===`disk`&&e.moduleMapLoaderPath!==void 0?await uu(e):await va({compiledArtifactsSource:e})}async function uu(e){if(e.moduleMapLoaderPath===void 0)throw Error(`Authored-source module map loading requires "moduleMapLoaderPath" in the compiled artifacts source.`);return await(await import(Ce(e.moduleMapLoaderPath).href)).loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:e})}async function du(e){if(su)return cu(e);let t=Qi(),n=Wi(e),r=await oa(e),i=t.bundleCacheKeyBySourceKey.get(n);i!==void 0&&i!==r&&t.bundleCache.delete(i),t.bundleCacheKeyBySourceKey.set(n,r);let a=t.bundleCache.get(r);if(a!==void 0)return a;let o=cu(e).catch(e=>{throw t.bundleCache.delete(r),t.bundleCacheKeyBySourceKey.get(n)===r&&t.bundleCacheKeyBySourceKey.delete(n),e});return t.bundleCache.set(r,o),o}async function fu(e){let t=await du(e.compiledArtifactsSource);if(e.nodeId===void 0)return t;let n=ua(t.graph,e.nodeId);return{adapterRegistry:t.adapterRegistry,compiledArtifactsSource:t.compiledArtifactsSource,graph:{nodesByNodeId:t.graph.nodesByNodeId,root:n},hookRegistry:n.hookRegistry,moduleMap:t.moduleMap,nodeId:e.nodeId,resolvedAgent:n.agent,subagentRegistry:n.subagentRegistry,toolRegistry:n.toolRegistry,turnAgent:n.turnAgent}}function pu(){let e=Qi();e.bundleCache.clear(),e.bundleCacheKeyBySourceKey.clear()}function mu(e){let t=new Map;for(let n of e.nodesByNodeId.values())for(let e of n.channels)t.set(`${e.sourceId}:${e.name}`,e);return[...t.values()]}new I(`ash.channel`,{codec:{serialize(e){return{kind:Ti(e),state:e.state?{...e.state}:{}}},deserialize(e,t){let n=t.get(hu);if(n===void 0)throw Error(`Cannot deserialize "ash.channel" before "ash.bundle". The runtime bundle must be present in context.`);return zi(n.adapterRegistry,e)}}});const hu=new I(`ash.bundle`,{codec:{serialize:e=>({nodeId:e.nodeId,source:e.compiledArtifactsSource}),deserialize:e=>{let{source:t,nodeId:n}=e;return fu({compiledArtifactsSource:t,nodeId:n})}}});new I(`ash.session`);const gu=new I(`ash.sandbox`),_u=`workflowEntry`,vu=At(),yu=new Set([_u,`turnWorkflow`]),bu=vu.name,xu={workflowId:`workflow//${bu}//${_u}`};`${bu}`;function Su(e=process.cwd()){return x(e)}function Cu(e){return _e(`sha256`).update(e).digest(`hex`).slice(0,12)}function wu(){return!!process.env.VERCEL}function Tu(e,t=`all`){let n=b(e,`.ash`,`nitro`);return t===`all`?n:b(n,t)}function Eu(e,t){return b(e,`.ash`,`nitro-output`,t)}function Du(e){let t=b(A(),`.ash`,`workflow-cache`);return Ou(t),b(t,Cu(e))}function Ou(e){if(!w(e))return;let t=At().version,n;try{n=ye(e)}catch{return}for(let r of n){let n=b(e,r),i=b(n,`ash-cache.json`);if(w(i))try{let e=JSON.parse(ve(i,`utf8`));typeof e.ashVersion==`string`&&e.ashVersion!==t&&xe(n,{force:!0,recursive:!0})}catch{}}}function ku(e){return b(e,`.ash`,`sandbox-cache`)}function Au(e){return wu()?b(e,`.vercel`,`output`):b(e,`.output`)}function ju(e){return{appRoot:e,outputDir:Au(e),workflowId:xu.workflowId,workflowBuildDir:Du(e),workflowSourceDir:Et(`src/execution`)}}export{Be as $,Tt as A,ot as B,hn as C,At as D,j as E,ft as F,Xe as G,qe as H,ut as I,Ke as J,Ge as K,lt as L,O as M,st as N,A as O,dt as P,ze as Q,pt as R,bn as S,gn as T,Je as U,it as V,Ye as W,D as X,T as Y,Re as Z,Ui as _,Du as a,Gn as b,Zl as c,H as d,He as et,pa as f,Hi as g,B as h,Eu as i,jt as j,Et as k,gs as l,ra as m,Su as n,yu as o,la as p,Ze as q,Tu as r,pu as s,ju as t,Ve as tt,hs as u,Wi as v,_n as w,Sn as x,oi as y,rt as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./chunk-DSjMdhoD.js";import{c as t,l as n}from"./client-
|
|
1
|
+
import{t as e}from"./chunk-DSjMdhoD.js";import{c as t,l as n}from"./client-ZqNLLMZB.js";var r=e(((e,r)=>{var i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,c=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of o(t))!s.call(e,c)&&c!==n&&i(e,c,{get:()=>t[c],enumerable:!(r=a(t,c))||r.enumerable});return e},u=e=>l(i({},`__esModule`,{value:!0}),e),d={};c(d,{refreshToken:()=>m}),r.exports=u(d);var f=n(),p=t();async function m(e){let t=e?.project,n=e?.team;if(!t&&!n){let e=(0,p.findProjectInfo)();t=e.projectId,n=e.teamId}else if(!t||!n){let e=(0,p.findProjectInfo)();t??=e.projectId,n??=e.teamId}if(!t)throw new f.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let r=(0,p.loadToken)(t);if(!r||(0,p.isExpired)((0,p.getTokenPayload)(r.token),e?.expirationBufferMs)){let i=await(0,p.getVercelToken)({expirationBufferMs:e?.expirationBufferMs});if(r=await(0,p.getVercelOidcToken)(i,t,n),!r)throw new f.VercelOidcTokenError(`Failed to refresh OIDC token`);(0,p.saveToken)(r,t)}process.env.VERCEL_OIDC_TOKEN=r.token}}));export default r();export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"#compiled/zod/index.js";const t=Symbol(`invalid-json-value-candidate`);function n(e){let n=i(e);if(n===t)throw TypeError(`Expected a JSON-serializable value.`);return n}function r(e){let t=n(e);if(!a(t))throw TypeError(`Expected a JSON-serializable object.`);return t}function i(e,n=new WeakSet){if(e===null||typeof e==`boolean`||typeof e==`string`)return e;if(typeof e==`number`)return Number.isFinite(e)?e:t;if(Array.isArray(e)){let r=[];for(let a of e){let e=i(a,n);if(e===t)return t;r.push(e)}return r}if(typeof e!=`object`||e===void 0||!o(e)||n.has(e))return t;n.add(e);let r={};for(let[a,o]of Object.entries(e)){if(o===void 0)continue;let e=i(o,n);if(e===t)return t;r[a]=e}return n.delete(e),r}function a(e){return e!==null&&!Array.isArray(e)&&typeof e==`object`}function o(e){let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}const s=e.unknown().transform((t,r)=>{try{return n(t)}catch(t){return r.addIssue({code:`custom`,message:l(t,`Expected a JSON-serializable value.`)}),e.NEVER}}),c=e.unknown().transform((t,n)=>{try{return r(t)}catch(t){return n.addIssue({code:`custom`,message:l(t,`Expected a JSON-serializable object.`)}),e.NEVER}});function l(e,t){return e instanceof Error?e.message:t}const u=`/ash/v1`,d=`${u}/health`,f=`${u}/info`,p=`${u}/session`,m=`${u}/session/:sessionId`,h=`${u}/session/:sessionId/stream`,g=`${u}/connections/:name/callback/:token`,_=`${u}/callback/:token`;function v(e){return`${u}/session/${encodeURIComponent(e)}/stream`}function y(e){return`${u}/session/${encodeURIComponent(e)}`}function b(e){return`${u}/callback/${encodeURIComponent(e)}`}const x=`x-ash-session-id`,S=`x-ash-stream-format`,C=`x-ash-stream-version`,w=`application/x-ndjson; charset=utf-8`,T=`ndjson`;new TextEncoder;function E(e){return e.type===`session.completed`||e.type===`session.failed`||e.type===`session.waiting`}const D=e.object({callId:e.string(),input:c,kind:e.literal(`tool-call`),toolName:e.string()}).strict(),O=e.object({callId:e.string(),description:e.string(),input:c,kind:e.literal(`subagent-call`),name:e.string(),nodeId:e.string(),subagentName:e.string()}).strict(),k=e.object({callId:e.string(),description:e.string(),input:c,kind:e.literal(`remote-agent-call`),name:e.string(),nodeId:e.string(),remoteAgentName:e.string()}).strict(),A=e.object({callId:e.string(),input:c,kind:e.literal(`load-skill`)}).strict();e.discriminatedUnion(`kind`,[A,k,O,D]),e.object({callId:e.string(),isError:e.boolean().optional(),kind:e.literal(`tool-result`),output:s,toolName:e.string()}).strict(),e.object({callId:e.string(),isError:e.boolean().optional(),kind:e.literal(`subagent-result`),output:s,subagentName:e.string()}).strict(),e.object({callId:e.string(),isError:e.boolean().optional(),kind:e.literal(`load-skill-result`),output:s,name:e.string().optional()}).strict();const j=e.object({description:e.string().describe(`Optional additional context for this option.`).optional(),id:e.string().describe(`Stable identifier for the option.`),label:e.string().describe(`User-facing label for the option.`),style:e.enum([`primary`,`danger`,`default`]).describe(`Visual treatment hint for the option.`).optional()}).strict(),M=e.object({action:D,allowFreeform:e.boolean().describe(`Whether the user may answer with freeform text instead of selecting one of the provided options.`).optional(),display:e.enum([`confirmation`,`select`,`text`]).describe(`Rendering hint — the channel uses this to pick a UX treatment.`).optional(),options:e.array(j).describe(`Selectable answer options to present to the user.`).optional(),prompt:e.string().describe(`The prompt to present to the user.`),requestId:e.string().describe(`Stable identifier for this request.`)}).strict(),N=e.object({optionId:e.string().optional(),requestId:e.string(),text:e.string().optional()}).strict();function P(e){return N.safeParse(e).success}export{b as _,x as a,c as b,E as c,m as d,p as f,u as g,h,T as i,_ as l,f as m,P as n,S as o,d as p,w as r,C as s,M as t,g as u,y as v,r as x,v as y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e,t}from"../../chunks/paths-
|
|
1
|
+
import{b as e,t}from"../../chunks/paths-DnlVBqHu.js";import{n,r,t as i}from"../../chunks/compile-agent-C4OrJW6C.js";import{d as a,f as o,h as s}from"../../chunks/types-BJSR0JNV.js";import{createCliTheme as c,renderCliBanner as l,renderCliSection as u}from"../ui/output.js";async function d(e){let n=await f(e);return{application:t(n?.project.appRoot??e),compiledState:n,messaging:{createSessionRoutePath:o,continueSessionRoutePattern:a,streamRoutePattern:s}}}async function f(t){try{return await n({startPath:t})}catch(t){if(t instanceof i)return t.result;if(t instanceof r||t instanceof e)return null;throw t}}function p(e,t){return`${e} ${t}${e===1?``:`s`}`}function m(e,t){return`${p(e,`error`)}, ${p(t,`warning`)}`}function h(e){switch(e){case`ready`:return`success`;case`failed`:return`danger`;default:return`warning`}}async function g(e,t){let n=await d(t),r=n.compiledState,i=n.application,a=c(),o=[{label:`App Root`,value:i.appRoot}],s=[{label:`Workflow Build`,value:i.workflowBuildDir},{label:`Output`,value:i.outputDir}],f=[];r===null?o.push({label:`Compile`,tone:`warning`,value:`unavailable`}):(o.push({label:`Agent Root`,value:r.project.agentRoot},{label:`Layout`,value:r.project.layout},{label:`Compile`,tone:h(r.metadata.status),value:r.metadata.status},{label:`Diagnostics`,tone:r.metadata.discovery.summary.errors>0?`danger`:r.metadata.discovery.summary.warnings>0?`warning`:`success`,value:m(r.metadata.discovery.summary.errors,r.metadata.discovery.summary.warnings)},{label:`Instructions`,value:r.manifest.instructions?.logicalPath??`none`},{label:`Skills`,value:p(r.manifest.skills.length,`skill`)}),s.unshift({label:`Compiled Manifest`,value:r.paths.compiledManifestPath},{label:`Discovery Manifest`,value:r.paths.discoveryManifestPath},{label:`Diagnostics`,value:r.paths.diagnosticsPath},{label:`Module Map`,value:r.paths.moduleMapPath},{label:`Metadata`,value:r.paths.compileMetadataPath}),f.push(r.manifest.instructions===void 0?{label:`Instructions`,value:`No instructions prompt discovered.`}:{label:`Instructions`,value:r.manifest.instructions.logicalPath})),e.log([l(a,{subtitle:`Resolved application paths and the active message contract.`,title:`Ash Info`}),``,u(a,{rows:o,title:`Application`}),``,u(a,{rows:s,title:`Artifacts`}),...r===null?[]:[``,u(a,{rows:f,title:`Instructions`})],``,u(a,{rows:[{label:`Workflow ID`,value:i.workflowId},{label:`Source Dir`,value:i.workflowSourceDir},{label:`Create`,tone:`info`,value:`POST ${n.messaging.createSessionRoutePath}`},{label:`Continue`,tone:`info`,value:`POST ${n.messaging.continueSessionRoutePattern}`},{label:`Stream`,tone:`info`,value:`GET ${n.messaging.streamRoutePattern}`}],title:`Messaging`})].join(`
|
|
2
2
|
`))}export{g as printApplicationInfo};
|
package/dist/src/cli/dev/repl.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"../../chunks/errors-HYWjHxV6.js";import{
|
|
2
|
-
`)}var A=class{#e;#t;constructor(e){let t=_(e.serverUrl),n={headers:()=>h({serverUrl:e.serverUrl}),host:e.serverUrl};this.#e=new y(t?n:{...n,auth:{bearer:ee}}),this.#t=this.#e.session()}async clear(){this.#t=this.#e.session()}async close(){}getSession(){return this.#t.state}async send(e){let t=await this.#t.send({clientContext:e.clientContext,inputResponses:e.inputResponses,message:e.message});e.onResponseStart?.({sessionId:t.sessionId});let n=[];for await(let r of t)n.push(r),e.onEvent?.(r);return{events:n,sessionId:t.sessionId,session:this.#t.state}}};function j(e){return new A(e)}function M(e){let t=[{label:`Server`,tone:`info`,value:e.serverUrl},{label:`Create`,tone:`info`,value:`POST ${r}`},{label:`Continue`,tone:`info`,value:`POST ${
|
|
3
|
-
`)}function F(e){let t=e.trim();return t.length>0?t:null}function I(e){return e.options?.isSubagent===!0?`subagent`:e.fallback}function L(e){return e.options?.isSubagent===!0?`subagent`:e.fallback}function R(e){return e.options?.sourceLabel===void 0?e.message:`${e.options.sourceLabel}${e.separator??` `}${e.message}`}function z(e,t,n){switch(t.type){case`message.appended`:return{finalized:!1,kind:`message`,line:l(e,{message:t.data.messageSoFar,speaker:n?.sourceLabel??`agent`,tone:L({fallback:`accent`,options:n})})};case`message.completed`:if(t.data.message===null)return;if(t.data.finishReason===`tool-calls`){let r=F(t.data.message);return r===null?void 0:{finalized:!0,kind:`message`,line:u(e,{message:R({message:r,options:n,separator:`: `}),tag:I({fallback:`step`,options:n}),tone:L({fallback:`accent`,options:n})})}}return{finalized:!0,kind:`message`,line:l(e,{message:t.data.message,speaker:n?.sourceLabel??`agent`,tone:L({fallback:`accent`,options:n})})};case`reasoning.appended`:return{finalized:!1,kind:`reasoning`,line:u(e,{message:R({message:t.data.reasoningSoFar,options:n,separator:`: `}),tag:I({fallback:`reasoning`,options:n}),tone:L({fallback:`info`,options:n})})};case`reasoning.completed`:return{finalized:!0,kind:`reasoning`,line:u(e,{message:R({message:t.data.reasoning,options:n,separator:`: `}),tag:I({fallback:`reasoning`,options:n}),tone:L({fallback:`info`,options:n})})};default:return}}function B(e,t,n){let r=z(e,t,n);if(r!==void 0)return r.line;switch(t.type){case`message.received`:return;case`actions.requested`:return u(e,{message:R({message:`${t.type} (${t.data.actions.length} action${t.data.actions.length===1?``:`s`})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`input.requested`:return u(e,{message:R({message:`${t.type} (${t.data.requests.length} request${t.data.requests.length===1?``:`s`})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`info`,options:n})});case`action.result`:return u(e,{message:R({message:`${t.type} (${J(t.data.result)})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`session.waiting`:case`session.completed`:return;case`connection.authorization_required`:return u(e,{message:R({message:`${t.type} (${t.data.connectionName}: ${t.data.description}${Y(t.data.authorization)})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`warning`,options:n})});case`compaction.requested`:return u(e,{message:R({message:`compacting conversation history`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`compaction.completed`:return u(e,{message:R({message:`conversation history compacted`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`step.failed`:case`turn.failed`:case`session.failed`:return;case`subagent.called`:return u(e,{message:R({message:`${t.type} (${t.data.name} -> ${t.data.childSessionId})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`info`,options:n})});case`subagent.started`:return u(e,{message:R({message:`${t.type} (${t.data.subagentName})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`info`,options:n})});case`subagent.event`:return u(e,{message:R({message:`${t.type} (${t.data.subagentName}: ${X(t.data.event)})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`subagent.completed`:return u(e,{message:R({message:`${t.type} (${t.data.subagentName})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`info`,options:n})});default:return}}function V(e){switch(e.type){case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:return`content`;default:return`meta`}}function H(){return{activeLiveContentKind:null,lastPrintedBlockKind:null}}function U(e){let t=e.state;return t.activeLiveContentKind!==null&&(e.terminal.commitLive(),t={activeLiveContentKind:null,lastPrintedBlockKind:`content`}),t.lastPrintedBlockKind!==null&&t.lastPrintedBlockKind!==e.kind&&e.terminal.print(``),e.terminal.print(e.line),{activeLiveContentKind:null,lastPrintedBlockKind:e.kind}}function W(e){let t=z(e.theme,e.event,e.options);if(t!==void 0){let n=e.state;return n.activeLiveContentKind!==null&&n.activeLiveContentKind!==t.kind&&(e.terminal.commitLive(),n={activeLiveContentKind:null,lastPrintedBlockKind:`content`}),n.lastPrintedBlockKind!==null&&n.lastPrintedBlockKind!==`content`&&e.terminal.print(``),e.terminal.updateLive(t.line),t.finalized?(e.terminal.commitLive(),{activeLiveContentKind:null,lastPrintedBlockKind:`content`}):{activeLiveContentKind:t.kind,lastPrintedBlockKind:`content`}}let n=B(e.theme,e.event,e.options);return n===void 0?e.state:U({kind:V(e.event),line:n,state:e.state,terminal:e.terminal})}function G(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}function K(e){return e.length===0}var q=class{#e=new Map;#t;#n;#r;#i;constructor(e){this.#t=e.displayStateRef,this.#n=e.serverUrl,this.#r=e.terminal,this.#i=e.theme}subscribe(e){if(this.#e.has(e.sessionId))return;let t=new AbortController,n=this.#a({controller:t,sessionId:e.sessionId,subagentName:e.subagentName}).finally(()=>{this.#e.delete(e.sessionId)});this.#e.set(e.sessionId,{controller:t,done:n,label:e.subagentName})}async waitForIdle(){for(;this.#e.size>0;)await Promise.all([...this.#e.values()].map(e=>e.done))}async close(){let e=[...this.#e.values()];for(let t of e)t.controller.abort();await Promise.allSettled(e.map(e=>e.done))}async#a(r){let i=T({resource:t(r.sessionId),serverUrl:this.#n});try{for await(let e of b({host:this.#n,maxReconnectAttempts:3,resolveHeaders:async()=>await v({resourceUrl:i}),sessionId:r.sessionId,signal:r.controller.signal,startIndex:0}))if(this.#t.current=W({event:e,options:{isSubagent:!0,sourceLabel:r.subagentName},state:this.#t.current,terminal:this.#r,theme:this.#i}),e.type===`subagent.called`&&this.subscribe({sessionId:e.data.childSessionId,subagentName:e.data.name}),n(e))return}catch(t){if(G(t))return;let n=e(t);this.#t.current=U({kind:`meta`,line:u(this.#i,{message:`${r.subagentName} stream failed: ${n}`,tag:`subagent`,tone:`danger`}),state:this.#t.current,terminal:this.#r})}finally{r.controller.abort()}}};function J(e){switch(e.kind){case`load-skill-result`:return e.kind;case`subagent-result`:return`${e.kind}:${e.subagentName}`;case`tool-result`:return`${e.kind}:${e.toolName}`}}function Y(e){if(e===void 0)return``;let t=[];return e.url!==void 0&&t.push(e.url),e.userCode!==void 0&&t.push(`code ${e.userCode}`),e.instructions!==void 0&&t.push(e.instructions),t.length===0?``:` — ${t.join(`, `)}`}function X(e){switch(e.type){case`actions.requested`:{let t=e.data.actions,n=t.map(e=>e.kind===`tool-call`?e.toolName:e.kind).join(`,`);return`${e.type} (${t.length} action${t.length===1?``:`s`}${n.length>0?`: ${n}`:``})`}case`action.result`:return`${e.type} (${J(e.data.result)})`;case`input.requested`:return`${e.type} (${e.data.requests.length} request${e.data.requests.length===1?``:`s`})`;default:return e.type}}function Z(e,t){return t.continuationToken?u(e,{message:`resuming session ${t.continuationToken}`,tag:`session`,tone:`info`}):u(e,{message:`starting a new session`,tag:`session`,tone:`info`})}function Q(e,t){return t.turn.inputResponses!==void 0&&t.turn.message===void 0?u(e,{message:`responding to pending input request${t.turn.inputResponses.length===1?``:`s`}`,tag:`session`,tone:`info`}):Z(e,t.session)}function ne(e,t){let n=te(t),r=d(t);switch(n?.type){case`session.waiting`:return[u(e,{message:r.length>0?`waiting for input approval/answer or the next message`:`waiting for the next message`,tag:`session`,tone:`success`})];case`session.completed`:return[u(e,{message:`session completed; the next input starts a new session`,tag:`session`,tone:`success`})];case`session.failed`:{let t=n.data.details&&typeof n.data.details.name==`string`?n.data.details.name:void 0;return[u(e,{message:t?`session failed (${t}): ${n.data.message}`:`session failed: ${n.data.message}`,tag:`session`,tone:`danger`}),u(e,{message:`cleared; the next input starts a new session`,tag:`session`,tone:`warning`})]}default:return[]}}async function $(e,t,n={}){return await new Promise(r=>{let i=e.input,a=()=>{e.off(`close`,o),e.off(`line`,s),i.off(`keypress`,c)},o=()=>{a(),r(void 0)},s=e=>{a(),r(e)},c=(t,i)=>{n.allowEscape!==!0||i.name!==`escape`||(a(),e.write(null,{ctrl:!0,name:`u`}),r(p))};e.setPrompt(t),e.once(`close`,o),e.once(`line`,s),n.allowEscape&&(C(i,e),i.on(`keypress`,c)),e.prompt()})}async function re(e){let n=e.turn,r={current:H()},i=new q({displayStateRef:r,serverUrl:e.serverUrl,terminal:e.terminal,theme:e.theme}),a=async t=>{e.terminal.startPrompt(e.rl,t);let n=await $(e.rl,t,{allowEscape:!0});return e.terminal.stopPrompt(),n};try{for(;;){let o=e.client.getSession();r.current=U({kind:`meta`,line:Q(e.theme,{session:o,turn:n}),state:r.current,terminal:e.terminal});let s=await e.client.send({inputResponses:n.inputResponses,message:n.message,onEvent(t){r.current=W({event:t,state:r.current,terminal:e.terminal,theme:e.theme}),t.type===`subagent.called`&&i.subscribe({sessionId:t.data.childSessionId,subagentName:t.data.name})},onResponseStart(n){n.sessionId&&o.sessionId!==n.sessionId&&(r.current=U({kind:`meta`,line:u(e.theme,{message:n.sessionId,tag:`session`,tone:`accent`}),state:r.current,terminal:e.terminal}),r.current=U({kind:`meta`,line:u(e.theme,{message:T({resource:t(n.sessionId),serverUrl:e.serverUrl}).toString(),tag:`stream`,tone:`info`}),state:r.current,terminal:e.terminal}))}}),c=d(s.events);if(K(c)){await i.waitForIdle();for(let t of ne(e.theme,s.events))r.current=U({kind:`meta`,line:t,state:r.current,terminal:e.terminal});return`continue`}let l=await f({ask:a,print(t){r.current=U({kind:`meta`,line:t,state:r.current,terminal:e.terminal})},requests:c,theme:e.theme});if(l.kind===`aborted`)return`exit`;if(l.kind===`deferred`)return r.current=U({kind:`meta`,line:u(e.theme,{message:`left pending input requests unresolved; send a new message to ignore them`,tag:`session`,tone:`warning`}),state:r.current,terminal:e.terminal}),`continue`;n={inputResponses:l.inputResponses}}}finally{await i.close()}}async function ie(t){let n=x(),r=o({color:!0}),i=S({input:process.stdin,output:n.output,terminal:!0});i.on(`SIGINT`,()=>{i.close()});let a=j({serverUrl:t.serverUrl});try{for(n.print(P(r,t)),n.print(``);;){n.print(``),n.startPrompt(i,`you> `);let o=await $(i,`you> `);if(n.stopPrompt(),o===void 0)return;let s=m(o);switch(s.kind!==`empty`&&s.kind!==`exit`&&n.print(``),s.kind){case`empty`:continue;case`help`:n.print(P(r,t)),n.print(``);continue;case`exit`:return;case`new`:await a.clear(),n.print(u(r,{message:`cleared; the next input starts a new session`,tag:`session`,tone:`warning`})),n.print(``);continue;case`message`:try{if(await re({client:a,rl:i,serverUrl:t.serverUrl,terminal:n,theme:r,turn:{message:s.message}})===`exit`)return}catch(i){O(i)?n.printError(u(r,{message:k({serverUrl:t.serverUrl}),tag:`auth`,tone:`warning`})):n.printError(u(r,{message:e(i),tag:`error`,tone:`danger`}))}n.print(``)}}}finally{await a.close(),i.close(),n.dispose()}}export{H as createTurnDisplayState,z as formatContentEvent,B as formatEvent,W as renderTurnEvent,ie as runDevelopmentRepl,K as shouldDrainSubagentStreamsOnBoundary};
|
|
1
|
+
import{t as e}from"../../chunks/errors-HYWjHxV6.js";import{c as t,d as n,f as r,h as i,y as a}from"../../chunks/types-BJSR0JNV.js";import{createCliTheme as o,renderCliBanner as s,renderCliSection as c,renderCliSpeakerLine as l,renderCliTaggedLine as u}from"../ui/output.js";import{n as d,r as f,t as p}from"../../chunks/input-requests-DJiy6dG9.js";import{parseDevReplInput as m}from"./input.js";import{a as h,d as g,i as _,o as ee,r as v,t as y,u as b}from"../../chunks/client-ZqNLLMZB.js";import{createDevelopmentTerminal as x}from"./terminal.js";import{createInterface as S,emitKeypressEvents as C}from"node:readline";function te(e){return[...e].reverse().find(t)}function w(e){let t=new URL(e);return t.hash=``,t.search=``,t.pathname.endsWith(`/`)||(t.pathname=`${t.pathname}/`),t}function T(e){let t=e.resource.trim();try{return new URL(t)}catch{return new URL(t.replace(/^\/+/,``),w(e.serverUrl))}}const E=[`vercel.com/sso-api`,`<title>Authentication Required</title>`,`Vercel Authentication`];function D(e){if(e.length===0)return!1;for(let t of E)if(e.includes(t))return!0;return!1}function O(e){return e instanceof g||typeof e==`object`&&e&&`body`in e&&typeof e.body==`string`?D(e.body):!1}function k(e){return[`Vercel Deployment Protection blocked the request to ${e.serverUrl}.`,``,"To access the deployment from `ash dev`, do one of:"," • Run `vercel link` in this project so the CLI can mint an OIDC",` token for the deployment automatically.`,` • Set VERCEL_AUTOMATION_BYPASS_SECRET to a Protection Bypass for`,` Automation token (Project Settings → Deployment Protection).`,` • Disable Deployment Protection on the target deployment.`,``,`Docs: https://vercel.com/docs/deployment-protection`].join(`
|
|
2
|
+
`)}var A=class{#e;#t;constructor(e){let t=_(e.serverUrl),n={headers:()=>h({serverUrl:e.serverUrl}),host:e.serverUrl};this.#e=new y(t?n:{...n,auth:{bearer:ee}}),this.#t=this.#e.session()}async clear(){this.#t=this.#e.session()}async close(){}getSession(){return this.#t.state}async send(e){let t=await this.#t.send({clientContext:e.clientContext,inputResponses:e.inputResponses,message:e.message});e.onResponseStart?.({sessionId:t.sessionId});let n=[];for await(let r of t)n.push(r),e.onEvent?.(r);return{events:n,sessionId:t.sessionId,session:this.#t.state}}};function j(e){return new A(e)}function M(e){let t=[{label:`Server`,tone:`info`,value:e.serverUrl},{label:`Create`,tone:`info`,value:`POST ${r}`},{label:`Continue`,tone:`info`,value:`POST ${n}`},{label:`Stream`,tone:`info`,value:`GET ${i}`}];return t.push({label:`Session`,value:`Follow-up messages reuse the active continuation token.`}),t}function N(){return[{label:`/help`,value:`Print the connection contract and available commands.`},{label:`/new`,value:`Clear the current durable session cursor.`},{label:`/exit`,value:`Exit the REPL.`}]}function P(e,t){return[s(e,{subtitle:`Interactive development REPL for the active Ash server.`,title:`Ash Dev`}),``,c(e,{rows:M(t),title:`Connection`}),``,c(e,{rows:N(),title:`Commands`})].join(`
|
|
3
|
+
`)}function F(e){let t=e.trim();return t.length>0?t:null}function I(e){return e.options?.isSubagent===!0?`subagent`:e.fallback}function L(e){return e.options?.isSubagent===!0?`subagent`:e.fallback}function R(e){return e.options?.sourceLabel===void 0?e.message:`${e.options.sourceLabel}${e.separator??` `}${e.message}`}function z(e,t,n){switch(t.type){case`message.appended`:return{finalized:!1,kind:`message`,line:l(e,{message:t.data.messageSoFar,speaker:n?.sourceLabel??`agent`,tone:L({fallback:`accent`,options:n})})};case`message.completed`:if(t.data.message===null)return;if(t.data.finishReason===`tool-calls`){let r=F(t.data.message);return r===null?void 0:{finalized:!0,kind:`message`,line:u(e,{message:R({message:r,options:n,separator:`: `}),tag:I({fallback:`step`,options:n}),tone:L({fallback:`accent`,options:n})})}}return{finalized:!0,kind:`message`,line:l(e,{message:t.data.message,speaker:n?.sourceLabel??`agent`,tone:L({fallback:`accent`,options:n})})};case`reasoning.appended`:return{finalized:!1,kind:`reasoning`,line:u(e,{message:R({message:t.data.reasoningSoFar,options:n,separator:`: `}),tag:I({fallback:`reasoning`,options:n}),tone:L({fallback:`info`,options:n})})};case`reasoning.completed`:return{finalized:!0,kind:`reasoning`,line:u(e,{message:R({message:t.data.reasoning,options:n,separator:`: `}),tag:I({fallback:`reasoning`,options:n}),tone:L({fallback:`info`,options:n})})};default:return}}function B(e,t,n){let r=z(e,t,n);if(r!==void 0)return r.line;switch(t.type){case`message.received`:return;case`actions.requested`:return u(e,{message:R({message:`${t.type} (${t.data.actions.length} action${t.data.actions.length===1?``:`s`})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`input.requested`:return u(e,{message:R({message:`${t.type} (${t.data.requests.length} request${t.data.requests.length===1?``:`s`})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`info`,options:n})});case`action.result`:return u(e,{message:R({message:`${t.type} (${J(t.data.result)})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`session.waiting`:case`session.completed`:return;case`connection.authorization_required`:return u(e,{message:R({message:`${t.type} (${t.data.connectionName}: ${t.data.description}${Y(t.data.authorization)})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`warning`,options:n})});case`compaction.requested`:return u(e,{message:R({message:`compacting conversation history`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`compaction.completed`:return u(e,{message:R({message:`conversation history compacted`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`step.failed`:case`turn.failed`:case`session.failed`:return;case`subagent.called`:return u(e,{message:R({message:`${t.type} (${t.data.name} -> ${t.data.childSessionId})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`info`,options:n})});case`subagent.started`:return u(e,{message:R({message:`${t.type} (${t.data.subagentName})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`info`,options:n})});case`subagent.event`:return u(e,{message:R({message:`${t.type} (${t.data.subagentName}: ${X(t.data.event)})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`muted`,options:n})});case`subagent.completed`:return u(e,{message:R({message:`${t.type} (${t.data.subagentName})`,options:n}),tag:I({fallback:`event`,options:n}),tone:L({fallback:`info`,options:n})});default:return}}function V(e){switch(e.type){case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:return`content`;default:return`meta`}}function H(){return{activeLiveContentKind:null,lastPrintedBlockKind:null}}function U(e){let t=e.state;return t.activeLiveContentKind!==null&&(e.terminal.commitLive(),t={activeLiveContentKind:null,lastPrintedBlockKind:`content`}),t.lastPrintedBlockKind!==null&&t.lastPrintedBlockKind!==e.kind&&e.terminal.print(``),e.terminal.print(e.line),{activeLiveContentKind:null,lastPrintedBlockKind:e.kind}}function W(e){let t=z(e.theme,e.event,e.options);if(t!==void 0){let n=e.state;return n.activeLiveContentKind!==null&&n.activeLiveContentKind!==t.kind&&(e.terminal.commitLive(),n={activeLiveContentKind:null,lastPrintedBlockKind:`content`}),n.lastPrintedBlockKind!==null&&n.lastPrintedBlockKind!==`content`&&e.terminal.print(``),e.terminal.updateLive(t.line),t.finalized?(e.terminal.commitLive(),{activeLiveContentKind:null,lastPrintedBlockKind:`content`}):{activeLiveContentKind:t.kind,lastPrintedBlockKind:`content`}}let n=B(e.theme,e.event,e.options);return n===void 0?e.state:U({kind:V(e.event),line:n,state:e.state,terminal:e.terminal})}function G(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}function K(e){return e.length===0}var q=class{#e=new Map;#t;#n;#r;#i;constructor(e){this.#t=e.displayStateRef,this.#n=e.serverUrl,this.#r=e.terminal,this.#i=e.theme}subscribe(e){if(this.#e.has(e.sessionId))return;let t=new AbortController,n=this.#a({controller:t,sessionId:e.sessionId,subagentName:e.subagentName}).finally(()=>{this.#e.delete(e.sessionId)});this.#e.set(e.sessionId,{controller:t,done:n,label:e.subagentName})}async waitForIdle(){for(;this.#e.size>0;)await Promise.all([...this.#e.values()].map(e=>e.done))}async close(){let e=[...this.#e.values()];for(let t of e)t.controller.abort();await Promise.allSettled(e.map(e=>e.done))}async#a(n){let r=T({resource:a(n.sessionId),serverUrl:this.#n});try{for await(let e of b({host:this.#n,maxReconnectAttempts:3,resolveHeaders:async()=>await v({resourceUrl:r}),sessionId:n.sessionId,signal:n.controller.signal,startIndex:0}))if(this.#t.current=W({event:e,options:{isSubagent:!0,sourceLabel:n.subagentName},state:this.#t.current,terminal:this.#r,theme:this.#i}),e.type===`subagent.called`&&this.subscribe({sessionId:e.data.childSessionId,subagentName:e.data.name}),t(e))return}catch(t){if(G(t))return;let r=e(t);this.#t.current=U({kind:`meta`,line:u(this.#i,{message:`${n.subagentName} stream failed: ${r}`,tag:`subagent`,tone:`danger`}),state:this.#t.current,terminal:this.#r})}finally{n.controller.abort()}}};function J(e){switch(e.kind){case`load-skill-result`:return e.kind;case`subagent-result`:return`${e.kind}:${e.subagentName}`;case`tool-result`:return`${e.kind}:${e.toolName}`}}function Y(e){if(e===void 0)return``;let t=[];return e.url!==void 0&&t.push(e.url),e.userCode!==void 0&&t.push(`code ${e.userCode}`),e.instructions!==void 0&&t.push(e.instructions),t.length===0?``:` — ${t.join(`, `)}`}function X(e){switch(e.type){case`actions.requested`:{let t=e.data.actions,n=t.map(e=>e.kind===`tool-call`?e.toolName:e.kind).join(`,`);return`${e.type} (${t.length} action${t.length===1?``:`s`}${n.length>0?`: ${n}`:``})`}case`action.result`:return`${e.type} (${J(e.data.result)})`;case`input.requested`:return`${e.type} (${e.data.requests.length} request${e.data.requests.length===1?``:`s`})`;default:return e.type}}function Z(e,t){return t.continuationToken?u(e,{message:`resuming session ${t.continuationToken}`,tag:`session`,tone:`info`}):u(e,{message:`starting a new session`,tag:`session`,tone:`info`})}function Q(e,t){return t.turn.inputResponses!==void 0&&t.turn.message===void 0?u(e,{message:`responding to pending input request${t.turn.inputResponses.length===1?``:`s`}`,tag:`session`,tone:`info`}):Z(e,t.session)}function ne(e,t){let n=te(t),r=d(t);switch(n?.type){case`session.waiting`:return[u(e,{message:r.length>0?`waiting for input approval/answer or the next message`:`waiting for the next message`,tag:`session`,tone:`success`})];case`session.completed`:return[u(e,{message:`session completed; the next input starts a new session`,tag:`session`,tone:`success`})];case`session.failed`:{let t=n.data.details&&typeof n.data.details.name==`string`?n.data.details.name:void 0;return[u(e,{message:t?`session failed (${t}): ${n.data.message}`:`session failed: ${n.data.message}`,tag:`session`,tone:`danger`}),u(e,{message:`cleared; the next input starts a new session`,tag:`session`,tone:`warning`})]}default:return[]}}async function $(e,t,n={}){return await new Promise(r=>{let i=e.input,a=()=>{e.off(`close`,o),e.off(`line`,s),i.off(`keypress`,c)},o=()=>{a(),r(void 0)},s=e=>{a(),r(e)},c=(t,i)=>{n.allowEscape!==!0||i.name!==`escape`||(a(),e.write(null,{ctrl:!0,name:`u`}),r(p))};e.setPrompt(t),e.once(`close`,o),e.once(`line`,s),n.allowEscape&&(C(i,e),i.on(`keypress`,c)),e.prompt()})}async function re(e){let t=e.turn,n={current:H()},r=new q({displayStateRef:n,serverUrl:e.serverUrl,terminal:e.terminal,theme:e.theme}),i=async t=>{e.terminal.startPrompt(e.rl,t);let n=await $(e.rl,t,{allowEscape:!0});return e.terminal.stopPrompt(),n};try{for(;;){let o=e.client.getSession();n.current=U({kind:`meta`,line:Q(e.theme,{session:o,turn:t}),state:n.current,terminal:e.terminal});let s=await e.client.send({inputResponses:t.inputResponses,message:t.message,onEvent(t){n.current=W({event:t,state:n.current,terminal:e.terminal,theme:e.theme}),t.type===`subagent.called`&&r.subscribe({sessionId:t.data.childSessionId,subagentName:t.data.name})},onResponseStart(t){t.sessionId&&o.sessionId!==t.sessionId&&(n.current=U({kind:`meta`,line:u(e.theme,{message:t.sessionId,tag:`session`,tone:`accent`}),state:n.current,terminal:e.terminal}),n.current=U({kind:`meta`,line:u(e.theme,{message:T({resource:a(t.sessionId),serverUrl:e.serverUrl}).toString(),tag:`stream`,tone:`info`}),state:n.current,terminal:e.terminal}))}}),c=d(s.events);if(K(c)){await r.waitForIdle();for(let t of ne(e.theme,s.events))n.current=U({kind:`meta`,line:t,state:n.current,terminal:e.terminal});return`continue`}let l=await f({ask:i,print(t){n.current=U({kind:`meta`,line:t,state:n.current,terminal:e.terminal})},requests:c,theme:e.theme});if(l.kind===`aborted`)return`exit`;if(l.kind===`deferred`)return n.current=U({kind:`meta`,line:u(e.theme,{message:`left pending input requests unresolved; send a new message to ignore them`,tag:`session`,tone:`warning`}),state:n.current,terminal:e.terminal}),`continue`;t={inputResponses:l.inputResponses}}}finally{await r.close()}}async function ie(t){let n=x(),r=o({color:!0}),i=S({input:process.stdin,output:n.output,terminal:!0});i.on(`SIGINT`,()=>{i.close()});let a=j({serverUrl:t.serverUrl});try{for(n.print(P(r,t)),n.print(``);;){n.print(``),n.startPrompt(i,`you> `);let o=await $(i,`you> `);if(n.stopPrompt(),o===void 0)return;let s=m(o);switch(s.kind!==`empty`&&s.kind!==`exit`&&n.print(``),s.kind){case`empty`:continue;case`help`:n.print(P(r,t)),n.print(``);continue;case`exit`:return;case`new`:await a.clear(),n.print(u(r,{message:`cleared; the next input starts a new session`,tag:`session`,tone:`warning`})),n.print(``);continue;case`message`:try{if(await re({client:a,rl:i,serverUrl:t.serverUrl,terminal:n,theme:r,turn:{message:s.message}})===`exit`)return}catch(i){O(i)?n.printError(u(r,{message:k({serverUrl:t.serverUrl}),tag:`auth`,tone:`warning`})):n.printError(u(r,{message:e(i),tag:`error`,tone:`danger`}))}n.print(``)}}}finally{await a.close(),i.close(),n.dispose()}}export{H as createTurnDisplayState,z as formatContentEvent,B as formatEvent,W as renderTurnEvent,ie as runDevelopmentRepl,K as shouldDrainSubagentStreamsOnBoundary};
|
package/dist/src/cli/run.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{D as e,n as t}from"../chunks/paths-
|
|
1
|
+
import{D as e,n as t}from"../chunks/paths-DnlVBqHu.js";import{createCliTheme as n,renderCliTaggedLine as r}from"./ui/output.js";import{i,n as a,r as o,t as s}from"../chunks/url-JdCGA634.js";async function c(){return(await import(`../chunks/host-F-DkwYJK.js`).then(e=>e.t)).buildApplication}async function l(){return(await import(`./commands/info.js`)).printApplicationInfo}async function u(){return(await import(`./dev/repl.js`)).runDevelopmentRepl}async function d(){return(await import(`../evals/cli/eval.js`)).runEvalCommand}async function f(){return(await import(`../chunks/host-F-DkwYJK.js`).then(e=>e.t)).startDevelopmentServer}function p(e){return e.name()===`info`||e.name()===`dev`}async function m(e){await new Promise((t,n)=>{let r=!1,i=()=>{process.off(`SIGINT`,a),process.off(`SIGTERM`,a)},a=()=>{r||(r=!0,i(),e.close().then(t,n))};process.once(`SIGINT`,a),process.once(`SIGTERM`,a)})}function h(e){if(!/^-?\d+$/.test(e))throw new i(`Expected a numeric port, received "${e}".`);let t=Number(e);if(t<0||t>65535)throw new i(`Expected a port between 0 and 65535, received "${e}".`);return t}function g(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function _(e){let t=e[1];return e[0]!==`dev`||e.length!==2||t===void 0||t.startsWith(`-`)?[...e]:[`dev`,`--url`,t]}function v(e){if(e.url){if(e.host!==void 0)throw new i(`The --host option cannot be used with --url.`);if(e.port!==void 0)throw new i(`The --port option cannot be used with --url.`);if(e.repl===!1)throw new i(`The --no-repl option cannot be used with --url.`);return e.url}}function y(i,o){let _=t(),y=e().version,b=new a,x=n();return b.name(`ash`).description(`Build and run an Ash application.`).version(y).showHelpAfterError().exitOverride().hook(`preAction`,(e,t)=>{p(t)&&i.log(`Ash (v${y})`)}).configureOutput({writeErr:e=>{i.error(e.trimEnd())},writeOut:e=>{i.log(e.trimEnd())}}),b.command(`build`).description(`Build the current Ash application.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:e}=await import(`./dev/environment.js`);e(_);let t=await(o.buildHost??await c())(_);i.log(r(x,{message:`built output at ${t}`,tag:`build`,tone:`success`}))}),b.command(`dev`).description(`Start the Ash development server or connect the REPL to an existing URL.`).option(`--host <host>`,`Host interface to bind`).option(`--no-repl`,`Start the server without the interactive REPL`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,h).option(`--schedules`,`Run scheduled tasks during development (off by default)`).option(`-u, --url <url>`,`Connect the REPL to an existing server URL`,s).addHelpText(`after`,`
|
|
2
2
|
You can also pass a bare URL as the only argument, for example: ash dev https://example.com
|
|
3
3
|
`).action(async e=>{let t=v(e),{loadDevelopmentEnvironmentFiles:n}=await import(`./dev/environment.js`);if(n(_),t){if(i.log(r(x,{message:`REPL connecting to ${t}`,tag:`dev`,tone:`info`})),!g()){i.log(r(x,{message:`Interactive REPL disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}i.log(``),await(o.runDevelopmentRepl??await u())({serverUrl:t});return}let a=await(o.startHost??await f())(_,{host:e.host,port:e.port,schedules:e.schedules===!0}),s=!1,c=async()=>{s||(s=!0,await a.close())};try{if(i.log(r(x,{message:`server listening at ${a.url}`,tag:`dev`,tone:`success`})),e.repl===!1)return await m({close:c});if(!g())return i.log(r(x,{message:`Interactive REPL disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await m({close:c});i.log(``),await(o.runDevelopmentRepl??await u())({serverUrl:a.url})}finally{await c()}}),b.command(`info`).description(`Print resolved application information.`).action(async()=>{await(o.printApplicationInfo??await l())(i,_)}),b.command(`eval`).description(`Run eval suites against an Ash agent.`).option(`--suite <id...>`,`Suite IDs to run (repeatable)`).option(`--all`,`Run all discovered suites`).option(`--url <url>`,`Remote agent URL (skip local host startup)`).option(`--timeout <ms>`,`Per-case timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent case executions per suite`).option(`--json`,`Output results as JSON`).option(`--skip-report`,`Skip suite-defined reporters (e.g. Braintrust)`).action(async e=>{await(o.runEvalCommand??await d())(e,i)}),b}async function b(e=process.argv.slice(2),t=console,n={}){let r=y(t,n),i=e.length===0?[`info`]:_(e);try{await r.parseAsync(i,{from:`user`})}catch(e){if(e instanceof o){if(e.exitCode===0)return;throw Error(e.message)}throw e}}export{b as runCli};
|
|
@@ -403,6 +403,12 @@ function normalizeActionRequest(action) {
|
|
|
403
403
|
name: action.subagentName,
|
|
404
404
|
toolName: `ash:subagent:${action.subagentName}`,
|
|
405
405
|
};
|
|
406
|
+
case "remote-agent-call":
|
|
407
|
+
return {
|
|
408
|
+
kind: "subagent-call",
|
|
409
|
+
name: action.remoteAgentName,
|
|
410
|
+
toolName: `ash:subagent:${action.remoteAgentName}`,
|
|
411
|
+
};
|
|
406
412
|
}
|
|
407
413
|
}
|
|
408
414
|
function normalizeActionResult(result) {
|
|
@@ -4,7 +4,7 @@ import { getCompiledRuntimeAgentBundle } from "#runtime/sessions/compiled-agent-
|
|
|
4
4
|
import type { SandboxAccess } from "#sandbox/state.js";
|
|
5
5
|
import { ContextKey } from "#context/key.js";
|
|
6
6
|
export type { SessionAuthContext, SessionParent, SessionTurn } from "#channel/types.js";
|
|
7
|
-
export { AuthKey, CapabilitiesKey, ContinuationTokenKey, InitiatorAuthKey, ModeKey, ParentSessionKey, SessionIdKey, SessionPreparedKey, } from "#context/seed-keys.js";
|
|
7
|
+
export { AuthKey, CapabilitiesKey, ContinuationTokenKey, InitiatorAuthKey, ModeKey, ParentSessionKey, SessionCallbackKey, SessionIdKey, SessionPreparedKey, } from "#context/seed-keys.js";
|
|
8
8
|
/**
|
|
9
9
|
* Auth metadata on the active session.
|
|
10
10
|
*
|
package/dist/src/context/keys.js
CHANGED
|
@@ -3,7 +3,7 @@ import { deserializeRuntimeAdapter } from "#runtime/channels/registry.js";
|
|
|
3
3
|
import { getCompiledRuntimeAgentBundle } from "#runtime/sessions/compiled-agent-cache.js";
|
|
4
4
|
import { ContextKey } from "#context/key.js";
|
|
5
5
|
// Re-export seed keys so existing consumers of `context/keys` keep working.
|
|
6
|
-
export { AuthKey, CapabilitiesKey, ContinuationTokenKey, InitiatorAuthKey, ModeKey, ParentSessionKey, SessionIdKey, SessionPreparedKey, } from "#context/seed-keys.js";
|
|
6
|
+
export { AuthKey, CapabilitiesKey, ContinuationTokenKey, InitiatorAuthKey, ModeKey, ParentSessionKey, SessionCallbackKey, SessionIdKey, SessionPreparedKey, } from "#context/seed-keys.js";
|
|
7
7
|
export const ChannelKey = new ContextKey("ash.channel", {
|
|
8
8
|
codec: {
|
|
9
9
|
serialize(adapter) {
|