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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # experimental-ash
2
2
 
3
+ ## 0.24.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 684b8a2: Update package dependencies and keep docs builds compatible with the upgraded docs stack.
8
+ - 824fd46: Reload development `.env` files when `ash dev` detects changes, while preserving parent-process environment variable precedence.
9
+
3
10
  ## 0.24.1
4
11
 
5
12
  ### Patch Changes
@@ -0,0 +1,4 @@
1
+ import{createRequire as e}from"node:module";import{dirname as t,extname as n,isAbsolute as r,join as i,resolve as a,sep as o}from"node:path";import{readFile as s,stat as c}from"node:fs/promises";import{createHash as l}from"node:crypto";import{existsSync as u,mkdirSync as ee,writeFileSync as d}from"node:fs";import{pathToFileURL as f}from"node:url";import{parse as p}from"#compiled/jsonc-parser/index.js";function m(e,t){return e[t.exportName??`default`]}async function h(e){return typeof e==`function`?await e():e}function g(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e}function _(e,t){if(typeof e!=`string`)throw Error(t);return e}function te(e,t){if(typeof e!=`function`)throw Error(t);return e}function ne(e,t){let n=g(e,t),r={};for(let[e,i]of Object.entries(n))r[e]=g(i,t);return r}function v(e,t,n){let r=new Set(t);for(let t of Object.keys(e))if(!r.has(t))throw Error(`${n} Unknown key "${t}".`)}function y(e,t,n){let r=e[t];if(r===void 0)return;let i=g(r,n),a={};for(let[e,t]of Object.entries(i))a[e]=_(t,n);return a}const b=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function x(){return{name:`ash-authored-asset-import`,resolveId(e,n){if(!C(e)||n===void 0)return;let{path:i,suffix:o}=w(e);return`${r(i)?i:a(t(n),i)}${o}`},async load(e){let{path:t,suffix:n}=w(e);if(!C(t))return;if(n===`?raw`){let e=await S(t);return e===void 0?void 0:{code:`export default ${JSON.stringify(e)};`,moduleType:`js`}}let r=await re(t);if(r!==void 0)return{code:`export default ${JSON.stringify(r)};`,moduleType:`js`}}}}async function S(e){try{return await s(e,`utf8`)}catch(e){if(T(e))return;throw e}}function C(e){if(e.startsWith(`\0`)||e.startsWith(`node:`)||e.startsWith(`data:`)||e.startsWith(`file:`))return!1;let{path:t}=w(e);if(!t.startsWith(`.`)&&!t.startsWith(`/`)&&!/^[A-Za-z]:[\\/]/.test(t))return!1;let r=n(t);return r.length>0&&r!==`.node`&&!b.includes(r)}function w(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)}}async function re(e){try{let t=await s(e);return`data:${ie(e)};base64,${t.toString(`base64`)}`}catch(e){if(T(e))return;throw e}}function T(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`)}function ie(e){switch(n(e).toLowerCase()){case`.css`:return`text/css`;case`.csv`:return`text/csv`;case`.gif`:return`image/gif`;case`.html`:return`text/html`;case`.jpg`:case`.jpeg`:return`image/jpeg`;case`.png`:return`image/png`;case`.svg`:return`image/svg+xml`;case`.txt`:return`text/plain`;case`.wasm`:return`application/wasm`;case`.webp`:return`image/webp`;default:return`application/octet-stream`}}function ae(e,t){let n=t instanceof Error?t.message:String(t),r=[];return(/\.node(?:\b|["'?])/i.test(n)||/native addon|native module|invalid utf-?8|Could not load .*\.node/i.test(n))&&r.push(`If this comes from a native Node package, keep that package external with agent build.externalDependencies so Vercel/Nitro traces it instead of bundling it.`),/Unexpected character|No loader is configured|Could not load|Unknown file extension/i.test(n)&&r.push(`If this comes from an asset import, Ash only supports assets that Rolldown can emit for a Node ESM bundle; otherwise load the file through fs/import.meta.url or externalize the package.`),Error([`Failed to bundle authored module "${e}".`,n,...r.map(e=>`Hint: ${e}`)].join(`
2
+ `))}const E=new Map,D=new Map;function oe(e){return{name:`ash-package-tsconfig-paths`,async resolveId(t,n,r){if(n===void 0||!R(t))return;let i=a(n);if(B(i,e.appPackageRoot))return;let o=await P(i);if(o===void 0||B(o,e.appPackageRoot))return;let s=await se(o);if(s!==void 0)for(let i of A(t,s)){let t=await this.resolve(i,n,{kind:r.kind,skipSelf:!0});if(t!==null)return t;let a=await M(i,e.extensions);if(a!==void 0)return{id:a}}}}}function se(e){let t=E.get(e);if(t!==void 0)return t;let n=O(e);return E.set(e,n),n}async function O(e){let n=await k(e);if(n===void 0)return;let r=[],i=p(n.source,r,{allowTrailingComma:!0});if(r.length>0||!z(i))return;let o=i.compilerOptions;if(!z(o)||!z(o.paths))return;let s=t(n.path),c=typeof o.baseUrl==`string`?a(s,o.baseUrl):s,l=Object.entries(o.paths).flatMap(([e,t])=>!Array.isArray(t)||!t.every(e=>typeof e==`string`)?[]:[{pattern:e,targets:t}]).sort((e,t)=>t.pattern.length-e.pattern.length);if(l.length!==0)return{baseDirectory:c,entries:l}}async function k(e){for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=i(e,t);try{return{path:n,source:await s(n,`utf8`)}}catch(e){if(!L(e))throw e}}}function A(e,t){let n=[];for(let r of t.entries){let i=j(e,r.pattern);if(i!==void 0)for(let e of r.targets){let r=e.includes(`*`)?e.replaceAll(`*`,i):e;n.push(a(t.baseDirectory,r))}}return n}function j(e,t){let n=t.indexOf(`*`);if(n===-1)return e===t?``:void 0;let r=t.slice(0,n),i=t.slice(n+1);if(!(!e.startsWith(r)||!e.endsWith(i)))return e.slice(r.length,e.length-i.length)}async function M(e,t){if(await N(e))return e;for(let n of t){let t=`${e}${n}`;if(await N(t))return t}for(let n of t){let t=i(e,`index${n}`);if(await N(t))return t}}async function N(e){try{return(await c(e)).isFile()}catch{return!1}}function P(e){let n=t(e),r=D.get(n);if(r!==void 0)return r;let i=F(n);return D.set(n,i),i}async function F(e){let n=e;for(;;){if(await I(i(n,`package.json`)))return n;let e=t(n);if(e===n)return;n=e}}async function I(e){try{return await c(e),!0}catch{return!1}}function L(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`)}function R(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)?!1:!/^(?:node|data|file):/.test(e)}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function B(e,t){let n=a(e),r=a(t);return n===r||n.startsWith(`${r}${o}`)}let V,H;function U(){return V??=(async()=>await import(f(e(e(import.meta.url).resolve(`nitro/package.json`)).resolve(`rolldown`)).href))(),V}function W(){return H??=(async()=>await import(f(e(e(import.meta.url).resolve(`nitro/package.json`)).resolve(`rolldown/parseAst`)).href))(),H}async function G(e){let{build:t}=await U();return await t(e)}function K(e,t){let n=e.output.filter(e=>e.type===`chunk`),r=n[0];if(r===void 0||n.length!==1)throw Error(`Expected one bundled ${t}.`);return r}const ce=[{importLine:`import { fileURLToPath as __ashFileURLToPath } from "node:url";`,declarationLine:`const __filename = __ashFileURLToPath(import.meta.url);`,bindingPattern:/^(?:const|let|var)\s+__filename\b/m},{importLine:`import { dirname as __ashDirname } from "node:path";`,declarationLine:`const __dirname = __ashDirname(__filename);`,bindingPattern:/^(?:const|let|var)\s+__dirname\b/m}],le={importLine:`import { createRequire as __ashCreateRequire } from "node:module";`,declarationLine:`const require = __ashCreateRequire(import.meta.url);`,bindingPattern:/^(?:const|let|var)\s+require\b/m};function ue(e,t={}){let n=[...ce];t.includeRequire===!0&&n.push(le);let r=[],i=[];for(let t of n)t.bindingPattern.test(e)||(r.push(t.importLine),i.push(t.declarationLine));return i.length===0?``:[...r,...i].join(`
3
+ `)}function q(e={}){return{name:`ash-node-esm-compat-banner`,renderChunk(t){let n=ue(t,e);return n===``?null:{code:`${n}\n${t}`}}}}const de=/\.[cm]?[jt]sx?$/,fe=i(`node_modules`,`.cache`,`experimental-ash`,`authored-modules`),J=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`],Y=`__ashChannelModuleCache__`,X=`ash-cached-channel:`;function pe(){return globalThis[Y]}const Z=new Map;function me(e){let t=a(e),n=Z.get(t);if(n!==void 0)return n;let r=(async()=>{try{return await he(e)}finally{Z.delete(t)}})();return Z.set(t,r),r}async function he(e){return g(de.test(e)?await ge(e):await import(Q(e)),`Expected "${e}" to export a module namespace object.`)}function Q(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}async function ge(e){let t=pe(),n=Se(e),r=xe(n),o=t&&t.size>0?{name:`ash-channel-identity`,async resolveId(e,n,r){if(!/channels[/\\]/.test(e)||r.kind!==`import-statement`)return;let i=await this.resolve(e,n,{kind:r.kind,skipSelf:!0});if(i===null||typeof i.id!=`string`)return;let o=a(i.id);if(t.has(o))return{id:`${X}${o}`}},load(e){if(!e.startsWith(X))return;let t=e.slice(19);return{code:[`const cache = globalThis["${Y}"];`,`export default cache.get(${JSON.stringify(t)});`].join(`
4
+ `),moduleType:`js`}}}:null,s=[x(),oe({appPackageRoot:n,extensions:J}),q({includeRequire:!0}),$(n),o].filter(e=>e!==null),c;try{c=K(await G({cwd:n,input:e,platform:`node`,plugins:s,resolve:{extensions:[...J]},tsconfig:r,write:!1,output:{comments:!1,format:`esm`,sourcemap:`inline`}}),`authored module for "${e}"`)}catch(t){throw ae(e,t)}let f=l(`sha1`).update(e).update(`\0`).update(c.code).digest(`hex`),p=i(n,fe),m=i(p,`${f}.mjs`);return u(m)||(ee(p,{recursive:!0}),d(m,c.code)),await import(`${Q(m)}?v=${f}`)}function $(e){return{name:`ash-package-boundary`,async resolveId(t,n,r){if(!_e(t))return;if(ve(t))return{external:!0,id:t};let i=n===void 0||n.startsWith(`\0`)||n.startsWith(X)?void 0:a(n);if(i!==void 0&&be(i,e)){let e=await this.resolve(t,n,{kind:r.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`||ye(e.id))return{external:!0,id:t}}}}}function _e(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)||/^(?:node|data|file):/.test(e)||e.startsWith(`@/`)?!1:!e.startsWith(X)}function ve(e){return e===`experimental-ash`||e.startsWith(`experimental-ash/`)}function ye(e){return e.replaceAll(`\\`,`/`).includes(`/node_modules/`)}function be(e,t){let n=a(e),r=a(t);return n===r||n.startsWith(`${r}${o}`)}function xe(e){for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=i(e,t);if(u(n))return n}return!1}function Se(e){let n=t(e);for(;;){if(u(i(n,`package.json`)))return n;let r=t(n);if(r===n)throw Error(`Failed to resolve the authored package root for "${e}".`);n=r}}export{W as a,v as c,m as d,y as f,K as i,ne as l,q as n,te as o,h as p,G as r,g as s,me as t,_ as u};
@@ -0,0 +1,4 @@
1
+ import{i as e,r as t,t as n}from"./chunk-DSjMdhoD.js";import{_ as r,f as i,g as a,l as o,p as s,v as c}from"./types-DDA2QUED.js";var l=class extends Error{status;body;constructor(e,t){super(t||`Server returned ${e}.`),this.name=`ClientError`,this.status=e,this.body=t}};function u(e){if(e instanceof DOMException)return e.name===`AbortError`;if(!(e instanceof Error))return!1;let t=`code`in e&&typeof e.code==`string`?e.code:void 0;return e.name===`AbortError`||e.message===`terminated`||t===`UND_ERR_SOCKET`||/abort|cancel|disconnect|premature close|socket|terminated/i.test(e.message)}async function*d(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let e=await t.read();if(e.done){r+=n.decode();break}e.value&&(r+=n.decode(e.value,{stream:!0}));let i=r.indexOf(`
2
+ `);for(;i!==-1;){let e=r.slice(0,i).trim();r=r.slice(i+1),e.length>0&&(yield JSON.parse(e)),i=r.indexOf(`
3
+ `)}}let e=r.trim();e.length>0&&(yield JSON.parse(e))}finally{t.releaseLock()}}function f(e,t,n){let r=t.startsWith(`/`)?t:`/${t}`,i=h(n);if(p(e)){let t=new URL(e);return t.pathname=`${m(t.pathname)}${r}`,t.search=i,t.hash=``,t.toString()}return`${m(e)}${r}${i}`}function p(e){return/^[a-z][a-z\d+\-.]*:/i.test(e)}function m(e){return e===`/`?``:e.endsWith(`/`)?e.slice(0,-1):e}function h(e){return!e||Object.keys(e).length===0?``:`?${new URLSearchParams(e).toString()}`}async function*g(e){let t=e.startIndex,n=e.maxReconnectAttempts;for(;;){let r=f(e.host,c(e.sessionId),t>0?{startIndex:String(t)}:void 0),i=await e.resolveHeaders(),a=await fetch(r,{headers:i,signal:e.signal??null});if(!a.ok){let e=await a.text();throw new l(a.status,e)}if(!a.body)throw new l(a.status,`Response body is null.`);let o=!1;try{for await(let e of d(a.body))t+=1,yield e}catch(e){if(!u(e))throw e;o=!0}if(!o||n<=0)return;--n}}var _=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}})),v=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{VercelOidcTokenError:()=>u}),t.exports=c(l);var u=class extends Error{constructor(e,t){super(e),this.name=`VercelOidcTokenError`,this.cause=t}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}}})),y=n(((t,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{getVercelOidcToken:()=>p,getVercelOidcTokenSync:()=>m}),n.exports=l(u);var d=_(),f=v();async function p(t){let n=``,r;try{n=m()}catch(e){r=e}try{let[{getTokenPayload:r,isExpired:i},{refreshToken:a}]=await Promise.all([await Promise.resolve().then(()=>e(w())),await import(`./token-D98SQdvs.js`).then(t=>e(t.default))]);(!n||i(r(n),t?.expirationBufferMs))&&(await a(t),n=m())}catch(e){let t=r instanceof Error?r.message:``;throw e instanceof Error&&(t=`${t}
4
+ ${e.message}`),t?new f.VercelOidcTokenError(t):e}return n}function m(){let e=(0,d.getContext)().headers?.[`x-vercel-oidc-token`]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error(`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`);return e}})),b=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>u,RefreshAccessTokenFailedError:()=>d}),t.exports=c(l);var u=class extends Error{constructor(){super(`No authentication found. Please log in with the Vercel CLI (vercel login).`),this.name=`AccessTokenMissingError`}},d=class extends Error{constructor(e){super(`Failed to refresh authentication token.`,{cause:e}),this.name=`RefreshAccessTokenFailedError`}}})),x=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{findRootDir:()=>y,getUserDataDir:()=>b}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=d(t(`os`)),_=v();function y(){try{let e=process.cwd();for(;e!==m.default.dirname(e);){let t=m.default.join(e,`.vercel`);if(h.default.existsSync(t))return e;e=m.default.dirname(e)}}catch{throw new _.VercelOidcTokenError(`Token refresh only supported in node server environments`)}return null}function b(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(g.default.platform()){case`darwin`:return m.default.join(g.default.homedir(),`Library/Application Support`);case`linux`:return m.default.join(g.default.homedir(),`.local/share`);case`win32`:return process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:null;default:return null}}})),S=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{isValidAccessToken:()=>b,readAuthConfig:()=>v,writeAuthConfig:()=>y}),n.exports=f(p);var m=d(t(`fs`)),h=d(t(`path`)),g=w();function _(){let e=(0,g.getVercelDataDir)();if(!e)throw Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return h.join(e,`auth.json`)}function v(){try{let e=_();if(!m.existsSync(e))return null;let t=m.readFileSync(e,`utf8`);return t?JSON.parse(t):null}catch{return null}}function y(e){let t=_(),n=h.dirname(t);m.existsSync(n)||m.mkdirSync(n,{mode:504,recursive:!0}),m.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function b(e,t=0){if(!e.token)return!1;if(typeof e.expiresAt!=`number`)return!0;let n=Math.floor(Date.now()/1e3),r=t/1e3;return e.expiresAt>=n+r}})),C=n(((e,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{processTokenResponse:()=>g,refreshTokenRequest:()=>h}),n.exports=l(u);var d=t(`os`);let f=`@vercel/oidc node-${process.version} ${(0,d.platform)()} (${(0,d.arch)()}) ${(0,d.hostname)()}`,p=null;async function m(){if(p)return p;let e=await fetch(`https://vercel.com/.well-known/openid-configuration`,{headers:{"user-agent":f}});if(!e.ok)throw Error(`Failed to discover OAuth endpoints`);let t=await e.json();if(!t||typeof t.token_endpoint!=`string`)throw Error(`Invalid OAuth discovery response`);let n=t.token_endpoint;return p=n,n}async function h(e){let t=await m();return await fetch(t,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":f},body:new URLSearchParams({client_id:`cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp`,grant_type:`refresh_token`,...e})})}async function g(e){let t=await e.json();if(!e.ok){let e=typeof t==`object`&&t&&`error`in t?String(t.error):`Token refresh failed`;return[Error(e)]}return typeof t!=`object`||!t?[Error(`Invalid token response`)]:typeof t.access_token==`string`?t.token_type===`Bearer`?typeof t.expires_in==`number`?[null,t]:[Error(`Missing expires_in in response`)]:[Error(`Invalid token_type in response`)]:[Error(`Missing access_token in response`)]}})),w=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{assertVercelOidcTokenResponse:()=>k,findProjectInfo:()=>A,getTokenPayload:()=>N,getVercelDataDir:()=>E,getVercelOidcToken:()=>O,getVercelToken:()=>D,isExpired:()=>P,loadToken:()=>M,saveToken:()=>j}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=v(),_=x(),y=S(),w=C(),T=b();function E(){let e=(0,_.getUserDataDir)();return e?m.join(e,`com.vercel.cli`):null}async function D(e){let t=(0,y.readAuthConfig)();if(!t?.token)throw new T.AccessTokenMissingError;if((0,y.isValidAccessToken)(t,e?.expirationBufferMs))return t.token;if(!t.refreshToken)throw(0,y.writeAuthConfig)({}),new T.RefreshAccessTokenFailedError(`No refresh token available`);try{let e=await(0,w.refreshTokenRequest)({refresh_token:t.refreshToken}),[n,r]=await(0,w.processTokenResponse)(e);if(n||!r)throw(0,y.writeAuthConfig)({}),new T.RefreshAccessTokenFailedError(n);let i={token:r.access_token,expiresAt:Math.floor(Date.now()/1e3)+r.expires_in};return r.refresh_token&&(i.refreshToken=r.refresh_token),(0,y.writeAuthConfig)(i),i.token}catch(e){throw(0,y.writeAuthConfig)({}),e instanceof T.AccessTokenMissingError||e instanceof T.RefreshAccessTokenFailedError?e:new T.RefreshAccessTokenFailedError(e)}}async function O(e,t,n){let r=`https://api.vercel.com/v1/projects/${t}/token?source=vercel-oidc-refresh${n?`&teamId=${n}`:``}`,i=await fetch(r,{method:`POST`,headers:{Authorization:`Bearer ${e}`}});if(!i.ok)throw new g.VercelOidcTokenError(`Failed to refresh OIDC token: ${i.statusText}`);let a=await i.json();return k(a),a}function k(e){if(!e||typeof e!=`object`)throw TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!(`token`in e)||typeof e.token!=`string`)throw TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function A(){let e=(0,_.findRootDir)();if(!e)throw new g.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let t=m.join(e,`.vercel`,`project.json`);if(!h.existsSync(t))throw new g.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let n=JSON.parse(h.readFileSync(t,`utf8`));if(typeof n.projectId!=`string`&&typeof n.orgId!=`string`)throw TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:n.projectId,teamId:n.orgId}}function j(e,t){let n=(0,_.getUserDataDir)();if(!n)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let r=m.join(n,`com.vercel.token`,`${t}.json`),i=JSON.stringify(e);h.mkdirSync(m.dirname(r),{mode:504,recursive:!0}),h.writeFileSync(r,i),h.chmodSync(r,432)}function M(e){let t=(0,_.getUserDataDir)();if(!t)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let n=m.join(t,`com.vercel.token`,`${e}.json`);if(!h.existsSync(n))return null;let r=JSON.parse(h.readFileSync(n,`utf8`));return k(r),r}function N(e){let t=e.split(`.`);if(t.length!==3)throw new g.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`),r=n.padEnd(n.length+(4-n.length%4)%4,`=`);return JSON.parse(Buffer.from(r,`base64`).toString(`utf8`))}function P(e,t=0){return e.exp*1e3<Date.now()+t}})),T=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>f.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>f.RefreshAccessTokenFailedError,getContext:()=>d.getContext,getVercelOidcToken:()=>u.getVercelOidcToken,getVercelOidcTokenSync:()=>u.getVercelOidcTokenSync,getVercelToken:()=>p.getVercelToken}),t.exports=c(l);var u=y(),d=_(),f=b(),p=w()})),E=T();const D=`${a}/`,O=new Set([`localhost`,`127.0.0.1`,`0.0.0.0`,`::1`,`[::1]`]);function k(e){return O.has(e.hostname)}const A=`x-vercel-protection-bypass`,j=`x-vercel-trusted-oidc-idp-token`;function M(e){return e.pathname.endsWith(`/ash/v1`)||e.pathname.includes(D)}async function N(e){let t=P(e),n=await I(t,e.resourceUrl);return n!==null&&F(t,n),t}function P(e){let t=new Headers(z(e.headers)),n=process.env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();return n&&M(e.resourceUrl)&&t.set(A,n),t}function F(e,t){e.has(`authorization`)||e.set(`authorization`,`Bearer ${t}`),e.set(j,t)}async function I(e,t){return L(t)?e.get(`x-vercel-oidc-token`)?.trim()||await R():null}function L(e){return!(!M(e)||k(e))}async function R(){let e=process.env.VERCEL_OIDC_TOKEN?.trim();try{let e=(await(0,E.getVercelOidcToken)()).trim();if(e.length>0)return e}catch{return e??null}return e??null}function z(e){if(e!==void 0)return e instanceof Headers?e:Array.isArray(e)?e.map(([e,t])=>[e,t]):e}function B(){return{streamIndex:0}}function V(e){let t=W(e.events),n=e.session.streamIndex+e.events.length;return t?.type===`session.waiting`?{continuationToken:e.continuationToken??e.session.continuationToken,sessionId:e.sessionId,streamIndex:n}:B()}function H(e){let t;for(let n of e)G(n)&&(t=n.data.message??void 0);return t}function U(e){let t=W(e);return t?.type===`session.waiting`?`waiting`:t?.type===`session.failed`?`failed`:`completed`}function W(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n!==void 0&&o(n))return n}}function G(e){return e.type===`message.completed`&&e.data.finishReason!==`tool-calls`}var K=class{continuationToken;sessionId;#e=!1;#t;constructor(e){this.continuationToken=e.continuationToken,this.sessionId=e.sessionId,this.#t=e.createStream}async result(){let e=[];for await(let t of this)e.push(t);return{events:e,message:H(e),sessionId:this.sessionId,status:U(e)}}[Symbol.asyncIterator](){if(this.#e)throw Error(`MessageResponse has already been consumed.`);return this.#e=!0,this.#t()}},q=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get state(){return this.#t}async sendMessage(e,t){return this.send({message:e},t)}async send(e,t){let n=this.#t,{continuationToken:r,sessionId:i}=await this.#n(e,n,t);return new K({continuationToken:r,createStream:()=>this.#r(i,r,n,t),sessionId:i})}openStream(e){let t=this.#t.sessionId;if(!t)throw Error(`Session has no session ID. Send a message first.`);return g({host:this.#e.host,maxReconnectAttempts:this.#e.maxReconnectAttempts,resolveHeaders:()=>this.#e.resolveHeaders(),sessionId:t,signal:e?.signal,startIndex:e?.startIndex??this.#t.streamIndex})}async#n(e,t,n){let a=t.sessionId?r(t.sessionId):i,o=f(this.#e.host,a),s=await this.#e.resolveHeaders(n?.headers);s.set(`content-type`,`application/json`);let c=J({input:e,session:t});if(c===null)throw Error(`Session.send requires a non-empty message, inputResponses, or both.`);let u=await fetch(o,{body:JSON.stringify(c),headers:s,method:`POST`,signal:n?.signal??null});if(!u.ok){let e=await u.text();throw new l(u.status,e)}let d=await u.json(),p=(typeof d.sessionId==`string`?d.sessionId:void 0)??u.headers.get(`x-ash-session-id`)?.trim()??t.sessionId;if(!p)throw Error(`Message route did not return a session id.`);return{continuationToken:typeof d.continuationToken==`string`?d.continuationToken:void 0,sessionId:p}}async*#r(e,t,n,r){let i=[];try{let t=n.sessionId===e?n.streamIndex:0,a=this.#e.maxReconnectAttempts;for(;;){let n=await this.#i(e,t,r?.signal),s=!1;try{for await(let e of d(n))if(i.push(e),t+=1,yield e,o(e)){s=!0;break}}catch(e){if(!u(e))throw e}if(s||a<=0)break;--a}}finally{this.#t=V({continuationToken:t,events:i,sessionId:e,session:n})}}async#i(e,t,n){let r=f(this.#e.host,c(e),t>0?{startIndex:String(t)}:void 0),i=await this.#e.resolveHeaders(),a=await fetch(r,{headers:i,signal:n??null});if(!a.ok){let e=await a.text();throw new l(a.status,e)}if(!a.body)throw new l(a.status,`Response body is null.`);return a.body}};function J(e){let t={};return e.input.message!==void 0&&(t.message=e.input.message),e.input.inputResponses!==void 0&&e.input.inputResponses.length>0&&(t.inputResponses=e.input.inputResponses),e.input.clientContext!==void 0&&(t.clientContext=e.input.clientContext),e.session.continuationToken!==void 0&&(t.continuationToken=e.session.continuationToken),Object.keys(t).length===0||e.session.continuationToken===void 0&&t.message===void 0||e.session.continuationToken!==void 0&&t.message===void 0&&t.inputResponses===void 0||`continuationToken`in t&&Object.keys(t).length===1?null:t}var Y=class{#e;#t;#n;#r;constructor(e){this.#n=e.host,this.#e=e.auth,this.#t=e.headers,this.#r=e.maxReconnectAttempts??3}async health(){let e=f(this.#n,s),t=await this.#i(),n=await fetch(e,{headers:t});if(!n.ok){let e=await n.text();throw new l(n.status,e)}return await n.json()}session(e){let t;return t=typeof e==`string`?{continuationToken:e,streamIndex:0}:e||B(),new q({host:this.#n,maxReconnectAttempts:this.#r,resolveHeaders:e=>this.#i(e)},t)}async#i(e){let t=new Headers,n=await Z(this.#t);for(let[e,r]of Object.entries(n))t.set(e,r);if(e)for(let[n,r]of Object.entries(e))t.set(n,r);let r=await this.#a();return r&&t.set(`authorization`,r),t}async#a(){let e=this.#e;if(e){if(`bearer`in e){let t=(await X(e.bearer)).trim();return t.length===0?void 0:`Bearer ${t}`}if(`basic`in e){let t=await X(e.basic.password);return`Basic ${Q(e.basic.username,t)}`}}}};async function X(e){return typeof e==`function`?e():e}async function Z(e){return e===void 0?{}:typeof e==`function`?await e():e}function Q(e,t){let n=new TextEncoder().encode(`${e}:${t}`),r=Array.from(n,e=>String.fromCodePoint(e)).join(``);return btoa(r)}export{T as a,g as c,N as i,l,A as n,w as o,j as r,v as s,Y as t};
@@ -0,0 +1 @@
1
+ import{s as e}from"./paths-CebY5GCi.js";import{t}from"./errors-HYWjHxV6.js";import{i as n}from"./package-HUaeub_D.js";import{getDevelopmentEnvironmentFilePaths as r,reloadDevelopmentEnvironmentFiles as i}from"../cli/dev/environment.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./host-zBy9FyyX.js";import{createRequire as d}from"node:module";import*as f from"node:path";import{dirname as p,isAbsolute as m,join as h,relative as g,resolve as _,sep as v}from"node:path";import{lstat as y,open as b,readFile as x,readdir as S,realpath as C,stat as w}from"node:fs/promises";import{existsSync as ee,stat as te,unwatchFile as T,watch as ne,watchFile as re}from"node:fs";import{parse as ie}from"#compiled/jsonc-parser/index.js";import{EventEmitter as ae}from"node:events";import{Readable as oe}from"node:stream";import{type as se}from"node:os";const E={FILE_TYPE:`files`,DIR_TYPE:`directories`,FILE_DIR_TYPE:`files_directories`,EVERYTHING_TYPE:`all`},D={root:`.`,fileFilter:e=>!0,directoryFilter:e=>!0,type:E.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(D);const O=`READDIRP_RECURSIVE_ERROR`,ce=new Set([`ENOENT`,`EPERM`,`EACCES`,`ELOOP`,O]),k=[E.DIR_TYPE,E.EVERYTHING_TYPE,E.FILE_DIR_TYPE,E.FILE_TYPE],le=new Set([E.DIR_TYPE,E.EVERYTHING_TYPE,E.FILE_DIR_TYPE]),ue=new Set([E.EVERYTHING_TYPE,E.FILE_DIR_TYPE,E.FILE_TYPE]),de=e=>ce.has(e.code),fe=process.platform===`win32`,pe=e=>!0,A=e=>{if(e===void 0)return pe;if(typeof e==`function`)return e;if(typeof e==`string`){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return pe};var me=class extends oe{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...D,...e},{root:n,type:r}=t;this._fileFilter=A(t.fileFilter),this._directoryFilter=A(t.directoryFilter);let i=t.lstat?y:w;fe?this._stat=e=>i(e,{bigint:!0}):this._stat=i,this._maxDepth=t.depth!=null&&Number.isSafeInteger(t.depth)?t.depth:D.depth,this._wantsDir=r?le.has(r):!1,this._wantsFile=r?ue.has(r):!1,this._wantsEverything=r===E.EVERYTHING_TYPE,this._root=_(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?`dirent`:`stats`,this._rdOptions={encoding:`utf8`,withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:r,depth:i}=t,a=n.splice(0,e).map(e=>this._formatEntry(e,r)),o=await Promise.all(a);for(let t of o){if(!t)continue;if(this.destroyed)return;let n=await this._getEntryType(t);n===`directory`&&this._directoryFilter(t)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(t.fullPath,i+1)),this._wantsDir&&(this.push(t),e--)):(n===`file`||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await S(e,this._rdOptions)}catch(e){this._onError(e)}return{files:n,depth:t,path:e}}async _formatEntry(e,t){let n,r=this._isDirent?e.name:e;try{let i=_(h(t,r));n={path:g(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(e){this._onError(e);return}return n}_onError(e){de(e)&&!this.destroyed?this.emit(`warn`,e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return``;let t=e[this._statsProp];if(t.isFile())return`file`;if(t.isDirectory())return`directory`;if(t&&t.isSymbolicLink()){let t=e.fullPath;try{let e=await C(t),n=await y(e);if(n.isFile())return`file`;if(n.isDirectory()){let n=e.length;if(t.startsWith(e)&&t.substr(n,1)===v){let n=Error(`Circular symlink detected: "${t}" points to "${e}"`);return n.code=O,this._onError(n)}return`directory`}}catch(e){return this._onError(e),``}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function he(e,t={}){let n=t.entryType||t.type;if(n===`both`&&(n=E.FILE_DIR_TYPE),n&&(t.type=n),!e)throw Error(`readdirp: root argument is required. Usage: readdirp(root, options)`);if(typeof e!=`string`)throw TypeError(`readdirp: root argument must be a string. Usage: readdirp(root, options)`);if(n&&!k.includes(n))throw Error(`readdirp: Invalid type passed. Use one of ${k.join(`, `)}`);return t.root=e,new me(t)}const j=()=>{},M=process.platform,N=M===`win32`,ge=M===`darwin`,_e=M===`linux`,ve=M===`freebsd`,ye=se()===`OS400`,P={ALL:`all`,READY:`ready`,ADD:`add`,CHANGE:`change`,ADD_DIR:`addDir`,UNLINK:`unlink`,UNLINK_DIR:`unlinkDir`,RAW:`raw`,ERROR:`error`},F=P,be={lstat:y,stat:w},I=`listeners`,L=`errHandlers`,R=`rawEmitters`,xe=[I,L,R],Se=new Set(`3dm.3ds.3g2.3gp.7z.a.aac.adp.afdesign.afphoto.afpub.ai.aif.aiff.alz.ape.apk.appimage.ar.arj.asf.au.avi.bak.baml.bh.bin.bk.bmp.btif.bz2.bzip2.cab.caf.cgm.class.cmx.cpio.cr2.cur.dat.dcm.deb.dex.djvu.dll.dmg.dng.doc.docm.docx.dot.dotm.dra.DS_Store.dsk.dts.dtshd.dvb.dwg.dxf.ecelp4800.ecelp7470.ecelp9600.egg.eol.eot.epub.exe.f4v.fbs.fh.fla.flac.flatpak.fli.flv.fpx.fst.fvt.g3.gh.gif.graffle.gz.gzip.h261.h263.h264.icns.ico.ief.img.ipa.iso.jar.jpeg.jpg.jpgv.jpm.jxr.key.ktx.lha.lib.lvp.lz.lzh.lzma.lzo.m3u.m4a.m4v.mar.mdi.mht.mid.midi.mj2.mka.mkv.mmr.mng.mobi.mov.movie.mp3.mp4.mp4a.mpeg.mpg.mpga.mxu.nef.npx.numbers.nupkg.o.odp.ods.odt.oga.ogg.ogv.otf.ott.pages.pbm.pcx.pdb.pdf.pea.pgm.pic.png.pnm.pot.potm.potx.ppa.ppam.ppm.pps.ppsm.ppsx.ppt.pptm.pptx.psd.pya.pyc.pyo.pyv.qt.rar.ras.raw.resources.rgb.rip.rlc.rmf.rmvb.rpm.rtf.rz.s3m.s7z.scpt.sgi.shar.snap.sil.sketch.slk.smv.snk.so.stl.suo.sub.swf.tar.tbz.tbz2.tga.tgz.thmx.tif.tiff.tlz.ttc.ttf.txz.udf.uvh.uvi.uvm.uvp.uvs.uvu.viv.vob.war.wav.wax.wbmp.wdp.weba.webm.webp.whl.wim.wm.wma.wmv.wmx.woff.woff2.wrm.wvx.xbm.xif.xla.xlam.xls.xlsb.xlsm.xlsx.xlt.xltm.xltx.xm.xmind.xpi.xpm.xwd.xz.z.zip.zipx`.split(`.`)),Ce=e=>Se.has(f.extname(e).slice(1).toLowerCase()),z=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},B=(e,t,n)=>{let r=e[t];r instanceof Set||(e[t]=r=new Set([r])),r.add(n)},we=e=>t=>{let n=e[t];n instanceof Set?n.clear():delete e[t]},V=(e,t,n)=>{let r=e[t];r instanceof Set?r.delete(n):r===n&&delete e[t]},H=e=>e instanceof Set?e.size===0:!e,U=new Map;function W(e,t,n,r,i){let a=(t,r)=>{n(e),i(t,r,{watchedPath:e}),r&&e!==r&&G(f.resolve(e,r),I,f.join(e,r))};try{return ne(e,{persistent:t.persistent},a)}catch(e){r(e);return}}const G=(e,t,n,r,i)=>{let a=U.get(e);a&&z(a[t],e=>{e(n,r,i)})},Te=(e,t,n,r)=>{let{listener:i,errHandler:a,rawEmitter:o}=r,s=U.get(t),c;if(!n.persistent)return c=W(e,n,i,a,o),c?c.close.bind(c):void 0;if(s)B(s,I,i),B(s,L,a),B(s,R,o);else{if(c=W(e,n,G.bind(null,t,I),a,G.bind(null,t,R)),!c)return;c.on(F.ERROR,async n=>{let r=G.bind(null,t,L);if(s&&(s.watcherUnusable=!0),N&&n.code===`EPERM`)try{await(await b(e,`r`)).close(),r(n)}catch{}else r(n)}),s={listeners:i,errHandlers:a,rawEmitters:o,watcher:c},U.set(t,s)}return()=>{V(s,I,i),V(s,L,a),V(s,R,o),H(s.listeners)&&(s.watcher.close(),U.delete(t),xe.forEach(we(s)),s.watcher=void 0,Object.freeze(s))}},K=new Map,Ee=(e,t,n,r)=>{let{listener:i,rawEmitter:a}=r,o=K.get(t),s=o&&o.options;return s&&(s.persistent<n.persistent||s.interval>n.interval)&&(T(t),o=void 0),o?(B(o,I,i),B(o,R,a)):(o={listeners:i,rawEmitters:a,options:n,watcher:re(t,n,(n,r)=>{z(o.rawEmitters,e=>{e(F.CHANGE,t,{curr:n,prev:r})});let i=n.mtimeMs;(n.size!==r.size||i>r.mtimeMs||i===0)&&z(o.listeners,t=>t(e,n))})},K.set(t,o)),()=>{V(o,I,i),V(o,R,a),H(o.listeners)&&(K.delete(t),T(t),o.options=o.watcher=void 0,Object.freeze(o))}};var De=class{fsw;_boundHandleError;constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let n=this.fsw.options,r=f.dirname(e),i=f.basename(e);this.fsw._getWatchedDir(r).add(i);let a=f.resolve(e),o={persistent:n.persistent};t||=j;let s;return n.usePolling?(o.interval=n.interval!==n.binaryInterval&&Ce(i)?n.binaryInterval:n.interval,s=Ee(e,a,o,{listener:t,rawEmitter:this.fsw._emitRaw})):s=Te(e,a,o,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),s}_handleFile(e,t,n){if(this.fsw.closed)return;let r=f.dirname(e),i=f.basename(e),a=this.fsw._getWatchedDir(r),o=t;if(a.has(i))return;let s=async(t,n)=>{if(this.fsw._throttle(`watch`,e,5)){if(!n||n.mtimeMs===0)try{let n=await w(e);if(this.fsw.closed)return;let r=n.atimeMs,i=n.mtimeMs;if((!r||r<=i||i!==o.mtimeMs)&&this.fsw._emit(F.CHANGE,e,n),(ge||_e||ve)&&o.ino!==n.ino){this.fsw._closeFile(t),o=n;let r=this._watchWithNodeFs(e,s);r&&this.fsw._addPathCloser(t,r)}else o=n}catch{this.fsw._remove(r,i)}else if(a.has(i)){let t=n.atimeMs,r=n.mtimeMs;(!t||t<=r||r!==o.mtimeMs)&&this.fsw._emit(F.CHANGE,e,n),o=n}}},c=this._watchWithNodeFs(e,s);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(F.ADD,e,0))return;this.fsw._emit(F.ADD,e,t)}return c}async _handleSymlink(e,t,n,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let t;try{t=await C(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==t&&(this.fsw._symlinkPaths.set(i,t),this.fsw._emit(F.CHANGE,n,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,t),this.fsw._emit(F.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,t,n,r,i,a,o){e=f.join(e,``);let s=r?`${e}:${r}`:e;if(o=this.fsw._throttle(`readdir`,s,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,u=this.fsw._readdirp(e,{fileFilter:e=>n.filterPath(e),directoryFilter:e=>n.filterDir(e)});if(u)return u.on(`data`,async o=>{if(this.fsw.closed){u=void 0;return}let s=o.path,d=f.join(e,s);if(l.add(s),!(o.stats.isSymbolicLink()&&await this._handleSymlink(o,e,d,s))){if(this.fsw.closed){u=void 0;return}(s===r||!r&&!c.has(s))&&(this.fsw._incrReadyCount(),d=f.join(i,f.relative(i,d)),this._addToNodeFs(d,t,n,a+1))}}).on(F.ERROR,this._boundHandleError),new Promise((t,s)=>{if(!u)return s();u.once(`end`,()=>{if(this.fsw.closed){u=void 0;return}let s=o?o.clear():!1;t(void 0),c.getChildren().filter(t=>t!==e&&!l.has(t)).forEach(t=>{this.fsw._remove(e,t)}),u=void 0,s&&this._handleRead(e,!1,n,r,i,a,o)})})}async _handleDir(e,t,n,r,i,a,o){let s=this.fsw._getWatchedDir(f.dirname(e)),c=s.has(f.basename(e));!(n&&this.fsw.options.ignoreInitial)&&!i&&!c&&this.fsw._emit(F.ADD_DIR,e,t),s.add(f.basename(e)),this.fsw._getWatchedDir(e);let l,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(e,n,a,i,e,r,void 0),this.fsw.closed))return;l=this._watchWithNodeFs(e,(t,n)=>{n&&n.mtimeMs===0||this._handleRead(t,!1,a,i,e,r,void 0)})}return l}async _addToNodeFs(e,t,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(e);n&&(o.filterPath=e=>n.filterPath(e),o.filterDir=e=>n.filterDir(e));try{let n=await be[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,n))return a(),!1;let s=this.fsw.options.followSymlinks,c;if(n.isDirectory()){let a=f.resolve(e),l=s?await C(e):e;if(this.fsw.closed||(c=await this._handleDir(o.watchPath,n,t,r,i,o,l),this.fsw.closed))return;a!==l&&l!==void 0&&this.fsw._symlinkPaths.set(a,l)}else if(n.isSymbolicLink()){let i=s?await C(e):e;if(this.fsw.closed)return;let a=f.dirname(o.watchPath);if(this.fsw._getWatchedDir(a).add(o.watchPath),this.fsw._emit(F.ADD,o.watchPath,n),c=await this._handleDir(a,n,t,r,e,o,i),this.fsw.closed)return;i!==void 0&&this.fsw._symlinkPaths.set(f.resolve(e),i)}else c=this._handleFile(o.watchPath,n,t);return a(),c&&this.fsw._addPathCloser(e,c),!1}catch(t){if(this.fsw._handleError(t))return a(),e}}};const Oe=/\\/g,q=/\/\//g,ke=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Ae=/^\.[/\\]/;function J(e){return Array.isArray(e)?e:[e]}const Y=e=>typeof e==`object`&&!!e&&!(e instanceof RegExp);function je(e){return typeof e==`function`?e:typeof e==`string`?t=>e===t:e instanceof RegExp?t=>e.test(t):typeof e==`object`&&e?t=>{if(e.path===t)return!0;if(e.recursive){let n=f.relative(e.path,t);return n?!n.startsWith(`..`)&&!f.isAbsolute(n):!1}return!1}:()=>!1}function Me(e){if(typeof e!=`string`)throw Error(`string expected`);e=f.normalize(e),e=e.replace(/\\/g,`/`);let t=!1;return e.startsWith(`//`)&&(t=!0),e=e.replace(q,`/`),t&&(e=`/`+e),e}function X(e,t,n){let r=Me(t);for(let t=0;t<e.length;t++){let i=e[t];if(i(r,n))return!0}return!1}function Ne(e,t){if(e==null)throw TypeError(`anymatch: specify first argument`);let n=J(e).map(e=>je(e));return t==null?(e,t)=>X(n,e,t):X(n,t)}const Z=e=>{let t=J(e).flat();if(!t.every(e=>typeof e==`string`))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(Pe)},Q=e=>{let t=e.replace(Oe,`/`),n=!1;return t.startsWith(`//`)&&(n=!0),t=t.replace(q,`/`),n&&(t=`/`+t),t},Pe=e=>Q(f.normalize(Q(e))),Fe=(e=``)=>t=>typeof t==`string`?Pe(f.isAbsolute(t)?t:f.join(e,t)):t,Ie=(e,t)=>f.isAbsolute(e)?e:f.join(t,e),Le=Object.freeze(new Set);var Re=class{path;_removeWatcher;items;constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==`.`&&e!==`..`&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let n=this.path;try{await S(n)}catch{this._removeWatcher&&this._removeWatcher(f.dirname(n),f.basename(n))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path=``,this._removeWatcher=j,this.items=Le,Object.freeze(this)}},ze=class{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(e,t,n){this.fsw=n;let r=e;this.path=e=e.replace(Ae,``),this.watchPath=r,this.fullWatchPath=f.resolve(r),this.dirParts=[],this.dirParts.forEach(e=>{e.length>1&&e.pop()}),this.followSymlinks=t,this.statMethod=t?`stat`:`lstat`}entryPath(e){return f.join(this.watchPath,f.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Be=class extends ae{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?J(e.ignored):J([]),awaitWriteFinish:t===!0?n:typeof t==`object`?{...n,...t}:!1};ye&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let e=i.toLowerCase();e===`false`||e===`0`?r.usePolling=!1:e===`true`||e===`1`?r.usePolling=!0:r.usePolling=!!e}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=j,this._readyEmitted=!0,process.nextTick(()=>this.emit(P.READY)))},this._emitRaw=(...e)=>this.emit(P.RAW,...e),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new De(this),Object.freeze(r)}_addIgnoredPath(e){if(Y(e)){for(let t of this._ignoredPaths)if(Y(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e==`string`)for(let t of this._ignoredPaths)Y(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=Z(e);return r&&(i=i.map(e=>Ie(e,r))),i.forEach(e=>{this._removeIgnoredPath(e)}),this._userIgnored=void 0,this._readyCount||=0,this._readyCount+=i.length,Promise.all(i.map(async e=>{let r=await this._nodeFsHandler._addToNodeFs(e,!n,void 0,0,t);return r&&this._emitReady(),r})).then(e=>{this.closed||e.forEach(e=>{e&&this.add(f.dirname(e),f.basename(t||e))})}),this}unwatch(e){if(this.closed)return this;let t=Z(e),{cwd:n}=this.options;return t.forEach(e=>{!f.isAbsolute(e)&&!this._closers.has(e)&&(n&&(e=f.join(n,e)),e=f.resolve(e)),this._closePath(e),this._addIgnoredPath(e),this._watched.has(e)&&this._addIgnoredPath({path:e,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(t=>{let n=t();n instanceof Promise&&e.push(n)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,n)=>{let r=(this.options.cwd?f.relative(this.options.cwd,n):n)||`.`;e[r]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==P.ERROR&&this.emit(P.ALL,e,...t)}async _emit(e,t,n){if(this.closed)return;let r=this.options;N&&(t=f.normalize(t)),r.cwd&&(t=f.relative(r.cwd,t));let i=[t];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(t)))return o.lastChange=new Date,this;if(r.atomic){if(e===P.UNLINK)return this._pendingUnlinks.set(t,[e,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((e,t)=>{this.emit(...e),this.emit(P.ALL,...e),this._pendingUnlinks.delete(t)})},typeof r.atomic==`number`?r.atomic:100),this;e===P.ADD&&this._pendingUnlinks.has(t)&&(e=P.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===P.ADD||e===P.CHANGE)&&this._readyEmitted)return this._awaitWriteFinish(t,a.stabilityThreshold,e,(t,n)=>{t?(e=P.ERROR,i[0]=t,this.emitWithAll(e,i)):n&&(i.length>1?i[1]=n:i.push(n),this.emitWithAll(e,i))}),this;if(e===P.CHANGE&&!this._throttle(P.CHANGE,t,50))return this;if(r.alwaysStat&&n===void 0&&(e===P.ADD||e===P.ADD_DIR||e===P.CHANGE)){let e=r.cwd?f.join(r.cwd,t):t,n;try{n=await w(e)}catch{}if(!n||this.closed)return;i.push(n)}return this.emitWithAll(e,i),this}_handleError(e){let t=e&&e.code;return e&&t!==`ENOENT`&&t!==`ENOTDIR`&&(!this.options.ignorePermissionErrors||t!==`EPERM`&&t!==`EACCES`)&&this.emit(P.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw Error(`invalid throttle`);let i=r.get(t);if(i)return i.count++,!1;let a,o=()=>{let e=r.get(t),n=e?e.count:0;return r.delete(t),clearTimeout(a),e&&clearTimeout(e.timeoutObject),n};a=setTimeout(o,n);let s={timeoutObject:a,clear:o,count:0};return r.set(t,s),s}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,n,r){let i=this.options.awaitWriteFinish;if(typeof i!=`object`)return;let a=i.pollInterval,o,s=e;this.options.cwd&&!f.isAbsolute(e)&&(s=f.join(this.options.cwd,e));let c=new Date,l=this._pendingWrites;function u(n){te(s,(i,s)=>{if(i||!l.has(e)){i&&i.code!==`ENOENT`&&r(i);return}let c=Number(new Date);n&&s.size!==n.size&&(l.get(e).lastChange=c),c-l.get(e).lastChange>=t?(l.delete(e),r(void 0,s)):o=setTimeout(u,a,s)})}l.has(e)||(l.set(e,{lastChange:c,cancelWait:()=>(l.delete(e),clearTimeout(o),n)}),o=setTimeout(u,a))}_isIgnored(e,t){if(this.options.atomic&&ke.test(e))return!0;if(!this._userIgnored){let{cwd:e}=this.options,t=(this.options.ignored||[]).map(Fe(e)),n=[...[...this._ignoredPaths].map(Fe(e)),...t];this._userIgnored=Ne(n,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new ze(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=f.resolve(e);return this._watched.has(t)||this._watched.set(t,new Re(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,n){let r=f.join(e,t),i=f.resolve(r);if(n??=this._watched.has(r)||this._watched.has(i),!this._throttle(`remove`,r,100))return;!n&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(e=>this._remove(r,e));let a=this._getWatchedDir(e),o=a.has(t);a.remove(t),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let s=r;if(this.options.cwd&&(s=f.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(s)&&this._pendingWrites.get(s).cancelWait()===P.ADD)return;this._watched.delete(r),this._watched.delete(i);let c=n?P.UNLINK_DIR:P.UNLINK;o&&!this._isIgnored(r)&&this._emit(c,r),this._closePath(r)}_closePath(e){this._closeFile(e);let t=f.dirname(e);this._getWatchedDir(t).remove(f.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(e=>e()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n=he(e,{type:P.ALL,alwaysStat:!0,lstat:!0,...t,depth:0});return this._streams.add(n),n.once(`close`,()=>{n=void 0}),n.once(`end`,()=>{n&&=(this._streams.delete(n),void 0)}),n}};function Ve(e,t={}){let n=new Be(t);return n.add(e),n}const He=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],Ue=[`.git`,`pnpm-workspace.yaml`],We=[`**/.ash/**`,`**/.git/**`,`**/.output/**`,`**/.turbo/**`,`**/.vercel/**`,`**/.workflow-data/**`,`**/node_modules/**`];async function Ge(r){let d=r.schedulesEnabled!==!1,f=r.preparedHost,p=!1,m=Promise.resolve(),h,g=new Set,_=new Set,v=await qe(f),y=Je(v),b=Ve(v,{awaitWriteFinish:{pollInterval:50,stabilityThreshold:160},followSymlinks:!1,ignoreInitial:!0,ignored:We}),x=Ke(b),S=()=>{p||(m=m.then(async()=>{if(p)return;let m=g.size,h=[..._];g.clear(),_.clear();let v=f,x=Xe(v.appRoot,h);console.log(`[ash:dev] change detected (${m} event${m===1?``:`s`}), rebuilding authored artifacts...`);try{x&&i(v.appRoot);let t=await s(v.appRoot);await l({appRoot:t.appRoot,log:e=>console.log(e)});let p=o({appRoot:t.appRoot,dev:r.nitro.options.dev===!0}),m=u(r.nitro,{artifactsConfig:p,next:c(t),previous:c(v)}),h=a(r.nitro,{artifactsConfig:p,dispatchModulePath:n(`src/internal/nitro/routes/schedule-task.ts`),next:d?t.scheduleRegistrations:[],previous:d?v.scheduleRegistrations:[]});e(),f=t,m||h||x?(console.log(`[ash:dev] structural change detected, reloading Nitro worker...`),await r.nitro.hooks.callHook(`rollup:reload`)):console.log(`[ash:dev] authored artifacts updated.`),y=Ye({nextWatchPaths:await qe(t),previousWatchPathsByKey:y,watcher:b})}catch(e){console.error(`[ash:dev] rebuild failed: ${t(e)}`)}}).catch(e=>{console.error(`[ash:dev] rebuild queue error: ${t(e)}`)}))};return b.on(`all`,(e,t)=>{p||(g.add(`${e}:${t}`),_.add(t),h!==void 0&&clearTimeout(h),h=setTimeout(()=>{h=void 0,S()},120))}),await x,{async close(){p=!0,h!==void 0&&(clearTimeout(h),h=void 0),await b.close(),await m}}}async function Ke(e){await new Promise((t,n)=>{e.on(`ready`,()=>{t()}),e.on(`error`,e=>{n(e)})})}async function qe(e){let t=new Set([e.compileResult.project.agentRoot,h(e.appRoot,`package.json`),h(e.appRoot,`jsconfig.json`),h(e.appRoot,`tsconfig.json`),h(e.appRoot,`tsconfig.*.json`)]),n=await $e(e.appRoot);for(let n of r(e.appRoot))t.add(n);for(let e of n)t.add(e);for(let n of Ze(e.appRoot))for(let e of He)t.add(h(n,e));return[...t].sort((e,t)=>e.localeCompare(t))}function Je(e){let t=new Map;for(let n of e)t.set($(n),n);return t}function Ye(e){let t=Je(e.nextWatchPaths),n=[],r=[];for(let[r,i]of t)e.previousWatchPathsByKey.has(r)||n.push(i);for(let[n,i]of e.previousWatchPathsByKey)t.has(n)||r.push(i);return n.length>0&&e.watcher.add(n),r.length>0&&e.watcher.unwatch(r),t}function $(e){return e.replaceAll(`\\`,`/`)}function Xe(e,t){let n=new Set(r(e).map(e=>$(_(e))));return t.some(e=>n.has($(_(e))))}function Ze(e){let t=[],n=_(e);for(;t.push(n),!Qe(n);){let e=p(n);if(e===n)break;n=e}return t}function Qe(e){return Ue.some(t=>ee(h(e,t)))}async function $e(e){let t=await et(e),n=new Set,r=new Set;for(let e of t)await tt({configPath:e,resolvedConfigPaths:n,visitingConfigPaths:r});return[...n].sort((e,t)=>e.localeCompare(t))}async function et(e){let t=new Set([h(e,`tsconfig.json`),h(e,`jsconfig.json`)]);try{let n=await S(e,{withFileTypes:!0});for(let r of n)r.isFile()&&/^tsconfig\..+\.json$/i.test(r.name)&&t.add(h(e,r.name))}catch{}return[...t]}async function tt(e){let t=_(e.configPath);if(e.resolvedConfigPaths.has(t)||e.visitingConfigPaths.has(t))return;let n=await nt(t);if(n!==void 0){e.resolvedConfigPaths.add(t),e.visitingConfigPaths.add(t);try{let r=rt(n);for(let n of r)for(let r of it({configPath:t,extendsSpecifier:n}))await tt({configPath:r,resolvedConfigPaths:e.resolvedConfigPaths,visitingConfigPaths:e.visitingConfigPaths})}finally{e.visitingConfigPaths.delete(t)}}}async function nt(e){try{return await x(e,`utf8`)}catch{return}}function rt(e){let t=[],n=ie(e,t,{allowTrailingComma:!0});if(t.length>0||typeof n!=`object`||!n||Array.isArray(n))return[];let r=n.extends;return typeof r==`string`?r.length>0?[r]:[]:Array.isArray(r)?r.filter(e=>typeof e==`string`&&e.length>0):[]}function it(e){let t=new Set;if(st(e.extendsSpecifier))for(let n of at({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);else for(let n of ot({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);return[...t]}function at(e){let t=_(p(e.configPath),e.extendsSpecifier),n=new Set;return n.add(t),t.endsWith(`.json`)||(n.add(`${t}.json`),n.add(h(t,`tsconfig.json`))),[...n]}function ot(e){let t=new Set([e.extendsSpecifier]);e.extendsSpecifier.endsWith(`.json`)||(t.add(`${e.extendsSpecifier}.json`),t.add(`${e.extendsSpecifier}/tsconfig.json`));let n=new Set,r=d(e.configPath);for(let e of t)try{n.add(r.resolve(e))}catch{}return[...n]}function st(e){return e.startsWith(`.`)||m(e)?!0:/^[A-Za-z]:[\\/]/.test(e)}export{Ge as startAuthoredSourceWatcher};
@@ -1 +1 @@
1
- import{n as e}from"./guards-CjJ3lmju.js";function t(t){return t instanceof Error?t.message:typeof t==`string`?t:t==null?String(t):e(t)?typeof t.message==`string`&&t.message.length>0?t.message:n(t):String(t)}function n(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}export{t};
1
+ import{n as e}from"./guards-26p6sOw3.js";function t(t){return t instanceof Error?t.message:typeof t==`string`?t:t==null?String(t):e(t)?typeof t.message==`string`&&t.message.length>0?t.message:n(t):String(t)}function n(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}export{t};