eve 0.24.2 → 0.24.4

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 (208) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/src/channel/adapter.d.ts +4 -2
  3. package/dist/src/channel/adapter.js +1 -1
  4. package/dist/src/channel/session.d.ts +5 -1
  5. package/dist/src/channel/types.d.ts +7 -6
  6. package/dist/src/chunks/{use-eve-agent-CFBTHlPx.js → use-eve-agent-BP9FpQsJ.js} +15 -4
  7. package/dist/src/chunks/{use-eve-agent-dEGV09g_.js → use-eve-agent-Dwa2j1wE.js} +15 -4
  8. package/dist/src/cli/dev/environment.d.ts +6 -0
  9. package/dist/src/cli/dev/environment.js +1 -1
  10. package/dist/src/cli/dev/tui/runner.d.ts +2 -2
  11. package/dist/src/cli/dev/tui/runner.js +1 -1
  12. package/dist/src/client/index.d.ts +1 -1
  13. package/dist/src/client/message-reducer.js +1 -1
  14. package/dist/src/client/open-stream.js +1 -1
  15. package/dist/src/client/session-utils.js +1 -1
  16. package/dist/src/client/session.d.ts +4 -2
  17. package/dist/src/client/session.js +1 -1
  18. package/dist/src/client/types.d.ts +3 -2
  19. package/dist/src/compiled/.vendor-stamp.json +2 -1
  20. package/dist/src/compiled/@chat-adapter/slack/index.js +12 -12
  21. package/dist/src/compiled/@chat-adapter/twilio/index.js +1 -1
  22. package/dist/src/compiled/@vercel/sandbox/index.js +19 -19
  23. package/dist/src/compiled/@workflow/world-local/index.d.ts +14 -0
  24. package/dist/src/compiled/_chunks/node/{auth-CWHn3Yve.js → auth-BuQkq4Gr.js} +2 -2
  25. package/dist/src/compiled/_chunks/node/{dist-BdTs18CF.js → chunk-BTyA9uPd.js} +1 -1
  26. package/dist/src/compiled/_chunks/node/{dist-W8yle6rh.js → dist-CdH_Yoxt.js} +5 -5
  27. package/dist/src/compiled/_chunks/node/{dist-RHRJZ03Q.js → dist-Drt-_JVK.js} +1 -1
  28. package/dist/src/compiled/_chunks/node/dist-DsNhwdzf.js +1 -0
  29. package/dist/src/compiled/_chunks/node/retry-DngYleaI.js +1 -0
  30. package/dist/src/compiled/_chunks/node/token-DabMnh8F.js +1 -0
  31. package/dist/src/compiled/_chunks/node/token-util-BoSJPKrG.js +1 -0
  32. package/dist/src/compiled/_chunks/node/token-util-DVigMYWS.js +1 -0
  33. package/dist/src/compiled/_chunks/node/virtual-loader-B8K8w9cr.js +1 -0
  34. package/dist/src/compiled/chat/index.js +1 -1
  35. package/dist/src/compiled/env-runner/LICENSE +21 -0
  36. package/dist/src/compiled/env-runner/index.d.ts +38 -0
  37. package/dist/src/compiled/env-runner/index.js +1 -0
  38. package/dist/src/compiled/env-runner/node-worker.d.ts +1 -0
  39. package/dist/src/compiled/env-runner/node-worker.js +12 -0
  40. package/dist/src/compiler/compile-agent.d.ts +4 -6
  41. package/dist/src/compiler/compile-agent.js +1 -1
  42. package/dist/src/discover/filesystem.js +1 -1
  43. package/dist/src/execution/create-session-step.d.ts +2 -2
  44. package/dist/src/execution/create-session-step.js +1 -1
  45. package/dist/src/execution/durable-session-migrations/turn-workflow.d.ts +1 -0
  46. package/dist/src/execution/durable-session-migrations/turn-workflow.js +1 -1
  47. package/dist/src/execution/next-driver-action.d.ts +7 -0
  48. package/dist/src/execution/settle-cancelled-turn-step.d.ts +16 -0
  49. package/dist/src/execution/settle-cancelled-turn-step.js +1 -0
  50. package/dist/src/execution/subagent-hitl-proxy.js +1 -1
  51. package/dist/src/execution/terminal-session-failure-step.d.ts +6 -0
  52. package/dist/src/execution/terminal-session-failure-step.js +1 -0
  53. package/dist/src/execution/turn-cancellation-control.d.ts +40 -0
  54. package/dist/src/execution/turn-cancellation-control.js +1 -0
  55. package/dist/src/execution/turn-dispatch.d.ts +14 -1
  56. package/dist/src/execution/turn-dispatch.js +1 -1
  57. package/dist/src/execution/turn-execution-cursor.d.ts +2 -1
  58. package/dist/src/execution/turn-execution-cursor.js +1 -1
  59. package/dist/src/execution/turn-workflow.d.ts +9 -1
  60. package/dist/src/execution/turn-workflow.js +1 -1
  61. package/dist/src/execution/workflow-entry.js +1 -1
  62. package/dist/src/execution/workflow-runtime.js +1 -1
  63. package/dist/src/execution/workflow-steps.d.ts +8 -6
  64. package/dist/src/execution/workflow-steps.js +1 -1
  65. package/dist/src/harness/active-turn-id.d.ts +11 -0
  66. package/dist/src/harness/active-turn-id.js +1 -0
  67. package/dist/src/harness/cancelled-turn-emission.d.ts +11 -0
  68. package/dist/src/harness/cancelled-turn-emission.js +1 -0
  69. package/dist/src/harness/emission.d.ts +4 -2
  70. package/dist/src/harness/emission.js +1 -1
  71. package/dist/src/harness/proxy-input-requests.d.ts +5 -0
  72. package/dist/src/harness/proxy-input-requests.js +1 -1
  73. package/dist/src/harness/session-limit-enforcement.js +1 -1
  74. package/dist/src/harness/tool-loop.js +2 -2
  75. package/dist/src/internal/application/compiled-artifacts.d.ts +13 -0
  76. package/dist/src/internal/application/compiled-artifacts.js +5 -3
  77. package/dist/src/internal/application/dev-environment.d.ts +4 -0
  78. package/dist/src/internal/application/dev-environment.js +1 -0
  79. package/dist/src/internal/application/optional-package-install.d.ts +2 -10
  80. package/dist/src/internal/application/optional-package-install.js +1 -1
  81. package/dist/src/internal/application/output-publication-lock.js +1 -1
  82. package/dist/src/internal/application/package.js +1 -1
  83. package/dist/src/internal/application/tsconfig-dependencies.js +1 -1
  84. package/dist/src/internal/authored-module-loader.d.ts +3 -9
  85. package/dist/src/internal/authored-module-loader.js +2 -2
  86. package/dist/src/internal/authored-package-boundary.d.ts +0 -2
  87. package/dist/src/internal/authored-package-boundary.js +1 -1
  88. package/dist/src/internal/authored-package-tsconfig-paths.js +1 -1
  89. package/dist/src/internal/bundler/nitro-rolldown.d.ts +18 -2
  90. package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
  91. package/dist/src/internal/compiled-manifest-fingerprint.d.ts +5 -0
  92. package/dist/src/internal/compiled-manifest-fingerprint.js +1 -0
  93. package/dist/src/internal/materialized-authored-modules.d.ts +0 -3
  94. package/dist/src/internal/materialized-authored-modules.js +1 -1
  95. package/dist/src/internal/nitro/dev-client-address.d.ts +22 -0
  96. package/dist/src/internal/nitro/dev-client-address.js +1 -0
  97. package/dist/src/internal/nitro/dev-runtime-artifacts-retention.d.ts +12 -0
  98. package/dist/src/internal/nitro/dev-runtime-artifacts-retention.js +1 -0
  99. package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +19 -1
  100. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  101. package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
  102. package/dist/src/internal/nitro/development-generation.d.ts +5 -1
  103. package/dist/src/internal/nitro/development-generation.js +1 -1
  104. package/dist/src/internal/nitro/host/artifacts-config.d.ts +2 -0
  105. package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
  106. package/dist/src/internal/nitro/host/channel-routes.d.ts +1 -13
  107. package/dist/src/internal/nitro/host/channel-routes.js +3 -3
  108. package/dist/src/internal/nitro/host/configure-nitro-routes.d.ts +1 -2
  109. package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
  110. package/dist/src/internal/nitro/host/create-application-nitro.d.ts +3 -5
  111. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  112. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.d.ts +32 -0
  113. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -0
  114. package/dist/src/internal/nitro/host/dev-authored-source-watcher.d.ts +4 -15
  115. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  116. package/dist/src/internal/nitro/host/dev-host-candidate.d.ts +16 -0
  117. package/dist/src/internal/nitro/host/dev-host-candidate.js +1 -0
  118. package/dist/src/internal/nitro/host/dev-host-fingerprint.d.ts +2 -0
  119. package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -0
  120. package/dist/src/internal/nitro/host/dev-host-workspace.d.ts +10 -0
  121. package/dist/src/internal/nitro/host/dev-host-workspace.js +1 -0
  122. package/dist/src/internal/nitro/host/dev-runner.d.ts +21 -0
  123. package/dist/src/internal/nitro/host/dev-runner.js +1 -0
  124. package/dist/src/internal/nitro/host/dev-server-http.d.ts +5 -0
  125. package/dist/src/internal/nitro/host/dev-server-http.js +1 -0
  126. package/dist/src/internal/nitro/host/dev-server-url.d.ts +6 -0
  127. package/dist/src/internal/nitro/host/dev-server-url.js +1 -0
  128. package/dist/src/internal/nitro/host/dev-workflow-world-setup.d.ts +9 -0
  129. package/dist/src/internal/nitro/host/dev-workflow-world-setup.js +1 -0
  130. package/dist/src/internal/nitro/host/dispatch-schedule-in-dev.js +1 -1
  131. package/dist/src/internal/nitro/host/drained-nitro-dev-server.d.ts +53 -0
  132. package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -0
  133. package/dist/src/internal/nitro/host/prepare-application-host.d.ts +4 -5
  134. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  135. package/dist/src/internal/nitro/host/start-development-server.d.ts +2 -5
  136. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  137. package/dist/src/internal/nitro/host/types.d.ts +6 -0
  138. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
  139. package/dist/src/internal/nitro/routes/runtime-artifacts.d.ts +7 -0
  140. package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -1
  141. package/dist/src/internal/nitro/routes/schedule-task.d.ts +9 -0
  142. package/dist/src/internal/nitro/routes/schedule-task.js +1 -1
  143. package/dist/src/internal/workflow/development-generation-context.d.ts +8 -0
  144. package/dist/src/internal/workflow/development-generation-context.js +1 -0
  145. package/dist/src/internal/workflow/development-world-client.d.ts +29 -0
  146. package/dist/src/internal/workflow/development-world-client.js +1 -0
  147. package/dist/src/internal/workflow/development-world-codec.d.ts +11 -0
  148. package/dist/src/internal/workflow/development-world-codec.js +1 -0
  149. package/dist/src/internal/workflow/development-world-protocol.d.ts +31 -0
  150. package/dist/src/internal/workflow/development-world-protocol.js +1 -0
  151. package/dist/src/internal/workflow/development-world-server.d.ts +27 -0
  152. package/dist/src/internal/workflow/development-world-server.js +1 -0
  153. package/dist/src/internal/workflow/local-world-data-directory.d.ts +2 -0
  154. package/dist/src/internal/workflow/local-world-data-directory.js +1 -0
  155. package/dist/src/internal/workflow-bundle/builder-support.js +3 -3
  156. package/dist/src/internal/workflow-bundle/builder.js +2 -2
  157. package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
  158. package/dist/src/protocol/message.d.ts +23 -3
  159. package/dist/src/protocol/message.js +2 -2
  160. package/dist/src/public/channels/discord/discordChannel.d.ts +1 -0
  161. package/dist/src/public/channels/eve.js +1 -1
  162. package/dist/src/public/channels/github/githubChannel.d.ts +1 -0
  163. package/dist/src/public/channels/linear/linearChannel.d.ts +1 -0
  164. package/dist/src/public/channels/slack/slackChannel.d.ts +1 -0
  165. package/dist/src/public/channels/teams/teamsChannel.d.ts +1 -0
  166. package/dist/src/public/channels/telegram/telegramChannel.d.ts +1 -0
  167. package/dist/src/public/channels/twilio/twilioChannel.d.ts +1 -0
  168. package/dist/src/public/definitions/channel.d.ts +5 -4
  169. package/dist/src/public/definitions/channel.js +1 -1
  170. package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
  171. package/dist/src/runtime/compiled-artifacts-source.d.ts +9 -0
  172. package/dist/src/runtime/compiled-artifacts-source.js +1 -1
  173. package/dist/src/runtime/durable-compiled-artifacts-source.d.ts +8 -0
  174. package/dist/src/runtime/durable-compiled-artifacts-source.js +1 -0
  175. package/dist/src/runtime/sessions/runtime-context-keys.js +1 -1
  176. package/dist/src/services/dev-client/runtime-artifacts.d.ts +2 -2
  177. package/dist/src/services/dev-client.d.ts +10 -18
  178. package/dist/src/services/dev-client.js +1 -1
  179. package/dist/src/setup/scaffold/create/extension.js +0 -1
  180. package/dist/src/setup/scaffold/create/project.js +1 -3
  181. package/dist/src/shared/atomic-write-file.d.ts +1 -1
  182. package/dist/src/shared/atomic-write-file.js +1 -1
  183. package/dist/src/shared/continuation-token.d.ts +2 -0
  184. package/dist/src/shared/continuation-token.js +1 -0
  185. package/dist/src/shared/rename-with-retry.d.ts +5 -0
  186. package/dist/src/shared/rename-with-retry.js +1 -0
  187. package/dist/src/svelte/index.js +1 -1
  188. package/dist/src/svelte/use-eve-agent.js +1 -1
  189. package/dist/src/vue/index.js +1 -1
  190. package/dist/src/vue/use-eve-agent.js +1 -1
  191. package/docs/agent-config.md +2 -0
  192. package/docs/concepts/execution-model-and-durability.md +1 -1
  193. package/docs/concepts/sessions-runs-and-streaming.md +13 -4
  194. package/docs/guides/client/continuations.mdx +14 -1
  195. package/docs/guides/client/streaming.mdx +14 -1
  196. package/docs/guides/deployment.md +1 -1
  197. package/docs/reference/cli.md +1 -1
  198. package/package.json +2 -1
  199. package/dist/src/compiled/_chunks/node/retry-DkR2H1Y0.js +0 -1
  200. package/dist/src/compiled/_chunks/node/token-ORseRyWn.js +0 -1
  201. package/dist/src/internal/bundler/nitro-node-file-trace.d.ts +0 -10
  202. package/dist/src/internal/bundler/nitro-node-file-trace.js +0 -1
  203. package/dist/src/internal/materialize-authored-external-dependencies.d.ts +0 -10
  204. package/dist/src/internal/materialize-authored-external-dependencies.js +0 -2
  205. package/dist/src/internal/nitro/host/dev-live-virtual-modules.d.ts +0 -15
  206. package/dist/src/internal/nitro/host/dev-live-virtual-modules.js +0 -1
  207. package/dist/src/internal/nitro/host/server-external-packages.d.ts +0 -5
  208. package/dist/src/internal/nitro/host/server-external-packages.js +0 -1
@@ -1,6 +1,8 @@
1
- import{getWorldImport}from"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/world-target.js";import"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/index.js";import{resolvePackageCompiledFilePath,resolvePackageSourceFilePath}from"#internal/application/package.js";import{existsSync}from"node:fs";import{join}from"node:path";import{copyFile,mkdir,writeFile}from"node:fs/promises";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";async function writeCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),r=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),a=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),c=resolveInstrumentationModule(e.compileResult.manifest.agentRoot);await mkdir(e.outDir,{recursive:!0}),await writeFile(t,await createCompiledArtifactsBootstrapSource({compileResult:e.compileResult,installModulePath:resolvePackageSourceFilePath(`src/runtime/loaders/bundled-artifacts.ts`),moduleMapPath:t,metadata:e.compileResult.metadata})),await writeFile(a,createWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world,defaultWorld:e.defaultWorkflowWorld})),c!==void 0&&await writeFile(r,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,instrumentationPath:c,registerConfigPath:resolvePackageSourceFilePath(`src/harness/instrumentation-config.ts`)}));let l={bootstrapPath:t,workflowWorldPluginPath:a};return c!==void 0&&(l.instrumentationPluginPath=r,l.instrumentationSourcePath=c),l}async function writeDevelopmentCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),r=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),c=join(e.outDir,`compiled-artifacts-instrumentation-source.mjs`),l=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),u=await readMaterializedAuthoredModuleIndex(e.runtimeAppRoot);if(u===void 0)throw Error(`Development generation at "${e.runtimeAppRoot}" is not materialized.`);await mkdir(e.outDir,{recursive:!0}),await writeFile(t,createDevelopmentCompiledArtifactsBootstrapSource(e.compileResult.manifest.config.name)),await writeFile(l,createWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world,defaultWorld:`local`}));let d={bootstrapPath:t,workflowWorldPluginPath:l};return u.instrumentation!==void 0&&(await copyFile(join(e.runtimeAppRoot,`.eve`,`compile`,u.instrumentation),c),await writeFile(r,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,instrumentationPath:c,registerConfigPath:resolvePackageSourceFilePath(`src/harness/instrumentation-config.ts`)})),d.instrumentationPluginPath=r,d.instrumentationSourcePath=c),d}function createDevelopmentCompiledArtifactsBootstrapSource(e){return[`// Generated by eve. Do not edit by hand.`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,``,`installEveWorkflowQueueNamespace(${JSON.stringify(e)});`,``,`export default function installDevelopmentCompiledArtifactsPlugin() {}`,``].join(`
1
+ import{getWorldImport}from"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/world-target.js";import"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/index.js";import{resolvePackageCompiledFilePath,resolvePackageSourceFilePath}from"#internal/application/package.js";import{existsSync}from"node:fs";import{join}from"node:path";import{copyFile,mkdir,writeFile}from"node:fs/promises";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";async function writeCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),r=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),a=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),c=resolveInstrumentationModule(e.compileResult.manifest.agentRoot);await mkdir(e.outDir,{recursive:!0}),await writeFile(t,await createCompiledArtifactsBootstrapSource({compileResult:e.compileResult,installModulePath:resolvePackageSourceFilePath(`src/runtime/loaders/bundled-artifacts.ts`),moduleMapPath:t,metadata:e.compileResult.metadata})),await writeFile(a,createWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world,defaultWorld:e.defaultWorkflowWorld})),c!==void 0&&await writeFile(r,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,instrumentationPath:c,registerConfigPath:resolvePackageSourceFilePath(`src/harness/instrumentation-config.ts`)}));let l={bootstrapPath:t,workflowWorldPluginPath:a};return c!==void 0&&(l.instrumentationPluginPath=r,l.instrumentationSourcePath=c),l}async function writeDevelopmentCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),r=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),c=join(e.outDir,`compiled-artifacts-instrumentation-source.mjs`),l=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),d=await readMaterializedAuthoredModuleIndex(e.runtimeAppRoot);if(d===void 0)throw Error(`Development generation at "${e.runtimeAppRoot}" is not materialized.`);await mkdir(e.outDir,{recursive:!0}),await writeFile(t,createDevelopmentCompiledArtifactsBootstrapSource(e.compileResult.manifest.config.name)),await writeFile(l,createDevelopmentWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world}));let f={bootstrapPath:t,workflowWorldPluginPath:l};return d.instrumentation!==void 0&&(await copyFile(join(e.runtimeAppRoot,`.eve`,`compile`,d.instrumentation),c),await writeFile(r,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,instrumentationPath:c,registerConfigPath:resolvePackageSourceFilePath(`src/harness/instrumentation-config.ts`)})),f.instrumentationPluginPath=r,f.instrumentationSourcePath=c),f}function createDevelopmentCompiledArtifactsBootstrapSource(e){return[`// Generated by eve. Do not edit by hand.`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,``,`installEveWorkflowQueueNamespace(${JSON.stringify(e)});`,``,`export default function installDevelopmentCompiledArtifactsPlugin() {}`,``].join(`
2
2
  `)}const INSTRUMENTATION_EXTENSIONS=[`.ts`,`.mts`,`.js`,`.mjs`];function resolveInstrumentationModule(e){for(let t of INSTRUMENTATION_EXTENSIONS){let n=join(e,`instrumentation${t}`);if(existsSync(n))return n}}function stripCompiledModuleMapExports(e){return e.replace(/^export const moduleMap = /m,`const moduleMap = `).replace(/\nexport default moduleMap;\n?$/,`
3
3
  `)}async function createCompiledArtifactsBootstrapSource(e){let t=e.compileResult.manifest.config.name,r=stripCompiledModuleMapExports(createCompiledModuleMapSource({importSpecifierStyle:`absolute`,manifest:e.compileResult.manifest,moduleMapPath:e.moduleMapPath})).trim();return[`// Generated by eve. Do not edit by hand.`,`import { installBundledCompiledArtifacts } from ${stringifyEsmImportSpecifier(e.installModulePath)};`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,``,`installEveWorkflowQueueNamespace(${JSON.stringify(t)});`,``,r,``,`const metadata = ${JSON.stringify(e.metadata,null,2)};`,``,`const manifest = ${JSON.stringify(e.compileResult.manifest,null,2)};`,``,`export function installCompiledArtifactsBootstrap() {`,` installBundledCompiledArtifacts({`,` manifest,`,` metadata,`,` moduleMap,`,` });`,`}`,``,`installCompiledArtifactsBootstrap();`,``,`// Default export satisfies the Nitro plugin contract so this file`,`// can be used directly as a Nitro plugin without a separate wrapper.`,`export default function installCompiledArtifactsPlugin() {`,` // Already installed on import above.`,`}`,``].join(`
4
- `)}function createWorkflowWorldPluginSource(r){let i=getWorldImport({WORKFLOW_TARGET_WORLD:r.configuredWorld??r.defaultWorld}),a=i===`@workflow/world-local`||i===`@workflow/world-vercel`?resolvePackageCompiledFilePath(`src/compiled/${i}/index.js`):i,o=resolvePackageCompiledFilePath(`src/compiled/@workflow/core/runtime.js`),s=resolvePackageSourceFilePath(`src/internal/workflow/validate-world.ts`);return[`// Generated by eve. Do not edit by hand.`,`import ${stringifyEsmImportSpecifier(r.compiledArtifactsBootstrapPath)};`,`import * as workflowWorldModule from ${stringifyEsmImportSpecifier(a)};`,`import { createWorldFromModule, getWorld, setWorld } from ${stringifyEsmImportSpecifier(o)};`,`import { validateWorkflowWorld } from ${stringifyEsmImportSpecifier(s)};`,``,`const workflowWorld = await createWorldFromModule(workflowWorldModule);`,`validateWorkflowWorld({ packageName: ${JSON.stringify(r.configuredWorld)}, world: workflowWorld });`,`setWorld(workflowWorld);`,`await getWorld();`,`await workflowWorld.start?.();`,``,`export default function installWorkflowWorldPlugin() {}`,``].join(`
4
+ `)}function createWorkflowWorldPluginSource(r){let i=getWorldImport({WORKFLOW_TARGET_WORLD:r.configuredWorld??r.defaultWorld}),a=i===`@workflow/world-local`||i===`@workflow/world-vercel`?resolvePackageCompiledFilePath(`src/compiled/${i}/index.js`):i,o=resolvePackageCompiledFilePath(`src/compiled/@workflow/core/runtime.js`),s=resolvePackageSourceFilePath(`src/internal/workflow/validate-world.ts`),c=i===`@workflow/world-local`?resolvePackageSourceFilePath(`src/internal/workflow/local-world-data-directory.ts`):void 0,u=c===void 0?`const workflowWorld = await createWorldFromModule(workflowWorldModule);`:[`const workflowWorld = await workflowWorldModule.createWorld({`,` dataDir: resolveLocalWorkflowWorldDataDirectory(process.cwd()),`,`});`].join(`
5
+ `),d=c===void 0?`createWorldFromModule, getWorld, setWorld`:`getWorld, setWorld`;return[`// Generated by eve. Do not edit by hand.`,`import ${stringifyEsmImportSpecifier(r.compiledArtifactsBootstrapPath)};`,`import * as workflowWorldModule from ${stringifyEsmImportSpecifier(a)};`,...c===void 0?[]:[`import { resolveLocalWorkflowWorldDataDirectory } from ${stringifyEsmImportSpecifier(c)};`],`import { ${d} } from ${stringifyEsmImportSpecifier(o)};`,`import { validateWorkflowWorld } from ${stringifyEsmImportSpecifier(s)};`,``,u,`validateWorkflowWorld({ packageName: ${JSON.stringify(r.configuredWorld)}, world: workflowWorld });`,`setWorld(workflowWorld);`,`await getWorld();`,`await workflowWorld.start?.();`,``,`export default function installWorkflowWorldPlugin() {}`,``].join(`
6
+ `)}function createDevelopmentWorkflowWorldPluginSource(e){if(!usesParentDevelopmentWorkflowWorld(e.configuredWorld))return createWorkflowWorldPluginSource({...e,defaultWorld:`local`});let r=resolvePackageCompiledFilePath(`src/compiled/@workflow/core/runtime.js`),i=resolvePackageSourceFilePath(`src/internal/workflow/development-world-client.ts`);return[`// Generated by eve. Do not edit by hand.`,`import ${stringifyEsmImportSpecifier(e.compiledArtifactsBootstrapPath)};`,`import { getWorld, setWorld } from ${stringifyEsmImportSpecifier(r)};`,`import { createDevelopmentWorkflowWorld } from ${stringifyEsmImportSpecifier(i)};`,``,`setWorld(createDevelopmentWorkflowWorld());`,`await getWorld();`,``,`export default function installDevelopmentWorkflowWorldPlugin() {}`,``].join(`
5
7
  `)}function createInstrumentationPluginSource(e){return[`// Generated by eve. Do not edit by hand.`,`import * as instrumentationModule from ${stringifyEsmImportSpecifier(e.instrumentationPath)};`,`import { registerInstrumentationConfig } from ${stringifyEsmImportSpecifier(e.registerConfigPath)};`,``,`if (instrumentationModule.default != null) {`,` registerInstrumentationConfig(instrumentationModule.default, { agentName: ${JSON.stringify(e.agentName)} });`,`}`,``,`// Default export satisfies the Nitro plugin contract so this file`,`// can be used directly as a Nitro plugin without a separate wrapper.`,`export default function installInstrumentationPlugin() {}`,``].join(`
6
- `)}export{createCompiledArtifactsBootstrapSource,createWorkflowWorldPluginSource,writeCompiledArtifactsFiles,writeDevelopmentCompiledArtifactsFiles};
8
+ `)}export{createCompiledArtifactsBootstrapSource,createDevelopmentWorkflowWorldPluginSource,createWorkflowWorldPluginSource,writeCompiledArtifactsFiles,writeDevelopmentCompiledArtifactsFiles};
@@ -0,0 +1,4 @@
1
+ /** Environment flag set for processes that belong to an `eve dev` session. */
2
+ export declare const EVE_DEV_ENV_FLAG = "EVE_DEV";
3
+ /** Reports whether this process belongs to an `eve dev` session. */
4
+ export declare function isEveDevEnvironment(): boolean;
@@ -0,0 +1 @@
1
+ const EVE_DEV_ENV_FLAG=`EVE_DEV`;function isEveDevEnvironment(){return process.env[EVE_DEV_ENV_FLAG]===`1`}export{EVE_DEV_ENV_FLAG,isEveDevEnvironment};
@@ -1,13 +1,5 @@
1
- /**
2
- * Environment flag set by `eve dev` so runtime code can distinguish the
3
- * interactive development server from production processes. Optional
4
- * engine packages are auto-installed only when this is set.
5
- */
6
- export declare const EVE_DEV_ENV_FLAG = "EVE_DEV";
7
- /**
8
- * Reports whether this process belongs to an `eve dev` session.
9
- */
10
- export declare function isEveDevEnvironment(): boolean;
1
+ import { EVE_DEV_ENV_FLAG, isEveDevEnvironment } from "#internal/application/dev-environment.js";
2
+ export { EVE_DEV_ENV_FLAG, isEveDevEnvironment };
11
3
  export type ProjectPackageManager = "bun" | "npm" | "pnpm" | "yarn";
12
4
  /**
13
5
  * Detects the project's package manager from its lockfile, walking up
@@ -1,4 +1,4 @@
1
- import{existsSync}from"node:fs";import{dirname,join}from"node:path";import{mkdir,readFile,rm,stat,writeFile}from"node:fs/promises";import{spawn}from"node:child_process";import{pathToFileURL}from"node:url";import{Worker}from"node:worker_threads";const EVE_DEV_ENV_FLAG=`EVE_DEV`;function isEveDevEnvironment(){return process.env[EVE_DEV_ENV_FLAG]===`1`}function detectProjectPackageManager(r){let i=r;for(;;){if(existsSync(join(i,`pnpm-lock.yaml`))||existsSync(join(i,`pnpm-workspace.yaml`)))return`pnpm`;if(existsSync(join(i,`yarn.lock`)))return`yarn`;if(existsSync(join(i,`bun.lock`))||existsSync(join(i,`bun.lockb`)))return`bun`;if(existsSync(join(i,`package-lock.json`)))return`npm`;let r=dirname(i);if(r===i)return`npm`;i=r}}const INSTALL_ARGUMENTS={bun:[`add`,`--dev`],npm:[`install`,`--save-dev`],pnpm:[`add`,`-D`],yarn:[`add`,`-D`]},OPTIONAL_PACKAGE_LOCK_TIMEOUT_MS=600*1e3,pendingOptionalPackageInstalls=new Map;async function installPackageIntoProject(e){let t=detectProjectPackageManager(e.appRoot),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({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.packageName})})}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 importInstalledEnginePackage(e){return await import(await resolveInstalledEnginePackageEntrypointHref(e))}async function isInstalledEnginePackageLoadable(e){try{return await importEntrypointInWorker(await resolveInstalledEnginePackageEntrypointHref(e)),!0}catch{return!1}}async function resolveInstalledEnginePackageEntrypointHref(e){let t=findInstalledPackageRoot(e),r=join(t,`package.json`),a=resolvePackageEntryPoint(JSON.parse(await readFile(r,`utf8`)));if(a.startsWith(`/`))throw Error(`Invalid absolute entrypoint for optional package "${e.packageName}".`);return pathToFileURL(join(t,a)).href}async function importEntrypointInWorker(e){let t=new Worker(`
1
+ import{existsSync}from"node:fs";import{dirname,join}from"node:path";import{mkdir,readFile,rm,stat,writeFile}from"node:fs/promises";import{spawn}from"node:child_process";import{EVE_DEV_ENV_FLAG,isEveDevEnvironment}from"#internal/application/dev-environment.js";import{pathToFileURL}from"node:url";import{Worker}from"node:worker_threads";function detectProjectPackageManager(r){let i=r;for(;;){if(existsSync(join(i,`pnpm-lock.yaml`))||existsSync(join(i,`pnpm-workspace.yaml`)))return`pnpm`;if(existsSync(join(i,`yarn.lock`)))return`yarn`;if(existsSync(join(i,`bun.lock`))||existsSync(join(i,`bun.lockb`)))return`bun`;if(existsSync(join(i,`package-lock.json`)))return`npm`;let r=dirname(i);if(r===i)return`npm`;i=r}}const INSTALL_ARGUMENTS={bun:[`add`,`--dev`],npm:[`install`,`--save-dev`],pnpm:[`add`,`-D`],yarn:[`add`,`-D`]},OPTIONAL_PACKAGE_LOCK_TIMEOUT_MS=600*1e3,pendingOptionalPackageInstalls=new Map;async function installPackageIntoProject(e){let t=detectProjectPackageManager(e.appRoot),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({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.packageName})})}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 importInstalledEnginePackage(e){return await import(await resolveInstalledEnginePackageEntrypointHref(e))}async function isInstalledEnginePackageLoadable(e){try{return await importEntrypointInWorker(await resolveInstalledEnginePackageEntrypointHref(e)),!0}catch{return!1}}async function resolveInstalledEnginePackageEntrypointHref(e){let t=findInstalledPackageRoot(e),r=join(t,`package.json`),a=resolvePackageEntryPoint(JSON.parse(await readFile(r,`utf8`)));if(a.startsWith(`/`))throw Error(`Invalid absolute entrypoint for optional package "${e.packageName}".`);return pathToFileURL(join(t,a)).href}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{watch}from"node:fs";import{basename,dirname,isAbsolute,join,relative,resolve}from"node:path";import{mkdir,readdir,rename,rm,stat,utimes}from"node:fs/promises";import{isErrnoCode}from"#shared/guards.js";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";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,r){let i=Date.now()+PUBLICATION_LOCK_TIMEOUT_MS,a=`${e}.recovery`;for(await mkdir(dirname(e),{recursive:!0});;){if(await pathExists(a)){if(await r(),await recoverStalePublication(e,a,t))continue;await waitForPublicationLockChange(e,i);continue}try{if(await mkdir(e),await pathExists(a)){await rm(e,{force:!0,recursive:!0}),await waitForPublicationLockChange(e,i);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 rename(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 r(),!await recoverStalePublication(e,a,t)&&await waitForPublicationLockChange(e,i)}}async function recoverStalePublication(e,t,n){let r=await acquireRecoveryLease(t,n.token);if(r===void 0)return!1;let a=startPublicationJournalHeartbeat(join(t,`lease`)),o=!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 rename(e,r),o=!0}catch(e){if(!isErrnoCode(e,`ENOENT`))throw e}}let a=await readdir(t,{withFileTypes:!0});o=a.some(e=>e.isDirectory()&&e.name.startsWith(`owner-`));for(let e of a)!e.isDirectory()||!e.name.startsWith(`owner-`)||await finishInterruptedPublication(join(t,e.name));return o=!1,!0}finally{a(),o?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 rename(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 rename(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 rename(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(r,i){let a=i-Date.now();if(a<=0)throw Error(`Timed out waiting ${PUBLICATION_LOCK_TIMEOUT_MS}ms to publish completed build output.`);let o=dirname(r),s=basename(r),c=await readPublicationLockState(r);await new Promise((t,n)=>{let i=!1,l=setTimeout(settleResolve,Math.min(a,INCOMPLETE_LOCK_STALE_MS)),u=watch(o,(e,t)=>{e===`rename`&&(t===null||t.toString().startsWith(s))&&settleResolve()});function cleanup(){clearTimeout(l),u.close()}function settleResolve(){i||(i=!0,cleanup(),t())}function settleReject(e){i||(i=!0,cleanup(),n(e))}u.once(`error`,settleReject),Promise.all([readPublicationLockState(r),pathExists(r),pathExists(`${r}.recovery`)]).then(([e,t,n])=>{(!t&&!n||e!==c)&&settleResolve()},settleReject)})}async function readPublicationLockState(e){let t=`${e}.recovery`,[n,r,a,o]=await Promise.all([readOutputPublicationJournal(e),readRecoveryLeaseJournal(join(t,`lease`)),pathExists(e),pathExists(t)]);return JSON.stringify({lockExists:a,lockToken:n?.token,recoveryExists:o,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,resolveOutputPublicationLockPath,startPublicationJournalHeartbeat};
1
+ import{watch}from"node:fs";import{basename,dirname,isAbsolute,join,relative,resolve}from"node:path";import{mkdir,readdir,rm,stat,utimes}from"node:fs/promises";import{isErrnoCode}from"#shared/guards.js";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,r){let i=Date.now()+PUBLICATION_LOCK_TIMEOUT_MS,a=`${e}.recovery`;for(await mkdir(dirname(e),{recursive:!0});;){if(await pathExists(a)){if(await r(),await recoverStalePublication(e,a,t))continue;await waitForPublicationLockChange(e,i);continue}try{if(await mkdir(e),await pathExists(a)){await rm(e,{force:!0,recursive:!0}),await waitForPublicationLockChange(e,i);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 r(),!await recoverStalePublication(e,a,t)&&await waitForPublicationLockChange(e,i)}}async function recoverStalePublication(e,t,n){let r=await acquireRecoveryLease(t,n.token);if(r===void 0)return!1;let a=startPublicationJournalHeartbeat(join(t,`lease`)),o=!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),o=!0}catch(e){if(!isErrnoCode(e,`ENOENT`))throw e}}let a=await readdir(t,{withFileTypes:!0});o=a.some(e=>e.isDirectory()&&e.name.startsWith(`owner-`));for(let e of a)!e.isDirectory()||!e.name.startsWith(`owner-`)||await finishInterruptedPublication(join(t,e.name));return o=!1,!0}finally{a(),o?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(r,i){let a=i-Date.now();if(a<=0)throw Error(`Timed out waiting ${PUBLICATION_LOCK_TIMEOUT_MS}ms to publish completed build output.`);let o=dirname(r),s=basename(r),c=await readPublicationLockState(r);await new Promise((t,n)=>{let i=!1,l=setTimeout(settleResolve,Math.min(a,INCOMPLETE_LOCK_STALE_MS)),u=watch(o,(e,t)=>{e===`rename`&&(t===null||t.toString().startsWith(s))&&settleResolve()});function cleanup(){clearTimeout(l),u.close()}function settleResolve(){i||(i=!0,cleanup(),t())}function settleReject(e){i||(i=!0,cleanup(),n(e))}u.once(`error`,settleReject),Promise.all([readPublicationLockState(r),pathExists(r),pathExists(`${r}.recovery`)]).then(([e,t,n])=>{(!t&&!n||e!==c)&&settleResolve()},settleReject)})}async function readPublicationLockState(e){let t=`${e}.recovery`,[n,r,a,o]=await Promise.all([readOutputPublicationJournal(e),readRecoveryLeaseJournal(join(t,`lease`)),pathExists(e),pathExists(t)]);return JSON.stringify({lockExists:a,lockToken:n?.token,recoveryExists:o,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,resolveOutputPublicationLockPath,startPublicationJournalHeartbeat};
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.24.2`,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 isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let n=e;for(;;){if(existsSync(join(n,`package.json`))&&!isBuildOutputPackageRoot(n))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve package root from "${e}".`);n=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}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){return require.resolve(e)}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 r=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(r?.name===t)return r}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,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{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.24.4`,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 isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let n=e;for(;;){if(existsSync(join(n,`package.json`))&&!isBuildOutputPackageRoot(n))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve package root from "${e}".`);n=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}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){return require.resolve(e)}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 r=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(r?.name===t)return r}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,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{existsSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{readFile,readdir}from"node:fs/promises";import{parse as parse$1}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$1(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 n of resolveTsConfigExtendsTargetPaths(e))if(existsSync(n))return n}function resolveFileExtendsCandidates(e){let t=resolve(dirname(e.configPath),e.extendsSpecifier),r=new Set;return r.add(t),t.endsWith(`.json`)||(r.add(`${t}.json`),r.add(join(t,`tsconfig.json`))),[...r]}function resolvePackageExtendsCandidates(t){let n=new Set([t.extendsSpecifier]);t.extendsSpecifier.endsWith(`.json`)||(n.add(`${t.extendsSpecifier}.json`),n.add(`${t.extendsSpecifier}/tsconfig.json`));let r=new Set,i=createRequire(t.configPath);for(let e of n)try{r.add(i.resolve(e))}catch{}return[...r]}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{existsSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{readFile,readdir}from"node:fs/promises";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 n of resolveTsConfigExtendsTargetPaths(e))if(existsSync(n))return n}function resolveFileExtendsCandidates(e){let t=resolve(dirname(e.configPath),e.extendsSpecifier),r=new Set;return r.add(t),t.endsWith(`.json`)||(r.add(`${t}.json`),r.add(join(t,`tsconfig.json`))),[...r]}function resolvePackageExtendsCandidates(t){let n=new Set([t.extendsSpecifier]);t.extendsSpecifier.endsWith(`.json`)||(n.add(`${t.extendsSpecifier}.json`),n.add(`${t.extendsSpecifier}/tsconfig.json`));let r=new Set,i=createRequire(t.configPath);for(let e of n)try{r.add(i.resolve(e))}catch{}return[...r]}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,4 +1,3 @@
1
- import type { ResolvedAuthoredExternalModule } from "#internal/materialize-authored-external-dependencies.js";
2
1
  export interface AuthoredModuleLoadOptions {
3
2
  readonly externalDependencies?: readonly string[];
4
3
  /**
@@ -8,10 +7,6 @@ export interface AuthoredModuleLoadOptions {
8
7
  */
9
8
  readonly extensionScopeNamespace?: string;
10
9
  }
11
- export interface AuthoredGenerationModuleBundle {
12
- readonly code: string;
13
- readonly externalModules: readonly ResolvedAuthoredExternalModule[];
14
- }
15
10
  /**
16
11
  * Loads one authored module namespace from disk during compile-time
17
12
  * discovery. Concurrent loads of the same `modulePath` share a single
@@ -26,8 +21,7 @@ export declare function bundleAuthoredModuleCode(modulePath: string, options?: A
26
21
  /**
27
22
  * Bundles one authored entry for an immutable development generation. Ordinary
28
23
  * package dependencies are inlined so the emitted code stays executable after
29
- * the original workspace changes; framework runtime imports and configured
30
- * external dependencies stay external, and every configured external the
31
- * bundle references is reported for closure materialization.
24
+ * the original workspace changes; framework runtime imports and explicitly
25
+ * configured external dependencies keep their normal runtime resolution.
32
26
  */
33
- export declare function bundleAuthoredModuleForGeneration(modulePath: string, options?: AuthoredModuleLoadOptions): Promise<AuthoredGenerationModuleBundle>;
27
+ export declare function bundleAuthoredModuleForGeneration(modulePath: string, options?: AuthoredModuleLoadOptions): Promise<string>;
@@ -1,4 +1,4 @@
1
- import{expectObjectRecord}from"#internal/authored-module.js";import{existsSync,mkdirSync,statSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{createHash}from"node:crypto";import{buildWithNitroRolldown,getSingleRolldownChunk}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{assertNoWorkflowDirectivePrologue}from"#internal/authored-directive-prologue.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createFixedNamespaceScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),CHANNEL_MODULE_CACHE_KEY=`__eveChannelModuleCache__`;function getChannelModuleCache(){return globalThis[CHANNEL_MODULE_CACHE_KEY]}const 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(t,n){return expectObjectRecord(AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)?await loadBundledAuthoredModule(t,n):await import(createFileImportSpecifier(t)),`Expected "${t}" 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={}){return await buildAuthoredModuleBundle(e,t,{channelIdentity:!0,packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){let n=new Map;return{code:removeRolldownModuleRegionComments(await buildAuthoredModuleBundle(e,t,{channelIdentity:!1,packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e),recordExternalModule(e){n.set(`${e.packageName}\0${e.resolvedId}`,e)}}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1})),externalModules:[...n.values()].sort((e,t)=>`${e.packageName}\0${e.resolvedId}`.localeCompare(`${t.packageName}\0${t.resolvedId}`))}}async function buildAuthoredModuleBundle(e,t,n){let r=n.channelIdentity?getChannelModuleCache():void 0,i=resolveAuthoredPackageRoot(e),a=resolveAuthoredTsConfigPath(i),o=[r&&r.size>0?{name:`eve-channel-identity`,async resolveId(e,t,n){if(!/channels[/\\]/.test(e)||n.kind!==`import-statement`)return;let i=await this.resolve(e,t,{kind:n.kind,skipSelf:!0});if(i===null||typeof i.id!=`string`)return;let a=resolve(i.id);if(r.has(a))return{id:`${CACHED_CHANNEL_PREFIX}${a}`}},load(e){if(!e.startsWith(CACHED_CHANNEL_PREFIX))return;let t=e.slice(CACHED_CHANNEL_PREFIX.length);return{code:[`const cache = globalThis["${CHANNEL_MODULE_CACHE_KEY}"];`,`export default cache.get(${JSON.stringify(t)});`].join(`
2
- `),moduleType:`js`}}}:null,...n.plugins,t.extensionScopeNamespace===void 0?null:createFixedNamespaceScopePlugin(t.extensionScopeNamespace),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin(),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:i,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),n.packageBoundaryPlugin].filter(e=>e!==null);try{return getSingleRolldownChunk(await buildWithNitroRolldown({cwd:i,input:e,platform:`node`,plugins:o,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:a,write:!1,output:{comments:!1,format:`esm`,sourcemap:n.sourcemap}}),`authored module for "${e}"`).code}catch(t){throw createAuthoredModuleBundleError(e,t)}}function createAuthoredDirectiveGuardPlugin(){return{name:`eve-authored-directive-guard`,async transform(e,t){!AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)||isNodeModulesPath(t)||await assertNoWorkflowDirectivePrologue({filePath:t,source:e})}}}function removeRolldownModuleRegionComments(e){return e.split(`
1
+ import{expectObjectRecord}from"#internal/authored-module.js";import{existsSync,mkdirSync,statSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{createHash}from"node:crypto";import{buildSingleRolldownChunk}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{assertNoWorkflowDirectivePrologue}from"#internal/authored-directive-prologue.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createFixedNamespaceScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),CHANNEL_MODULE_CACHE_KEY=`__eveChannelModuleCache__`;function getChannelModuleCache(){return globalThis[CHANNEL_MODULE_CACHE_KEY]}const 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(t,n){return expectObjectRecord(AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)?await loadBundledAuthoredModule(t,n):await import(createFileImportSpecifier(t)),`Expected "${t}" 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={}){return await buildAuthoredModuleBundle(e,t,{channelIdentity:!0,packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){return removeRolldownModuleRegionComments(await buildAuthoredModuleBundle(e,t,{channelIdentity:!1,packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1}))}async function buildAuthoredModuleBundle(e,t,n){let r=n.channelIdentity?getChannelModuleCache():void 0,i=resolveAuthoredPackageRoot(e),a=resolveAuthoredTsConfigPath(i),o=[r&&r.size>0?{name:`eve-channel-identity`,async resolveId(e,t,n){if(!/channels[/\\]/.test(e)||n.kind!==`import-statement`)return;let i=await this.resolve(e,t,{kind:n.kind,skipSelf:!0});if(i===null||typeof i.id!=`string`)return;let a=resolve(i.id);if(r.has(a))return{id:`${CACHED_CHANNEL_PREFIX}${a}`}},load(e){if(!e.startsWith(CACHED_CHANNEL_PREFIX))return;let t=e.slice(CACHED_CHANNEL_PREFIX.length);return{code:[`const cache = globalThis["${CHANNEL_MODULE_CACHE_KEY}"];`,`export default cache.get(${JSON.stringify(t)});`].join(`
2
+ `),moduleType:`js`}}}:null,...n.plugins,t.extensionScopeNamespace===void 0?null:createFixedNamespaceScopePlugin(t.extensionScopeNamespace),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin(),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:i,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),n.packageBoundaryPlugin].filter(e=>e!==null);try{return(await buildSingleRolldownChunk(`authored module for "${e}"`,{cwd:i,input:e,platform:`node`,plugins:o,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:a,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){!AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)||isNodeModulesPath(t)||await assertNoWorkflowDirectivePrologue({filePath:t,source:e})}}}function removeRolldownModuleRegionComments(e){return e.split(`
3
3
  `).filter(e=>!e.startsWith(`//#region `)&&e!==`//#endregion`).join(`
4
4
  `)}async function loadBundledAuthoredModule(e,r){let a=await bundleAuthoredModuleCode(e,r),o=normalizeExternalDependencies(r.externalDependencies),s=createHash(`sha1`).update(e).update(`\0`).update(o.join(`\0`)).update(`\0`).update(r.extensionScopeNamespace??``).update(`\0`).update(a).digest(`hex`),c=join(resolveAuthoredPackageRoot(e),AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH),l=join(c,`${s}.mjs`);return existsSync(l)||(mkdirSync(c,{recursive:!0}),writeFileSync(l,a)),await import(`${createFileImportSpecifier(l)}?v=${s}`)}function createAuthoredRelativeExtensionResolverPlugin(e){return{name:`eve-authored-relative-extension-resolver`,resolveId(t,n){if(n===void 0||n.startsWith(`\0`)||n.startsWith(CACHED_CHANNEL_PREFIX)||!isPathImport(t))return;let r=resolveExistingImportPath(isAbsolute(t)?t:resolve(dirname(n),t),e.extensions);if(r!==void 0)return{id:r}}}}function createInFlightModuleLoadKey(e,t){return`${e}\0${normalizeExternalDependencies(t.externalDependencies).join(`\0`)}\0${t.extensionScopeNamespace??``}`}function resolveExistingImportPath(e,t){if(isFile(e))return e;for(let n of t){let t=`${e}${n}`;if(isFile(t))return t}for(let n of t){let t=join(e,`index${n}`);if(isFile(t))return t}}function isFile(e){try{return statSync(e).isFile()}catch{return!1}}function resolveAuthoredTsConfigPath(e){for(let n of[`tsconfig.json`,`jsconfig.json`]){let r=join(e,n);if(existsSync(r))return r}return!1}function resolveAuthoredPackageRoot(e){let n=dirname(e);for(;;){if(existsSync(join(n,`package.json`)))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve the authored package root for "${e}".`);n=r}}export{bundleAuthoredModuleCode,bundleAuthoredModuleForGeneration,loadAuthoredModuleNamespace};
@@ -1,4 +1,3 @@
1
- import type { ResolvedAuthoredExternalModule } from "#internal/materialize-authored-external-dependencies.js";
2
1
  export declare const CACHED_CHANNEL_PREFIX = "eve-cached-channel:";
3
2
  export declare const RESOLVE_EXTENSIONS: readonly [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".json"];
4
3
  type RolldownResolveResult = {
@@ -13,7 +12,6 @@ export type RolldownResolveContext = {
13
12
  export declare function createGenerationPackageBoundaryPlugin(input: {
14
13
  readonly externalDependencies: readonly string[];
15
14
  readonly packageRoot: string;
16
- readonly recordExternalModule: (externalModule: ResolvedAuthoredExternalModule) => void;
17
15
  }): Record<string, unknown>;
18
16
  export declare function createRuntimeLoaderPackageBoundaryPlugin(input: {
19
17
  readonly externalDependencies: readonly string[];
@@ -1 +1 @@
1
- import{existsSync,realpathSync}from"node:fs";import{join,resolve,sep}from"node:path";import{SERVER_EXTERNAL_PACKAGES}from"#internal/nitro/host/server-external-packages.js";const CACHED_CHANNEL_PREFIX=`eve-cached-channel:`,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))return;if(isFrameworkRuntimeImport(t,n))return{external:!0,id:t};let i=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:n,kind:r.kind,packageRoot:e.packageRoot,source:t});if(i!==void 0)return e.recordExternalModule(i),{external:!0,id:t}}}}function createRuntimeLoaderPackageBoundaryPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-runtime-loader-package-boundary`,async resolveId(n,i,a){if(!isPackageImport(n))return;if(isFrameworkRuntimeImport(n,i))return{external:!0,id:n};let o=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:i,kind:a.kind,packageRoot:e.packageRoot,source:n});if(o!==void 0)return{external:!0,id:resolveExistingExternalFilePath(o.resolvedId)??o.resolvedId};let s=i===void 0||i.startsWith(`\0`)||i.startsWith(`eve-cached-channel:`)?void 0:resolve(i);if(s!==void 0&&isPathInsideOrEqual(toCanonicalPath(s),t)){let e=await this.resolve(n,i,{kind:a.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`)throw Error(`Cannot resolve package "${n}" imported from "${s}". 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}}}}}async function resolveConfiguredExternalModule(e){let t=resolveConfiguredExternalDependency(e.source,e.externalDependencies);if(t===void 0)return;let r=await this.resolve(e.source,e.importer,{kind:e.kind,skipSelf:!0});if(r===null&&(r=await this.resolve(e.source,join(e.packageRoot,`package.json`),{kind:e.kind,skipSelf:!0})),r===null||typeof r.id!=`string`)throw Error(`Cannot resolve external package "${e.source}".`);return{packageName:t,resolvedId:r.id}}function normalizeExternalDependencies(e=[]){return[...new Set([...SERVER_EXTERNAL_PACKAGES,...e])].sort()}function resolveConfiguredExternalDependency(e,t){return t.find(t=>e===t||e.startsWith(`${t}/`))}function resolveExistingExternalFilePath(t){if(existsSync(t))return t;for(let n of RESOLVE_EXTENSIONS){let r=`${t}${n}`;if(existsSync(r))return r}}function isPackageImport(e){return isPathImport(e)||/^(?:node|data|file):/.test(e)||e.startsWith(`@/`)?!1:!e.startsWith(CACHED_CHANNEL_PREFIX)}function isPathImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function isFrameworkRuntimeImport(e,t){return e===`eve`||e.startsWith(`eve/`)?!0:e===`workflow`||e.startsWith(`workflow/`)||e.startsWith(`@workflow/`)?t===void 0||!isNodeModulesPath(t):!1}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),a=resolve(t);return n===a||n.startsWith(`${a}${sep}`)}export{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies};
1
+ import{existsSync,realpathSync}from"node:fs";import{join,resolve,sep}from"node:path";const CACHED_CHANNEL_PREFIX=`eve-cached-channel:`,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)&&(isFrameworkRuntimeImport(t,n)||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,i,a){if(!isPackageImport(n))return;if(isFrameworkRuntimeImport(n,i))return{external:!0,id:n};let o=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:i,kind:a.kind,packageRoot:e.packageRoot,source:n});if(o!==void 0)return{external:!0,id:resolveExistingExternalFilePath(o.resolvedId)??o.resolvedId};let s=i===void 0||i.startsWith(`\0`)||i.startsWith(`eve-cached-channel:`)?void 0:resolve(i);if(s!==void 0&&isPathInsideOrEqual(toCanonicalPath(s),t)){let e=await this.resolve(n,i,{kind:a.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`)throw Error(`Cannot resolve package "${n}" imported from "${s}". 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}}}}}async function resolveConfiguredExternalModule(e){let t=resolveConfiguredExternalDependency(e.source,e.externalDependencies);if(t===void 0)return;let r=await this.resolve(e.source,e.importer,{kind:e.kind,skipSelf:!0});if(r===null&&(r=await this.resolve(e.source,join(e.packageRoot,`package.json`),{kind:e.kind,skipSelf:!0})),r===null||typeof r.id!=`string`)throw Error(`Cannot resolve external package "${e.source}".`);return{packageName:t,resolvedId:r.id}}function normalizeExternalDependencies(e=[]){return[...new Set(e)].sort()}function resolveConfiguredExternalDependency(e,t){return t.find(t=>e===t||e.startsWith(`${t}/`))}function resolveExistingExternalFilePath(t){if(existsSync(t))return t;for(let n of RESOLVE_EXTENSIONS){let r=`${t}${n}`;if(existsSync(r))return r}}function isPackageImport(e){return isPathImport(e)||/^(?:node|data|file):/.test(e)||e.startsWith(`@/`)?!1:!e.startsWith(CACHED_CHANNEL_PREFIX)}function isPathImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function isFrameworkRuntimeImport(e,t){return e===`eve`||e.startsWith(`eve/`)?!0:e===`workflow`||e.startsWith(`workflow/`)||e.startsWith(`@workflow/`)?t===void 0||!isNodeModulesPath(t):!1}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),a=resolve(t);return n===a||n.startsWith(`${a}${sep}`)}export{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies};
@@ -1 +1 @@
1
- import{dirname,join,resolve,sep}from"node:path";import{readFile,stat}from"node:fs/promises";import{parse as parse$1}from"#compiled/jsonc-parser/index.js";const packageTsConfigPathsCache=new Map,nearestPackageRootCache=new Map;function createAuthoredPackageTsConfigPathsPlugin(e){return{name:`eve-package-tsconfig-paths`,async resolveId(t,r,i){if(r===void 0||!isPackageImport(t))return;let a=resolve(r);if(isPathInsideOrEqual(a,e.appPackageRoot))return;let o=await resolveNearestPackageRoot(a);if(o===void 0||isPathInsideOrEqual(o,e.appPackageRoot))return;let s=await loadPackageTsConfigPaths(o);if(s!==void 0)for(let n of createTsConfigPathCandidates(t,s)){let t=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(t!==null)return t;let a=await resolveExistingPath(n,e.extensions);if(a!==void 0)return{id:a}}}}}function loadPackageTsConfigPaths(e){let t=packageTsConfigPathsCache.get(e);if(t!==void 0)return t;let n=readPackageTsConfigPaths(e);return packageTsConfigPathsCache.set(e,n),n}async function readPackageTsConfigPaths(t){let r=await readPackageConfig(t);if(r===void 0)return;let i=[],a=parse$1(r.source,i,{allowTrailingComma:!0});if(i.length>0||!isObjectRecord(a))return;let s=a.compilerOptions;if(!isObjectRecord(s)||!isObjectRecord(s.paths))return;let c=dirname(r.path),l=typeof s.baseUrl==`string`?resolve(c,s.baseUrl):c,u=Object.entries(s.paths).flatMap(([e,t])=>!Array.isArray(t)||!t.every(e=>typeof e==`string`)?[]:[{pattern:e,targets:t}]).sort((e,t)=>t.pattern.length-e.pattern.length);if(u.length!==0)return{baseDirectory:l,entries:u}}async function readPackageConfig(e){for(let n of[`tsconfig.json`,`jsconfig.json`]){let r=join(e,n);try{return{path:r,source:await readFile(r,`utf8`)}}catch(e){if(!isPathNotFoundError(e))throw e}}}function createTsConfigPathCandidates(e,t){let r=[];for(let i of t.entries){let a=matchTsConfigPathPattern(e,i.pattern);if(a!==void 0)for(let e of i.targets){let i=e.includes(`*`)?e.replaceAll(`*`,a):e;r.push(resolve(t.baseDirectory,i))}}return r}function matchTsConfigPathPattern(e,t){let n=t.indexOf(`*`);if(n===-1)return e===t?``:void 0;let r=t.slice(0,n),i=t.slice(n+1);if(!(!e.startsWith(r)||!e.endsWith(i)))return e.slice(r.length,e.length-i.length)}async function resolveExistingPath(e,n){if(await existsAsFile(e))return e;for(let t of n){let n=`${e}${t}`;if(await existsAsFile(n))return n}for(let r of n){let n=join(e,`index${r}`);if(await existsAsFile(n))return n}}async function existsAsFile(e){try{return(await stat(e)).isFile()}catch{return!1}}function resolveNearestPackageRoot(t){let n=dirname(t),r=nearestPackageRootCache.get(n);if(r!==void 0)return r;let i=findNearestPackageRoot(n);return nearestPackageRootCache.set(n,i),i}async function findNearestPackageRoot(n){let r=n;for(;;){if(await pathExists(join(r,`package.json`)))return r;let n=dirname(r);if(n===r)return;r=n}}async function pathExists(e){try{return await stat(e),!0}catch{return!1}}function isPathNotFoundError(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`)}function isPackageImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)?!1:!/^(?:node|data|file):/.test(e)}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function isPathInsideOrEqual(e,t){let i=resolve(e),a=resolve(t);return i===a||i.startsWith(`${a}${sep}`)}export{createAuthoredPackageTsConfigPathsPlugin};
1
+ import{dirname,join,resolve,sep}from"node:path";import{readFile,stat}from"node:fs/promises";import{parse}from"#compiled/jsonc-parser/index.js";const packageTsConfigPathsCache=new Map,nearestPackageRootCache=new Map;function createAuthoredPackageTsConfigPathsPlugin(e){return{name:`eve-package-tsconfig-paths`,async resolveId(t,r,i){if(r===void 0||!isPackageImport(t))return;let a=resolve(r);if(isPathInsideOrEqual(a,e.appPackageRoot))return;let o=await resolveNearestPackageRoot(a);if(o===void 0||isPathInsideOrEqual(o,e.appPackageRoot))return;let s=await loadPackageTsConfigPaths(o);if(s!==void 0)for(let n of createTsConfigPathCandidates(t,s)){let t=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(t!==null)return t;let a=await resolveExistingPath(n,e.extensions);if(a!==void 0)return{id:a}}}}}function loadPackageTsConfigPaths(e){let t=packageTsConfigPathsCache.get(e);if(t!==void 0)return t;let n=readPackageTsConfigPaths(e);return packageTsConfigPathsCache.set(e,n),n}async function readPackageTsConfigPaths(t){let r=await readPackageConfig(t);if(r===void 0)return;let i=[],a=parse(r.source,i,{allowTrailingComma:!0});if(i.length>0||!isObjectRecord(a))return;let s=a.compilerOptions;if(!isObjectRecord(s)||!isObjectRecord(s.paths))return;let c=dirname(r.path),l=typeof s.baseUrl==`string`?resolve(c,s.baseUrl):c,u=Object.entries(s.paths).flatMap(([e,t])=>!Array.isArray(t)||!t.every(e=>typeof e==`string`)?[]:[{pattern:e,targets:t}]).sort((e,t)=>t.pattern.length-e.pattern.length);if(u.length!==0)return{baseDirectory:l,entries:u}}async function readPackageConfig(e){for(let n of[`tsconfig.json`,`jsconfig.json`]){let r=join(e,n);try{return{path:r,source:await readFile(r,`utf8`)}}catch(e){if(!isPathNotFoundError(e))throw e}}}function createTsConfigPathCandidates(e,t){let r=[];for(let i of t.entries){let a=matchTsConfigPathPattern(e,i.pattern);if(a!==void 0)for(let e of i.targets){let i=e.includes(`*`)?e.replaceAll(`*`,a):e;r.push(resolve(t.baseDirectory,i))}}return r}function matchTsConfigPathPattern(e,t){let n=t.indexOf(`*`);if(n===-1)return e===t?``:void 0;let r=t.slice(0,n),i=t.slice(n+1);if(!(!e.startsWith(r)||!e.endsWith(i)))return e.slice(r.length,e.length-i.length)}async function resolveExistingPath(e,n){if(await existsAsFile(e))return e;for(let t of n){let n=`${e}${t}`;if(await existsAsFile(n))return n}for(let r of n){let n=join(e,`index${r}`);if(await existsAsFile(n))return n}}async function existsAsFile(e){try{return(await stat(e)).isFile()}catch{return!1}}function resolveNearestPackageRoot(t){let n=dirname(t),r=nearestPackageRootCache.get(n);if(r!==void 0)return r;let i=findNearestPackageRoot(n);return nearestPackageRootCache.set(n,i),i}async function findNearestPackageRoot(n){let r=n;for(;;){if(await pathExists(join(r,`package.json`)))return r;let n=dirname(r);if(n===r)return;r=n}}async function pathExists(e){try{return await stat(e),!0}catch{return!1}}function isPathNotFoundError(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`)}function isPackageImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)?!1:!/^(?:node|data|file):/.test(e)}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function isPathInsideOrEqual(e,t){let i=resolve(e),a=resolve(t);return i===a||i.startsWith(`${a}${sep}`)}export{createAuthoredPackageTsConfigPathsPlugin};
@@ -11,7 +11,6 @@ type RolldownOutputAsset = {
11
11
  type RolldownOutput = {
12
12
  readonly output: readonly [RolldownOutputChunk, ...(RolldownOutputChunk | RolldownOutputAsset)[]];
13
13
  };
14
- export type RolldownBuild = (options: Record<string, unknown>) => Promise<RolldownOutput>;
15
14
  type RolldownParseAst = (sourceText: string, options?: Record<string, unknown> | null, filename?: string) => unknown;
16
15
  export type RolldownParserLanguage = "js" | "jsx" | "ts" | "tsx";
17
16
  type RolldownParseAstModule = {
@@ -24,6 +23,23 @@ type RolldownParseAstModule = {
24
23
  export declare function loadNitroRolldownParseAst(): Promise<RolldownParseAstModule>;
25
24
  export declare function inferRolldownParserLanguage(filename: string): RolldownParserLanguage;
26
25
  export declare function parseWithNitroRolldownAst(filename: string, sourceText: string): Promise<unknown>;
26
+ /**
27
+ * Runs a raw Rolldown build. Prefer {@link buildSingleRolldownChunk} for any
28
+ * bundle whose consumer expects one in-memory file; use this directly only
29
+ * for multi-file, written-to-disk output.
30
+ */
27
31
  export declare function buildWithNitroRolldown(options: Record<string, unknown>): Promise<RolldownOutput>;
28
- export declare function getSingleRolldownChunk(output: RolldownOutput, description: string): RolldownOutputChunk;
32
+ /**
33
+ * Runs a Rolldown build whose contract is exactly one in-memory chunk:
34
+ * code splitting is disabled and the result is asserted to contain a
35
+ * single JavaScript chunk, so dynamic imports are inlined rather than
36
+ * split into lazy chunks. Every eve single-file bundle (the authored-module
37
+ * evaluator, immutable development generations, and workflow step/function
38
+ * bundles) goes through this helper so the single-file policy and its
39
+ * assertion cannot drift apart. The final Nitro production server build
40
+ * does not use it and keeps code splitting enabled.
41
+ */
42
+ export declare function buildSingleRolldownChunk(description: string, options: Record<string, unknown> & {
43
+ readonly output?: Record<string, unknown>;
44
+ }): Promise<RolldownOutputChunk>;
29
45
  export {};
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{pathToFileURL}from"node:url";let rolldownPromise,rolldownParseAstPromise;function loadNitroRolldown(){return rolldownPromise??=(async()=>await import(pathToFileURL(createRequire(createRequire(import.meta.url).resolve(`nitro/package.json`)).resolve(`rolldown`)).href))(),rolldownPromise}function loadNitroRolldownParseAst(){return rolldownParseAstPromise??=(async()=>await import(pathToFileURL(createRequire(createRequire(import.meta.url).resolve(`nitro/package.json`)).resolve(`rolldown/parseAst`)).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){let{build:t}=await loadNitroRolldown();return await t(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{buildWithNitroRolldown,getSingleRolldownChunk,inferRolldownParserLanguage,loadNitroRolldownParseAst,parseWithNitroRolldownAst};
1
+ import{createRequire}from"node:module";import{pathToFileURL}from"node:url";let rolldownPromise,rolldownParseAstPromise;function loadNitroRolldown(){return rolldownPromise??=(async()=>await import(pathToFileURL(createRequire(createRequire(import.meta.url).resolve(`nitro/package.json`)).resolve(`rolldown`)).href))(),rolldownPromise}function loadNitroRolldownParseAst(){return rolldownParseAstPromise??=(async()=>await import(pathToFileURL(createRequire(createRequire(import.meta.url).resolve(`nitro/package.json`)).resolve(`rolldown/parseAst`)).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){let{build:t}=await loadNitroRolldown();return await t(e)}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{buildSingleRolldownChunk,buildWithNitroRolldown,inferRolldownParserLanguage,loadNitroRolldownParseAst,parseWithNitroRolldownAst};
@@ -0,0 +1,5 @@
1
+ import type { CompiledAgentManifest } from "#compiler/manifest.js";
2
+ export declare function serializeCompiledManifestForFingerprint(input: {
3
+ readonly manifest: CompiledAgentManifest;
4
+ readonly runtimeAppRoot: string;
5
+ }): string;
@@ -0,0 +1 @@
1
+ import{isAbsolute,relative,sep}from"node:path";const RUNTIME_ROOT_TOKEN=`$runtime`;function serializeCompiledManifestForFingerprint(e){return JSON.stringify(normalizeValue(e.manifest,e.runtimeAppRoot))}function normalizeValue(e,t){return typeof e==`string`?normalizeRuntimePath(e,t):Array.isArray(e)?e.map(e=>normalizeValue(e,t)):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>[e,normalizeValue(n,t)]))}function normalizeRuntimePath(r,i){if(!isAbsolute(r))return r;let a=relative(i,r);return a===``?RUNTIME_ROOT_TOKEN:a===`..`||a.startsWith(`..${sep}`)||isAbsolute(a)?r:`${RUNTIME_ROOT_TOKEN}/${a.split(sep).join(`/`)}`}export{serializeCompiledManifestForFingerprint};
@@ -7,9 +7,6 @@ export interface MaterializedAuthoredModuleIndex {
7
7
  readonly version: 1;
8
8
  }
9
9
  export declare function materializeAuthoredModules(input: {
10
- readonly appRoot: string;
11
10
  readonly runtimeAppRoot: string;
12
- readonly snapshotSourceRoot: string;
13
- readonly sourceRoot: string;
14
11
  }): Promise<MaterializedAuthoredModuleIndex>;
15
12
  export declare function readMaterializedAuthoredModuleIndex(runtimeAppRoot: string): Promise<MaterializedAuthoredModuleIndex | undefined>;
@@ -1 +1 @@
1
- import{existsSync}from"node:fs";import{join,relative,sep}from"node:path";import{lstat,mkdir,readFile,readdir,readlink,writeFile}from"node:fs/promises";import{createHash}from"node:crypto";import{collectModuleRefsForManifest}from"#compiler/module-map.js";import{COMPILED_AGENT_MANIFEST_KIND,ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{bundleAuthoredModuleForGeneration}from"#internal/authored-module-loader.js";import{materializeAuthoredExternalDependencies}from"#internal/materialize-authored-external-dependencies.js";const MATERIALIZED_MODULES_DIRECTORY=`authored-modules`,MATERIALIZED_MODULES_INDEX=`authored-modules.json`,INSTRUMENTATION_EXTENSIONS=[`.ts`,`.mts`,`.js`,`.mjs`];async function materializeAuthoredModules(e){let n=join(e.runtimeAppRoot,`.eve`,`compile`),r=await readCompiledManifest(join(n,`compiled-agent-manifest.json`)),i=join(n,MATERIALIZED_MODULES_DIRECTORY),o=createExtensionScopeIndex(r),s={},c=[],u=createHash(`sha256`);await mkdir(i,{recursive:!0});for(let e of collectNodeManifests(r)){let n={};for(let r of collectModuleRefsForManifest(e.manifest).sort((e,t)=>e.sourceId.localeCompare(t.sourceId))){let a=await bundleAuthoredModuleForGeneration(join(e.agentRoot,r.logicalPath),{externalDependencies:e.manifest.config.build?.externalDependencies??[],extensionScopeNamespace:extensionNamespaceForSourceId(r.sourceId,o)}),s=createMaterializedModuleFileName(e.nodeId,r.sourceId,a.code);await writeFile(join(i,s),a.code),c.push(...a.externalModules),u.update(`module\0`).update(e.nodeId).update(`\0`).update(r.sourceId).update(`\0`).update(a.code).update(`\0`),n[r.sourceId]=join(MATERIALIZED_MODULES_DIRECTORY,s)}s[e.nodeId]={modules:n}}let d=resolveInstrumentationModule(r.agentRoot),f;if(d!==void 0){let e=await bundleAuthoredModuleForGeneration(d,{externalDependencies:r.config.build?.externalDependencies??[]}),n=createMaterializedModuleFileName(ROOT_COMPILED_AGENT_NODE_ID,`instrumentation`,e.code);await writeFile(join(i,n),e.code),c.push(...e.externalModules),f=join(MATERIALIZED_MODULES_DIRECTORY,n),u.update(`instrumentation\0`).update(e.code).update(`\0`)}await hashDirectoryIfPresent({fingerprint:u,path:join(n,`workspace-resources`),root:join(n,`workspace-resources`)}),u.update(`external-dependencies\0`).update(await materializeAuthoredExternalDependencies({appRoot:e.appRoot,externalModules:c,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot})).update(`\0`);let p={fingerprint:u.digest(`hex`),nodes:s,version:1};return f!==void 0&&(p.instrumentation=f),await writeFile(join(n,MATERIALIZED_MODULES_INDEX),`${JSON.stringify(p)}\n`),p}async function readMaterializedAuthoredModuleIndex(n){let r=join(n,`.eve`,`compile`,MATERIALIZED_MODULES_INDEX);if(!existsSync(r))return;let i=JSON.parse(await readFile(r,`utf8`));if(i.version!==1||typeof i.fingerprint!=`string`||i.fingerprint.length===0||typeof i.nodes!=`object`||i.nodes===null||i.instrumentation!==void 0&&typeof i.instrumentation!=`string`)throw Error(`Invalid materialized authored module index at "${r}".`);return i}function collectNodeManifests(e){return[{agentRoot:e.agentRoot,manifest:e,nodeId:ROOT_COMPILED_AGENT_NODE_ID},...[...e.subagents].sort((e,t)=>e.nodeId.localeCompare(t.nodeId)).map(e=>({agentRoot:e.agent.agentRoot,manifest:e.agent,nodeId:e.nodeId}))]}function createExtensionScopeIndex(e){return{byMountNamespace:new Map(e.extensionMounts.map(e=>[e.namespace,e.packageNamespace]))}}function extensionNamespaceForSourceId(e,t){let n=e.match(/^ext:([^:]+):/u);return n===null?void 0:t.byMountNamespace.get(n[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 resolveInstrumentationModule(n){for(let r of INSTRUMENTATION_EXTENSIONS){let i=join(n,`instrumentation${r}`);if(existsSync(i))return i}}function createMaterializedModuleFileName(e,t,n){return`${createHash(`sha256`).update(e).update(`\0`).update(t).update(`\0`).update(n).digest(`hex`)}.mjs`}async function hashDirectoryIfPresent(r){if(!existsSync(r.path))return;let a=await lstat(r.path),l=toPortablePath(relative(r.root,r.path));if(a.isSymbolicLink()){r.fingerprint.update(l).update(`\0link\0`).update(await readlink(r.path)).update(`\0`);return}if(a.isDirectory()){for(let e of(await readdir(r.path)).sort())await hashDirectoryIfPresent({...r,path:join(r.path,e)});return}a.isFile()&&r.fingerprint.update(l).update(`\0file\0`).update(await readFile(r.path)).update(`\0`)}function toPortablePath(e){return e.split(sep).join(`/`)}export{materializeAuthoredModules,readMaterializedAuthoredModuleIndex};
1
+ import{existsSync}from"node:fs";import{join,relative,sep}from"node:path";import{lstat,mkdir,readFile,readdir,readlink,writeFile}from"node:fs/promises";import{createHash}from"node:crypto";import{collectModuleRefsForManifest}from"#compiler/module-map.js";import{COMPILED_AGENT_MANIFEST_KIND,ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{bundleAuthoredModuleForGeneration}from"#internal/authored-module-loader.js";import{serializeCompiledManifestForFingerprint}from"#internal/compiled-manifest-fingerprint.js";const MATERIALIZED_MODULES_DIRECTORY=`authored-modules`,MATERIALIZED_MODULES_INDEX=`authored-modules.json`,INSTRUMENTATION_EXTENSIONS=[`.ts`,`.mts`,`.js`,`.mjs`];async function materializeAuthoredModules(e){let n=join(e.runtimeAppRoot,`.eve`,`compile`),r=await readCompiledManifest(join(n,`compiled-agent-manifest.json`)),i=join(n,MATERIALIZED_MODULES_DIRECTORY),o=createExtensionScopeIndex(r),s={},c=createHash(`sha256`);await mkdir(i,{recursive:!0}),c.update(`manifest\0`).update(serializeCompiledManifestForFingerprint({manifest:r,runtimeAppRoot:e.runtimeAppRoot})).update(`\0`);for(let e of collectNodeManifests(r)){let n={};for(let r of collectModuleRefsForManifest(e.manifest).sort((e,t)=>e.sourceId.localeCompare(t.sourceId))){let a=await bundleAuthoredModuleForGeneration(join(e.agentRoot,r.logicalPath),{externalDependencies:e.manifest.config.build?.externalDependencies??[],extensionScopeNamespace:extensionNamespaceForSourceId(r.sourceId,o)}),s=createMaterializedModuleFileName(e.nodeId,r.sourceId,a);await writeFile(join(i,s),a),c.update(`module\0`).update(e.nodeId).update(`\0`).update(r.sourceId).update(`\0`).update(a).update(`\0`),n[r.sourceId]=join(MATERIALIZED_MODULES_DIRECTORY,s)}s[e.nodeId]={modules:n}}let u=resolveInstrumentationModule(r.agentRoot),d;if(u!==void 0){let e=await bundleAuthoredModuleForGeneration(u,{externalDependencies:r.config.build?.externalDependencies??[]}),n=createMaterializedModuleFileName(ROOT_COMPILED_AGENT_NODE_ID,`instrumentation`,e);await writeFile(join(i,n),e),d=join(MATERIALIZED_MODULES_DIRECTORY,n),c.update(`instrumentation\0`).update(e).update(`\0`)}await hashDirectoryIfPresent({fingerprint:c,path:join(n,`workspace-resources`),root:join(n,`workspace-resources`)});let f={fingerprint:c.digest(`hex`),nodes:s,version:1};return d!==void 0&&(f.instrumentation=d),await writeFile(join(n,MATERIALIZED_MODULES_INDEX),`${JSON.stringify(f)}\n`),f}async function readMaterializedAuthoredModuleIndex(n){let r=join(n,`.eve`,`compile`,MATERIALIZED_MODULES_INDEX);if(!existsSync(r))return;let i=JSON.parse(await readFile(r,`utf8`));if(i.version!==1||typeof i.fingerprint!=`string`||i.fingerprint.length===0||typeof i.nodes!=`object`||i.nodes===null||i.instrumentation!==void 0&&typeof i.instrumentation!=`string`)throw Error(`Invalid materialized authored module index at "${r}".`);return i}function collectNodeManifests(e){return[{agentRoot:e.agentRoot,manifest:e,nodeId:ROOT_COMPILED_AGENT_NODE_ID},...[...e.subagents].sort((e,t)=>e.nodeId.localeCompare(t.nodeId)).map(e=>({agentRoot:e.agent.agentRoot,manifest:e.agent,nodeId:e.nodeId}))]}function createExtensionScopeIndex(e){return{byMountNamespace:new Map(e.extensionMounts.map(e=>[e.namespace,e.packageNamespace]))}}function extensionNamespaceForSourceId(e,t){let n=e.match(/^ext:([^:]+):/u);return n===null?void 0:t.byMountNamespace.get(n[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 resolveInstrumentationModule(n){for(let r of INSTRUMENTATION_EXTENSIONS){let i=join(n,`instrumentation${r}`);if(existsSync(i))return i}}function createMaterializedModuleFileName(e,t,n){return`${createHash(`sha256`).update(e).update(`\0`).update(t).update(`\0`).update(n).digest(`hex`)}.mjs`}async function hashDirectoryIfPresent(r){if(!existsSync(r.path))return;let a=await lstat(r.path),l=toPortablePath(relative(r.root,r.path));if(a.isSymbolicLink()){r.fingerprint.update(l).update(`\0link\0`).update(await readlink(r.path)).update(`\0`);return}if(a.isDirectory()){for(let e of(await readdir(r.path)).sort())await hashDirectoryIfPresent({...r,path:join(r.path,e)});return}a.isFile()&&r.fingerprint.update(l).update(`\0file\0`).update(await readFile(r.path)).update(`\0`)}function toPortablePath(e){return e.split(sep).join(`/`)}export{materializeAuthoredModules,readMaterializedAuthoredModuleIndex};
@@ -0,0 +1,22 @@
1
+ import type { IncomingHttpHeaders } from "node:http";
2
+ export declare const DEVELOPMENT_CLIENT_ADDRESS_HEADER = "x-eve-dev-client-address";
3
+ export declare const DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER = "x-eve-dev-client-address-signature";
4
+ /**
5
+ * Stamps the accepted socket's peer address onto a request bound for the
6
+ * dev worker. Public copies of the metadata headers are dropped first, and
7
+ * the value is signed with the per-process dev transport secret: the
8
+ * worker's own HTTP port is reachable by other local processes, so an
9
+ * unsigned header could be forged by anything that discovers it.
10
+ */
11
+ export declare function stampDevelopmentClientAddress(headers: Headers | IncomingHttpHeaders, address: string | undefined, secret: string | undefined): void;
12
+ /**
13
+ * Returns the parent-stamped client address when its signature verifies,
14
+ * `undefined` otherwise. Callers fall back to the socket peer, which in the
15
+ * proxied dev topology is the parent's loopback hop.
16
+ */
17
+ export declare function readTrustedDevelopmentClientAddress(headers: Headers, secret: string | undefined): string | undefined;
18
+ /**
19
+ * Constant-time string comparison over fixed-length digests, so neither the
20
+ * length nor the content of a secret comparison leaks through timing.
21
+ */
22
+ export declare function timingSafeEqualStrings(a: string, b: string): boolean;
@@ -0,0 +1 @@
1
+ import{createHash,createHmac,timingSafeEqual}from"node:crypto";const DEVELOPMENT_CLIENT_ADDRESS_HEADER=`x-eve-dev-client-address`,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER=`x-eve-dev-client-address-signature`;function stampDevelopmentClientAddress(e,t,n){deleteHeader(e,DEVELOPMENT_CLIENT_ADDRESS_HEADER),deleteHeader(e,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER),!(t===void 0||t.length===0||n===void 0||n.length===0)&&(setHeader(e,DEVELOPMENT_CLIENT_ADDRESS_HEADER,t),setHeader(e,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER,signClientAddress(t,n)))}function readTrustedDevelopmentClientAddress(e,t){let n=e.get(DEVELOPMENT_CLIENT_ADDRESS_HEADER),i=e.get(DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER);if(!(n===null||i===null||t===void 0||t.length===0||!timingSafeEqualStrings(i,signClientAddress(n,t))))return n}function timingSafeEqualStrings(t,r){return timingSafeEqual(createHash(`sha256`).update(t).digest(),createHash(`sha256`).update(r).digest())}function signClientAddress(e,n){return createHmac(`sha256`,n).update(e).digest(`base64url`)}function deleteHeader(e,t){if(e instanceof Headers){e.delete(t);return}delete e[t]}function setHeader(e,t,n){if(e instanceof Headers){e.set(t,n);return}e[t]=n}export{DEVELOPMENT_CLIENT_ADDRESS_HEADER,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER,readTrustedDevelopmentClientAddress,stampDevelopmentClientAddress,timingSafeEqualStrings};
@@ -0,0 +1,12 @@
1
+ export declare const DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER = "activated";
2
+ /** Records the instant at which an activated generation stopped being current. */
3
+ export declare function recordRetiredDevelopmentRuntimeArtifactsSnapshot(snapshotRoot: string, retiredAt?: number): Promise<void>;
4
+ /** Applies the bounded retention policy within one dev snapshot directory. */
5
+ export declare function pruneDevelopmentRuntimeArtifactsSnapshotDirectory(input: {
6
+ readonly activeSnapshotRoot: string | undefined;
7
+ readonly gracePeriodMs?: number;
8
+ readonly now?: number;
9
+ readonly protectAll: boolean;
10
+ readonly retainCount?: number;
11
+ readonly snapshotsDirectory: string;
12
+ }): Promise<void>;
@@ -0,0 +1 @@
1
+ import{existsSync}from"node:fs";import{join,resolve}from"node:path";import{readFile,readdir,rm,stat,writeFile}from"node:fs/promises";const DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER=`activated`,DEVELOPMENT_RUNTIME_ARTIFACTS_RETIRED_METADATA=`retired.json`;async function recordRetiredDevelopmentRuntimeArtifactsSnapshot(e,n=Date.now()){await writeFile(join(e,DEVELOPMENT_RUNTIME_ARTIFACTS_RETIRED_METADATA),`${JSON.stringify({retiredAt:n})}\n`)}async function pruneDevelopmentRuntimeArtifactsSnapshotDirectory(r){if(r.protectAll)return;let o=r.now??Date.now(),s=Math.max(0,r.gracePeriodMs??18e5),c=Math.max(0,Math.trunc(r.retainCount??5)),l;try{l=await readdir(r.snapshotsDirectory,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let u=r.activeSnapshotRoot===void 0?void 0:resolve(r.activeSnapshotRoot),d=await Promise.all(l.filter(e=>e.isDirectory()).map(async i=>{let a=join(r.snapshotsDirectory,i.name),s=u===resolve(a),c=existsSync(join(a,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER)),l;if(c&&!s)try{l=await readRetiredAt(a),l===void 0&&(await recordRetiredDevelopmentRuntimeArtifactsSnapshot(a,o),l=o)}catch(e){console.warn(`[eve:dev] failed to read or initialize runtime generation retirement metadata for "${a}": ${String(e)}`)}return{activated:c,active:s,path:a,retiredAt:l,mtimeMs:(await stat(a)).mtimeMs}})),f=new Set(d.flatMap(e=>e.retiredAt===void 0?[]:[{path:e.path,retiredAt:e.retiredAt}]).sort((e,t)=>t.retiredAt-e.retiredAt).slice(0,c).map(e=>e.path)),p=new Set(d.filter(e=>!e.activated).sort((e,t)=>t.mtimeMs-e.mtimeMs).slice(0,c).map(e=>e.path));await Promise.all(d.map(async e=>{e.active||e.activated&&e.retiredAt===void 0||f.has(e.path)||p.has(e.path)||e.retiredAt!==void 0&&o-e.retiredAt<=s||!e.activated&&o-e.mtimeMs<=s||await rm(e.path,{force:!0,recursive:!0})}))}async function readRetiredAt(e){let n;try{n=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 i;try{i=JSON.parse(n)}catch{return}if(typeof i==`object`&&i&&!Array.isArray(i)&&`retiredAt`in i&&typeof i.retiredAt==`number`&&Number.isFinite(i.retiredAt)&&i.retiredAt>=0)return i.retiredAt}export{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot};
@@ -8,6 +8,14 @@ export interface DevelopmentRuntimeArtifactsSnapshot {
8
8
  readonly snapshotSourceRoot: string;
9
9
  readonly sourceRoot: string;
10
10
  }
11
+ export interface ActiveDevelopmentRuntimeArtifactsSnapshot {
12
+ readonly runtimeAppRoot: string;
13
+ readonly snapshotRoot: string;
14
+ }
15
+ export interface DevelopmentRuntimeArtifactsActivation {
16
+ commit(): void;
17
+ rollback(): Promise<void>;
18
+ }
11
19
  /**
12
20
  * Resolves the dev-server pointer that records the latest runtime artifact
13
21
  * snapshot for new sessions.
@@ -24,17 +32,27 @@ export declare function activateDevelopmentRuntimeArtifactsSnapshot(input: {
24
32
  readonly appRoot: string;
25
33
  readonly snapshot: DevelopmentRuntimeArtifactsSnapshot;
26
34
  }): Promise<void>;
35
+ export declare function activateDevelopmentRuntimeArtifactsSnapshotTransaction(input: {
36
+ readonly appRoot: string;
37
+ readonly snapshot: DevelopmentRuntimeArtifactsSnapshot;
38
+ }): Promise<DevelopmentRuntimeArtifactsActivation>;
27
39
  /**
28
40
  * Reads the latest dev runtime snapshot root when the dev server has one.
29
41
  */
30
42
  export declare function readDevelopmentRuntimeArtifactsSnapshotRoot(pointerPath: string | undefined): string | undefined;
43
+ export declare function readActiveDevelopmentRuntimeArtifactsSnapshot(appRoot: string): ActiveDevelopmentRuntimeArtifactsSnapshot | undefined;
31
44
  /**
32
45
  * Reads a revision token for the latest dev runtime artifact snapshot.
33
46
  */
34
47
  export declare function readDevelopmentRuntimeArtifactsRevision(appRoot: string): DevelopmentRuntimeArtifactsRevision;
48
+ /**
49
+ * Bounds dev snapshot storage without consulting a Workflow World. The active
50
+ * generation is always retained; retired generations receive a grace period,
51
+ * and the newest retired generations remain as a rebuild-rate safety net.
52
+ */
35
53
  export declare function pruneDevelopmentRuntimeArtifactsSnapshots(input: {
36
54
  readonly appRoot: string;
55
+ readonly gracePeriodMs?: number;
37
56
  readonly now?: number;
38
- readonly recentWindowMs?: number;
39
57
  readonly retainCount?: number;
40
58
  }): Promise<void>;
@@ -1 +1 @@
1
- import{existsSync,readFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{cp,mkdir,readFile,readdir,rename,rm,stat,writeFile}from"node:fs/promises";import{randomUUID}from"node:crypto";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{createDevelopmentSourceSnapshotPlan}from"#internal/nitro/dev-runtime-source-snapshot.js";const DEV_RUNTIME_ARTIFACTS_DIRECTORY=`dev-runtime`,DEV_RUNTIME_ARTIFACTS_ACTIVATED_MARKER=`activated`,TERMINAL_WORKFLOW_RUN_STATUSES=new Set([`completed`,`failed`,`cancelled`,`canceled`]);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`)}async function stageDevelopmentRuntimeArtifactsSnapshot(e){let t=join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.project.appRoot),`${Date.now().toString(36)}-${randomUUID()}`),n=await createDevelopmentSourceSnapshotPlan({appRoot:e.project.appRoot,snapshotRoot:t});try{await copyDevelopmentSourceSnapshot(n),await cp(e.paths.compileDirectoryPath,join(n.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot})}catch(e){throw await rm(t,{force:!0,recursive:!0}).catch(()=>{}),e}return{runtimeAppRoot:n.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}}async function activateDevelopmentRuntimeArtifactsSnapshot(e){await writeFile(join(e.snapshot.snapshotRoot,DEV_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),``),await writeDevelopmentRuntimeArtifactsPointer(e)}function readDevelopmentRuntimeArtifactsSnapshotRoot(e){let t=readDevelopmentRuntimeArtifactsPointer(e);if(t!==void 0)return t.version===1?t.appRoot:t.runtimeAppRoot}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function pruneDevelopmentRuntimeArtifactsSnapshots(t){let n=resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(t.appRoot),i=[...collectProtectedSnapshotPaths(readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(t.appRoot))),...await collectWorkflowDataSnapshotPaths({appRoot:t.appRoot,snapshotsDirectory:n})],a=t.now??Date.now(),o=t.recentWindowMs??9e5,s=t.retainCount??5,c;try{c=await readdir(n,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let l=(await Promise.all(c.filter(e=>e.isDirectory()).map(async e=>{let t=join(n,e.name);return{path:t,mtimeMs:(await stat(t)).mtimeMs}}))).sort((e,t)=>t.mtimeMs-e.mtimeMs);await Promise.all(l.map(async(t,n)=>{existsSync(join(t.path,DEV_RUNTIME_ARTIFACTS_ACTIVATED_MARKER))||n<s||a-t.mtimeMs<=o||i.some(e=>pathsOverlap(t.path,e))||await rm(t.path,{force:!0,recursive:!0})}))}function readDevelopmentRuntimeArtifactsPointer(n){if(!(n===void 0||!existsSync(n)))try{let e=JSON.parse(readFileSync(n,`utf8`));return e.kind!==`eve-dev-runtime-artifacts-pointer`||typeof e.version!=`number`?void 0:e.version===1&&typeof e.appRoot==`string`&&e.appRoot.length>0?{appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:e.version===2&&typeof e.appRoot==`string`&&typeof e.runtimeAppRoot==`string`&&e.runtimeAppRoot.length>0&&typeof e.snapshotRoot==`string`&&e.snapshotRoot.length>0?{appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.runtimeAppRoot,snapshotRoot:e.snapshotRoot,version:2}:void 0}catch{return}}function collectProtectedSnapshotPaths(e){return e===void 0?[]:e.version===1?[e.appRoot]:[e.runtimeAppRoot,e.snapshotRoot]}async function collectWorkflowDataSnapshotPaths(e){let t=join(e.appRoot,`.workflow-data`),n=new Set;return await collectSnapshotPathsFromDirectory({directory:t,snapshotPaths:n,snapshotsDirectory:e.snapshotsDirectory}),[...n]}async function collectSnapshotPathsFromDirectory(e){let t;try{t=await readdir(e.directory,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}await Promise.all(t.map(async t=>{let n=join(e.directory,t.name);if(t.isDirectory()){await collectSnapshotPathsFromDirectory({directory:n,snapshotPaths:e.snapshotPaths,snapshotsDirectory:e.snapshotsDirectory});return}if(!t.isFile()||(await stat(n)).size>1048576)return;let i=await readFile(n,`utf8`);if(shouldScanWorkflowDataSource(i))for(let t of collectSnapshotPathsFromText(i,e.snapshotsDirectory))e.snapshotPaths.add(t)}))}function collectSnapshotPathsFromText(e,t){let n=new Set,i=t.replaceAll(`\\`,`/`),a=RegExp(`${escapeRegExp(i)}/([^/"'\\s]+)`,`gu`),o=e.replaceAll(`\\\\`,`/`).replaceAll(`\\`,`/`);for(let e of o.matchAll(a)){let i=e[1];i!==void 0&&i.length>0&&n.add(join(t,i))}return[...n]}function shouldScanWorkflowDataSource(e){let t=parseJsonObject(e);if(t===void 0)return!0;let n=t.status;return typeof n!=`string`||!TERMINAL_WORKFLOW_RUN_STATUSES.has(n)}function parseJsonObject(e){try{let t=JSON.parse(e);return isObjectRecord(t)?t:void 0}catch{return}}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/gu,`\\$&`)}function pathsOverlap(e,t){return isPathInsideOrEqual(e,t)||isPathInsideOrEqual(t,e)}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,runtimeAppRoot:e.runtimeAppRoot,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]=rewritePathWithinAppRoot({appRoot:e.appRoot,path:r,runtimeAppRoot:e.runtimeAppRoot});continue}t[n]=rewriteManifestRoots({appRoot:e.appRoot,runtimeAppRoot:e.runtimeAppRoot,value:r})}return t}function rewritePathWithinAppRoot(e){if(!isPathInsideOrEqual(e.path,e.appRoot))return 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),r=`${t}.${randomUUID()}.tmp`,i={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await mkdir(dirname(t),{recursive:!0}),await writeFile(r,`${JSON.stringify(i,null,2)}\n`);try{await rename(r,t)}catch(e){throw await rm(r,{force:!0}).catch(()=>{}),e}}async function validateSnapshotCompiledManifestRoots(e){let t=collectManifestRootPaths(JSON.parse(await readFile(e.manifestPath,`utf8`)));for(let n of t)if(!isPathInsideOrEqual(n,e.runtimeAppRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime app root "${e.runtimeAppRoot}".`)}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,pruneDevelopmentRuntimeArtifactsSnapshots,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
1
+ import{existsSync,readFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{cp,mkdir,readFile,rm,writeFile}from"node:fs/promises";import{randomUUID}from"node:crypto";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{createDevelopmentSourceSnapshotPlan}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,snapshotRoot:t});try{await copyDevelopmentSourceSnapshot(n),await cp(e.paths.compileDirectoryPath,join(n.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot}),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{runtimeAppRoot:n.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}}async function activateDevelopmentRuntimeArtifactsSnapshot(e){(await activateDevelopmentRuntimeArtifactsSnapshotTransaction(e)).commit()}async function activateDevelopmentRuntimeArtifactsSnapshotTransaction(e){let t=join(e.snapshot.snapshotRoot,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),n=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),i=readDevelopmentRuntimeArtifactsPointer(n),a=await readOptionalFile(n);try{await writeFile(t,``),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:t,pointerPath:n,previousPointerSource:a})}let o=!1;return{commit(){o=!0},async rollback(){if(o)return;o=!0;let e=await restoreDevelopmentRuntimeArtifactsActivation({markerPath:t,pointerPath:n,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 readDevelopmentRuntimeArtifactsPointer(n){if(!(n===void 0||!existsSync(n)))try{let e=JSON.parse(readFileSync(n,`utf8`));return e.kind!==`eve-dev-runtime-artifacts-pointer`||typeof e.version!=`number`?void 0:e.version===1&&typeof e.appRoot==`string`&&e.appRoot.length>0?{appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:e.version===2&&typeof e.appRoot==`string`&&typeof e.runtimeAppRoot==`string`&&e.runtimeAppRoot.length>0&&typeof e.snapshotRoot==`string`&&e.snapshotRoot.length>0?{appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.runtimeAppRoot,snapshotRoot:e.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,runtimeAppRoot:e.runtimeAppRoot,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]=rewritePathWithinAppRoot({appRoot:e.appRoot,path:r,runtimeAppRoot:e.runtimeAppRoot});continue}t[n]=rewriteManifestRoots({appRoot:e.appRoot,runtimeAppRoot:e.runtimeAppRoot,value:r})}return t}function rewritePathWithinAppRoot(e){if(!isPathInsideOrEqual(e.path,e.appRoot))return 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 r=`${e}.${randomUUID()}.tmp`;await mkdir(dirname(e),{recursive:!0}),await writeFile(r,t);try{await renameWithTransientBusyRetry(r,e)}catch(e){throw await rm(r,{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.runtimeAppRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime app root "${e.runtimeAppRoot}".`)}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{constants,existsSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{cp,lstat,mkdir,readFile,readdir,symlink,writeFile}from"node:fs/promises";import{DevelopmentRuntimeSourceSnapshotError,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveTsConfigExtendsTargetPaths}from"#internal/application/tsconfig-dependencies.js";const SNAPSHOT_SKIP_NAMES=new Set([`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`.workflow-data`,`node_modules`]),SNAPSHOT_APP_ROOT_SKIP_NAMES=new Set([`build`,`dist`]),SNAPSHOT_COPY_MODE=constants.COPYFILE_FICLONE;async function copyDevelopmentSourceSnapshot(e){await mkdir(e.snapshotSourceRoot,{recursive:!0});for(let t of e.copyRoots)await copySnapshotPath({plan:e,sourcePath:t,targetPath:toSnapshotPathForPlan(e,t)});for(let n of e.copyFiles)existsSync(n)&&await copySnapshotPath({plan:e,sourcePath:n,targetPath:toSnapshotPathForPlan(e,n)});await rewriteSnapshotTsConfigAbsoluteExtends(e),await createSnapshotSymlinks(e),await ensureRuntimePackageJson(e),await validateDevelopmentSourceSnapshot(e)}async function copySnapshotPath(e){try{if((await lstat(e.sourcePath)).isDirectory()){await copySnapshotDirectory(e);return}await mkdir(dirname(e.targetPath),{recursive:!0}),await cp(e.sourcePath,e.targetPath,{mode:SNAPSHOT_COPY_MODE,recursive:!0})}catch(t){throw new DevelopmentRuntimeSourceSnapshotError(`Failed to copy development runtime source snapshot path "${e.sourcePath}" to "${e.targetPath}": ${formatErrorMessage(t)}`)}}async function copySnapshotDirectory(e){await mkdir(e.targetPath,{recursive:!0});for(let t of await readdir(e.sourcePath,{withFileTypes:!0})){let n=join(e.sourcePath,t.name);shouldSkipSnapshotSource(e.plan,n)||await cp(n,join(e.targetPath,t.name),{filter:t=>!shouldSkipSnapshotSource(e.plan,t),mode:SNAPSHOT_COPY_MODE,recursive:!0})}}function shouldSkipSnapshotSource(e,n){let i=relative(e.sourceRoot,n);return i.length===0?!1:i.split(/[\\/]/).some(e=>SNAPSHOT_SKIP_NAMES.has(e)||e.startsWith(`.env`))||existsSync(join(n,`.git`))?!0:isDirectAppRootSkipPath({appRoot:e.appRoot,sourcePath:n})}function isDirectAppRootSkipPath(e){if(!isPathInsideOrEqual(e.sourcePath,e.appRoot))return!1;let t=relative(e.appRoot,e.sourcePath);if(t.length===0)return!1;let n=t.split(/[\\/]/)[0];return n!==void 0&&SNAPSHOT_APP_ROOT_SKIP_NAMES.has(n)}async function rewriteSnapshotTsConfigAbsoluteExtends(e){for(let t of e.tsconfigPaths){let n=await readTextFileIfExists(t);if(n===void 0)continue;let r=rewriteTsConfigAbsoluteExtends({configPath:t,snapshotConfigPath:toSnapshotPathForPlan(e,t),snapshotSourceRoot:e.snapshotSourceRoot,source:n,sourceRoot:e.sourceRoot});r!==void 0&&await writeFile(toSnapshotPathForPlan(e,t),r)}}function rewriteTsConfigAbsoluteExtends(e){let t=parseTsConfigObject(e.source);if(t===void 0)return;let n=rewriteTsConfigExtendsValue({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:t.extends});if(n.changed===!0)return`${JSON.stringify({...t,extends:n.value},null,2)}\n`}function rewriteTsConfigExtendsValue(e){if(typeof e.value==`string`){let t=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:e.value});return t===void 0?{changed:!1,value:e.value}:{changed:!0,value:t}}if(!Array.isArray(e.value))return{changed:!1,value:e.value};let t=!1,n=e.value.map(n=>{if(typeof n!=`string`)return n;let r=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:n});return r===void 0?n:(t=!0,r)});return{changed:t,value:n}}function rewriteTsConfigExtendsSpecifier(e){if(!isTsConfigFilePath(e.value)||!isAbsoluteFilePath(e.value))return;let t=resolveFirstExistingTsConfigExtendsTarget({configPath:e.configPath,extendsSpecifier:e.value});if(!(t===void 0||!isPathInsideOrEqual(t,e.sourceRoot)))return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}async function createSnapshotSymlinks(e){for(let t of e.symlinks){let r=toSnapshotPathForPlan(e,t.linkPath),i=t.targetKind===`local`?toSnapshotPathForPlan(e,t.targetPath):t.targetPath,a=t.targetKind===`local`?relative(dirname(r),i)||`.`:i;await mkdir(dirname(r),{recursive:!0}),await symlink(a,r,`junction`)}}async function ensureRuntimePackageJson(e){let n=join(e.runtimeAppRoot,`package.json`);existsSync(n)||(await mkdir(e.runtimeAppRoot,{recursive:!0}),await writeFile(n,`${JSON.stringify({private:!0,type:`module`},null,2)}\n`))}async function validateDevelopmentSourceSnapshot(e){let n=join(e.runtimeAppRoot,`package.json`);if(!existsSync(n))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing the runtime app package.json at "${n}".`);for(let n of e.tsconfigPaths){let r=toSnapshotPathForPlan(e,n);if(!existsSync(r))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing tsconfig dependency "${r}".`);await validateSnapshotTsConfigExtends(r)}}async function validateSnapshotTsConfigExtends(e){let n=extractTsConfigExtendsSpecifiers(await readFile(e,`utf8`));for(let r of n)if(!(!isTsConfigFilePath(r)||resolveTsConfigExtendsTargetPaths({configPath:e,extendsSpecifier:r}).some(e=>existsSync(e))))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot cannot resolve tsconfig extends "${r}" from "${e}".`)}function toSnapshotPathForPlan(e,t){return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}function isAbsoluteFilePath(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function formatErrorMessage(e){return e instanceof Error?e.message:String(e)}export{copyDevelopmentSourceSnapshot};
1
+ import{constants,existsSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{cp,lstat,mkdir,readFile,readdir,symlink,writeFile}from"node:fs/promises";import{DevelopmentRuntimeSourceSnapshotError,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveTsConfigExtendsTargetPaths}from"#internal/application/tsconfig-dependencies.js";const SNAPSHOT_SKIP_NAMES=new Set([`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`node_modules`]),SNAPSHOT_APP_ROOT_SKIP_NAMES=new Set([`build`,`dist`]),SNAPSHOT_COPY_MODE=constants.COPYFILE_FICLONE;async function copyDevelopmentSourceSnapshot(e){await mkdir(e.snapshotSourceRoot,{recursive:!0});for(let t of e.copyRoots)await copySnapshotPath({plan:e,sourcePath:t,targetPath:toSnapshotPathForPlan(e,t)});for(let n of e.copyFiles)existsSync(n)&&await copySnapshotPath({plan:e,sourcePath:n,targetPath:toSnapshotPathForPlan(e,n)});await rewriteSnapshotTsConfigAbsoluteExtends(e),await createSnapshotSymlinks(e),await ensureRuntimePackageJson(e),await validateDevelopmentSourceSnapshot(e)}async function copySnapshotPath(e){try{if((await lstat(e.sourcePath)).isDirectory()){await copySnapshotDirectory(e);return}await mkdir(dirname(e.targetPath),{recursive:!0}),await cp(e.sourcePath,e.targetPath,{mode:SNAPSHOT_COPY_MODE,recursive:!0})}catch(t){throw new DevelopmentRuntimeSourceSnapshotError(`Failed to copy development runtime source snapshot path "${e.sourcePath}" to "${e.targetPath}": ${formatErrorMessage(t)}`)}}async function copySnapshotDirectory(e){await mkdir(e.targetPath,{recursive:!0});for(let t of await readdir(e.sourcePath,{withFileTypes:!0})){let n=join(e.sourcePath,t.name);shouldSkipSnapshotSource(e.plan,n)||await cp(n,join(e.targetPath,t.name),{filter:t=>!shouldSkipSnapshotSource(e.plan,t),mode:SNAPSHOT_COPY_MODE,recursive:!0})}}function shouldSkipSnapshotSource(e,n){let i=relative(e.sourceRoot,n);return i.length===0?!1:i.split(/[\\/]/).some(e=>SNAPSHOT_SKIP_NAMES.has(e)||e.startsWith(`.env`))||existsSync(join(n,`.git`))?!0:isDirectAppRootSkipPath({appRoot:e.appRoot,sourcePath:n})}function isDirectAppRootSkipPath(e){if(!isPathInsideOrEqual(e.sourcePath,e.appRoot))return!1;let t=relative(e.appRoot,e.sourcePath);if(t.length===0)return!1;let n=t.split(/[\\/]/)[0];return n!==void 0&&SNAPSHOT_APP_ROOT_SKIP_NAMES.has(n)}async function rewriteSnapshotTsConfigAbsoluteExtends(e){for(let t of e.tsconfigPaths){let n=await readTextFileIfExists(t);if(n===void 0)continue;let r=rewriteTsConfigAbsoluteExtends({configPath:t,snapshotConfigPath:toSnapshotPathForPlan(e,t),snapshotSourceRoot:e.snapshotSourceRoot,source:n,sourceRoot:e.sourceRoot});r!==void 0&&await writeFile(toSnapshotPathForPlan(e,t),r)}}function rewriteTsConfigAbsoluteExtends(e){let t=parseTsConfigObject(e.source);if(t===void 0)return;let n=rewriteTsConfigExtendsValue({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:t.extends});if(n.changed===!0)return`${JSON.stringify({...t,extends:n.value},null,2)}\n`}function rewriteTsConfigExtendsValue(e){if(typeof e.value==`string`){let t=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:e.value});return t===void 0?{changed:!1,value:e.value}:{changed:!0,value:t}}if(!Array.isArray(e.value))return{changed:!1,value:e.value};let t=!1,n=e.value.map(n=>{if(typeof n!=`string`)return n;let r=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:n});return r===void 0?n:(t=!0,r)});return{changed:t,value:n}}function rewriteTsConfigExtendsSpecifier(e){if(!isTsConfigFilePath(e.value)||!isAbsoluteFilePath(e.value))return;let t=resolveFirstExistingTsConfigExtendsTarget({configPath:e.configPath,extendsSpecifier:e.value});if(!(t===void 0||!isPathInsideOrEqual(t,e.sourceRoot)))return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}async function createSnapshotSymlinks(e){for(let t of e.symlinks){let r=toSnapshotPathForPlan(e,t.linkPath),i=t.targetKind===`local`?toSnapshotPathForPlan(e,t.targetPath):t.targetPath,a=t.targetKind===`local`?relative(dirname(r),i)||`.`:i;await mkdir(dirname(r),{recursive:!0}),await symlink(a,r,`junction`)}}async function ensureRuntimePackageJson(e){let n=join(e.runtimeAppRoot,`package.json`);existsSync(n)||(await mkdir(e.runtimeAppRoot,{recursive:!0}),await writeFile(n,`${JSON.stringify({private:!0,type:`module`},null,2)}\n`))}async function validateDevelopmentSourceSnapshot(e){let n=join(e.runtimeAppRoot,`package.json`);if(!existsSync(n))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing the runtime app package.json at "${n}".`);for(let n of e.tsconfigPaths){let r=toSnapshotPathForPlan(e,n);if(!existsSync(r))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing tsconfig dependency "${r}".`);await validateSnapshotTsConfigExtends(r)}}async function validateSnapshotTsConfigExtends(e){let n=extractTsConfigExtendsSpecifiers(await readFile(e,`utf8`));for(let r of n)if(!(!isTsConfigFilePath(r)||resolveTsConfigExtendsTargetPaths({configPath:e,extendsSpecifier:r}).some(e=>existsSync(e))))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot cannot resolve tsconfig extends "${r}" from "${e}".`)}function toSnapshotPathForPlan(e,t){return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}function isAbsoluteFilePath(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function formatErrorMessage(e){return e instanceof Error?e.message:String(e)}export{copyDevelopmentSourceSnapshot};
@@ -1,5 +1,5 @@
1
1
  import type { CompileAgentResult } from "#compiler/compile-agent.js";
2
- import { type DevelopmentRuntimeArtifactsSnapshot } from "#internal/nitro/dev-runtime-artifacts.js";
2
+ import { type DevelopmentRuntimeArtifactsActivation, type DevelopmentRuntimeArtifactsSnapshot } from "#internal/nitro/dev-runtime-artifacts.js";
3
3
  export interface DevelopmentGeneration extends DevelopmentRuntimeArtifactsSnapshot {
4
4
  readonly fingerprint: string;
5
5
  }
@@ -9,4 +9,8 @@ export declare function activateDevelopmentGeneration(input: {
9
9
  readonly appRoot: string;
10
10
  readonly generation: DevelopmentGeneration;
11
11
  }): Promise<void>;
12
+ export declare function activateDevelopmentGenerationTransaction(input: {
13
+ readonly appRoot: string;
14
+ readonly generation: DevelopmentGeneration;
15
+ }): Promise<DevelopmentRuntimeArtifactsActivation>;
12
16
  export declare function discardDevelopmentGeneration(generation: DevelopmentGeneration): Promise<void>;
@@ -1 +1 @@
1
- import{rm}from"node:fs/promises";import{materializeAuthoredModules}from"#internal/materialized-authored-modules.js";import{activateDevelopmentRuntimeArtifactsSnapshot,stageDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts.js";async function stageDevelopmentGeneration(n){let r=await stageDevelopmentRuntimeArtifactsSnapshot(n);try{let e=await materializeAuthoredModules({appRoot:n.project.appRoot,runtimeAppRoot:r.runtimeAppRoot,snapshotSourceRoot:r.snapshotSourceRoot,sourceRoot:r.sourceRoot});return{...r,fingerprint:e.fingerprint}}catch(t){try{await rm(r.snapshotRoot,{force:!0,recursive:!0})}catch(e){throw AggregateError([t,e],`Failed to materialize and discard development generation "${r.snapshotRoot}".`)}throw t}}async function publishDevelopmentGeneration(e){let t=await stageDevelopmentGeneration(e);return await activateDevelopmentGeneration({appRoot:e.project.appRoot,generation:t}),t}async function activateDevelopmentGeneration(e){await activateDevelopmentRuntimeArtifactsSnapshot({appRoot:e.appRoot,snapshot:e.generation})}async function discardDevelopmentGeneration(t){await rm(t.snapshotRoot,{force:!0,recursive:!0})}export{activateDevelopmentGeneration,discardDevelopmentGeneration,publishDevelopmentGeneration,stageDevelopmentGeneration};
1
+ import{rm}from"node:fs/promises";import{materializeAuthoredModules}from"#internal/materialized-authored-modules.js";import{activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,stageDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts.js";const developmentGenerationPruneStates=new Map;async function stageDevelopmentGeneration(n){let r=await stageDevelopmentRuntimeArtifactsSnapshot(n);try{let e=await materializeAuthoredModules({runtimeAppRoot:r.runtimeAppRoot});return{...r,fingerprint:e.fingerprint}}catch(t){try{await rm(r.snapshotRoot,{force:!0,recursive:!0})}catch(e){throw AggregateError([t,e],`Failed to materialize and discard development generation "${r.snapshotRoot}".`)}throw t}}async function publishDevelopmentGeneration(e){let t=await stageDevelopmentGeneration(e);return await activateDevelopmentGeneration({appRoot:e.project.appRoot,generation:t}),t}async function activateDevelopmentGeneration(e){(await activateDevelopmentGenerationTransaction(e)).commit()}async function activateDevelopmentGenerationTransaction(e){let t=await activateDevelopmentRuntimeArtifactsSnapshotTransaction({appRoot:e.appRoot,snapshot:e.generation}),r=!1;return{commit(){r||(r=!0,t.commit(),requestDevelopmentGenerationPrune(e.appRoot))},async rollback(){r||(r=!0,await t.rollback())}}}async function discardDevelopmentGeneration(t){await rm(t.snapshotRoot,{force:!0,recursive:!0})}function requestDevelopmentGenerationPrune(e){let t=developmentGenerationPruneStates.get(e)??{requested:!1,running:void 0};developmentGenerationPruneStates.set(e,t),t.requested=!0,t.running===void 0&&startDevelopmentGenerationPruning(e,t)}function startDevelopmentGenerationPruning(e,t){t.running=(async()=>{for(;t.requested;)t.requested=!1,await pruneDevelopmentRuntimeArtifactsSnapshots({appRoot:e})})().catch(e=>{console.warn(`[eve:dev] failed to prune runtime generations: ${String(e)}`)}).finally(()=>{t.running=void 0,t.requested?startDevelopmentGenerationPruning(e,t):developmentGenerationPruneStates.delete(e)})}export{activateDevelopmentGeneration,activateDevelopmentGenerationTransaction,discardDevelopmentGeneration,publishDevelopmentGeneration,stageDevelopmentGeneration};
@@ -1,4 +1,5 @@
1
1
  import type { DevelopmentNitroArtifactsConfig, ProductionNitroArtifactsConfig } from "#internal/nitro/routes/runtime-artifacts.js";
2
+ import type { AgentWorkflowWorldDefinition } from "#shared/agent-definition.js";
2
3
  /**
3
4
  * Runtime-artifacts wiring for the dev server: routes read compiled
4
5
  * artifacts from the authored app root via the snapshot pointer so hot
@@ -6,6 +7,7 @@ import type { DevelopmentNitroArtifactsConfig, ProductionNitroArtifactsConfig }
6
7
  */
7
8
  export declare function createDevelopmentNitroArtifactsConfig(input: {
8
9
  readonly appRoot: string;
10
+ readonly configuredWorld?: AgentWorkflowWorldDefinition;
9
11
  }): DevelopmentNitroArtifactsConfig;
10
12
  /**
11
13
  * Runtime-artifacts wiring for built output: routes require the artifacts