experimental-ash 0.24.1 → 0.24.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/src/chunks/authored-module-loader-DcCfCiBm.js +4 -0
  3. package/dist/src/chunks/client-DLHAGI2g.js +4 -0
  4. package/dist/src/chunks/dev-authored-source-watcher-CBID_Dwh.js +1 -0
  5. package/dist/src/chunks/{errors-DsO9xmQL.js → errors-HYWjHxV6.js} +1 -1
  6. package/dist/src/chunks/{gray-matter-BxS7ZG-J.js → gray-matter-D-9jHwOT.js} +4 -4
  7. package/dist/src/chunks/host-zBy9FyyX.js +70 -0
  8. package/dist/src/chunks/{jsdist-M7JFZoA4.js → jsdist-BkeWZ7EZ.js} +61 -61
  9. package/dist/src/chunks/package-HUaeub_D.js +1 -0
  10. package/dist/src/chunks/{paths-jcVjBqc3.js → paths-CebY5GCi.js} +2 -2
  11. package/dist/src/chunks/{picocolors-Bq-tZK9u.js → picocolors-aAkqW4On.js} +1 -1
  12. package/dist/src/chunks/token-D98SQdvs.js +1 -0
  13. package/dist/src/chunks/{url-BVRhVE2O.js → url-JdCGA634.js} +1 -1
  14. package/dist/src/cli/commands/info.js +1 -1
  15. package/dist/src/cli/dev/environment.d.ts +16 -2
  16. package/dist/src/cli/dev/environment.js +1 -1
  17. package/dist/src/cli/dev/input-requests.js +1 -1
  18. package/dist/src/cli/dev/repl.js +3 -3
  19. package/dist/src/cli/dev/url.js +1 -1
  20. package/dist/src/cli/run.js +1 -1
  21. package/dist/src/cli/ui/output.js +1 -1
  22. package/dist/src/client/index.d.ts +1 -0
  23. package/dist/src/client/index.js +1 -0
  24. package/dist/src/compiled/.vendor-stamp.json +7 -6
  25. package/dist/src/compiled/@ai-sdk/anthropic/index.js +1 -1
  26. package/dist/src/compiled/@ai-sdk/google/index.js +1 -1
  27. package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
  28. package/dist/src/compiled/@ai-sdk/openai/index.js +1 -1
  29. package/dist/src/compiled/@ai-sdk/otel/index.js +1 -1
  30. package/dist/src/compiled/@chat-adapter/slack/_slack-web-api.d.ts +7 -0
  31. package/dist/src/compiled/@chat-adapter/slack/index.d.ts +418 -109
  32. package/dist/src/compiled/@chat-adapter/slack/index.js +31 -27
  33. package/dist/src/compiled/@chat-adapter/slack/package.json +1 -1
  34. package/dist/src/compiled/@chat-adapter/state-memory/index.d.ts +8 -2
  35. package/dist/src/compiled/@chat-adapter/state-memory/index.js +1 -1
  36. package/dist/src/compiled/@chat-adapter/state-memory/package.json +1 -1
  37. package/dist/src/compiled/@opentelemetry/api/index.js +1 -1
  38. package/dist/src/compiled/@vercel/sandbox/index.js +19 -17
  39. package/dist/src/compiled/@vercel/sandbox/package.json +1 -1
  40. package/dist/src/compiled/@workflow/core/index.js +2 -2
  41. package/dist/src/compiled/@workflow/core/runtime.js +22 -22
  42. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  43. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  44. package/dist/src/compiled/_chunks/node/auth-ZhCJAHxl.js +2 -0
  45. package/dist/src/compiled/_chunks/node/{dist-BdWHjlRQ.js → dist-BQYUcBqu.js} +31 -31
  46. package/dist/src/compiled/_chunks/node/{chunk-Dd2tEFlW.js → dist-BdTs18CF.js} +1 -1
  47. package/dist/src/compiled/_chunks/node/retry-DkR2H1Y0.js +1 -0
  48. package/dist/src/compiled/_chunks/node/token-CoIbMZkq.js +1 -0
  49. package/dist/src/compiled/_chunks/node/{version-BMyZn3Y2.js → version-D4IYmfaS.js} +1 -1
  50. package/dist/src/compiled/_chunks/workflow/coerce-BhzIW-Hm.js +1 -0
  51. package/dist/src/compiled/_chunks/workflow/{compat-CIROS3w4.js → compat-DcEvieoj.js} +1 -1
  52. package/dist/src/compiled/_chunks/workflow/{core-DOVmxHH8.js → core-XWIi7wKc.js} +3 -3
  53. package/dist/src/compiled/_chunks/workflow/{dist-C7wPwOI9.js → dist-DO14ZaQj.js} +1 -1
  54. package/dist/src/compiled/_chunks/workflow/{dist-CpUQh3NH.js → dist-DZZY3Zyp.js} +1 -1
  55. package/dist/src/compiled/_chunks/workflow/resume-hook-DOMbNs-S.js +51 -0
  56. package/dist/src/compiled/_chunks/workflow/{schemas-DFZoEyCn.js → schemas-DmgDnhW3.js} +1 -1
  57. package/dist/src/compiled/_chunks/workflow/sleep-CRjce49s.js +1 -0
  58. package/dist/src/compiled/_chunks/workflow/{src-ClRYdO4-.js → src-B54rYDvB.js} +1 -1
  59. package/dist/src/compiled/_chunks/workflow/symbols-D8paKc8P.js +9 -0
  60. package/dist/src/compiled/_chunks/workflow/{token-CsNmv7KW.js → token-D9z1dMB6.js} +1 -1
  61. package/dist/src/compiled/_chunks/workflow/{token-j5Cl4rrs.js → token-DV7rQw_t.js} +1 -1
  62. package/dist/src/compiled/chat/index.d.ts +6 -3143
  63. package/dist/src/compiled/chat/index.js +1 -1
  64. package/dist/src/compiled/chat/{jsx-runtime-DxGwoLu2.d.ts → jsx-runtime-CFq1K_Ve.d.ts} +1 -1
  65. package/dist/src/compiled/chat/package.json +1 -1
  66. package/dist/src/compiled/jose/index.js +2 -2
  67. package/dist/src/compiled/jsonc-parser/LICENSE.md +21 -0
  68. package/dist/src/compiled/jsonc-parser/index.d.ts +13 -0
  69. package/dist/src/compiled/jsonc-parser/index.js +15 -0
  70. package/dist/src/compiled/jsonc-parser/package.json +7 -0
  71. package/dist/src/compiled/just-bash/index.js +773 -773
  72. package/dist/src/compiled/just-bash/package.json +1 -1
  73. package/dist/src/compiled/turndown/index.js +1 -1
  74. package/dist/src/compiled/zod/index.js +1 -1
  75. package/dist/src/compiled/zod-validation-error/index.js +1 -1
  76. package/dist/src/evals/cli/eval.js +1 -1
  77. package/dist/src/evals/loaders/yaml.js +1 -1
  78. package/dist/src/evals/runner/discover.js +1 -1
  79. package/dist/src/evals/runner/execute-suite.js +1 -1
  80. package/dist/src/evals/runner/reporters/console.js +1 -1
  81. package/dist/src/evals/scorers/autoevals-client.js +1 -1
  82. package/dist/src/evals/scorers/autoevals.js +1 -1
  83. package/dist/src/evals/scorers/json.js +1 -1
  84. package/dist/src/evals/scorers/run.js +1 -1
  85. package/dist/src/evals/scorers/sql.js +1 -1
  86. package/dist/src/evals/scorers/text.js +1 -1
  87. package/dist/src/internal/application/package.js +1 -1
  88. package/dist/src/internal/authored-asset-import-plugin.d.ts +5 -0
  89. package/dist/src/internal/authored-asset-import-plugin.js +141 -0
  90. package/dist/src/internal/authored-module-bundle.d.ts +4 -0
  91. package/dist/src/internal/authored-module-bundle.js +19 -0
  92. package/dist/src/internal/authored-module-loader.d.ts +6 -0
  93. package/dist/src/internal/authored-module-loader.js +114 -125
  94. package/dist/src/internal/authored-package-tsconfig-paths.d.ts +9 -0
  95. package/dist/src/internal/authored-package-tsconfig-paths.js +209 -0
  96. package/dist/src/internal/nitro/host/channel-routes.d.ts +9 -2
  97. package/dist/src/internal/nitro/host/dev-authored-source-watcher.d.ts +12 -1
  98. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +19 -3
  99. package/dist/src/internal/nitro/host/schedule-task-routes.d.ts +7 -3
  100. package/dist/src/internal/nitro/host/start-development-server.js +2 -0
  101. package/package.json +17 -17
  102. package/dist/src/chunks/authored-module-loader-XcFLnl49.js +0 -2
  103. package/dist/src/chunks/client-nshDsWNF.js +0 -4
  104. package/dist/src/chunks/dev-authored-source-watcher-CApkYfee.js +0 -7
  105. package/dist/src/chunks/host-3sfHdmXL.js +0 -65
  106. package/dist/src/chunks/package-DmsQgn4v.js +0 -1
  107. package/dist/src/chunks/prewarm-DslujbK5.js +0 -6
  108. package/dist/src/chunks/token-DtoyQZy2.js +0 -1
  109. package/dist/src/chunks/token-util-CHjOk3A7.js +0 -1
  110. package/dist/src/compiled/_chunks/node/auth-vbe4XEEK.js +0 -2
  111. package/dist/src/compiled/_chunks/node/dist-DMSq2ehP.js +0 -1
  112. package/dist/src/compiled/_chunks/node/retry-BOcy5BbJ.js +0 -1
  113. package/dist/src/compiled/_chunks/node/token-D-BTJHoU.js +0 -1
  114. package/dist/src/compiled/_chunks/workflow/coerce-Dh0wa7P9.js +0 -1
  115. package/dist/src/compiled/_chunks/workflow/context-errors-Bbvvp-li.js +0 -6
  116. package/dist/src/compiled/_chunks/workflow/dist-C_oiE-l7.js +0 -40
  117. package/dist/src/compiled/_chunks/workflow/resume-hook-C3VWUPii.js +0 -12
  118. package/dist/src/compiled/_chunks/workflow/sleep-QTkC1VFe.js +0 -1
  119. package/dist/src/compiled/_chunks/workflow/symbols-QezhMuLg.js +0 -4
  120. package/dist/src/compiled/chat/_workflow-serde.d.ts +0 -5
  121. /package/dist/src/chunks/{chunk-8L7ocgPr.js → chunk-DSjMdhoD.js} +0 -0
  122. /package/dist/src/chunks/{guards-CjJ3lmju.js → guards-26p6sOw3.js} +0 -0
  123. /package/dist/src/chunks/{input-requests-BsBi7_5K.js → input-requests-DJiy6dG9.js} +0 -0
  124. /package/dist/src/chunks/{runtime-model-BWu6M_hq.js → runtime-model-Dh0Nz64z.js} +0 -0
  125. /package/dist/src/chunks/{types-MZUhN0Zy.js → types-DDA2QUED.js} +0 -0
  126. /package/dist/src/compiled/_chunks/workflow/{chunk-DHhdAPOb.js → chunk-DSjMdhoD.js} +0 -0
@@ -0,0 +1 @@
1
+ import{createRequire as e}from"node:module";import{basename as t,dirname as n,join as r}from"node:path";import{existsSync as i,readFileSync as a,realpathSync as o}from"node:fs";import{fileURLToPath as s}from"node:url";const c=`experimental-ash`;let l;const u={"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 d(){return`__ASH_PACKAGE_VERSION__`}const f={name:c,version:d()};function p(){return typeof __filename==`string`?__filename:m()}function m(){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:`)?s(e):e}finally{Error.prepareStackTrace=e}}const h=e(p());function g(e){return t(e)===`dist`&&i(r(n(e),`package.json`))}function _(){let e=n(o(p()));for(;;){if(g(e))return e;let t=n(e);if(t===e)return null;e=t}}function v(e){let t=e;for(;;){if(i(r(t,`package.json`))&&!g(t))return t;let a=n(t);if(a===t)throw Error(`Failed to resolve package root from "${e}".`);t=a}}function y(){return v(n(o(p())))}function b(){try{return y()}catch{return}}function x(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function S(e){let t=_();return t===null?r(y(),e):r(t,x(e))}function C(e){let t=_();return r(t===null?y():t,e)}function w(e){let t=_();return t===null?r(y(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):r(t,e)}function T(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function E(e,t){let n=T(JSON.parse(a(e,`utf8`)));if(n?.name===t)return n}function D(){if(l)return l;let e=b(),t=e===void 0?void 0:E(r(e,`package.json`),c);if(t)return l=t,l;try{let e=E(h.resolve(`${c}/package.json`),c);if(e)return l=e,l}catch{}return l={...f},l}function O(e){if(e===`workflow`)return S(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return S(`src/internal/workflow/builtins.ts`);let t=u[e];return t===void 0?h.resolve(e):w(t)}export{O as a,S as i,y as n,c as o,C as r,D as t};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./chunk-8L7ocgPr.js";import{t}from"./gray-matter-BxS7ZG-J.js";import{c as n,d as r,f as i,l as a,o,p as s,s as c,t as l,u}from"./authored-module-loader-XcFLnl49.js";import{n as d,t as f}from"./guards-CjJ3lmju.js";import{t as p}from"./errors-DsO9xmQL.js";import{n as m,o as h,r as g,t as _}from"./package-DmsQgn4v.js";import{a as v,b as y,f as ee,i as te,n as ne,o as re,r as ie,s as ae,t as oe,u as se,y as ce}from"./types-MZUhN0Zy.js";import{t as le}from"./runtime-model-BWu6M_hq.js";import{z as b}from"#compiled/zod/index.js";import{basename as ue,dirname as x,join as S,posix as de,relative as fe,resolve as C,sep as pe}from"node:path";import{access as me,cp as he,mkdir as w,readFile as ge,readdir as _e,rm as ve,stat as ye,writeFile as T}from"node:fs/promises";import{createHash as be}from"node:crypto";import{existsSync as xe,readFileSync as Se,readdirSync as Ce,rmSync as we}from"node:fs";import{pathToFileURL as Te}from"node:url";import{Buffer as Ee}from"node:buffer";import"#compiled/@workflow/errors/index.js";import{resumeHook as De}from"#compiled/@workflow/core/runtime.js";import{AsyncLocalStorage as Oe}from"node:async_hooks";import{SpanStatusCode as ke,trace as Ae}from"#compiled/@opentelemetry/api/index.js";import{getErrorMessage as je}from"#compiled/@ai-sdk/provider/index.js";import{inspect as Me}from"node:util";import{fromError as Ne}from"#compiled/zod-validation-error/index.js";import{createRemoteJWKSet as Pe,decodeJwt as Fe,jwtVerify as Ie}from"#compiled/jose/index.js";import"ai";import Le from"#compiled/turndown/index.js";const Re=b.union([b.literal(`error`),b.literal(`warning`)]);b.object({code:b.string(),message:b.string(),severity:Re,sourcePath:b.string()}).strict();const ze=b.object({errors:b.number().finite(),warnings:b.number().finite()}).strict();function Be(e){return e}function E(e){return Be({...e,severity:`error`})}function Ve(e){return Be({...e,severity:`warning`})}function He(e){return e.reduce((e,t)=>(t.severity===`error`?e.errors+=1:e.warnings+=1,e),{errors:0,warnings:0})}function Ue(e){return e.some(e=>e.severity===`error`)}const We=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],Ge=[`package.json`,`vercel.json`],Ke=[`agent.ts`,`agent.cts`,`agent.mts`,`agent.js`,`agent.cjs`,`agent.mjs`,`instructions.md`,`instructions.ts`,`instructions.cts`,`instructions.mts`,`instructions.js`,`instructions.cjs`,`instructions.mjs`,`system.md`,`system.ts`,`system.cts`,`system.mts`,`system.js`,`system.cjs`,`system.mjs`],qe=[`channels`,`connections`,`hooks`,`lib`,`sandbox`,`skills`,`tools`,`schedules`,`subagents`],Je=[`agent.ts`,`agent.cts`,`agent.mts`,`agent.js`,`agent.cjs`,`agent.mjs`,`instructions.md`,`instructions.ts`,`instructions.cts`,`instructions.mts`,`instructions.js`,`instructions.cjs`,`instructions.mjs`,`system.md`,`system.ts`,`system.cts`,`system.mts`,`system.js`,`system.cjs`,`system.mjs`],Ye=[`hooks`,`lib`,`sandbox`,`skills`,`tools`,`subagents`],Xe=[`SKILL.md`],Ze=[`scripts`,`references`,`assets`],Qe=new Set(Ge);new Set(Ke),new Set(qe),new Set(Je),new Set(Ye),new Set(Xe),new Set(Ze);function D(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function $e(e,t){return t===`file`&&Qe.has(e)}function et(e,t){if(t===`file`)return A(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:A(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:A(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 tt(e,t){if(t===`file`)return A(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:A(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:A(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 nt(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 rt(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(e.endsWith(`.md`))return`flat-skill-markdown`;if(k(e)!==null)return`flat-skill-module`}return`unknown`}function O(e){return e.replaceAll(pe,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function k(e){for(let t of We)if(e.endsWith(t)&&e.length>t.length)return e.slice(0,-t.length);return null}function A(e,t){return k(e)===t}function j(e){let t=O(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}var it=e(t(),1);function at(e,t){let r=c(e,t);if(n(r,[`build`,`compaction`,`description`,`metadata`,`model`,`modelContextWindowTokens`,`modelOptions`],t),r.model===void 0)throw Error(`${t} The "model" field is required.`);let a={model:r.model};r.description!==void 0&&(a.description=u(r.description,t));let o=i(r,`metadata`,t);return o!==void 0&&(a.metadata=o),r.compaction!==void 0&&(a.compaction=lt(r.compaction,t)),r.build!==void 0&&(a.build=st(r.build,t)),r.modelOptions!==void 0&&(a.modelOptions=ct(r.modelOptions,t)),r.modelContextWindowTokens!==void 0&&(a.modelContextWindowTokens=ot(r.modelContextWindowTokens,t)),a}function ot(e,t){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(t);return e}function st(e,t){let r=c(e,t);n(r,[`externalDependencies`],t);let i={};if(r.externalDependencies!==void 0){if(!Array.isArray(r.externalDependencies))throw Error(t);i.externalDependencies=Object.freeze(r.externalDependencies.map(e=>u(e,t)))}return i}function ct(e,t){let r=c(e,t);n(r,[`providerOptions`],t);let i=r.providerOptions;return i===void 0?{}:{providerOptions:a(i,t)}}function lt(e,t){let r=c(e,t);n(r,[`model`,`modelContextWindowTokens`,`thresholdPercent`],t);let i={};if(r.model!==void 0&&(i.model=r.model),r.modelContextWindowTokens!==void 0&&(i.modelContextWindowTokens=ot(r.modelContextWindowTokens,t)),r.thresholdPercent!==void 0){let e=r.thresholdPercent;if(typeof e!=`number`||!Number.isFinite(e)||e<0||e>1)throw Error(t);i.thresholdPercent=e}return i}function ut(e,t){let r=c(e,t);return n(r,[`markdown`],t),{markdown:u(r.markdown,t)}}function dt(e,t){let r=c(e,t);n(r,[`description`,`files`,`license`,`markdown`,`metadata`],t);let a={description:u(r.description,t),markdown:u(r.markdown,t)},o=r.license,s=i(r,`metadata`,t);return o!==void 0&&(a.license=u(o,t)),s!==void 0&&(a.metadata=s),r.files!==void 0&&(a.files=ft(r.files,t)),a}function ft(e,t){let n=c(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 pt(e,t){let r=c(e,t);n(r,[`cron`,`markdown`,`run`],t);let i=u(r.cron,t),a=r.markdown!==void 0,s=r.run!==void 0;if(a&&s)throw Error(`${t} Pass either "markdown" (fire-and-forget) or "run" (handler) — not both.`);if(!a&&!s)throw Error(`${t} Must provide either "markdown" (fire-and-forget) or "run" (handler).`);let l={cron:i};return a?l.markdown=u(r.markdown,t):l.run=o(r.run,t),l}function mt(e){return e}function ht(e){return e}function gt(e){return e}const _t=/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/;function vt(e){if(!it.default.test(e))return{hasFrontmatter:!1,frontmatter:{},markdown:e};let t;try{t=(0,it.default)(e)}catch(t){throw St(e)&&!Ct(e)?Error(`Markdown frontmatter is missing a closing delimiter.`):t}if(!d(t.data))throw Error(`Markdown frontmatter must parse to an object.`);return{hasFrontmatter:!0,frontmatter:t.data,markdown:wt(t.content)}}function yt(e){return gt(ut({markdown:e},`Expected authored instructions markdown to match the public Ash shape.`))}function bt(e){let t=vt(e);if(!t.hasFrontmatter)throw Error(`Schedule markdown must start with YAML frontmatter declaring "cron".`);if(`run`in t.frontmatter)throw Error('Markdown-form schedules do not support the "run" frontmatter key. Use a TypeScript schedule (`<name>.ts`) to author a handler.');return mt(pt({...t.frontmatter,markdown:t.markdown},`Expected authored schedule markdown to match the public Ash shape.`))}function xt(e,t={}){let n=vt(e),r=t.slug;if(r===void 0&&!n.hasFrontmatter)throw Error(`Skill markdown must start with YAML frontmatter.`);let i=Dt(n.frontmatter),a=Ot(i.description,`description`),o=r===void 0?kt(i.description,`description`):a??t.description??jt(n.markdown,r),s={...i,description:o,markdown:n.markdown};return Tt(s,i),ht(dt(s,`Expected authored skill markdown to match the public Ash shape.`))}function St(e){return e.startsWith(`---
1
+ import{i as e}from"./chunk-DSjMdhoD.js";import{t}from"./gray-matter-D-9jHwOT.js";import{c as n,d as r,f as i,l as a,o,p as s,s as c,t as l,u}from"./authored-module-loader-DcCfCiBm.js";import{n as d,t as f}from"./guards-26p6sOw3.js";import{t as p}from"./errors-HYWjHxV6.js";import{n as m,o as h,r as g,t as _}from"./package-HUaeub_D.js";import{a as v,b as y,f as ee,i as te,n as ne,o as re,r as ie,s as ae,t as oe,u as se,y as ce}from"./types-DDA2QUED.js";import{t as le}from"./runtime-model-Dh0Nz64z.js";import{z as b}from"#compiled/zod/index.js";import{basename as ue,dirname as x,join as S,posix as de,relative as fe,resolve as C,sep as pe}from"node:path";import{access as me,cp as he,mkdir as w,readFile as ge,readdir as _e,rm as ve,stat as ye,writeFile as T}from"node:fs/promises";import{createHash as be}from"node:crypto";import{existsSync as xe,readFileSync as Se,readdirSync as Ce,rmSync as we}from"node:fs";import{pathToFileURL as Te}from"node:url";import{Buffer as Ee}from"node:buffer";import"#compiled/@workflow/errors/index.js";import{resumeHook as De}from"#compiled/@workflow/core/runtime.js";import{AsyncLocalStorage as Oe}from"node:async_hooks";import{SpanStatusCode as ke,trace as Ae}from"#compiled/@opentelemetry/api/index.js";import{getErrorMessage as je}from"#compiled/@ai-sdk/provider/index.js";import{inspect as Me}from"node:util";import{fromError as Ne}from"#compiled/zod-validation-error/index.js";import{createRemoteJWKSet as Pe,decodeJwt as Fe,jwtVerify as Ie}from"#compiled/jose/index.js";import"ai";import Le from"#compiled/turndown/index.js";const Re=b.union([b.literal(`error`),b.literal(`warning`)]);b.object({code:b.string(),message:b.string(),severity:Re,sourcePath:b.string()}).strict();const ze=b.object({errors:b.number().finite(),warnings:b.number().finite()}).strict();function Be(e){return e}function E(e){return Be({...e,severity:`error`})}function Ve(e){return Be({...e,severity:`warning`})}function He(e){return e.reduce((e,t)=>(t.severity===`error`?e.errors+=1:e.warnings+=1,e),{errors:0,warnings:0})}function Ue(e){return e.some(e=>e.severity===`error`)}const We=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],Ge=[`package.json`,`vercel.json`],Ke=[`agent.ts`,`agent.cts`,`agent.mts`,`agent.js`,`agent.cjs`,`agent.mjs`,`instructions.md`,`instructions.ts`,`instructions.cts`,`instructions.mts`,`instructions.js`,`instructions.cjs`,`instructions.mjs`,`system.md`,`system.ts`,`system.cts`,`system.mts`,`system.js`,`system.cjs`,`system.mjs`],qe=[`channels`,`connections`,`hooks`,`lib`,`sandbox`,`skills`,`tools`,`schedules`,`subagents`],Je=[`agent.ts`,`agent.cts`,`agent.mts`,`agent.js`,`agent.cjs`,`agent.mjs`,`instructions.md`,`instructions.ts`,`instructions.cts`,`instructions.mts`,`instructions.js`,`instructions.cjs`,`instructions.mjs`,`system.md`,`system.ts`,`system.cts`,`system.mts`,`system.js`,`system.cjs`,`system.mjs`],Ye=[`hooks`,`lib`,`sandbox`,`skills`,`tools`,`subagents`],Xe=[`SKILL.md`],Ze=[`scripts`,`references`,`assets`],Qe=new Set(Ge);new Set(Ke),new Set(qe),new Set(Je),new Set(Ye),new Set(Xe),new Set(Ze);function D(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function $e(e,t){return t===`file`&&Qe.has(e)}function et(e,t){if(t===`file`)return A(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:A(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:A(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 tt(e,t){if(t===`file`)return A(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:A(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:A(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 nt(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 rt(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(e.endsWith(`.md`))return`flat-skill-markdown`;if(k(e)!==null)return`flat-skill-module`}return`unknown`}function O(e){return e.replaceAll(pe,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function k(e){for(let t of We)if(e.endsWith(t)&&e.length>t.length)return e.slice(0,-t.length);return null}function A(e,t){return k(e)===t}function j(e){let t=O(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}var it=e(t(),1);function at(e,t){let r=c(e,t);if(n(r,[`build`,`compaction`,`description`,`metadata`,`model`,`modelContextWindowTokens`,`modelOptions`],t),r.model===void 0)throw Error(`${t} The "model" field is required.`);let a={model:r.model};r.description!==void 0&&(a.description=u(r.description,t));let o=i(r,`metadata`,t);return o!==void 0&&(a.metadata=o),r.compaction!==void 0&&(a.compaction=lt(r.compaction,t)),r.build!==void 0&&(a.build=st(r.build,t)),r.modelOptions!==void 0&&(a.modelOptions=ct(r.modelOptions,t)),r.modelContextWindowTokens!==void 0&&(a.modelContextWindowTokens=ot(r.modelContextWindowTokens,t)),a}function ot(e,t){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(t);return e}function st(e,t){let r=c(e,t);n(r,[`externalDependencies`],t);let i={};if(r.externalDependencies!==void 0){if(!Array.isArray(r.externalDependencies))throw Error(t);i.externalDependencies=Object.freeze(r.externalDependencies.map(e=>u(e,t)))}return i}function ct(e,t){let r=c(e,t);n(r,[`providerOptions`],t);let i=r.providerOptions;return i===void 0?{}:{providerOptions:a(i,t)}}function lt(e,t){let r=c(e,t);n(r,[`model`,`modelContextWindowTokens`,`thresholdPercent`],t);let i={};if(r.model!==void 0&&(i.model=r.model),r.modelContextWindowTokens!==void 0&&(i.modelContextWindowTokens=ot(r.modelContextWindowTokens,t)),r.thresholdPercent!==void 0){let e=r.thresholdPercent;if(typeof e!=`number`||!Number.isFinite(e)||e<0||e>1)throw Error(t);i.thresholdPercent=e}return i}function ut(e,t){let r=c(e,t);return n(r,[`markdown`],t),{markdown:u(r.markdown,t)}}function dt(e,t){let r=c(e,t);n(r,[`description`,`files`,`license`,`markdown`,`metadata`],t);let a={description:u(r.description,t),markdown:u(r.markdown,t)},o=r.license,s=i(r,`metadata`,t);return o!==void 0&&(a.license=u(o,t)),s!==void 0&&(a.metadata=s),r.files!==void 0&&(a.files=ft(r.files,t)),a}function ft(e,t){let n=c(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 pt(e,t){let r=c(e,t);n(r,[`cron`,`markdown`,`run`],t);let i=u(r.cron,t),a=r.markdown!==void 0,s=r.run!==void 0;if(a&&s)throw Error(`${t} Pass either "markdown" (fire-and-forget) or "run" (handler) — not both.`);if(!a&&!s)throw Error(`${t} Must provide either "markdown" (fire-and-forget) or "run" (handler).`);let l={cron:i};return a?l.markdown=u(r.markdown,t):l.run=o(r.run,t),l}function mt(e){return e}function ht(e){return e}function gt(e){return e}const _t=/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/;function vt(e){if(!it.default.test(e))return{hasFrontmatter:!1,frontmatter:{},markdown:e};let t;try{t=(0,it.default)(e)}catch(t){throw St(e)&&!Ct(e)?Error(`Markdown frontmatter is missing a closing delimiter.`):t}if(!d(t.data))throw Error(`Markdown frontmatter must parse to an object.`);return{hasFrontmatter:!0,frontmatter:t.data,markdown:wt(t.content)}}function yt(e){return gt(ut({markdown:e},`Expected authored instructions markdown to match the public Ash shape.`))}function bt(e){let t=vt(e);if(!t.hasFrontmatter)throw Error(`Schedule markdown must start with YAML frontmatter declaring "cron".`);if(`run`in t.frontmatter)throw Error('Markdown-form schedules do not support the "run" frontmatter key. Use a TypeScript schedule (`<name>.ts`) to author a handler.');return mt(pt({...t.frontmatter,markdown:t.markdown},`Expected authored schedule markdown to match the public Ash shape.`))}function xt(e,t={}){let n=vt(e),r=t.slug;if(r===void 0&&!n.hasFrontmatter)throw Error(`Skill markdown must start with YAML frontmatter.`);let i=Dt(n.frontmatter),a=Ot(i.description,`description`),o=r===void 0?kt(i.description,`description`):a??t.description??jt(n.markdown,r),s={...i,description:o,markdown:n.markdown};return Tt(s,i),ht(dt(s,`Expected authored skill markdown to match the public Ash shape.`))}function St(e){return e.startsWith(`---
2
2
  `)||e.startsWith(`---\r
3
3
  `)}function Ct(e){return _t.test(e)}function wt(e){return e.replace(/^\r?\n/u,``)}function Tt(e,t){let n=Ot(t.license,`license`);n!==void 0&&(e.license=n);let r=At(t.metadata,`metadata`);r!==void 0&&(e.metadata=r)}const Et=[`name`];function Dt(e){let t={...e};for(let e of Et)delete t[e];return t}function Ot(e,t){if(e!=null){if(typeof e!=`string`)throw Error(`Expected "${t}" frontmatter to be a string.`);return e}}function kt(e,t){let n=Ot(e,t);if(n===void 0)throw Error(`Missing required "${t}" frontmatter.`);return n}function At(e,t){if(e==null)return;if(!d(e))throw Error(`Expected "${t}" frontmatter to be an object.`);let n=Object.entries(e).map(([e,n])=>{if(typeof n!=`string`)throw Error(`Expected "${t}.${e}" frontmatter to be a string.`);return[e,n]});return Object.fromEntries(n)}function jt(e,t){let n=e.split(/\r?\n/u).map(e=>e.trim()).find(e=>e!==``&&!e.startsWith("```"));return n===void 0?`Instructions for the ${t} skill.`:n.replace(/^[#>*\-\s]+/u,``).trim()||`Instructions for the ${t} skill.`}function Mt(e){let t=C(e.appRoot),n=C(e.agentRoot),r={agentId:e.agentId??Nt(t,n,e.packageName),agentRoot:n,appRoot:t,channels:[...e.channels??[]],connections:[...e.connections??[]],diagnosticsSummary:He(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 Nt(e,t,n){let r=O(fe(e,t));return r===``||r===`.`||r===`agent`?n??ue(e):ue(t)}function M(e){return O(e)}function N(e){let t=O(e.logicalPath),n={sourceKind:`module`,logicalPath:t,sourceId:e.sourceId??M(t)};return e.exportName!==void 0&&(n.exportName=e.exportName),n}function Pt(e){return{...N(e),connectionName:e.connectionName}}function Ft(e){let t=O(e.logicalPath);return{entryPath:e.entryPath,logicalPath:t,manifest:e.manifest,rootPath:e.rootPath,sourceId:e.sourceId??M(t),subagentId:e.subagentId}}function It(e){let t={description:e.description,sourceKind:`skill-package`,logicalPath:O(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}async function Lt(e){let t=O(e.logicalPath);return{definition:e.lower(await e.source.readTextFile(e.sourcePath),{name:j(t)}),sourceKind:`markdown`,logicalPath:t,sourceId:M(t)}}function Rt(e,t){let n={moduleFileNames:[]};for(let r of e)if(r.isFile()){if(t.markdownFileName!==void 0&&r.name===t.markdownFileName){n.markdownFileName=r.name;continue}t.moduleBaseName!==void 0&&k(r.name)===t.moduleBaseName&&n.moduleFileNames.push(r.name)}return n.moduleFileNames.sort((e,t)=>e.localeCompare(t)),n}function zt(e,t){let n=new Map;for(let r of e){if(!r.isFile())continue;let e=t.allowMarkdown?Bt(r.name):null,i=t.allowModules?k(r.name):null,a=e??i;if(a===null)continue;let o=n.get(a);if(o===void 0&&(o={moduleFileNames:[],slotName:a},n.set(a,o)),e!==null){o.markdownFileName=r.name;continue}i!==null&&o.moduleFileNames.push(r.name)}return[...n.values()].map(e=>(e.moduleFileNames.sort((e,t)=>e.localeCompare(t)),e)).sort((e,t)=>e.slotName.localeCompare(t.slotName))}function Bt(e){return!e.endsWith(`.md`)||e.length<=3?null:e.slice(0,-3)}async function P(e){let t=S(e.rootPath,e.directoryName),n=e.rootEntries.find(t=>t.name===e.directoryName);if(n===void 0)return{diagnostics:[],sources:[]};if(!n.isDirectory())return{diagnostics:[E({code:e.invalidDirectoryCode,message:e.invalidDirectoryMessage,sourcePath:t})],sources:[]};let r=[],i=[];return await Vt({allowMarkdown:e.allowMarkdown===!0,diagnostics:r,markdownLowerer:e.allowMarkdown===!0?e.markdownLowerer:void 0,projectSource:e.source,recursive:e.recursive,relativeDirectory:e.directoryName,rootDirectoryPath:t,sources:i,subdirectoryRelative:``,unsupportedEntryCode:e.unsupportedEntryCode,unsupportedEntryMessage:e.unsupportedEntryMessage,unsupportedFileCode:e.unsupportedFileCode,unsupportedFileMessage:e.unsupportedFileMessage,validateSegment:e.validateSegment}),{diagnostics:r,sources:i}}async function Vt(e){let t=e.subdirectoryRelative===``?e.rootDirectoryPath:S(e.rootDirectoryPath,e.subdirectoryRelative),n=await F(e.projectSource,t);e.recursive&&await Ht(e,n,t),(e.unsupportedFileCode!==void 0||e.unsupportedEntryCode!==void 0)&&Ut(e,n,t),await Wt(e,n,t)}async function Ht(e,t,n){for(let r of t){if(!r.isDirectory())continue;let t=S(n,r.name);if(e.validateSegment!==void 0){let n=e.validateSegment(r.name,t);if(n!==null){e.diagnostics.push(n);continue}}await Vt({allowMarkdown:e.allowMarkdown,diagnostics:e.diagnostics,markdownLowerer:e.markdownLowerer,projectSource:e.projectSource,recursive:e.recursive,relativeDirectory:e.relativeDirectory,rootDirectoryPath:e.rootDirectoryPath,sources:e.sources,subdirectoryRelative:e.subdirectoryRelative===``?r.name:S(e.subdirectoryRelative,r.name),unsupportedEntryCode:e.unsupportedEntryCode,unsupportedEntryMessage:e.unsupportedEntryMessage,unsupportedFileCode:e.unsupportedFileCode,unsupportedFileMessage:e.unsupportedFileMessage,validateSegment:e.validateSegment})}}function Ut(e,t,n){for(let r of t){let t=D(r),i=S(n,r.name);if(t===`directory`)continue;if(t===`other`){e.unsupportedEntryCode!==void 0&&e.diagnostics.push(E({code:e.unsupportedEntryCode,message:e.unsupportedEntryMessage?.(i,e.relativeDirectory)??`Expected "${i}" to be a regular file or directory within "${e.relativeDirectory}/".`,sourcePath:i}));continue}if(e.unsupportedFileCode===void 0)continue;let a=k(r.name)!==null,o=e.allowMarkdown&&r.name.endsWith(`.md`);a||o||e.diagnostics.push(E({code:e.unsupportedFileCode,message:e.unsupportedFileMessage?.(i,e.relativeDirectory)??`Expected "${i}" to be a supported authored source within "${e.relativeDirectory}/".`,sourcePath:i}))}}async function Wt(e,t,n){for(let r of zt(t,{allowMarkdown:e.allowMarkdown,allowModules:!0})){let t=e.subdirectoryRelative===``?r.slotName:S(e.subdirectoryRelative,r.slotName),i=O(S(e.relativeDirectory,t));if(e.validateSegment!==void 0){let t=r.markdownFileName??r.moduleFileNames[0]??r.slotName,i=e.validateSegment(r.slotName,S(n,t));if(i!==null){e.diagnostics.push(i);continue}}if(r.markdownFileName!==void 0&&r.moduleFileNames.length>0){e.diagnostics.push(on(n,i,[r.markdownFileName,...r.moduleFileNames]));continue}if(r.moduleFileNames.length>1){e.diagnostics.push(sn(n,i,r.moduleFileNames));continue}if(r.markdownFileName!==void 0){let t=e.subdirectoryRelative===``?r.markdownFileName:S(e.subdirectoryRelative,r.markdownFileName),n=O(S(e.relativeDirectory,t));if(e.markdownLowerer===void 0)continue;let i=await Lt({logicalPath:n,lower:e.markdownLowerer,source:e.projectSource,sourcePath:S(e.rootDirectoryPath,t)});e.sources.push(i);continue}let[a]=r.moduleFileNames;if(a===void 0)continue;let o=e.subdirectoryRelative===``?a:S(e.subdirectoryRelative,a);e.sources.push(N({logicalPath:O(S(e.relativeDirectory,o))}))}}const Gt=`discover/module-slot-collision`,Kt=`discover/tools-directory-invalid`,qt=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,Jt=/^[a-z][a-z0-9-]{0,63}$/,Yt=/^(\.?[a-z][a-z0-9-]{0,63}|\[[a-zA-Z][a-zA-Z0-9_]{0,63}\])$/,Xt=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;async function F(e,t){let n=[...await e.readDirectory(t)];return n.sort((e,t)=>e.name.localeCompare(t.name)),n}async function Zt(e){let t=await Qt({markdownFileName:`instructions.md`,moduleBaseName:`instructions`,rootEntries:e.rootEntries,rootPath:e.rootPath,slotLabel:`instructions`,source:e.source});if(t.diagnostics.length>0||t.source!==void 0)return{diagnostics:t.diagnostics,instructions:t.source};let n=await Qt({markdownFileName:`system.md`,moduleBaseName:`system`,rootEntries:e.rootEntries,rootPath:e.rootPath,slotLabel:`system`,source:e.source});if(n.source!==void 0){let t=n.source.sourceKind===`markdown`?`system.md`:n.source.logicalPath;return{diagnostics:[Ve({code:`discover/deprecated-system-slot`,message:`The "${t}" slot is deprecated. Rename it to "${t.replace(/^system/,`instructions`)}" — the runtime still loads the legacy slot for now, but support will be removed in a future release.`,sourcePath:S(e.rootPath,t)}),...n.diagnostics],instructions:n.source}}return n.diagnostics.length>0?{diagnostics:n.diagnostics}:e.required===!1?{diagnostics:[]}:{diagnostics:[E({code:`discover/required-instructions-missing`,message:`Expected one authored instructions prompt source at "instructions.md", "instructions.ts", "instructions.cts", "instructions.mts", "instructions.js", "instructions.cjs", or "instructions.mjs".`,sourcePath:e.rootPath})]}}async function Qt(e){let t=Rt(e.rootEntries,{markdownFileName:e.markdownFileName,moduleBaseName:e.moduleBaseName});if(t.markdownFileName!==void 0&&t.moduleFileNames.length>0)return{diagnostics:[on(e.rootPath,e.slotLabel,[t.markdownFileName,...t.moduleFileNames])]};if(t.moduleFileNames.length>1)return{diagnostics:[sn(e.rootPath,e.slotLabel,t.moduleFileNames)]};if(t.markdownFileName!==void 0)return{diagnostics:[],source:await Lt({logicalPath:e.markdownFileName,lower:yt,source:e.source,sourcePath:S(e.rootPath,t.markdownFileName)})};let[n]=t.moduleFileNames;return n===void 0?{diagnostics:[]}:{diagnostics:[],source:N({logicalPath:n})}}function $t(e){let t=Rt(e.rootEntries,{moduleBaseName:e.slotName});if(t.moduleFileNames.length>1)return{diagnostics:[sn(e.rootPath,e.slotName,t.moduleFileNames)]};let[n]=t.moduleFileNames;return n===void 0?e.missingDiagnostic===void 0?{diagnostics:[]}:{diagnostics:[E({code:e.missingDiagnostic.code,message:e.missingDiagnostic.message,sourcePath:e.rootPath})]}:{diagnostics:[],module:N({logicalPath:n})}}function en(e,t){return qt.test(e)?null:E({code:`discover/tool-name-invalid`,message:`Tool filename "${e}" is not a legal tool name. Expected ASCII letters, digits, underscores, and dashes only, starting with a letter, up to 64 characters.`,sourcePath:t})}function tn(e,t){return Jt.test(e)?null:E({code:`discover/connection-name-invalid`,message:`Connection filename "${e}" is not a legal connection name. Expected lowercase ASCII letters, digits, and dashes only, starting with a letter, up to 64 characters.`,sourcePath:t})}function nn(e,t){return Yt.test(e)?null:E({code:`discover/channel-name-invalid`,message:`Channel path segment "${e}" is not a legal channel name. Expected lowercase kebab-case (\`my-channel\`), optionally with a leading dot (\`.well-known\`), or a path parameter form (\`[sessionId]\`).`,sourcePath:t})}function rn(e,t){return Xt.test(e)?null:E({code:`discover/hook-name-invalid`,message:`Hook path segment "${e}" is not a legal hook name. Expected ASCII letters, digits, underscores, and dashes only, starting with a letter, up to 64 characters.`,sourcePath:t})}function an(e){return e.rootEntries.flatMap(t=>!t.isDirectory()||e.classifyEntry(t.name,D(t))!==`unknown`?[]:[Ve({code:`discover/unsupported-directory`,message:e.createUnsupportedDirectoryMessage(t.name),sourcePath:S(e.rootPath,t.name)})])}function on(e,t,n){return E({code:`discover/slot-collision`,message:`Found conflicting authored sources for "${t}": ${cn(n)}.`,sourcePath:e})}function sn(e,t,n){return E({code:Gt,message:`Found multiple authored module sources for "${t}": ${cn(n)}.`,sourcePath:e})}function cn(e){return e.map(e=>`"${e}"`).join(`, `)}async function ln(e){let t=`connections`,n=S(e.rootPath,t),r=e.rootEntries.find(e=>e.name===t);if(r===void 0)return{connections:[],diagnostics:[]};if(!r.isDirectory())return{connections:[],diagnostics:[E({code:`discover/connections-directory-invalid`,message:`Expected "${n}" to be a directory of authored connections.`,sourcePath:n})]};let i=await F(e.source,n),a=[],o=[],s=new Set;for(let e of zt(i,{allowMarkdown:!1,allowModules:!0})){let r=O(S(t,e.slotName));if(e.moduleFileNames.length>1){s.add(e.slotName),o.push(sn(n,r,e.moduleFileNames));continue}let[i]=e.moduleFileNames;if(i===void 0)continue;s.add(e.slotName);let c=tn(e.slotName,S(n,i));if(c!==null){o.push(c);continue}a.push(Pt({connectionName:e.slotName,logicalPath:S(t,i)}))}for(let r of i){if(!r.isDirectory())continue;let i=r.name,c=S(n,i);if(s.has(i)){o.push(E({code:`discover/connection-file-folder-collision`,message:`Connection "${i}" is defined twice. Found both file-form "connections/${i}.ts" and folder-form "connections/${i}/". Use one form, not both.`,sourcePath:c}));let e=a.findIndex(e=>e.connectionName===i);e!==-1&&a.splice(e,1);continue}let l=tn(i,c);if(l!==null){o.push(l);continue}let u=un(await F(e.source,c));if(u.length>1){o.push(E({code:Gt,message:`Found multiple connection definition modules inside "${O(S(t,i))}": `+u.map(e=>`"${e}"`).join(`, `),sourcePath:c}));continue}let[d]=u;if(d===void 0){o.push(E({code:`discover/connection-folder-empty`,message:`Connection folder "connections/${i}/" contains no "connection.ts" definition. Add "connections/${i}/connection.ts" or use the file form "connections/${i}.ts".`,sourcePath:c}));continue}a.push(Pt({connectionName:i,logicalPath:S(t,i,d)}))}return{connections:a,diagnostics:o}}function un(e){let t=e.filter(e=>e.isFile()),n=[];for(let e of zt(t,{allowMarkdown:!1,allowModules:!0}))e.slotName===`connection`&&n.push(...e.moduleFileNames);return n}const dn=`discover/lib-entry-unsupported`;async function fn(e){let t=await P({directoryName:`lib`,invalidDirectoryCode:`discover/lib-directory-invalid`,invalidDirectoryMessage:`Expected "${e.agentRoot}/lib" to be a directory of authored helper modules.`,recursive:!0,rootEntries:e.rootEntries,rootPath:e.agentRoot,source:e.source,unsupportedEntryCode:dn,unsupportedEntryMessage:e=>`Expected "${e}" to be a supported authored module within "lib/".`,unsupportedFileCode:dn,unsupportedFileMessage:e=>`Expected "${e}" to be a supported authored module within "lib/".`});return{diagnostics:t.diagnostics,lib:t.sources}}function I(){return{kind:`disk`,async readDirectory(e){return await _e(e,{withFileTypes:!0})},async readTextFile(e){return await ge(e,`utf8`)},async stat(e){try{let t=await ye(e);return t.isDirectory()?`directory`:t.isFile()?`file`:`other`}catch{return`missing`}}}}const L=`sandbox`,pn=`workspace`,mn=`sandbox`;async function hn(e){let t=[],n=e.rootEntries.find(e=>e.name===L);if(n===void 0)return gn({diagnostics:t,rootEntries:e.rootEntries,rootPath:e.rootPath});let r=S(e.rootPath,L);if(!n.isDirectory())return t.push(E({code:`discover/sandbox-directory-invalid`,message:`Expected "${r}" to be the sandbox folder.`,sourcePath:r})),{diagnostics:t,sandbox:null,sandboxWorkspace:null};let i=await F(e.source,r),a=_n(i),o=i.find(e=>e.name===pn&&e.isDirectory());if(a.length>1)return t.push(E({code:Gt,message:`Found multiple sandbox definition modules inside "${O(L)}": `+a.map(e=>`"${e}"`).join(`, `),sourcePath:r})),{diagnostics:t,sandbox:null,sandboxWorkspace:null};let[s]=a,c=s!==void 0,l=o!==void 0;if(!c&&!l)return t.push(E({code:`discover/sandbox-folder-empty`,message:`Sandbox folder "sandbox/" contains neither a "sandbox.<ext>" definition nor a "workspace/" subdirectory. Add one or the other, or remove the folder.`,sourcePath:r})),{diagnostics:t,sandbox:null,sandboxWorkspace:null};let u=null;c&&(u=N({logicalPath:S(L,s)}));let d=null;if(l){let n=S(r,pn),i=O(S(L,pn)),a=await yn(e.source,n);a===null?d={logicalPath:i,rootEntries:await vn(e.source,n),sourceId:M(i),sourcePath:n}:t.push(a)}return{diagnostics:t,sandbox:u,sandboxWorkspace:d}}function gn(e){let t=Rt(e.rootEntries,{moduleBaseName:mn});if(t.moduleFileNames.length>1)return e.diagnostics.push(E({code:Gt,message:`Found multiple top-level sandbox definition modules: `+t.moduleFileNames.map(e=>`"${e}"`).join(`, `),sourcePath:e.rootPath})),{diagnostics:e.diagnostics,sandbox:null,sandboxWorkspace:null};let[n]=t.moduleFileNames;return n===void 0?{diagnostics:e.diagnostics,sandbox:null,sandboxWorkspace:null}:{diagnostics:e.diagnostics,sandbox:N({logicalPath:n}),sandboxWorkspace:null}}function _n(e){let t=e.filter(e=>e.isFile()),n=[];for(let e of zt(t,{allowMarkdown:!1,allowModules:!0}))e.slotName===mn&&n.push(...e.moduleFileNames);return n}async function vn(e,t){let n=await F(e,t),r=[];for(let e of n){if(e.isDirectory()){r.push(`${e.name}/`);continue}e.isFile()&&r.push(e.name)}return r}async function yn(e,t){return(await F(e,t)).find(e=>e.name===`skills`)===void 0?null:E({code:`discover/sandbox-workspace-skills-reserved`,message:`"sandbox/workspace/skills/" is reserved for the framework skill discovery. Move skill files under "agent/skills/" instead, or rename the subtree.`,sourcePath:S(t,`skills`)})}const bn=`discover/skill-frontmatter-invalid`;async function xn(e){let t=e.source??I(),n=C(e.agentRoot),r=C(e.skillsDirectoryPath??S(n,`skills`)),i=O(e.skillsLogicalPath??fe(n,r)),a=await t.stat(r);if(a===`missing`)return{diagnostics:[],skills:[]};if(a!==`directory`)return{diagnostics:[E({code:`discover/skills-directory-invalid`,message:`Expected "${r}" to be a directory of authored skills.`,sourcePath:r})],skills:[]};let o=[],s=new Set,c=new Map,l=await F(t,r);for(let e of l){let n=await Sn({entryName:e.name,entryType:D(e),skillsDirectoryPath:r,skillsLogicalPath:i,source:t});if(o.push(...n.diagnostics),n.skill===null||n.skillId===null||s.has(n.skillId))continue;let a=c.get(n.skillId);if(a!==void 0){o.push(E({code:`discover/skill-collision`,message:`Found conflicting authored skill sources for "${n.skillId}": "${a.logicalPath}" and "${n.logicalPath}".`,sourcePath:S(r,n.skillId)})),s.add(n.skillId),c.delete(n.skillId);continue}c.set(n.skillId,{logicalPath:n.logicalPath,skill:n.skill})}return{diagnostics:o,skills:[...c.values()].map(e=>e.skill)}}async function Sn(e){let t=S(e.skillsDirectoryPath,e.entryName);switch(rt(e.entryName,e.entryType)){case`skill-package-directory`:return Cn({logicalSkillsPath:e.skillsLogicalPath,skillId:e.entryName,skillRootPath:t,source:e.source});case`flat-skill-markdown`:return wn({logicalSkillsPath:e.skillsLogicalPath,skillFileName:e.entryName,skillFilePath:t,source:e.source});case`flat-skill-module`:return Tn({logicalSkillsPath:e.skillsLogicalPath,skillFileName:e.entryName});default:return{diagnostics:[E({code:`discover/skill-entry-not-directory`,message:`Expected "${t}" to be a skill directory containing SKILL.md or a flat ".md", ".ts", ".cts", ".mts", ".js", ".cjs", or ".mjs" skill file.`,sourcePath:t})],logicalPath:O(S(e.skillsLogicalPath,e.entryName)),skill:null,skillId:null}}}async function Cn(e){let t=S(e.skillRootPath,`SKILL.md`),n=O(S(e.logicalSkillsPath,e.skillId,`SKILL.md`));if(await e.source.stat(t)!==`file`)return{diagnostics:[E({code:`discover/skill-markdown-missing`,message:`Expected "${t}" to exist for the "${e.skillId}" skill.`,sourcePath:e.skillRootPath})],logicalPath:n,skill:null,skillId:null};let r;try{r=xt(await e.source.readTextFile(t))}catch(e){return{diagnostics:[E({code:bn,message:Dn(t,e),sourcePath:t})],logicalPath:n,skill:null,skillId:null}}let i=await En(e.source,e.skillRootPath),a={description:r.description,logicalPath:n,markdown:r.markdown,name:e.skillId,rootPath:e.skillRootPath,skillFilePath:t,skillId:e.skillId,sourceId:M(n)};return i.assetsPath!==void 0&&(a.assetsPath=i.assetsPath),r.license!==void 0&&(a.license=r.license),r.metadata!==void 0&&(a.metadata=r.metadata),i.referencesPath!==void 0&&(a.referencesPath=i.referencesPath),i.scriptsPath!==void 0&&(a.scriptsPath=i.scriptsPath),{diagnostics:[],logicalPath:n,skill:It(a),skillId:e.skillId}}async function wn(e){let t=On(e.skillFileName),n=O(S(e.logicalSkillsPath,e.skillFileName)),r;try{r=xt(await e.source.readTextFile(e.skillFilePath),{slug:t})}catch(t){return{diagnostics:[E({code:bn,message:Dn(e.skillFilePath,t),sourcePath:e.skillFilePath})],logicalPath:n,skill:null,skillId:null}}return{diagnostics:[],logicalPath:n,skill:{definition:r,sourceKind:`markdown`,logicalPath:n,sourceId:M(n)},skillId:t}}async function Tn(e){let t=k(e.skillFileName),n=O(S(e.logicalSkillsPath,e.skillFileName));return t===null?{diagnostics:[],logicalPath:n,skill:null,skillId:null}:{diagnostics:[],logicalPath:n,skill:N({logicalPath:n}),skillId:t}}async function En(e,t){let n=await e.readDirectory(t),r={};for(let e of n)if(e.isDirectory())switch(nt(e.name,D(e))){case`skill-assets-directory`:r.assetsPath=S(t,e.name);break;case`skill-references-directory`:r.referencesPath=S(t,e.name);break;case`skill-scripts-directory`:r.scriptsPath=S(t,e.name);break;default:break}return r}function Dn(e,t){return`Invalid authored skill frontmatter in "${e}": ${p(t)}`}function On(e){return e.endsWith(`.md`)?e.slice(0,-3):e}async function kn(e){let t=e.source??I(),n=C(e.agentRoot),r=C(e.subagentsDirectoryPath??S(n,`subagents`)),i=O(e.subagentsLogicalPath??fe(n,r)),a=await t.stat(r);if(a===`missing`)return{diagnostics:[],subagents:[]};if(a!==`directory`)return{diagnostics:[E({code:`discover/subagents-directory-invalid`,message:`Expected "${r}" to be a directory of authored subagents.`,sourcePath:r})],subagents:[]};let o=await F(t,r),s=[],c=[];for(let a of o){if(a.isFile()){let t=k(a.name);if(t===null)continue;c.push(An({agentRoot:n,appRoot:e.appRoot,subagentId:t,subagentLogicalPath:S(i,a.name),subagentPath:S(r,a.name)}));continue}if(!a.isDirectory())continue;let o=await jn({appRoot:e.appRoot,source:t,subagentId:a.name,subagentLogicalPath:S(i,a.name),subagentRoot:S(r,a.name)});s.push(...o.diagnostics),c.push(o.subagent)}return{diagnostics:s,subagents:c}}function An(e){let t=N({logicalPath:e.subagentLogicalPath}),n=Mt({agentId:e.subagentId,agentRoot:e.agentRoot,appRoot:e.appRoot,configModule:t});return Ft({entryPath:e.subagentPath,logicalPath:e.subagentLogicalPath,manifest:n,rootPath:e.agentRoot,subagentId:e.subagentId})}async function jn(e){let t=[],n=await F(e.source,e.subagentRoot);t.push(...an({classifyEntry:tt,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the local subagent root.`},rootEntries:n,rootPath:e.subagentRoot}));let r=await Zt({required:!1,rootEntries:n,rootPath:e.subagentRoot,source:e.source});t.push(...r.diagnostics);let i=$t({missingDiagnostic:{code:`discover/required-subagent-config-module-missing`,message:`Expected one authored subagent config module at "agent.ts", "agent.cts", "agent.mts", "agent.js", "agent.cjs", or "agent.mjs".`},rootEntries:n,rootPath:e.subagentRoot,slotName:`agent`});t.push(...i.diagnostics);let a=await ln({rootEntries:n,rootPath:e.subagentRoot,source:e.source});t.push(...a.diagnostics);let o=await hn({rootEntries:n,rootPath:e.subagentRoot,source:e.source});t.push(...o.diagnostics);let s=await P({directoryName:`tools`,invalidDirectoryCode:Kt,invalidDirectoryMessage:`Expected "${S(e.subagentRoot,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:n,rootPath:e.subagentRoot,source:e.source,validateSegment:en});t.push(...s.diagnostics);let c=await P({directoryName:`hooks`,invalidDirectoryCode:Pn,invalidDirectoryMessage:`Expected "${S(e.subagentRoot,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:n,rootPath:e.subagentRoot,source:e.source,validateSegment:rn});t.push(...c.diagnostics);let l=await fn({agentRoot:e.subagentRoot,rootEntries:n,source:e.source});t.push(...l.diagnostics),t.push(...Mn(e.subagentRoot,n));let u=await xn({agentRoot:e.subagentRoot,source:e.source});t.push(...u.diagnostics);let d=await kn({agentRoot:e.subagentRoot,appRoot:e.appRoot,source:e.source});t.push(...d.diagnostics);let f={agentRoot:e.subagentRoot,appRoot:e.appRoot,connections:a.connections,diagnostics:t,hooks:c.sources,lib:l.lib,instructions:r.instructions,sandbox:o.sandbox,sandboxWorkspaces:o.sandboxWorkspace===null?[]:[o.sandboxWorkspace],skills:u.skills,tools:s.sources,subagents:d.subagents};i.module!==void 0&&(f.configModule=i.module);let p=Mt(f);return{diagnostics:t,subagent:Ft({entryPath:e.subagentRoot,logicalPath:e.subagentLogicalPath,manifest:p,rootPath:e.subagentRoot,subagentId:e.subagentId})}}function Mn(e,t){return t.flatMap(t=>tt(t.name,D(t))===`invalid-schedules-directory`?[E({code:`discover/local-subagent-schedules-invalid`,message:`Local subagent packages cannot define schedules at "${S(e,t.name)}".`,sourcePath:S(e,t.name)})]:[])}async function Nn(e){let t=await P({allowMarkdown:!0,directoryName:`schedules`,invalidDirectoryCode:`discover/schedules-directory-invalid`,invalidDirectoryMessage:`Expected "${S(e.agentRoot,`schedules`)}" to be a directory of authored schedules.`,markdownLowerer:e=>bt(e),recursive:!0,rootEntries:e.rootEntries,rootPath:e.agentRoot,source:e.source,unsupportedFileCode:`discover/schedule-file-unsupported`,unsupportedFileMessage:e=>`Expected "${e}" to be a TypeScript or markdown schedule file within "schedules/".`});return{diagnostics:t.diagnostics,schedules:t.sources}}const Pn=`discover/hooks-directory-invalid`;async function Fn(e){let t=e.source??I(),n=C(e.appRoot),r=C(e.agentRoot),i=[],a=await In(t,n),o=await F(t,r);i.push(...an({classifyEntry:et,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the agent root.`},rootEntries:o,rootPath:r}));let s=await Zt({rootEntries:o,rootPath:r,source:t});i.push(...s.diagnostics);let c=$t({rootEntries:o,rootPath:r,slotName:`agent`});i.push(...c.diagnostics);let l=await P({directoryName:`channels`,invalidDirectoryCode:`discover/channels-directory-invalid`,invalidDirectoryMessage:`Expected "${S(r,`channels`)}" to be a directory of authored channels.`,recursive:!0,rootEntries:o,rootPath:r,source:t,validateSegment:nn});i.push(...l.diagnostics);let u=await fn({agentRoot:r,rootEntries:o,source:t});i.push(...u.diagnostics);let d=await Nn({agentRoot:r,rootEntries:o,source:t});i.push(...d.diagnostics);let f=await ln({rootEntries:o,rootPath:r,source:t});i.push(...f.diagnostics);let p=await hn({rootEntries:o,rootPath:r,source:t});i.push(...p.diagnostics);let m=await P({directoryName:`tools`,invalidDirectoryCode:Kt,invalidDirectoryMessage:`Expected "${S(r,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:o,rootPath:r,source:t,validateSegment:en});i.push(...m.diagnostics);let h=await P({directoryName:`hooks`,invalidDirectoryCode:Pn,invalidDirectoryMessage:`Expected "${S(r,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:o,rootPath:r,source:t,validateSegment:rn});i.push(...h.diagnostics);let g=await xn({agentRoot:r,source:t});i.push(...g.diagnostics);let _=await kn({agentRoot:r,appRoot:n,source:t});i.push(..._.diagnostics);let v={agentRoot:r,appRoot:n,channels:l.sources,connections:f.connections,packageName:a,diagnostics:i,hooks:h.sources,lib:u.lib,instructions:s.instructions,sandbox:p.sandbox,sandboxWorkspaces:p.sandboxWorkspace===null?[]:[p.sandboxWorkspace],schedules:d.schedules,skills:g.skills,tools:m.sources,subagents:_.subagents};return c.module!==void 0&&(v.configModule=c.module),{diagnostics:i,manifest:Mt(v)}}async function In(e,t){try{let n=S(t,`package.json`),r=JSON.parse(await e.readTextFile(n)).name;if(typeof r!=`string`||r.length===0)return;let i=r.lastIndexOf(`/`);return i===-1?r:r.slice(i+1)}catch{return}}var Ln=class extends Error{diagnostic;constructor(e){super(e.message),this.name=`DiscoveryProjectResolutionError`,this.diagnostic=e}};async function Rn(e=process.cwd(),t={}){let n=t.source??I(),r=await zn(n,e),i=r;for(;;){let e=await Bn(n,i);if(e!==null)return e;let t=await Vn(n,i);if(t!==null)return t;if(await Hn(n,i))return{agentRoot:i,appRoot:i,layout:`flat`};let r=x(i);if(r===i)break;i=r}throw new Ln(E({code:`discover/project-not-found`,message:`Could not resolve an Ash agent root from "${r}".`,sourcePath:r}))}async function zn(e,t){let n=C(t);return await e.stat(n)===`directory`?n:x(n)}async function Bn(e,t){if(ue(t)!==`agent`)return null;let n=x(t);return await Un(e,n)?{agentRoot:t,appRoot:n,layout:`nested`}:null}async function Vn(e,t){if(!await Un(e,t))return null;let n=S(t,`agent`);return await Gn(e,n)?{agentRoot:n,appRoot:t,layout:`nested`}:null}async function Hn(e,t){let n=await Wn(e,t);return Array.from(n.entries()).some(([e,t])=>{let n=et(e,t);return n!==`unknown`&&n!==`lib-directory`})}async function Un(e,t){let n=await Wn(e,t);return Array.from(n.entries()).some(([e,t])=>$e(e,t))}async function Wn(e,t){if(await e.stat(t)!==`directory`)return new Map;let n=await e.readDirectory(t);return new Map(n.map(e=>[e.name,D(e)]))}async function Gn(e,t){return await e.stat(t)===`directory`}const Kn=b.object({description:b.string(),entryPath:b.string(),exportName:b.string().optional(),logicalPath:b.string(),name:b.string(),nodeId:b.string(),path:b.string(),rootPath:b.string(),sourceId:b.string(),sourceKind:b.literal(`module`),url:b.string()}).strict(),qn=`ash-agent-compiled-manifest`,R=`__root__`,Jn=b.object({exportName:b.string().optional(),sourceKind:b.literal(`module`),logicalPath:b.string(),sourceId:b.string()}).strict(),Yn=b.union([b.literal(`GET`),b.literal(`POST`),b.literal(`PUT`),b.literal(`DELETE`),b.literal(`PATCH`)]),Xn=b.object({kind:b.literal(`channel`),name:b.string(),logicalPath:b.string(),method:Yn,urlPath:b.string(),sourceId:b.string(),sourceKind:b.literal(`module`),exportName:b.string().optional(),adapterKind:b.string().optional()}).strict(),Zn=b.object({kind:b.literal(`disabled`),name:b.string(),logicalPath:b.string()}).strict(),Qn=b.union([Xn,Zn]),$n=b.object({contextWindowTokens:b.number().int().positive().optional(),id:b.string(),source:Jn.optional(),providerOptions:ce.optional()}).strict(),er=b.object({externalDependencies:b.array(b.string()).optional()}).strict(),tr=b.object({model:$n.optional(),thresholdPercent:b.number().finite().min(0).max(1).optional()}).strict(),nr=b.object({build:er.optional(),compaction:tr.optional(),description:b.string().optional(),metadata:b.record(b.string(),b.string()),model:$n,name:b.string(),source:Jn.optional()}).strict(),rr=b.object({name:b.string(),logicalPath:b.string(),markdown:b.string(),sourceId:b.string(),sourceKind:b.union([b.literal(`markdown`),b.literal(`module`)])}).strict(),ir={name:b.string(),description:b.string(),license:b.string().optional(),markdown:b.string(),metadata:b.record(b.string(),b.string()).optional(),sourceId:b.string(),logicalPath:b.string()},ar=b.discriminatedUnion(`sourceKind`,[b.object({...ir,sourceKind:b.literal(`markdown`)}).strict(),b.object({...ir,sourceKind:b.literal(`module`),exportName:b.string().optional()}).strict(),b.object({...ir,sourceKind:b.literal(`skill-package`),skillId:b.string(),skillFilePath:b.string(),rootPath:b.string(),assetsPath:b.string().optional(),referencesPath:b.string().optional(),scriptsPath:b.string().optional()}).strict()]),or=b.object({cron:b.string(),hasRun:b.boolean(),name:b.string(),logicalPath:b.string(),markdown:b.string().optional(),sourceId:b.string(),sourceKind:b.union([b.literal(`markdown`),b.literal(`module`)])}).strict(),sr=b.object({description:b.string().optional(),exportName:b.string().optional(),logicalPath:b.string(),sourceId:b.string(),sourceKind:b.literal(`module`)}).strict(),cr=b.object({logicalPath:b.string(),rootEntries:b.array(b.string()).readonly(),sourceId:b.string(),sourcePath:b.string()}).strict(),lr=b.object({logicalPath:b.string(),rootEntries:b.array(b.string()).readonly()}).strict(),ur=b.object({connectionName:b.string(),description:b.string(),exportName:b.string().optional(),logicalPath:b.string(),sourceId:b.string(),sourceKind:b.literal(`module`),url:b.string(),vercelConnect:b.object({connector:b.string()}).strict().optional()}).strict(),dr=b.object({description:b.string(),exportName:b.string().optional(),inputSchema:ce.nullable(),logicalPath:b.string(),name:b.string(),sourceId:b.string(),sourceKind:b.literal(`module`)}).strict(),fr=b.object({exportName:b.string().optional(),logicalPath:b.string(),slug:b.string(),sourceId:b.string(),sourceKind:b.literal(`module`)}).strict(),pr=b.object({agentRoot:b.string(),appRoot:b.string(),channels:b.array(Qn),config:nr,connections:b.array(ur),diagnosticsSummary:ze,disabledFrameworkTools:b.array(b.string()).readonly(),hooks:b.array(fr),sandbox:sr.nullable(),sandboxWorkspaces:b.array(cr),schedules:b.array(or),remoteAgents:b.array(Kn),skills:b.array(ar).readonly(),instructions:rr.optional(),tools:b.array(dr),workspaceResourceRoot:lr}).strict(),mr=b.object({agent:pr,description:b.string(),entryPath:b.string(),logicalPath:b.string(),name:b.string(),nodeId:b.string(),rootPath:b.string(),sourceId:b.string(),sourceKind:b.literal(`module`),exportName:b.string().optional()}).strict(),hr=b.object({childNodeId:b.string(),parentNodeId:b.string()}).strict(),gr=b.object({agentRoot:b.string(),appRoot:b.string(),channels:b.array(Qn),config:nr,connections:b.array(ur),diagnosticsSummary:ze,disabledFrameworkTools:b.array(b.string()).readonly(),hooks:b.array(fr),kind:b.literal(qn),remoteAgents:b.array(Kn),sandbox:sr.nullable(),sandboxWorkspaces:b.array(cr),schedules:b.array(or),skills:b.array(ar).readonly(),subagentEdges:b.array(hr),subagents:b.array(mr),instructions:rr.optional(),tools:b.array(dr),version:b.literal(24),workspaceResourceRoot:lr}).strict();function _r(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:xr(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,metadata:{...e.config.metadata},model:xr(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:vr({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function vr(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 yr(e,t){return e===`__root__`?t:`${e}::${t}`}function br(e){return{..._r(e),kind:qn,subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:24}}function xr(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 Sr=/^\/?[A-Za-z]:[\\/]/,Cr=/^\\\\[^\\]/,wr=/(\b(?:from|import)\s*(?:\(\s*)?)(["'])([A-Za-z]:[\\/][^"'\n\r]*)\2/g;function Tr(e){return Sr.test(e)||Cr.test(e)}function Er(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 Dr(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 Or(e){if(e.startsWith(`file://`))return e;let{path:t,suffix:n}=Dr(e);return Tr(t)?`${Er(t)}${n}`:e.replaceAll(`\\`,`/`)}function kr(e){return JSON.stringify(Or(e))}function Ar(e){return e.replace(wr,(e,t,n,r)=>`${t}${n}${Or(r)}${n}`)}const jr=b.object({modules:b.record(b.string(),b.object({}).passthrough())}).strict(),Mr=b.object({nodes:b.record(b.string(),jr)}).strict();function Nr(e){let t=zr(e.moduleMapPath),n=e.importSpecifierStyle??`relative`,r=0,i=[Pr({agentRoot:e.manifest.agentRoot,importSpecifierStyle:n,manifest:e.manifest,moduleMapDirectory:t,nextBindingName(){return`module_${r++}`},nodeId:R}),...[...e.manifest.subagents].sort((e,t)=>e.nodeId.localeCompare(t.nodeId)).map(e=>Pr({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 = ${Lr(i)};`,``,`export default moduleMap;`,``].join(`
4
4
  `)}function Pr(e){return{modules:Fr(e.manifest).sort((e,t)=>e.sourceId.localeCompare(t.sourceId)).map(t=>({bindingName:e.nextBindingName(),importSpecifier:Ir({fromDirectory:e.moduleMapDirectory,importSpecifierStyle:e.importSpecifierStyle,targetPath:Br(e.agentRoot,t.logicalPath)}),sourceId:t.sourceId})),nodeId:e.nodeId}}function Fr(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 Ir(e){if(e.importSpecifierStyle===`absolute`)return Or(Hr(e.targetPath));let t=Vr(e.fromDirectory,e.targetPath);return t.startsWith(`.`)?t:`./${t}`}function Lr(e){return Rr([{key:`nodes`,value:Rr(e.map(e=>({key:e.nodeId,value:Rr([{key:`modules`,value:Rr(e.modules.map(e=>({key:e.sourceId,value:e.bindingName})))}],3)})))}],0)}function Rr(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(`
@@ -86,4 +86,4 @@ ${e}`}}function mc(e){let t=new URL(e.url).searchParams.get(`startIndex`);if(t==
86
86
  `),execute:Fl,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`},Ll={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 Rl(e){let{filePath:t,content:n}=e;jc(t);let r=await J(),i=H(),a=Y(t),o=Hc(a),s=await r.readTextFile({path:t});if(s===null)return await r.writeTextFile({content:n,path:t}),Wc(i,o,Uc({content:n,filePath:a})),{existed:!1,path:a};let c=i.ensure(Vc,()=>({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=Uc({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}),Wc(i,o,Uc({content:n,filePath:a})),{existed:!0,path:a}}const zl={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 Bl(e){return Rl(e)}const Vl=[Ac,Bc,nl,ul,ml,{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(`
87
87
  `),execute:Bl,inputSchema:zl,logicalPath:`ash:framework/write-file`,name:`write_file`,sourceId:`ash:write-file-tool`,sourceKind:`module`},El,Il,Ll,xl,ns],Hl=new Map([[ns,e=>e.hasConnections]]);function Ul(e){return Vl.filter(t=>{let n=Hl.get(t);return n===void 0||n(e)})}function Wl(){return new Set(Vl.map(e=>e.name))}function Gl(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 Z=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 Kl(e){return{exportName:e.exportName,logicalPath:e.logicalPath,sourceId:e.sourceId,sourceKind:`module`}}async function Q(e){let t=e.nodeId??`__root__`,n=e.moduleMap.nodes[t]?.modules[e.definition.sourceId];if(n===void 0)throw new Z(`Missing compiled module namespace for ${e.kindLabel} source "${e.definition.sourceId}" in node "${t}".`,{logicalPath:e.definition.logicalPath,sourceId:e.definition.sourceId});return await s(r(c(n,`Missing compiled module namespace for ${e.kindLabel} source "${e.definition.sourceId}" in node "${t}".`),{exportName:e.definition.exportName,logicalPath:e.definition.logicalPath}))}async function ql(e,t,n){try{let r=li(await Q({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=Kl({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 Z?t:new Z(`Failed to attach the channel definition from "${e.logicalPath}": ${p(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}async function Jl(e,t,n){try{let r=c(await Q({definition:e,kindLabel:`connection`,moduleMap:t,nodeId:n}),`Expected the connection export "${e.exportName??`default`}" from "${e.logicalPath}" to return an object.`);Yi(`connection:${r.url}`,{kind:`connection`,name:e.connectionName});let i=r.auth!==void 0,a=r.headers!==void 0,o={connectionName:e.connectionName,description:e.description,exportName:e.exportName,logicalPath:e.logicalPath,sourceId:e.sourceId,sourceKind:`module`,url:e.url};if(i)try{o.authorization=mi(r.auth,`Connection "${e.connectionName}" at "${e.logicalPath}":`)}catch(t){throw new Z(p(t),{logicalPath:e.logicalPath,sourceId:e.sourceId})}return a&&(o.headers=r.headers),r.tools!==void 0&&(o.tools=r.tools),typeof r.approval==`function`&&(o.approval=r.approval),o}catch(t){throw t instanceof Z?t:new Z(`Failed to resolve connection "${e.connectionName}" from "${e.logicalPath}": ${p(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}async function Yl(e,t,n){try{let r=c(await Q({definition:e,kindLabel:`hook`,moduleMap:t,nodeId:n}),Xl(e,`to return an object`)),i={},a={},s=r.lifecycle;if(s!==void 0){let t=c(s,Xl(e,"to expose `lifecycle` as an object"));for(let n of[`session`,`turn`]){let r=t[n];r!==void 0&&(i[n]=o(r,Xl(e,`to provide a function for "lifecycle.${n}"`)))}}let l=r.events;if(l!==void 0){let t=c(l,Xl(e,"to expose `events` as an object"));for(let[n,r]of Object.entries(t))r!==void 0&&(a[n]=o(r,Xl(e,`to provide a function for "events.${n}"`)))}return{events:a,exportName:e.exportName,lifecycle:i,logicalPath:e.logicalPath,slug:e.slug,sourceId:e.sourceId,sourceKind:`module`}}catch(t){throw t instanceof Z?t:new Z(`Failed to attach hook handlers from "${e.logicalPath}": ${p(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}function Xl(e,t){return`Expected the hook export "${e.exportName??`default`}" from "${e.logicalPath}" ${t}.`}var Zl=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 Ql(e){let t=[];for await(let n of e)t.push(n);return Buffer.concat(t)}function $l(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}function eu(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 Ql(n)},async readTextFile(t){tu(t);let n=await e.readFile({abortSignal:t.abortSignal,path:e.resolvePath(t.path)});return n===null?null:ru(iu(await Ql(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:$l(t.content),path:e.resolvePath(t.path)})},async writeTextFile(t){let n=au(t.content,t.encoding??`utf-8`);await e.writeFile({abortSignal:t.abortSignal,content:$l(n),path:e.resolvePath(t.path)})}}}function tu(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 nu(e){let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`\r`?r+1<e.length&&e[r+1]===`
88
88
  `?(t.push(e.slice(n,r+2)),n=r+2,r++):(t.push(e.slice(n,r+1)),n=r+1):e[r]===`
89
- `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}function ru(e,t){if(t.startLine===void 0&&t.endLine===void 0)return e;let n=nu(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 iu(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 au(e,t){return t===`utf-8`||t===`utf8`?new TextEncoder().encode(e):Buffer.from(e,t)}function ou(e={}){return{name:`local`,async prewarm(e){let t=fu(Ud(e.runtimeContext.appRoot),e.templateKey);if(await bu(t))return;let n=await su({sessionKey:e.templateKey,snapshotPath:t}),r=eu(lu(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=Ud(e.runtimeContext.appRoot),n=await vu(fu(t,e.templateKey));if(n===null)throw new Zl({backendName:`local`,templateKey:e.templateKey});let r=xu(e.existingMetadata)??pu(t,e.sessionKey);return await bu(r)||await yu(r,n),cu(await su({sessionKey:e.sessionKey,snapshotPath:r}))}}}async function su(e){let{Bash:t,InMemoryFs:n}=await import(`#compiled/just-bash/index.js`),r=await vu(e.snapshotPath),i=new n(mu(r));await hu(i),await gu(i,r?.entries??[]);let a=new t({cwd:K,env:r?.env,fs:i,network:{dangerouslyAllowFullInternetAccess:!0}});return{async captureSnapshot(){let t=await _u({filesystem:i,sandbox:a});return await yu(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 ${X(e.workingDirectory)} && ${e.command} )`,n=a.exec(t),r=e.abortSignal?await uu(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=x(t.path);await i.mkdir(e,{recursive:!0}),await i.writeFile(t.path,t.content)}}}}function cu(e){let t=eu(lu(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 lu(e){return{id:e.sessionKey,resolvePath:du,async runCommand(t){return await e.executeCommand(t)},async readFile(t){let n=await e.readFileBytes(t.path);return n===null?null:$l(n)},async writeFile(t){let n=await Ql(t.content);await e.writeFiles([{content:n,path:t.path}])}}}async function uu(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 du(e){return e.startsWith(`/`)?e:`${K}/${e}`}function fu(e,t){return S(e,`local`,`templates`,`${t}.json`)}function pu(e,t){return S(e,`local`,`sessions`,`${t}.json`)}function mu(e){let t={};for(let n of e?.entries??[])n.kind===`file`&&(t[n.path]=Buffer.from(n.contentBase64,`base64`));return t}async function hu(e){await e.mkdir(K,{recursive:!0})}async function gu(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 _u(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 vu(e){if(!await bu(e))return null;let t=JSON.parse(await ge(e,`utf8`));return t.version===1?t:null}async function yu(e,t){await w(x(e),{recursive:!0}),await T(e,`${JSON.stringify(t,null,2)}\n`)}async function bu(e){try{return await me(e),!0}catch{return!1}}function xu(e){let t=e?.snapshotPath;return typeof t==`string`?t:void 0}function Su(e){return ou({createOptions:e})}function Cu(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n={timeout:Vu,...e.createOptions},r=new Map;return{name:`vercel`,async create(e){let i=Lu(n.tags,e.tags),a;try{a=await wu({loadSandboxModule:t,prewarmedTemplates:r,templateKey:e.templateKey})}catch(t){throw Zl.is(t)?t:Error(`Failed to read sandbox template "${e.templateKey}": ${Bu(t)}`,{cause:t})}let o;try{o=await Eu({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}": ${Bu(t)}`,{cause:t})}return Du(o,e.sessionKey)},async prewarm(e){let i;try{i=await Tu({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}": ${Bu(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 wu(e){let t=e.prewarmedTemplates.get(e.templateKey);if(t!==void 0)return t;let n=await Nu(await e.loadSandboxModule(),e.templateKey);if(n===null||typeof n.currentSnapshotId!=`string`)throw new Zl({backendName:`vercel`,templateKey:e.templateKey});return{sandboxName:n.name,snapshotId:n.currentSnapshotId,templateKey:e.templateKey}}async function Tu(e){let t=await e.loadSandboxModule(),n=await Nu(t,e.templateKey),r=Lu(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 Ru(n,r);let i=Fu(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 Au(n,e.createOptions);let a=eu(Ou(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 Eu(e){let t=Iu(e.existingMetadata)??e.sessionKey,n=await Nu(e.sandboxModule,t);if(n!==null)return await Ru(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 Du(e,t){return{session:eu(Ou(e,t)),useSessionFn:async n=>(n!==void 0&&await e.update(n),eu(Ou(e,t))),async captureState(){return{backendName:`vercel`,metadata:{sandboxName:e.name},sessionKey:t}},async dispose(){}}}function Ou(e,t){return{id:t,resolvePath:ku,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 Ql(t.content);await e.writeFiles([{content:n,path:t.path}])}}}function ku(e){return e.startsWith(`/`)?e:`${K}/${e}`}async function Au(e,t){await ju(e,{failureMessage:`Failed to initialize Vercel sandbox workspace.`,script:`mkdir -p ${K} && chown ${Mu}:${Mu} ${K}`}),t.networkPolicy!==`deny-all`&&await ju(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 ju(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 Mu=`vercel-sandbox`;async function Nu(e,t){try{return await e.Sandbox.get({name:t})}catch(e){if(Pu(e))return null;throw Error(`Failed to look up Vercel sandbox "${t}": ${Bu(e)}`,{cause:e})}}function Pu(e){return e instanceof Error?(e.response?.status??e.cause?.response?.status)===404:!1}function Fu(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}function Iu(e){let t=e?.sandboxName;return typeof t==`string`?t:void 0}function Lu(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>Hu)throw Error(`Vercel Sandbox supports at most ${Hu} tags. Ash reserves "agent", "channel", and "sessionId"; remove or consolidate custom tags passed to vercelBackend().`);return n}}async function Ru(e,t){t===void 0||zu(e.tags,t)||await e.update({tags:t})}function zu(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 Bu(e){return e instanceof Error?e.message:String(e)}const Vu=1800*1e3,Hu=5;function Uu(e){return Cu({createOptions:e})}function Wu(e){return Oi(()=>process.env.VERCEL?Uu(e?.vercel):Su(e?.local))}async function Gu(e,t,n){try{let r=c(await Q({definition:e,kindLabel:`sandbox`,moduleMap:t,nodeId:n}),`Expected the sandbox export "${e.exportName??`default`}" from "${e.logicalPath}" to return an object.`);return{backend:Ku(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 Z?t:new Z(`Failed to attach the sandbox lifecycle handlers from "${e.logicalPath}": ${p(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}function Ku(e,t){if(e===void 0)return Wu();if(typeof e==`function`)return Oi(e);if(typeof e!=`object`||!e)throw new Z(`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 Z(`Sandbox "${t}" backend is missing a non-empty string "name" identifier.`,{logicalPath:t});if(typeof n.create!=`function`)throw new Z(`Sandbox "${t}" backend is missing a "create" function.`,{logicalPath:t});return n}async function qu(e,t,n){try{let r=c(await Q({definition:e,kindLabel:`tool`,moduleMap:t,nodeId:n}),$(e,`to return an object`));Yi(`tool:${r.description}`,{kind:`tool`,name:e.name});let i=o(r.execute,$(e,`to provide an execute function`));return{description:e.description,execute:i,exportName:e.exportName,inputSchema:e.inputSchema,logicalPath:e.logicalPath,name:e.name,sourceId:e.sourceId,sourceKind:`module`,...Ju(r,e)}}catch(t){throw t instanceof Z?t:new Z(`Failed to attach the tool execute function from "${e.logicalPath}": ${p(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}function Ju(e,t){let n={};e.onCompact!==void 0&&(n.onCompact=o(e.onCompact,$(t,`to provide an onCompact function`))),e.needsApproval!==void 0&&(n.needsApproval=o(e.needsApproval,$(t,`to provide a needsApproval function`)));let r=Yu(e,t);return r!==void 0&&(n.retentionPolicy=r),e.toModelOutput!==void 0&&(n.toModelOutput=o(e.toModelOutput,$(t,`to provide a toModelOutput function`))),e.inputSchema!==void 0&&Xu(e.inputSchema)&&(n.inputStandardSchema=e.inputSchema),n}function Yu(e,t){let n=e.retentionPolicy;if(n!==void 0){if(n===`auto`||n===`keep`||typeof n==`function`)return n;throw new Z($(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 Xu(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}async function Zu(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 ql(t,e.moduleMap,e.nodeId))}let i=await Promise.all(e.manifest.tools.map(t=>qu(t,e.moduleMap,e.nodeId))),a=await Promise.all(e.manifest.hooks.map(t=>Yl(t,e.moduleMap,e.nodeId))),o=await Promise.all(e.manifest.connections.map(t=>Jl(t,e.moduleMap,e.nodeId))),s=e.manifest.sandbox===null?null:await Gu(e.manifest.sandbox,e.moduleMap,e.nodeId),c=Qu(e.manifest.instructions),l=e.manifest.workspaceResourceRoot,u={channels:n,config:$u(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 Qu(e){if(e!==void 0)return{name:e.name,logicalPath:e.logicalPath,markdown:e.markdown,sourceId:e.sourceId,sourceKind:e.sourceKind}}function $u(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=Kl(e.config.source)),t}function ed(e){return{sandbox:{definition:e.authoredSandbox??td(),workspaceResourceRoot:e.workspaceResourceRoot}}}function td(){return{backend:Wu(),logicalPath:`ash:framework/default-sandbox`,sourceId:`ash:default-sandbox`,sourceKind:`module`}}const nd=`load_skill`,rd=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 id(e){let t=[],n=new $a(`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 U(`subagent`,`Found multiple runtime subagents mapped to node id "${i.nodeId}".`,{...e,entryName:i.name});let a=ad(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 ad(e){return{description:e.description,inputSchema:rd,kind:e.kind,logicalPath:e.logicalPath,name:e.name,nodeId:e.nodeId,sourceId:e.sourceId}}async function od(e,t={}){let n=[],r=new $a(`tool`,t.reservedToolNames??[]);for(let t of e.tools){let e=await sd(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 sd(e){return{description:e.description,inputSchema:await cd(e),kind:`authored-tool`,logicalPath:e.logicalPath,name:e.name,sourceId:e.sourceId}}async function cd(e){return e.inputSchema}var ld=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 ud(e){let t=new Map,n=gd(e.manifest),r=new Map(e.manifest.subagents.map(e=>[e.nodeId,e]));return{nodesByNodeId:t,root:await dd({childNodeIdsByParentNodeId:n,manifest:e.manifest,moduleMap:e.moduleMap,nodeId:R,nodesByNodeId:t,subagentNodesById:r})}}async function dd(e){let t=_d(e.nodeId);if(e.nodesByNodeId.has(t))throw new ld(`Found multiple runtime agent nodes for node id "${t}".`,{nodeId:t,sourceId:e.sourceId});let n=await Zu({manifest:e.manifest,moduleMap:e.moduleMap,nodeId:e.nodeId}),r=n.connections.length>0,i=Ul({hasConnections:r}),a=r?yd(i,n.connections):i,o=new Set(a.map(e=>e.name)),s=Wl(),c=new Set(n.tools.map(e=>e.name));for(let r of n.disabledFrameworkTools)if(!s.has(r))throw new ld(`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 od({tools:[...a.filter(e=>!c.has(e.name)&&!l.has(e.name)),...n.tools]},{reservedToolNames:o.has(`load_skill`)||c.has(`load_skill`)?[]:[nd]}),d=new Set(n.channels.map(e=>e.name)),f=Tc();for(let r of n.disabledFrameworkChannels)if(!f.has(r))throw new ld(`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=[...wc().filter(e=>!d.has(e.name)&&!p.has(e.name)),...n.channels],h=ed({authoredSandbox:n.sandbox,workspaceResourceRoot:n.workspaceResourceRoot}),g=id({reservedToolNames:[nd,...u.preparedTools.map(e=>e.name)],subagents:await fd({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,manifest:e.manifest,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,parentNodeId:e.nodeId,subagentNodesById:e.subagentNodesById})}),_={agent:n,channels:m,hookRegistry:Gl(n.hooks),nodeId:t,sandboxRegistry:h,sourceId:e.sourceId,subagentRegistry:g,toolRegistry:u,turnAgent:hs({agent:n,nodeId:t,tools:[...u.preparedTools,...g.preparedTools]})};return e.nodesByNodeId.set(t,_),_}async function fd(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 ld(`Missing compiled subagent node "${r}" while resolving runtime subagents.`,{nodeId:_d(e.parentNodeId),sourceId:r});t.push(await pd({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,sourceRef:n,subagentNodesById:e.subagentNodesById}))}for(let n of e.manifest.remoteAgents)t.push(await md({moduleMap:e.moduleMap,nodeScopeId:e.parentNodeId,sourceRef:n}));return t}async function pd(e){let t={description:e.sourceRef.description,kind:`subagent`,logicalPath:e.sourceRef.logicalPath,name:e.sourceRef.name,nodeId:_d(e.sourceRef.nodeId),sourceId:e.sourceRef.sourceId,sourceKind:`module`};return await dd({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 md(e){let t=c(await Q({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:_d(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=hd(t.headers);return r!==void 0&&(n.headers=r),n}function hd(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 gd(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 _d(e){return e===`__root__`?ko:e}const vd=ns.name;function yd(e,t){let n=t.map(e=>e.connectionName).join(`, `);return e.map(e=>e.name===vd?{...e,description:`${e.description} Available connections: ${n}.`}:e)}const bd=process.env.ASH_DISABLE_AGENT_CACHE===`1`;async function xd(e){let[t,n]=await Promise.all([No({compiledArtifactsSource:e}),Sd(e)]),r=await ud({manifest:t,moduleMap:n}),i=r.root;return{adapterRegistry:ro({channels:Dd(r)}),compiledArtifactsSource:e,graph:r,hookRegistry:i.hookRegistry,moduleMap:n,resolvedAgent:i.agent,subagentRegistry:i.subagentRegistry,toolRegistry:i.toolRegistry,turnAgent:i.turnAgent}}async function Sd(e){return e.kind===`disk`&&e.moduleMapLoadMode===`authored-source`?await Cd(e):await Ro({compiledArtifactsSource:e})}async function Cd(e){if(e.moduleMapLoaderPath===void 0)throw Error(`Authored-source module map loading requires "moduleMapLoaderPath" in the compiled artifacts source.`);return await(await import(Te(e.moduleMapLoaderPath).href)).loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:e})}async function wd(e){if(bd)return xd(e);let t=vo(),n=lo(e),r=await Eo(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=xd(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 Td(e){let t=await wd(e.compiledArtifactsSource);if(e.nodeId===void 0)return t;let n=Ao(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 Ed(){let e=vo();e.bundleCache.clear(),e.bundleCacheKeyBySourceKey.clear()}function Dd(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 V(`ash.channel`,{codec:{serialize(e){return{kind:Wa(e),state:e.state?{...e.state}:{}}},deserialize(e,t){let n=t.get(Od);if(n===void 0)throw Error(`Cannot deserialize "ash.channel" before "ash.bundle". The runtime bundle must be present in context.`);return io(n.adapterRegistry,e)}}});const Od=new V(`ash.bundle`,{codec:{serialize:e=>({nodeId:e.nodeId,source:e.compiledArtifactsSource}),deserialize:e=>{let{source:t,nodeId:n}=e;return Td({compiledArtifactsSource:t,nodeId:n})}}});new V(`ash.session`);const kd=new V(`ash.sandbox`),Ad=`workflowEntry`,jd=`turnWorkflow`,Md=_(),Nd=new Set([Ad,jd]),Pd=Md.name,Fd={workflowId:`workflow//${Pd}//${Ad}`};`${Pd}${jd}`;function Id(e=process.cwd()){return C(e)}function Ld(e){return be(`sha256`).update(e).digest(`hex`).slice(0,12)}function Rd(){return!!process.env.VERCEL}function zd(e,t=`all`){let n=S(e,`.ash`,`nitro`);return t===`all`?n:S(n,t)}function Bd(e,t){return S(e,`.ash`,`nitro-output`,t)}function Vd(e){let t=S(m(),`.ash`,`workflow-cache`);return Hd(t),S(t,Ld(e))}function Hd(e){if(!xe(e))return;let t=_().version,n;try{n=Ce(e)}catch{return}for(let r of n){let n=S(e,r),i=S(n,`ash-cache.json`);if(xe(i))try{let e=JSON.parse(Se(i,`utf8`));typeof e.ashVersion==`string`&&e.ashVersion!==t&&we(n,{force:!0,recursive:!0})}catch{}}}function Ud(e){return S(e,`.ash`,`sandbox-cache`)}function Wd(e){return Rd()?S(e,`.vercel`,`output`):S(e,`.output`)}function Gd(e){return{appRoot:e,outputDir:Wd(e),workflowId:Fd.workflowId,workflowBuildDir:Vd(e),workflowSourceDir:g(`src/execution`)}}export{Nr as C,R as D,kr as E,Ln as O,Fr as S,Ar as T,co as _,Vd as a,Sa as b,ud as c,K as d,No as f,so as g,W as h,Bd as i,Tc as l,Co as m,Id as n,Nd as o,ko as p,zd as r,Ed as s,Gd as t,wc as u,lo as v,Or as w,ii as x,xa as y};
89
+ `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}function ru(e,t){if(t.startLine===void 0&&t.endLine===void 0)return e;let n=nu(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 iu(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 au(e,t){return t===`utf-8`||t===`utf8`?new TextEncoder().encode(e):Buffer.from(e,t)}function ou(e={}){return{name:`local`,async prewarm(e){let t=fu(Hd(e.runtimeContext.appRoot),e.templateKey);if(await bu(t))return;let n=await su({sessionKey:e.templateKey,snapshotPath:t}),r=eu(lu(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=Hd(e.runtimeContext.appRoot),n=await vu(fu(t,e.templateKey));if(n===null)throw new Zl({backendName:`local`,templateKey:e.templateKey});let r=xu(e.existingMetadata)??pu(t,e.sessionKey);return await bu(r)||await yu(r,n),cu(await su({sessionKey:e.sessionKey,snapshotPath:r}))}}}async function su(e){let{Bash:t,InMemoryFs:n}=await import(`#compiled/just-bash/index.js`),r=await vu(e.snapshotPath),i=new n(mu(r));await hu(i),await gu(i,r?.entries??[]);let a=new t({cwd:K,env:r?.env,fs:i,network:{dangerouslyAllowFullInternetAccess:!0}});return{async captureSnapshot(){let t=await _u({filesystem:i,sandbox:a});return await yu(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 ${X(e.workingDirectory)} && ${e.command} )`,n=a.exec(t),r=e.abortSignal?await uu(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=x(t.path);await i.mkdir(e,{recursive:!0}),await i.writeFile(t.path,t.content)}}}}function cu(e){let t=eu(lu(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 lu(e){return{id:e.sessionKey,resolvePath:du,async runCommand(t){return await e.executeCommand(t)},async readFile(t){let n=await e.readFileBytes(t.path);return n===null?null:$l(n)},async writeFile(t){let n=await Ql(t.content);await e.writeFiles([{content:n,path:t.path}])}}}async function uu(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 du(e){return e.startsWith(`/`)?e:`${K}/${e}`}function fu(e,t){return S(e,`local`,`templates`,`${t}.json`)}function pu(e,t){return S(e,`local`,`sessions`,`${t}.json`)}function mu(e){let t={};for(let n of e?.entries??[])n.kind===`file`&&(t[n.path]=Buffer.from(n.contentBase64,`base64`));return t}async function hu(e){await e.mkdir(K,{recursive:!0})}async function gu(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 _u(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 vu(e){if(!await bu(e))return null;let t=JSON.parse(await ge(e,`utf8`));return t.version===1?t:null}async function yu(e,t){await w(x(e),{recursive:!0}),await T(e,`${JSON.stringify(t,null,2)}\n`)}async function bu(e){try{return await me(e),!0}catch{return!1}}function xu(e){let t=e?.snapshotPath;return typeof t==`string`?t:void 0}function Su(e){return ou({createOptions:e})}function Cu(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n={timeout:Vu,...e.createOptions},r=new Map;return{name:`vercel`,async create(e){let i=Lu(n.tags,e.tags),a;try{a=await wu({loadSandboxModule:t,prewarmedTemplates:r,templateKey:e.templateKey})}catch(t){throw Zl.is(t)?t:Error(`Failed to read sandbox template "${e.templateKey}": ${Bu(t)}`,{cause:t})}let o;try{o=await Eu({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}": ${Bu(t)}`,{cause:t})}return Du(o,e.sessionKey)},async prewarm(e){let i;try{i=await Tu({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}": ${Bu(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 wu(e){let t=e.prewarmedTemplates.get(e.templateKey);if(t!==void 0)return t;let n=await Nu(await e.loadSandboxModule(),e.templateKey);if(n===null||typeof n.currentSnapshotId!=`string`)throw new Zl({backendName:`vercel`,templateKey:e.templateKey});return{sandboxName:n.name,snapshotId:n.currentSnapshotId,templateKey:e.templateKey}}async function Tu(e){let t=await e.loadSandboxModule(),n=await Nu(t,e.templateKey),r=Lu(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 Ru(n,r);let i=Fu(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 Au(n,e.createOptions);let a=eu(Ou(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 Eu(e){let t=Iu(e.existingMetadata)??e.sessionKey,n=await Nu(e.sandboxModule,t);if(n!==null)return await Ru(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 Du(e,t){return{session:eu(Ou(e,t)),useSessionFn:async n=>(n!==void 0&&await e.update(n),eu(Ou(e,t))),async captureState(){return{backendName:`vercel`,metadata:{sandboxName:e.name},sessionKey:t}},async dispose(){}}}function Ou(e,t){return{id:t,resolvePath:ku,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 Ql(t.content);await e.writeFiles([{content:n,path:t.path}])}}}function ku(e){return e.startsWith(`/`)?e:`${K}/${e}`}async function Au(e,t){await ju(e,{failureMessage:`Failed to initialize Vercel sandbox workspace.`,script:`mkdir -p ${K} && chown ${Mu}:${Mu} ${K}`}),t.networkPolicy!==`deny-all`&&await ju(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 ju(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 Mu=`vercel-sandbox`;async function Nu(e,t){try{return await e.Sandbox.get({name:t})}catch(e){if(Pu(e))return null;throw Error(`Failed to look up Vercel sandbox "${t}": ${Bu(e)}`,{cause:e})}}function Pu(e){return e instanceof Error?(e.response?.status??e.cause?.response?.status)===404:!1}function Fu(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}function Iu(e){let t=e?.sandboxName;return typeof t==`string`?t:void 0}function Lu(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>Hu)throw Error(`Vercel Sandbox supports at most ${Hu} tags. Ash reserves "agent", "channel", and "sessionId"; remove or consolidate custom tags passed to vercelBackend().`);return n}}async function Ru(e,t){t===void 0||zu(e.tags,t)||await e.update({tags:t})}function zu(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 Bu(e){return e instanceof Error?e.message:String(e)}const Vu=1800*1e3,Hu=5;function Uu(e){return Cu({createOptions:e})}function Wu(e){return Oi(()=>process.env.VERCEL?Uu(e?.vercel):Su(e?.local))}async function Gu(e,t,n){try{let r=c(await Q({definition:e,kindLabel:`sandbox`,moduleMap:t,nodeId:n}),`Expected the sandbox export "${e.exportName??`default`}" from "${e.logicalPath}" to return an object.`);return{backend:Ku(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 Z?t:new Z(`Failed to attach the sandbox lifecycle handlers from "${e.logicalPath}": ${p(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}function Ku(e,t){if(e===void 0)return Wu();if(typeof e==`function`)return Oi(e);if(typeof e!=`object`||!e)throw new Z(`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 Z(`Sandbox "${t}" backend is missing a non-empty string "name" identifier.`,{logicalPath:t});if(typeof n.create!=`function`)throw new Z(`Sandbox "${t}" backend is missing a "create" function.`,{logicalPath:t});return n}async function qu(e,t,n){try{let r=c(await Q({definition:e,kindLabel:`tool`,moduleMap:t,nodeId:n}),$(e,`to return an object`));Yi(`tool:${r.description}`,{kind:`tool`,name:e.name});let i=o(r.execute,$(e,`to provide an execute function`));return{description:e.description,execute:i,exportName:e.exportName,inputSchema:e.inputSchema,logicalPath:e.logicalPath,name:e.name,sourceId:e.sourceId,sourceKind:`module`,...Ju(r,e)}}catch(t){throw t instanceof Z?t:new Z(`Failed to attach the tool execute function from "${e.logicalPath}": ${p(t)}`,{logicalPath:e.logicalPath,sourceId:e.sourceId})}}function Ju(e,t){let n={};e.onCompact!==void 0&&(n.onCompact=o(e.onCompact,$(t,`to provide an onCompact function`))),e.needsApproval!==void 0&&(n.needsApproval=o(e.needsApproval,$(t,`to provide a needsApproval function`)));let r=Yu(e,t);return r!==void 0&&(n.retentionPolicy=r),e.toModelOutput!==void 0&&(n.toModelOutput=o(e.toModelOutput,$(t,`to provide a toModelOutput function`))),e.inputSchema!==void 0&&Xu(e.inputSchema)&&(n.inputStandardSchema=e.inputSchema),n}function Yu(e,t){let n=e.retentionPolicy;if(n!==void 0){if(n===`auto`||n===`keep`||typeof n==`function`)return n;throw new Z($(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 Xu(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}async function Zu(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 ql(t,e.moduleMap,e.nodeId))}let i=await Promise.all(e.manifest.tools.map(t=>qu(t,e.moduleMap,e.nodeId))),a=await Promise.all(e.manifest.hooks.map(t=>Yl(t,e.moduleMap,e.nodeId))),o=await Promise.all(e.manifest.connections.map(t=>Jl(t,e.moduleMap,e.nodeId))),s=e.manifest.sandbox===null?null:await Gu(e.manifest.sandbox,e.moduleMap,e.nodeId),c=Qu(e.manifest.instructions),l=e.manifest.workspaceResourceRoot,u={channels:n,config:$u(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 Qu(e){if(e!==void 0)return{name:e.name,logicalPath:e.logicalPath,markdown:e.markdown,sourceId:e.sourceId,sourceKind:e.sourceKind}}function $u(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=Kl(e.config.source)),t}function ed(e){return{sandbox:{definition:e.authoredSandbox??td(),workspaceResourceRoot:e.workspaceResourceRoot}}}function td(){return{backend:Wu(),logicalPath:`ash:framework/default-sandbox`,sourceId:`ash:default-sandbox`,sourceKind:`module`}}const nd=`load_skill`,rd=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 id(e){let t=[],n=new $a(`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 U(`subagent`,`Found multiple runtime subagents mapped to node id "${i.nodeId}".`,{...e,entryName:i.name});let a=ad(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 ad(e){return{description:e.description,inputSchema:rd,kind:e.kind,logicalPath:e.logicalPath,name:e.name,nodeId:e.nodeId,sourceId:e.sourceId}}async function od(e,t={}){let n=[],r=new $a(`tool`,t.reservedToolNames??[]);for(let t of e.tools){let e=await sd(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 sd(e){return{description:e.description,inputSchema:await cd(e),kind:`authored-tool`,logicalPath:e.logicalPath,name:e.name,sourceId:e.sourceId}}async function cd(e){return e.inputSchema}var ld=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 ud(e){let t=new Map,n=gd(e.manifest),r=new Map(e.manifest.subagents.map(e=>[e.nodeId,e]));return{nodesByNodeId:t,root:await dd({childNodeIdsByParentNodeId:n,manifest:e.manifest,moduleMap:e.moduleMap,nodeId:R,nodesByNodeId:t,subagentNodesById:r})}}async function dd(e){let t=_d(e.nodeId);if(e.nodesByNodeId.has(t))throw new ld(`Found multiple runtime agent nodes for node id "${t}".`,{nodeId:t,sourceId:e.sourceId});let n=await Zu({manifest:e.manifest,moduleMap:e.moduleMap,nodeId:e.nodeId}),r=n.connections.length>0,i=Ul({hasConnections:r}),a=r?yd(i,n.connections):i,o=new Set(a.map(e=>e.name)),s=Wl(),c=new Set(n.tools.map(e=>e.name));for(let r of n.disabledFrameworkTools)if(!s.has(r))throw new ld(`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 od({tools:[...a.filter(e=>!c.has(e.name)&&!l.has(e.name)),...n.tools]},{reservedToolNames:o.has(`load_skill`)||c.has(`load_skill`)?[]:[nd]}),d=new Set(n.channels.map(e=>e.name)),f=Tc();for(let r of n.disabledFrameworkChannels)if(!f.has(r))throw new ld(`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=[...wc().filter(e=>!d.has(e.name)&&!p.has(e.name)),...n.channels],h=ed({authoredSandbox:n.sandbox,workspaceResourceRoot:n.workspaceResourceRoot}),g=id({reservedToolNames:[nd,...u.preparedTools.map(e=>e.name)],subagents:await fd({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,manifest:e.manifest,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,parentNodeId:e.nodeId,subagentNodesById:e.subagentNodesById})}),_={agent:n,channels:m,hookRegistry:Gl(n.hooks),nodeId:t,sandboxRegistry:h,sourceId:e.sourceId,subagentRegistry:g,toolRegistry:u,turnAgent:hs({agent:n,nodeId:t,tools:[...u.preparedTools,...g.preparedTools]})};return e.nodesByNodeId.set(t,_),_}async function fd(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 ld(`Missing compiled subagent node "${r}" while resolving runtime subagents.`,{nodeId:_d(e.parentNodeId),sourceId:r});t.push(await pd({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,sourceRef:n,subagentNodesById:e.subagentNodesById}))}for(let n of e.manifest.remoteAgents)t.push(await md({moduleMap:e.moduleMap,nodeScopeId:e.parentNodeId,sourceRef:n}));return t}async function pd(e){let t={description:e.sourceRef.description,kind:`subagent`,logicalPath:e.sourceRef.logicalPath,name:e.sourceRef.name,nodeId:_d(e.sourceRef.nodeId),sourceId:e.sourceRef.sourceId,sourceKind:`module`};return await dd({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 md(e){let t=c(await Q({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:_d(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=hd(t.headers);return r!==void 0&&(n.headers=r),n}function hd(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 gd(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 _d(e){return e===`__root__`?ko:e}const vd=ns.name;function yd(e,t){let n=t.map(e=>e.connectionName).join(`, `);return e.map(e=>e.name===vd?{...e,description:`${e.description} Available connections: ${n}.`}:e)}const bd=process.env.ASH_DISABLE_AGENT_CACHE===`1`;async function xd(e){let[t,n]=await Promise.all([No({compiledArtifactsSource:e}),Sd(e)]),r=await ud({manifest:t,moduleMap:n}),i=r.root;return{adapterRegistry:ro({channels:Dd(r)}),compiledArtifactsSource:e,graph:r,hookRegistry:i.hookRegistry,moduleMap:n,resolvedAgent:i.agent,subagentRegistry:i.subagentRegistry,toolRegistry:i.toolRegistry,turnAgent:i.turnAgent}}async function Sd(e){return e.kind===`disk`&&e.moduleMapLoadMode===`authored-source`?await Cd(e):await Ro({compiledArtifactsSource:e})}async function Cd(e){if(e.moduleMapLoaderPath===void 0)throw Error(`Authored-source module map loading requires "moduleMapLoaderPath" in the compiled artifacts source.`);return await(await import(Te(e.moduleMapLoaderPath).href)).loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:e})}async function wd(e){if(bd)return xd(e);let t=vo(),n=lo(e),r=await Eo(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=xd(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 Td(e){let t=await wd(e.compiledArtifactsSource);if(e.nodeId===void 0)return t;let n=Ao(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 Ed(){let e=vo();e.bundleCache.clear(),e.bundleCacheKeyBySourceKey.clear()}function Dd(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 V(`ash.channel`,{codec:{serialize(e){return{kind:Wa(e),state:e.state?{...e.state}:{}}},deserialize(e,t){let n=t.get(Od);if(n===void 0)throw Error(`Cannot deserialize "ash.channel" before "ash.bundle". The runtime bundle must be present in context.`);return io(n.adapterRegistry,e)}}});const Od=new V(`ash.bundle`,{codec:{serialize:e=>({nodeId:e.nodeId,source:e.compiledArtifactsSource}),deserialize:e=>{let{source:t,nodeId:n}=e;return Td({compiledArtifactsSource:t,nodeId:n})}}});new V(`ash.session`);const kd=new V(`ash.sandbox`),Ad=`workflowEntry`,jd=_(),Md=new Set([Ad,`turnWorkflow`]),Nd=jd.name,Pd={workflowId:`workflow//${Nd}//${Ad}`};`${Nd}`;function Fd(e=process.cwd()){return C(e)}function Id(e){return be(`sha256`).update(e).digest(`hex`).slice(0,12)}function Ld(){return!!process.env.VERCEL}function Rd(e,t=`all`){let n=S(e,`.ash`,`nitro`);return t===`all`?n:S(n,t)}function zd(e,t){return S(e,`.ash`,`nitro-output`,t)}function Bd(e){let t=S(m(),`.ash`,`workflow-cache`);return Vd(t),S(t,Id(e))}function Vd(e){if(!xe(e))return;let t=_().version,n;try{n=Ce(e)}catch{return}for(let r of n){let n=S(e,r),i=S(n,`ash-cache.json`);if(xe(i))try{let e=JSON.parse(Se(i,`utf8`));typeof e.ashVersion==`string`&&e.ashVersion!==t&&we(n,{force:!0,recursive:!0})}catch{}}}function Hd(e){return S(e,`.ash`,`sandbox-cache`)}function Ud(e){return Ld()?S(e,`.vercel`,`output`):S(e,`.output`)}function Wd(e){return{appRoot:e,outputDir:Ud(e),workflowId:Pd.workflowId,workflowBuildDir:Bd(e),workflowSourceDir:g(`src/execution`)}}export{Nr as C,R as D,kr as E,Ln as O,Fr as S,Ar as T,co as _,Bd as a,Sa as b,ud as c,K as d,No as f,so as g,W as h,zd as i,Tc as l,Co as m,Fd as n,Md as o,ko as p,Rd as r,Ed as s,Wd as t,wc as u,lo as v,Or as w,ii as x,xa as y};
@@ -1 +1 @@
1
- import{t as e}from"./chunk-8L7ocgPr.js";var t=e(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}));export{t};
1
+ import{t as e}from"./chunk-DSjMdhoD.js";var t=e(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}));export{t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./chunk-DSjMdhoD.js";import{o as t,s as n}from"./client-DLHAGI2g.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{};
@@ -1,4 +1,4 @@
1
- import{i as e,r as t,t as n}from"./chunk-8L7ocgPr.js";var r=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),i=n((e=>{let{InvalidArgumentError:t}=r();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function i(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=i})),a=n((e=>{let{humanReadableArgName:t}=i();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
1
+ import{i as e,r as t,t as n}from"./chunk-DSjMdhoD.js";var r=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),i=n((e=>{let{InvalidArgumentError:t}=r();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function i(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=i})),a=n((e=>{let{humanReadableArgName:t}=i();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
2
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
3
3
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
4
4
  `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),o=n((e=>{let{InvalidArgumentError:t}=r();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=o(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?a(this.name().replace(/^no-/,``)):a(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},i=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function a(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function o(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -1,2 +1,2 @@
1
- import{O as e,b as t,t as n,x as r,y as i}from"../../chunks/paths-jcVjBqc3.js";import{d as a,f as o,h as s}from"../../chunks/types-MZUhN0Zy.js";import{createCliTheme as c,renderCliBanner as l,renderCliSection as u}from"../ui/output.js";async function d(e){let t=await f(e);return{application:n(t?.project.appRoot??e),compiledState:t,messaging:{createSessionRoutePath:o,continueSessionRoutePattern:a,streamRoutePattern:s}}}async function f(n){try{return await t({startPath:n})}catch(t){if(t instanceof i)return t.result;if(t instanceof e||t instanceof r)return null;throw t}}function p(e,t){return`${e} ${t}${e===1?``:`s`}`}function m(e,t){return`${`${e} error${e===1?``:`s`}`}, ${`${t} warning${t===1?``:`s`}`}`}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(`
1
+ import{O as e,b as t,t as n,x as r,y as i}from"../../chunks/paths-CebY5GCi.js";import{d as a,f as o,h as s}from"../../chunks/types-DDA2QUED.js";import{createCliTheme as c,renderCliBanner as l,renderCliSection as u}from"../ui/output.js";async function d(e){let t=await f(e);return{application:n(t?.project.appRoot??e),compiledState:t,messaging:{createSessionRoutePath:o,continueSessionRoutePattern:a,streamRoutePattern:s}}}async function f(n){try{return await t({startPath:n})}catch(t){if(t instanceof i)return t.result;if(t instanceof e||t instanceof r)return null;throw t}}function p(e,t){return`${e} ${t}${e===1?``:`s`}`}function m(e,t){return`${`${e} error${e===1?``:`s`}`}, ${`${t} warning${t===1?``:`s`}`}`}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};
@@ -5,7 +5,21 @@
5
5
  */
6
6
  export declare const DEVELOPMENT_ENV_FILE_NAMES: readonly [".env.development.local", ".env.local", ".env.development", ".env"];
7
7
  /**
8
- * Loads local development environment files from the application root without
9
- * overriding variables that were already provided by the parent process.
8
+ * Returns the local development environment files Ash loads from an
9
+ * application root, ordered from highest to lowest precedence.
10
+ */
11
+ export declare function getDevelopmentEnvironmentFilePaths(appRoot: string): string[];
12
+ /**
13
+ * Loads or reloads local development environment files from the application
14
+ * root.
15
+ *
16
+ * Variables that existed before the first load keep parent-process
17
+ * precedence. Variables supplied by env files are refreshed on subsequent
18
+ * reloads so dev-mode file watching can pick up changed values.
10
19
  */
11
20
  export declare function loadDevelopmentEnvironmentFiles(appRoot: string): void;
21
+ /**
22
+ * Reloads local development environment files for a previously loaded app
23
+ * root, creating the loader on demand when dev mode is started programmatically.
24
+ */
25
+ export declare function reloadDevelopmentEnvironmentFiles(appRoot: string): void;
@@ -1 +1 @@
1
- import{n as e}from"../../chunks/guards-CjJ3lmju.js";import{join as t}from"node:path";const n=[`.env.development.local`,`.env.local`,`.env.development`,`.env`];function r(t){return e(t)&&t.code===`ENOENT`}function i(e){for(let i of n)try{process.loadEnvFile(t(e,i))}catch(e){if(!r(e))throw e}}export{n as DEVELOPMENT_ENV_FILE_NAMES,i as loadDevelopmentEnvironmentFiles};
1
+ import{n as e}from"../../chunks/guards-26p6sOw3.js";import{join as t,resolve as n}from"node:path";import{readFileSync as r}from"node:fs";import{parseEnv as i}from"node:util";const a=[`.env.development.local`,`.env.local`,`.env.development`,`.env`];function o(t){return e(t)&&t.code===`ENOENT`}const s=new Map;function c(e){let r=n(e);return a.map(e=>t(r,e))}function l(e){d(e).reload()}function u(e){d(e).reload()}function d(e){let t=n(e),r=s.get(t);if(r!==void 0)return r;let i=f(t);return s.set(t,i),i}function f(e){let t=new Set(Object.keys(process.env)),n=new Map;return{reload(){let r=p(e);for(let[e,i]of n)r.has(e)||t.has(e)||(process.env[e]===i&&delete process.env[e],n.delete(e));for(let[e,i]of r)t.has(e)||(process.env[e]=i,n.set(e,i))}}}function p(e){let n=new Map;for(let s of[...a].reverse())try{let a=i(r(t(e,s),`utf8`));for(let[e,t]of Object.entries(a))t!==void 0&&n.set(e,t)}catch(e){if(!o(e))throw e}return n}export{a as DEVELOPMENT_ENV_FILE_NAMES,c as getDevelopmentEnvironmentFilePaths,l as loadDevelopmentEnvironmentFiles,u as reloadDevelopmentEnvironmentFiles};
@@ -1 +1 @@
1
- import"../ui/output.js";import{n as e,r as t,t as n}from"../../chunks/input-requests-BsBi7_5K.js";export{n as ESCAPED_RUNTIME_INPUT_PROMPT,e as extractPendingRuntimeInputRequests,t as promptForRuntimeInputRequests};
1
+ import"../ui/output.js";import{n as e,r as t,t as n}from"../../chunks/input-requests-DJiy6dG9.js";export{n as ESCAPED_RUNTIME_INPUT_PROMPT,e as extractPendingRuntimeInputRequests,t as promptForRuntimeInputRequests};
@@ -1,3 +1,3 @@
1
- import{t as e}from"../../chunks/errors-DsO9xmQL.js";import{c as t,d as n,f as r,h as i,l as a}from"../../chunks/types-MZUhN0Zy.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-BsBi7_5K.js";import{parseDevReplInput as m}from"./input.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"../../chunks/client-nshDsWNF.js";import{createDevelopmentTerminal as S}from"./terminal.js";import{createInterface as C,emitKeypressEvents as ee}from"node:readline";function te(e){return[...e].reverse().find(a)}function ne(e){let t=new URL(e);return t.hash=``,t.search=``,t.pathname.endsWith(`/`)||(t.pathname=`${t.pathname}/`),t}function w(e){return new URL(e.routePath.replace(/^\/+/,``),ne(e.serverUrl))}function T(e){let t=e.resource.trim();try{return new URL(t)}catch{return w({routePath:t,serverUrl: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 b||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=h();async function j(){try{let e=(await(0,A.getVercelOidcToken)()).trim();if(e.length>0)return e}catch{}return process.env.VERCEL_OIDC_TOKEN?.trim()||``}const M=new Set([`localhost`,`127.0.0.1`,`0.0.0.0`,`::1`,`[::1]`]);function N(e){try{return M.has(new URL(e).hostname)}catch{return!1}}async function P(e){let t={},n=process.env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();if(n&&(t[_]=n),!e.isLocal){let e=await j();e.length>0&&(t[y]=e)}return t}var F=class{#e;#t;constructor(e){let t=N(e.serverUrl);this.#e=new x({headers:()=>P({isLocal:t}),host:e.serverUrl,...t?{}:{auth:{bearer:j}}}),this.#t=this.#e.session()}async clear(){this.#t=this.#e.session()}async close(){}getSession(){return this.#t.state}async sendMessage(e){return await this.send({message:e.message,onEvent:e.onEvent,onResponseStart:e.onResponseStart})}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 I(e){return new F(e)}function L(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 R(){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 z(e,t){return[s(e,{subtitle:`Interactive development REPL for the active Ash server.`,title:`Ash Dev`}),``,c(e,{rows:L(t),title:`Connection`}),``,c(e,{rows:R(),title:`Commands`})].join(`
3
- `)}function re(e){let t=e.trim();return t.length>0?t:null}function B(e){return e.options?.sourceKind===`subagent`?`subagent`:e.fallback}function V(e){return e.options?.sourceKind===`subagent`?`subagent`:e.fallback}function H(e){return e.options?.sourceLabel===void 0?e.message:`${e.options.sourceLabel}${e.separator??` `}${e.message}`}function U(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:V({fallback:`accent`,options:n})})};case`message.completed`:if(t.data.message===null)return;if(t.data.finishReason===`tool-calls`){let r=re(t.data.message);return r===null?void 0:{finalized:!0,kind:`message`,line:u(e,{message:H({message:r,options:n,separator:`: `}),tag:B({fallback:`step`,options:n}),tone:V({fallback:`accent`,options:n})})}}return{finalized:!0,kind:`message`,line:l(e,{message:t.data.message,speaker:n?.sourceLabel??`agent`,tone:V({fallback:`accent`,options:n})})};case`reasoning.appended`:return{finalized:!1,kind:`reasoning`,line:u(e,{message:H({message:t.data.reasoningSoFar,options:n,separator:`: `}),tag:B({fallback:`reasoning`,options:n}),tone:V({fallback:`info`,options:n})})};case`reasoning.completed`:return{finalized:!0,kind:`reasoning`,line:u(e,{message:H({message:t.data.reasoning,options:n,separator:`: `}),tag:B({fallback:`reasoning`,options:n}),tone:V({fallback:`info`,options:n})})};default:return}}function W(e,t,n){let r=U(e,t,n);if(r!==void 0)return r.line;switch(t.type){case`message.received`:return;case`actions.requested`:return u(e,{message:H({message:`${t.type} (${t.data.actions.length} action${t.data.actions.length===1?``:`s`})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`input.requested`:return u(e,{message:H({message:`${t.type} (${t.data.requests.length} request${t.data.requests.length===1?``:`s`})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`info`,options:n})});case`action.result`:return u(e,{message:H({message:`${t.type} (${Z(t.data.result)})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`session.waiting`:case`session.completed`:return;case`connection.authorization_required`:return u(e,{message:H({message:`${t.type} (${t.data.connectionName}: ${t.data.description}${ae(t.data.authorization)})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`warning`,options:n})});case`compaction.requested`:return u(e,{message:H({message:`compacting conversation history`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`compaction.completed`:return u(e,{message:H({message:`conversation history compacted`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`step.failed`:case`turn.failed`:case`session.failed`:return;case`subagent.called`:return u(e,{message:H({message:`${t.type} (${t.data.name} -> ${t.data.childSessionId})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`info`,options:n})});case`subagent.started`:return u(e,{message:H({message:`${t.type} (${t.data.subagentName})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`info`,options:n})});case`subagent.event`:return u(e,{message:H({message:`${t.type} (${t.data.subagentName}: ${oe(t.data.event)})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`subagent.completed`:return u(e,{message:H({message:`${t.type} (${t.data.subagentName})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`info`,options:n})});default:return}}function G(e){switch(e.type){case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:return`content`;default:return`meta`}}function K(){return{activeLiveContentKind:null,lastPrintedBlockKind:null}}function q(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 J(e){let t=U(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=W(e.theme,e.event,e.options);return n===void 0?e.state:q({kind:G(e.event),line:n,state:e.state,terminal:e.terminal})}function Y(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}function X(e){return e.length===0}var ie=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:t(n.sessionId),serverUrl:this.#n});try{for await(let e of v({host:this.#n,maxReconnectAttempts:3,resolveHeaders:async()=>await g({resourceUrl:r}),sessionId:n.sessionId,signal:n.controller.signal,startIndex:0}))if(this.#t.current=J({event:e,options:{sourceKind:`subagent`,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}),a(e))return}catch(t){if(Y(t))return;let r=e(t);this.#t.current=q({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 Z(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 ae(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 oe(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} (${Z(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 se(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 ce(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`}):se(e,t.session)}function le(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 Q(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&&(ee(i,e),i.on(`keypress`,c)),e.prompt()})}async function $(e){let n=e.turn,r={current:K()},i=new ie({displayStateRef:r,serverUrl:e.serverUrl,terminal:e.terminal,theme:e.theme}),a=async t=>{e.terminal.startPrompt(e.rl,t);let n=await Q(e.rl,t,{allowEscape:!0});return e.terminal.stopPrompt(),n};try{for(;;){let o=e.client.getSession();r.current=q({kind:`meta`,line:ce(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=J({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=q({kind:`meta`,line:u(e.theme,{message:n.sessionId,tag:`session`,tone:`accent`}),state:r.current,terminal:e.terminal}),r.current=q({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(X(c)){await i.waitForIdle();for(let t of le(e.theme,s.events))r.current=q({kind:`meta`,line:t,state:r.current,terminal:e.terminal});return`continue`}let l=await f({ask:a,print(t){r.current=q({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=q({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 ue(t){let n=S(),r=o({color:!0}),i=C({input:process.stdin,output:n.output,terminal:!0});i.on(`SIGINT`,()=>{i.close()});let a=I({serverUrl:t.serverUrl});try{for(n.print(z(r,t)),n.print(``);;){n.print(``),n.startPrompt(i,`you> `);let o=await Q(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(z(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 $({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{K as createTurnDisplayState,U as formatContentEvent,W as formatEvent,J as renderTurnEvent,ue as runDevelopmentRepl,X 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,l as a}from"../../chunks/types-DDA2QUED.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,c as g,i as _,l as v,n as y,r as b,t as x}from"../../chunks/client-DLHAGI2g.js";import{createDevelopmentTerminal as S}from"./terminal.js";import{createInterface as C,emitKeypressEvents as ee}from"node:readline";function te(e){return[...e].reverse().find(a)}function ne(e){let t=new URL(e);return t.hash=``,t.search=``,t.pathname.endsWith(`/`)||(t.pathname=`${t.pathname}/`),t}function w(e){return new URL(e.routePath.replace(/^\/+/,``),ne(e.serverUrl))}function T(e){let t=e.resource.trim();try{return new URL(t)}catch{return w({routePath:t,serverUrl: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 v||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=h();async function j(){try{let e=(await(0,A.getVercelOidcToken)()).trim();if(e.length>0)return e}catch{}return process.env.VERCEL_OIDC_TOKEN?.trim()||``}const M=new Set([`localhost`,`127.0.0.1`,`0.0.0.0`,`::1`,`[::1]`]);function N(e){try{return M.has(new URL(e).hostname)}catch{return!1}}async function P(e){let t={},n=process.env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();if(n&&(t[y]=n),!e.isLocal){let e=await j();e.length>0&&(t[b]=e)}return t}var F=class{#e;#t;constructor(e){let t=N(e.serverUrl);this.#e=new x({headers:()=>P({isLocal:t}),host:e.serverUrl,...t?{}:{auth:{bearer:j}}}),this.#t=this.#e.session()}async clear(){this.#t=this.#e.session()}async close(){}getSession(){return this.#t.state}async sendMessage(e){return await this.send({message:e.message,onEvent:e.onEvent,onResponseStart:e.onResponseStart})}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 I(e){return new F(e)}function L(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 R(){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 z(e,t){return[s(e,{subtitle:`Interactive development REPL for the active Ash server.`,title:`Ash Dev`}),``,c(e,{rows:L(t),title:`Connection`}),``,c(e,{rows:R(),title:`Commands`})].join(`
3
+ `)}function re(e){let t=e.trim();return t.length>0?t:null}function B(e){return e.options?.sourceKind===`subagent`?`subagent`:e.fallback}function V(e){return e.options?.sourceKind===`subagent`?`subagent`:e.fallback}function H(e){return e.options?.sourceLabel===void 0?e.message:`${e.options.sourceLabel}${e.separator??` `}${e.message}`}function U(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:V({fallback:`accent`,options:n})})};case`message.completed`:if(t.data.message===null)return;if(t.data.finishReason===`tool-calls`){let r=re(t.data.message);return r===null?void 0:{finalized:!0,kind:`message`,line:u(e,{message:H({message:r,options:n,separator:`: `}),tag:B({fallback:`step`,options:n}),tone:V({fallback:`accent`,options:n})})}}return{finalized:!0,kind:`message`,line:l(e,{message:t.data.message,speaker:n?.sourceLabel??`agent`,tone:V({fallback:`accent`,options:n})})};case`reasoning.appended`:return{finalized:!1,kind:`reasoning`,line:u(e,{message:H({message:t.data.reasoningSoFar,options:n,separator:`: `}),tag:B({fallback:`reasoning`,options:n}),tone:V({fallback:`info`,options:n})})};case`reasoning.completed`:return{finalized:!0,kind:`reasoning`,line:u(e,{message:H({message:t.data.reasoning,options:n,separator:`: `}),tag:B({fallback:`reasoning`,options:n}),tone:V({fallback:`info`,options:n})})};default:return}}function W(e,t,n){let r=U(e,t,n);if(r!==void 0)return r.line;switch(t.type){case`message.received`:return;case`actions.requested`:return u(e,{message:H({message:`${t.type} (${t.data.actions.length} action${t.data.actions.length===1?``:`s`})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`input.requested`:return u(e,{message:H({message:`${t.type} (${t.data.requests.length} request${t.data.requests.length===1?``:`s`})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`info`,options:n})});case`action.result`:return u(e,{message:H({message:`${t.type} (${Z(t.data.result)})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`session.waiting`:case`session.completed`:return;case`connection.authorization_required`:return u(e,{message:H({message:`${t.type} (${t.data.connectionName}: ${t.data.description}${ae(t.data.authorization)})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`warning`,options:n})});case`compaction.requested`:return u(e,{message:H({message:`compacting conversation history`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`compaction.completed`:return u(e,{message:H({message:`conversation history compacted`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`step.failed`:case`turn.failed`:case`session.failed`:return;case`subagent.called`:return u(e,{message:H({message:`${t.type} (${t.data.name} -> ${t.data.childSessionId})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`info`,options:n})});case`subagent.started`:return u(e,{message:H({message:`${t.type} (${t.data.subagentName})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`info`,options:n})});case`subagent.event`:return u(e,{message:H({message:`${t.type} (${t.data.subagentName}: ${oe(t.data.event)})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`muted`,options:n})});case`subagent.completed`:return u(e,{message:H({message:`${t.type} (${t.data.subagentName})`,options:n}),tag:B({fallback:`event`,options:n}),tone:V({fallback:`info`,options:n})});default:return}}function G(e){switch(e.type){case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:return`content`;default:return`meta`}}function K(){return{activeLiveContentKind:null,lastPrintedBlockKind:null}}function q(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 J(e){let t=U(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=W(e.theme,e.event,e.options);return n===void 0?e.state:q({kind:G(e.event),line:n,state:e.state,terminal:e.terminal})}function Y(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}function X(e){return e.length===0}var ie=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:t(n.sessionId),serverUrl:this.#n});try{for await(let e of g({host:this.#n,maxReconnectAttempts:3,resolveHeaders:async()=>await _({resourceUrl:r}),sessionId:n.sessionId,signal:n.controller.signal,startIndex:0}))if(this.#t.current=J({event:e,options:{sourceKind:`subagent`,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}),a(e))return}catch(t){if(Y(t))return;let r=e(t);this.#t.current=q({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 Z(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 ae(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 oe(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} (${Z(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 se(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 ce(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`}):se(e,t.session)}function le(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 Q(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&&(ee(i,e),i.on(`keypress`,c)),e.prompt()})}async function $(e){let n=e.turn,r={current:K()},i=new ie({displayStateRef:r,serverUrl:e.serverUrl,terminal:e.terminal,theme:e.theme}),a=async t=>{e.terminal.startPrompt(e.rl,t);let n=await Q(e.rl,t,{allowEscape:!0});return e.terminal.stopPrompt(),n};try{for(;;){let o=e.client.getSession();r.current=q({kind:`meta`,line:ce(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=J({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=q({kind:`meta`,line:u(e.theme,{message:n.sessionId,tag:`session`,tone:`accent`}),state:r.current,terminal:e.terminal}),r.current=q({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(X(c)){await i.waitForIdle();for(let t of le(e.theme,s.events))r.current=q({kind:`meta`,line:t,state:r.current,terminal:e.terminal});return`continue`}let l=await f({ask:a,print(t){r.current=q({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=q({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 ue(t){let n=S(),r=o({color:!0}),i=C({input:process.stdin,output:n.output,terminal:!0});i.on(`SIGINT`,()=>{i.close()});let a=I({serverUrl:t.serverUrl});try{for(n.print(z(r,t)),n.print(``);;){n.print(``),n.startPrompt(i,`you> `);let o=await Q(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(z(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 $({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{K as createTurnDisplayState,U as formatContentEvent,W as formatEvent,J as renderTurnEvent,ue as runDevelopmentRepl,X as shouldDrainSubagentStreamsOnBoundary};
@@ -1 +1 @@
1
- import{t as e}from"../../chunks/url-BVRhVE2O.js";export{e as parseDevelopmentServerUrl};
1
+ import{t as e}from"../../chunks/url-JdCGA634.js";export{e as parseDevelopmentServerUrl};
@@ -1,3 +1,3 @@
1
- import{t as e}from"../chunks/package-DmsQgn4v.js";import{createCliTheme as t,renderCliTaggedLine as n}from"./ui/output.js";import{i as r,n as i,r as a,t as o}from"../chunks/url-BVRhVE2O.js";import{resolve as s}from"node:path";async function c(){return(await import(`../chunks/host-3sfHdmXL.js`).then(e=>e.t)).buildHost}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-3sfHdmXL.js`).then(e=>e.t)).startHost}function p(e=process.cwd()){return s(e)}function m(e){return`Ash (v${e})`}function h(e){return e.name()===`info`||e.name()===`dev`}async function g(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 _(e){if(!/^-?\d+$/.test(e))throw new r(`Expected a numeric port, received "${e}".`);let t=Number(e);if(!Number.isInteger(t))throw new r(`Expected a numeric port, received "${e}".`);if(t<0||t>65535)throw new r(`Expected a port between 0 and 65535, received "${e}".`);return t}function v(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function y(e){let t=e[1];return e[0]!==`dev`||e.length!==2||t===void 0||t.startsWith(`-`)?[...e]:[`dev`,`--url`,t]}function b(e){if(e.url){if(e.host!==void 0)throw new r(`The --host option cannot be used with --url.`);if(e.port!==void 0)throw new r(`The --port option cannot be used with --url.`);if(e.repl===!1)throw new r(`The --no-repl option cannot be used with --url.`);return e.url}}function x(r,a){let s=p(),y=e().version,x=new i,S=t();return x.name(`ash`).description(`Build and run an Ash application.`).version(y).showHelpAfterError().exitOverride().hook(`preAction`,(e,t)=>{h(t)&&r.log(m(y))}).configureOutput({writeErr:e=>{r.error(e.trimEnd())},writeOut:e=>{r.log(e.trimEnd())}}),x.command(`build`).description(`Build the current Ash application.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:e}=await import(`./dev/environment.js`);e(s);let t=await(a.buildHost??await c())(s);r.log(n(S,{message:`built output at ${t}`,tag:`build`,tone:`success`}))}),x.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)`,_).option(`--schedules`,`Run scheduled tasks during development (off by default)`).option(`-u, --url <url>`,`Connect the REPL to an existing server URL`,o).addHelpText(`after`,`
1
+ import{t as e}from"../chunks/package-HUaeub_D.js";import{createCliTheme as t,renderCliTaggedLine as n}from"./ui/output.js";import{i as r,n as i,r as a,t as o}from"../chunks/url-JdCGA634.js";import{resolve as s}from"node:path";async function c(){return(await import(`../chunks/host-zBy9FyyX.js`).then(e=>e.t)).buildHost}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-zBy9FyyX.js`).then(e=>e.t)).startHost}function p(e=process.cwd()){return s(e)}function m(e){return`Ash (v${e})`}function h(e){return e.name()===`info`||e.name()===`dev`}async function g(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 _(e){if(!/^-?\d+$/.test(e))throw new r(`Expected a numeric port, received "${e}".`);let t=Number(e);if(!Number.isInteger(t))throw new r(`Expected a numeric port, received "${e}".`);if(t<0||t>65535)throw new r(`Expected a port between 0 and 65535, received "${e}".`);return t}function v(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function y(e){let t=e[1];return e[0]!==`dev`||e.length!==2||t===void 0||t.startsWith(`-`)?[...e]:[`dev`,`--url`,t]}function b(e){if(e.url){if(e.host!==void 0)throw new r(`The --host option cannot be used with --url.`);if(e.port!==void 0)throw new r(`The --port option cannot be used with --url.`);if(e.repl===!1)throw new r(`The --no-repl option cannot be used with --url.`);return e.url}}function x(r,a){let s=p(),y=e().version,x=new i,S=t();return x.name(`ash`).description(`Build and run an Ash application.`).version(y).showHelpAfterError().exitOverride().hook(`preAction`,(e,t)=>{h(t)&&r.log(m(y))}).configureOutput({writeErr:e=>{r.error(e.trimEnd())},writeOut:e=>{r.log(e.trimEnd())}}),x.command(`build`).description(`Build the current Ash application.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:e}=await import(`./dev/environment.js`);e(s);let t=await(a.buildHost??await c())(s);r.log(n(S,{message:`built output at ${t}`,tag:`build`,tone:`success`}))}),x.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)`,_).option(`--schedules`,`Run scheduled tasks during development (off by default)`).option(`-u, --url <url>`,`Connect the REPL to an existing server URL`,o).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=b(e),{loadDevelopmentEnvironmentFiles:i}=await import(`./dev/environment.js`);if(i(s),t){if(r.log(n(S,{message:`REPL connecting to ${t}`,tag:`dev`,tone:`info`})),!v()){r.log(n(S,{message:`Interactive REPL disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}r.log(``),await(a.runDevelopmentRepl??await u())({serverUrl:t});return}let o=await(a.startHost??await f())(s,{host:e.host,port:e.port,schedules:e.schedules===!0}),c=!1,l=async()=>{c||(c=!0,await o.close())};try{if(r.log(n(S,{message:`server listening at ${o.url}`,tag:`dev`,tone:`success`})),e.repl===!1)return await g({close:l});if(!v())return r.log(n(S,{message:`Interactive REPL disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await g({close:l});r.log(``),await(a.runDevelopmentRepl??await u())({serverUrl:o.url})}finally{await l()}}),x.command(`info`).description(`Print resolved application information.`).action(async()=>{await(a.printApplicationInfo??await l())(r,s)}),x.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(`--list-suites`,`List discovered suites and exit`).option(`--skip-report`,`Skip suite-defined reporters (e.g. Braintrust)`).action(async e=>{await(a.runEvalCommand??await d())(e,r)}),x}async function S(e=process.argv.slice(2),t=console,n={}){let r=x(t,n),i=e.length===0?[`info`]:y(e);try{await r.parseAsync(i,{from:`user`})}catch(e){if(e instanceof a){if(e.exitCode===0)return;throw Error(e.message)}throw e}}export{S as runCli};
@@ -1,4 +1,4 @@
1
- import{i as e}from"../../chunks/chunk-8L7ocgPr.js";import{t}from"../../chunks/picocolors-Bq-tZK9u.js";var n=e(t(),1);function r(e,t,n){switch(t){case`accent`:return e.accent(n);case`danger`:return e.danger(n);case`info`:return e.info(n);case`muted`:return e.muted(n);case`subagent`:return e.subagent(n);case`success`:return e.success(n);case`warning`:return e.warning(n);default:return e.plain(n)}}function i(e,t){let[n=``,...r]=e;return[n,...r.map(e=>`${t}${e}`)]}function a(e){return e.color?`\u001B[38;5;208m${e.text}\u001B[39m`:e.text}function o(e={}){let t=n.default.createColors(e.color??!!process.stdout.isTTY);return{accent:e=>t.cyan(e),color:t.isColorSupported,danger:e=>t.red(e),heading:e=>t.bold(t.cyan(e)),info:e=>t.blue(e),label:e=>t.bold(e),muted:e=>t.dim(e),plain:e=>e,subagent:e=>a({color:t.isColorSupported,text:e}),success:e=>t.green(e),warning:e=>t.yellow(e)}}function s(e,t){let n=[e.heading(t.title),e.muted(`=`.repeat(t.title.length))];return t.subtitle&&n.push(e.muted(t.subtitle)),n.join(`
1
+ import{i as e}from"../../chunks/chunk-DSjMdhoD.js";import{t}from"../../chunks/picocolors-aAkqW4On.js";var n=e(t(),1);function r(e,t,n){switch(t){case`accent`:return e.accent(n);case`danger`:return e.danger(n);case`info`:return e.info(n);case`muted`:return e.muted(n);case`subagent`:return e.subagent(n);case`success`:return e.success(n);case`warning`:return e.warning(n);default:return e.plain(n)}}function i(e,t){let[n=``,...r]=e;return[n,...r.map(e=>`${t}${e}`)]}function a(e){return e.color?`\u001B[38;5;208m${e.text}\u001B[39m`:e.text}function o(e={}){let t=n.default.createColors(e.color??!!process.stdout.isTTY);return{accent:e=>t.cyan(e),color:t.isColorSupported,danger:e=>t.red(e),heading:e=>t.bold(t.cyan(e)),info:e=>t.blue(e),label:e=>t.bold(e),muted:e=>t.dim(e),plain:e=>e,subagent:e=>a({color:t.isColorSupported,text:e}),success:e=>t.green(e),warning:e=>t.yellow(e)}}function s(e,t){let n=[e.heading(t.title),e.muted(`=`.repeat(t.title.length))];return t.subtitle&&n.push(e.muted(t.subtitle)),n.join(`
2
2
  `)}function c(e,t){let n=t.rows.reduce((e,t)=>Math.max(e,t.label.length),0),a=[e.accent(t.title)];for(let o of t.rows){let[t=``,...s]=i(r(e,o.tone??`default`,o.value).split(`
3
3
  `),`${` `.repeat(n)} `);a.push(`${e.label(o.label.padEnd(n))} ${t}`),a.push(...s)}return a.join(`
4
4
  `)}function l(e,t){let n=`[${t.tag.toUpperCase()}]`,[a=``,...o]=i(r(e,t.tone??`default`,t.message).split(`
@@ -10,3 +10,4 @@ export type { ActionResultStreamEvent, ActionsRequestedStreamEvent, AssistantSte
10
10
  export { isCurrentTurnBoundaryEvent } from "#protocol/message.js";
11
11
  export type { InputOption, InputRequest, InputResponse } from "#runtime/input/types.js";
12
12
  export { inputOptionSchema, inputRequestSchema, inputResponseSchema, isInputRequest, isInputResponse, } from "#runtime/input/types.js";
13
+ export { resolveTextToResponse, resolveTextToResponses } from "#channel/resolve-text.js";
@@ -8,3 +8,4 @@ export { MessageResponse } from "#client/message-response.js";
8
8
  export { ClientSession } from "#client/session.js";
9
9
  export { isCurrentTurnBoundaryEvent } from "#protocol/message.js";
10
10
  export { inputOptionSchema, inputRequestSchema, inputResponseSchema, isInputRequest, isInputResponse, } from "#runtime/input/types.js";
11
+ export { resolveTextToResponse, resolveTextToResponses } from "#channel/resolve-text.js";
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "moduleVersions": {
3
3
  "@ai-sdk/anthropic": "4.0.0-canary.57",
4
- "chat": "4.28.1",
5
- "@chat-adapter/slack": "4.28.1",
6
- "@chat-adapter/state-memory": "4.28.1",
4
+ "chat": "4.29.0",
5
+ "@chat-adapter/slack": "4.29.0",
6
+ "@chat-adapter/state-memory": "4.29.0",
7
7
  "@ai-sdk/google": "4.0.0-canary.69",
8
8
  "jose": "6.2.3",
9
- "just-bash": "2.14.5",
9
+ "just-bash": "3.0.1",
10
+ "jsonc-parser": "3.3.1",
10
11
  "@ai-sdk/mcp": "2.0.0-canary.52",
11
12
  "@ai-sdk/openai": "4.0.0-canary.62",
12
13
  "@opentelemetry/api": "1.9.1",
@@ -14,11 +15,11 @@
14
15
  "@ai-sdk/provider": "4.0.0-canary.17",
15
16
  "@standard-schema/spec": "1.1.0",
16
17
  "turndown": "7.2.4",
17
- "@vercel/sandbox": "2.0.0-beta.14",
18
+ "@vercel/sandbox": "2.0.0",
18
19
  "@workflow/core": "5.0.0-beta.7",
19
20
  "@workflow/errors": "5.0.0-beta.4",
20
21
  "zod": "4.4.3",
21
22
  "zod-validation-error": "5.0.0"
22
23
  },
23
- "scriptHash": "7fbc085b9ab020af451fc7dfbdd8ae8c5e8eca101bf5c39cc9edb2d63d7231db"
24
+ "scriptHash": "5c7b8cab469fbc4adca392b2abf448ea2729421fe97f353cb77c0da982d8c5f9"
24
25
  }