eve 0.67.0 → 0.67.1

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 (147) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/src/channel/schedule-auth.d.ts +0 -2
  3. package/dist/src/channel/schedule-auth.js +1 -1
  4. package/dist/src/chunks/{use-eve-agent-OCHP4s0z.js → use-eve-agent-D4HVZBjn.js} +1 -1
  5. package/dist/src/chunks/{use-eve-agent-DzdyI97Z.js → use-eve-agent-DXcE_8Ja.js} +1 -1
  6. package/dist/src/cli/application-root.d.ts +0 -2
  7. package/dist/src/cli/application-root.js +1 -1
  8. package/dist/src/cli/commands/agent-instructions.d.ts +0 -4
  9. package/dist/src/cli/commands/agent-instructions.js +3 -3
  10. package/dist/src/cli/commands/extension-init.js +1 -1
  11. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  12. package/dist/src/cli/commands/init-project.d.ts +0 -1
  13. package/dist/src/cli/commands/init-project.js +1 -1
  14. package/dist/src/cli/commands/init.js +1 -1
  15. package/dist/src/cli/dev/diagnostic-dump.js +1 -1
  16. package/dist/src/cli/dev/environment.js +1 -1
  17. package/dist/src/cli/dev/tui/runner.d.ts +0 -1
  18. package/dist/src/cli/dev/tui/runner.js +1 -1
  19. package/dist/src/cli/ui/output.d.ts +0 -15
  20. package/dist/src/cli/ui/output.js +2 -5
  21. package/dist/src/client/eve-agent-store.js +1 -1
  22. package/dist/src/compiled/.vendor-stamp.json +1 -1
  23. package/dist/src/compiler/artifacts.js +1 -1
  24. package/dist/src/compiler/compile-agent.js +1 -1
  25. package/dist/src/discover/diagnostics.d.ts +0 -4
  26. package/dist/src/discover/diagnostics.js +1 -1
  27. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  28. package/dist/src/execution/runtime-context.js +1 -1
  29. package/dist/src/execution/sandbox/bindings/docker-templates.js +1 -1
  30. package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
  31. package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +1 -1
  32. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  33. package/dist/src/execution/tools/ask-question-workflow.js +1 -1
  34. package/dist/src/execution/tools/sleep-workflow.js +1 -1
  35. package/dist/src/execution/tools/subagent/start.js +1 -1
  36. package/dist/src/harness/authorization.d.ts +0 -9
  37. package/dist/src/harness/authorization.js +1 -1
  38. package/dist/src/harness/provider-safety.d.ts +9 -0
  39. package/dist/src/harness/provider-safety.js +1 -1
  40. package/dist/src/harness/step-hooks.js +1 -1
  41. package/dist/src/harness/tool-loop.js +2 -2
  42. package/dist/src/harness/turn-cancellation.d.ts +2 -7
  43. package/dist/src/harness/turn-cancellation.js +1 -1
  44. package/dist/src/harness/workflow-stream-error.d.ts +0 -7
  45. package/dist/src/harness/workflow-stream-error.js +1 -1
  46. package/dist/src/instrumentation/runtime.js +1 -1
  47. package/dist/src/internal/application/cache-metadata.js +1 -1
  48. package/dist/src/internal/application/compiled-artifacts.js +1 -1
  49. package/dist/src/internal/application/optional-package-import.js +1 -1
  50. package/dist/src/internal/application/optional-package-install.js +1 -1
  51. package/dist/src/internal/application/output-publication-lock.js +1 -1
  52. package/dist/src/internal/application/package.js +1 -1
  53. package/dist/src/internal/application/paths.js +1 -1
  54. package/dist/src/internal/application/tsconfig-dependencies.js +1 -1
  55. package/dist/src/internal/authored-asset-import-plugin.js +1 -1
  56. package/dist/src/internal/authored-module-evaluation-error.js +1 -1
  57. package/dist/src/internal/authored-module-loader.js +1 -1
  58. package/dist/src/internal/authored-package-boundary.js +1 -1
  59. package/dist/src/internal/authored-relative-extension-resolver.js +1 -1
  60. package/dist/src/internal/bundler/extension-scope-plugin.js +1 -1
  61. package/dist/src/internal/bundler/nitro-rolldown.d.ts +3 -1
  62. package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
  63. package/dist/src/internal/bundler/vendored-dependency-log.d.ts +7 -0
  64. package/dist/src/internal/bundler/vendored-dependency-log.js +1 -0
  65. package/dist/src/internal/gateway.d.ts +2 -0
  66. package/dist/src/internal/gateway.js +1 -1
  67. package/dist/src/internal/instrumentation-layout.js +1 -1
  68. package/dist/src/internal/materialized-authored-modules.js +1 -1
  69. package/dist/src/internal/nitro/dev-runtime-artifacts-retention.js +1 -1
  70. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  71. package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
  72. package/dist/src/internal/nitro/dev-runtime-source-snapshot-local-roots.js +1 -1
  73. package/dist/src/internal/nitro/dev-runtime-source-snapshot.js +1 -1
  74. package/dist/src/internal/nitro/host/build-application.js +1 -1
  75. package/dist/src/internal/nitro/host/build-extension.js +1 -1
  76. package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
  77. package/dist/src/internal/nitro/host/configure-nitro-routes.js +1 -1
  78. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  79. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  80. package/dist/src/internal/nitro/host/extension-external-dependency-plugin.js +1 -1
  81. package/dist/src/internal/nitro/host/local-tracing-runtime-plugin.js +1 -1
  82. package/dist/src/internal/nitro/host/nitro-bundler-config.js +1 -1
  83. package/dist/src/internal/nitro/host/schedule-task-routes.d.ts +1 -25
  84. package/dist/src/internal/nitro/host/schedule-task-routes.js +2 -2
  85. package/dist/src/internal/nitro/host/start-production-server.js +1 -1
  86. package/dist/src/internal/nitro/host/workspace-extensions.js +1 -1
  87. package/dist/src/internal/process/pnpm.js +1 -1
  88. package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
  89. package/dist/src/internal/workflow/development-world-client.js +1 -1
  90. package/dist/src/internal/workflow/development-world-server.js +1 -1
  91. package/dist/src/internal/workflow-bundle/builder-support.js +1 -1
  92. package/dist/src/internal/workflow-bundle/builder.js +2 -2
  93. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  94. package/dist/src/public/channels/github/api.d.ts +0 -10
  95. package/dist/src/public/channels/github/api.js +1 -1
  96. package/dist/src/public/channels/slack/hitl.d.ts +0 -4
  97. package/dist/src/public/channels/slack/hitl.js +2 -2
  98. package/dist/src/public/channels/slack/mrkdwn.d.ts +0 -2
  99. package/dist/src/public/channels/slack/mrkdwn.js +1 -1
  100. package/dist/src/public/channels/upload-policy.d.ts +0 -11
  101. package/dist/src/public/channels/upload-policy.js +1 -1
  102. package/dist/src/public/next/server.js +1 -1
  103. package/dist/src/public/nuxt/dev-server.js +1 -1
  104. package/dist/src/public/sveltekit/dev-server.js +1 -1
  105. package/dist/src/self-modification/extension/subagents/agent/tools/search_traces.js +1 -1
  106. package/dist/src/services/dev-client/vercel-auth-error.d.ts +0 -8
  107. package/dist/src/services/dev-client/vercel-auth-error.js +2 -3
  108. package/dist/src/setup/boxes/select-model.d.ts +2 -36
  109. package/dist/src/setup/boxes/select-model.js +1 -1
  110. package/dist/src/setup/flows/model-source-change.js +1 -1
  111. package/dist/src/setup/flows/provider.d.ts +2 -45
  112. package/dist/src/setup/flows/provider.js +1 -4
  113. package/dist/src/setup/primitives/pm/pnpm.js +1 -1
  114. package/dist/src/setup/primitives/run-vercel.js +1 -1
  115. package/dist/src/setup/project-resolution.d.ts +0 -2
  116. package/dist/src/setup/project-resolution.js +1 -1
  117. package/dist/src/setup/provider-settings.js +1 -1
  118. package/dist/src/setup/scaffold/connections/catalog.d.ts +0 -13
  119. package/dist/src/setup/scaffold/connections/catalog.js +1 -1
  120. package/dist/src/setup/scaffold/create/project.js +1 -1
  121. package/dist/src/setup/scaffold/version-tokens.js +1 -1
  122. package/dist/src/setup/scaffold/workspace-root.js +1 -1
  123. package/dist/src/setup/vercel-api-failure.d.ts +0 -2
  124. package/dist/src/setup/vercel-api-failure.js +1 -1
  125. package/dist/src/setup/vercel-project.d.ts +2 -21
  126. package/dist/src/setup/vercel-project.js +0 -0
  127. package/dist/src/shared/conversation-identity.d.ts +2 -0
  128. package/dist/src/shared/conversation-identity.js +1 -0
  129. package/dist/src/shared/skill-paths.d.ts +0 -13
  130. package/dist/src/shared/skill-paths.js +2 -2
  131. package/dist/src/svelte/index.js +1 -1
  132. package/dist/src/svelte/use-eve-agent.js +1 -1
  133. package/dist/src/tracing/agent-invocation-coordinator.js +1 -1
  134. package/dist/src/tracing/agent-otel-attributes.js +1 -1
  135. package/dist/src/tracing/agent-trace-context-store.d.ts +0 -2
  136. package/dist/src/tracing/agent-trace-context-store.js +1 -1
  137. package/dist/src/tracing/conversation-context.d.ts +0 -2
  138. package/dist/src/tracing/conversation-context.js +1 -1
  139. package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
  140. package/dist/src/vue/index.js +1 -1
  141. package/dist/src/vue/use-eve-agent.js +1 -1
  142. package/docs/agent-config.md +7 -0
  143. package/package.json +1 -1
  144. package/dist/src/cli/commands/init-confirm.d.ts +0 -12
  145. package/dist/src/cli/commands/init-confirm.js +0 -1
  146. package/dist/src/setup/gateway-models.d.ts +0 -10
  147. package/dist/src/setup/gateway-models.js +0 -1
@@ -1 +1 @@
1
- import{readFile}from"node:fs/promises";import{dirname,join}from"node:path";import{existsSync}from"node:fs";import{pathToFileURL}from"node:url";async function importInstalledEnginePackage(e){return await import(await resolveInstalledEnginePackageEntrypointHref(e))}async function resolveInstalledEnginePackageEntrypointHref(e){let t=findInstalledPackageRoot(e),n=join(t,`package.json`),r=resolvePackageEntryPoint(JSON.parse(await readFile(n,`utf8`)));if(r.startsWith(`/`))throw Error(`Invalid absolute entrypoint for optional package "${e.packageName}".`);return pathToFileURL(join(t,r)).href}function findInstalledPackageRoot(e){let t=e.packageName.split(`/`),n=[],r=e.appRoot;for(;;){let i=join(r,`node_modules`,...t);if(n.push(i),existsSync(join(i,`package.json`)))return i;let a=dirname(r);if(a===r)throw Error(`Could not find installed optional dependency "${e.packageName}". Checked: ${n.join(`, `)}`);r=a}}function resolvePackageEntryPoint(e){let t=readDotExport(e.exports);return t===void 0?typeof e.module==`string`&&e.module.length>0?e.module:typeof e.main==`string`&&e.main.length>0?e.main:`index.js`:t}function readDotExport(e){if(typeof e==`string`&&e.length>0)return e;if(typeof e!=`object`||!e)return;let t=`.`in e?e[`.`]:e;if(typeof t==`string`&&t.length>0)return t;if(typeof t!=`object`||!t)return;let n=t;if(typeof n.import==`string`&&n.import.length>0)return n.import;if(typeof n.default==`string`&&n.default.length>0)return n.default}export{importInstalledEnginePackage,resolveInstalledEnginePackageEntrypointHref};
1
+ import{readFile}from"node:fs/promises";import{existsSync}from"node:fs";import{dirname,join}from"node:path";import{pathToFileURL}from"node:url";async function importInstalledEnginePackage(e){return await import(await resolveInstalledEnginePackageEntrypointHref(e))}async function resolveInstalledEnginePackageEntrypointHref(e){let t=findInstalledPackageRoot(e),n=join(t,`package.json`),r=resolvePackageEntryPoint(JSON.parse(await readFile(n,`utf8`)));if(r.startsWith(`/`))throw Error(`Invalid absolute entrypoint for optional package "${e.packageName}".`);return pathToFileURL(join(t,r)).href}function findInstalledPackageRoot(e){let t=e.packageName.split(`/`),n=[],r=e.appRoot;for(;;){let i=join(r,`node_modules`,...t);if(n.push(i),existsSync(join(i,`package.json`)))return i;let a=dirname(r);if(a===r)throw Error(`Could not find installed optional dependency "${e.packageName}". Checked: ${n.join(`, `)}`);r=a}}function resolvePackageEntryPoint(e){let t=readDotExport(e.exports);return t===void 0?typeof e.module==`string`&&e.module.length>0?e.module:typeof e.main==`string`&&e.main.length>0?e.main:`index.js`:t}function readDotExport(e){if(typeof e==`string`&&e.length>0)return e;if(typeof e!=`object`||!e)return;let t=`.`in e?e[`.`]:e;if(typeof t==`string`&&t.length>0)return t;if(typeof t!=`object`||!t)return;let n=t;if(typeof n.import==`string`&&n.import.length>0)return n.import;if(typeof n.default==`string`&&n.default.length>0)return n.default}export{importInstalledEnginePackage,resolveInstalledEnginePackageEntrypointHref};
@@ -1,4 +1,4 @@
1
- import{mkdir,rm,stat,writeFile}from"node:fs/promises";import{dirname,join,resolve}from"node:path";import{existsSync,realpathSync}from"node:fs";import{spawn}from"node:child_process";import{ensurePnpmOptionalDependencyDefaults}from"#setup/primitives/pm/pnpm-build-policy.js";import{EVE_DEV_ENV_FLAG,isEveDevEnvironment}from"#internal/application/dev-environment.js";import{importInstalledEnginePackage,importInstalledEnginePackage as importInstalledEnginePackage$1,resolveInstalledEnginePackageEntrypointHref}from"#internal/application/optional-package-import.js";import{Worker}from"node:worker_threads";function detectProjectPackageManager(e){return resolveProjectInstallation(e).packageManager}function resolveProjectInstallation(e){let t=resolve(e);try{t=realpathSync.native(t)}catch{}let n=t;for(;;){if(existsSync(join(t,`pnpm-lock.yaml`))||existsSync(join(t,`pnpm-workspace.yaml`)))return{root:t,packageManager:`pnpm`};if(existsSync(join(t,`yarn.lock`)))return{root:t,packageManager:`yarn`};if(existsSync(join(t,`bun.lock`))||existsSync(join(t,`bun.lockb`)))return{root:t,packageManager:`bun`};if(existsSync(join(t,`package-lock.json`)))return{root:t,packageManager:`npm`};let e=dirname(t);if(e===t)return{root:n,packageManager:`npm`};t=e}}const INSTALL_ARGUMENTS={bun:[`add`,`--dev`],npm:[`install`,`--save-dev`],pnpm:[`add`,`-D`],yarn:[`add`,`-D`]},OPTIONAL_PACKAGE_LOCK_TIMEOUT_MS=6e5,pendingOptionalPackageInstalls=new Map;async function installPackageIntoProject(e){let t=detectProjectPackageManager(e.appRoot);t===`pnpm`&&e.ignoredOptionalDependencies?.length&&await ensurePnpmOptionalDependencyDefaults(e.appRoot,e.ignoredOptionalDependencies);let n=[...INSTALL_ARGUMENTS[t],e.packageName];console.info(`[eve:dev] installing optional dependency "${e.packageName}" via \`${t} ${n.join(` `)}\`...`);let r=spawn(t,n,{cwd:e.appRoot,shell:shouldSpawnPackageManagerWithShell(),stdio:[`ignore`,`pipe`,`pipe`]}),i=[];r.stdout?.on(`data`,e=>i.push(e)),r.stderr?.on(`data`,e=>i.push(e));let a=await new Promise((e,t)=>{r.on(`error`,t),r.on(`close`,t=>e(t??1))});if(a!==0){let n=Buffer.concat(i).toString(`utf8`).trim();throw Error(`Failed to install "${e.packageName}" with ${t} (exit ${a}).`+(n.length>0?`\n${n.slice(-2e3)}`:``))}console.info(`[eve:dev] installed "${e.packageName}".`)}async function loadOptionalEnginePackage(e){try{return await e.importModule()}catch(t){if(!e.autoInstall||!isEveDevEnvironment())throw Error(e.missingMessage,{cause:t});let n=e.importInstalledModule??(async()=>await importInstalledEnginePackage$1({appRoot:e.appRoot,packageName:e.packageName})),r=e.importInstalledModule===void 0?async()=>await isInstalledEnginePackageLoadable(e):async()=>{try{return await n(),!0}catch{return!1}};try{await withOptionalPackageInstallLock(e,async()=>{await r()||await installPackageIntoProject({appRoot:e.appRoot,packageName:e.installPackageName??e.packageName,ignoredOptionalDependencies:e.ignoredOptionalDependencies})})}catch(t){throw Error(`${e.missingMessage} Automatic installation failed: ${toMessage(t)}`,{cause:t})}try{return await n()}catch(t){throw Error(`${e.missingMessage} Automatic installation completed, but "${e.packageName}" still could not be loaded from "${e.appRoot}". This usually means the package manager installed into a different workspace, node_modules is unavailable, or the Node/package-manager environment changed while eve dev was running. Last load error: ${toMessage(t)}`,{cause:t})}}}async function isInstalledEnginePackageLoadable(e){try{return await importEntrypointInWorker(await resolveInstalledEnginePackageEntrypointHref(e)),!0}catch{return!1}}async function importEntrypointInWorker(e){let t=new Worker(`
1
+ import{mkdir,rm,stat,writeFile}from"node:fs/promises";import{existsSync,realpathSync}from"node:fs";import{dirname,join,resolve}from"node:path";import{spawn}from"node:child_process";import{ensurePnpmOptionalDependencyDefaults}from"#setup/primitives/pm/pnpm-build-policy.js";import{EVE_DEV_ENV_FLAG,isEveDevEnvironment}from"#internal/application/dev-environment.js";import{importInstalledEnginePackage,importInstalledEnginePackage as importInstalledEnginePackage$1,resolveInstalledEnginePackageEntrypointHref}from"#internal/application/optional-package-import.js";import{Worker}from"node:worker_threads";function detectProjectPackageManager(e){return resolveProjectInstallation(e).packageManager}function resolveProjectInstallation(e){let t=resolve(e);try{t=realpathSync.native(t)}catch{}let n=t;for(;;){if(existsSync(join(t,`pnpm-lock.yaml`))||existsSync(join(t,`pnpm-workspace.yaml`)))return{root:t,packageManager:`pnpm`};if(existsSync(join(t,`yarn.lock`)))return{root:t,packageManager:`yarn`};if(existsSync(join(t,`bun.lock`))||existsSync(join(t,`bun.lockb`)))return{root:t,packageManager:`bun`};if(existsSync(join(t,`package-lock.json`)))return{root:t,packageManager:`npm`};let e=dirname(t);if(e===t)return{root:n,packageManager:`npm`};t=e}}const INSTALL_ARGUMENTS={bun:[`add`,`--dev`],npm:[`install`,`--save-dev`],pnpm:[`add`,`-D`],yarn:[`add`,`-D`]},OPTIONAL_PACKAGE_LOCK_TIMEOUT_MS=6e5,pendingOptionalPackageInstalls=new Map;async function installPackageIntoProject(e){let t=detectProjectPackageManager(e.appRoot);t===`pnpm`&&e.ignoredOptionalDependencies?.length&&await ensurePnpmOptionalDependencyDefaults(e.appRoot,e.ignoredOptionalDependencies);let n=[...INSTALL_ARGUMENTS[t],e.packageName];console.info(`[eve:dev] installing optional dependency "${e.packageName}" via \`${t} ${n.join(` `)}\`...`);let r=spawn(t,n,{cwd:e.appRoot,shell:shouldSpawnPackageManagerWithShell(),stdio:[`ignore`,`pipe`,`pipe`]}),i=[];r.stdout?.on(`data`,e=>i.push(e)),r.stderr?.on(`data`,e=>i.push(e));let a=await new Promise((e,t)=>{r.on(`error`,t),r.on(`close`,t=>e(t??1))});if(a!==0){let n=Buffer.concat(i).toString(`utf8`).trim();throw Error(`Failed to install "${e.packageName}" with ${t} (exit ${a}).`+(n.length>0?`\n${n.slice(-2e3)}`:``))}console.info(`[eve:dev] installed "${e.packageName}".`)}async function loadOptionalEnginePackage(e){try{return await e.importModule()}catch(t){if(!e.autoInstall||!isEveDevEnvironment())throw Error(e.missingMessage,{cause:t});let n=e.importInstalledModule??(async()=>await importInstalledEnginePackage$1({appRoot:e.appRoot,packageName:e.packageName})),r=e.importInstalledModule===void 0?async()=>await isInstalledEnginePackageLoadable(e):async()=>{try{return await n(),!0}catch{return!1}};try{await withOptionalPackageInstallLock(e,async()=>{await r()||await installPackageIntoProject({appRoot:e.appRoot,packageName:e.installPackageName??e.packageName,ignoredOptionalDependencies:e.ignoredOptionalDependencies})})}catch(t){throw Error(`${e.missingMessage} Automatic installation failed: ${toMessage(t)}`,{cause:t})}try{return await n()}catch(t){throw Error(`${e.missingMessage} Automatic installation completed, but "${e.packageName}" still could not be loaded from "${e.appRoot}". This usually means the package manager installed into a different workspace, node_modules is unavailable, or the Node/package-manager environment changed while eve dev was running. Last load error: ${toMessage(t)}`,{cause:t})}}}async function isInstalledEnginePackageLoadable(e){try{return await importEntrypointInWorker(await resolveInstalledEnginePackageEntrypointHref(e)),!0}catch{return!1}}async function importEntrypointInWorker(e){let t=new Worker(`
2
2
  const { parentPort, workerData } = require("node:worker_threads");
3
3
 
4
4
  (async () => {
@@ -1 +1 @@
1
- import{mkdir,readdir,realpath,rm,stat,utimes}from"node:fs/promises";import{isErrnoCode}from"#shared/guards.js";import{basename,dirname,isAbsolute,join,relative,resolve}from"node:path";import{watch}from"node:fs";import{pathExists}from"#shared/path-exists.js";import{removeOutputPublicationBackups,rollbackOutputPublication}from"#internal/application/output-publication-artifacts.js";import{readOutputPublicationJournal,readRecoveryLeaseJournal,resolveJournalFilePath,writeOutputPublicationJournal,writeRecoveryLeaseJournal}from"#internal/application/output-publication-journal.js";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";const PUBLICATION_LOCK_TIMEOUT_MS=6e4,INCOMPLETE_LOCK_STALE_MS=5e3;function resolveOutputPublicationLockPath(e){return join(resolve(e),`.eve`,`locks`,`output-publication.lock`)}function startPublicationJournalHeartbeat(e){let t=resolveJournalFilePath(e),n=setInterval(()=>{let e=new Date;utimes(t,e,e).catch(()=>void 0)},1e3);return n.unref(),()=>{clearInterval(n)}}async function acquireOutputPublicationLock(e,t,n){let r=Date.now()+PUBLICATION_LOCK_TIMEOUT_MS,i=`${e}.recovery`;for(await mkdir(dirname(e),{recursive:!0});;){if(await pathExists(i)){if(await n(),await recoverStalePublication(e,i,t))continue;await waitForPublicationLockChange(e,r);continue}try{if(await mkdir(e),await pathExists(i)){await rm(e,{force:!0,recursive:!0}),await waitForPublicationLockChange(e,r);continue}try{await writeOutputPublicationJournal(e,t)}catch(t){throw await rm(e,{force:!0,recursive:!0}),t}return async()=>{if((await readOutputPublicationJournal(e))?.token!==t.token)return;let n=`${e}.released-${t.token}`;try{await renameWithTransientBusyRetry(e,n)}catch(e){if(isErrnoCode(e,`ENOENT`))return;throw e}await rm(n,{force:!0,recursive:!0})}}catch(e){if(!isErrnoCode(e,`EEXIST`))throw e}await n(),!await recoverStalePublication(e,i,t)&&await waitForPublicationLockChange(e,r)}}async function recoverStalePublication(e,t,n){let r=await acquireRecoveryLease(t,n.token);if(r===void 0)return!1;let i=startPublicationJournalHeartbeat(join(t,`lease`)),a=!1;try{let r=await readOutputPublicationJournal(e);if(r!==void 0&&r.liveness===`active`&&isProcessAlive(r.pid)&&!await isJournalStale(e)||r===void 0&&!await isPathStale(e))return!1;if(await pathExists(e)){let r=join(t,`owner-${n.token}`);try{await renameWithTransientBusyRetry(e,r),a=!0}catch(e){if(!isErrnoCode(e,`ENOENT`))throw e}}let i=await readdir(t,{withFileTypes:!0});a=i.some(e=>e.isDirectory()&&e.name.startsWith(`owner-`));for(let e of i)e.isDirectory()&&e.name.startsWith(`owner-`)&&await finishInterruptedPublication(join(t,e.name));return a=!1,!0}finally{i(),a?await r.release():await r.complete()}}async function acquireRecoveryLease(e,t){let n=join(e,`lease`),r={pid:process.pid,token:t};for(await mkdir(e,{recursive:!0});;){try{await mkdir(n);try{await writeRecoveryLeaseJournal(n,r)}catch(e){throw await rm(n,{force:!0,recursive:!0}),e}return{async complete(){if((await readRecoveryLeaseJournal(n))?.token!==t)return;let r=`${e}.released-${t}`;try{await renameWithTransientBusyRetry(e,r)}catch(e){if(isErrnoCode(e,`ENOENT`))return;throw e}await rm(r,{force:!0,recursive:!0})},async release(){if((await readRecoveryLeaseJournal(n))?.token!==t)return;let e=`${n}.released-${t}`;try{await renameWithTransientBusyRetry(n,e)}catch(e){if(isErrnoCode(e,`ENOENT`))return;throw e}await rm(e,{force:!0,recursive:!0})}}}catch(e){if(isErrnoCode(e,`ENOENT`))return;if(!isErrnoCode(e,`EEXIST`))throw e}let i=await readRecoveryLeaseJournal(n);if(i!==void 0&&isProcessAlive(i.pid)&&!await isJournalStale(n)||i===void 0&&!await isPathStale(n))return;let a=`${n}.stale-${t}`;try{await renameWithTransientBusyRetry(n,a)}catch(e){if(isErrnoCode(e,`ENOENT`))continue;throw e}await rm(a,{force:!0,recursive:!0})}}async function finishInterruptedPublication(e){let t=await readOutputPublicationJournal(e);if(t===void 0||!hasTokenDerivedBackupPaths(t)){await rm(e,{force:!0,recursive:!0});return}t.phase===`committed`?await removeOutputPublicationBackups(t):await rollbackOutputPublication(t),await removePublicationScratchDirectory(t),await rm(e,{force:!0,recursive:!0})}function hasTokenDerivedBackupPaths(e){return e.outputBackupPath===`${e.finalOutputDir}.eve-backup-${e.token}`&&e.summaryBackupPath===`${e.finalSummaryPath}.eve-backup-${e.token}`}async function removePublicationScratchDirectory(e){let t=relative(e.scratchDir,e.stagedOutputDir);t===``||t.startsWith(`..`)||isAbsolute(t)||await rm(e.scratchDir,{force:!0,recursive:!0})}async function waitForPublicationLockChange(e,t){let n=t-Date.now();if(n<=0)throw Error(`Timed out waiting ${PUBLICATION_LOCK_TIMEOUT_MS}ms to publish completed build output.`);let r=await realpath(dirname(e)),i=basename(e),a=await readPublicationLockState(e);await new Promise((t,o)=>{let s=!1,c=setTimeout(settleResolve,Math.min(n,INCOMPLETE_LOCK_STALE_MS)),l=watch(r,(e,t)=>{e===`rename`&&(t===null||t.toString().startsWith(i))&&settleResolve()});function cleanup(){clearTimeout(c),l.close()}function settleResolve(){s||(s=!0,cleanup(),t())}function settleReject(e){s||(s=!0,cleanup(),o(e))}l.once(`error`,settleReject),Promise.all([readPublicationLockState(e),pathExists(e),pathExists(`${e}.recovery`)]).then(([e,t,n])=>{(!t&&!n||e!==a)&&settleResolve()},settleReject)})}async function readPublicationLockState(e){let t=`${e}.recovery`,[n,r,i,a]=await Promise.all([readOutputPublicationJournal(e),readRecoveryLeaseJournal(join(t,`lease`)),pathExists(e),pathExists(t)]);return JSON.stringify({lockExists:i,lockToken:n?.token,recoveryExists:a,recoveryToken:r?.token})}async function isPathStale(e){try{return Date.now()-(await stat(e)).mtimeMs>=INCOMPLETE_LOCK_STALE_MS}catch(e){if(isErrnoCode(e,`ENOENT`))return!0;throw e}}async function isJournalStale(e){try{let t=await stat(resolveJournalFilePath(e));return Date.now()-t.mtimeMs>=15e3}catch(e){if(isErrnoCode(e,`ENOENT`))return!0;throw e}}function isProcessAlive(e){try{return process.kill(e,0),!0}catch(e){return!isErrnoCode(e,`ESRCH`)}}export{acquireOutputPublicationLock,acquireRecoveryLease,resolveOutputPublicationLockPath,startPublicationJournalHeartbeat};
1
+ import{mkdir,readdir,realpath,rm,stat,utimes}from"node:fs/promises";import{isErrnoCode}from"#shared/guards.js";import{watch}from"node:fs";import{basename,dirname,isAbsolute,join,relative,resolve}from"node:path";import{pathExists}from"#shared/path-exists.js";import{removeOutputPublicationBackups,rollbackOutputPublication}from"#internal/application/output-publication-artifacts.js";import{readOutputPublicationJournal,readRecoveryLeaseJournal,resolveJournalFilePath,writeOutputPublicationJournal,writeRecoveryLeaseJournal}from"#internal/application/output-publication-journal.js";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";const PUBLICATION_LOCK_TIMEOUT_MS=6e4,INCOMPLETE_LOCK_STALE_MS=5e3;function resolveOutputPublicationLockPath(e){return join(resolve(e),`.eve`,`locks`,`output-publication.lock`)}function startPublicationJournalHeartbeat(e){let t=resolveJournalFilePath(e),n=setInterval(()=>{let e=new Date;utimes(t,e,e).catch(()=>void 0)},1e3);return n.unref(),()=>{clearInterval(n)}}async function acquireOutputPublicationLock(e,t,n){let r=Date.now()+PUBLICATION_LOCK_TIMEOUT_MS,i=`${e}.recovery`;for(await mkdir(dirname(e),{recursive:!0});;){if(await pathExists(i)){if(await n(),await recoverStalePublication(e,i,t))continue;await waitForPublicationLockChange(e,r);continue}try{if(await mkdir(e),await pathExists(i)){await rm(e,{force:!0,recursive:!0}),await waitForPublicationLockChange(e,r);continue}try{await writeOutputPublicationJournal(e,t)}catch(t){throw await rm(e,{force:!0,recursive:!0}),t}return async()=>{if((await readOutputPublicationJournal(e))?.token!==t.token)return;let n=`${e}.released-${t.token}`;try{await renameWithTransientBusyRetry(e,n)}catch(e){if(isErrnoCode(e,`ENOENT`))return;throw e}await rm(n,{force:!0,recursive:!0})}}catch(e){if(!isErrnoCode(e,`EEXIST`))throw e}await n(),!await recoverStalePublication(e,i,t)&&await waitForPublicationLockChange(e,r)}}async function recoverStalePublication(e,t,n){let r=await acquireRecoveryLease(t,n.token);if(r===void 0)return!1;let i=startPublicationJournalHeartbeat(join(t,`lease`)),a=!1;try{let r=await readOutputPublicationJournal(e);if(r!==void 0&&r.liveness===`active`&&isProcessAlive(r.pid)&&!await isJournalStale(e)||r===void 0&&!await isPathStale(e))return!1;if(await pathExists(e)){let r=join(t,`owner-${n.token}`);try{await renameWithTransientBusyRetry(e,r),a=!0}catch(e){if(!isErrnoCode(e,`ENOENT`))throw e}}let i=await readdir(t,{withFileTypes:!0});a=i.some(e=>e.isDirectory()&&e.name.startsWith(`owner-`));for(let e of i)e.isDirectory()&&e.name.startsWith(`owner-`)&&await finishInterruptedPublication(join(t,e.name));return a=!1,!0}finally{i(),a?await r.release():await r.complete()}}async function acquireRecoveryLease(e,t){let n=join(e,`lease`),r={pid:process.pid,token:t};for(await mkdir(e,{recursive:!0});;){try{await mkdir(n);try{await writeRecoveryLeaseJournal(n,r)}catch(e){throw await rm(n,{force:!0,recursive:!0}),e}return{async complete(){if((await readRecoveryLeaseJournal(n))?.token!==t)return;let r=`${e}.released-${t}`;try{await renameWithTransientBusyRetry(e,r)}catch(e){if(isErrnoCode(e,`ENOENT`))return;throw e}await rm(r,{force:!0,recursive:!0})},async release(){if((await readRecoveryLeaseJournal(n))?.token!==t)return;let e=`${n}.released-${t}`;try{await renameWithTransientBusyRetry(n,e)}catch(e){if(isErrnoCode(e,`ENOENT`))return;throw e}await rm(e,{force:!0,recursive:!0})}}}catch(e){if(isErrnoCode(e,`ENOENT`))return;if(!isErrnoCode(e,`EEXIST`))throw e}let i=await readRecoveryLeaseJournal(n);if(i!==void 0&&isProcessAlive(i.pid)&&!await isJournalStale(n)||i===void 0&&!await isPathStale(n))return;let a=`${n}.stale-${t}`;try{await renameWithTransientBusyRetry(n,a)}catch(e){if(isErrnoCode(e,`ENOENT`))continue;throw e}await rm(a,{force:!0,recursive:!0})}}async function finishInterruptedPublication(e){let t=await readOutputPublicationJournal(e);if(t===void 0||!hasTokenDerivedBackupPaths(t)){await rm(e,{force:!0,recursive:!0});return}t.phase===`committed`?await removeOutputPublicationBackups(t):await rollbackOutputPublication(t),await removePublicationScratchDirectory(t),await rm(e,{force:!0,recursive:!0})}function hasTokenDerivedBackupPaths(e){return e.outputBackupPath===`${e.finalOutputDir}.eve-backup-${e.token}`&&e.summaryBackupPath===`${e.finalSummaryPath}.eve-backup-${e.token}`}async function removePublicationScratchDirectory(e){let t=relative(e.scratchDir,e.stagedOutputDir);t===``||t.startsWith(`..`)||isAbsolute(t)||await rm(e.scratchDir,{force:!0,recursive:!0})}async function waitForPublicationLockChange(e,t){let n=t-Date.now();if(n<=0)throw Error(`Timed out waiting ${PUBLICATION_LOCK_TIMEOUT_MS}ms to publish completed build output.`);let r=await realpath(dirname(e)),i=basename(e),a=await readPublicationLockState(e);await new Promise((t,o)=>{let s=!1,c=setTimeout(settleResolve,Math.min(n,INCOMPLETE_LOCK_STALE_MS)),l=watch(r,(e,t)=>{e===`rename`&&(t===null||t.toString().startsWith(i))&&settleResolve()});function cleanup(){clearTimeout(c),l.close()}function settleResolve(){s||(s=!0,cleanup(),t())}function settleReject(e){s||(s=!0,cleanup(),o(e))}l.once(`error`,settleReject),Promise.all([readPublicationLockState(e),pathExists(e),pathExists(`${e}.recovery`)]).then(([e,t,n])=>{(!t&&!n||e!==a)&&settleResolve()},settleReject)})}async function readPublicationLockState(e){let t=`${e}.recovery`,[n,r,i,a]=await Promise.all([readOutputPublicationJournal(e),readRecoveryLeaseJournal(join(t,`lease`)),pathExists(e),pathExists(t)]);return JSON.stringify({lockExists:i,lockToken:n?.token,recoveryExists:a,recoveryToken:r?.token})}async function isPathStale(e){try{return Date.now()-(await stat(e)).mtimeMs>=INCOMPLETE_LOCK_STALE_MS}catch(e){if(isErrnoCode(e,`ENOENT`))return!0;throw e}}async function isJournalStale(e){try{let t=await stat(resolveJournalFilePath(e));return Date.now()-t.mtimeMs>=15e3}catch(e){if(isErrnoCode(e,`ENOENT`))return!0;throw e}}function isProcessAlive(e){try{return process.kill(e,0),!0}catch(e){return!isErrnoCode(e,`ESRCH`)}}export{acquireOutputPublicationLock,acquireRecoveryLease,resolveOutputPublicationLockPath,startPublicationJournalHeartbeat};
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.67.0`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){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:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function tryResolveVerifiedPackageRoot(e){try{let t=realpathSync.native(e);return tryReadInstalledPackageInfo(t,EVE_PACKAGE_NAME)===void 0?void 0:dirname(t)}catch{return}}function findNearestVerifiedPackageRoot(e){let t=e;for(;;){let e=tryResolveVerifiedPackageRoot(join(t,`package.json`));if(e!==void 0)return e;let n=dirname(t);if(n===t)return;t=n}}function tryResolveDirectBuildLocation(e){let t=dirname(e);for(;;){if(basename(t)===`dist`){let e=tryResolveVerifiedPackageRoot(join(dirname(t),`package.json`));if(e!==void 0)return{packageBuildRoot:t,packageRoot:e}}let e=dirname(t);if(e===t)return;t=e}}function isSourceCheckout(e){return existsSync(join(e,`src`,`internal`,`application`,`package.ts`))}function tryCreatePackageLocation(e){if(isSourceCheckout(e))return{packageBuildRoot:null,packageRoot:e};let t=join(e,`dist`);if(existsSync(t))return{packageBuildRoot:t,packageRoot:e}}function resolveSelfPackageJsonPath(e){return createRequire(e).resolve(`${EVE_PACKAGE_NAME}/package.json`)}function resolvePackageLocationFromModulePath(e,t=resolveSelfPackageJsonPath){let n=realpathSync.native(e),r=tryResolveDirectBuildLocation(n);if(r!==void 0)return r;let i=findNearestVerifiedPackageRoot(dirname(n));if(i!==void 0&&isSourceCheckout(i))return{packageBuildRoot:null,packageRoot:i};try{let e=tryResolveVerifiedPackageRoot(t(n)),r=e===void 0?void 0:tryCreatePackageLocation(e);if(r!==void 0)return r}catch{}let a=i===void 0?void 0:tryCreatePackageLocation(i);if(a!==void 0)return a;throw Error(`Failed to resolve the eve package root from "${e}".`)}function resolvePackageLocation(){return cachedPackageLocation??=resolvePackageLocationFromModulePath(resolveCurrentModulePath()),cachedPackageLocation}function resolvePackageBuildRoot(){return resolvePackageLocation().packageBuildRoot}function resolvePackageRoot(){return resolvePackageLocation().packageRoot}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){try{return require.resolve(e)}catch(t){let n=tryResolvePackageRoot(),r=n===void 0||!isSourceCheckout(n)?void 0:resolveSourceCheckoutExport(n,e);if(r!==void 0)return r;throw t}}function resolveSourceCheckoutExport(e,t){if(t!==EVE_PACKAGE_NAME&&!t.startsWith(`${EVE_PACKAGE_NAME}/`))return;let n=t===EVE_PACKAGE_NAME?`.`:`.${t.slice(EVE_PACKAGE_NAME.length)}`;try{let t=JSON.parse(readFileSync(join(e,`package.json`),`utf8`)).exports?.[n],r=typeof t==`string`?t:t?.[`eve-source`]??t?.import??t?.default;if(r===void 0)return;let i=r.replace(/^\.\/dist\/src\//,`src/`).replace(/\.[cm]?js$/u,`.ts`),a=join(e,i);return existsSync(a)?a:void 0}catch{return}}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(typeof t.name==`string`&&typeof t.version==`string`)return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageLocationFromModulePath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
1
+ import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.67.1`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){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:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function tryResolveVerifiedPackageRoot(e){try{let t=realpathSync.native(e);return tryReadInstalledPackageInfo(t,EVE_PACKAGE_NAME)===void 0?void 0:dirname(t)}catch{return}}function findNearestVerifiedPackageRoot(e){let t=e;for(;;){let e=tryResolveVerifiedPackageRoot(join(t,`package.json`));if(e!==void 0)return e;let n=dirname(t);if(n===t)return;t=n}}function tryResolveDirectBuildLocation(e){let t=dirname(e);for(;;){if(basename(t)===`dist`){let e=tryResolveVerifiedPackageRoot(join(dirname(t),`package.json`));if(e!==void 0)return{packageBuildRoot:t,packageRoot:e}}let e=dirname(t);if(e===t)return;t=e}}function isSourceCheckout(e){return existsSync(join(e,`src`,`internal`,`application`,`package.ts`))}function tryCreatePackageLocation(e){if(isSourceCheckout(e))return{packageBuildRoot:null,packageRoot:e};let t=join(e,`dist`);if(existsSync(t))return{packageBuildRoot:t,packageRoot:e}}function resolveSelfPackageJsonPath(e){return createRequire(e).resolve(`${EVE_PACKAGE_NAME}/package.json`)}function resolvePackageLocationFromModulePath(e,t=resolveSelfPackageJsonPath){let n=realpathSync.native(e),r=tryResolveDirectBuildLocation(n);if(r!==void 0)return r;let i=findNearestVerifiedPackageRoot(dirname(n));if(i!==void 0&&isSourceCheckout(i))return{packageBuildRoot:null,packageRoot:i};try{let e=tryResolveVerifiedPackageRoot(t(n)),r=e===void 0?void 0:tryCreatePackageLocation(e);if(r!==void 0)return r}catch{}let a=i===void 0?void 0:tryCreatePackageLocation(i);if(a!==void 0)return a;throw Error(`Failed to resolve the eve package root from "${e}".`)}function resolvePackageLocation(){return cachedPackageLocation??=resolvePackageLocationFromModulePath(resolveCurrentModulePath()),cachedPackageLocation}function resolvePackageBuildRoot(){return resolvePackageLocation().packageBuildRoot}function resolvePackageRoot(){return resolvePackageLocation().packageRoot}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){try{return require.resolve(e)}catch(t){let n=tryResolvePackageRoot(),r=n===void 0||!isSourceCheckout(n)?void 0:resolveSourceCheckoutExport(n,e);if(r!==void 0)return r;throw t}}function resolveSourceCheckoutExport(e,t){if(t!==EVE_PACKAGE_NAME&&!t.startsWith(`${EVE_PACKAGE_NAME}/`))return;let n=t===EVE_PACKAGE_NAME?`.`:`.${t.slice(EVE_PACKAGE_NAME.length)}`;try{let t=JSON.parse(readFileSync(join(e,`package.json`),`utf8`)).exports?.[n],r=typeof t==`string`?t:t?.[`eve-source`]??t?.import??t?.default;if(r===void 0)return;let i=r.replace(/^\.\/dist\/src\//,`src/`).replace(/\.[cm]?js$/u,`.ts`),a=join(e,i);return existsSync(a)?a:void 0}catch{return}}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(typeof t.name==`string`&&typeof t.version==`string`)return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageLocationFromModulePath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
@@ -1 +1 @@
1
- import{createHash}from"node:crypto";import{join,resolve}from"node:path";import{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath}from"#internal/application/package.js";import{existsSync,readFileSync,readdirSync,rmSync}from"node:fs";import{EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV}from"#internal/application/build-output-environment.js";import{workflowEntryReference}from"#execution/workflow-runtime.js";function resolveApplicationRoot(e=process.cwd()){return resolve(e)}function getWorkflowBuildCacheKey(e){return createHash(`sha256`).update(e).digest(`hex`).slice(0,12)}function isVercelBuildEnvironment(){return!!process.env.VERCEL}function resolveNitroBuildDirectory(e){return join(e,`.eve`,`nitro`)}function resolveApplicationHostArtifactsDirectory(e){return join(e,`.eve`,`host`)}function resolveWorkflowBuildDirectory(e){let t=join(resolvePackageRoot(),`.eve`,`workflow-cache`);return pruneStaleWorkflowCacheSiblings(t),join(t,getWorkflowBuildCacheKey(e))}function pruneStaleWorkflowCacheSiblings(e){if(!existsSync(e))return;let t=resolveInstalledPackageInfo().version,n;try{n=readdirSync(e)}catch{return}for(let r of n){let n=join(e,r),i=join(n,`eve-cache.json`);if(existsSync(i))try{let e=JSON.parse(readFileSync(i,`utf8`));typeof e.eveVersion==`string`&&e.eveVersion!==t&&rmSync(n,{force:!0,recursive:!0})}catch{}}}function resolveSandboxCacheDirectory(e){return join(e,`.eve`,`sandbox-cache`)}function resolveOutputDirectory(e){return isVercelBuildEnvironment()?join(e,`.vercel`,`output`):join(e,`.output`)}function getApplicationInfo(e){return{appRoot:e,outputDir:resolveOutputDirectory(e),workflowId:workflowEntryReference.workflowId,workflowBuildDir:resolveWorkflowBuildDirectory(e),workflowSourceDir:resolvePackageSourceDirectoryPath(`src/execution`)}}export{EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV,getApplicationInfo,isVercelBuildEnvironment,resolveApplicationHostArtifactsDirectory,resolveApplicationRoot,resolveNitroBuildDirectory,resolveOutputDirectory,resolveSandboxCacheDirectory,resolveWorkflowBuildDirectory};
1
+ import{createHash}from"node:crypto";import{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath}from"#internal/application/package.js";import{existsSync,readFileSync,readdirSync,rmSync}from"node:fs";import{join,resolve}from"node:path";import{EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV}from"#internal/application/build-output-environment.js";import{workflowEntryReference}from"#execution/workflow-runtime.js";function resolveApplicationRoot(e=process.cwd()){return resolve(e)}function getWorkflowBuildCacheKey(e){return createHash(`sha256`).update(e).digest(`hex`).slice(0,12)}function isVercelBuildEnvironment(){return!!process.env.VERCEL}function resolveNitroBuildDirectory(e){return join(e,`.eve`,`nitro`)}function resolveApplicationHostArtifactsDirectory(e){return join(e,`.eve`,`host`)}function resolveWorkflowBuildDirectory(e){let t=join(resolvePackageRoot(),`.eve`,`workflow-cache`);return pruneStaleWorkflowCacheSiblings(t),join(t,getWorkflowBuildCacheKey(e))}function pruneStaleWorkflowCacheSiblings(e){if(!existsSync(e))return;let t=resolveInstalledPackageInfo().version,n;try{n=readdirSync(e)}catch{return}for(let r of n){let n=join(e,r),i=join(n,`eve-cache.json`);if(existsSync(i))try{let e=JSON.parse(readFileSync(i,`utf8`));typeof e.eveVersion==`string`&&e.eveVersion!==t&&rmSync(n,{force:!0,recursive:!0})}catch{}}}function resolveSandboxCacheDirectory(e){return join(e,`.eve`,`sandbox-cache`)}function resolveOutputDirectory(e){return isVercelBuildEnvironment()?join(e,`.vercel`,`output`):join(e,`.output`)}function getApplicationInfo(e){return{appRoot:e,outputDir:resolveOutputDirectory(e),workflowId:workflowEntryReference.workflowId,workflowBuildDir:resolveWorkflowBuildDirectory(e),workflowSourceDir:resolvePackageSourceDirectoryPath(`src/execution`)}}export{EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV,getApplicationInfo,isVercelBuildEnvironment,resolveApplicationHostArtifactsDirectory,resolveApplicationRoot,resolveNitroBuildDirectory,resolveOutputDirectory,resolveSandboxCacheDirectory,resolveWorkflowBuildDirectory};
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{readFile,readdir}from"node:fs/promises";import{dirname,isAbsolute,join,resolve}from"node:path";import{existsSync}from"node:fs";import{parse}from"#compiled/jsonc-parser/index.js";async function resolveTsConfigDependencyPaths(e){let t=await resolveRootTsConfigPaths(e),n=new Set,r=new Set;for(let e of t)await collectTsConfigDependencyPaths({configPath:e,resolvedConfigPaths:n,visitingConfigPaths:r});return[...n].sort((e,t)=>e.localeCompare(t))}async function resolveRootTsConfigPaths(e){let t=new Set([join(e,`tsconfig.json`),join(e,`jsconfig.json`)]);try{let n=await readdir(e,{withFileTypes:!0});for(let r of n)r.isFile()&&/^tsconfig\..+\.json$/i.test(r.name)&&t.add(join(e,r.name))}catch{}return[...t]}async function collectTsConfigDependencyPaths(e){let t=resolve(e.configPath);if(e.resolvedConfigPaths.has(t)||e.visitingConfigPaths.has(t))return;let n=await readTextFileIfExists(t);if(n!==void 0){e.resolvedConfigPaths.add(t),e.visitingConfigPaths.add(t);try{let r=extractTsConfigExtendsSpecifiers(n);for(let n of r)for(let r of resolveTsConfigExtendsTargetPaths({configPath:t,extendsSpecifier:n}))await collectTsConfigDependencyPaths({configPath:r,resolvedConfigPaths:e.resolvedConfigPaths,visitingConfigPaths:e.visitingConfigPaths})}finally{e.visitingConfigPaths.delete(t)}}}async function readTextFileIfExists(e){try{return await readFile(e,`utf8`)}catch{return}}function parseTsConfigObject(e){let t=[],n=parse(e,t,{allowTrailingComma:!0});if(!(t.length>0||typeof n!=`object`||!n||Array.isArray(n)))return n}function extractTsConfigExtendsSpecifiers(e){let t=parseTsConfigObject(e);if(t===void 0)return[];let n=t.extends;return typeof n==`string`?n.length>0?[n]:[]:Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}function resolveTsConfigExtendsTargetPaths(e){let t=new Set;if(isTsConfigFilePath(e.extendsSpecifier))for(let n of resolveFileExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);else for(let n of resolvePackageExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);return[...t]}function resolveFirstExistingTsConfigExtendsTarget(e){for(let t of resolveTsConfigExtendsTargetPaths(e))if(existsSync(t))return t}function resolveFileExtendsCandidates(e){let t=resolve(dirname(e.configPath),e.extendsSpecifier),n=new Set;return n.add(t),t.endsWith(`.json`)||(n.add(`${t}.json`),n.add(join(t,`tsconfig.json`))),[...n]}function resolvePackageExtendsCandidates(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=createRequire(e.configPath);for(let e of t)try{n.add(r.resolve(e))}catch{}return[...n]}function isTsConfigFilePath(e){return e.startsWith(`.`)||isAbsolute(e)?!0:/^[A-Za-z]:[\\/]/.test(e)}export{collectTsConfigDependencyPaths,extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveRootTsConfigPaths,resolveTsConfigDependencyPaths,resolveTsConfigExtendsTargetPaths};
1
+ import{createRequire}from"node:module";import{readFile,readdir}from"node:fs/promises";import{existsSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{parse}from"#compiled/jsonc-parser/index.js";async function resolveTsConfigDependencyPaths(e){let t=await resolveRootTsConfigPaths(e),n=new Set,r=new Set;for(let e of t)await collectTsConfigDependencyPaths({configPath:e,resolvedConfigPaths:n,visitingConfigPaths:r});return[...n].sort((e,t)=>e.localeCompare(t))}async function resolveRootTsConfigPaths(e){let t=new Set([join(e,`tsconfig.json`),join(e,`jsconfig.json`)]);try{let n=await readdir(e,{withFileTypes:!0});for(let r of n)r.isFile()&&/^tsconfig\..+\.json$/i.test(r.name)&&t.add(join(e,r.name))}catch{}return[...t]}async function collectTsConfigDependencyPaths(e){let t=resolve(e.configPath);if(e.resolvedConfigPaths.has(t)||e.visitingConfigPaths.has(t))return;let n=await readTextFileIfExists(t);if(n!==void 0){e.resolvedConfigPaths.add(t),e.visitingConfigPaths.add(t);try{let r=extractTsConfigExtendsSpecifiers(n);for(let n of r)for(let r of resolveTsConfigExtendsTargetPaths({configPath:t,extendsSpecifier:n}))await collectTsConfigDependencyPaths({configPath:r,resolvedConfigPaths:e.resolvedConfigPaths,visitingConfigPaths:e.visitingConfigPaths})}finally{e.visitingConfigPaths.delete(t)}}}async function readTextFileIfExists(e){try{return await readFile(e,`utf8`)}catch{return}}function parseTsConfigObject(e){let t=[],n=parse(e,t,{allowTrailingComma:!0});if(!(t.length>0||typeof n!=`object`||!n||Array.isArray(n)))return n}function extractTsConfigExtendsSpecifiers(e){let t=parseTsConfigObject(e);if(t===void 0)return[];let n=t.extends;return typeof n==`string`?n.length>0?[n]:[]:Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}function resolveTsConfigExtendsTargetPaths(e){let t=new Set;if(isTsConfigFilePath(e.extendsSpecifier))for(let n of resolveFileExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);else for(let n of resolvePackageExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);return[...t]}function resolveFirstExistingTsConfigExtendsTarget(e){for(let t of resolveTsConfigExtendsTargetPaths(e))if(existsSync(t))return t}function resolveFileExtendsCandidates(e){let t=resolve(dirname(e.configPath),e.extendsSpecifier),n=new Set;return n.add(t),t.endsWith(`.json`)||(n.add(`${t}.json`),n.add(join(t,`tsconfig.json`))),[...n]}function resolvePackageExtendsCandidates(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=createRequire(e.configPath);for(let e of t)try{n.add(r.resolve(e))}catch{}return[...n]}function isTsConfigFilePath(e){return e.startsWith(`.`)||isAbsolute(e)?!0:/^[A-Za-z]:[\\/]/.test(e)}export{collectTsConfigDependencyPaths,extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveRootTsConfigPaths,resolveTsConfigDependencyPaths,resolveTsConfigExtendsTargetPaths};
@@ -1 +1 @@
1
- import{readFile}from"node:fs/promises";import{dirname,extname,isAbsolute,relative,resolve}from"node:path";import{realpathSync}from"node:fs";const AUTHORED_ASSET_CODE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createAuthoredAssetImportPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-authored-asset-import`,resolveId(e,n){if(!isPotentialAuthoredAssetImport(e)||n===void 0)return;let{path:r,suffix:i}=splitImportSuffix(e),a=toCanonicalPath(isAbsolute(r)?r:resolve(dirname(n),r));if(!isPathInsideOrEqual(a,t))throw Error(`Authored asset import "${e}" from "${n}" resolves outside package root "${t}".`);return`${a}${i}`},async load(e){let{path:t,suffix:n}=splitImportSuffix(e);if(!isPotentialAuthoredAssetImport(t))return;if(n===`?raw`){let e=await readAssetText(t);return e===void 0?void 0:{code:`export default ${JSON.stringify(e)};`,moduleType:`js`}}let r=await readAssetDataUrl(t);if(r!==void 0)return{code:`export default ${JSON.stringify(r)};`,moduleType:`js`}}}}function isPathInsideOrEqual(e,t){let n=relative(t,resolve(e));return n===``||!n.startsWith(`..`)&&!isAbsolute(n)}function toCanonicalPath(e){let t=resolve(e);try{return realpathSync.native(t)}catch{return t}}async function readAssetText(e){try{return await readFile(e,`utf8`)}catch(e){if(isPathNotFoundError(e))return;throw e}}function isPotentialAuthoredAssetImport(e){if(e.startsWith(`\0`)||e.startsWith(`node:`)||e.startsWith(`data:`)||e.startsWith(`file:`))return!1;let{path:t}=splitImportSuffix(e);if(!t.startsWith(`.`)&&!t.startsWith(`/`)&&!/^[A-Za-z]:[\\/]/.test(t))return!1;let n=extname(t);return n.length>0&&n!==`.node`&&!AUTHORED_ASSET_CODE_EXTENSIONS.includes(n)}function splitImportSuffix(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 readAssetDataUrl(e){try{let t=await readFile(e);return`data:${getAssetMimeType(e)};base64,${t.toString(`base64`)}`}catch(e){if(isPathNotFoundError(e))return;throw e}}function isPathNotFoundError(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`)}function getAssetMimeType(e){switch(extname(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`}}export{createAuthoredAssetImportPlugin};
1
+ import{readFile}from"node:fs/promises";import{realpathSync}from"node:fs";import{dirname,extname,isAbsolute,relative,resolve}from"node:path";const AUTHORED_ASSET_CODE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createAuthoredAssetImportPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-authored-asset-import`,resolveId(e,n){if(!isPotentialAuthoredAssetImport(e)||n===void 0)return;let{path:r,suffix:i}=splitImportSuffix(e),a=toCanonicalPath(isAbsolute(r)?r:resolve(dirname(n),r));if(!isPathInsideOrEqual(a,t))throw Error(`Authored asset import "${e}" from "${n}" resolves outside package root "${t}".`);return`${a}${i}`},async load(e){let{path:t,suffix:n}=splitImportSuffix(e);if(!isPotentialAuthoredAssetImport(t))return;if(n===`?raw`){let e=await readAssetText(t);return e===void 0?void 0:{code:`export default ${JSON.stringify(e)};`,moduleType:`js`}}let r=await readAssetDataUrl(t);if(r!==void 0)return{code:`export default ${JSON.stringify(r)};`,moduleType:`js`}}}}function isPathInsideOrEqual(e,t){let n=relative(t,resolve(e));return n===``||!n.startsWith(`..`)&&!isAbsolute(n)}function toCanonicalPath(e){let t=resolve(e);try{return realpathSync.native(t)}catch{return t}}async function readAssetText(e){try{return await readFile(e,`utf8`)}catch(e){if(isPathNotFoundError(e))return;throw e}}function isPotentialAuthoredAssetImport(e){if(e.startsWith(`\0`)||e.startsWith(`node:`)||e.startsWith(`data:`)||e.startsWith(`file:`))return!1;let{path:t}=splitImportSuffix(e);if(!t.startsWith(`.`)&&!t.startsWith(`/`)&&!/^[A-Za-z]:[\\/]/.test(t))return!1;let n=extname(t);return n.length>0&&n!==`.node`&&!AUTHORED_ASSET_CODE_EXTENSIONS.includes(n)}function splitImportSuffix(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 readAssetDataUrl(e){try{let t=await readFile(e);return`data:${getAssetMimeType(e)};base64,${t.toString(`base64`)}`}catch(e){if(isPathNotFoundError(e))return;throw e}}function isPathNotFoundError(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`)}function getAssetMimeType(e){switch(extname(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`}}export{createAuthoredAssetImportPlugin};
@@ -1,4 +1,4 @@
1
- import{dirname,extname,join,relative,resolve}from"node:path";import{existsSync,readFileSync,statSync}from"node:fs";import{fileURLToPath}from"node:url";function createAuthoredModuleEvaluationError(e,t){let n=describeInstalledPackageLoadFailure(t);return Error([`Failed to evaluate authored module:`,` ${e}`,...n===void 0?[]:[``,n]].join(`
1
+ import{existsSync,readFileSync,statSync}from"node:fs";import{dirname,extname,join,relative,resolve}from"node:path";import{fileURLToPath}from"node:url";function createAuthoredModuleEvaluationError(e,t){let n=describeInstalledPackageLoadFailure(t);return Error([`Failed to evaluate authored module:`,` ${e}`,...n===void 0?[]:[``,n]].join(`
2
2
  `),{cause:t})}function describeInstalledPackageLoadFailure(e){if(!(e instanceof Error))return;let t=e;if(t.code!==`ERR_MODULE_NOT_FOUND`||typeof t.url!=`string`)return;let n=filePathFromUrl(t.url);if(n===void 0||extname(n)!==``)return;let r=findInstalledPackage(n);if(r===void 0)return;let i=toPackageRelativePath(r.root,n);return findExistingModulePath(n)===void 0?[`Failed to load an installed package:`,` Package: ${r.name} (loaded outside the authored bundle)`,` Missing: ${i}`,` Reason: Package output may be incomplete, incorrectly installed, or incompatible with a standalone Node runtime.`,` Hint: Verify the installed package version and output, use a Node-compatible entrypoint, or report the missing module to the package publisher.`].join(`
3
3
  `):[`Failed to load an installed package:`,` Package: ${r.name} (loaded outside the authored bundle)`,` Import: ${i}`,` Reason: Node's ESM loader does not infer file extensions for relative imports.`,` Hint: Use a Node-compatible package or entrypoint, or report the extensionless import to the package publisher.`].join(`
4
4
  `)}function findExistingModulePath(e){for(let t of[`.js`,`.mjs`,`.cjs`]){let n=`${e}${t}`;try{if(statSync(n).isFile())return n}catch{}}}function toPackageRelativePath(e,t){return relative(e,t).replaceAll(`\\`,`/`)}function filePathFromUrl(e){try{let t=new URL(e);return t.protocol===`file:`?fileURLToPath(t):void 0}catch{return}}function findInstalledPackage(e){let t=dirname(resolve(e));for(;;){let e=join(t,`package.json`);if(existsSync(e)&&isNodeModulesPath(e))try{let n=JSON.parse(readFileSync(e,`utf8`));if(typeof n.name==`string`&&n.name.length>0)return{name:n.name,root:t}}catch{return}let n=dirname(t);if(n===t)return;t=n}}function isNodeModulesPath(e){return e.replaceAll(`\\`,`/`).includes(`/node_modules/`)}export{createAuthoredModuleEvaluationError};
@@ -1,3 +1,3 @@
1
- import{createHash}from"node:crypto";import{expectObjectRecord}from"#internal/authored-module.js";import{dirname,join,relative,resolve,sep}from"node:path";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{existsSync,mkdirSync,realpathSync,writeFileSync}from"node:fs";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";import{buildSingleRolldownChunk,buildWithNitroRolldown}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{authoredModuleConditions}from"#internal/authored-module-conditions.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredModuleEvaluationError}from"#internal/authored-module-evaluation-error.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createAuthoredRelativeExtensionResolverPlugin}from"#internal/authored-relative-extension-resolver.js";import{createExtensionScopePlugin,createFixedNamespaceScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";import{prepareAuthoredWorkflowDirectives}from"#internal/workflow-bundle/authored-workflow-directives.js";import{createDynamicCapabilityTransformPlugin}from"#internal/workflow-bundle/dynamic-capability-transform-plugin.js";import{applyWorkflowTransform,isAuthoredApplicationModule}from"#internal/workflow-bundle/workflow-builders.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),inFlightModuleLoads=new Map;function loadAuthoredModuleNamespace(e,t={}){let n=createInFlightModuleLoadKey(resolve(e),t),r=inFlightModuleLoads.get(n);if(r!==void 0)return r;let i=(async()=>{try{return await doLoadAuthoredModuleNamespace(e,t)}finally{inFlightModuleLoads.delete(n)}})();return inFlightModuleLoads.set(n,i),i}async function doLoadAuthoredModuleNamespace(e,t){let n=AUTHORED_BUNDLED_MODULE_EXTENSION.test(e)?await loadBundledAuthoredModule(e,t):await import(createFileImportSpecifier(e));return expectObjectRecord(n,`Expected "${e}" to export a module namespace object.`)}function createFileImportSpecifier(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}async function bundleAuthoredModuleCode(e,t={}){let n=resolveAuthoredPackageRoot(e);return await buildAuthoredModuleBundle(e,t,{packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:n}),plugins:[createAuthoredWorkflowDirectivePlugin({appRoot:n})],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){return removeRolldownModuleRegionComments(await buildAuthoredModuleBundle(e,t,{packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1}))}async function bundleExtensionDistributionGraph(e){let t=[createAuthoredDirectiveGuardPlugin(),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:e.packageRoot}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:e.packageRoot,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createDistributionPackageBoundaryPlugin({packageRoot:e.packageRoot,runtimeDependencies:e.runtimeDependencies})];try{let n=await buildWithNitroRolldown({cwd:e.packageRoot,input:Object.fromEntries(e.entries.map(e=>[e.name,e.path])),platform:`node`,plugins:t,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(e.packageRoot),write:!1,output:{chunkFileNames:`_chunks/[name]-[hash].mjs`,codeSplitting:!0,comments:!1,entryFileNames:`[name].mjs`,format:`esm`,sourcemap:!1}}),r=new Map,i=new Set;for(let e of n.output)if(e.type===`chunk`){r.set(e.fileName,removeRolldownModuleRegionComments(e.code));for(let t of[...e.imports,...e.dynamicImports])i.add(t)}return{files:r,imports:[...i]}}catch(t){throw createAuthoredModuleBundleError(e.packageRoot,t)}}async function bundleAuthoredModuleMapForGeneration(e){let t=resolveAuthoredPackageRoot(e.manifest.agentRoot),n=resolvePackageSourceFilePath(usesDevelopmentExtensionModules(e.manifest)?`src/internal/development-programmatic-source-loader.ts`:`src/internal/programmatic-source-loader.ts`),r=normalizeExternalDependencies([...e.manifest.config.build?.externalDependencies??[],...e.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])]),i=createCompiledModuleMapSource({manifest:e.manifest,moduleMapPath:e.moduleMapPath,programmaticLoaderImportSpecifier:n}),a=createExtensionScopePlugin([e.manifest,...e.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({packageNamespace:e.packageNamespace,sourceRoot:e.sourceRoot})))),o=new AuthoredWorkflowSourceRecorder(e.appRoot),s=[createVirtualGenerationModuleMapPlugin({id:e.moduleMapPath,source:i}),createExternalRuntimeImportPlugin(n),createAuthoredWorkflowDirectivePlugin({appRoot:e.appRoot,recorder:o}),createDynamicCapabilityTransformPlugin({workflowFunctions:e=>o.workflowFunctions(e)}),o.graphPlugin(),a,createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:t}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:t,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createGenerationPackageBoundaryPlugin({externalDependencies:r,packageRoot:t})].filter(e=>e!==null);try{let n=await buildSingleRolldownChunk(`authored module map`,{cwd:t,input:e.moduleMapPath,platform:`node`,plugins:s,resolve:{conditionNames:authoredModuleConditions(),extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(t),output:{comments:!1,format:`esm`,sourcemap:!1}});return{authoredWorkflowModules:o.modules(),code:removeRolldownModuleRegionComments(n.code),workflowSourceFingerprint:o.fingerprint()}}catch(t){throw createAuthoredModuleBundleError(e.moduleMapPath,t)}}function usesDevelopmentExtensionModules(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>Object.values(e.bindings).some(e=>e.backing.kind===`programmatic`&&e.backing.registryId.startsWith(`eve:development-extension:`)))}function createExternalRuntimeImportPlugin(e){let t=normalizeEsmImportSpecifier(e);return{name:`eve-external-runtime-import`,resolveId(e){return e===t?{external:!0,id:t}:void 0}}}var AuthoredWorkflowSourceRecorder=class{#e;#t=new Set;#n=new Map;#r=new Map;#i=new Map;constructor(e){this.#e=e}record(e,t,n){this.#r.set(e,t),(n.steps!==void 0||n.workflows!==void 0)&&this.#t.add(e);let r=Object.values(n.workflows??{})[0];r!==void 0&&this.#i.set(e,new Set(Object.keys(r)))}workflowFunctions(e){return this.#i.get(e)}graphPlugin(){let e=this.#n;return{name:`eve-authored-module-graph`,buildEnd(){for(let t of this.getModuleIds()){let n=this.getModuleInfo(t);n!==null&&e.set(t,[...n.importedIds,...n.dynamicallyImportedIds])}}}}modules(){return{directiveModules:[...this.#t].sort(),workflowModules:[...this.#i.keys()].sort()}}fingerprint(){if(this.#t.size===0)return;let e=new Set,t=[...this.#t];for(let n=t.shift();n!==void 0;n=t.shift())!e.has(n)&&this.#r.has(n)&&(e.add(n),t.push(...this.#n.get(n)??[]));let n=createHash(`sha256`);for(let t of[...e].sort())n.update(relative(this.#e,t).split(sep).join(`/`)).update(`\0`).update(this.#r.get(t)??``).update(`\0`);return n.digest(`hex`)}};function createVirtualGenerationModuleMapPlugin(e){return{name:`eve-generation-module-map`,resolveId(t){return t===e.id?t:void 0},load(t){return t===e.id?{code:e.source,moduleType:`js`}:void 0}}}async function buildAuthoredModuleBundle(e,t,n){let r=resolveAuthoredPackageRoot(e),i=resolveAuthoredTsConfigPath(r),a=[...n.plugins,t.extensionScopeNamespace===void 0?null:createFixedNamespaceScopePlugin(t.extensionScopeNamespace),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:r}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:r,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),n.packageBoundaryPlugin].filter(e=>e!==null);try{return(await buildSingleRolldownChunk(`authored module for "${e}"`,{cwd:r,input:e,platform:`node`,plugins:a,resolve:{conditionNames:authoredModuleConditions(),extensions:[...RESOLVE_EXTENSIONS]},tsconfig:i,output:{comments:!1,format:`esm`,sourcemap:n.sourcemap}})).code}catch(t){throw createAuthoredModuleBundleError(e,t)}}function createAuthoredDirectiveGuardPlugin(){return{name:`eve-authored-directive-guard`,async transform(e,t){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)||isNodeModulesPath(t))return;let{hasDirectives:n}=await prepareAuthoredWorkflowDirectives({filePath:t,source:e});if(n)throw Error(`Module "${t}" uses Workflow directives ("use step" or "use workflow"). Workflow directives are supported in application modules only, not in extensions or instrumentation.`)}}}function createAuthoredWorkflowDirectivePlugin(e){return{name:`eve-authored-workflow-directives`,async transform(t,n){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(n)||isNodeModulesPath(n)||!isAuthoredApplicationModule(n,e.appRoot))return;let r=await applyWorkflowTransform(n,t,`client`,n,e.appRoot);return e.recorder?.record(n,t,r.workflowManifest),r.code===t?void 0:{code:r.code,map:null}}}}function removeRolldownModuleRegionComments(e){return e.split(`
1
+ import{createHash}from"node:crypto";import{expectObjectRecord}from"#internal/authored-module.js";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{existsSync,mkdirSync,realpathSync,writeFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";import{buildSingleRolldownChunk,buildWithNitroRolldown}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{authoredModuleConditions}from"#internal/authored-module-conditions.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredModuleEvaluationError}from"#internal/authored-module-evaluation-error.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createAuthoredRelativeExtensionResolverPlugin}from"#internal/authored-relative-extension-resolver.js";import{createExtensionScopePlugin,createFixedNamespaceScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";import{prepareAuthoredWorkflowDirectives}from"#internal/workflow-bundle/authored-workflow-directives.js";import{createDynamicCapabilityTransformPlugin}from"#internal/workflow-bundle/dynamic-capability-transform-plugin.js";import{applyWorkflowTransform,isAuthoredApplicationModule}from"#internal/workflow-bundle/workflow-builders.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),inFlightModuleLoads=new Map;function loadAuthoredModuleNamespace(e,t={}){let n=createInFlightModuleLoadKey(resolve(e),t),r=inFlightModuleLoads.get(n);if(r!==void 0)return r;let i=(async()=>{try{return await doLoadAuthoredModuleNamespace(e,t)}finally{inFlightModuleLoads.delete(n)}})();return inFlightModuleLoads.set(n,i),i}async function doLoadAuthoredModuleNamespace(e,t){let n=AUTHORED_BUNDLED_MODULE_EXTENSION.test(e)?await loadBundledAuthoredModule(e,t):await import(createFileImportSpecifier(e));return expectObjectRecord(n,`Expected "${e}" to export a module namespace object.`)}function createFileImportSpecifier(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}async function bundleAuthoredModuleCode(e,t={}){let n=resolveAuthoredPackageRoot(e);return await buildAuthoredModuleBundle(e,t,{packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:n}),plugins:[createAuthoredWorkflowDirectivePlugin({appRoot:n})],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){return removeRolldownModuleRegionComments(await buildAuthoredModuleBundle(e,t,{packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1}))}async function bundleExtensionDistributionGraph(e){let t=[createAuthoredDirectiveGuardPlugin(),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:e.packageRoot}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:e.packageRoot,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createDistributionPackageBoundaryPlugin({packageRoot:e.packageRoot,runtimeDependencies:e.runtimeDependencies})];try{let n=await buildWithNitroRolldown({cwd:e.packageRoot,input:Object.fromEntries(e.entries.map(e=>[e.name,e.path])),platform:`node`,plugins:t,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(e.packageRoot),write:!1,output:{chunkFileNames:`_chunks/[name]-[hash].mjs`,codeSplitting:!0,comments:!1,entryFileNames:`[name].mjs`,format:`esm`,sourcemap:!1}}),r=new Map,i=new Set;for(let e of n.output)if(e.type===`chunk`){r.set(e.fileName,removeRolldownModuleRegionComments(e.code));for(let t of[...e.imports,...e.dynamicImports])i.add(t)}return{files:r,imports:[...i]}}catch(t){throw createAuthoredModuleBundleError(e.packageRoot,t)}}async function bundleAuthoredModuleMapForGeneration(e){let t=resolveAuthoredPackageRoot(e.manifest.agentRoot),n=resolvePackageSourceFilePath(usesDevelopmentExtensionModules(e.manifest)?`src/internal/development-programmatic-source-loader.ts`:`src/internal/programmatic-source-loader.ts`),r=normalizeExternalDependencies([...e.manifest.config.build?.externalDependencies??[],...e.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])]),i=createCompiledModuleMapSource({manifest:e.manifest,moduleMapPath:e.moduleMapPath,programmaticLoaderImportSpecifier:n}),a=createExtensionScopePlugin([e.manifest,...e.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({packageNamespace:e.packageNamespace,sourceRoot:e.sourceRoot})))),o=new AuthoredWorkflowSourceRecorder(e.appRoot),s=[createVirtualGenerationModuleMapPlugin({id:e.moduleMapPath,source:i}),createExternalRuntimeImportPlugin(n),createAuthoredWorkflowDirectivePlugin({appRoot:e.appRoot,recorder:o}),createDynamicCapabilityTransformPlugin({workflowFunctions:e=>o.workflowFunctions(e)}),o.graphPlugin(),a,createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:t}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:t,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createGenerationPackageBoundaryPlugin({externalDependencies:r,packageRoot:t})].filter(e=>e!==null);try{let n=await buildSingleRolldownChunk(`authored module map`,{cwd:t,input:e.moduleMapPath,platform:`node`,plugins:s,resolve:{conditionNames:authoredModuleConditions(),extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(t),output:{comments:!1,format:`esm`,sourcemap:!1}});return{authoredWorkflowModules:o.modules(),code:removeRolldownModuleRegionComments(n.code),workflowSourceFingerprint:o.fingerprint()}}catch(t){throw createAuthoredModuleBundleError(e.moduleMapPath,t)}}function usesDevelopmentExtensionModules(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>Object.values(e.bindings).some(e=>e.backing.kind===`programmatic`&&e.backing.registryId.startsWith(`eve:development-extension:`)))}function createExternalRuntimeImportPlugin(e){let t=normalizeEsmImportSpecifier(e);return{name:`eve-external-runtime-import`,resolveId(e){return e===t?{external:!0,id:t}:void 0}}}var AuthoredWorkflowSourceRecorder=class{#e;#t=new Set;#n=new Map;#r=new Map;#i=new Map;constructor(e){this.#e=e}record(e,t,n){this.#r.set(e,t),(n.steps!==void 0||n.workflows!==void 0)&&this.#t.add(e);let r=Object.values(n.workflows??{})[0];r!==void 0&&this.#i.set(e,new Set(Object.keys(r)))}workflowFunctions(e){return this.#i.get(e)}graphPlugin(){let e=this.#n;return{name:`eve-authored-module-graph`,buildEnd(){for(let t of this.getModuleIds()){let n=this.getModuleInfo(t);n!==null&&e.set(t,[...n.importedIds,...n.dynamicallyImportedIds])}}}}modules(){return{directiveModules:[...this.#t].sort(),workflowModules:[...this.#i.keys()].sort()}}fingerprint(){if(this.#t.size===0)return;let e=new Set,t=[...this.#t];for(let n=t.shift();n!==void 0;n=t.shift())!e.has(n)&&this.#r.has(n)&&(e.add(n),t.push(...this.#n.get(n)??[]));let n=createHash(`sha256`);for(let t of[...e].sort())n.update(relative(this.#e,t).split(sep).join(`/`)).update(`\0`).update(this.#r.get(t)??``).update(`\0`);return n.digest(`hex`)}};function createVirtualGenerationModuleMapPlugin(e){return{name:`eve-generation-module-map`,resolveId(t){return t===e.id?t:void 0},load(t){return t===e.id?{code:e.source,moduleType:`js`}:void 0}}}async function buildAuthoredModuleBundle(e,t,n){let r=resolveAuthoredPackageRoot(e),i=resolveAuthoredTsConfigPath(r),a=[...n.plugins,t.extensionScopeNamespace===void 0?null:createFixedNamespaceScopePlugin(t.extensionScopeNamespace),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:r}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:r,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),n.packageBoundaryPlugin].filter(e=>e!==null);try{return(await buildSingleRolldownChunk(`authored module for "${e}"`,{cwd:r,input:e,platform:`node`,plugins:a,resolve:{conditionNames:authoredModuleConditions(),extensions:[...RESOLVE_EXTENSIONS]},tsconfig:i,output:{comments:!1,format:`esm`,sourcemap:n.sourcemap}})).code}catch(t){throw createAuthoredModuleBundleError(e,t)}}function createAuthoredDirectiveGuardPlugin(){return{name:`eve-authored-directive-guard`,async transform(e,t){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)||isNodeModulesPath(t))return;let{hasDirectives:n}=await prepareAuthoredWorkflowDirectives({filePath:t,source:e});if(n)throw Error(`Module "${t}" uses Workflow directives ("use step" or "use workflow"). Workflow directives are supported in application modules only, not in extensions or instrumentation.`)}}}function createAuthoredWorkflowDirectivePlugin(e){return{name:`eve-authored-workflow-directives`,async transform(t,n){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(n)||isNodeModulesPath(n)||!isAuthoredApplicationModule(n,e.appRoot))return;let r=await applyWorkflowTransform(n,t,`client`,n,e.appRoot);return e.recorder?.record(n,t,r.workflowManifest),r.code===t?void 0:{code:r.code,map:null}}}}function removeRolldownModuleRegionComments(e){return e.split(`
2
2
  `).filter(e=>!e.startsWith(`//#region `)&&e!==`//#endregion`).join(`
3
3
  `)}async function loadBundledAuthoredModule(e,t){let n=await bundleAuthoredModuleCode(e,t),r=normalizeExternalDependencies(t.externalDependencies),i=createHash(`sha1`).update(e).update(`\0`).update(r.join(`\0`)).update(`\0`).update(t.extensionScopeNamespace??``).update(`\0`).update(n).digest(`hex`),a=join(resolveAuthoredPackageRoot(e),AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH),o=join(a,`${i}.mjs`);existsSync(o)||(mkdirSync(a,{recursive:!0}),writeFileSync(o,n));try{return await import(`${createFileImportSpecifier(o)}?v=${i}`)}catch(t){throw createAuthoredModuleEvaluationError(e,t)}}function createInFlightModuleLoadKey(e,t){return`${e}\0${normalizeExternalDependencies(t.externalDependencies).join(`\0`)}\0${t.extensionScopeNamespace??``}`}function resolveAuthoredTsConfigPath(e){for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=join(e,t);if(existsSync(n))return n}return!1}function resolveAuthoredPackageRoot(e){let t=dirname(e);for(;;){if(existsSync(join(t,`package.json`)))return realpathSync(t);let n=dirname(t);if(n===t)throw Error(`Failed to resolve the authored package root for "${e}".`);t=n}}export{bundleAuthoredModuleCode,bundleAuthoredModuleForGeneration,bundleAuthoredModuleMapForGeneration,bundleExtensionDistributionGraph,loadAuthoredModuleNamespace,resolveAuthoredPackageRoot,resolveAuthoredTsConfigPath};
@@ -1 +1 @@
1
- import{createRequire,isBuiltin}from"node:module";import{dirname,join,resolve,sep}from"node:path";import{resolvePackageDependencyPath,resolveWorkflowModulePath}from"#internal/application/package.js";import{existsSync,readFileSync,realpathSync}from"node:fs";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";const RESOLVE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createGenerationPackageBoundaryPlugin(e){return{name:`eve-generation-package-boundary`,async resolveId(t,n,r){if(isPackageImport(t)){if(isFrameworkRuntimeImport(t,n))return{external:!0,id:resolveFrameworkRuntimeImport(t)};if(t.startsWith(`#`)){let r=resolvePackageImport(t,n,e.packageRoot);if(r!==void 0)return{id:r}}if(await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:n,kind:r.kind,packageRoot:e.packageRoot,source:t})!==void 0)return{external:!0,id:t}}}}}function createRuntimeLoaderPackageBoundaryPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-runtime-loader-package-boundary`,async resolveId(n,r,i){if(!isPackageImport(n))return;if(isFrameworkRuntimeImport(n,r))return{external:!0,id:resolveRuntimeLoaderFrameworkImport(n)};if(n.startsWith(`#`)){let t=resolvePackageImport(n,r,e.packageRoot);if(t!==void 0)return{id:t}}let a=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:r,kind:i.kind,packageRoot:e.packageRoot,source:n});if(a!==void 0){let e=resolveExistingExternalFilePath(a.resolvedId)??a.resolvedId;return{external:!0,id:normalizeEsmImportSpecifier(e)}}let o=r===void 0||r.startsWith(`\0`)?void 0:resolve(r);if(o!==void 0&&isPathInsideOrEqual(toCanonicalPath(o),t)){let e=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`)throw Error(`Cannot resolve package "${n}" imported from "${o}". Install it with your package manager (e.g. \`pnpm install\`); a running \`eve dev\` retries on the next rebuild.`);if(isNodeModulesPath(e.id))return{external:!0,id:n}}}}}function createDistributionPackageBoundaryPlugin(e){let t=new Set(e.runtimeDependencies);return{name:`eve-extension-distribution-package-boundary`,async resolveId(n,r,i){if(!isPackageImport(n))return;if(n.startsWith(`#`)){let a=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(a!==null&&typeof a.id==`string`&&!isPathInsideOrEqual(toCanonicalPath(a.id),toCanonicalPath(e.packageRoot))){let e=nearestPackageName(a.id);if(e!==void 0&&!t.has(e))throw Error(`Package import "${n}" resolves to undeclared package "${e}". Add "${e}" to dependencies, optionalDependencies, or peerDependencies.`)}return}if(isBuiltin(n))return{external:!0,id:n};let a=packageImportName(n);if(!t.has(a))throw Error(`Package "${n}" is not declared by the extension. Add "${a}" to dependencies, optionalDependencies, or peerDependencies.`);let o=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(o===null&&(o=await this.resolve(n,join(e.packageRoot,`package.json`),{kind:i.kind,skipSelf:!0})),o===null||typeof o.id!=`string`)throw Error(`Cannot resolve declared package "${n}". Install the extension's dependencies before building.`);return{external:!0,id:n}}}}async function resolveConfiguredExternalModule(e){let t=resolveConfiguredExternalDependency(e.source,e.externalDependencies);if(t===void 0)return;let n=await this.resolve(e.source,e.importer,{kind:e.kind,skipSelf:!0});if(n===null&&(n=await this.resolve(e.source,join(e.packageRoot,`package.json`),{kind:e.kind,skipSelf:!0})),n===null||typeof n.id!=`string`)throw Error(`Cannot resolve external package "${e.source}".`);return{packageName:t,resolvedId:n.id}}function normalizeExternalDependencies(e=[]){return[...new Set(e)].sort()}function resolveConfiguredExternalDependency(e,t){return t.find(t=>e===t||e.startsWith(`${t}/`))}function packageImportName(e){return e.startsWith(`@`)?e.split(`/`,2).join(`/`):e.split(`/`,1)[0]}function nearestPackageName(e){let t=nearestPackageRoot(e);if(t!==void 0)try{let e=JSON.parse(readFileSync(join(t,`package.json`),`utf8`));return typeof e.name==`string`&&e.name.length>0?e.name:void 0}catch{return}}function nearestPackageRoot(e){let t=dirname(toCanonicalPath(e));for(;;){if(existsSync(join(t,`package.json`)))return t;let e=dirname(t);if(e===t)return;t=e}}function resolvePackageImport(e,t,n){let r=t===void 0||t.startsWith(`\0`)?n:nearestPackageRoot(t)??n;try{let t=createRequire(join(r,`package.json`)).resolve(e);return isPathInsideOrEqual(toCanonicalPath(t),toCanonicalPath(r))?t:void 0}catch{return}}function resolveExistingExternalFilePath(e){if(existsSync(e))return e;for(let t of RESOLVE_EXTENSIONS){let n=`${e}${t}`;if(existsSync(n))return n}}function isPackageImport(e){return isPathImport(e)||/^(?:node|data|file):/.test(e)?!1:!e.startsWith(`@/`)}function isPathImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function isFrameworkRuntimeImport(e,t){return e===`eve/self-modification`?!1:e===`eve`||e.startsWith(`eve/`)?!0:e===`workflow`||e.startsWith(`workflow/`)||e.startsWith(`@workflow/`)?t===void 0||!isNodeModulesPath(t):!1}function resolveFrameworkRuntimeImport(e){return e===`eve`||e.startsWith(`eve/`)?e:normalizeEsmImportSpecifier(resolveWorkflowModulePath(e))}function resolveRuntimeLoaderFrameworkImport(e){return e===`eve`||e.startsWith(`eve/`)?normalizeEsmImportSpecifier(resolvePackageDependencyPath(e)):resolveFrameworkRuntimeImport(e)}function isNodeModulesPath(e){return e.replaceAll(`\\`,`/`).includes(`/node_modules/`)}function toCanonicalPath(e){try{return realpathSync(e)}catch{return resolve(e)}}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies};
1
+ import{createRequire,isBuiltin}from"node:module";import{resolvePackageDependencyPath,resolveWorkflowModulePath}from"#internal/application/package.js";import{existsSync,readFileSync,realpathSync}from"node:fs";import{dirname,join,resolve,sep}from"node:path";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";const RESOLVE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createGenerationPackageBoundaryPlugin(e){return{name:`eve-generation-package-boundary`,async resolveId(t,n,r){if(isPackageImport(t)){if(isFrameworkRuntimeImport(t,n))return{external:!0,id:resolveFrameworkRuntimeImport(t)};if(t.startsWith(`#`)){let r=resolvePackageImport(t,n,e.packageRoot);if(r!==void 0)return{id:r}}if(await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:n,kind:r.kind,packageRoot:e.packageRoot,source:t})!==void 0)return{external:!0,id:t}}}}}function createRuntimeLoaderPackageBoundaryPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-runtime-loader-package-boundary`,async resolveId(n,r,i){if(!isPackageImport(n))return;if(isFrameworkRuntimeImport(n,r))return{external:!0,id:resolveRuntimeLoaderFrameworkImport(n)};if(n.startsWith(`#`)){let t=resolvePackageImport(n,r,e.packageRoot);if(t!==void 0)return{id:t}}let a=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:r,kind:i.kind,packageRoot:e.packageRoot,source:n});if(a!==void 0){let e=resolveExistingExternalFilePath(a.resolvedId)??a.resolvedId;return{external:!0,id:normalizeEsmImportSpecifier(e)}}let o=r===void 0||r.startsWith(`\0`)?void 0:resolve(r);if(o!==void 0&&isPathInsideOrEqual(toCanonicalPath(o),t)){let e=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`)throw Error(`Cannot resolve package "${n}" imported from "${o}". Install it with your package manager (e.g. \`pnpm install\`); a running \`eve dev\` retries on the next rebuild.`);if(isNodeModulesPath(e.id))return{external:!0,id:n}}}}}function createDistributionPackageBoundaryPlugin(e){let t=new Set(e.runtimeDependencies);return{name:`eve-extension-distribution-package-boundary`,async resolveId(n,r,i){if(!isPackageImport(n))return;if(n.startsWith(`#`)){let a=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(a!==null&&typeof a.id==`string`&&!isPathInsideOrEqual(toCanonicalPath(a.id),toCanonicalPath(e.packageRoot))){let e=nearestPackageName(a.id);if(e!==void 0&&!t.has(e))throw Error(`Package import "${n}" resolves to undeclared package "${e}". Add "${e}" to dependencies, optionalDependencies, or peerDependencies.`)}return}if(isBuiltin(n))return{external:!0,id:n};let a=packageImportName(n);if(!t.has(a))throw Error(`Package "${n}" is not declared by the extension. Add "${a}" to dependencies, optionalDependencies, or peerDependencies.`);let o=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(o===null&&(o=await this.resolve(n,join(e.packageRoot,`package.json`),{kind:i.kind,skipSelf:!0})),o===null||typeof o.id!=`string`)throw Error(`Cannot resolve declared package "${n}". Install the extension's dependencies before building.`);return{external:!0,id:n}}}}async function resolveConfiguredExternalModule(e){let t=resolveConfiguredExternalDependency(e.source,e.externalDependencies);if(t===void 0)return;let n=await this.resolve(e.source,e.importer,{kind:e.kind,skipSelf:!0});if(n===null&&(n=await this.resolve(e.source,join(e.packageRoot,`package.json`),{kind:e.kind,skipSelf:!0})),n===null||typeof n.id!=`string`)throw Error(`Cannot resolve external package "${e.source}".`);return{packageName:t,resolvedId:n.id}}function normalizeExternalDependencies(e=[]){return[...new Set(e)].sort()}function resolveConfiguredExternalDependency(e,t){return t.find(t=>e===t||e.startsWith(`${t}/`))}function packageImportName(e){return e.startsWith(`@`)?e.split(`/`,2).join(`/`):e.split(`/`,1)[0]}function nearestPackageName(e){let t=nearestPackageRoot(e);if(t!==void 0)try{let e=JSON.parse(readFileSync(join(t,`package.json`),`utf8`));return typeof e.name==`string`&&e.name.length>0?e.name:void 0}catch{return}}function nearestPackageRoot(e){let t=dirname(toCanonicalPath(e));for(;;){if(existsSync(join(t,`package.json`)))return t;let e=dirname(t);if(e===t)return;t=e}}function resolvePackageImport(e,t,n){let r=t===void 0||t.startsWith(`\0`)?n:nearestPackageRoot(t)??n;try{let t=createRequire(join(r,`package.json`)).resolve(e);return isPathInsideOrEqual(toCanonicalPath(t),toCanonicalPath(r))?t:void 0}catch{return}}function resolveExistingExternalFilePath(e){if(existsSync(e))return e;for(let t of RESOLVE_EXTENSIONS){let n=`${e}${t}`;if(existsSync(n))return n}}function isPackageImport(e){return isPathImport(e)||/^(?:node|data|file):/.test(e)?!1:!e.startsWith(`@/`)}function isPathImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function isFrameworkRuntimeImport(e,t){return e===`eve/self-modification`?!1:e===`eve`||e.startsWith(`eve/`)?!0:e===`workflow`||e.startsWith(`workflow/`)||e.startsWith(`@workflow/`)?t===void 0||!isNodeModulesPath(t):!1}function resolveFrameworkRuntimeImport(e){return e===`eve`||e.startsWith(`eve/`)?e:normalizeEsmImportSpecifier(resolveWorkflowModulePath(e))}function resolveRuntimeLoaderFrameworkImport(e){return e===`eve`||e.startsWith(`eve/`)?normalizeEsmImportSpecifier(resolvePackageDependencyPath(e)):resolveFrameworkRuntimeImport(e)}function isNodeModulesPath(e){return e.replaceAll(`\\`,`/`).includes(`/node_modules/`)}function toCanonicalPath(e){try{return realpathSync(e)}catch{return resolve(e)}}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies};
@@ -1 +1 @@
1
- import{dirname,isAbsolute,join,resolve}from"node:path";import{realpathSync,statSync}from"node:fs";import{isNodeModulesPath,isPathImport}from"#internal/authored-package-boundary.js";const PATH_IMPORT_FILTER=/^(?:\.|\/|[A-Za-z]:[\\/])/;function createAuthoredRelativeExtensionResolverPlugin(e){let t=createCachedFileProbe();return{name:`eve-authored-relative-extension-resolver`,resolveId:{filter:{id:PATH_IMPORT_FILTER},handler(n,r){if(r===void 0||r.startsWith(`\0`)||!isPathImport(n))return;let i=resolveExistingImportPath(isAbsolute(n)?n:resolve(dirname(r),n),e.extensions,t);if(i!==void 0)return{id:isNodeModulesPath(i)?toRealModulePath(i):i}}}}}function createCachedFileProbe(){let e=new Map;return t=>{let n=e.get(t);if(n!==void 0)return n;let r=!1;try{r=statSync(t).isFile()}catch{}return e.set(t,r),r}}function resolveExistingImportPath(e,t,n){if(n(e))return e;for(let r of t){let t=`${e}${r}`;if(n(t))return t}for(let r of t){let t=join(e,`index${r}`);if(n(t))return t}}function toRealModulePath(e){try{return realpathSync(e)}catch{return e}}export{createAuthoredRelativeExtensionResolverPlugin};
1
+ import{realpathSync,statSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{isNodeModulesPath,isPathImport}from"#internal/authored-package-boundary.js";const PATH_IMPORT_FILTER=/^(?:\.|\/|[A-Za-z]:[\\/])/;function createAuthoredRelativeExtensionResolverPlugin(e){let t=createCachedFileProbe();return{name:`eve-authored-relative-extension-resolver`,resolveId:{filter:{id:PATH_IMPORT_FILTER},handler(n,r){if(r===void 0||r.startsWith(`\0`)||!isPathImport(n))return;let i=resolveExistingImportPath(isAbsolute(n)?n:resolve(dirname(r),n),e.extensions,t);if(i!==void 0)return{id:isNodeModulesPath(i)?toRealModulePath(i):i}}}}}function createCachedFileProbe(){let e=new Map;return t=>{let n=e.get(t);if(n!==void 0)return n;let r=!1;try{r=statSync(t).isFile()}catch{}return e.set(t,r),r}}function resolveExistingImportPath(e,t,n){if(n(e))return e;for(let r of t){let t=`${e}${r}`;if(n(t))return t}for(let r of t){let t=join(e,`index${r}`);if(n(t))return t}}function toRealModulePath(e){try{return realpathSync(e)}catch{return e}}export{createAuthoredRelativeExtensionResolverPlugin};
@@ -1,3 +1,3 @@
1
- import{resolve,sep}from"node:path";import{realpathSync}from"node:fs";const VIRTUAL_PREFIX=`\0eve-ext-scope:`,SCOPED_FRAMEWORK_MODULES={"eve/context":`context`,"eve/extension":`extension`};function canonicalize(e){try{return realpathSync(e)}catch{return resolve(e)}}function importerPath(e){let t=e.indexOf(`?`);return canonicalize(t===-1?e:e.slice(0,t))}function isUnder(e,t){return e===t||e.startsWith(`${t}${sep}`)}function shimSource(e,t){let n=JSON.stringify(t);return e===`context`?[`import { defineState as __eveScopedDefineState } from "eve/context";`,`export function defineState(name, initial) {`,` return __eveScopedDefineState(${n} + "." + name, initial);`,`}`,``].join(`
1
+ import{realpathSync}from"node:fs";import{resolve,sep}from"node:path";const VIRTUAL_PREFIX=`\0eve-ext-scope:`,SCOPED_FRAMEWORK_MODULES={"eve/context":`context`,"eve/extension":`extension`};function canonicalize(e){try{return realpathSync(e)}catch{return resolve(e)}}function importerPath(e){let t=e.indexOf(`?`);return canonicalize(t===-1?e:e.slice(0,t))}function isUnder(e,t){return e===t||e.startsWith(`${t}${sep}`)}function shimSource(e,t){let n=JSON.stringify(t);return e===`context`?[`import { defineState as __eveScopedDefineState } from "eve/context";`,`export function defineState(name, initial) {`,` return __eveScopedDefineState(${n} + "." + name, initial);`,`}`,``].join(`
2
2
  `):[`import { defineExtension as __eveScopedDefineExtension } from "eve/extension";`,`export function defineExtension(options, namespace) {`,` return __eveScopedDefineExtension(options, namespace === undefined ? ${n} : namespace);`,`}`,``].join(`
3
3
  `)}function scopeHooks(e,t){return{name:e,resolveId(e,n){let r=SCOPED_FRAMEWORK_MODULES[e];if(r===void 0||n===void 0||n.startsWith(`\0`))return;let i=t(n);if(i!==void 0)return`${VIRTUAL_PREFIX}${r}:${i}`},load(e){if(!e.startsWith(VIRTUAL_PREFIX))return;let t=e.slice(15),n=t.indexOf(`:`);return{code:shimSource(t.slice(0,n),t.slice(n+1)),moduleType:`js`}}}}function createExtensionScopePlugin(e){if(e.length===0)return null;let t=e.map(e=>({root:canonicalize(e.sourceRoot),packageNamespace:e.packageNamespace}));return scopeHooks(`eve-extension-scope`,e=>{let n=importerPath(e);for(let e of t)if(isUnder(n,e.root))return e.packageNamespace})}function createFixedNamespaceScopePlugin(e){return scopeHooks(`eve-extension-scope-fixed`,()=>e)}export{createExtensionScopePlugin,createFixedNamespaceScopePlugin};
@@ -28,7 +28,9 @@ export declare function parseWithNitroRolldownAst(filename: string, sourceText:
28
28
  /**
29
29
  * Runs a raw Rolldown build. Prefer {@link buildSingleRolldownChunk} for any
30
30
  * bundle whose consumer expects one in-memory file; use this directly only
31
- * for multi-file, written-to-disk output.
31
+ * for multi-file, written-to-disk output. Warnings raised only by dependency
32
+ * code are dropped unless the caller supplies its own `onLog`, except
33
+ * unresolved imports.
32
34
  */
33
35
  export declare function buildWithNitroRolldown(options: Record<string, unknown>): Promise<RolldownOutput>;
34
36
  export declare const ROLLDOWN_STANDARD_CONDITION_NAMES: ReadonlySet<string>;
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{pathToFileURL}from"node:url";let rolldownPromise,rolldownParseAstPromise;function loadNitroRolldown(){return rolldownPromise??=(async()=>{let e=createRequire(import.meta.url),t=createRequire(e.resolve(`nitro/package.json`)).resolve(`rolldown`);return await import(pathToFileURL(t).href)})(),rolldownPromise}function loadNitroRolldownParseAst(){return rolldownParseAstPromise??=(async()=>{let e=createRequire(import.meta.url),t=createRequire(e.resolve(`nitro/package.json`)).resolve(`rolldown/parseAst`);return await import(pathToFileURL(t).href)})(),rolldownParseAstPromise}function inferRolldownParserLanguage(e){return e.endsWith(`.tsx`)?`tsx`:e.endsWith(`.jsx`)?`jsx`:/\.[cm]?ts$/.test(e)?`ts`:`js`}async function parseWithNitroRolldownAst(e,t){let{parseAst:n}=await loadNitroRolldownParseAst();return n(t,{astType:`ts`,lang:inferRolldownParserLanguage(e),range:!0,sourceType:`module`},e)}async function buildWithNitroRolldown(e){assertCustomRolldownConditionNames(e);let{build:t}=await loadNitroRolldown();return await t(e)}const ROLLDOWN_STANDARD_CONDITION_NAMES=new Set([`browser`,`default`,`import`,`node`,`require`]);function assertCustomRolldownConditionNames(e){let t=e.resolve;if(typeof t!=`object`||!t)return;let n=Reflect.get(t,`conditionNames`);if(Array.isArray(n)){for(let e of n)if(typeof e==`string`&&ROLLDOWN_STANDARD_CONDITION_NAMES.has(e))throw Error(`Rolldown resolves the standard condition ${JSON.stringify(e)} per import edge; conditionNames may contain only eve-specific additions.`)}}async function buildSingleRolldownChunk(e,t){return getSingleRolldownChunk(await buildWithNitroRolldown({...t,write:!1,output:{...t.output,codeSplitting:!1}}),e)}function getSingleRolldownChunk(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}export{ROLLDOWN_STANDARD_CONDITION_NAMES,buildSingleRolldownChunk,buildWithNitroRolldown,inferRolldownParserLanguage,loadNitroRolldownParseAst,parseWithNitroRolldownAst};
1
+ import{createRequire}from"node:module";import{pathToFileURL}from"node:url";import{onVendoredDependencyLog}from"#internal/bundler/vendored-dependency-log.js";let rolldownPromise,rolldownParseAstPromise;function loadNitroRolldown(){return rolldownPromise??=(async()=>{let e=createRequire(import.meta.url),t=createRequire(e.resolve(`nitro/package.json`)).resolve(`rolldown`);return await import(pathToFileURL(t).href)})(),rolldownPromise}function loadNitroRolldownParseAst(){return rolldownParseAstPromise??=(async()=>{let e=createRequire(import.meta.url),t=createRequire(e.resolve(`nitro/package.json`)).resolve(`rolldown/parseAst`);return await import(pathToFileURL(t).href)})(),rolldownParseAstPromise}function inferRolldownParserLanguage(e){return e.endsWith(`.tsx`)?`tsx`:e.endsWith(`.jsx`)?`jsx`:/\.[cm]?ts$/.test(e)?`ts`:`js`}async function parseWithNitroRolldownAst(e,t){let{parseAst:n}=await loadNitroRolldownParseAst();return n(t,{astType:`ts`,lang:inferRolldownParserLanguage(e),range:!0,sourceType:`module`},e)}async function buildWithNitroRolldown(e){assertCustomRolldownConditionNames(e);let{build:t}=await loadNitroRolldown();return await t({onLog:onRolldownBuildLog,...e})}function onRolldownBuildLog(e,t,n){if(e===`warn`&&t?.code===`UNRESOLVED_IMPORT`){n(e,t);return}onVendoredDependencyLog(e,t,n)}const ROLLDOWN_STANDARD_CONDITION_NAMES=new Set([`browser`,`default`,`import`,`node`,`require`]);function assertCustomRolldownConditionNames(e){let t=e.resolve;if(typeof t!=`object`||!t)return;let n=Reflect.get(t,`conditionNames`);if(Array.isArray(n)){for(let e of n)if(typeof e==`string`&&ROLLDOWN_STANDARD_CONDITION_NAMES.has(e))throw Error(`Rolldown resolves the standard condition ${JSON.stringify(e)} per import edge; conditionNames may contain only eve-specific additions.`)}}async function buildSingleRolldownChunk(e,t){return getSingleRolldownChunk(await buildWithNitroRolldown({...t,write:!1,output:{...t.output,codeSplitting:!1}}),e)}function getSingleRolldownChunk(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}export{ROLLDOWN_STANDARD_CONDITION_NAMES,buildSingleRolldownChunk,buildWithNitroRolldown,inferRolldownParserLanguage,loadNitroRolldownParseAst,parseWithNitroRolldownAst};
@@ -0,0 +1,7 @@
1
+ export type BundlerDefaultLogHandler = (level: string, log: unknown) => void;
2
+ /**
3
+ * Rollup/Rolldown `onLog` handler that drops warnings raised only by
4
+ * dependency code (`node_modules` or eve's compiled vendor modules), which the
5
+ * user cannot act on, and forwards everything else.
6
+ */
7
+ export declare function onVendoredDependencyLog(level: string, log: unknown, defaultHandler: BundlerDefaultLogHandler): void;
@@ -0,0 +1 @@
1
+ function normalizePath(e){return e.replaceAll(`\\`,`/`)}function isNodeModulesPath(e){return normalizePath(e).split(`/`).includes(`node_modules`)}function hasPathSegments(e,t){let n=normalizePath(e).split(`/`).filter(Boolean);return n.some((e,r)=>t.every((e,t)=>n[r+t]===e))}function isCompiledVendorPath(e){return hasPathSegments(e,[`.generated`,`compiled`])||hasPathSegments(e,[`dist`,`src`,`compiled`])}function getLogFilePaths(e){if(typeof e!=`object`||!e)return[];let t=e,n=Array.isArray(t.ids)?t.ids:[];return[t.id,...n,t.loc?.file].filter(e=>typeof e==`string`)}function isVendoredDependencyWarning(e){let t=getLogFilePaths(e);return t.length>0&&t.every(e=>isNodeModulesPath(e)||isCompiledVendorPath(e))}function onVendoredDependencyLog(e,t,n){e===`warn`&&isVendoredDependencyWarning(t)||n(e,t)}export{onVendoredDependencyLog};
@@ -18,3 +18,5 @@ export declare const vercelGatewayFetch: typeof globalThis.fetch;
18
18
  */
19
19
  export declare function resolveProviderHeaders(model: LanguageModel): Record<string, string> | undefined;
20
20
  export declare function isGatewayModel(model: LanguageModel): boolean;
21
+ /** Groups Gateway generations under the same identity used by eve's agent spans. */
22
+ export declare function mergeGatewaySessionId(model: LanguageModel, providerOptions: Readonly<Record<string, unknown>> | undefined, conversationId: string): Record<string, unknown> | undefined;
@@ -1 +1 @@
1
- import{appendPackageUserAgent,withPackageUserAgent}from"#internal/user-agent.js";const GATEWAY_BASE_URL=`https://ai-gateway.vercel.sh`,AI_GATEWAY_MODELS_URL=`${GATEWAY_BASE_URL}/v1/models`,AI_GATEWAY_MODELS_CATALOG_URL=`${GATEWAY_BASE_URL}/v1/models/catalog`,vercelGatewayFetch=withPackageUserAgent();function resolveProviderHeaders(e){if(isGatewayModel(e))return Object.fromEntries(appendPackageUserAgent(new Headers))}function isGatewayModel(e){return typeof e==`string`||e.provider?.split(`.`)[0]===`gateway`}export{AI_GATEWAY_MODELS_CATALOG_URL,AI_GATEWAY_MODELS_URL,isGatewayModel,resolveProviderHeaders,vercelGatewayFetch};
1
+ import{appendPackageUserAgent,withPackageUserAgent}from"#internal/user-agent.js";const GATEWAY_BASE_URL=`https://ai-gateway.vercel.sh`,AI_GATEWAY_MODELS_URL=`${GATEWAY_BASE_URL}/v1/models`,AI_GATEWAY_MODELS_CATALOG_URL=`${GATEWAY_BASE_URL}/v1/models/catalog`,vercelGatewayFetch=withPackageUserAgent();function resolveProviderHeaders(e){if(isGatewayModel(e))return Object.fromEntries(appendPackageUserAgent(new Headers))}function isGatewayModel(e){return typeof e==`string`||e.provider?.split(`.`)[0]===`gateway`}function mergeGatewaySessionId(e,t,n){if(!isGatewayModel(e))return t;let r=t?.gateway,i=typeof r==`object`&&r&&!Array.isArray(r)?r:void 0;return typeof i?.sessionId==`string`&&i.sessionId.trim()?t:{...t,gateway:{...i,sessionId:n}}}export{AI_GATEWAY_MODELS_CATALOG_URL,AI_GATEWAY_MODELS_URL,isGatewayModel,mergeGatewaySessionId,resolveProviderHeaders,vercelGatewayFetch};
@@ -1 +1 @@
1
- import{join}from"node:path";import{existsSync,readdirSync,statSync}from"node:fs";import{isAuthoredTestPath}from"#discover/filesystem.js";const INSTRUMENTATION_EXTENSIONS=[`.ts`,`.mts`,`.js`,`.mjs`],INSTRUMENTATION_DIRECTORY=`instrumentation`;function resolveInstrumentationLayout(e){let t=findRemovedInstrumentationFile(e.agentRoot),n=join(e.agentRoot,INSTRUMENTATION_DIRECTORY),r=existsSync(n)&&statSync(n).isDirectory();if(t!==void 0)throw Error(`Found removed instrumentation file "${t}". Move it into the "${INSTRUMENTATION_DIRECTORY}/" directory as one file per provider. See the instrumentation migration guide.`);return r?{kind:`directory`,modulePathsBySlot:collectInstrumentationProviderModules(n)}:{kind:`directory`,modulePathsBySlot:{}}}function collectInstrumentationProviderModules(e){let t=new Map;for(let n of readdirSync(e,{withFileTypes:!0})){if(!n.isFile()||isAuthoredTestPath(n.name))continue;let r=INSTRUMENTATION_EXTENSIONS.find(e=>n.name.endsWith(e));if(r===void 0)continue;let i=n.name.slice(0,-r.length);if(i!==``){if(t.get(i)!==void 0)throw Error(`Two files declare the "${i}" instrumentation provider in "${e}". Keep one of them.`);t.set(i,join(e,n.name))}}return Object.fromEntries([...t].sort(([e],[t])=>e.localeCompare(t)))}function findRemovedInstrumentationFile(e){for(let t of INSTRUMENTATION_EXTENSIONS){let n=join(e,`${INSTRUMENTATION_DIRECTORY}${t}`);if(existsSync(n))return n}}export{resolveInstrumentationLayout};
1
+ import{existsSync,readdirSync,statSync}from"node:fs";import{join}from"node:path";import{isAuthoredTestPath}from"#discover/filesystem.js";const INSTRUMENTATION_EXTENSIONS=[`.ts`,`.mts`,`.js`,`.mjs`],INSTRUMENTATION_DIRECTORY=`instrumentation`;function resolveInstrumentationLayout(e){let t=findRemovedInstrumentationFile(e.agentRoot),n=join(e.agentRoot,INSTRUMENTATION_DIRECTORY),r=existsSync(n)&&statSync(n).isDirectory();if(t!==void 0)throw Error(`Found removed instrumentation file "${t}". Move it into the "${INSTRUMENTATION_DIRECTORY}/" directory as one file per provider. See the instrumentation migration guide.`);return r?{kind:`directory`,modulePathsBySlot:collectInstrumentationProviderModules(n)}:{kind:`directory`,modulePathsBySlot:{}}}function collectInstrumentationProviderModules(e){let t=new Map;for(let n of readdirSync(e,{withFileTypes:!0})){if(!n.isFile()||isAuthoredTestPath(n.name))continue;let r=INSTRUMENTATION_EXTENSIONS.find(e=>n.name.endsWith(e));if(r===void 0)continue;let i=n.name.slice(0,-r.length);if(i!==``){if(t.get(i)!==void 0)throw Error(`Two files declare the "${i}" instrumentation provider in "${e}". Keep one of them.`);t.set(i,join(e,n.name))}}return Object.fromEntries([...t].sort(([e],[t])=>e.localeCompare(t)))}function findRemovedInstrumentationFile(e){for(let t of INSTRUMENTATION_EXTENSIONS){let n=join(e,`${INSTRUMENTATION_DIRECTORY}${t}`);if(existsSync(n))return n}}export{resolveInstrumentationLayout};
@@ -1 +1 @@
1
- import{createHash}from"node:crypto";import{lstat,mkdir,readFile,readdir,readlink,writeFile}from"node:fs/promises";import{join,relative,sep}from"node:path";import{existsSync}from"node:fs";import{COMPILED_AGENT_MANIFEST_KIND,ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{serializeCompiledManifestForFingerprint}from"#internal/compiled-manifest-fingerprint.js";const MATERIALIZED_MODULES_DIRECTORY=`authored-modules`,MATERIALIZED_MODULES_INDEX=`authored-modules.json`;async function writeMaterializedAuthoredModules(e){let t=join(e.runtimeAppRoot,`.eve`,`compile`),n=await readCompiledManifest(join(t,`compiled-agent-manifest.json`)),r=join(t,MATERIALIZED_MODULES_DIRECTORY),i=createHash(`sha256`);await mkdir(r,{recursive:!0}),i.update(`manifest\0`).update(serializeCompiledManifestForFingerprint({manifest:n,runtimeAppRoot:e.runtimeAppRoot})).update(`\0`);let a=createMaterializedModuleFileName(ROOT_COMPILED_AGENT_NODE_ID,`module-map`,e.prepared.moduleMapCode),o=join(MATERIALIZED_MODULES_DIRECTORY,a);await writeFile(join(r,a),e.prepared.moduleMapCode),i.update(`module-map\0`).update(e.prepared.moduleMapCode).update(`\0`);let materializeInstrumentationModule=async(e,t)=>{let n=createMaterializedModuleFileName(ROOT_COMPILED_AGENT_NODE_ID,`instrumentation:${e}`,t);return await writeFile(join(r,n),t),i.update(`instrumentation:${e}\0`).update(t).update(`\0`),join(MATERIALIZED_MODULES_DIRECTORY,n)},s={};for(let[t,n]of Object.entries(e.prepared.instrumentation.moduleCodeBySlot))s[t]=await materializeInstrumentationModule(t,n);let c={kind:`directory`,modulePathsBySlot:s};await hashDirectoryIfPresent({fingerprint:i,path:join(t,`workspace-resources`),root:join(t,`workspace-resources`)});let l={fingerprint:i.digest(`hex`),moduleMap:o,version:3};return l.instrumentation=c,await writeFile(join(t,MATERIALIZED_MODULES_INDEX),`${JSON.stringify(l)}\n`),l}async function readMaterializedAuthoredModuleIndex(e){let t=join(e,`.eve`,`compile`,MATERIALIZED_MODULES_INDEX);if(!existsSync(t))return;let n=JSON.parse(await readFile(t,`utf8`));if(n.version!==3||typeof n.fingerprint!=`string`||n.fingerprint.length===0||typeof n.moduleMap!=`string`||n.moduleMap.length===0||!isMaterializedInstrumentation(n.instrumentation))throw Error(`Invalid materialized authored module index at "${t}".`);return n}function isMaterializedInstrumentation(e){if(e===void 0)return!0;if(typeof e!=`object`||!e)return!1;let t=e;if(t.kind===`directory`){let e=t.modulePathsBySlot;return typeof e==`object`&&!!e&&Object.values(e).every(e=>typeof e==`string`)}return!1}async function readCompiledManifest(e){let t=JSON.parse(await readFile(e,`utf8`));if(t.kind!==COMPILED_AGENT_MANIFEST_KIND)throw Error(`Invalid compiled agent manifest at "${e}".`);return t}function createMaterializedModuleFileName(e,t,n){return`${createHash(`sha256`).update(e).update(`\0`).update(t).update(`\0`).update(n).digest(`hex`)}.mjs`}async function hashDirectoryIfPresent(e){if(!existsSync(e.path))return;let t=await lstat(e.path),n=toPortablePath(relative(e.root,e.path));if(t.isSymbolicLink()){e.fingerprint.update(n).update(`\0link\0`).update(await readlink(e.path)).update(`\0`);return}if(t.isDirectory()){for(let t of(await readdir(e.path)).sort())await hashDirectoryIfPresent({...e,path:join(e.path,t)});return}t.isFile()&&e.fingerprint.update(n).update(`\0file\0`).update(await readFile(e.path)).update(`\0`)}function toPortablePath(e){return e.split(sep).join(`/`)}export{readMaterializedAuthoredModuleIndex,writeMaterializedAuthoredModules};
1
+ import{createHash}from"node:crypto";import{lstat,mkdir,readFile,readdir,readlink,writeFile}from"node:fs/promises";import{existsSync}from"node:fs";import{join,relative,sep}from"node:path";import{COMPILED_AGENT_MANIFEST_KIND,ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{serializeCompiledManifestForFingerprint}from"#internal/compiled-manifest-fingerprint.js";const MATERIALIZED_MODULES_DIRECTORY=`authored-modules`,MATERIALIZED_MODULES_INDEX=`authored-modules.json`;async function writeMaterializedAuthoredModules(e){let t=join(e.runtimeAppRoot,`.eve`,`compile`),n=await readCompiledManifest(join(t,`compiled-agent-manifest.json`)),r=join(t,MATERIALIZED_MODULES_DIRECTORY),i=createHash(`sha256`);await mkdir(r,{recursive:!0}),i.update(`manifest\0`).update(serializeCompiledManifestForFingerprint({manifest:n,runtimeAppRoot:e.runtimeAppRoot})).update(`\0`);let a=createMaterializedModuleFileName(ROOT_COMPILED_AGENT_NODE_ID,`module-map`,e.prepared.moduleMapCode),o=join(MATERIALIZED_MODULES_DIRECTORY,a);await writeFile(join(r,a),e.prepared.moduleMapCode),i.update(`module-map\0`).update(e.prepared.moduleMapCode).update(`\0`);let materializeInstrumentationModule=async(e,t)=>{let n=createMaterializedModuleFileName(ROOT_COMPILED_AGENT_NODE_ID,`instrumentation:${e}`,t);return await writeFile(join(r,n),t),i.update(`instrumentation:${e}\0`).update(t).update(`\0`),join(MATERIALIZED_MODULES_DIRECTORY,n)},s={};for(let[t,n]of Object.entries(e.prepared.instrumentation.moduleCodeBySlot))s[t]=await materializeInstrumentationModule(t,n);let c={kind:`directory`,modulePathsBySlot:s};await hashDirectoryIfPresent({fingerprint:i,path:join(t,`workspace-resources`),root:join(t,`workspace-resources`)});let l={fingerprint:i.digest(`hex`),moduleMap:o,version:3};return l.instrumentation=c,await writeFile(join(t,MATERIALIZED_MODULES_INDEX),`${JSON.stringify(l)}\n`),l}async function readMaterializedAuthoredModuleIndex(e){let t=join(e,`.eve`,`compile`,MATERIALIZED_MODULES_INDEX);if(!existsSync(t))return;let n=JSON.parse(await readFile(t,`utf8`));if(n.version!==3||typeof n.fingerprint!=`string`||n.fingerprint.length===0||typeof n.moduleMap!=`string`||n.moduleMap.length===0||!isMaterializedInstrumentation(n.instrumentation))throw Error(`Invalid materialized authored module index at "${t}".`);return n}function isMaterializedInstrumentation(e){if(e===void 0)return!0;if(typeof e!=`object`||!e)return!1;let t=e;if(t.kind===`directory`){let e=t.modulePathsBySlot;return typeof e==`object`&&!!e&&Object.values(e).every(e=>typeof e==`string`)}return!1}async function readCompiledManifest(e){let t=JSON.parse(await readFile(e,`utf8`));if(t.kind!==COMPILED_AGENT_MANIFEST_KIND)throw Error(`Invalid compiled agent manifest at "${e}".`);return t}function createMaterializedModuleFileName(e,t,n){return`${createHash(`sha256`).update(e).update(`\0`).update(t).update(`\0`).update(n).digest(`hex`)}.mjs`}async function hashDirectoryIfPresent(e){if(!existsSync(e.path))return;let t=await lstat(e.path),n=toPortablePath(relative(e.root,e.path));if(t.isSymbolicLink()){e.fingerprint.update(n).update(`\0link\0`).update(await readlink(e.path)).update(`\0`);return}if(t.isDirectory()){for(let t of(await readdir(e.path)).sort())await hashDirectoryIfPresent({...e,path:join(e.path,t)});return}t.isFile()&&e.fingerprint.update(n).update(`\0file\0`).update(await readFile(e.path)).update(`\0`)}function toPortablePath(e){return e.split(sep).join(`/`)}export{readMaterializedAuthoredModuleIndex,writeMaterializedAuthoredModules};
@@ -1 +1 @@
1
- import{readFile,readdir,rm,stat,writeFile}from"node:fs/promises";import{join,resolve}from"node:path";import{existsSync}from"node:fs";const DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER=`activated`,DEVELOPMENT_RUNTIME_ARTIFACTS_RETIRED_METADATA=`retired.json`;async function recordRetiredDevelopmentRuntimeArtifactsSnapshot(e,t=Date.now()){await writeFile(join(e,DEVELOPMENT_RUNTIME_ARTIFACTS_RETIRED_METADATA),`${JSON.stringify({retiredAt:t})}\n`)}async function pruneDevelopmentRuntimeArtifactsSnapshotDirectory(e){if(e.protectAll)return;let t=e.now??Date.now(),n=Math.max(0,e.gracePeriodMs??18e5),r=Math.max(0,Math.trunc(e.retainCount??5)),i;try{i=await readdir(e.snapshotsDirectory,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let a=e.activeSnapshotRoot===void 0?void 0:resolve(e.activeSnapshotRoot),o=await Promise.all(i.filter(e=>e.isDirectory()).map(async n=>{let r=join(e.snapshotsDirectory,n.name),i=a===resolve(r),o=existsSync(join(r,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER)),s;if(o&&!i)try{s=await readRetiredAt(r),s===void 0&&(await recordRetiredDevelopmentRuntimeArtifactsSnapshot(r,t),s=t)}catch(e){console.warn(`[eve:dev] failed to read or initialize runtime generation retirement metadata for "${r}": ${String(e)}`)}return{activated:o,active:i,path:r,retiredAt:s,mtimeMs:(await stat(r)).mtimeMs}})),s=new Set(o.flatMap(e=>e.retiredAt===void 0?[]:[{path:e.path,retiredAt:e.retiredAt}]).sort((e,t)=>t.retiredAt-e.retiredAt).slice(0,r).map(e=>e.path)),c=new Set(o.filter(e=>!e.activated).sort((e,t)=>t.mtimeMs-e.mtimeMs).slice(0,r).map(e=>e.path));await Promise.all(o.map(async e=>{e.active||e.activated&&e.retiredAt===void 0||s.has(e.path)||c.has(e.path)||e.retiredAt!==void 0&&t-e.retiredAt<=n||!e.activated&&t-e.mtimeMs<=n||await rm(e.path,{force:!0,recursive:!0})}))}async function readRetiredAt(e){let t;try{t=await readFile(join(e,DEVELOPMENT_RUNTIME_ARTIFACTS_RETIRED_METADATA),`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let n;try{n=JSON.parse(t)}catch{return}if(typeof n==`object`&&n&&!Array.isArray(n)&&`retiredAt`in n&&typeof n.retiredAt==`number`&&Number.isFinite(n.retiredAt)&&n.retiredAt>=0)return n.retiredAt}export{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot};
1
+ import{readFile,readdir,rm,stat,writeFile}from"node:fs/promises";import{existsSync}from"node:fs";import{join,resolve}from"node:path";const DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER=`activated`,DEVELOPMENT_RUNTIME_ARTIFACTS_RETIRED_METADATA=`retired.json`;async function recordRetiredDevelopmentRuntimeArtifactsSnapshot(e,t=Date.now()){await writeFile(join(e,DEVELOPMENT_RUNTIME_ARTIFACTS_RETIRED_METADATA),`${JSON.stringify({retiredAt:t})}\n`)}async function pruneDevelopmentRuntimeArtifactsSnapshotDirectory(e){if(e.protectAll)return;let t=e.now??Date.now(),n=Math.max(0,e.gracePeriodMs??18e5),r=Math.max(0,Math.trunc(e.retainCount??5)),i;try{i=await readdir(e.snapshotsDirectory,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let a=e.activeSnapshotRoot===void 0?void 0:resolve(e.activeSnapshotRoot),o=await Promise.all(i.filter(e=>e.isDirectory()).map(async n=>{let r=join(e.snapshotsDirectory,n.name),i=a===resolve(r),o=existsSync(join(r,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER)),s;if(o&&!i)try{s=await readRetiredAt(r),s===void 0&&(await recordRetiredDevelopmentRuntimeArtifactsSnapshot(r,t),s=t)}catch(e){console.warn(`[eve:dev] failed to read or initialize runtime generation retirement metadata for "${r}": ${String(e)}`)}return{activated:o,active:i,path:r,retiredAt:s,mtimeMs:(await stat(r)).mtimeMs}})),s=new Set(o.flatMap(e=>e.retiredAt===void 0?[]:[{path:e.path,retiredAt:e.retiredAt}]).sort((e,t)=>t.retiredAt-e.retiredAt).slice(0,r).map(e=>e.path)),c=new Set(o.filter(e=>!e.activated).sort((e,t)=>t.mtimeMs-e.mtimeMs).slice(0,r).map(e=>e.path));await Promise.all(o.map(async e=>{e.active||e.activated&&e.retiredAt===void 0||s.has(e.path)||c.has(e.path)||e.retiredAt!==void 0&&t-e.retiredAt<=n||!e.activated&&t-e.mtimeMs<=n||await rm(e.path,{force:!0,recursive:!0})}))}async function readRetiredAt(e){let t;try{t=await readFile(join(e,DEVELOPMENT_RUNTIME_ARTIFACTS_RETIRED_METADATA),`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let n;try{n=JSON.parse(t)}catch{return}if(typeof n==`object`&&n&&!Array.isArray(n)&&`retiredAt`in n&&typeof n.retiredAt==`number`&&Number.isFinite(n.retiredAt)&&n.retiredAt>=0)return n.retiredAt}export{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot};
@@ -1 +1 @@
1
- import{randomUUID}from"node:crypto";import{cp,mkdir,readFile,rm,symlink,writeFile}from"node:fs/promises";import{dirname,join,relative,resolve,sep}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{existsSync,readFileSync}from"node:fs";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createDevelopmentSourceSnapshotPlan,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts-retention.js";const DEV_RUNTIME_ARTIFACTS_DIRECTORY=`dev-runtime`;function resolveDevelopmentRuntimeArtifactsPointerPath(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`current.json`)}function resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`snapshots`)}function isDevelopmentRuntimeArtifactsSnapshotRoot(e,t){return dirname(resolve(t))===resolve(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e))}async function stageDevelopmentRuntimeArtifactsSnapshot(e){let t=join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.project.appRoot),`${Date.now().toString(36)}-${randomUUID()}`),n=await createDevelopmentSourceSnapshotPlan({appRoot:e.project.appRoot,authoredSourceRoots:collectExtensionMountSourceRoots(e.manifest),snapshotRoot:t});try{await copyDevelopmentSourceSnapshot(n),await mountFrameworkPackage(n.runtimeAppRoot),await mountExtensionExternalDependencies({manifest:e.manifest,runtimeAppRoot:n.runtimeAppRoot}),await cp(e.paths.compileDirectoryPath,join(n.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,extensionPackageRoots:(e.manifest?.subagents??[]).flatMap(e=>e.owner.kind===`extension`?[{sourceRoot:e.agent.appRoot,packageName:e.owner.packageName}]:[]),manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),snapshotSourceRoot:n.snapshotSourceRoot}),await writeFile(join(t,`generation.json`),`${JSON.stringify({runtimeAppRoot:n.runtimeAppRoot})}\n`)}catch(e){throw await rm(t,{force:!0,recursive:!0}).catch(()=>{}),e}return{sourceWatchPaths:n.watchPaths,runtimeAppRoot:n.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}}async function mountFrameworkPackage(e){let t=join(e,`node_modules`,`eve`);await mkdir(dirname(t),{recursive:!0}),await rm(t,{force:!0,recursive:!0}),await symlink(resolvePackageRoot(),t,`junction`)}async function mountExtensionExternalDependencies(e){if(e.manifest===void 0)return;let t=[e.manifest,...(e.manifest.subagents??[]).map(e=>e.agent)].flatMap(e=>e.extensionMounts??[]).filter(e=>(e.externalDependencies??[]).length>0);for(let[n,r]of Object.entries(resolveExtensionExternalDependencyPaths(t))){let t=findPackageRoot(r,n),i=join(e.runtimeAppRoot,`node_modules`,...n.split(`/`));await mkdir(dirname(i),{recursive:!0}),await rm(i,{force:!0,recursive:!0}),await symlink(t,i,`junction`)}}function findPackageRoot(e,t){let n=dirname(e);for(;;){let e=join(n,`package.json`);if(existsSync(e))try{if(JSON.parse(readFileSync(e,`utf8`)).name===t)return n}catch{}let r=dirname(n);if(r===n)throw Error(`Cannot locate package root for extension external dependency "${t}".`);n=r}}async function activateDevelopmentRuntimeArtifactsSnapshot(e){(await activateDevelopmentRuntimeArtifactsSnapshotTransaction(e)).commit()}async function activateDevelopmentRuntimeArtifactsSnapshotTransaction(e){let t=await readMaterializedAuthoredModuleIndex(e.snapshot.runtimeAppRoot);if(t===void 0||!existsSync(join(e.snapshot.runtimeAppRoot,`.eve`,`compile`,t.moduleMap)))throw Error(`Cannot activate development runtime generation "${e.snapshot.snapshotRoot}" before its authored modules are materialized.`);let n=join(e.snapshot.snapshotRoot,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),r=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),i=readDevelopmentRuntimeArtifactsPointer(r),a=await readOptionalFile(r);try{await writeFile(n,``),await writeDevelopmentRuntimeArtifactsPointer(e),i?.version===2&&i.snapshotRoot!==e.snapshot.snapshotRoot&&isDevelopmentRuntimeArtifactsSnapshotRoot(e.appRoot,i.snapshotRoot)&&await recordRetiredDevelopmentRuntimeArtifactsSnapshot(i.snapshotRoot).catch(e=>{console.warn(`[eve:dev] failed to record retired runtime generation "${i.snapshotRoot}": ${String(e)}`)})}catch(e){throw await rollbackFailedActivation({cause:e,markerPath:n,pointerPath:r,previousPointerSource:a})}let o=!1;return{commit(){o=!0},async rollback(){if(o)return;o=!0;let e=await restoreDevelopmentRuntimeArtifactsActivation({markerPath:n,pointerPath:r,previousPointerSource:a});if(e!==void 0)throw e}}}function readDevelopmentRuntimeArtifactsSnapshotRoot(e){let t=readDevelopmentRuntimeArtifactsPointer(e);if(t!==void 0)return t.version===1?t.appRoot:t.runtimeAppRoot}function readActiveDevelopmentRuntimeArtifactsSnapshot(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e));if(t!==void 0&&t.version!==1)return{runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot}}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function pruneDevelopmentRuntimeArtifactsSnapshots(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot));await pruneDevelopmentRuntimeArtifactsSnapshotDirectory({activeSnapshotRoot:t?.version===2?t.snapshotRoot:void 0,gracePeriodMs:e.gracePeriodMs,now:e.now,protectAll:t?.version===1,retainCount:e.retainCount,snapshotsDirectory:resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.appRoot)})}function collectExtensionMountSourceRoots(e){return e===void 0?[]:[e,...(e.subagents??[]).map(e=>e.agent)].flatMap(e=>(e.extensionMounts??[]).map(e=>e.sourceRoot))}function readDevelopmentRuntimeArtifactsPointer(e){if(e!==void 0&&existsSync(e))try{let t=JSON.parse(readFileSync(e,`utf8`));return t.kind!==`eve-dev-runtime-artifacts-pointer`||typeof t.version!=`number`?void 0:t.version===1&&typeof t.appRoot==`string`&&t.appRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:t.version===2&&typeof t.appRoot==`string`&&typeof t.runtimeAppRoot==`string`&&t.runtimeAppRoot.length>0&&typeof t.snapshotRoot==`string`&&t.snapshotRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot,version:2}:void 0}catch{return}}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:t});await writeFile(e.manifestPath,`${JSON.stringify(n,null,2)}\n`)}function rewriteManifestRoots(e){if(Array.isArray(e.value))return e.value.map(t=>rewriteManifestRoots({...e,value:t}));if(e.value===null||typeof e.value!=`object`)return e.value;let t={};for(let[n,r]of Object.entries(e.value)){if(typeof r==`string`&&(n===`appRoot`||n===`agentRoot`)){t[n]=isPathInsideOrEqual(r,e.appRoot)||e.extensionPackageRoots.some(e=>isPathInsideOrEqual(r,e.sourceRoot))?rewritePathWithinAppRoot({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,path:r,runtimeAppRoot:e.runtimeAppRoot}):rewritePathWithinSourceRoot({path:r,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot});continue}if(typeof r==`string`&&n===`sourceRoot`){t[n]=rewritePathWithinSourceRoot({path:r,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot});continue}t[n]=rewriteManifestRoots({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:r})}return t}function rewritePathWithinSourceRoot(e){return isPathInsideOrEqual(e.path,e.sourceRoot)?toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:e.path,sourceRoot:e.sourceRoot}):e.path}function rewritePathWithinAppRoot(e){if(!isPathInsideOrEqual(e.path,e.appRoot)){let t=e.extensionPackageRoots.find(t=>isPathInsideOrEqual(e.path,t.sourceRoot));return t===void 0?e.path:join(e.runtimeAppRoot,`node_modules`,t.packageName,relative(t.sourceRoot,e.path))}let t=relative(e.appRoot,e.path);return t.length===0?e.runtimeAppRoot:join(e.runtimeAppRoot,t)}async function writeDevelopmentRuntimeArtifactsPointer(e){let t=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),n={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await writeDevelopmentRuntimeArtifactsPointerSource(t,`${JSON.stringify(n,null,2)}\n`)}async function writeDevelopmentRuntimeArtifactsPointerSource(e,t){let n=`${e}.${randomUUID()}.tmp`;await mkdir(dirname(e),{recursive:!0}),await writeFile(n,t);try{await renameWithTransientBusyRetry(n,e)}catch(e){throw await rm(n,{force:!0}).catch(()=>{}),e}}async function readOptionalFile(e){try{return await readFile(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}}async function rollbackFailedActivation(e){let t=await restoreDevelopmentRuntimeArtifactsActivation(e);return t===void 0?e.cause:AggregateError([e.cause,t],`Development runtime activation and rollback failed.`,{cause:e.cause})}async function restoreDevelopmentRuntimeArtifactsActivation(e){let t=(await Promise.allSettled([e.previousPointerSource===void 0?rm(e.pointerPath,{force:!0}):writeDevelopmentRuntimeArtifactsPointerSource(e.pointerPath,e.previousPointerSource),rm(e.markerPath,{force:!0})])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length!==0)return AggregateError(t,`Failed to restore development runtime activation.`)}async function validateSnapshotCompiledManifestRoots(e){let t=collectManifestRootPaths(JSON.parse(await readFile(e.manifestPath,`utf8`)));for(let n of t)if(!isPathInsideOrEqual(n,e.snapshotSourceRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime snapshot source root "${e.snapshotSourceRoot}".`)}function collectManifestRootPaths(e){if(Array.isArray(e))return e.flatMap(e=>collectManifestRootPaths(e));if(typeof e!=`object`||!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if((n===`appRoot`||n===`agentRoot`)&&typeof r==`string`){t.push(r);continue}t.push(...collectManifestRootPaths(r))}return t}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{activateDevelopmentRuntimeArtifactsSnapshot,activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,readActiveDevelopmentRuntimeArtifactsSnapshot,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
1
+ import{randomUUID}from"node:crypto";import{cp,mkdir,readFile,rm,symlink,writeFile}from"node:fs/promises";import{resolvePackageRoot}from"#internal/application/package.js";import{existsSync,readFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createDevelopmentSourceSnapshotPlan,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts-retention.js";const DEV_RUNTIME_ARTIFACTS_DIRECTORY=`dev-runtime`;function resolveDevelopmentRuntimeArtifactsPointerPath(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`current.json`)}function resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`snapshots`)}function isDevelopmentRuntimeArtifactsSnapshotRoot(e,t){return dirname(resolve(t))===resolve(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e))}async function stageDevelopmentRuntimeArtifactsSnapshot(e){let t=join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.project.appRoot),`${Date.now().toString(36)}-${randomUUID()}`),n=await createDevelopmentSourceSnapshotPlan({appRoot:e.project.appRoot,authoredSourceRoots:collectExtensionMountSourceRoots(e.manifest),snapshotRoot:t});try{await copyDevelopmentSourceSnapshot(n),await mountFrameworkPackage(n.runtimeAppRoot),await mountExtensionExternalDependencies({manifest:e.manifest,runtimeAppRoot:n.runtimeAppRoot}),await cp(e.paths.compileDirectoryPath,join(n.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,extensionPackageRoots:(e.manifest?.subagents??[]).flatMap(e=>e.owner.kind===`extension`?[{sourceRoot:e.agent.appRoot,packageName:e.owner.packageName}]:[]),manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),snapshotSourceRoot:n.snapshotSourceRoot}),await writeFile(join(t,`generation.json`),`${JSON.stringify({runtimeAppRoot:n.runtimeAppRoot})}\n`)}catch(e){throw await rm(t,{force:!0,recursive:!0}).catch(()=>{}),e}return{sourceWatchPaths:n.watchPaths,runtimeAppRoot:n.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}}async function mountFrameworkPackage(e){let t=join(e,`node_modules`,`eve`);await mkdir(dirname(t),{recursive:!0}),await rm(t,{force:!0,recursive:!0}),await symlink(resolvePackageRoot(),t,`junction`)}async function mountExtensionExternalDependencies(e){if(e.manifest===void 0)return;let t=[e.manifest,...(e.manifest.subagents??[]).map(e=>e.agent)].flatMap(e=>e.extensionMounts??[]).filter(e=>(e.externalDependencies??[]).length>0);for(let[n,r]of Object.entries(resolveExtensionExternalDependencyPaths(t))){let t=findPackageRoot(r,n),i=join(e.runtimeAppRoot,`node_modules`,...n.split(`/`));await mkdir(dirname(i),{recursive:!0}),await rm(i,{force:!0,recursive:!0}),await symlink(t,i,`junction`)}}function findPackageRoot(e,t){let n=dirname(e);for(;;){let e=join(n,`package.json`);if(existsSync(e))try{if(JSON.parse(readFileSync(e,`utf8`)).name===t)return n}catch{}let r=dirname(n);if(r===n)throw Error(`Cannot locate package root for extension external dependency "${t}".`);n=r}}async function activateDevelopmentRuntimeArtifactsSnapshot(e){(await activateDevelopmentRuntimeArtifactsSnapshotTransaction(e)).commit()}async function activateDevelopmentRuntimeArtifactsSnapshotTransaction(e){let t=await readMaterializedAuthoredModuleIndex(e.snapshot.runtimeAppRoot);if(t===void 0||!existsSync(join(e.snapshot.runtimeAppRoot,`.eve`,`compile`,t.moduleMap)))throw Error(`Cannot activate development runtime generation "${e.snapshot.snapshotRoot}" before its authored modules are materialized.`);let n=join(e.snapshot.snapshotRoot,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),r=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),i=readDevelopmentRuntimeArtifactsPointer(r),a=await readOptionalFile(r);try{await writeFile(n,``),await writeDevelopmentRuntimeArtifactsPointer(e),i?.version===2&&i.snapshotRoot!==e.snapshot.snapshotRoot&&isDevelopmentRuntimeArtifactsSnapshotRoot(e.appRoot,i.snapshotRoot)&&await recordRetiredDevelopmentRuntimeArtifactsSnapshot(i.snapshotRoot).catch(e=>{console.warn(`[eve:dev] failed to record retired runtime generation "${i.snapshotRoot}": ${String(e)}`)})}catch(e){throw await rollbackFailedActivation({cause:e,markerPath:n,pointerPath:r,previousPointerSource:a})}let o=!1;return{commit(){o=!0},async rollback(){if(o)return;o=!0;let e=await restoreDevelopmentRuntimeArtifactsActivation({markerPath:n,pointerPath:r,previousPointerSource:a});if(e!==void 0)throw e}}}function readDevelopmentRuntimeArtifactsSnapshotRoot(e){let t=readDevelopmentRuntimeArtifactsPointer(e);if(t!==void 0)return t.version===1?t.appRoot:t.runtimeAppRoot}function readActiveDevelopmentRuntimeArtifactsSnapshot(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e));if(t!==void 0&&t.version!==1)return{runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot}}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function pruneDevelopmentRuntimeArtifactsSnapshots(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot));await pruneDevelopmentRuntimeArtifactsSnapshotDirectory({activeSnapshotRoot:t?.version===2?t.snapshotRoot:void 0,gracePeriodMs:e.gracePeriodMs,now:e.now,protectAll:t?.version===1,retainCount:e.retainCount,snapshotsDirectory:resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.appRoot)})}function collectExtensionMountSourceRoots(e){return e===void 0?[]:[e,...(e.subagents??[]).map(e=>e.agent)].flatMap(e=>(e.extensionMounts??[]).map(e=>e.sourceRoot))}function readDevelopmentRuntimeArtifactsPointer(e){if(e!==void 0&&existsSync(e))try{let t=JSON.parse(readFileSync(e,`utf8`));return t.kind!==`eve-dev-runtime-artifacts-pointer`||typeof t.version!=`number`?void 0:t.version===1&&typeof t.appRoot==`string`&&t.appRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:t.version===2&&typeof t.appRoot==`string`&&typeof t.runtimeAppRoot==`string`&&t.runtimeAppRoot.length>0&&typeof t.snapshotRoot==`string`&&t.snapshotRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot,version:2}:void 0}catch{return}}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:t});await writeFile(e.manifestPath,`${JSON.stringify(n,null,2)}\n`)}function rewriteManifestRoots(e){if(Array.isArray(e.value))return e.value.map(t=>rewriteManifestRoots({...e,value:t}));if(e.value===null||typeof e.value!=`object`)return e.value;let t={};for(let[n,r]of Object.entries(e.value)){if(typeof r==`string`&&(n===`appRoot`||n===`agentRoot`)){t[n]=isPathInsideOrEqual(r,e.appRoot)||e.extensionPackageRoots.some(e=>isPathInsideOrEqual(r,e.sourceRoot))?rewritePathWithinAppRoot({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,path:r,runtimeAppRoot:e.runtimeAppRoot}):rewritePathWithinSourceRoot({path:r,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot});continue}if(typeof r==`string`&&n===`sourceRoot`){t[n]=rewritePathWithinSourceRoot({path:r,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot});continue}t[n]=rewriteManifestRoots({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:r})}return t}function rewritePathWithinSourceRoot(e){return isPathInsideOrEqual(e.path,e.sourceRoot)?toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:e.path,sourceRoot:e.sourceRoot}):e.path}function rewritePathWithinAppRoot(e){if(!isPathInsideOrEqual(e.path,e.appRoot)){let t=e.extensionPackageRoots.find(t=>isPathInsideOrEqual(e.path,t.sourceRoot));return t===void 0?e.path:join(e.runtimeAppRoot,`node_modules`,t.packageName,relative(t.sourceRoot,e.path))}let t=relative(e.appRoot,e.path);return t.length===0?e.runtimeAppRoot:join(e.runtimeAppRoot,t)}async function writeDevelopmentRuntimeArtifactsPointer(e){let t=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),n={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await writeDevelopmentRuntimeArtifactsPointerSource(t,`${JSON.stringify(n,null,2)}\n`)}async function writeDevelopmentRuntimeArtifactsPointerSource(e,t){let n=`${e}.${randomUUID()}.tmp`;await mkdir(dirname(e),{recursive:!0}),await writeFile(n,t);try{await renameWithTransientBusyRetry(n,e)}catch(e){throw await rm(n,{force:!0}).catch(()=>{}),e}}async function readOptionalFile(e){try{return await readFile(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}}async function rollbackFailedActivation(e){let t=await restoreDevelopmentRuntimeArtifactsActivation(e);return t===void 0?e.cause:AggregateError([e.cause,t],`Development runtime activation and rollback failed.`,{cause:e.cause})}async function restoreDevelopmentRuntimeArtifactsActivation(e){let t=(await Promise.allSettled([e.previousPointerSource===void 0?rm(e.pointerPath,{force:!0}):writeDevelopmentRuntimeArtifactsPointerSource(e.pointerPath,e.previousPointerSource),rm(e.markerPath,{force:!0})])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length!==0)return AggregateError(t,`Failed to restore development runtime activation.`)}async function validateSnapshotCompiledManifestRoots(e){let t=collectManifestRootPaths(JSON.parse(await readFile(e.manifestPath,`utf8`)));for(let n of t)if(!isPathInsideOrEqual(n,e.snapshotSourceRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime snapshot source root "${e.snapshotSourceRoot}".`)}function collectManifestRootPaths(e){if(Array.isArray(e))return e.flatMap(e=>collectManifestRootPaths(e));if(typeof e!=`object`||!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if((n===`appRoot`||n===`agentRoot`)&&typeof r==`string`){t.push(r);continue}t.push(...collectManifestRootPaths(r))}return t}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{activateDevelopmentRuntimeArtifactsSnapshot,activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,readActiveDevelopmentRuntimeArtifactsSnapshot,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
@@ -1 +1 @@
1
- import{cp,mkdir,symlink,writeFile}from"node:fs/promises";import{dirname,join}from"node:path";import{constants,existsSync}from"node:fs";import{DevelopmentRuntimeSourceSnapshotError,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";const SNAPSHOT_COPY_MODE=constants.COPYFILE_FICLONE;async function copyDevelopmentSourceSnapshot(e){await mkdir(e.snapshotSourceRoot,{recursive:!0});for(let t of e.copyFiles){if(!existsSync(t))continue;let n=toSnapshotPathForPlan(e,t);try{await mkdir(dirname(n),{recursive:!0}),await cp(t,n,{mode:SNAPSHOT_COPY_MODE,recursive:!0})}catch(e){throw new DevelopmentRuntimeSourceSnapshotError(`Failed to copy development runtime source snapshot path "${t}" to "${n}": ${formatErrorMessage(e)}`)}}await createSnapshotDependencyMounts(e),await ensureRuntimePackageJson(e)}async function createSnapshotDependencyMounts(e){for(let t of e.dependencyMounts){let n=toSnapshotPathForPlan(e,t.mountPath);await mkdir(dirname(n),{recursive:!0}),await symlink(t.sourcePath,n,`junction`)}}async function ensureRuntimePackageJson(e){let t=join(e.runtimeAppRoot,`package.json`);existsSync(t)||(await mkdir(e.runtimeAppRoot,{recursive:!0}),await writeFile(t,`${JSON.stringify({private:!0,type:`module`},null,2)}\n`))}function toSnapshotPathForPlan(e,t){return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}function formatErrorMessage(e){return e instanceof Error?e.message:String(e)}export{copyDevelopmentSourceSnapshot};
1
+ import{cp,mkdir,symlink,writeFile}from"node:fs/promises";import{constants,existsSync}from"node:fs";import{dirname,join}from"node:path";import{DevelopmentRuntimeSourceSnapshotError,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";const SNAPSHOT_COPY_MODE=constants.COPYFILE_FICLONE;async function copyDevelopmentSourceSnapshot(e){await mkdir(e.snapshotSourceRoot,{recursive:!0});for(let t of e.copyFiles){if(!existsSync(t))continue;let n=toSnapshotPathForPlan(e,t);try{await mkdir(dirname(n),{recursive:!0}),await cp(t,n,{mode:SNAPSHOT_COPY_MODE,recursive:!0})}catch(e){throw new DevelopmentRuntimeSourceSnapshotError(`Failed to copy development runtime source snapshot path "${t}" to "${n}": ${formatErrorMessage(e)}`)}}await createSnapshotDependencyMounts(e),await ensureRuntimePackageJson(e)}async function createSnapshotDependencyMounts(e){for(let t of e.dependencyMounts){let n=toSnapshotPathForPlan(e,t.mountPath);await mkdir(dirname(n),{recursive:!0}),await symlink(t.sourcePath,n,`junction`)}}async function ensureRuntimePackageJson(e){let t=join(e.runtimeAppRoot,`package.json`);existsSync(t)||(await mkdir(e.runtimeAppRoot,{recursive:!0}),await writeFile(t,`${JSON.stringify({private:!0,type:`module`},null,2)}\n`))}function toSnapshotPathForPlan(e,t){return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}function formatErrorMessage(e){return e instanceof Error?e.message:String(e)}export{copyDevelopmentSourceSnapshot};
@@ -1 +1 @@
1
- import{lstat}from"node:fs/promises";import{dirname,join,relative,resolve,sep}from"node:path";import{existsSync}from"node:fs";import{parseTsConfigObject,readTextFileIfExists}from"#internal/application/tsconfig-dependencies.js";async function resolveLocalTsConfigPathTargetRoots(e){let t=await readTextFileIfExists(e.configPath);if(t===void 0)return[];let n=parseTsConfigObject(t),r=isObjectRecord(n?.compilerOptions)?n.compilerOptions:void 0,i=isObjectRecord(r?.paths)?r.paths:void 0;if(r===void 0||i===void 0)return[];let a=typeof r.baseUrl==`string`?resolve(dirname(e.configPath),r.baseUrl):dirname(e.configPath),o=new Set;for(let t of Object.values(i))if(Array.isArray(t))for(let n of t){if(typeof n!=`string`||n.length===0)continue;let t=await resolveLocalTsConfigPathTargetRoot({baseDirectory:a,sourceRoot:e.sourceRoot,target:n});t!==void 0&&o.add(t)}return[...o].sort((e,t)=>e.localeCompare(t))}async function resolveNearestPackageRoot(e,t){let n=resolve(e);try{(await lstat(n)).isDirectory()||(n=dirname(n))}catch{n=dirname(n)}for(;isAuthoredSourcePath(n,t);){if(existsSync(join(n,`package.json`)))return n;let e=dirname(n);if(e===n)return;n=e}}function isAuthoredSourcePath(e,t){return isPathInsideOrEqual(e,t)?!relative(t,e).split(/[\\/]/).includes(`node_modules`):!1}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}async function resolveLocalTsConfigPathTargetRoot(e){let t=e.target.includes(`*`),n=t?e.target.slice(0,e.target.indexOf(`*`)):e.target;if(n.length===0||n===`.`||n===`./`)return;let r=resolve(e.baseDirectory,n);if(!isAuthoredSourcePath(r,e.sourceRoot))return;let i=await resolveExistingPathOrAncestor({path:r,stopDirectory:e.sourceRoot});if(i===void 0)return;let a=await resolveNearestPackageRoot(i,e.sourceRoot);if(a!==void 0&&a!==e.sourceRoot)return a;if(!t)return i===e.sourceRoot?void 0:i}async function resolveExistingPathOrAncestor(e){let t=resolve(e.path);for(;isAuthoredSourcePath(t,e.stopDirectory);){if(existsSync(t))return t;let e=dirname(t);if(e===t)return;t=e}}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{isAuthoredSourcePath,isPathInsideOrEqual,resolveLocalTsConfigPathTargetRoots,resolveNearestPackageRoot};
1
+ import{lstat}from"node:fs/promises";import{existsSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{parseTsConfigObject,readTextFileIfExists}from"#internal/application/tsconfig-dependencies.js";async function resolveLocalTsConfigPathTargetRoots(e){let t=await readTextFileIfExists(e.configPath);if(t===void 0)return[];let n=parseTsConfigObject(t),r=isObjectRecord(n?.compilerOptions)?n.compilerOptions:void 0,i=isObjectRecord(r?.paths)?r.paths:void 0;if(r===void 0||i===void 0)return[];let a=typeof r.baseUrl==`string`?resolve(dirname(e.configPath),r.baseUrl):dirname(e.configPath),o=new Set;for(let t of Object.values(i))if(Array.isArray(t))for(let n of t){if(typeof n!=`string`||n.length===0)continue;let t=await resolveLocalTsConfigPathTargetRoot({baseDirectory:a,sourceRoot:e.sourceRoot,target:n});t!==void 0&&o.add(t)}return[...o].sort((e,t)=>e.localeCompare(t))}async function resolveNearestPackageRoot(e,t){let n=resolve(e);try{(await lstat(n)).isDirectory()||(n=dirname(n))}catch{n=dirname(n)}for(;isAuthoredSourcePath(n,t);){if(existsSync(join(n,`package.json`)))return n;let e=dirname(n);if(e===n)return;n=e}}function isAuthoredSourcePath(e,t){return isPathInsideOrEqual(e,t)?!relative(t,e).split(/[\\/]/).includes(`node_modules`):!1}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}async function resolveLocalTsConfigPathTargetRoot(e){let t=e.target.includes(`*`),n=t?e.target.slice(0,e.target.indexOf(`*`)):e.target;if(n.length===0||n===`.`||n===`./`)return;let r=resolve(e.baseDirectory,n);if(!isAuthoredSourcePath(r,e.sourceRoot))return;let i=await resolveExistingPathOrAncestor({path:r,stopDirectory:e.sourceRoot});if(i===void 0)return;let a=await resolveNearestPackageRoot(i,e.sourceRoot);if(a!==void 0&&a!==e.sourceRoot)return a;if(!t)return i===e.sourceRoot?void 0:i}async function resolveExistingPathOrAncestor(e){let t=resolve(e.path);for(;isAuthoredSourcePath(t,e.stopDirectory);){if(existsSync(t))return t;let e=dirname(t);if(e===t)return;t=e}}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{isAuthoredSourcePath,isPathInsideOrEqual,resolveLocalTsConfigPathTargetRoots,resolveNearestPackageRoot};
@@ -1 +1 @@
1
- import{lstat,readlink,realpath}from"node:fs/promises";import{dirname,join,relative,resolve}from"node:path";import{existsSync,readFileSync}from"node:fs";import{readTextFileIfExists,resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{isAuthoredSourcePath,isAuthoredSourcePath as isAuthoredSourcePath$1,isPathInsideOrEqual,resolveLocalTsConfigPathTargetRoots,resolveNearestPackageRoot}from"#internal/nitro/dev-runtime-source-snapshot-local-roots.js";const DEV_RUNTIME_SOURCE_DIRECTORY=`source`,SOURCE_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WORKSPACE_METADATA_FILE_NAMES=[`package.json`,`pnpm-workspace.yaml`,`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`,`.npmrc`],PACKAGE_DEPENDENCY_FIELDS=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`];var DevelopmentRuntimeSourceSnapshotError=class extends Error{constructor(e){super(e),this.name=`DevelopmentRuntimeSourceSnapshotError`}};async function createDevelopmentSourceSnapshotPlan(e){let t=resolve(e.appRoot),n=resolve(e.snapshotRoot),r=resolveDevelopmentSourceRoot(t),i=join(n,DEV_RUNTIME_SOURCE_DIRECTORY),a={appRoot:t,copyFiles:new Set,dependencyMountsByPath:new Map,localRootsToProcess:[t],processedLocalRoots:new Set,snapshotRoot:n,snapshotSourceRoot:i,sourceRoot:r,tsconfigPaths:new Set},o=join(t,`package.json`);for(existsSync(o)&&a.copyFiles.add(o),await addAuthoredSourceRoots(a,e.authoredSourceRoots??[]);a.localRootsToProcess.length>0;){let e=a.localRootsToProcess.shift();if(e===void 0)continue;let t=resolve(e);!a.processedLocalRoots.has(t)&&isAuthoredSourcePath$1(t,r)&&(a.processedLocalRoots.add(t),await addTsConfigDependenciesForRoot(a,t),await addDependencyMountsForRoot(a,t))}let s=[...a.copyFiles].filter(e=>isPathInsideOrEqual(e,r)).sort((e,t)=>e.localeCompare(t)),c=[...a.tsconfigPaths].filter(e=>isPathInsideOrEqual(e,r)).sort((e,t)=>e.localeCompare(t)),l=[...a.dependencyMountsByPath.values()].sort((e,t)=>e.mountPath.localeCompare(t.mountPath)),u=createWatchPaths({appRoot:t,copyFiles:s,dependencyMounts:l,localRoots:[...a.processedLocalRoots],sourceRoot:r,tsconfigPaths:c});return{appRoot:t,copyFiles:s,dependencyMounts:l,runtimeAppRoot:toSnapshotPath({sourcePath:t,sourceRoot:r,snapshotSourceRoot:i}),snapshotRoot:n,snapshotSourceRoot:i,sourceRoot:r,tsconfigPaths:c,watchPaths:u}}async function resolveDevelopmentSourceSnapshotWatchPaths(e){return[...(await createDevelopmentSourceSnapshotPlan({appRoot:e,snapshotRoot:join(resolve(e),`.eve`,`dev-runtime`,`__watch-plan__`)})).watchPaths]}function toDevelopmentSourceSnapshotPath(e){return toSnapshotPath(e)}function resolveDevelopmentSourceRoot(e){let t=resolve(e);for(;;){if(SOURCE_ROOT_MARKER_NAMES.some(e=>existsSync(join(t,e)))||isWorkspaceManifestRoot(t))return t;let n=dirname(t);if(n===t)return resolve(e);t=n}}async function addAuthoredSourceRoots(e,t){for(let n of t){let t=resolve(n);isAuthoredSourcePath$1(t,e.sourceRoot)&&enqueueLocalRoot(e,await resolveNearestPackageRoot(t,e.sourceRoot)??t)}}async function addTsConfigDependenciesForRoot(e,t){let n=await resolveTsConfigDependencyPaths(t);for(let t of n)if(isPathInsideOrEqual(t,e.sourceRoot)){e.tsconfigPaths.add(t);for(let n of await resolveLocalTsConfigPathTargetRoots({configPath:t,sourceRoot:e.sourceRoot}))enqueueLocalRoot(e,n)}}async function addDependencyMountsForRoot(e,t){let n=await readPackageDependencyNames(resolveDependencyDeclarationRoot(t,e.sourceRoot));for(let r of n)for(let n of listAncestorNodeModulesRoots(t,e.sourceRoot))await addDependencyMount(e,joinNodeModulesPackagePath(n,r))}function resolveDependencyDeclarationRoot(e,t){let n=resolve(e),r=resolve(t);for(;isPathInsideOrEqual(n,r);){if(existsSync(join(n,`package.json`)))return n;let e=dirname(n);if(e===n)break;n=e}return e}function listAncestorNodeModulesRoots(e,t){let n=resolve(t),r=new Set,i=resolve(e);for(;isPathInsideOrEqual(i,n);){r.add(i);let e=dirname(i);if(e===i)break;i=e}return r.add(resolve(e)),r.add(n),[...r]}function isWorkspaceManifestRoot(e){let t=join(e,`package.json`);if(!existsSync(t))return!1;try{let e=JSON.parse(readFileSync(t,`utf8`));return isObjectRecord(e)&&e.workspaces!==void 0}catch{return!1}}async function addDependencyMount(e,t){let n;try{n=await lstat(t)}catch{return}if(!n.isDirectory()&&!n.isSymbolicLink())return;let r=await resolveDependencySourcePathCandidates(t),i=r.find(t=>isAuthoredSourcePath$1(t,e.sourceRoot));if(i!==void 0){await addWorkspaceDependencyMount({mountPath:t,state:e,sourcePath:i});return}let a=r.find(e=>existsSync(e));a!==void 0&&e.dependencyMountsByPath.set(resolve(t),{mountPath:resolve(t),sourceKind:`installed`,sourcePath:a})}async function addWorkspaceDependencyMount(e){let t=await resolveNearestPackageRoot(e.sourcePath,e.state.sourceRoot);if(t===void 0||!isAuthoredSourcePath$1(t,e.state.sourceRoot))return;let{state:n}=e;enqueueLocalRoot(n,t),n.dependencyMountsByPath.set(resolve(e.mountPath),{mountPath:resolve(e.mountPath),sourceKind:`workspace`,sourcePath:t})}async function resolveDependencySourcePathCandidates(e){let t=new Set;try{let n=await readlink(e);t.add(resolve(dirname(e),n))}catch{}try{t.add(await realpath(e))}catch{}return[...t]}function enqueueLocalRoot(e,t){let n=resolve(t);e.processedLocalRoots.has(n)||e.localRootsToProcess.includes(n)||!isAuthoredSourcePath$1(n,e.sourceRoot)||e.localRootsToProcess.push(n)}async function readPackageDependencyNames(e){let t=join(e,`package.json`),n=await readTextFileIfExists(t);if(n===void 0)return[];let r;try{r=JSON.parse(n)}catch{return[]}if(!isObjectRecord(r))return[];let i=new Set;for(let e of PACKAGE_DEPENDENCY_FIELDS){let t=r[e];if(isObjectRecord(t))for(let e of Object.keys(t))i.add(e)}return[...i].sort((e,t)=>e.localeCompare(t))}function createWatchPaths(e){let t=new Set([join(e.appRoot,`package.json`),...e.copyFiles,...e.tsconfigPaths]);for(let n of e.localRoots)n!==e.appRoot&&t.add(n);for(let n of e.dependencyMounts)n.sourceKind===`workspace`&&n.sourcePath!==e.appRoot&&t.add(n.sourcePath);if(e.sourceRoot!==e.appRoot)for(let n of WORKSPACE_METADATA_FILE_NAMES){let r=join(e.sourceRoot,n);existsSync(r)&&t.add(r)}return[...t].sort((e,t)=>e.localeCompare(t))}function joinNodeModulesPackagePath(e,t){return join(e,`node_modules`,...t.split(`/`))}function toSnapshotPath(e){if(!isPathInsideOrEqual(e.sourcePath,e.sourceRoot))throw new DevelopmentRuntimeSourceSnapshotError(`Cannot map source path "${e.sourcePath}" into a development runtime snapshot because it is outside source root "${e.sourceRoot}".`);return join(e.snapshotSourceRoot,relative(e.sourceRoot,e.sourcePath))}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{DEV_RUNTIME_SOURCE_DIRECTORY,DevelopmentRuntimeSourceSnapshotError,createDevelopmentSourceSnapshotPlan,isAuthoredSourcePath,resolveDevelopmentSourceRoot,resolveDevelopmentSourceSnapshotWatchPaths,toDevelopmentSourceSnapshotPath};
1
+ import{lstat,readlink,realpath}from"node:fs/promises";import{existsSync,readFileSync}from"node:fs";import{dirname,join,relative,resolve}from"node:path";import{readTextFileIfExists,resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{isAuthoredSourcePath,isAuthoredSourcePath as isAuthoredSourcePath$1,isPathInsideOrEqual,resolveLocalTsConfigPathTargetRoots,resolveNearestPackageRoot}from"#internal/nitro/dev-runtime-source-snapshot-local-roots.js";const DEV_RUNTIME_SOURCE_DIRECTORY=`source`,SOURCE_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WORKSPACE_METADATA_FILE_NAMES=[`package.json`,`pnpm-workspace.yaml`,`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`,`.npmrc`],PACKAGE_DEPENDENCY_FIELDS=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`];var DevelopmentRuntimeSourceSnapshotError=class extends Error{constructor(e){super(e),this.name=`DevelopmentRuntimeSourceSnapshotError`}};async function createDevelopmentSourceSnapshotPlan(e){let t=resolve(e.appRoot),n=resolve(e.snapshotRoot),r=resolveDevelopmentSourceRoot(t),i=join(n,DEV_RUNTIME_SOURCE_DIRECTORY),a={appRoot:t,copyFiles:new Set,dependencyMountsByPath:new Map,localRootsToProcess:[t],processedLocalRoots:new Set,snapshotRoot:n,snapshotSourceRoot:i,sourceRoot:r,tsconfigPaths:new Set},o=join(t,`package.json`);for(existsSync(o)&&a.copyFiles.add(o),await addAuthoredSourceRoots(a,e.authoredSourceRoots??[]);a.localRootsToProcess.length>0;){let e=a.localRootsToProcess.shift();if(e===void 0)continue;let t=resolve(e);!a.processedLocalRoots.has(t)&&isAuthoredSourcePath$1(t,r)&&(a.processedLocalRoots.add(t),await addTsConfigDependenciesForRoot(a,t),await addDependencyMountsForRoot(a,t))}let s=[...a.copyFiles].filter(e=>isPathInsideOrEqual(e,r)).sort((e,t)=>e.localeCompare(t)),c=[...a.tsconfigPaths].filter(e=>isPathInsideOrEqual(e,r)).sort((e,t)=>e.localeCompare(t)),l=[...a.dependencyMountsByPath.values()].sort((e,t)=>e.mountPath.localeCompare(t.mountPath)),u=createWatchPaths({appRoot:t,copyFiles:s,dependencyMounts:l,localRoots:[...a.processedLocalRoots],sourceRoot:r,tsconfigPaths:c});return{appRoot:t,copyFiles:s,dependencyMounts:l,runtimeAppRoot:toSnapshotPath({sourcePath:t,sourceRoot:r,snapshotSourceRoot:i}),snapshotRoot:n,snapshotSourceRoot:i,sourceRoot:r,tsconfigPaths:c,watchPaths:u}}async function resolveDevelopmentSourceSnapshotWatchPaths(e){return[...(await createDevelopmentSourceSnapshotPlan({appRoot:e,snapshotRoot:join(resolve(e),`.eve`,`dev-runtime`,`__watch-plan__`)})).watchPaths]}function toDevelopmentSourceSnapshotPath(e){return toSnapshotPath(e)}function resolveDevelopmentSourceRoot(e){let t=resolve(e);for(;;){if(SOURCE_ROOT_MARKER_NAMES.some(e=>existsSync(join(t,e)))||isWorkspaceManifestRoot(t))return t;let n=dirname(t);if(n===t)return resolve(e);t=n}}async function addAuthoredSourceRoots(e,t){for(let n of t){let t=resolve(n);isAuthoredSourcePath$1(t,e.sourceRoot)&&enqueueLocalRoot(e,await resolveNearestPackageRoot(t,e.sourceRoot)??t)}}async function addTsConfigDependenciesForRoot(e,t){let n=await resolveTsConfigDependencyPaths(t);for(let t of n)if(isPathInsideOrEqual(t,e.sourceRoot)){e.tsconfigPaths.add(t);for(let n of await resolveLocalTsConfigPathTargetRoots({configPath:t,sourceRoot:e.sourceRoot}))enqueueLocalRoot(e,n)}}async function addDependencyMountsForRoot(e,t){let n=await readPackageDependencyNames(resolveDependencyDeclarationRoot(t,e.sourceRoot));for(let r of n)for(let n of listAncestorNodeModulesRoots(t,e.sourceRoot))await addDependencyMount(e,joinNodeModulesPackagePath(n,r))}function resolveDependencyDeclarationRoot(e,t){let n=resolve(e),r=resolve(t);for(;isPathInsideOrEqual(n,r);){if(existsSync(join(n,`package.json`)))return n;let e=dirname(n);if(e===n)break;n=e}return e}function listAncestorNodeModulesRoots(e,t){let n=resolve(t),r=new Set,i=resolve(e);for(;isPathInsideOrEqual(i,n);){r.add(i);let e=dirname(i);if(e===i)break;i=e}return r.add(resolve(e)),r.add(n),[...r]}function isWorkspaceManifestRoot(e){let t=join(e,`package.json`);if(!existsSync(t))return!1;try{let e=JSON.parse(readFileSync(t,`utf8`));return isObjectRecord(e)&&e.workspaces!==void 0}catch{return!1}}async function addDependencyMount(e,t){let n;try{n=await lstat(t)}catch{return}if(!n.isDirectory()&&!n.isSymbolicLink())return;let r=await resolveDependencySourcePathCandidates(t),i=r.find(t=>isAuthoredSourcePath$1(t,e.sourceRoot));if(i!==void 0){await addWorkspaceDependencyMount({mountPath:t,state:e,sourcePath:i});return}let a=r.find(e=>existsSync(e));a!==void 0&&e.dependencyMountsByPath.set(resolve(t),{mountPath:resolve(t),sourceKind:`installed`,sourcePath:a})}async function addWorkspaceDependencyMount(e){let t=await resolveNearestPackageRoot(e.sourcePath,e.state.sourceRoot);if(t===void 0||!isAuthoredSourcePath$1(t,e.state.sourceRoot))return;let{state:n}=e;enqueueLocalRoot(n,t),n.dependencyMountsByPath.set(resolve(e.mountPath),{mountPath:resolve(e.mountPath),sourceKind:`workspace`,sourcePath:t})}async function resolveDependencySourcePathCandidates(e){let t=new Set;try{let n=await readlink(e);t.add(resolve(dirname(e),n))}catch{}try{t.add(await realpath(e))}catch{}return[...t]}function enqueueLocalRoot(e,t){let n=resolve(t);e.processedLocalRoots.has(n)||e.localRootsToProcess.includes(n)||!isAuthoredSourcePath$1(n,e.sourceRoot)||e.localRootsToProcess.push(n)}async function readPackageDependencyNames(e){let t=join(e,`package.json`),n=await readTextFileIfExists(t);if(n===void 0)return[];let r;try{r=JSON.parse(n)}catch{return[]}if(!isObjectRecord(r))return[];let i=new Set;for(let e of PACKAGE_DEPENDENCY_FIELDS){let t=r[e];if(isObjectRecord(t))for(let e of Object.keys(t))i.add(e)}return[...i].sort((e,t)=>e.localeCompare(t))}function createWatchPaths(e){let t=new Set([join(e.appRoot,`package.json`),...e.copyFiles,...e.tsconfigPaths]);for(let n of e.localRoots)n!==e.appRoot&&t.add(n);for(let n of e.dependencyMounts)n.sourceKind===`workspace`&&n.sourcePath!==e.appRoot&&t.add(n.sourcePath);if(e.sourceRoot!==e.appRoot)for(let n of WORKSPACE_METADATA_FILE_NAMES){let r=join(e.sourceRoot,n);existsSync(r)&&t.add(r)}return[...t].sort((e,t)=>e.localeCompare(t))}function joinNodeModulesPackagePath(e,t){return join(e,`node_modules`,...t.split(`/`))}function toSnapshotPath(e){if(!isPathInsideOrEqual(e.sourcePath,e.sourceRoot))throw new DevelopmentRuntimeSourceSnapshotError(`Cannot map source path "${e.sourcePath}" into a development runtime snapshot because it is outside source root "${e.sourceRoot}".`);return join(e.snapshotSourceRoot,relative(e.sourceRoot,e.sourcePath))}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{DEV_RUNTIME_SOURCE_DIRECTORY,DevelopmentRuntimeSourceSnapshotError,createDevelopmentSourceSnapshotPlan,isAuthoredSourcePath,resolveDevelopmentSourceRoot,resolveDevelopmentSourceSnapshotWatchPaths,toDevelopmentSourceSnapshotPath};
@@ -1 +1 @@
1
- import{readFile}from"node:fs/promises";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isObject}from"#shared/guards.js";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import{resolveInstalledPackageInfo,resolvePackageSourceFilePath}from"#internal/application/package.js";import{normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{toErrorMessage}from"#shared/errors.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{ApplicationBuildProfiler,createApplicationBuildProfile,measureApplicationBuildOutput,writeApplicationBuildProfile}from"#internal/application/build-profile.js";import{RecoverablePublicationError,publishApplicationBuildArtifacts}from"#internal/application/output-publication.js";import{stageProductionCompilerArtifacts}from"#internal/application/production-compiler-artifacts.js";import{materializeVercelWorkflowFunctionOutput,normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{emitConnectManifest}from"#internal/external-resources.js";import{copyHostMiddlewareFunctions}from"#internal/nitro/host/copy-host-middleware.js";import{normalizeVercelServiceCrons}from"#internal/nitro/host/normalize-vercel-service-crons.js";import{prepareProductionApplicationHost,refreshProductionCompiledArtifacts}from"#internal/nitro/host/prepare-application-host.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";import{resolveEveServicePrefixByRoot}from"#internal/vercel/vercel-service-config-operations.js";import{parseVercelServicesConfig}from"#internal/vercel/vercel-services-config.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}async function measureBuildPhase(e,t,n){return e===void 0?n():e.measure(t,n)}function isPathInside(e,t){let n=relative(e,t);return n.length===0||!n.startsWith(`..${sep}`)&&n!==`..`&&!isAbsolute(n)}function assertProfileOutputOutsideBuildOutput(e,t){if(e!==void 0&&isPathInside(t,e))throw Error(`Build profile path ${e} must be outside the published output directory ${t}.`)}async function writeOptionalApplicationBuildProfile(e){try{assertProfileOutputOutsideBuildOutput(e.profileOutputPath,e.outputDirectory);let t=e.profiler.finish(),n=await measureApplicationBuildOutput(e.outputDirectory);await writeApplicationBuildProfile(e.profileOutputPath,createApplicationBuildProfile({output:n,target:process.env.VERCEL?`vercel`:`local`,timing:t}))}catch(t){console.warn(`eve: failed to write optional build profile to ${e.profileOutputPath}; continuing with the published build output: ${toErrorMessage(t)}`)}}async function resolveEveServicePrefixForVercelFunctionOutput(e,t){let n=Array.from(new Set([resolve(e),resolve(t)])),r=await findClosestVercelOutputDirectory(e);if(r!==void 0)try{let e=join(r,`config.json`),t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),i=resolveEveServicePrefixByRoot({appRoots:n,configRoot:await resolveVercelOutputConfigRoot(r),config:t});if(i!==void 0)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let i=e;for(;;){for(let e of[join(i,`vercel.json`),join(i,`.vercel`,`output`,`config.json`)])try{let t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),r=e.endsWith(`vercel.json`)?i:await resolveVercelOutputConfigRoot(dirname(e)),a=resolveEveServicePrefixByRoot({appRoots:n,configRoot:r,config:t});if(a!==void 0)return a}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let e=dirname(i);if(e===i)return;i=e}}async function resolveVercelOutputConfigRoot(e){let t=dirname(dirname(e));try{let e=JSON.parse(await readFile(join(t,`.vercel`,`project.json`),`utf8`));if(isObject(e)&&isObject(e.settings)){let n=e.settings.rootDirectory;if(typeof n==`string`&&n.trim().length>0)return resolve(t,n)}}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return t}async function buildNitroOutput(e,t,n){let r=trimTrailingSlash(e.options.output.dir);return await measureBuildPhase(t,`${n}.cache.prepare`,()=>prepareEveVersionedCacheDirectory(r)),await measureBuildPhase(t,`${n}.prepare`,()=>prepare(e)),await measureBuildPhase(t,`${n}.public-assets`,()=>copyPublicAssets(e)),await measureBuildPhase(t,`${n}.prerender`,()=>prerender(e)),await measureBuildPhase(t,`${n}.bundle`,()=>build(e)),await measureBuildPhase(t,`${n}.cache.write`,()=>writeEveVersionedCacheMetadata(r)),r}async function buildApplication(e,t){let n=t.profileOutputPath===void 0?void 0:resolve(t.profileOutputPath),r=n===void 0?void 0:new ApplicationBuildProfiler,i=await measureBuildPhase(r,`extension.check`,()=>tryReadExtensionBuildConfig(e));if(i!==null)throw Error(`Package "${i.packageName}" is an eve extension. Run \`eve extension build\` instead of \`eve build\`.`);let a=await measureBuildPhase(r,`project.resolve`,()=>resolveDiscoveryProject(e)),o=await measureBuildPhase(r,`workspace.create`,()=>createApplicationBuildWorkspace(a.appRoot,t.vercelServiceOutput?.serviceOutputDirectory)),s=!1,c;try{c=await buildApplicationInWorkspace(o,t,r)}catch(e){throw s=e instanceof RecoverablePublicationError,e}finally{s||await measureBuildPhase(r,`workspace.remove`,()=>removeApplicationBuildWorkspace(o))}return r!==void 0&&n!==void 0&&await writeOptionalApplicationBuildProfile({outputDirectory:c,profileOutputPath:n,profiler:r}),c}async function buildApplicationInWorkspace(e,t,n){let r=await measureBuildPhase(n,`host.prepare`,()=>prepareProductionApplicationHost(e)),i=!!process.env.VERCEL,a=i?await measureBuildPhase(n,`vercel.service-prefix.resolve`,()=>resolveEveServicePrefixForVercelFunctionOutput(r.appRoot,r.compileResult.project.agentRoot)):void 0,o=normalizePublicRoutePrefix(a),s=o===EVE_ROUTE_PREFIX?void 0:o;if(t.publicRoutePrefix!==void 0&&s!==void 0&&t.publicRoutePrefix!==s)throw Error(`EVE_PUBLIC_ROUTE_PREFIX ${JSON.stringify(t.publicRoutePrefix)} conflicts with the configured Vercel service prefix ${JSON.stringify(a)}.`);let c=t.publicRoutePrefix??s,l=createProductionNitroArtifactsConfig(e.appRoot).sandboxScope,u=await measureBuildPhase(n,`nitro.create`,()=>createProductionApplicationNitro(r,{buildDir:e.nitro.buildDir,outputDir:e.publication.output.stagedDir,publicRoutePrefix:c,workspaceMember:t.workspaceMember}));try{if(!t.skipSandboxPrewarm){let t={appRoot:r.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(e.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:r.appRoot,sandboxScope:l}),log(e){console.log(e)}};await measureBuildPhase(n,`sandbox.prewarm`,async()=>{i?await runVercelBuildPrewarm(t):await prewarmAppSandboxes(t)}),await refreshProductionCompiledArtifacts(r,e.host.artifactsDir)}await buildNitroOutput(u,n,`nitro`),i&&await measureBuildPhase(n,`vercel.workflow-function.materialize`,()=>materializeVercelWorkflowFunctionOutput(e.publication.output.stagedDir)),a!==void 0&&await measureBuildPhase(n,`vercel.functions.normalize`,()=>normalizeEveVercelFunctionOutput(e.publication.output.stagedDir,{servicePrefix:a}));let o=t.vercelServiceOutput;o!==void 0&&(await measureBuildPhase(n,`vercel.service-crons.normalize`,()=>normalizeVercelServiceCrons({publicRoutePrefix:c,serviceOutputDirectory:e.publication.output.stagedDir})),await measureBuildPhase(n,`vercel.host-middleware.copy`,()=>copyHostMiddlewareFunctions({hostOutputDirectory:o.hostOutputDirectory,serviceOutputDirectory:e.publication.output.stagedDir}))),await measureBuildPhase(n,`agent-summary.emit`,()=>emitVercelAgentSummary({manifest:r.compileResult.manifest,outputPath:e.publication.summary.stagedPath})),await measureBuildPhase(n,`connect-manifest.emit`,()=>emitConnectManifest({appRoot:r.appRoot,generatorVersion:resolveInstalledPackageInfo().version,manifest:r.compileResult.manifest,outputDirectory:e.publication.output.stagedDir,publicRoutePrefix:c})),i||await measureBuildPhase(n,`compiler-artifacts.stage`,()=>stageProductionCompilerArtifacts({compilerArtifactsRoot:e.compiler.artifactsDir,outputDir:e.publication.output.stagedDir}))}finally{await measureBuildPhase(n,`nitro.close`,()=>u.close())}return await measureBuildPhase(n,`output.publish`,()=>publishCompletedApplicationBuild(e)),e.publication.output.finalDir}async function publishCompletedApplicationBuild(e){await publishApplicationBuildArtifacts({appRoot:e.appRoot,finalOutputDir:e.publication.output.finalDir,finalSummaryPath:e.publication.summary.finalPath,scratchDir:e.rootDir,stagedOutputDir:e.publication.output.stagedDir,stagedSummaryPath:e.publication.summary.stagedPath})}export{buildApplication};
1
+ import{readFile}from"node:fs/promises";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isObject}from"#shared/guards.js";import{resolveDiscoveryProject}from"#discover/project.js";import{resolveInstalledPackageInfo,resolvePackageSourceFilePath}from"#internal/application/package.js";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{toErrorMessage}from"#shared/errors.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{ApplicationBuildProfiler,createApplicationBuildProfile,measureApplicationBuildOutput,writeApplicationBuildProfile}from"#internal/application/build-profile.js";import{RecoverablePublicationError,publishApplicationBuildArtifacts}from"#internal/application/output-publication.js";import{stageProductionCompilerArtifacts}from"#internal/application/production-compiler-artifacts.js";import{materializeVercelWorkflowFunctionOutput,normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{emitConnectManifest}from"#internal/external-resources.js";import{copyHostMiddlewareFunctions}from"#internal/nitro/host/copy-host-middleware.js";import{normalizeVercelServiceCrons}from"#internal/nitro/host/normalize-vercel-service-crons.js";import{prepareProductionApplicationHost,refreshProductionCompiledArtifacts}from"#internal/nitro/host/prepare-application-host.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";import{resolveEveServicePrefixByRoot}from"#internal/vercel/vercel-service-config-operations.js";import{parseVercelServicesConfig}from"#internal/vercel/vercel-services-config.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}async function measureBuildPhase(e,t,n){return e===void 0?n():e.measure(t,n)}function isPathInside(e,t){let n=relative(e,t);return n.length===0||!n.startsWith(`..${sep}`)&&n!==`..`&&!isAbsolute(n)}function assertProfileOutputOutsideBuildOutput(e,t){if(e!==void 0&&isPathInside(t,e))throw Error(`Build profile path ${e} must be outside the published output directory ${t}.`)}async function writeOptionalApplicationBuildProfile(e){try{assertProfileOutputOutsideBuildOutput(e.profileOutputPath,e.outputDirectory);let t=e.profiler.finish(),n=await measureApplicationBuildOutput(e.outputDirectory);await writeApplicationBuildProfile(e.profileOutputPath,createApplicationBuildProfile({output:n,target:process.env.VERCEL?`vercel`:`local`,timing:t}))}catch(t){console.warn(`eve: failed to write optional build profile to ${e.profileOutputPath}; continuing with the published build output: ${toErrorMessage(t)}`)}}async function resolveEveServicePrefixForVercelFunctionOutput(e,t){let n=Array.from(new Set([resolve(e),resolve(t)])),r=await findClosestVercelOutputDirectory(e);if(r!==void 0)try{let e=join(r,`config.json`),t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),i=resolveEveServicePrefixByRoot({appRoots:n,configRoot:await resolveVercelOutputConfigRoot(r),config:t});if(i!==void 0)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let i=e;for(;;){for(let e of[join(i,`vercel.json`),join(i,`.vercel`,`output`,`config.json`)])try{let t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),r=e.endsWith(`vercel.json`)?i:await resolveVercelOutputConfigRoot(dirname(e)),a=resolveEveServicePrefixByRoot({appRoots:n,configRoot:r,config:t});if(a!==void 0)return a}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let e=dirname(i);if(e===i)return;i=e}}async function resolveVercelOutputConfigRoot(e){let t=dirname(dirname(e));try{let e=JSON.parse(await readFile(join(t,`.vercel`,`project.json`),`utf8`));if(isObject(e)&&isObject(e.settings)){let n=e.settings.rootDirectory;if(typeof n==`string`&&n.trim().length>0)return resolve(t,n)}}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return t}async function buildNitroOutput(e,t,n){let r=trimTrailingSlash(e.options.output.dir);return await measureBuildPhase(t,`${n}.cache.prepare`,()=>prepareEveVersionedCacheDirectory(r)),await measureBuildPhase(t,`${n}.prepare`,()=>prepare(e)),await measureBuildPhase(t,`${n}.public-assets`,()=>copyPublicAssets(e)),await measureBuildPhase(t,`${n}.prerender`,()=>prerender(e)),await measureBuildPhase(t,`${n}.bundle`,()=>build(e)),await measureBuildPhase(t,`${n}.cache.write`,()=>writeEveVersionedCacheMetadata(r)),r}async function buildApplication(e,t){let n=t.profileOutputPath===void 0?void 0:resolve(t.profileOutputPath),r=n===void 0?void 0:new ApplicationBuildProfiler,i=await measureBuildPhase(r,`extension.check`,()=>tryReadExtensionBuildConfig(e));if(i!==null)throw Error(`Package "${i.packageName}" is an eve extension. Run \`eve extension build\` instead of \`eve build\`.`);let a=await measureBuildPhase(r,`project.resolve`,()=>resolveDiscoveryProject(e)),o=await measureBuildPhase(r,`workspace.create`,()=>createApplicationBuildWorkspace(a.appRoot,t.vercelServiceOutput?.serviceOutputDirectory)),s=!1,c;try{c=await buildApplicationInWorkspace(o,t,r)}catch(e){throw s=e instanceof RecoverablePublicationError,e}finally{s||await measureBuildPhase(r,`workspace.remove`,()=>removeApplicationBuildWorkspace(o))}return r!==void 0&&n!==void 0&&await writeOptionalApplicationBuildProfile({outputDirectory:c,profileOutputPath:n,profiler:r}),c}async function buildApplicationInWorkspace(e,t,n){let r=await measureBuildPhase(n,`host.prepare`,()=>prepareProductionApplicationHost(e)),i=!!process.env.VERCEL,a=i?await measureBuildPhase(n,`vercel.service-prefix.resolve`,()=>resolveEveServicePrefixForVercelFunctionOutput(r.appRoot,r.compileResult.project.agentRoot)):void 0,o=normalizePublicRoutePrefix(a),s=o===EVE_ROUTE_PREFIX?void 0:o;if(t.publicRoutePrefix!==void 0&&s!==void 0&&t.publicRoutePrefix!==s)throw Error(`EVE_PUBLIC_ROUTE_PREFIX ${JSON.stringify(t.publicRoutePrefix)} conflicts with the configured Vercel service prefix ${JSON.stringify(a)}.`);let c=t.publicRoutePrefix??s,l=createProductionNitroArtifactsConfig(e.appRoot).sandboxScope,u=await measureBuildPhase(n,`nitro.create`,()=>createProductionApplicationNitro(r,{buildDir:e.nitro.buildDir,outputDir:e.publication.output.stagedDir,publicRoutePrefix:c,workspaceMember:t.workspaceMember}));try{if(!t.skipSandboxPrewarm){let t={appRoot:r.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(e.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:r.appRoot,sandboxScope:l}),log(e){console.log(e)}};await measureBuildPhase(n,`sandbox.prewarm`,async()=>{i?await runVercelBuildPrewarm(t):await prewarmAppSandboxes(t)}),await refreshProductionCompiledArtifacts(r,e.host.artifactsDir)}await buildNitroOutput(u,n,`nitro`),i&&await measureBuildPhase(n,`vercel.workflow-function.materialize`,()=>materializeVercelWorkflowFunctionOutput(e.publication.output.stagedDir)),a!==void 0&&await measureBuildPhase(n,`vercel.functions.normalize`,()=>normalizeEveVercelFunctionOutput(e.publication.output.stagedDir,{servicePrefix:a}));let o=t.vercelServiceOutput;o!==void 0&&(await measureBuildPhase(n,`vercel.service-crons.normalize`,()=>normalizeVercelServiceCrons({publicRoutePrefix:c,serviceOutputDirectory:e.publication.output.stagedDir})),await measureBuildPhase(n,`vercel.host-middleware.copy`,()=>copyHostMiddlewareFunctions({hostOutputDirectory:o.hostOutputDirectory,serviceOutputDirectory:e.publication.output.stagedDir}))),await measureBuildPhase(n,`agent-summary.emit`,()=>emitVercelAgentSummary({manifest:r.compileResult.manifest,outputPath:e.publication.summary.stagedPath})),await measureBuildPhase(n,`connect-manifest.emit`,()=>emitConnectManifest({appRoot:r.appRoot,generatorVersion:resolveInstalledPackageInfo().version,manifest:r.compileResult.manifest,outputDirectory:e.publication.output.stagedDir,publicRoutePrefix:c})),i||await measureBuildPhase(n,`compiler-artifacts.stage`,()=>stageProductionCompilerArtifacts({compilerArtifactsRoot:e.compiler.artifactsDir,outputDir:e.publication.output.stagedDir}))}finally{await measureBuildPhase(n,`nitro.close`,()=>u.close())}return await measureBuildPhase(n,`output.publish`,()=>publishCompletedApplicationBuild(e)),e.publication.output.finalDir}async function publishCompletedApplicationBuild(e){await publishApplicationBuildArtifacts({appRoot:e.appRoot,finalOutputDir:e.publication.output.finalDir,finalSummaryPath:e.publication.summary.finalPath,scratchDir:e.rootDir,stagedOutputDir:e.publication.output.stagedDir,stagedSummaryPath:e.publication.summary.stagedPath})}export{buildApplication};
@@ -1,2 +1,2 @@
1
- import{mkdir,mkdtemp,rm}from"node:fs/promises";import{join,relative,resolve}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{discoverAgent}from"#discover/discover-agent.js";import{createDiskProjectSource}from"#discover/project-source.js";import{discoverFlatModuleSource,readSortedDirectoryEntries}from"#discover/grammar.js";import{EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,writeExtensionCompatibilityManifest}from"#compiler/extension-compatibility.js";import{ensureExtensionExports,tryReadExtensionBuildConfig}from"#internal/nitro/host/extension-build-config.js";import{deriveExtensionCapabilityRequirements}from"#internal/nitro/host/extension-capability-requirements.js";import{ExtensionOutputRestoreError,emitExtensionDistribution,replaceExtensionBuildOutput}from"#internal/nitro/host/extension-distribution.js";async function buildExtensionPackage(e,t){let n=resolve(e),r=createDiskProjectSource(),{diagnostics:i,manifest:a}=await discoverAgent({agentRoot:t.sourceRoot,appRoot:n,source:r,role:`extension`}),o=i.filter(e=>e.severity===`error`);if(o.length>0)throw Error(`Cannot build extension "${t.packageName}":\n${o.map(e=>` - ${e.message}`).join(`
1
+ import{mkdir,mkdtemp,rm}from"node:fs/promises";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{join,relative,resolve}from"node:path";import{discoverAgent}from"#discover/discover-agent.js";import{createDiskProjectSource}from"#discover/project-source.js";import{discoverFlatModuleSource,readSortedDirectoryEntries}from"#discover/grammar.js";import{EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,writeExtensionCompatibilityManifest}from"#compiler/extension-compatibility.js";import{ensureExtensionExports,tryReadExtensionBuildConfig}from"#internal/nitro/host/extension-build-config.js";import{deriveExtensionCapabilityRequirements}from"#internal/nitro/host/extension-capability-requirements.js";import{ExtensionOutputRestoreError,emitExtensionDistribution,replaceExtensionBuildOutput}from"#internal/nitro/host/extension-distribution.js";async function buildExtensionPackage(e,t){let n=resolve(e),r=createDiskProjectSource(),{diagnostics:i,manifest:a}=await discoverAgent({agentRoot:t.sourceRoot,appRoot:n,source:r,role:`extension`}),o=i.filter(e=>e.severity===`error`);if(o.length>0)throw Error(`Cannot build extension "${t.packageName}":\n${o.map(e=>` - ${e.message}`).join(`
2
2
  `)}`);let s=discoverFlatModuleSource({rootEntries:await readSortedDirectoryEntries(r,t.sourceRoot),rootPath:t.sourceRoot,slotName:`extension`}).module;if(s===void 0)throw Error(`Cannot build extension "${t.packageName}": its source root "${t.sourceRoot}" is missing an "extension.<ext>" declaration. Add \`export default defineExtension(...)\` there (with or without config).`);let c=await mkdtemp(join(n,`.eve-extension-build-`)),l=join(c,`output`),u=join(l,relative(t.outDir,t.distRoot)),d=!1;try{await mkdir(u,{recursive:!0});let e=await emitExtensionDistribution({appRoot:n,declarationModule:s,declarationsRoot:join(c,`declarations`),manifest:a,runtimeDependencies:t.runtimeDependencies,shortName:t.shortName,sourceRoot:t.sourceRoot,stagedDistRoot:u,stagedOutDir:l,transactionRoot:c});return await ensureExtensionExports(n,t.outDir),await writeExtensionCompatibilityManifest(u,{kind:EXTENSION_COMPATIBILITY_MANIFEST_KIND,formatVersion:EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,builtWithEve:resolveInstalledPackageInfo().version,...t.externalDependencies.length===0?{}:{build:{externalDependencies:t.externalDependencies}},requires:await deriveExtensionCapabilityRequirements({runtimeImports:e,runtimeRoot:l,declarationModule:s,manifest:a,packageName:t.packageName,runtimeDependencies:t.runtimeDependencies,shortName:t.shortName,sourceRoot:t.sourceRoot})}),await replaceExtensionBuildOutput({outDir:t.outDir,stagedOutDir:l,transactionRoot:c}),t.outDir}catch(e){throw d=e instanceof ExtensionOutputRestoreError,e}finally{d||await rm(c,{force:!0,recursive:!0})}}export{buildExtensionPackage,tryReadExtensionBuildConfig};
@@ -1 +1 @@
1
- import{mkdir,writeFile}from"node:fs/promises";import{dirname}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{VERCEL_EVE_AGENT_SUMMARY_KIND,VERCEL_EVE_AGENT_SUMMARY_VERSION,normalizeChannelKindForDisplay}from"#internal/vercel-agent-summary.js";function buildVercelAgentSummary(e){let{manifest:t}=e;return{kind:VERCEL_EVE_AGENT_SUMMARY_KIND,schemaVersion:VERCEL_EVE_AGENT_SUMMARY_VERSION,generatorVersion:e.generatorVersion??resolveInstalledPackageInfo().version,agent:t.config.dynamicModel===void 0?{name:t.config.name,description:t.config.description,modelId:t.config.model.id}:{name:t.config.name,description:t.config.description,modelRouting:{kind:`dynamic`}},instructions:t.instructions.map(toInstructionsEntry),schedules:t.schedules.map(toScheduleEntry),tools:t.tools.map(toToolEntry),skills:t.skills.map(toSkillEntry),connections:t.connections.map(toConnectionEntry),channels:t.channelRoutes.effective.map(toChannelEntry),sandbox:t.sandbox===null?null:{logicalPath:t.sandbox.logicalPath},subagents:t.subagents.map(toSubagentEntry),diagnostics:{errors:t.diagnosticsSummary.errors,warnings:t.diagnosticsSummary.warnings}}}async function emitVercelAgentSummary(e){let t=buildVercelAgentSummary({generatorVersion:e.generatorVersion,manifest:e.manifest});return await mkdir(dirname(e.outputPath),{recursive:!0}),await writeFile(e.outputPath,`${JSON.stringify(t,null,2)}\n`),e.outputPath}function toInstructionsEntry(e){return{content:e.content,logicalPath:e.logicalPath,role:e.role,sourceKind:e.sourceKind}}function toScheduleEntry(e){return{name:e.name,cron:e.cron,logicalPath:e.logicalPath}}function toToolEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function toSkillEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath,sourceKind:e.sourceKind}}function toConnectionEntry(e){let t={name:e.connectionName,description:e.description,url:e.url,logicalPath:e.logicalPath,type:e.protocol};return e.vercelConnect===void 0?t:{...t,vercelConnect:{connector:e.vercelConnect.connector}}}function toChannelEntry(e){let t={name:e.name,method:e.method,urlPath:e.urlPath,type:normalizeChannelKindForDisplay(e.adapterKind),logicalPath:e.logicalPath};return e.adapterKind===void 0?t:{...t,adapterKind:e.adapterKind}}function toSubagentEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}export{buildVercelAgentSummary,emitVercelAgentSummary};
1
+ import{mkdir,writeFile}from"node:fs/promises";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{dirname}from"node:path";import{VERCEL_EVE_AGENT_SUMMARY_KIND,VERCEL_EVE_AGENT_SUMMARY_VERSION,normalizeChannelKindForDisplay}from"#internal/vercel-agent-summary.js";function buildVercelAgentSummary(e){let{manifest:t}=e;return{kind:VERCEL_EVE_AGENT_SUMMARY_KIND,schemaVersion:VERCEL_EVE_AGENT_SUMMARY_VERSION,generatorVersion:e.generatorVersion??resolveInstalledPackageInfo().version,agent:t.config.dynamicModel===void 0?{name:t.config.name,description:t.config.description,modelId:t.config.model.id}:{name:t.config.name,description:t.config.description,modelRouting:{kind:`dynamic`}},instructions:t.instructions.map(toInstructionsEntry),schedules:t.schedules.map(toScheduleEntry),tools:t.tools.map(toToolEntry),skills:t.skills.map(toSkillEntry),connections:t.connections.map(toConnectionEntry),channels:t.channelRoutes.effective.map(toChannelEntry),sandbox:t.sandbox===null?null:{logicalPath:t.sandbox.logicalPath},subagents:t.subagents.map(toSubagentEntry),diagnostics:{errors:t.diagnosticsSummary.errors,warnings:t.diagnosticsSummary.warnings}}}async function emitVercelAgentSummary(e){let t=buildVercelAgentSummary({generatorVersion:e.generatorVersion,manifest:e.manifest});return await mkdir(dirname(e.outputPath),{recursive:!0}),await writeFile(e.outputPath,`${JSON.stringify(t,null,2)}\n`),e.outputPath}function toInstructionsEntry(e){return{content:e.content,logicalPath:e.logicalPath,role:e.role,sourceKind:e.sourceKind}}function toScheduleEntry(e){return{name:e.name,cron:e.cron,logicalPath:e.logicalPath}}function toToolEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function toSkillEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath,sourceKind:e.sourceKind}}function toConnectionEntry(e){let t={name:e.connectionName,description:e.description,url:e.url,logicalPath:e.logicalPath,type:e.protocol};return e.vercelConnect===void 0?t:{...t,vercelConnect:{connector:e.vercelConnect.connector}}}function toChannelEntry(e){let t={name:e.name,method:e.method,urlPath:e.urlPath,type:normalizeChannelKindForDisplay(e.adapterKind),logicalPath:e.logicalPath};return e.adapterKind===void 0?t:{...t,adapterKind:e.adapterKind}}function toSubagentEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}export{buildVercelAgentSummary,emitVercelAgentSummary};