eve 0.81.1 → 0.82.0

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 (285) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/src/channel/channel-address.d.ts +21 -2
  3. package/dist/src/channel/channel-address.js +1 -1
  4. package/dist/src/channel/channel-operations.d.ts +32 -1
  5. package/dist/src/channel/channel-operations.js +1 -1
  6. package/dist/src/channel/delivery-idempotency.d.ts +4 -0
  7. package/dist/src/channel/delivery-idempotency.js +1 -0
  8. package/dist/src/channel/routes.d.ts +6 -0
  9. package/dist/src/channel/session.d.ts +5 -0
  10. package/dist/src/channel/session.js +1 -1
  11. package/dist/src/channel/types.d.ts +14 -11
  12. package/dist/src/chunks/{use-eve-agent-Bp6nbhfV.js → use-eve-agent-DTu78IAF.js} +36 -0
  13. package/dist/src/chunks/{use-eve-agent-DLkjJIm3.js → use-eve-agent-DlznYwQk.js} +36 -0
  14. package/dist/src/cli/dev/command-options.d.ts +1 -0
  15. package/dist/src/cli/dev/diagnostic-dump.js +1 -1
  16. package/dist/src/cli/run.d.ts +1 -0
  17. package/dist/src/cli/run.js +1 -1
  18. package/dist/src/client/index.d.ts +1 -1
  19. package/dist/src/client/message-reducer-types.d.ts +7 -3
  20. package/dist/src/client/message-reducer.js +1 -1
  21. package/dist/src/client/transcript-reducer.d.ts +6 -3
  22. package/dist/src/client/transcript-reducer.js +1 -1
  23. package/dist/src/compiled/.vendor-stamp.json +1 -1
  24. package/dist/src/compiler/extension-compatibility.d.ts +19 -18
  25. package/dist/src/compiler/extension-compatibility.js +1 -1
  26. package/dist/src/compiler/load-binding-namespace.d.ts +2 -0
  27. package/dist/src/compiler/load-binding-namespace.js +1 -1
  28. package/dist/src/compiler/manifest.js +1 -1
  29. package/dist/src/compiler/module-lifecycle.d.ts +1 -1
  30. package/dist/src/compiler/module-lifecycle.js +1 -1
  31. package/dist/src/compiler/module-map.js +1 -1
  32. package/dist/src/compiler/normalize-agent-config.js +1 -1
  33. package/dist/src/compiler/normalize-manifest.js +1 -1
  34. package/dist/src/compiler/project-sources.d.ts +6 -0
  35. package/dist/src/compiler/project-sources.js +1 -1
  36. package/dist/src/context/keys.d.ts +2 -0
  37. package/dist/src/context/keys.js +1 -1
  38. package/dist/src/evals/cli/eval-state-directory.d.ts +7 -0
  39. package/dist/src/evals/cli/eval-state-directory.js +1 -0
  40. package/dist/src/evals/cli/eval.js +2 -2
  41. package/dist/src/eve-channel/index.js +1 -1
  42. package/dist/src/eve-channel/support.d.ts +2 -0
  43. package/dist/src/eve-channel/support.js +1 -1
  44. package/dist/src/eve-channel/types.d.ts +7 -0
  45. package/dist/src/execution/agent-sessions/context.d.ts +2 -13
  46. package/dist/src/execution/agent-sessions/context.js +1 -1
  47. package/dist/src/execution/agent-sessions/runtime-overrides.d.ts +5 -0
  48. package/dist/src/execution/agent-sessions/runtime-overrides.js +1 -0
  49. package/dist/src/execution/agent-sessions/session.d.ts +2 -2
  50. package/dist/src/execution/agent-sessions/session.js +1 -1
  51. package/dist/src/execution/agent-sessions/steps.d.ts +2 -0
  52. package/dist/src/execution/agent-sessions/steps.js +1 -1
  53. package/dist/src/execution/coordination-dispatch-shared.d.ts +5 -5
  54. package/dist/src/execution/coordination-dispatch-step.d.ts +17 -2
  55. package/dist/src/execution/coordination-dispatch-step.js +1 -1
  56. package/dist/src/execution/create-session-step.d.ts +5 -2
  57. package/dist/src/execution/create-session-step.js +1 -1
  58. package/dist/src/execution/deliver-payloads.js +1 -1
  59. package/dist/src/execution/durable-session-store.d.ts +0 -1
  60. package/dist/src/execution/dynamic-connection-recovery.js +1 -1
  61. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  62. package/dist/src/execution/effective-agent-config.d.ts +8 -2
  63. package/dist/src/execution/effective-agent-config.js +1 -1
  64. package/dist/src/execution/install-workflow-deployment-id.d.ts +3 -0
  65. package/dist/src/execution/install-workflow-deployment-id.js +1 -0
  66. package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
  67. package/dist/src/execution/node-step.d.ts +1 -0
  68. package/dist/src/execution/node-step.js +1 -1
  69. package/dist/src/execution/runtime-context.d.ts +2 -0
  70. package/dist/src/execution/runtime-context.js +1 -1
  71. package/dist/src/execution/session/active-turn.js +1 -1
  72. package/dist/src/execution/session/admission.js +1 -1
  73. package/dist/src/execution/session/checkpoint-migrations.js +1 -1
  74. package/dist/src/execution/session/entry-input.d.ts +1 -3
  75. package/dist/src/execution/session/entry.js +1 -1
  76. package/dist/src/execution/session/finalization.js +1 -1
  77. package/dist/src/execution/session/handoff.d.ts +6 -9
  78. package/dist/src/execution/session/handoff.js +1 -1
  79. package/dist/src/execution/session/input-queue.d.ts +5 -1
  80. package/dist/src/execution/session/input-queue.js +1 -1
  81. package/dist/src/execution/session/pending-history.d.ts +5 -0
  82. package/dist/src/execution/session/pending-history.js +1 -0
  83. package/dist/src/execution/session/pending-turn-state.js +1 -1
  84. package/dist/src/execution/session/program.d.ts +1 -1
  85. package/dist/src/execution/session/program.js +1 -1
  86. package/dist/src/execution/session/timeout-control.d.ts +18 -4
  87. package/dist/src/execution/session/timeout-control.js +1 -1
  88. package/dist/src/execution/session/timeout.d.ts +1 -2
  89. package/dist/src/execution/session/timeout.js +1 -1
  90. package/dist/src/execution/session/turn-event-handler.js +1 -1
  91. package/dist/src/execution/session/turn-step-result.js +1 -1
  92. package/dist/src/execution/session/turn-step.js +1 -1
  93. package/dist/src/execution/session/turn-waiting-step.js +1 -1
  94. package/dist/src/execution/session/turn.js +1 -1
  95. package/dist/src/execution/session-inbox/protocol.js +1 -1
  96. package/dist/src/execution/session.d.ts +0 -12
  97. package/dist/src/execution/session.js +2 -2
  98. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  99. package/dist/src/execution/tasks/model-step.js +1 -1
  100. package/dist/src/execution/tasks/start.d.ts +4 -4
  101. package/dist/src/execution/tasks/start.js +1 -1
  102. package/dist/src/execution/tasks/steps.js +1 -1
  103. package/dist/src/execution/terminate-child-sessions-step.js +1 -1
  104. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  105. package/dist/src/execution/tools/workflow/body.d.ts +2 -2
  106. package/dist/src/execution/workflow-runtime.d.ts +5 -1
  107. package/dist/src/execution/workflow-runtime.js +1 -1
  108. package/dist/src/harness/hitl/approvals.js +1 -1
  109. package/dist/src/harness/hitl/budget-request.d.ts +12 -6
  110. package/dist/src/harness/hitl/budget-request.js +1 -1
  111. package/dist/src/harness/hitl/budget.d.ts +7 -1
  112. package/dist/src/harness/hitl/budget.js +1 -1
  113. package/dist/src/harness/hitl/coordinator.js +1 -1
  114. package/dist/src/harness/hitl/delivery.d.ts +1 -1
  115. package/dist/src/harness/hitl/delivery.js +1 -1
  116. package/dist/src/harness/hitl/index.js +1 -1
  117. package/dist/src/harness/hitl/intake.d.ts +2 -2
  118. package/dist/src/harness/hitl/intake.js +1 -1
  119. package/dist/src/harness/messages.d.ts +5 -0
  120. package/dist/src/harness/messages.js +1 -1
  121. package/dist/src/harness/model-call/call.d.ts +2 -2
  122. package/dist/src/harness/model-call/request.d.ts +2 -2
  123. package/dist/src/harness/session-machine/transitions.d.ts +3 -1
  124. package/dist/src/harness/session-machine/transitions.js +1 -1
  125. package/dist/src/harness/step/context.d.ts +3 -0
  126. package/dist/src/harness/step/context.js +1 -1
  127. package/dist/src/harness/step/intake.d.ts +5 -2
  128. package/dist/src/harness/step/intake.js +1 -1
  129. package/dist/src/harness/tool-loop.js +1 -1
  130. package/dist/src/harness/turn-tag-state.d.ts +7 -26
  131. package/dist/src/harness/turn-tag-state.js +1 -1
  132. package/dist/src/harness/types.d.ts +10 -25
  133. package/dist/src/internal/application/build-profile.d.ts +3 -0
  134. package/dist/src/internal/application/build-profile.js +1 -1
  135. package/dist/src/internal/application/compiled-artifacts.js +2 -2
  136. package/dist/src/internal/application/dev-environment.d.ts +13 -0
  137. package/dist/src/internal/application/dev-environment.js +1 -1
  138. package/dist/src/internal/application/stamped-package-version.js +1 -1
  139. package/dist/src/internal/authored-definition/core.js +1 -1
  140. package/dist/src/internal/authored-module-build-options.d.ts +7 -0
  141. package/dist/src/internal/authored-module-build-options.js +1 -0
  142. package/dist/src/internal/authored-module-graph.d.ts +13 -0
  143. package/dist/src/internal/authored-module-graph.js +1 -0
  144. package/dist/src/internal/authored-module-loader.d.ts +22 -1
  145. package/dist/src/internal/authored-module-loader.js +1 -3
  146. package/dist/src/internal/authored-module.d.ts +7 -0
  147. package/dist/src/internal/authored-module.js +1 -1
  148. package/dist/src/internal/authored-package-boundary.js +1 -1
  149. package/dist/src/internal/bundler/nitro-rolldown.d.ts +5 -1
  150. package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
  151. package/dist/src/internal/development-programmatic-source-loader.d.ts +1 -0
  152. package/dist/src/internal/development-programmatic-source-loader.js +1 -1
  153. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  154. package/dist/src/internal/nitro/dev-runtime-generation-metadata.js +1 -1
  155. package/dist/src/internal/nitro/host/build-application.js +1 -1
  156. package/dist/src/internal/nitro/host/build-deployment-id.d.ts +8 -0
  157. package/dist/src/internal/nitro/host/build-deployment-id.js +1 -0
  158. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  159. package/dist/src/internal/nitro/host/dev-server-state.js +1 -1
  160. package/dist/src/internal/nitro/host/skill-server-assets.js +1 -1
  161. package/dist/src/internal/nitro/host/stage-build-deployment-id.d.ts +2 -0
  162. package/dist/src/internal/nitro/host/stage-build-deployment-id.js +1 -0
  163. package/dist/src/internal/nitro/host/start-production-server.d.ts +1 -0
  164. package/dist/src/internal/nitro/host/start-production-server.js +3 -3
  165. package/dist/src/internal/nitro/routes/schedule-task.d.ts +3 -0
  166. package/dist/src/internal/nitro/routes/schedule-task.js +1 -1
  167. package/dist/src/internal/programmatic-source-loader.d.ts +1 -0
  168. package/dist/src/internal/programmatic-source-loader.js +1 -1
  169. package/dist/src/internal/schedules/disabled.d.ts +2 -0
  170. package/dist/src/internal/schedules/disabled.js +1 -0
  171. package/dist/src/internal/workflow/development-world-server.js +1 -1
  172. package/dist/src/internal/workflow/local-world-data-directory.d.ts +2 -1
  173. package/dist/src/internal/workflow/local-world-data-directory.js +1 -1
  174. package/dist/src/internal/workflow-bundle/builder.js +1 -1
  175. package/dist/src/protocol/message.d.ts +27 -1
  176. package/dist/src/protocol/message.js +2 -2
  177. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +13 -0
  178. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
  179. package/dist/src/public/channels/chat-sdk/fetch-message.d.ts +10 -0
  180. package/dist/src/public/channels/chat-sdk/fetch-message.js +1 -0
  181. package/dist/src/public/channels/chat-sdk/index.d.ts +1 -1
  182. package/dist/src/public/channels/chat-sdk/reply-context.d.ts +15 -0
  183. package/dist/src/public/channels/chat-sdk/reply-context.js +2 -0
  184. package/dist/src/public/channels/discord/discordChannel.d.ts +3 -0
  185. package/dist/src/public/channels/discord/discordChannel.js +1 -1
  186. package/dist/src/public/channels/github/dispatch.js +1 -1
  187. package/dist/src/public/channels/github/githubChannel.d.ts +3 -0
  188. package/dist/src/public/channels/imessage-tapbacks.d.ts +74 -0
  189. package/dist/src/public/channels/imessage-tapbacks.js +1 -0
  190. package/dist/src/public/channels/index.d.ts +2 -1
  191. package/dist/src/public/channels/index.js +1 -1
  192. package/dist/src/public/channels/linear/linearChannel.d.ts +3 -0
  193. package/dist/src/public/channels/linear/linearChannel.js +1 -1
  194. package/dist/src/public/channels/linq/inboundContent.d.ts +7 -0
  195. package/dist/src/public/channels/linq/inboundContent.js +1 -1
  196. package/dist/src/public/channels/linq/index.d.ts +1 -0
  197. package/dist/src/public/channels/linq/index.js +1 -1
  198. package/dist/src/public/channels/linq/linqChannel.d.ts +17 -1
  199. package/dist/src/public/channels/linq/linqChannel.js +1 -1
  200. package/dist/src/public/channels/photon/inboundContent.d.ts +7 -0
  201. package/dist/src/public/channels/photon/inboundContent.js +2 -1
  202. package/dist/src/public/channels/photon/index.d.ts +1 -0
  203. package/dist/src/public/channels/photon/index.js +1 -1
  204. package/dist/src/public/channels/photon/photonIMessageChannel.d.ts +17 -1
  205. package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
  206. package/dist/src/public/channels/slack/api.d.ts +6 -0
  207. package/dist/src/public/channels/slack/api.js +1 -1
  208. package/dist/src/public/channels/slack/model-context.d.ts +7 -0
  209. package/dist/src/public/channels/slack/model-context.js +1 -1
  210. package/dist/src/public/channels/slack/reply-delivery.d.ts +5 -0
  211. package/dist/src/public/channels/slack/reply-delivery.js +1 -1
  212. package/dist/src/public/channels/slack/slackChannel.d.ts +17 -3
  213. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  214. package/dist/src/public/channels/teams/teamsChannel.d.ts +3 -0
  215. package/dist/src/public/channels/teams/teamsChannel.js +1 -1
  216. package/dist/src/public/channels/telegram/telegramChannel.d.ts +3 -0
  217. package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
  218. package/dist/src/public/definitions/agent.d.ts +1 -1
  219. package/dist/src/public/definitions/channel.d.ts +2 -2
  220. package/dist/src/public/definitions/channel.js +1 -1
  221. package/dist/src/public/definitions/hook.d.ts +1 -0
  222. package/dist/src/public/index.d.ts +1 -1
  223. package/dist/src/public/tools/index.d.ts +1 -1
  224. package/dist/src/runtime/agent/resolve-model.d.ts +4 -0
  225. package/dist/src/runtime/agent/resolve-model.js +1 -1
  226. package/dist/src/runtime/resolve-agent.js +1 -1
  227. package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
  228. package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +2 -1
  229. package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -1
  230. package/dist/src/runtime/types.d.ts +3 -2
  231. package/dist/src/setup/scaffold/create/project.js +1 -1
  232. package/dist/src/shared/agent-definition.d.ts +31 -42
  233. package/dist/src/shared/session-history.d.ts +22 -0
  234. package/dist/src/shared/session-history.js +1 -0
  235. package/dist/src/subagents/tool.d.ts +1 -3
  236. package/dist/src/subagents/tool.js +1 -1
  237. package/dist/src/svelte/index.js +1 -1
  238. package/dist/src/svelte/use-eve-agent.js +1 -1
  239. package/dist/src/tools/provided/ask-question-workflow.js +1 -1
  240. package/dist/src/tools/provided/sleep-workflow.js +1 -1
  241. package/dist/src/tools/workflow-definition.d.ts +14 -1
  242. package/dist/src/tracing/eve/conversation-context.d.ts +4 -1
  243. package/dist/src/tracing/eve/conversation-context.js +1 -1
  244. package/dist/src/tracing/eve/invoke-tool-span.js +1 -1
  245. package/dist/src/tracing/eve/operation-input.d.ts +0 -5
  246. package/dist/src/tracing/eve/operation-input.js +1 -1
  247. package/dist/src/tracing/eve/otel-registration.js +1 -1
  248. package/dist/src/tracing/eve/session.d.ts +3 -2
  249. package/dist/src/tracing/eve/session.js +1 -1
  250. package/dist/src/vue/index.js +1 -1
  251. package/dist/src/vue/use-eve-agent.js +1 -1
  252. package/docs/agent-config.md +86 -65
  253. package/docs/channels/chat-sdk.mdx +6 -1
  254. package/docs/channels/custom.mdx +38 -6
  255. package/docs/channels/eve.mdx +46 -0
  256. package/docs/channels/linq.mdx +51 -0
  257. package/docs/channels/photon.mdx +64 -0
  258. package/docs/channels/slack.mdx +4 -2
  259. package/docs/concepts/built-in-tools.md +1 -1
  260. package/docs/concepts/execution-model-and-durability.mdx +12 -5
  261. package/docs/concepts/sessions-runs-and-streaming.md +9 -8
  262. package/docs/connections/overview.mdx +1 -1
  263. package/docs/experimental/dynamic-schedules.mdx +186 -0
  264. package/docs/experimental/meta.json +4 -0
  265. package/docs/guides/client/streaming.mdx +1 -0
  266. package/docs/guides/deployment/self-hosting.md +3 -0
  267. package/docs/guides/hooks.md +21 -1
  268. package/docs/memory/overview.mdx +2 -1
  269. package/docs/patterns/dynamic-scheduling.md +3 -1
  270. package/docs/reference/cli.md +14 -7
  271. package/docs/schedules.mdx +2 -0
  272. package/docs/subagents/index.mdx +2 -0
  273. package/docs/tools/overview.mdx +2 -1
  274. package/docs/tools/tasks-upgrade.md +12 -7
  275. package/docs/tools/tasks.md +10 -6
  276. package/docs/tools/workflows.mdx +36 -5
  277. package/docs/tutorial/connect-a-warehouse.mdx +1 -1
  278. package/docs/tutorial/run-analysis.mdx +1 -1
  279. package/package.json +1 -1
  280. package/dist/src/execution/run-session-limits.d.ts +0 -12
  281. package/dist/src/execution/run-session-limits.js +0 -1
  282. package/dist/src/harness/session-usage-limits.d.ts +0 -49
  283. package/dist/src/harness/session-usage-limits.js +0 -1
  284. package/dist/src/subagents/token-budget.d.ts +0 -15
  285. package/dist/src/subagents/token-budget.js +0 -1
@@ -1,5 +1,18 @@
1
1
  /** Environment flag set for processes that belong to an `eve dev` session. */
2
2
  export declare const EVE_DEV_ENV_FLAG = "EVE_DEV";
3
+ /**
4
+ * Internal handoff from `eve eval` to the development server it starts; not a
5
+ * user-facing setting.
6
+ */
7
+ export declare const EVE_DEV_STATE_DIR_ENV = "EVE_DEV_STATE_DIR";
8
+ /**
9
+ * Resolves where a development server keeps the state only one server per app
10
+ * root may own: the active runtime generation and its snapshots, the local
11
+ * Workflow World data, and the record a second `eve dev` attaches through.
12
+ * Defaults to `<appRoot>/.eve`. `eve eval` points it at a per-run directory so
13
+ * its server can run beside an `eve dev` session without touching it.
14
+ */
15
+ export declare function resolveDevelopmentStateDirectory(appRoot: string): string;
3
16
  type InstrumentationEnvironment = "development" | "preview" | "production";
4
17
  /** Reports whether this process belongs to an `eve dev` session. */
5
18
  export declare function isEveDevEnvironment(): boolean;
@@ -1 +1 @@
1
- const EVE_DEV_ENV_FLAG=`EVE_DEV`;function isEveDevEnvironment(){return process.env[EVE_DEV_ENV_FLAG]===`1`}function resolveInstrumentationEnvironment(){return isEveDevEnvironment()||process.env.VERCEL_ENV===`development`?`development`:process.env.VERCEL_ENV===`preview`?`preview`:`production`}const EVE_EVALUATION_ENV_FLAG=`EVE_EVALUATION`,EVE_EVALUATION_RUN_ID_ENV=`EVE_EVALUATION_RUN_ID`;function isEveEvaluationEnvironment(){return process.env[EVE_EVALUATION_ENV_FLAG]===`1`}function resolveEveEvaluationRunId(){if(!isEveEvaluationEnvironment())return;let e=process.env[EVE_EVALUATION_RUN_ID_ENV];return e===void 0||e.length===0?void 0:e}export{EVE_DEV_ENV_FLAG,EVE_EVALUATION_ENV_FLAG,EVE_EVALUATION_RUN_ID_ENV,isEveDevEnvironment,resolveEveEvaluationRunId,resolveInstrumentationEnvironment};
1
+ import{join,resolve}from"node:path";const EVE_DEV_ENV_FLAG=`EVE_DEV`,EVE_DEV_STATE_DIR_ENV=`EVE_DEV_STATE_DIR`;function resolveDevelopmentStateDirectory(e){let t=process.env[EVE_DEV_STATE_DIR_ENV];return!isEveDevEnvironment()||t===void 0||t.length===0?join(e,`.eve`):resolve(e,t)}function isEveDevEnvironment(){return process.env[EVE_DEV_ENV_FLAG]===`1`}function resolveInstrumentationEnvironment(){return isEveDevEnvironment()||process.env.VERCEL_ENV===`development`?`development`:process.env.VERCEL_ENV===`preview`?`preview`:`production`}const EVE_EVALUATION_ENV_FLAG=`EVE_EVALUATION`,EVE_EVALUATION_RUN_ID_ENV=`EVE_EVALUATION_RUN_ID`;function isEveEvaluationEnvironment(){return process.env[EVE_EVALUATION_ENV_FLAG]===`1`}function resolveEveEvaluationRunId(){if(!isEveEvaluationEnvironment())return;let e=process.env[EVE_EVALUATION_RUN_ID_ENV];return e===void 0||e.length===0?void 0:e}export{EVE_DEV_ENV_FLAG,EVE_DEV_STATE_DIR_ENV,EVE_EVALUATION_ENV_FLAG,EVE_EVALUATION_RUN_ID_ENV,isEveDevEnvironment,resolveDevelopmentStateDirectory,resolveEveEvaluationRunId,resolveInstrumentationEnvironment};
@@ -1 +1 @@
1
- const STAMPED_PACKAGE_VERSION=`0.81.1`;function readStampedPackageVersion(){return STAMPED_PACKAGE_VERSION.startsWith(`__`)?void 0:STAMPED_PACKAGE_VERSION}export{readStampedPackageVersion};
1
+ const STAMPED_PACKAGE_VERSION=`0.82.0`;function readStampedPackageVersion(){return STAMPED_PACKAGE_VERSION.startsWith(`__`)?void 0:STAMPED_PACKAGE_VERSION}export{readStampedPackageVersion};
@@ -1 +1 @@
1
- import{expectAgentToolExposure,expectBoolean,expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectPositiveInteger,expectProviderOptions,expectString,getOptionalStringRecordProperty}from"#internal/authored-module.js";import{AGENT_WORKFLOW_RETENTION_VALUES,ANTHROPIC_PROMPT_CACHE_TTLS}from"#shared/agent-definition.js";import{isAgentReasoningDefinition}from"#internal/runtime-model.js";import{isDynamicSentinel}from"#dynamic/definition.js";function normalizeAgentDefinition(e,t){let n=expectObjectRecord(e,t);if(expectOnlyKnownKeys(n,[`build`,`compaction`,`defaultTools`,`description`,`experimental`,`limits`,`model`,`modelContextWindowTokens`,`modelOptions`,`reasoning`,`tool`],t),n.model===void 0)throw Error(`${t} The "model" field is required.`);let r={model:normalizeAgentModelDefinition(n.model,t)};if(isDynamicSentinel(r.model)&&(n.modelContextWindowTokens!==void 0||n.modelOptions!==void 0))throw Error(`${t} Dynamic model definitions do not support sibling "modelContextWindowTokens" or "modelOptions" fields. Return those overrides from the resolver selection instead.`);return n.description!==void 0&&(r.description=expectString(n.description,t)),n.defaultTools!==void 0&&(r.defaultTools=expectBoolean(n.defaultTools,t)),n.compaction!==void 0&&(r.compaction=normalizeAgentCompactionDefinition(n.compaction,t)),n.build!==void 0&&(r.build=normalizeAgentBuildDefinition(n.build,t)),n.experimental!==void 0&&(r.experimental=normalizeAgentExperimentalDefinition(n.experimental,t)),n.modelOptions!==void 0&&(r.modelOptions=normalizeAgentModelOptions(n.modelOptions,t)),n.modelContextWindowTokens!==void 0&&(r.modelContextWindowTokens=expectPositiveInteger(n.modelContextWindowTokens,t)),n.reasoning!==void 0&&(r.reasoning=normalizeAgentReasoningDefinition(n.reasoning,t)),n.tool!==void 0&&(r.tool=expectAgentToolExposure(n.tool,t)),n.limits!==void 0&&(r.limits=normalizeAgentLimitsDefinition(n.limits,t)),r}function normalizeAgentReasoningDefinition(e,t){if(!isAgentReasoningDefinition(e))throw Error(t);return e}function normalizeAgentModelDefinition(e,t){if(!isDynamicSentinel(e))return e;let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`events`,`kind`],t);let r=expectObjectRecord(n.events,t),i={};for(let[e,n]of Object.entries(r))i[e]=expectFunction(n,t);return{events:i,kind:n.kind}}function expectPositiveIntegerOrFalse(e,t){return e!==!1&&expectPositiveInteger(e,t)}function expectPositiveNumberOrFalse(e,t){if(e===!1)return!1;if(typeof e!=`number`||!Number.isFinite(e)||e<=0)throw Error(t);return e}function normalizeAgentLimitsDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`maxInputTokensPerSession`,`maxOutputTokensPerSession`,`maxTokenCostUsdPerSession`,`sessionTimeoutMs`],t);let r={};return n.sessionTimeoutMs!==void 0&&(r.sessionTimeoutMs=expectPositiveIntegerOrFalse(n.sessionTimeoutMs,t)),n.maxInputTokensPerSession!==void 0&&(r.maxInputTokensPerSession=expectPositiveIntegerOrFalse(n.maxInputTokensPerSession,t)),n.maxOutputTokensPerSession!==void 0&&(r.maxOutputTokensPerSession=expectPositiveIntegerOrFalse(n.maxOutputTokensPerSession,t)),n.maxTokenCostUsdPerSession!==void 0&&(r.maxTokenCostUsdPerSession=expectPositiveNumberOrFalse(n.maxTokenCostUsdPerSession,t)),r}function normalizeAgentBuildDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`externalDependencies`],t);let r={};if(n.externalDependencies!==void 0){if(!Array.isArray(n.externalDependencies))throw Error(t);r.externalDependencies=Object.freeze(n.externalDependencies.map(e=>expectString(e,t)))}return r}function normalizeAgentWorkflowDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`modelCallsPerStep`,`retention`,`world`],t);let r={};return n.modelCallsPerStep!==void 0&&(r.modelCallsPerStep=expectPositiveInteger(n.modelCallsPerStep,t)),n.retention!==void 0&&(r.retention=normalizeAgentWorkflowRetentionDefinition(n.retention,t)),n.world!==void 0&&(r.world=normalizeAgentWorkflowWorldDefinition(n.world,t)),r}function normalizeAgentWorkflowRetentionDefinition(e,t){let n=AGENT_WORKFLOW_RETENTION_VALUES.find(t=>t===e);if(n===void 0){let e=AGENT_WORKFLOW_RETENTION_VALUES.map(e=>JSON.stringify(e)).join(` or `);throw Error(`${t} "experimental.workflow.retention" must be ${e}.`)}return n}function normalizeAgentWorkflowWorldDefinition(e,t){let n=expectString(e,t);if(n.trim()===``)throw Error(`${t} "experimental.workflow.world" must be a non-empty package name.`);return n}function normalizeAgentExperimentalDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`workflow`],t);let r={};return n.workflow!==void 0&&(r.workflow=normalizeAgentWorkflowDefinition(n.workflow,t)),r}function normalizeAgentModelOptions(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`promptCache`,`providerOptions`],t);let r={};return n.providerOptions!==void 0&&(r.providerOptions=expectProviderOptions(n.providerOptions,t)),n.promptCache!==void 0&&(r.promptCache=normalizeAgentPromptCache(n.promptCache,t)),r}function normalizeAgentPromptCache(e,t){let n=expectObjectRecord(e,`${t} "modelOptions.promptCache" must be an object.`);if(expectOnlyKnownKeys(n,[`anthropic`],`${t} In "modelOptions.promptCache":`),n.anthropic===void 0)return{};let r=expectObjectRecord(n.anthropic,`${t} "modelOptions.promptCache.anthropic" must be an object.`);expectOnlyKnownKeys(r,[`ttl`],`${t} In "modelOptions.promptCache.anthropic":`);let i=r.ttl;if(i===void 0)return{anthropic:{}};if(!ANTHROPIC_PROMPT_CACHE_TTLS.includes(i))throw Error(`${t} "modelOptions.promptCache.anthropic.ttl" must be "5m" or "1h"; received ${JSON.stringify(i)}.`);return{anthropic:{ttl:i}}}function normalizeAgentCompactionDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`model`,`modelContextWindowTokens`,`thresholdPercent`],t);let r={};if(n.model!==void 0){if(isDynamicSentinel(n.model))throw Error(`${t} "compaction.model" does not support defineDynamic — provide a static model.`);r.model=n.model}if(n.modelContextWindowTokens!==void 0&&(r.modelContextWindowTokens=expectPositiveInteger(n.modelContextWindowTokens,t)),n.thresholdPercent!==void 0){let e=n.thresholdPercent;if(typeof e!=`number`||!Number.isFinite(e)||e<0||e>1)throw Error(t);r.thresholdPercent=e}return r}function normalizeInstructionsDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`content`,`markdown`,`role`],t);let r=Object.hasOwn(n,`content`),i=Object.hasOwn(n,`markdown`);if(r===i)throw Error(`${t} Provide exactly one of "content" or "markdown".`);if(i){if(Object.hasOwn(n,`role`))throw Error(`${t} The deprecated "markdown" shape does not support "role".`);return{content:expectString(n.markdown,t),role:`system`}}let a=n.role===void 0?`system`:expectString(n.role,t);if(a!==`system`&&a!==`user`)throw Error(`${t} Expected "role" to be one of: system, user.`);return{content:expectString(n.content,t),role:a}}function normalizeSkillDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`deferred`,`description`,`files`,`license`,`markdown`,`metadata`],t);let r={description:expectString(n.description,t),markdown:expectString(n.markdown,t)};n.deferred!==void 0&&(r.deferred=expectBoolean(n.deferred,t));let i=n.license,a=getOptionalStringRecordProperty(n,`metadata`,t);return i!==void 0&&(r.license=expectString(i,t)),a!==void 0&&(r.metadata=a),n.files!==void 0&&(r.files=normalizeSkillFiles(n.files,t)),r}function normalizeSkillFiles(e,t){let n=expectObjectRecord(e,t),r={};for(let[e,i]of Object.entries(n)){if(typeof i==`string`||i instanceof Uint8Array){r[e]=i;continue}throw Error(`${t} Expected skill file "${e}" to be a string or Uint8Array.`)}return r}function normalizeScheduleDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`cron`,`markdown`,`run`],t);let r=expectString(n.cron,t),i=n.markdown!==void 0,a=n.run!==void 0;if(i&&a)throw Error(`${t} Pass either "markdown" (fire-and-forget) or "run" (handler) — not both.`);if(!i&&!a)throw Error(`${t} Must provide either "markdown" (fire-and-forget) or "run" (handler).`);let o={cron:r};return i?o.markdown=expectString(n.markdown,t):o.run=expectFunction(n.run,t),o}export{normalizeAgentDefinition,normalizeAgentPromptCache,normalizeInstructionsDefinition,normalizeScheduleDefinition,normalizeSkillDefinition};
1
+ import{expectAgentToolExposure,expectBoolean,expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectPositiveInteger,expectProviderOptions,expectString,getOptionalStringRecordProperty}from"#internal/authored-module.js";import{AGENT_WORKFLOW_RETENTION_VALUES,ANTHROPIC_PROMPT_CACHE_TTLS}from"#shared/agent-definition.js";import{isAgentReasoningDefinition}from"#internal/runtime-model.js";import{isDynamicSentinel}from"#dynamic/definition.js";function normalizeAgentDefinition(e,t){let n=expectObjectRecord(e,t);if(expectOnlyKnownKeys(n,[`build`,`compaction`,`defaultTools`,`description`,`experimental`,`limits`,`model`,`modelContextWindowTokens`,`modelOptions`,`reasoning`,`tool`],t),n.model===void 0)throw Error(`${t} The "model" field is required.`);let r={model:normalizeAgentModelDefinition(n.model,t)};if(isDynamicSentinel(r.model)&&(n.modelContextWindowTokens!==void 0||n.modelOptions!==void 0))throw Error(`${t} Dynamic model definitions do not support sibling "modelContextWindowTokens" or "modelOptions" fields. Return those overrides from the resolver selection instead.`);return n.description!==void 0&&(r.description=expectString(n.description,t)),n.defaultTools!==void 0&&(r.defaultTools=expectBoolean(n.defaultTools,t)),n.compaction!==void 0&&(r.compaction=normalizeAgentCompactionDefinition(n.compaction,t)),n.build!==void 0&&(r.build=normalizeAgentBuildDefinition(n.build,t)),n.experimental!==void 0&&(r.experimental=normalizeAgentExperimentalDefinition(n.experimental,t)),n.modelOptions!==void 0&&(r.modelOptions=normalizeAgentModelOptions(n.modelOptions,t)),n.modelContextWindowTokens!==void 0&&(r.modelContextWindowTokens=expectPositiveInteger(n.modelContextWindowTokens,t)),n.reasoning!==void 0&&(r.reasoning=normalizeAgentReasoningDefinition(n.reasoning,t)),n.tool!==void 0&&(r.tool=expectAgentToolExposure(n.tool,t)),n.limits!==void 0&&(r.limits=normalizeAgentLimitsDefinition(n.limits,t)),r}function normalizeAgentReasoningDefinition(e,t){if(!isAgentReasoningDefinition(e))throw Error(t);return e}function normalizeAgentModelDefinition(e,t){if(!isDynamicSentinel(e))return e;let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`events`,`kind`],t);let r=expectObjectRecord(n.events,t),i={};for(let[e,n]of Object.entries(r))i[e]=expectFunction(n,t);return{events:i,kind:n.kind}}function expectPositiveIntegerOrFalse(e,t){return e!==!1&&expectPositiveInteger(e,t)}function normalizeAgentLimitsDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`sessionTimeoutMs`,`sessionUsage`],t);let r={};return n.sessionTimeoutMs!==void 0&&(r.sessionTimeoutMs=expectPositiveIntegerOrFalse(n.sessionTimeoutMs,t)),n.sessionUsage!==void 0&&(r.sessionUsage=expectFunction(n.sessionUsage,t)),r}function normalizeAgentBuildDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`externalDependencies`],t);let r={};if(n.externalDependencies!==void 0){if(!Array.isArray(n.externalDependencies))throw Error(t);r.externalDependencies=Object.freeze(n.externalDependencies.map(e=>expectString(e,t)))}return r}function normalizeAgentWorkflowDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`modelCallsPerStep`,`retention`,`world`],t);let r={};return n.modelCallsPerStep!==void 0&&(r.modelCallsPerStep=expectPositiveInteger(n.modelCallsPerStep,t)),n.retention!==void 0&&(r.retention=normalizeAgentWorkflowRetentionDefinition(n.retention,t)),n.world!==void 0&&(r.world=normalizeAgentWorkflowWorldDefinition(n.world,t)),r}function normalizeAgentWorkflowRetentionDefinition(e,t){let n=AGENT_WORKFLOW_RETENTION_VALUES.find(t=>t===e);if(n===void 0){let e=AGENT_WORKFLOW_RETENTION_VALUES.map(e=>JSON.stringify(e)).join(` or `);throw Error(`${t} "experimental.workflow.retention" must be ${e}.`)}return n}function normalizeAgentWorkflowWorldDefinition(e,t){let n=expectString(e,t);if(n.trim()===``)throw Error(`${t} "experimental.workflow.world" must be a non-empty package name.`);return n}function normalizeAgentExperimentalDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`workflow`],t);let r={};return n.workflow!==void 0&&(r.workflow=normalizeAgentWorkflowDefinition(n.workflow,t)),r}function normalizeAgentModelOptions(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`promptCache`,`providerOptions`],t);let r={};return n.providerOptions!==void 0&&(r.providerOptions=expectProviderOptions(n.providerOptions,t)),n.promptCache!==void 0&&(r.promptCache=normalizeAgentPromptCache(n.promptCache,t)),r}function normalizeAgentPromptCache(e,t){let n=expectObjectRecord(e,`${t} "modelOptions.promptCache" must be an object.`);if(expectOnlyKnownKeys(n,[`anthropic`],`${t} In "modelOptions.promptCache":`),n.anthropic===void 0)return{};let r=expectObjectRecord(n.anthropic,`${t} "modelOptions.promptCache.anthropic" must be an object.`);expectOnlyKnownKeys(r,[`ttl`],`${t} In "modelOptions.promptCache.anthropic":`);let i=r.ttl;if(i===void 0)return{anthropic:{}};if(!ANTHROPIC_PROMPT_CACHE_TTLS.includes(i))throw Error(`${t} "modelOptions.promptCache.anthropic.ttl" must be "5m" or "1h"; received ${JSON.stringify(i)}.`);return{anthropic:{ttl:i}}}function normalizeAgentCompactionDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`model`,`modelContextWindowTokens`,`thresholdPercent`],t);let r={};if(n.model!==void 0){if(isDynamicSentinel(n.model))throw Error(`${t} "compaction.model" does not support defineDynamic — provide a static model.`);r.model=n.model}if(n.modelContextWindowTokens!==void 0&&(r.modelContextWindowTokens=expectPositiveInteger(n.modelContextWindowTokens,t)),n.thresholdPercent!==void 0){let e=n.thresholdPercent;if(typeof e!=`number`||!Number.isFinite(e)||e<0||e>1)throw Error(t);r.thresholdPercent=e}return r}function normalizeInstructionsDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`content`,`markdown`,`role`],t);let r=Object.hasOwn(n,`content`),i=Object.hasOwn(n,`markdown`);if(r===i)throw Error(`${t} Provide exactly one of "content" or "markdown".`);if(i){if(Object.hasOwn(n,`role`))throw Error(`${t} The deprecated "markdown" shape does not support "role".`);return{content:expectString(n.markdown,t),role:`system`}}let a=n.role===void 0?`system`:expectString(n.role,t);if(a!==`system`&&a!==`user`)throw Error(`${t} Expected "role" to be one of: system, user.`);return{content:expectString(n.content,t),role:a}}function normalizeSkillDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`deferred`,`description`,`files`,`license`,`markdown`,`metadata`],t);let r={description:expectString(n.description,t),markdown:expectString(n.markdown,t)};n.deferred!==void 0&&(r.deferred=expectBoolean(n.deferred,t));let i=n.license,a=getOptionalStringRecordProperty(n,`metadata`,t);return i!==void 0&&(r.license=expectString(i,t)),a!==void 0&&(r.metadata=a),n.files!==void 0&&(r.files=normalizeSkillFiles(n.files,t)),r}function normalizeSkillFiles(e,t){let n=expectObjectRecord(e,t),r={};for(let[e,i]of Object.entries(n)){if(typeof i==`string`||i instanceof Uint8Array){r[e]=i;continue}throw Error(`${t} Expected skill file "${e}" to be a string or Uint8Array.`)}return r}function normalizeScheduleDefinition(e,t){let n=expectObjectRecord(e,t);expectOnlyKnownKeys(n,[`cron`,`markdown`,`run`],t);let r=expectString(n.cron,t),i=n.markdown!==void 0,a=n.run!==void 0;if(i&&a)throw Error(`${t} Pass either "markdown" (fire-and-forget) or "run" (handler) — not both.`);if(!i&&!a)throw Error(`${t} Must provide either "markdown" (fire-and-forget) or "run" (handler).`);let o={cron:r};return i?o.markdown=expectString(n.markdown,t):o.run=expectFunction(n.run,t),o}export{normalizeAgentDefinition,normalizeAgentPromptCache,normalizeInstructionsDefinition,normalizeScheduleDefinition,normalizeSkillDefinition};
@@ -0,0 +1,7 @@
1
+ /** Rolldown options shared by every authored module bundle of one package. */
2
+ export declare function createAuthoredModuleBuildOptions(input: {
3
+ readonly packageBoundaryPlugin: Record<string, unknown>;
4
+ readonly packageRoot: string;
5
+ readonly plugins: readonly (object | null)[];
6
+ }): Record<string, unknown>;
7
+ export declare function resolveAuthoredTsConfigPath(packageRoot: string): string | false;
@@ -0,0 +1 @@
1
+ import{existsSync}from"node:fs";import{join}from"node:path";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{authoredModuleConditions}from"#internal/authored-module-conditions.js";import{RESOLVE_EXTENSIONS}from"#internal/authored-package-boundary.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createAuthoredRelativeExtensionResolverPlugin}from"#internal/authored-relative-extension-resolver.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";function createAuthoredModuleBuildOptions(e){return{cwd:e.packageRoot,platform:`node`,plugins:[...e.plugins,createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:e.packageRoot}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:e.packageRoot,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),e.packageBoundaryPlugin].filter(e=>e!==null),resolve:{conditionNames:authoredModuleConditions(),extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(e.packageRoot)}}function resolveAuthoredTsConfigPath(e){for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=join(e,t);if(existsSync(n))return n}return!1}export{createAuthoredModuleBuildOptions,resolveAuthoredTsConfigPath};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Bundles a compile's application modules as one code-split graph per set of
3
+ * external dependencies, so a module they share is evaluated once, as in the
4
+ * runtime module map. A module bundled on its own evaluates a private copy of
5
+ * everything it imports.
6
+ */
7
+ export interface AuthoredModuleGraph {
8
+ /** Returns the graph entry file for `modulePath`, or `undefined` to bundle it alone. */
9
+ entryPath(modulePath: string, externalDependencies: readonly string[]): Promise<string | undefined>;
10
+ }
11
+ export declare function createAuthoredModuleGraph(modulePaths: readonly string[], options?: {
12
+ readonly appRoot?: string;
13
+ }): AuthoredModuleGraph;
@@ -0,0 +1 @@
1
+ import{existsSync,mkdirSync,writeFileSync}from"node:fs";import{join,resolve}from"node:path";import{AUTHORED_BUNDLED_MODULE_EXTENSION,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH,createAuthoredWorkflowDirectivePlugin,resolveAuthoredPackageRoot}from"#internal/authored-module-loader.js";import{createRuntimeLoaderPackageBoundaryPlugin,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{buildWithNitroRolldown}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredModuleBuildOptions}from"#internal/authored-module-build-options.js";function createAuthoredModuleGraph(e,t={}){let n=[...new Set(e.map(e=>resolve(e)))].filter(e=>AUTHORED_BUNDLED_MODULE_EXTENSION.test(e)),r=new Map;return{async entryPath(e,i){let a=normalizeExternalDependencies(i),o=a.join(`\0`),s=r.get(o);return s===void 0&&(s=writeAuthoredModuleGraph(n,a,t.appRoot).catch(()=>void 0),r.set(o,s)),(await s)?.get(resolve(e))}}}async function writeAuthoredModuleGraph(e,t,n){let r=new Map;if(e.length===0)return r;let i=resolveAuthoredPackageRoot(e[0]),a=new Map(e.filter(e=>resolveAuthoredPackageRoot(e)===i).map((e,t)=>[`entry-${t}`,e])),o=await buildWithNitroRolldown({...createAuthoredModuleBuildOptions({packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:[...t],packageRoot:i}),packageRoot:i,plugins:[createAuthoredWorkflowDirectivePlugin({appRoot:n??i})]}),input:Object.fromEntries(a),preserveEntrySignatures:`strict`,write:!1,output:{chunkFileNames:`[name]-[hash].mjs`,codeSplitting:!0,comments:!1,entryFileNames:`[name]-[hash].mjs`,format:`esm`,sourcemap:`inline`}}),s=join(i,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH);mkdirSync(s,{recursive:!0});for(let e of o.output){if(e.type!==`chunk`)continue;let t=join(s,e.fileName);existsSync(t)||writeFileSync(t,e.code);let n=e.isEntry?a.get(e.name):void 0;n!==void 0&&r.set(n,t)}return r}export{createAuthoredModuleGraph};
@@ -1,5 +1,9 @@
1
1
  import type { CompiledAgentManifest } from "#compiler/manifest.js";
2
+ import type { AuthoredModuleGraph } from "#internal/authored-module-graph.js";
2
3
  import type { AuthoredWorkflowModules } from "#internal/workflow-bundle/builder-support.js";
4
+ import { type WorkflowManifest } from "#internal/workflow-bundle/workflow-builders.js";
5
+ export declare const AUTHORED_BUNDLED_MODULE_EXTENSION: RegExp;
6
+ export declare const AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH: string;
3
7
  export interface ExtensionMountEntry {
4
8
  readonly mountSourcePath: string;
5
9
  readonly packageName: string;
@@ -26,6 +30,8 @@ export interface AuthoredModuleLoadOptions {
26
30
  })[];
27
31
  readonly evaluationId?: string;
28
32
  };
33
+ /** Shares one evaluated module graph across the loads of one compilation. */
34
+ readonly graph?: AuthoredModuleGraph;
29
35
  }
30
36
  /**
31
37
  * Loads one authored module namespace from disk during compile-time
@@ -84,5 +90,20 @@ export declare function bundleAuthoredModuleMapForGeneration(input: {
84
90
  readonly moduleMapPath: string;
85
91
  readonly resolveExternalPaths?: boolean;
86
92
  }): Promise<AuthoredModuleMapBundle>;
87
- export declare function resolveAuthoredTsConfigPath(packageRoot: string): string | false;
93
+ /** Reuses the build's own resolution so the fingerprint is exact without a second resolver. */
94
+ declare class AuthoredWorkflowSourceRecorder {
95
+ #private;
96
+ constructor(appRoot: string);
97
+ record(id: string, source: string, manifest: WorkflowManifest): void;
98
+ workflowFunctions(id: string): ReadonlySet<string> | undefined;
99
+ sourceModules(): readonly string[];
100
+ graphPlugin(): Record<string, unknown>;
101
+ modules(): AuthoredWorkflowModules;
102
+ fingerprint(): string | undefined;
103
+ }
104
+ export declare function createAuthoredWorkflowDirectivePlugin(input: {
105
+ readonly appRoot: string;
106
+ readonly recorder?: AuthoredWorkflowSourceRecorder;
107
+ }): Record<string, unknown>;
88
108
  export declare function resolveAuthoredPackageRoot(modulePath: string): string;
109
+ export {};
@@ -1,3 +1 @@
1
- import{createHash}from"node:crypto";import{expectObjectRecord}from"#internal/authored-module.js";import{existsSync,mkdirSync,realpathSync,writeFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{extensionOverridePaths}from"#compiler/extension-mount-bindings.js";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";import{buildSingleRolldownChunk,buildWithNitroRolldown}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{EXTENSION_CHUNK_DIRECTORY,createExtensionMountPlugin}from"#internal/bundler/extension-mount-plugin.js";import{authoredModuleConditions}from"#internal/authored-module-conditions.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredModuleEvaluationError}from"#internal/authored-module-evaluation-error.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createAuthoredRelativeExtensionResolverPlugin}from"#internal/authored-relative-extension-resolver.js";import{createExtensionScopePlugin,createFixedMountScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";import{prepareAuthoredWorkflowDirectives}from"#internal/workflow-bundle/authored-workflow-directives.js";import{createDynamicCapabilityTransformPlugin}from"#internal/workflow-bundle/dynamic-capability-transform-plugin.js";import{applyWorkflowTransform,isAuthoredApplicationModule}from"#internal/workflow-bundle/workflow-builders.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),inFlightModuleLoads=new Map;function loadAuthoredModuleNamespace(e,t={}){let n=createInFlightModuleLoadKey(resolve(e),t),r=inFlightModuleLoads.get(n);if(r!==void 0)return r;let i=(async()=>{try{return await doLoadAuthoredModuleNamespace(e,t)}finally{inFlightModuleLoads.delete(n)}})();return inFlightModuleLoads.set(n,i),i}async function doLoadAuthoredModuleNamespace(e,t){let n=AUTHORED_BUNDLED_MODULE_EXTENSION.test(e)?await loadBundledAuthoredModule(e,t):await import(createFileImportSpecifier(e));return expectObjectRecord(n,`Expected "${e}" to export a module namespace object.`)}function createFileImportSpecifier(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}async function bundleAuthoredModuleCode(e,t={}){let n=resolveAuthoredPackageRoot(e),r=t.extension?.entry,i=t.extension?.mountId,a=r===void 0?[]:[...t.extension?.ancestors??[],{...r,mountId:i}];return await buildAuthoredModuleBundle(e,t,{packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:n,extensionSpecifiers:new Set(a.map(e=>e.specifier))}),plugins:[...r===void 0?[]:[{name:`eve-compile-mount-entry`,resolveId(e){return e===`\0eve-compile-mount-entry`?e:void 0},load(t){if(t!==`\0eve-compile-mount-entry`)return;let n=a.map(e=>`import ${JSON.stringify(`${e.mountSourcePath}?eve-mount=${encodeURIComponent(e.mountId)}`)};`),r=`${e}?eve-mount=${encodeURIComponent(i)}`;return`${n.join(` `)} export * from ${JSON.stringify(r)}; import entry from ${JSON.stringify(r)}; export default entry;`}}],createAuthoredWorkflowDirectivePlugin({appRoot:t.appRoot??n}),...r===void 0?[]:[createExtensionMountPlugin(a)]],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){return removeRolldownModuleRegionComments(await buildAuthoredModuleBundle(e,t,{packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1}))}async function bundleExtensionDistributionGraph(e){let t=[createAuthoredDirectiveGuardPlugin(),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:e.packageRoot}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:e.packageRoot,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createDistributionPackageBoundaryPlugin({packageRoot:e.packageRoot,runtimeDependencies:e.runtimeDependencies})];try{let n=await buildWithNitroRolldown({cwd:e.packageRoot,input:Object.fromEntries(e.entries.map(e=>[e.name,e.path])),platform:`node`,plugins:t,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(e.packageRoot),write:!1,output:{chunkFileNames:`${EXTENSION_CHUNK_DIRECTORY}/[name]-[hash].mjs`,codeSplitting:!0,comments:!1,entryFileNames:`[name].mjs`,format:`esm`,sourcemap:!1}}),r=new Map,i=new Set;for(let e of n.output)if(e.type===`chunk`){r.set(e.fileName,removeRolldownModuleRegionComments(e.code));for(let t of[...e.imports,...e.dynamicImports])i.add(t)}return{files:r,imports:[...i]}}catch(t){throw createAuthoredModuleBundleError(e.packageRoot,t)}}async function bundleAuthoredModuleMapForGeneration(e){let t=resolveAuthoredPackageRoot(e.manifest.agentRoot),n=resolvePackageSourceFilePath(usesDevelopmentExtensionModules(e.manifest)?`src/internal/development-programmatic-source-loader.ts`:`src/internal/programmatic-source-loader.ts`),r=normalizeExternalDependencies([...e.manifest.config.build?.externalDependencies??[],...e.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])]),i=createCompiledModuleMapSource({manifest:e.manifest,moduleMapPath:e.moduleMapPath,programmaticLoaderImportSpecifier:n}),a=[e.manifest,...e.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts),o=createExtensionScopePlugin([e.manifest,...e.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({mountId:e.mountId,sourceRoot:e.sourceRoot})))),s=new AuthoredWorkflowSourceRecorder(e.appRoot),c=[createVirtualGenerationModuleMapPlugin({id:e.moduleMapPath,source:i}),createExternalRuntimeImportPlugin(n),createAuthoredWorkflowDirectivePlugin({appRoot:e.appRoot,recorder:s}),createDynamicCapabilityTransformPlugin({workflowFunctions:e=>s.workflowFunctions(e)}),s.graphPlugin(),createExtensionMountPlugin(a,extensionOverridePaths(e.manifest)),o,createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:t}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:t,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createGenerationPackageBoundaryPlugin({externalDependencies:r,packageRoot:t,extensionSpecifiers:new Set(a.map(e=>e.specifier)),resolveExternalPaths:e.resolveExternalPaths})].filter(e=>e!==null);try{let n=await buildSingleRolldownChunk(`authored module map`,{cwd:t,input:e.moduleMapPath,platform:`node`,plugins:c,resolve:{conditionNames:authoredModuleConditions(),extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(t),output:{comments:!1,format:`esm`,sourcemap:!1}});return{authoredWorkflowModules:s.modules(),code:removeRolldownModuleRegionComments(n.code),sourceModules:s.sourceModules().filter(t=>t!==e.moduleMapPath),workflowSourceFingerprint:s.fingerprint()}}catch(t){throw createAuthoredModuleBundleError(e.moduleMapPath,t)}}function usesDevelopmentExtensionModules(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>Object.values(e.bindings).some(e=>e.backing.kind===`programmatic`&&e.backing.registryId.startsWith(`eve:development-extension:`)))}function createExternalRuntimeImportPlugin(e){let t=normalizeEsmImportSpecifier(e);return{name:`eve-external-runtime-import`,resolveId(e){return e===t?{external:!0,id:t}:void 0}}}var AuthoredWorkflowSourceRecorder=class{#e;#t=new Set;#n=new Map;#r=new Map;#i=new Map;constructor(e){this.#e=e}record(e,t,n){this.#r.set(e,t),(n.steps!==void 0||n.workflows!==void 0)&&this.#t.add(e);let r=Object.values(n.workflows??{})[0];r!==void 0&&this.#i.set(e,new Set(Object.keys(r)))}workflowFunctions(e){return this.#i.get(e)}sourceModules(){return[...this.#r.keys()].sort()}graphPlugin(){let e=this.#n;return{name:`eve-authored-module-graph`,buildEnd(){for(let t of this.getModuleIds()){let n=this.getModuleInfo(t);n!==null&&e.set(t,[...n.importedIds,...n.dynamicallyImportedIds])}}}}modules(){return{directiveModules:[...this.#t].sort(),workflowModules:[...this.#i.keys()].sort()}}fingerprint(){if(this.#t.size===0)return;let e=new Set,t=[...this.#t];for(let n=t.shift();n!==void 0;n=t.shift())!e.has(n)&&this.#r.has(n)&&(e.add(n),t.push(...this.#n.get(n)??[]));let n=createHash(`sha256`);for(let t of[...e].sort())n.update(relative(this.#e,t).split(sep).join(`/`)).update(`\0`).update(this.#r.get(t)??``).update(`\0`);return n.digest(`hex`)}};function createVirtualGenerationModuleMapPlugin(e){return{name:`eve-generation-module-map`,resolveId(t){return t===e.id?t:void 0},load(t){return t===e.id?{code:e.source,moduleType:`js`}:void 0}}}async function buildAuthoredModuleBundle(e,t,n){let r=resolveAuthoredPackageRoot(e),i=resolveAuthoredTsConfigPath(r),a=[...n.plugins,t.extension===void 0?null:createFixedMountScopePlugin(t.extension.mountId),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:r}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:r,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),n.packageBoundaryPlugin].filter(e=>e!==null);try{return(await buildSingleRolldownChunk(`authored module for "${e}"`,{cwd:r,input:t.extension?.entry===void 0?e:`\0eve-compile-mount-entry`,platform:`node`,plugins:a,resolve:{conditionNames:authoredModuleConditions(),extensions:[...RESOLVE_EXTENSIONS]},tsconfig:i,output:{comments:!1,format:`esm`,sourcemap:n.sourcemap}})).code}catch(t){throw createAuthoredModuleBundleError(e,t)}}function createAuthoredDirectiveGuardPlugin(){return{name:`eve-authored-directive-guard`,async transform(e,t){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)||isNodeModulesPath(t))return;let{hasDirectives:n}=await prepareAuthoredWorkflowDirectives({filePath:t,source:e});if(n)throw Error(`Module "${t}" uses Workflow directives ("use step" or "use workflow"). Workflow directives are supported in application modules only, not in extensions or instrumentation.`)}}}function createAuthoredWorkflowDirectivePlugin(e){return{name:`eve-authored-workflow-directives`,async transform(t,n){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(n)||isNodeModulesPath(n)||!isAuthoredApplicationModule(n,e.appRoot))return;let r=await applyWorkflowTransform(n,t,`client`,n,e.appRoot);return e.recorder?.record(n,t,r.workflowManifest),r.code===t?void 0:{code:r.code,map:null}}}}function removeRolldownModuleRegionComments(e){return e.split(`
2
- `).filter(e=>!e.startsWith(`//#region `)&&e!==`//#endregion`).join(`
3
- `)}async function loadBundledAuthoredModule(e,t){let n=await bundleAuthoredModuleCode(e,t),r=normalizeExternalDependencies(t.externalDependencies),i=createHash(`sha1`).update(e).update(`\0`).update(r.join(`\0`)).update(`\0`).update(t.extension?.mountId??``).update(`\0`).update(n).digest(`hex`),a=join(resolveAuthoredPackageRoot(e),AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH),o=join(a,`${i}.mjs`);existsSync(o)||(mkdirSync(a,{recursive:!0}),writeFileSync(o,n));try{let e=t.extension?.evaluationId??``;return await import(`${createFileImportSpecifier(o)}?v=${i}&instance=${encodeURIComponent(e)}`)}catch(t){throw createAuthoredModuleEvaluationError(e,t)}}function createInFlightModuleLoadKey(e,t){return`${e}\0${normalizeExternalDependencies(t.externalDependencies).join(`\0`)}\0${t.extension?.mountId??``}\0${t.extension?.evaluationId??``}\0${t.appRoot??``}`}function resolveAuthoredTsConfigPath(e){for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=join(e,t);if(existsSync(n))return n}return!1}function resolveAuthoredPackageRoot(e){let t=dirname(e);for(;;){if(existsSync(join(t,`package.json`)))return realpathSync(t);let n=dirname(t);if(n===t)throw Error(`Failed to resolve the authored package root for "${e}".`);t=n}}export{bundleAuthoredModuleCode,bundleAuthoredModuleForGeneration,bundleAuthoredModuleMapForGeneration,bundleExtensionDistributionGraph,loadAuthoredModuleNamespace,resolveAuthoredPackageRoot,resolveAuthoredTsConfigPath};
1
+ import{createHash}from"node:crypto";import{expectObjectRecord,interopAuthoredModuleNamespace}from"#internal/authored-module.js";import{existsSync,mkdirSync,realpathSync,writeFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{extensionOverridePaths}from"#compiler/extension-mount-bindings.js";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{authoredModuleConditions}from"#internal/authored-module-conditions.js";import{RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createAuthoredRelativeExtensionResolverPlugin}from"#internal/authored-relative-extension-resolver.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";import{buildSingleRolldownChunk,buildWithNitroRolldown}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredModuleBuildOptions,resolveAuthoredTsConfigPath}from"#internal/authored-module-build-options.js";import{EXTENSION_CHUNK_DIRECTORY,createExtensionMountPlugin}from"#internal/bundler/extension-mount-plugin.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredModuleEvaluationError}from"#internal/authored-module-evaluation-error.js";import{createExtensionScopePlugin,createFixedMountScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{prepareAuthoredWorkflowDirectives}from"#internal/workflow-bundle/authored-workflow-directives.js";import{createDynamicCapabilityTransformPlugin}from"#internal/workflow-bundle/dynamic-capability-transform-plugin.js";import{applyWorkflowTransform,isAuthoredApplicationModule}from"#internal/workflow-bundle/workflow-builders.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),inFlightModuleLoads=new Map;function loadAuthoredModuleNamespace(e,t={}){let n=createInFlightModuleLoadKey(resolve(e),t),r=inFlightModuleLoads.get(n);if(r!==void 0)return r;let i=(async()=>{try{return await doLoadAuthoredModuleNamespace(e,t)}finally{inFlightModuleLoads.delete(n)}})();return inFlightModuleLoads.set(n,i),i}async function doLoadAuthoredModuleNamespace(e,t){let n=AUTHORED_BUNDLED_MODULE_EXTENSION.test(e)?await loadBundledAuthoredModule(e,t):await import(createFileImportSpecifier(e));return expectObjectRecord(interopAuthoredModuleNamespace(n),`Expected "${e}" to export a module namespace object.`)}function createFileImportSpecifier(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}async function bundleAuthoredModuleCode(e,t={}){let n=resolveAuthoredPackageRoot(e),r=t.extension?.entry,i=t.extension?.mountId,a=r===void 0?[]:[...t.extension?.ancestors??[],{...r,mountId:i}];return await buildAuthoredModuleBundle(e,t,{packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:n,extensionSpecifiers:new Set(a.map(e=>e.specifier))}),plugins:[...r===void 0?[]:[{name:`eve-compile-mount-entry`,resolveId(e){return e===`\0eve-compile-mount-entry`?e:void 0},load(t){if(t!==`\0eve-compile-mount-entry`)return;let n=a.map(e=>`import ${JSON.stringify(`${e.mountSourcePath}?eve-mount=${encodeURIComponent(e.mountId)}`)};`),r=`${e}?eve-mount=${encodeURIComponent(i)}`;return`${n.join(` `)} export * from ${JSON.stringify(r)}; import entry from ${JSON.stringify(r)}; export default entry;`}}],createAuthoredWorkflowDirectivePlugin({appRoot:t.appRoot??n}),...r===void 0?[]:[createExtensionMountPlugin(a)]],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){return await buildAuthoredModuleBundle(e,t,{packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1})}async function bundleExtensionDistributionGraph(e){let t=[createAuthoredDirectiveGuardPlugin(),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:e.packageRoot}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:e.packageRoot,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createDistributionPackageBoundaryPlugin({packageRoot:e.packageRoot,runtimeDependencies:e.runtimeDependencies})];try{let n=await buildWithNitroRolldown({cwd:e.packageRoot,input:Object.fromEntries(e.entries.map(e=>[e.name,e.path])),platform:`node`,plugins:t,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(e.packageRoot),write:!1,output:{chunkFileNames:`${EXTENSION_CHUNK_DIRECTORY}/[name]-[hash].mjs`,codeSplitting:!0,comments:!1,entryFileNames:`[name].mjs`,format:`esm`,sourcemap:!1}}),r=new Map,i=new Set;for(let e of n.output)if(e.type===`chunk`){r.set(e.fileName,e.code);for(let t of[...e.imports,...e.dynamicImports])i.add(t)}return{files:r,imports:[...i]}}catch(t){throw createAuthoredModuleBundleError(e.packageRoot,t)}}async function bundleAuthoredModuleMapForGeneration(e){let t=resolveAuthoredPackageRoot(e.manifest.agentRoot),n=resolvePackageSourceFilePath(usesDevelopmentExtensionModules(e.manifest)?`src/internal/development-programmatic-source-loader.ts`:`src/internal/programmatic-source-loader.ts`),r=normalizeExternalDependencies([...e.manifest.config.build?.externalDependencies??[],...e.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])]),i=createCompiledModuleMapSource({manifest:e.manifest,moduleMapPath:e.moduleMapPath,programmaticLoaderImportSpecifier:n}),a=[e.manifest,...e.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts),o=createExtensionScopePlugin([e.manifest,...e.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({mountId:e.mountId,sourceRoot:e.sourceRoot})))),s=new AuthoredWorkflowSourceRecorder(e.appRoot),c=[createVirtualGenerationModuleMapPlugin({id:e.moduleMapPath,source:i}),createExternalRuntimeImportPlugin(n),createAuthoredWorkflowDirectivePlugin({appRoot:e.appRoot,recorder:s}),createDynamicCapabilityTransformPlugin({workflowFunctions:e=>s.workflowFunctions(e)}),s.graphPlugin(),createExtensionMountPlugin(a,extensionOverridePaths(e.manifest)),o,createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:t}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:t,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createGenerationPackageBoundaryPlugin({externalDependencies:r,packageRoot:t,extensionSpecifiers:new Set(a.map(e=>e.specifier)),resolveExternalPaths:e.resolveExternalPaths})].filter(e=>e!==null);try{let n=await buildSingleRolldownChunk(`authored module map`,{cwd:t,input:e.moduleMapPath,platform:`node`,plugins:c,resolve:{conditionNames:authoredModuleConditions(),extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(t),output:{comments:!1,format:`esm`,sourcemap:!1}});return{authoredWorkflowModules:s.modules(),code:n.code,sourceModules:s.sourceModules().filter(t=>t!==e.moduleMapPath),workflowSourceFingerprint:s.fingerprint()}}catch(t){throw createAuthoredModuleBundleError(e.moduleMapPath,t)}}function usesDevelopmentExtensionModules(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>Object.values(e.bindings).some(e=>e.backing.kind===`programmatic`&&e.backing.registryId.startsWith(`eve:development-extension:`)))}function createExternalRuntimeImportPlugin(e){let t=normalizeEsmImportSpecifier(e);return{name:`eve-external-runtime-import`,resolveId(e){return e===t?{external:!0,id:t}:void 0}}}var AuthoredWorkflowSourceRecorder=class{#e;#t=new Set;#n=new Map;#r=new Map;#i=new Map;constructor(e){this.#e=e}record(e,t,n){this.#r.set(e,t),(n.steps!==void 0||n.workflows!==void 0)&&this.#t.add(e);let r=Object.values(n.workflows??{})[0];r!==void 0&&this.#i.set(e,new Set(Object.keys(r)))}workflowFunctions(e){return this.#i.get(e)}sourceModules(){return[...this.#r.keys()].sort()}graphPlugin(){let e=this.#n;return{name:`eve-authored-module-graph`,buildEnd(){for(let t of this.getModuleIds()){let n=this.getModuleInfo(t);n!==null&&e.set(t,[...n.importedIds,...n.dynamicallyImportedIds])}}}}modules(){return{directiveModules:[...this.#t].sort(),workflowModules:[...this.#i.keys()].sort()}}fingerprint(){if(this.#t.size===0)return;let e=new Set,t=[...this.#t];for(let n=t.shift();n!==void 0;n=t.shift())!e.has(n)&&this.#r.has(n)&&(e.add(n),t.push(...this.#n.get(n)??[]));let n=createHash(`sha256`);for(let t of[...e].sort())n.update(relative(this.#e,t).split(sep).join(`/`)).update(`\0`).update(this.#r.get(t)??``).update(`\0`);return n.digest(`hex`)}};function createVirtualGenerationModuleMapPlugin(e){return{name:`eve-generation-module-map`,resolveId(t){return t===e.id?t:void 0},load(t){return t===e.id?{code:e.source,moduleType:`js`}:void 0}}}async function buildAuthoredModuleBundle(e,t,n){let r=resolveAuthoredPackageRoot(e);try{return(await buildSingleRolldownChunk(`authored module for "${e}"`,{...createAuthoredModuleBuildOptions({packageBoundaryPlugin:n.packageBoundaryPlugin,packageRoot:r,plugins:[...n.plugins,t.extension===void 0?null:createFixedMountScopePlugin(t.extension.mountId)]}),input:t.extension?.entry===void 0?e:`\0eve-compile-mount-entry`,output:{comments:!1,format:`esm`,sourcemap:n.sourcemap}})).code}catch(t){throw createAuthoredModuleBundleError(e,t)}}function createAuthoredDirectiveGuardPlugin(){return{name:`eve-authored-directive-guard`,async transform(e,t){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)||isNodeModulesPath(t))return;let{hasDirectives:n}=await prepareAuthoredWorkflowDirectives({filePath:t,source:e});if(n)throw Error(`Module "${t}" uses Workflow directives ("use step" or "use workflow"). Workflow directives are supported in application modules only, not in extensions or instrumentation.`)}}}function createAuthoredWorkflowDirectivePlugin(e){return{name:`eve-authored-workflow-directives`,async transform(t,n){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(n)||isNodeModulesPath(n)||!isAuthoredApplicationModule(n,e.appRoot))return;let r=await applyWorkflowTransform(n,t,`client`,n,e.appRoot);return e.recorder?.record(n,t,r.workflowManifest),r.code===t?void 0:{code:r.code,map:null}}}}async function loadBundledAuthoredModule(e,t){let n=t.extension===void 0?await t.graph?.entryPath(e,t.externalDependencies??[]):void 0,r=n===void 0?await writeAuthoredModuleBundle(e,t):createFileImportSpecifier(n);try{return await import(r)}catch(t){throw createAuthoredModuleEvaluationError(e,t)}}async function writeAuthoredModuleBundle(e,t){let n=await bundleAuthoredModuleCode(e,t),r=normalizeExternalDependencies(t.externalDependencies),i=createHash(`sha1`).update(e).update(`\0`).update(r.join(`\0`)).update(`\0`).update(t.extension?.mountId??``).update(`\0`).update(n).digest(`hex`),a=join(resolveAuthoredPackageRoot(e),AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH),o=join(a,`${i}.mjs`);existsSync(o)||(mkdirSync(a,{recursive:!0}),writeFileSync(o,n));let s=t.extension?.evaluationId??``;return`${createFileImportSpecifier(o)}?v=${i}&instance=${encodeURIComponent(s)}`}function createInFlightModuleLoadKey(e,t){return`${e}\0${normalizeExternalDependencies(t.externalDependencies).join(`\0`)}\0${t.extension?.mountId??``}\0${t.extension?.evaluationId??``}\0${t.appRoot??``}`}function resolveAuthoredPackageRoot(e){let t=dirname(e);for(;;){if(existsSync(join(t,`package.json`)))return realpathSync(t);let n=dirname(t);if(n===t)throw Error(`Failed to resolve the authored package root for "${e}".`);t=n}}export{AUTHORED_BUNDLED_MODULE_EXTENSION,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH,bundleAuthoredModuleCode,bundleAuthoredModuleForGeneration,bundleAuthoredModuleMapForGeneration,bundleExtensionDistributionGraph,createAuthoredWorkflowDirectivePlugin,loadAuthoredModuleNamespace,resolveAuthoredPackageRoot};
@@ -1,6 +1,13 @@
1
1
  import type { ModuleDefinitionExport } from "#public/definitions/source.js";
2
2
  import type { ModuleSourceRef } from "#shared/source-ref.js";
3
3
  import type { AgentModelOptionsDefinition, AgentToolExposure } from "#shared/agent-definition.js";
4
+ /**
5
+ * Returns the exports of transpiled CommonJS as its module namespace. Bundlers
6
+ * expose a CommonJS module's whole `exports` object as the ESM default, so a
7
+ * module marked `__esModule` would otherwise read its namespace as
8
+ * `{ default: { default, ...named } }`.
9
+ */
10
+ export declare function interopAuthoredModuleNamespace(namespace: unknown): unknown;
4
11
  /**
5
12
  * Returns the selected authored module export from one namespace.
6
13
  */
@@ -1 +1 @@
1
- function getAuthoredModuleExport(e,t){return e[t.exportName??`default`]}async function materializeAuthoredModuleExport(e){return typeof e==`function`?await e():e}function expectObjectRecord(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e}function expectString(e,t){if(typeof e!=`string`)throw Error(t);return e}function expectBoolean(e,t){if(typeof e!=`boolean`)throw Error(t);return e}function expectAgentToolExposure(e,t){return e===`deferred`?e:expectBoolean(e,`${t} Expected "tool" to be true, false, or "deferred".`)}function expectPositiveInteger(e,t){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(t);return e}function expectFunction(e,t){if(typeof e!=`function`)throw Error(t);return e}function expectProviderOptions(e,t){let n=expectObjectRecord(e,t),r={};for(let[e,i]of Object.entries(n))r[e]=expectObjectRecord(i,t);return r}function expectOnlyKnownKeys(e,t,n){let r=new Set(t);for(let t of Object.keys(e))if(!r.has(t))throw Error(`${n} Unknown key "${t}".`)}function getOptionalStringRecordProperty(e,t,n){let r=e[t];if(r===void 0)return;let i=expectObjectRecord(r,n),a={};for(let[e,t]of Object.entries(i))a[e]=expectString(t,n);return a}export{expectAgentToolExposure,expectBoolean,expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectPositiveInteger,expectProviderOptions,expectString,getAuthoredModuleExport,getOptionalStringRecordProperty,materializeAuthoredModuleExport};
1
+ function interopAuthoredModuleNamespace(e){if(typeof e!=`object`||!e)return e;let t=Reflect.get(e,`default`);return typeof t==`object`&&t&&Reflect.get(t,`__esModule`)===!0?t:e}function getAuthoredModuleExport(e,t){return e[t.exportName??`default`]}async function materializeAuthoredModuleExport(e){return typeof e==`function`?await e():e}function expectObjectRecord(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e}function expectString(e,t){if(typeof e!=`string`)throw Error(t);return e}function expectBoolean(e,t){if(typeof e!=`boolean`)throw Error(t);return e}function expectAgentToolExposure(e,t){return e===`deferred`?e:expectBoolean(e,`${t} Expected "tool" to be true, false, or "deferred".`)}function expectPositiveInteger(e,t){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(t);return e}function expectFunction(e,t){if(typeof e!=`function`)throw Error(t);return e}function expectProviderOptions(e,t){let n=expectObjectRecord(e,t),r={};for(let[e,i]of Object.entries(n))r[e]=expectObjectRecord(i,t);return r}function expectOnlyKnownKeys(e,t,n){let r=new Set(t);for(let t of Object.keys(e))if(!r.has(t))throw Error(`${n} Unknown key "${t}".`)}function getOptionalStringRecordProperty(e,t,n){let r=e[t];if(r===void 0)return;let i=expectObjectRecord(r,n),a={};for(let[e,t]of Object.entries(i))a[e]=expectString(t,n);return a}export{expectAgentToolExposure,expectBoolean,expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectPositiveInteger,expectProviderOptions,expectString,getAuthoredModuleExport,getOptionalStringRecordProperty,interopAuthoredModuleNamespace,materializeAuthoredModuleExport};
@@ -1 +1 @@
1
- import{createRequire,isBuiltin}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{dirname,join,resolve,sep}from"node:path";import{resolvePackageDependencyPath,resolvePackageRoot,resolveWorkflowModulePath}from"#internal/application/package.js";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";const RESOLVE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createGenerationPackageBoundaryPlugin(e){return{name:`eve-generation-package-boundary`,async resolveId(t,n,r){if(!isPackageImport(t)||e.extensionSpecifiers?.has(t))return;if(isFrameworkRuntimeImport(t,n))return e.extensionSpecifiers?.has(t)?void 0:{external:!0,id:resolveFrameworkRuntimeImport(t)};if(t.startsWith(`#`)){let r=resolvePackageImport(t,n,e.packageRoot);if(r!==void 0)return{id:r}}let i=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:n,kind:r.kind,packageRoot:e.packageRoot,source:t});if(i!==void 0)return{external:!0,id:e.resolveExternalPaths?normalizeEsmImportSpecifier(i.resolvedId):t}}}}function createRuntimeLoaderPackageBoundaryPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-runtime-loader-package-boundary`,async resolveId(n,r,i){if(!isPackageImport(n)||e.extensionSpecifiers?.has(n)===!0)return;if(isFrameworkRuntimeImport(n,r))return{external:!0,id:resolveRuntimeLoaderFrameworkImport(n)};if(n.startsWith(`#`)){let t=resolvePackageImport(n,r,e.packageRoot);if(t!==void 0)return isFrameworkPackagePath(t)?{external:!0,id:normalizeEsmImportSpecifier(t)}:{id:t}}let a=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:r,kind:i.kind,packageRoot:e.packageRoot,source:n});if(a!==void 0){let e=resolveExistingExternalFilePath(a.resolvedId)??a.resolvedId;return{external:!0,id:normalizeEsmImportSpecifier(e)}}let o=r===void 0||r.startsWith(`\0`)?void 0:resolve(r);if(o!==void 0&&isPathInsideOrEqual(toCanonicalPath(o),t)){let e=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`)throw Error(`Cannot resolve package "${n}" imported from "${o}". Install it with your package manager (e.g. \`pnpm install\`); a running \`eve dev\` retries on the next rebuild.`);if(isNodeModulesPath(e.id))return{external:!0,id:n}}}}}function createDistributionPackageBoundaryPlugin(e){let t=new Set(e.runtimeDependencies);return{name:`eve-extension-distribution-package-boundary`,async resolveId(n,r,i){if(!isPackageImport(n))return;if(n.startsWith(`#`)){let a=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(a!==null&&typeof a.id==`string`&&!isPathInsideOrEqual(toCanonicalPath(a.id),toCanonicalPath(e.packageRoot))){let e=nearestPackageName(a.id);if(e!==void 0&&!t.has(e))throw Error(`Package import "${n}" resolves to undeclared package "${e}". Add "${e}" to dependencies, optionalDependencies, or peerDependencies.`)}return}if(isBuiltin(n))return{external:!0,id:n};let a=packageImportName(n);if(!t.has(a))throw Error(`Package "${n}" is not declared by the extension. Add "${a}" to dependencies, optionalDependencies, or peerDependencies.`);let o=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(o===null&&(o=await this.resolve(n,join(e.packageRoot,`package.json`),{kind:i.kind,skipSelf:!0})),o===null||typeof o.id!=`string`)throw Error(`Cannot resolve declared package "${n}". Install the extension's dependencies before building.`);return{external:!0,id:n}}}}async function resolveConfiguredExternalModule(e){let t=resolveConfiguredExternalDependency(e.source,e.externalDependencies);if(t===void 0)return;let n=await this.resolve(e.source,e.importer,{kind:e.kind,skipSelf:!0});if(n===null&&(n=await this.resolve(e.source,join(e.packageRoot,`package.json`),{kind:e.kind,skipSelf:!0})),n===null||typeof n.id!=`string`)throw Error(`Cannot resolve external package "${e.source}".`);return{packageName:t,resolvedId:n.id}}function normalizeExternalDependencies(e=[]){return[...new Set(e)].sort()}function resolveConfiguredExternalDependency(e,t){return t.find(t=>e===t||e.startsWith(`${t}/`))}function packageImportName(e){return e.startsWith(`@`)?e.split(`/`,2).join(`/`):e.split(`/`,1)[0]}function nearestPackageName(e){let t=nearestPackageRoot(e);if(t!==void 0)try{let e=JSON.parse(readFileSync(join(t,`package.json`),`utf8`));return typeof e.name==`string`&&e.name.length>0?e.name:void 0}catch{return}}function nearestPackageRoot(e){let t=dirname(toCanonicalPath(e));for(;;){if(existsSync(join(t,`package.json`)))return t;let e=dirname(t);if(e===t)return;t=e}}function resolvePackageImport(e,t,n){let r=t===void 0||t.startsWith(`\0`)?n:nearestPackageRoot(t)??n;try{let t=createRequire(join(r,`package.json`)).resolve(e);return isPathInsideOrEqual(toCanonicalPath(t),toCanonicalPath(r))?t:void 0}catch{return}}let canonicalFrameworkPackageRoot;function isFrameworkPackagePath(e){return canonicalFrameworkPackageRoot??=toCanonicalPath(resolvePackageRoot()),nearestPackageRoot(e)===canonicalFrameworkPackageRoot}function resolveExistingExternalFilePath(e){if(existsSync(e))return e;for(let t of RESOLVE_EXTENSIONS){let n=`${e}${t}`;if(existsSync(n))return n}}function isPackageImport(e){return isPathImport(e)||/^(?:node|data|file):/.test(e)?!1:!e.startsWith(`@/`)}function isPathImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}const SELF_MODIFICATION_MOUNT_SPECIFIERS=new Set([`eve/self-modification`,`eve/self-modification/local`,`eve/self-modification/remote`]);function isFrameworkRuntimeImport(e,t){return SELF_MODIFICATION_MOUNT_SPECIFIERS.has(e)?!1:e===`eve`||e.startsWith(`eve/`)?!0:e===`workflow`||e.startsWith(`workflow/`)||e.startsWith(`@workflow/`)?t===void 0||!isNodeModulesPath(t):!1}function resolveFrameworkRuntimeImport(e){return e===`eve`||e.startsWith(`eve/`)?e:normalizeEsmImportSpecifier(resolveWorkflowModulePath(e))}function resolveRuntimeLoaderFrameworkImport(e){return e===`eve`||e.startsWith(`eve/`)?normalizeEsmImportSpecifier(resolvePackageDependencyPath(e)):resolveFrameworkRuntimeImport(e)}function isNodeModulesPath(e){return e.replaceAll(`\\`,`/`).includes(`/node_modules/`)}function toCanonicalPath(e){try{return realpathSync(e)}catch{return resolve(e)}}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies,packageImportName,resolveConfiguredExternalDependency};
1
+ import{createRequire,isBuiltin}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{dirname,join,resolve,sep}from"node:path";import{resolvePackageDependencyPath,resolvePackageRoot,resolveWorkflowModulePath}from"#internal/application/package.js";import{fileURLToPath}from"node:url";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";const RESOLVE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createGenerationPackageBoundaryPlugin(e){return{name:`eve-generation-package-boundary`,async resolveId(t,n,r){if(!isPackageImport(t)||e.extensionSpecifiers?.has(t))return;if(isFrameworkRuntimeImport(t,n))return e.extensionSpecifiers?.has(t)?void 0:{external:!0,id:toExternalModuleId(resolveFrameworkRuntimeImport(t),r.kind)};if(t.startsWith(`#`)){let r=resolvePackageImport(t,n,e.packageRoot);if(r!==void 0)return{id:r}}let i=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:n,kind:r.kind,packageRoot:e.packageRoot,source:t});if(i!==void 0)return{external:!0,id:e.resolveExternalPaths?toExternalModuleId(normalizeEsmImportSpecifier(i.resolvedId),r.kind):t}}}}function createRuntimeLoaderPackageBoundaryPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-runtime-loader-package-boundary`,async resolveId(n,r,i){if(!isPackageImport(n)||e.extensionSpecifiers?.has(n)===!0)return;if(isFrameworkRuntimeImport(n,r))return{external:!0,id:toExternalModuleId(resolveRuntimeLoaderFrameworkImport(n),i.kind)};if(n.startsWith(`#`)){let t=resolvePackageImport(n,r,e.packageRoot);if(t!==void 0)return isFrameworkPackagePath(t)?{external:!0,id:toExternalModuleId(normalizeEsmImportSpecifier(t),i.kind)}:{id:t}}let a=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:r,kind:i.kind,packageRoot:e.packageRoot,source:n});if(a!==void 0){let e=resolveExistingExternalFilePath(a.resolvedId)??a.resolvedId;return{external:!0,id:toExternalModuleId(normalizeEsmImportSpecifier(e),i.kind)}}let o=r===void 0||r.startsWith(`\0`)?void 0:resolve(r);if(o!==void 0&&isPathInsideOrEqual(toCanonicalPath(o),t)){let e=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`)throw Error(`Cannot resolve package "${n}" imported from "${o}". Install it with your package manager (e.g. \`pnpm install\`); a running \`eve dev\` retries on the next rebuild.`);if(isNodeModulesPath(e.id))return{external:!0,id:n}}}}}function createDistributionPackageBoundaryPlugin(e){let t=new Set(e.runtimeDependencies);return{name:`eve-extension-distribution-package-boundary`,async resolveId(n,r,i){if(!isPackageImport(n))return;if(n.startsWith(`#`)){let a=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(a!==null&&typeof a.id==`string`&&!isPathInsideOrEqual(toCanonicalPath(a.id),toCanonicalPath(e.packageRoot))){let e=nearestPackageName(a.id);if(e!==void 0&&!t.has(e))throw Error(`Package import "${n}" resolves to undeclared package "${e}". Add "${e}" to dependencies, optionalDependencies, or peerDependencies.`)}return}if(isBuiltin(n))return{external:!0,id:n};let a=packageImportName(n);if(!t.has(a))throw Error(`Package "${n}" is not declared by the extension. Add "${a}" to dependencies, optionalDependencies, or peerDependencies.`);let o=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(o===null&&(o=await this.resolve(n,join(e.packageRoot,`package.json`),{kind:i.kind,skipSelf:!0})),o===null||typeof o.id!=`string`)throw Error(`Cannot resolve declared package "${n}". Install the extension's dependencies before building.`);return{external:!0,id:n}}}}async function resolveConfiguredExternalModule(e){let t=resolveConfiguredExternalDependency(e.source,e.externalDependencies);if(t===void 0)return;let n=await this.resolve(e.source,e.importer,{kind:e.kind,skipSelf:!0});if(n===null&&(n=await this.resolve(e.source,join(e.packageRoot,`package.json`),{kind:e.kind,skipSelf:!0})),n===null||typeof n.id!=`string`)throw Error(`Cannot resolve external package "${e.source}".`);return{packageName:t,resolvedId:n.id}}function normalizeExternalDependencies(e=[]){return[...new Set(e)].sort()}function resolveConfiguredExternalDependency(e,t){return t.find(t=>e===t||e.startsWith(`${t}/`))}function packageImportName(e){return e.startsWith(`@`)?e.split(`/`,2).join(`/`):e.split(`/`,1)[0]}function nearestPackageName(e){let t=nearestPackageRoot(e);if(t!==void 0)try{let e=JSON.parse(readFileSync(join(t,`package.json`),`utf8`));return typeof e.name==`string`&&e.name.length>0?e.name:void 0}catch{return}}function nearestPackageRoot(e){let t=dirname(toCanonicalPath(e));for(;;){if(existsSync(join(t,`package.json`)))return t;let e=dirname(t);if(e===t)return;t=e}}function resolvePackageImport(e,t,n){let r=t===void 0||t.startsWith(`\0`)?n:nearestPackageRoot(t)??n;try{let t=createRequire(join(r,`package.json`)).resolve(e);return isPathInsideOrEqual(toCanonicalPath(t),toCanonicalPath(r))?t:void 0}catch{return}}let canonicalFrameworkPackageRoot;function isFrameworkPackagePath(e){return canonicalFrameworkPackageRoot??=toCanonicalPath(resolvePackageRoot()),nearestPackageRoot(e)===canonicalFrameworkPackageRoot}function toExternalModuleId(e,t){return t===`require-call`&&e.startsWith(`file:`)?fileURLToPath(e):e}function resolveExistingExternalFilePath(e){if(existsSync(e))return e;for(let t of RESOLVE_EXTENSIONS){let n=`${e}${t}`;if(existsSync(n))return n}}function isPackageImport(e){return isPathImport(e)||/^(?:node|data|file):/.test(e)?!1:!e.startsWith(`@/`)}function isPathImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}const SELF_MODIFICATION_MOUNT_SPECIFIERS=new Set([`eve/self-modification`,`eve/self-modification/local`,`eve/self-modification/remote`]);function isFrameworkRuntimeImport(e,t){return SELF_MODIFICATION_MOUNT_SPECIFIERS.has(e)?!1:e===`eve`||e.startsWith(`eve/`)?!0:e===`workflow`||e.startsWith(`workflow/`)||e.startsWith(`@workflow/`)?t===void 0||!isNodeModulesPath(t):!1}function resolveFrameworkRuntimeImport(e){return e===`eve`||e.startsWith(`eve/`)?e:normalizeEsmImportSpecifier(resolveWorkflowModulePath(e))}function resolveRuntimeLoaderFrameworkImport(e){return e===`eve`||e.startsWith(`eve/`)?normalizeEsmImportSpecifier(resolvePackageDependencyPath(e)):resolveFrameworkRuntimeImport(e)}function isNodeModulesPath(e){return e.replaceAll(`\\`,`/`).includes(`/node_modules/`)}function toCanonicalPath(e){try{return realpathSync(e)}catch{return resolve(e)}}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies,packageImportName,resolveConfiguredExternalDependency};
@@ -4,6 +4,8 @@ export type RolldownOutputChunk = {
4
4
  readonly fileName: string;
5
5
  readonly imports: readonly string[];
6
6
  readonly dynamicImports: readonly string[];
7
+ readonly isEntry: boolean;
8
+ readonly name: string;
7
9
  };
8
10
  export type RolldownOutputAsset = {
9
11
  readonly type: "asset";
@@ -21,7 +23,9 @@ export declare function parseWithNitroRolldownAst(filename: string, sourceText:
21
23
  * code are dropped unless the caller supplies its own `onLog`, except
22
24
  * unresolved imports.
23
25
  */
24
- export declare function buildWithNitroRolldown(options: Record<string, unknown>): Promise<RolldownOutput>;
26
+ export declare function buildWithNitroRolldown(options: Record<string, unknown> & {
27
+ readonly experimental?: Record<string, unknown>;
28
+ }): Promise<RolldownOutput>;
25
29
  export declare const ROLLDOWN_STANDARD_CONDITION_NAMES: ReadonlySet<string>;
26
30
  /**
27
31
  * Runs a Rolldown build whose contract is exactly one in-memory chunk:
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{pathToFileURL}from"node:url";import{onVendoredDependencyLog}from"#internal/bundler/vendored-dependency-log.js";let rolldownPromise,rolldownParseAstPromise;function loadNitroRolldown(){return rolldownPromise??=(async()=>{let e=createRequire(import.meta.url),t=createRequire(e.resolve(`nitro/package.json`)).resolve(`rolldown`);return await import(pathToFileURL(t).href)})(),rolldownPromise}function loadNitroRolldownParseAst(){return rolldownParseAstPromise??=(async()=>{let e=createRequire(import.meta.url),t=createRequire(e.resolve(`nitro/package.json`)).resolve(`rolldown/parseAst`);return await import(pathToFileURL(t).href)})(),rolldownParseAstPromise}function inferRolldownParserLanguage(e){return e.endsWith(`.tsx`)?`tsx`:e.endsWith(`.jsx`)?`jsx`:/\.[cm]?ts$/.test(e)?`ts`:`js`}async function parseWithNitroRolldownAst(e,t){let{parseAst:n}=await loadNitroRolldownParseAst();return n(t,{astType:`ts`,lang:inferRolldownParserLanguage(e),range:!0,sourceType:`module`},e)}async function buildWithNitroRolldown(e){assertCustomRolldownConditionNames(e);let{build:t}=await loadNitroRolldown();return await t({onLog:onRolldownBuildLog,...e})}function onRolldownBuildLog(e,t,n){if(e===`warn`&&t?.code===`UNRESOLVED_IMPORT`){n(e,t);return}onVendoredDependencyLog(e,t,n)}const ROLLDOWN_STANDARD_CONDITION_NAMES=new Set([`browser`,`default`,`import`,`node`,`require`]);function assertCustomRolldownConditionNames(e){let t=e.resolve;if(typeof t!=`object`||!t)return;let n=Reflect.get(t,`conditionNames`);if(Array.isArray(n)){for(let e of n)if(typeof e==`string`&&ROLLDOWN_STANDARD_CONDITION_NAMES.has(e))throw Error(`Rolldown resolves the standard condition ${JSON.stringify(e)} per import edge; conditionNames may contain only eve-specific additions.`)}}async function buildSingleRolldownChunk(e,t){return getSingleRolldownChunk(await buildWithNitroRolldown({...t,write:!1,output:{...t.output,codeSplitting:!1}}),e)}function getSingleRolldownChunk(e,t){let n=e.output.filter(e=>e.type===`chunk`),r=n[0];if(r===void 0||n.length!==1)throw Error(`Expected one bundled ${t}.`);return r}export{ROLLDOWN_STANDARD_CONDITION_NAMES,buildSingleRolldownChunk,buildWithNitroRolldown,parseWithNitroRolldownAst};
1
+ import{createRequire}from"node:module";import{pathToFileURL}from"node:url";import{onVendoredDependencyLog}from"#internal/bundler/vendored-dependency-log.js";let rolldownPromise,rolldownParseAstPromise;function loadNitroRolldown(){return rolldownPromise??=(async()=>{let e=createRequire(import.meta.url),t=createRequire(e.resolve(`nitro/package.json`)).resolve(`rolldown`);return await import(pathToFileURL(t).href)})(),rolldownPromise}function loadNitroRolldownParseAst(){return rolldownParseAstPromise??=(async()=>{let e=createRequire(import.meta.url),t=createRequire(e.resolve(`nitro/package.json`)).resolve(`rolldown/parseAst`);return await import(pathToFileURL(t).href)})(),rolldownParseAstPromise}function inferRolldownParserLanguage(e){return e.endsWith(`.tsx`)?`tsx`:e.endsWith(`.jsx`)?`jsx`:/\.[cm]?ts$/.test(e)?`ts`:`js`}async function parseWithNitroRolldownAst(e,t){let{parseAst:n}=await loadNitroRolldownParseAst();return n(t,{astType:`ts`,lang:inferRolldownParserLanguage(e),range:!0,sourceType:`module`},e)}async function buildWithNitroRolldown(e){assertCustomRolldownConditionNames(e);let{build:t}=await loadNitroRolldown();return await t({onLog:onRolldownBuildLog,...e,experimental:{...e.experimental,attachDebugInfo:`none`}})}function onRolldownBuildLog(e,t,n){if(e===`warn`&&t?.code===`UNRESOLVED_IMPORT`){n(e,t);return}onVendoredDependencyLog(e,t,n)}const ROLLDOWN_STANDARD_CONDITION_NAMES=new Set([`browser`,`default`,`import`,`node`,`require`]);function assertCustomRolldownConditionNames(e){let t=e.resolve;if(typeof t!=`object`||!t)return;let n=Reflect.get(t,`conditionNames`);if(Array.isArray(n)){for(let e of n)if(typeof e==`string`&&ROLLDOWN_STANDARD_CONDITION_NAMES.has(e))throw Error(`Rolldown resolves the standard condition ${JSON.stringify(e)} per import edge; conditionNames may contain only eve-specific additions.`)}}async function buildSingleRolldownChunk(e,t){return getSingleRolldownChunk(await buildWithNitroRolldown({...t,write:!1,output:{...t.output,codeSplitting:!1}}),e)}function getSingleRolldownChunk(e,t){let n=e.output.filter(e=>e.type===`chunk`),r=n[0];if(r===void 0||n.length!==1)throw Error(`Expected one bundled ${t}.`);return r}export{ROLLDOWN_STANDARD_CONDITION_NAMES,buildSingleRolldownChunk,buildWithNitroRolldown,parseWithNitroRolldownAst};
@@ -4,3 +4,4 @@ export declare function loadFrameworkProgrammaticModule(backing: Extract<AgentMo
4
4
  readonly kind: "programmatic";
5
5
  }>, dependencyNamespaces?: Readonly<Record<string, ProgrammaticModuleNamespace>>): Promise<ProgrammaticModuleNamespace>;
6
6
  export { memoizeModuleNamespaceFactories } from "#compiler/source-graph.js";
7
+ export { interopAuthoredModuleNamespace } from "#internal/authored-module.js";
@@ -1 +1 @@
1
- import{getDevelopmentExtensionSourceRegistry}from"#compiler/development-extensions.js";import{loadProgrammaticModuleNamespace,memoizeModuleNamespaceFactories,memoizeModuleNamespaceFactories as memoizeModuleNamespaceFactories$1}from"#compiler/source-graph.js";import{frameworkAgentSourceRegistry}from"#framework/sources/registry.js";async function loadFrameworkProgrammaticModule(e,t){return memoizeModuleNamespaceFactories$1(await loadProgrammaticModuleNamespace({backing:e,dependencyNamespaces:t,registries:[frameworkAgentSourceRegistry,getDevelopmentExtensionSourceRegistry()]}))}export{loadFrameworkProgrammaticModule,memoizeModuleNamespaceFactories};
1
+ import{interopAuthoredModuleNamespace}from"#internal/authored-module.js";import{getDevelopmentExtensionSourceRegistry}from"#compiler/development-extensions.js";import{loadProgrammaticModuleNamespace,memoizeModuleNamespaceFactories,memoizeModuleNamespaceFactories as memoizeModuleNamespaceFactories$1}from"#compiler/source-graph.js";import{frameworkAgentSourceRegistry}from"#framework/sources/registry.js";async function loadFrameworkProgrammaticModule(e,t){return memoizeModuleNamespaceFactories$1(await loadProgrammaticModuleNamespace({backing:e,dependencyNamespaces:t,registries:[frameworkAgentSourceRegistry,getDevelopmentExtensionSourceRegistry()]}))}export{interopAuthoredModuleNamespace,loadFrameworkProgrammaticModule,memoizeModuleNamespaceFactories};
@@ -1 +1 @@
1
- import{randomUUID}from"node:crypto";import{cp,mkdir,readFile,rm,symlink,writeFile}from"node:fs/promises";import{existsSync,readFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createDevelopmentSourceSnapshotPlan,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts-retention.js";import{resolveDevelopmentRuntimeArtifactsSnapshotsDirectory}from"#internal/nitro/dev-runtime-generation-metadata.js";function resolveDevelopmentRuntimeArtifactsPointerPath(e){return join(e,`.eve`,`dev-runtime`,`current.json`)}function isDevelopmentRuntimeArtifactsSnapshotRoot(e,t){return dirname(resolve(t))===resolve(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e))}async function stageDevelopmentRuntimeArtifactsSnapshot(e){let t=join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.project.appRoot),`${Date.now().toString(36)}-${randomUUID()}`),n=await createDevelopmentSourceSnapshotPlan({appRoot:e.project.appRoot,authoredSourceRoots:collectExtensionMountSourceRoots(e.manifest),snapshotRoot:t});try{await copyDevelopmentSourceSnapshot(n),await mountFrameworkPackage(n.runtimeAppRoot),await mountExtensionExternalDependencies({manifest:e.manifest,runtimeAppRoot:n.runtimeAppRoot}),await cp(e.paths.compileDirectoryPath,join(n.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,extensionPackageRoots:(e.manifest?.subagents??[]).flatMap(e=>e.owner.kind===`extension`?[{sourceRoot:e.agent.appRoot,packageName:e.owner.packageName}]:[]),manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),snapshotSourceRoot:n.snapshotSourceRoot}),await writeFile(join(t,`generation.json`),`${JSON.stringify({runtimeAppRoot:n.runtimeAppRoot})}\n`)}catch(e){throw await rm(t,{force:!0,recursive:!0}).catch(()=>{}),e}return{sourceWatchPaths:n.watchPaths,runtimeAppRoot:n.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}}async function mountFrameworkPackage(e){let t=join(e,`node_modules`,`eve`);await mkdir(dirname(t),{recursive:!0}),await rm(t,{force:!0,recursive:!0}),await symlink(resolvePackageRoot(),t,`junction`)}async function mountExtensionExternalDependencies(e){if(e.manifest===void 0)return;let t=[e.manifest,...(e.manifest.subagents??[]).map(e=>e.agent)].flatMap(e=>e.extensionMounts??[]).filter(e=>(e.externalDependencies??[]).length>0);for(let[n,r]of Object.entries(resolveExtensionExternalDependencyPaths(t))){let t=findPackageRoot(r,n),i=join(e.runtimeAppRoot,`node_modules`,...n.split(`/`));await mkdir(dirname(i),{recursive:!0}),await rm(i,{force:!0,recursive:!0}),await symlink(t,i,`junction`)}}function findPackageRoot(e,t){let n=dirname(e);for(;;){let e=join(n,`package.json`);if(existsSync(e))try{if(JSON.parse(readFileSync(e,`utf8`)).name===t)return n}catch{}let r=dirname(n);if(r===n)throw Error(`Cannot locate package root for extension external dependency "${t}".`);n=r}}async function activateDevelopmentRuntimeArtifactsSnapshotTransaction(e){let t=await readMaterializedAuthoredModuleIndex(e.snapshot.runtimeAppRoot);if(t===void 0||!existsSync(join(e.snapshot.runtimeAppRoot,`.eve`,`compile`,t.moduleMap)))throw Error(`Cannot activate development runtime generation "${e.snapshot.snapshotRoot}" before its authored modules are materialized.`);let n=join(e.snapshot.snapshotRoot,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),r=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),i=readDevelopmentRuntimeArtifactsPointer(r),a=await readOptionalFile(r);try{await writeFile(n,``),await writeDevelopmentRuntimeArtifactsPointer(e),i?.version===2&&i.snapshotRoot!==e.snapshot.snapshotRoot&&isDevelopmentRuntimeArtifactsSnapshotRoot(e.appRoot,i.snapshotRoot)&&await recordRetiredDevelopmentRuntimeArtifactsSnapshot(i.snapshotRoot).catch(e=>{console.warn(`[eve:dev] failed to record retired runtime generation "${i.snapshotRoot}": ${String(e)}`)})}catch(e){throw await rollbackFailedActivation({cause:e,markerPath:n,pointerPath:r,previousPointerSource:a})}let o=!1;return{commit(){o=!0},async rollback(){if(o)return;o=!0;let e=await restoreDevelopmentRuntimeArtifactsActivation({markerPath:n,pointerPath:r,previousPointerSource:a});if(e!==void 0)throw e}}}function readDevelopmentRuntimeArtifactsSnapshotRoot(e){let t=readDevelopmentRuntimeArtifactsPointer(e);if(t!==void 0)return t.version===1?t.appRoot:t.runtimeAppRoot}function readActiveDevelopmentRuntimeArtifactsSnapshot(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e));if(t!==void 0&&t.version!==1)return{runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot}}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function pruneDevelopmentRuntimeArtifactsSnapshots(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot));return await pruneDevelopmentRuntimeArtifactsSnapshotDirectory({activeSnapshotRoot:t?.version===2?t.snapshotRoot:void 0,gracePeriodMs:e.gracePeriodMs,now:e.now,protectAll:t?.version===1,retainCount:e.retainCount,snapshotsDirectory:resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.appRoot)})}function collectExtensionMountSourceRoots(e){return e===void 0?[]:[e,...(e.subagents??[]).map(e=>e.agent)].flatMap(e=>(e.extensionMounts??[]).map(e=>e.sourceRoot))}function readDevelopmentRuntimeArtifactsPointer(e){if(e!==void 0&&existsSync(e))try{let t=JSON.parse(readFileSync(e,`utf8`));return t.kind!==`eve-dev-runtime-artifacts-pointer`||typeof t.version!=`number`?void 0:t.version===1&&typeof t.appRoot==`string`&&t.appRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:t.version===2&&typeof t.appRoot==`string`&&typeof t.runtimeAppRoot==`string`&&t.runtimeAppRoot.length>0&&typeof t.snapshotRoot==`string`&&t.snapshotRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot,version:2}:void 0}catch{return}}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:t});await writeFile(e.manifestPath,`${JSON.stringify(n,null,2)}\n`)}function rewriteManifestRoots(e){if(Array.isArray(e.value))return e.value.map(t=>rewriteManifestRoots({...e,value:t}));if(e.value===null||typeof e.value!=`object`)return e.value;let t={};for(let[n,r]of Object.entries(e.value)){if(typeof r==`string`&&(n===`appRoot`||n===`agentRoot`)){t[n]=isPathInsideOrEqual(r,e.appRoot)||e.extensionPackageRoots.some(e=>isPathInsideOrEqual(r,e.sourceRoot))?rewritePathWithinAppRoot({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,path:r,runtimeAppRoot:e.runtimeAppRoot}):rewritePathWithinSourceRoot({path:r,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot});continue}if(typeof r==`string`&&n===`sourceRoot`){t[n]=rewritePathWithinSourceRoot({path:r,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot});continue}t[n]=rewriteManifestRoots({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:r})}return t}function rewritePathWithinSourceRoot(e){return isPathInsideOrEqual(e.path,e.sourceRoot)?toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:e.path,sourceRoot:e.sourceRoot}):e.path}function rewritePathWithinAppRoot(e){if(!isPathInsideOrEqual(e.path,e.appRoot)){let t=e.extensionPackageRoots.find(t=>isPathInsideOrEqual(e.path,t.sourceRoot));return t===void 0?e.path:join(e.runtimeAppRoot,`node_modules`,t.packageName,relative(t.sourceRoot,e.path))}let t=relative(e.appRoot,e.path);return t.length===0?e.runtimeAppRoot:join(e.runtimeAppRoot,t)}async function writeDevelopmentRuntimeArtifactsPointer(e){let t=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),n={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await writeDevelopmentRuntimeArtifactsPointerSource(t,`${JSON.stringify(n,null,2)}\n`)}async function writeDevelopmentRuntimeArtifactsPointerSource(e,t){let n=`${e}.${randomUUID()}.tmp`;await mkdir(dirname(e),{recursive:!0}),await writeFile(n,t);try{await renameWithTransientBusyRetry(n,e)}catch(e){throw await rm(n,{force:!0}).catch(()=>{}),e}}async function readOptionalFile(e){try{return await readFile(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}}async function rollbackFailedActivation(e){let t=await restoreDevelopmentRuntimeArtifactsActivation(e);return t===void 0?e.cause:AggregateError([e.cause,t],`Development runtime activation and rollback failed.`,{cause:e.cause})}async function restoreDevelopmentRuntimeArtifactsActivation(e){let t=(await Promise.allSettled([e.previousPointerSource===void 0?rm(e.pointerPath,{force:!0}):writeDevelopmentRuntimeArtifactsPointerSource(e.pointerPath,e.previousPointerSource),rm(e.markerPath,{force:!0})])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length!==0)return AggregateError(t,`Failed to restore development runtime activation.`)}async function validateSnapshotCompiledManifestRoots(e){let t=collectManifestRootPaths(JSON.parse(await readFile(e.manifestPath,`utf8`)));for(let n of t)if(!isPathInsideOrEqual(n,e.snapshotSourceRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime snapshot source root "${e.snapshotSourceRoot}".`)}function collectManifestRootPaths(e){if(Array.isArray(e))return e.flatMap(e=>collectManifestRootPaths(e));if(typeof e!=`object`||!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if((n===`appRoot`||n===`agentRoot`)&&typeof r==`string`){t.push(r);continue}t.push(...collectManifestRootPaths(r))}return t}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,readActiveDevelopmentRuntimeArtifactsSnapshot,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
1
+ import{randomUUID}from"node:crypto";import{cp,mkdir,readFile,rm,symlink,writeFile}from"node:fs/promises";import{existsSync,readFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{resolveDevelopmentStateDirectory}from"#internal/application/dev-environment.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createDevelopmentSourceSnapshotPlan,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts-retention.js";import{resolveDevelopmentRuntimeArtifactsSnapshotsDirectory}from"#internal/nitro/dev-runtime-generation-metadata.js";function resolveDevelopmentRuntimeArtifactsPointerPath(e){return join(resolveDevelopmentStateDirectory(e),`dev-runtime`,`current.json`)}function isDevelopmentRuntimeArtifactsSnapshotRoot(e,t){return dirname(resolve(t))===resolve(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e))}async function stageDevelopmentRuntimeArtifactsSnapshot(e){let t=join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.project.appRoot),`${Date.now().toString(36)}-${randomUUID()}`),n=await createDevelopmentSourceSnapshotPlan({appRoot:e.project.appRoot,authoredSourceRoots:collectExtensionMountSourceRoots(e.manifest),snapshotRoot:t});try{await copyDevelopmentSourceSnapshot(n),await mountFrameworkPackage(n.runtimeAppRoot),await mountExtensionExternalDependencies({manifest:e.manifest,runtimeAppRoot:n.runtimeAppRoot}),await cp(e.paths.compileDirectoryPath,join(n.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,extensionPackageRoots:(e.manifest?.subagents??[]).flatMap(e=>e.owner.kind===`extension`?[{sourceRoot:e.agent.appRoot,packageName:e.owner.packageName}]:[]),manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),snapshotSourceRoot:n.snapshotSourceRoot}),await writeFile(join(t,`generation.json`),`${JSON.stringify({runtimeAppRoot:n.runtimeAppRoot})}\n`)}catch(e){throw await rm(t,{force:!0,recursive:!0}).catch(()=>{}),e}return{sourceWatchPaths:n.watchPaths,runtimeAppRoot:n.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}}async function mountFrameworkPackage(e){let t=join(e,`node_modules`,`eve`);await mkdir(dirname(t),{recursive:!0}),await rm(t,{force:!0,recursive:!0}),await symlink(resolvePackageRoot(),t,`junction`)}async function mountExtensionExternalDependencies(e){if(e.manifest===void 0)return;let t=[e.manifest,...(e.manifest.subagents??[]).map(e=>e.agent)].flatMap(e=>e.extensionMounts??[]).filter(e=>(e.externalDependencies??[]).length>0);for(let[n,r]of Object.entries(resolveExtensionExternalDependencyPaths(t))){let t=findPackageRoot(r,n),i=join(e.runtimeAppRoot,`node_modules`,...n.split(`/`));await mkdir(dirname(i),{recursive:!0}),await rm(i,{force:!0,recursive:!0}),await symlink(t,i,`junction`)}}function findPackageRoot(e,t){let n=dirname(e);for(;;){let e=join(n,`package.json`);if(existsSync(e))try{if(JSON.parse(readFileSync(e,`utf8`)).name===t)return n}catch{}let r=dirname(n);if(r===n)throw Error(`Cannot locate package root for extension external dependency "${t}".`);n=r}}async function activateDevelopmentRuntimeArtifactsSnapshotTransaction(e){let t=await readMaterializedAuthoredModuleIndex(e.snapshot.runtimeAppRoot);if(t===void 0||!existsSync(join(e.snapshot.runtimeAppRoot,`.eve`,`compile`,t.moduleMap)))throw Error(`Cannot activate development runtime generation "${e.snapshot.snapshotRoot}" before its authored modules are materialized.`);let n=join(e.snapshot.snapshotRoot,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),r=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),i=readDevelopmentRuntimeArtifactsPointer(r),a=await readOptionalFile(r);try{await writeFile(n,``),await writeDevelopmentRuntimeArtifactsPointer(e),i?.version===2&&i.snapshotRoot!==e.snapshot.snapshotRoot&&isDevelopmentRuntimeArtifactsSnapshotRoot(e.appRoot,i.snapshotRoot)&&await recordRetiredDevelopmentRuntimeArtifactsSnapshot(i.snapshotRoot).catch(e=>{console.warn(`[eve:dev] failed to record retired runtime generation "${i.snapshotRoot}": ${String(e)}`)})}catch(e){throw await rollbackFailedActivation({cause:e,markerPath:n,pointerPath:r,previousPointerSource:a})}let o=!1;return{commit(){o=!0},async rollback(){if(o)return;o=!0;let e=await restoreDevelopmentRuntimeArtifactsActivation({markerPath:n,pointerPath:r,previousPointerSource:a});if(e!==void 0)throw e}}}function readDevelopmentRuntimeArtifactsSnapshotRoot(e){let t=readDevelopmentRuntimeArtifactsPointer(e);if(t!==void 0)return t.version===1?t.appRoot:t.runtimeAppRoot}function readActiveDevelopmentRuntimeArtifactsSnapshot(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e));if(t!==void 0&&t.version!==1)return{runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot}}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function pruneDevelopmentRuntimeArtifactsSnapshots(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot));return await pruneDevelopmentRuntimeArtifactsSnapshotDirectory({activeSnapshotRoot:t?.version===2?t.snapshotRoot:void 0,gracePeriodMs:e.gracePeriodMs,now:e.now,protectAll:t?.version===1,retainCount:e.retainCount,snapshotsDirectory:resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.appRoot)})}function collectExtensionMountSourceRoots(e){return e===void 0?[]:[e,...(e.subagents??[]).map(e=>e.agent)].flatMap(e=>(e.extensionMounts??[]).map(e=>e.sourceRoot))}function readDevelopmentRuntimeArtifactsPointer(e){if(e!==void 0&&existsSync(e))try{let t=JSON.parse(readFileSync(e,`utf8`));return t.kind!==`eve-dev-runtime-artifacts-pointer`||typeof t.version!=`number`?void 0:t.version===1&&typeof t.appRoot==`string`&&t.appRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:t.version===2&&typeof t.appRoot==`string`&&typeof t.runtimeAppRoot==`string`&&t.runtimeAppRoot.length>0&&typeof t.snapshotRoot==`string`&&t.snapshotRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot,version:2}:void 0}catch{return}}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:t});await writeFile(e.manifestPath,`${JSON.stringify(n,null,2)}\n`)}function rewriteManifestRoots(e){if(Array.isArray(e.value))return e.value.map(t=>rewriteManifestRoots({...e,value:t}));if(e.value===null||typeof e.value!=`object`)return e.value;let t={};for(let[n,r]of Object.entries(e.value)){if(typeof r==`string`&&(n===`appRoot`||n===`agentRoot`)){t[n]=isPathInsideOrEqual(r,e.appRoot)||e.extensionPackageRoots.some(e=>isPathInsideOrEqual(r,e.sourceRoot))?rewritePathWithinAppRoot({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,path:r,runtimeAppRoot:e.runtimeAppRoot}):rewritePathWithinSourceRoot({path:r,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot});continue}if(typeof r==`string`&&n===`sourceRoot`){t[n]=rewritePathWithinSourceRoot({path:r,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot});continue}t[n]=rewriteManifestRoots({appRoot:e.appRoot,extensionPackageRoots:e.extensionPackageRoots,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:r})}return t}function rewritePathWithinSourceRoot(e){return isPathInsideOrEqual(e.path,e.sourceRoot)?toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:e.path,sourceRoot:e.sourceRoot}):e.path}function rewritePathWithinAppRoot(e){if(!isPathInsideOrEqual(e.path,e.appRoot)){let t=e.extensionPackageRoots.find(t=>isPathInsideOrEqual(e.path,t.sourceRoot));return t===void 0?e.path:join(e.runtimeAppRoot,`node_modules`,t.packageName,relative(t.sourceRoot,e.path))}let t=relative(e.appRoot,e.path);return t.length===0?e.runtimeAppRoot:join(e.runtimeAppRoot,t)}async function writeDevelopmentRuntimeArtifactsPointer(e){let t=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),n={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await writeDevelopmentRuntimeArtifactsPointerSource(t,`${JSON.stringify(n,null,2)}\n`)}async function writeDevelopmentRuntimeArtifactsPointerSource(e,t){let n=`${e}.${randomUUID()}.tmp`;await mkdir(dirname(e),{recursive:!0}),await writeFile(n,t);try{await renameWithTransientBusyRetry(n,e)}catch(e){throw await rm(n,{force:!0}).catch(()=>{}),e}}async function readOptionalFile(e){try{return await readFile(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}}async function rollbackFailedActivation(e){let t=await restoreDevelopmentRuntimeArtifactsActivation(e);return t===void 0?e.cause:AggregateError([e.cause,t],`Development runtime activation and rollback failed.`,{cause:e.cause})}async function restoreDevelopmentRuntimeArtifactsActivation(e){let t=(await Promise.allSettled([e.previousPointerSource===void 0?rm(e.pointerPath,{force:!0}):writeDevelopmentRuntimeArtifactsPointerSource(e.pointerPath,e.previousPointerSource),rm(e.markerPath,{force:!0})])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length!==0)return AggregateError(t,`Failed to restore development runtime activation.`)}async function validateSnapshotCompiledManifestRoots(e){let t=collectManifestRootPaths(JSON.parse(await readFile(e.manifestPath,`utf8`)));for(let n of t)if(!isPathInsideOrEqual(n,e.snapshotSourceRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime snapshot source root "${e.snapshotSourceRoot}".`)}function collectManifestRootPaths(e){if(Array.isArray(e))return e.flatMap(e=>collectManifestRootPaths(e));if(typeof e!=`object`||!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if((n===`appRoot`||n===`agentRoot`)&&typeof r==`string`){t.push(r);continue}t.push(...collectManifestRootPaths(r))}return t}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,readActiveDevelopmentRuntimeArtifactsSnapshot,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
@@ -1 +1 @@
1
- import{readFile,readdir}from"node:fs/promises";import{basename,join}from"node:path";function resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e){return join(e,`.eve`,`dev-runtime`,`snapshots`)}async function listDevelopmentGenerationIds(e){try{return(await readdir(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e),{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return[];throw e}}async function readDevelopmentGenerationMetadata(e,t){if(!t||t===`.`||t===`..`||basename(t)!==t)throw Error(`Workflow run references an invalid development generation.`);let n;try{n=await readFile(join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e),t,`generation.json`),`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{kind:`missing`};throw e}let r;try{r=JSON.parse(n)}catch{return{kind:`invalid`}}return typeof r!=`object`||!r||Array.isArray(r)||!(`runtimeAppRoot`in r)||typeof r.runtimeAppRoot!=`string`||r.runtimeAppRoot.length===0?{kind:`invalid`}:{kind:`ready`,metadata:{runtimeAppRoot:r.runtimeAppRoot}}}export{listDevelopmentGenerationIds,readDevelopmentGenerationMetadata,resolveDevelopmentRuntimeArtifactsSnapshotsDirectory};
1
+ import{readFile,readdir}from"node:fs/promises";import{basename,join}from"node:path";import{resolveDevelopmentStateDirectory}from"#internal/application/dev-environment.js";function resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e){return join(resolveDevelopmentStateDirectory(e),`dev-runtime`,`snapshots`)}async function listDevelopmentGenerationIds(e){try{return(await readdir(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e),{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return[];throw e}}async function readDevelopmentGenerationMetadata(e,t){if(!t||t===`.`||t===`..`||basename(t)!==t)throw Error(`Workflow run references an invalid development generation.`);let n;try{n=await readFile(join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e),t,`generation.json`),`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{kind:`missing`};throw e}let r;try{r=JSON.parse(n)}catch{return{kind:`invalid`}}return typeof r!=`object`||!r||Array.isArray(r)||!(`runtimeAppRoot`in r)||typeof r.runtimeAppRoot!=`string`||r.runtimeAppRoot.length===0?{kind:`invalid`}:{kind:`ready`,metadata:{runtimeAppRoot:r.runtimeAppRoot}}}export{listDevelopmentGenerationIds,readDevelopmentGenerationMetadata,resolveDevelopmentRuntimeArtifactsSnapshotsDirectory};
@@ -1 +1 @@
1
- import{readFile}from"node:fs/promises";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{isObject}from"#shared/guards.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import{resolveInstalledPackageInfo,resolvePackageSourceFilePath}from"#internal/application/package.js";import{normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{toErrorMessage}from"#shared/errors.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{ApplicationBuildProfiler,createApplicationBuildProfile,measureApplicationBuildOutput,writeApplicationBuildProfile}from"#internal/application/build-profile.js";import{RecoverablePublicationError,publishApplicationBuildArtifacts}from"#internal/application/output-publication.js";import{stageProductionCompilerArtifacts}from"#internal/application/production-compiler-artifacts.js";import{materializeVercelWorkflowFunctionOutput,normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{emitConnectManifest}from"#internal/external-resources.js";import{copyHostMiddlewareFunctions}from"#internal/nitro/host/copy-host-middleware.js";import{normalizeVercelServiceCrons}from"#internal/nitro/host/normalize-vercel-service-crons.js";import{prepareProductionApplicationHost,refreshProductionCompiledArtifacts}from"#internal/nitro/host/prepare-application-host.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";import{resolveEveServicePrefixByRoot}from"#internal/vercel/vercel-service-config-operations.js";import{parseVercelServicesConfig}from"#internal/vercel/vercel-services-config.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}async function measureBuildPhase(e,t,n){return e===void 0?n():e.measure(t,n)}function isPathInside(e,t){let n=relative(e,t);return n.length===0||!n.startsWith(`..${sep}`)&&n!==`..`&&!isAbsolute(n)}function assertProfileOutputOutsideBuildOutput(e,t){if(e!==void 0&&isPathInside(t,e))throw Error(`Build profile path ${e} must be outside the published output directory ${t}.`)}async function writeOptionalApplicationBuildProfile(e){try{assertProfileOutputOutsideBuildOutput(e.profileOutputPath,e.outputDirectory);let t=e.profiler.finish(),n=await measureApplicationBuildOutput(e.outputDirectory);await writeApplicationBuildProfile(e.profileOutputPath,createApplicationBuildProfile({output:n,target:process.env.VERCEL?`vercel`:`local`,timing:t}))}catch(t){console.warn(`eve: failed to write optional build profile to ${e.profileOutputPath}; continuing with the published build output: ${toErrorMessage(t)}`)}}async function resolveEveServicePrefixForVercelFunctionOutput(e,t){let n=Array.from(new Set([resolve(e),resolve(t)])),r=await findClosestVercelOutputDirectory(e);if(r!==void 0)try{let e=join(r,`config.json`),t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),i=resolveEveServicePrefixByRoot({appRoots:n,configRoot:await resolveVercelOutputConfigRoot(r),config:t});if(i!==void 0)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let i=e;for(;;){for(let e of[join(i,`vercel.json`),join(i,`.vercel`,`output`,`config.json`)])try{let t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),r=e.endsWith(`vercel.json`)?i:await resolveVercelOutputConfigRoot(dirname(e)),a=resolveEveServicePrefixByRoot({appRoots:n,configRoot:r,config:t});if(a!==void 0)return a}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let e=dirname(i);if(e===i)return;i=e}}async function resolveVercelOutputConfigRoot(e){let t=dirname(dirname(e));try{let e=JSON.parse(await readFile(join(t,`.vercel`,`project.json`),`utf8`));if(isObject(e)&&isObject(e.settings)){let n=e.settings.rootDirectory;if(typeof n==`string`&&n.trim().length>0)return resolve(t,n)}}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return t}async function buildNitroOutput(e,t,n){let r=trimTrailingSlash(e.options.output.dir);return await measureBuildPhase(t,`${n}.cache.prepare`,()=>prepareEveVersionedCacheDirectory(r)),await measureBuildPhase(t,`${n}.prepare`,()=>prepare(e)),await measureBuildPhase(t,`${n}.public-assets`,()=>copyPublicAssets(e)),await measureBuildPhase(t,`${n}.prerender`,()=>prerender(e)),await measureBuildPhase(t,`${n}.bundle`,()=>build(e)),await measureBuildPhase(t,`${n}.cache.write`,()=>writeEveVersionedCacheMetadata(r)),r}async function buildApplication(e,t){let n=t.profileOutputPath===void 0?void 0:resolve(t.profileOutputPath),r=n===void 0?void 0:new ApplicationBuildProfiler,i=await measureBuildPhase(r,`extension.check`,()=>tryReadExtensionBuildConfig(e));if(i!==null)throw Error(`Package "${i.packageName}" is an eve extension. Run \`eve extension build\` instead of \`eve build\`.`);let a=await measureBuildPhase(r,`project.resolve`,()=>resolveDiscoveryProject(e)),o=await measureBuildPhase(r,`workspace.create`,()=>createApplicationBuildWorkspace(a.appRoot,t.vercelServiceOutput?.serviceOutputDirectory)),s=!1,c;try{c=await buildApplicationInWorkspace(o,t,r)}catch(e){throw s=e instanceof RecoverablePublicationError,e}finally{s||await measureBuildPhase(r,`workspace.remove`,()=>removeApplicationBuildWorkspace(o))}return r!==void 0&&n!==void 0&&await writeOptionalApplicationBuildProfile({outputDirectory:c,profileOutputPath:n,profiler:r}),c}async function buildApplicationInWorkspace(e,t,n){let r=await measureBuildPhase(n,`host.prepare`,()=>prepareProductionApplicationHost(e)),i=!!process.env.VERCEL,a=i?await measureBuildPhase(n,`vercel.service-prefix.resolve`,()=>resolveEveServicePrefixForVercelFunctionOutput(r.appRoot,r.compileResult.project.agentRoot)):void 0,o=normalizePublicRoutePrefix(a),s=o===EVE_ROUTE_PREFIX?void 0:o;if(t.publicRoutePrefix!==void 0&&s!==void 0&&t.publicRoutePrefix!==s)throw Error(`EVE_PUBLIC_ROUTE_PREFIX ${JSON.stringify(t.publicRoutePrefix)} conflicts with the configured Vercel service prefix ${JSON.stringify(a)}.`);let c=t.publicRoutePrefix??s,l=createProductionNitroArtifactsConfig(e.appRoot).sandboxScope,u=await measureBuildPhase(n,`nitro.create`,()=>createProductionApplicationNitro(r,{buildDir:e.nitro.buildDir,outputDir:e.publication.output.stagedDir,publicRoutePrefix:c,workspaceMember:t.workspaceMember}));try{if(!t.skipSandboxPrewarm){let t={appRoot:r.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(e.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:r.appRoot,sandboxScope:l}),log(e){console.log(e)}};await measureBuildPhase(n,`sandbox.prewarm`,async()=>{i?await runVercelBuildPrewarm(t):await prewarmAppSandboxes(t)}),await refreshProductionCompiledArtifacts(r,e.host.artifactsDir)}await buildNitroOutput(u,n,`nitro`),i&&await measureBuildPhase(n,`vercel.workflow-function.materialize`,()=>materializeVercelWorkflowFunctionOutput(e.publication.output.stagedDir)),a!==void 0&&await measureBuildPhase(n,`vercel.functions.normalize`,()=>normalizeEveVercelFunctionOutput(e.publication.output.stagedDir,{servicePrefix:a}));let o=t.vercelServiceOutput;o!==void 0&&(await measureBuildPhase(n,`vercel.service-crons.normalize`,()=>normalizeVercelServiceCrons({publicRoutePrefix:c,serviceOutputDirectory:e.publication.output.stagedDir})),await measureBuildPhase(n,`vercel.host-middleware.copy`,()=>copyHostMiddlewareFunctions({hostOutputDirectory:o.hostOutputDirectory,serviceOutputDirectory:e.publication.output.stagedDir}))),await measureBuildPhase(n,`agent-summary.emit`,()=>emitVercelAgentSummary({manifest:r.compileResult.manifest,outputPath:e.publication.summary.stagedPath})),await measureBuildPhase(n,`connect-manifest.emit`,()=>emitConnectManifest({appRoot:r.appRoot,generatorVersion:resolveInstalledPackageInfo().version,manifest:r.compileResult.manifest,outputDirectory:e.publication.output.stagedDir,publicRoutePrefix:c})),i||await measureBuildPhase(n,`compiler-artifacts.stage`,()=>stageProductionCompilerArtifacts({compilerArtifactsRoot:e.compiler.artifactsDir,outputDir:e.publication.output.stagedDir}))}finally{await measureBuildPhase(n,`nitro.close`,()=>u.close())}return await measureBuildPhase(n,`output.publish`,()=>publishCompletedApplicationBuild(e)),e.publication.output.finalDir}async function publishCompletedApplicationBuild(e){await publishApplicationBuildArtifacts({appRoot:e.appRoot,finalOutputDir:e.publication.output.finalDir,finalSummaryPath:e.publication.summary.finalPath,scratchDir:e.rootDir,stagedOutputDir:e.publication.output.stagedDir,stagedSummaryPath:e.publication.summary.stagedPath})}export{buildApplication};
1
+ import{readFile}from"node:fs/promises";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{isObject}from"#shared/guards.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import{resolveInstalledPackageInfo,resolvePackageSourceFilePath}from"#internal/application/package.js";import{normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{toErrorMessage}from"#shared/errors.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{ApplicationBuildProfiler,createApplicationBuildProfile,measureApplicationBuildOutput,writeApplicationBuildProfile}from"#internal/application/build-profile.js";import{RecoverablePublicationError,publishApplicationBuildArtifacts}from"#internal/application/output-publication.js";import{stageProductionCompilerArtifacts}from"#internal/application/production-compiler-artifacts.js";import{stageBuildDeploymentId}from"#internal/nitro/host/stage-build-deployment-id.js";import{materializeVercelWorkflowFunctionOutput,normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{emitConnectManifest}from"#internal/external-resources.js";import{copyHostMiddlewareFunctions}from"#internal/nitro/host/copy-host-middleware.js";import{normalizeVercelServiceCrons}from"#internal/nitro/host/normalize-vercel-service-crons.js";import{prepareProductionApplicationHost,refreshProductionCompiledArtifacts}from"#internal/nitro/host/prepare-application-host.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";import{resolveEveServicePrefixByRoot}from"#internal/vercel/vercel-service-config-operations.js";import{parseVercelServicesConfig}from"#internal/vercel/vercel-services-config.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}async function measureBuildPhase(e,t,n){return e===void 0?n():e.measure(t,n)}function isPathInside(e,t){let n=relative(e,t);return n.length===0||!n.startsWith(`..${sep}`)&&n!==`..`&&!isAbsolute(n)}function assertProfileOutputOutsideBuildOutput(e,t){if(e!==void 0&&isPathInside(t,e))throw Error(`Build profile path ${e} must be outside the published output directory ${t}.`)}async function writeOptionalApplicationBuildProfile(e){try{assertProfileOutputOutsideBuildOutput(e.profileOutputPath,e.outputDirectory);let t=e.profiler.finish(),n=await measureApplicationBuildOutput(e.outputDirectory);await writeApplicationBuildProfile(e.profileOutputPath,createApplicationBuildProfile({deploymentId:e.deploymentId,output:n,target:process.env.VERCEL?`vercel`:`local`,timing:t}))}catch(t){console.warn(`eve: failed to write optional build profile to ${e.profileOutputPath}; continuing with the published build output: ${toErrorMessage(t)}`)}}async function resolveEveServicePrefixForVercelFunctionOutput(e,t){let n=Array.from(new Set([resolve(e),resolve(t)])),r=await findClosestVercelOutputDirectory(e);if(r!==void 0)try{let e=join(r,`config.json`),t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),i=resolveEveServicePrefixByRoot({appRoots:n,configRoot:await resolveVercelOutputConfigRoot(r),config:t});if(i!==void 0)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let i=e;for(;;){for(let e of[join(i,`vercel.json`),join(i,`.vercel`,`output`,`config.json`)])try{let t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),r=e.endsWith(`vercel.json`)?i:await resolveVercelOutputConfigRoot(dirname(e)),a=resolveEveServicePrefixByRoot({appRoots:n,configRoot:r,config:t});if(a!==void 0)return a}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let e=dirname(i);if(e===i)return;i=e}}async function resolveVercelOutputConfigRoot(e){let t=dirname(dirname(e));try{let e=JSON.parse(await readFile(join(t,`.vercel`,`project.json`),`utf8`));if(isObject(e)&&isObject(e.settings)){let n=e.settings.rootDirectory;if(typeof n==`string`&&n.trim().length>0)return resolve(t,n)}}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return t}async function buildNitroOutput(e,t,n){let r=trimTrailingSlash(e.options.output.dir);return await measureBuildPhase(t,`${n}.cache.prepare`,()=>prepareEveVersionedCacheDirectory(r)),await measureBuildPhase(t,`${n}.prepare`,()=>prepare(e)),await measureBuildPhase(t,`${n}.public-assets`,()=>copyPublicAssets(e)),await measureBuildPhase(t,`${n}.prerender`,()=>prerender(e)),await measureBuildPhase(t,`${n}.bundle`,()=>build(e)),await measureBuildPhase(t,`${n}.cache.write`,()=>writeEveVersionedCacheMetadata(r)),r}async function buildApplication(e,t){let n=t.profileOutputPath===void 0?void 0:resolve(t.profileOutputPath),r=n===void 0?void 0:new ApplicationBuildProfiler,i=await measureBuildPhase(r,`extension.check`,()=>tryReadExtensionBuildConfig(e));if(i!==null)throw Error(`Package "${i.packageName}" is an eve extension. Run \`eve extension build\` instead of \`eve build\`.`);let a=await measureBuildPhase(r,`project.resolve`,()=>resolveDiscoveryProject(e)),o=await measureBuildPhase(r,`workspace.create`,()=>createApplicationBuildWorkspace(a.appRoot,t.vercelServiceOutput?.serviceOutputDirectory)),s=!1,c;try{c=await buildApplicationInWorkspace(o,t,r)}catch(e){throw s=e instanceof RecoverablePublicationError,e}finally{s||await measureBuildPhase(r,`workspace.remove`,()=>removeApplicationBuildWorkspace(o))}return r!==void 0&&n!==void 0&&await writeOptionalApplicationBuildProfile({deploymentId:c.deploymentId,outputDirectory:c.outputDirectory,profileOutputPath:n,profiler:r}),c.outputDirectory}async function buildApplicationInWorkspace(e,t,n){let r=await measureBuildPhase(n,`host.prepare`,()=>prepareProductionApplicationHost(e)),i=!!process.env.VERCEL,a=i?await measureBuildPhase(n,`vercel.service-prefix.resolve`,()=>resolveEveServicePrefixForVercelFunctionOutput(r.appRoot,r.compileResult.project.agentRoot)):void 0,o=normalizePublicRoutePrefix(a),s=o===EVE_ROUTE_PREFIX?void 0:o;if(t.publicRoutePrefix!==void 0&&s!==void 0&&t.publicRoutePrefix!==s)throw Error(`EVE_PUBLIC_ROUTE_PREFIX ${JSON.stringify(t.publicRoutePrefix)} conflicts with the configured Vercel service prefix ${JSON.stringify(a)}.`);let c=t.publicRoutePrefix??s,l=createProductionNitroArtifactsConfig(e.appRoot).sandboxScope,u=await measureBuildPhase(n,`nitro.create`,()=>createProductionApplicationNitro(r,{buildDir:e.nitro.buildDir,outputDir:e.publication.output.stagedDir,publicRoutePrefix:c,workspaceMember:t.workspaceMember}));try{if(!t.skipSandboxPrewarm){let t={appRoot:r.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(e.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:r.appRoot,sandboxScope:l}),log(e){console.log(e)}};await measureBuildPhase(n,`sandbox.prewarm`,async()=>{i?await runVercelBuildPrewarm(t):await prewarmAppSandboxes(t)}),await refreshProductionCompiledArtifacts(r,e.host.artifactsDir)}await buildNitroOutput(u,n,`nitro`),i&&await measureBuildPhase(n,`vercel.workflow-function.materialize`,()=>materializeVercelWorkflowFunctionOutput(e.publication.output.stagedDir)),a!==void 0&&await measureBuildPhase(n,`vercel.functions.normalize`,()=>normalizeEveVercelFunctionOutput(e.publication.output.stagedDir,{servicePrefix:a}));let o=t.vercelServiceOutput;o!==void 0&&(await measureBuildPhase(n,`vercel.service-crons.normalize`,()=>normalizeVercelServiceCrons({publicRoutePrefix:c,serviceOutputDirectory:e.publication.output.stagedDir})),await measureBuildPhase(n,`vercel.host-middleware.copy`,()=>copyHostMiddlewareFunctions({hostOutputDirectory:o.hostOutputDirectory,serviceOutputDirectory:e.publication.output.stagedDir}))),await measureBuildPhase(n,`agent-summary.emit`,()=>emitVercelAgentSummary({manifest:r.compileResult.manifest,outputPath:e.publication.summary.stagedPath})),await measureBuildPhase(n,`connect-manifest.emit`,()=>emitConnectManifest({appRoot:r.appRoot,generatorVersion:resolveInstalledPackageInfo().version,manifest:r.compileResult.manifest,outputDirectory:e.publication.output.stagedDir,publicRoutePrefix:c})),i||await measureBuildPhase(n,`compiler-artifacts.stage`,()=>stageProductionCompilerArtifacts({compilerArtifactsRoot:e.compiler.artifactsDir,outputDir:e.publication.output.stagedDir}))}finally{await measureBuildPhase(n,`nitro.close`,()=>u.close())}let d=u.options.preset===`node-server`?await measureBuildPhase(n,`id.compute`,()=>stageBuildDeploymentId(e.publication.output.stagedDir)):void 0;return await measureBuildPhase(n,`output.publish`,()=>publishCompletedApplicationBuild(e)),{deploymentId:d,outputDirectory:e.publication.output.finalDir}}async function publishCompletedApplicationBuild(e){await publishApplicationBuildArtifacts({appRoot:e.appRoot,finalOutputDir:e.publication.output.finalDir,finalSummaryPath:e.publication.summary.finalPath,scratchDir:e.rootDir,stagedOutputDir:e.publication.output.stagedDir,stagedSummaryPath:e.publication.summary.stagedPath})}export{buildApplication};
@@ -0,0 +1,8 @@
1
+ export declare const BUILD_DEPLOYMENT_ID_PLACEHOLDER = "eve_BUILD_DEPLOYMENT_ID_PLACEHOLDER_";
2
+ export interface BuildDeploymentFile {
3
+ readonly relativePath: string;
4
+ readonly bytes: Uint8Array;
5
+ }
6
+ /** Hashes files in path order while holding at most `READ_AHEAD` files in memory. */
7
+ export declare function computeBuildDeploymentId(relativePaths: readonly string[], readBytes: (relativePath: string) => Promise<Uint8Array>, extraInputs?: readonly string[]): Promise<string>;
8
+ export declare function replaceBuildDeploymentId(files: readonly BuildDeploymentFile[], deploymentId: string): BuildDeploymentFile;
@@ -0,0 +1 @@
1
+ import{createHash}from"node:crypto";import{BUILD_DEPLOYMENT_ID_PATTERN}from"#execution/install-workflow-deployment-id.js";const BUILD_DEPLOYMENT_ID_PLACEHOLDER=`eve_BUILD_DEPLOYMENT_ID_PLACEHOLDER_`;async function computeBuildDeploymentId(e,t,n=[]){let r=createHash(`sha256`),append=e=>{r.update(`${e.byteLength}:`),r.update(e)};r.update(`eve-build-v1\0`);let i=e.filter(e=>e!==`nitro.json`).sort((e,t)=>e<t?-1:+(e>t)),a=[],startRead=e=>{if(e>=i.length)return;let n=t(i[e]);n.catch(()=>void 0),a[e]=n};for(let e=0;e<16;e++)startRead(e);for(let e=0;e<i.length;e++){let t=await a[e];delete a[e],startRead(e+16),r.update(`file\0`),append(Buffer.from(i[e])),append(t)}for(let e of[...n].sort())r.update(`input\0`),append(Buffer.from(e));return`eve_${r.digest(`hex`).slice(0,32)}`}function replaceBuildDeploymentId(e,t){let n=Buffer.from(BUILD_DEPLOYMENT_ID_PLACEHOLDER),r=Buffer.from(t);if(!BUILD_DEPLOYMENT_ID_PATTERN.test(t)||r.length!==n.length)throw Error(`Invalid build deployment id: expected eve_ followed by 32 lowercase hex characters.`);let i,a=0;for(let t of e){let e=Buffer.from(t.bytes);for(let r=e.indexOf(n);r!==-1;r=e.indexOf(n,r+n.length))a++,i={file:t,offset:r}}if(a!==1||i===void 0)throw Error(`Cannot install build deployment id: expected exactly one workflow-world placeholder in server/**/*.mjs outside node_modules, found ${a}. This is an eve bug; please report it.`);let o=Buffer.from(i.file.bytes);return r.copy(o,i.offset),{relativePath:i.file.relativePath,bytes:o}}export{BUILD_DEPLOYMENT_ID_PLACEHOLDER,computeBuildDeploymentId,replaceBuildDeploymentId};
@@ -1 +1 @@
1
- import{readFile}from"node:fs/promises";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{fileURLToPath}from"node:url";import{resolveAuthoredTsConfigPath}from"#internal/authored-module-loader.js";import{extensionOverridePaths}from"#compiler/extension-mount-bindings.js";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{createExtensionMountPlugin}from"#internal/bundler/extension-mount-plugin.js";import{createExtensionScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{applyWorkflowTransform}from"#internal/workflow-bundle/workflow-builders.js";import{createExtensionExternalDependencyPlugin,resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createNitro}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{hasVercelScheduleCollections,usesLocalVercelSchedules}from"#internal/schedules/consumer-route.js";import{configureInstrumentationEntry}from"#internal/nitro/host/instrumentation-entry.js";import{createCompiledSandboxProviderPrunePlugin}from"#internal/nitro/host/compiled-sandbox-provider-prune-plugin.js";import{createDevelopmentRuntimePrunePlugin}from"#internal/nitro/host/development-runtime-prune-plugin.js";import{prepareSkillServerAssets}from"#internal/nitro/host/skill-server-assets.js";import{configureDevelopmentNitroRoutes,configureProductionNitroRoutes}from"#internal/nitro/host/configure-nitro-routes.js";import{applyEveCronHandlerRoute}from"#internal/nitro/host/cron-handler-route.js";import{createExternalDependencyOutputCheckPlugin}from"#internal/nitro/host/external-dependency-output-check-plugin.js";import{createNitroBundlerConfig}from"#internal/nitro/host/nitro-bundler-config.js";import{OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME,createOptionalEngineDependencyPlugin}from"#internal/nitro/host/optional-engine-dependency-plugin.js";import{addNitroRoutingImportSpecifierPlugin}from"#internal/nitro/host/nitro-routing-import-specifier-plugin.js";import{registerScheduleTaskHandlers}from"#internal/nitro/host/schedule-task-routes.js";import{createEveVercelOptions}from"#internal/nitro/host/vercel-build-output-config.js";const WORKFLOW_ALIAS_SPECIFIERS=[`workflow`,`workflow/api`,`workflow/errors`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`],INSTRUMENTATION_ALIAS_PATHS={"eve/instrumentation":`src/public/instrumentation/index.ts`,"eve/instrumentation/otel":`src/public/instrumentation/otel.ts`},WORKFLOW_TRANSFORM_PATCHED=Symbol(`eve.workflow-transform-patched`),EVE_NITRO_BUILDER=`rolldown`,LOCAL_SANDBOX_BACKEND_NAMES=new Set([`docker`,...Object.keys(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME)]);function resolveWorkflowAliases(){let e={};for(let t of WORKFLOW_ALIAS_SPECIFIERS)e[t]=resolveWorkflowModulePath(t);return e}function resolveProductionNitroPreset(){return process.env.VERCEL?`vercel`:void 0}function manifestHasWorkflowProgram(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>e.tools.some(e=>e.workflowProgram!==void 0))}function manifestHasWebSocketChannel(e){return e.channelRoutes.effective.some(e=>e.method===`WEBSOCKET`)}function collectHostedTraceDependencies(e,t){let n=new Set(collectExtensionExternalDependencies(e.compileResult.manifest)),r=collectConfiguredExternalDependencies(e.compileResult.manifest);return[...new Set([...t,...r,...[...n].map(e=>`${e}*`)])].filter(e=>e!==EVE_PACKAGE_NAME&&e!==`${EVE_PACKAGE_NAME}*`)}function collectConfiguredExternalDependencies(e){return[...e.config.build?.externalDependencies??[],...e.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])]}function collectExtensionExternalDependencies(e){return[e,...e.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.flatMap(e=>e.externalDependencies))}function collectConfiguredSandboxProviderNames(e){let t=[e,...e.subagents.map(e=>e.agent)];return new Set(t.map(e=>e.sandbox?.providerName).filter(e=>typeof e==`string`))}function shouldPruneLocalSandboxProviders(e){return e.preset===`vercel`&&![...e.configuredBackendNames].some(e=>LOCAL_SANDBOX_BACKEND_NAMES.has(e))}function createDevelopmentWatchOptions(e){return{ignored:[e,join(e,`**`)]}}function normalizePath(e){return e.replaceAll(`\\`,`/`)}function stripPathQueryAndHash(e){let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function stripFileSystemPrefix(e){return e.startsWith(`/@fs/`)?e.slice(4):e}function resolveNitroModuleComparisonPath(e,t){return t.startsWith(`file://`)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(fileURLToPath(t)))):isAbsolute(t)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(t))):normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(resolve(e,t))))}function isWorkflowBundlePath(e,t){let n=normalizePath(e);return n.startsWith(t)||n.includes(`/.eve/workflow-cache/`)}function normalizeStepTransformComparisonPath(e){let t=normalizePath(e);return process.platform===`win32`?t.toLowerCase():t}function parseImportedModuleSpecifiers(e){let t=/^\s*import\s+(?:.+?\s+from\s+)?["']([^"']+)["'];?\s*$/gm,n=[];for(let r of e.matchAll(t)){let e=r[1];e!==void 0&&n.push(e)}return n}function resolveNitroImportPath(e,t,n){return t.startsWith(`workflow`)?resolveWorkflowModulePath(t):t.startsWith(`.`)||t.startsWith(`/`)||t.startsWith(`file://`)?resolveNitroModuleComparisonPath(n===void 0?e:dirname(resolveNitroModuleComparisonPath(e,n)),t):null}async function collectNitroStepTransformTargets(e,t){let n=await readFile(e,`utf8`),r=new Set;for(let i of parseImportedModuleSpecifiers(n)){let n=resolveNitroImportPath(t,i,e);n!==null&&r.add(normalizeStepTransformComparisonPath(n))}return r}async function addNitroStepNoExternals(e,t){if(e.options.noExternals===!0)return;let n;try{n=await collectNitroStepTransformTargets(t,e.options.rootDir)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let r=Array.isArray(e.options.noExternals)?[...e.options.noExternals]:[];e.options.noExternals=[...new Set([...r,...n])]}function createRelativeTransformFilename(e,t){let n=createPackageRelativeTransformFilename(t);if(n!==void 0)return n;let r=normalizePath(e).replace(/\/$/,``),i=normalizePath(t),a=r.toLowerCase(),o=i.toLowerCase();if(o.startsWith(`${a}/`))return i.slice(r.length+1);if(o===a)return`.`;let s=relative(r,i).replaceAll(`\\`,`/`);if(s.startsWith(`../`)&&(s=s.split(`/`).filter(e=>e!==`..`).join(`/`)),s.includes(`:`)||s.startsWith(`/`)){let e=i.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return s}function createPackageRelativeTransformFilename(e){let t=normalizePath(resolvePackageRoot()).replace(/\/$/,``),n=normalizePath(e),r=t.toLowerCase(),i=n.toLowerCase(),a=`${t}/src/`,o=`${r}/src/`,s=`${t}/dist/src/`,c=`${r}/dist/src/`;if(i.startsWith(o))return`src/${n.slice(a.length)}`;if(i.startsWith(c))return`src/${n.slice(s.length)}`}function addWorkflowModuleSideEffectsPlugin(e,t){let n=[t,join(e.options.buildDir,`workflow`)].map(t=>resolveNitroModuleComparisonPath(e.options.rootDir,t));e.hooks.hook(`rollup:before`,(t,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`eve:workflow-module-side-effects`,resolveId(t,r){let i=resolveNitroImportPath(e.options.rootDir,t,r)??resolveNitroModuleComparisonPath(e.options.rootDir,t);return n.some(e=>isWorkflowBundlePath(i,e))?{id:i,moduleSideEffects:`no-treeshake`}:null}})})}function addNitroStepModuleSideEffectsPlugin(e,t){e.hooks.hook(`rollup:before`,(n,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`eve:workflow-step-module-side-effects`,async resolveId(n,r){let i=resolveNitroImportPath(e.options.rootDir,n,r);return i===null||!(await t()).has(normalizeStepTransformComparisonPath(i))?null:{id:i,moduleSideEffects:`no-treeshake`}}})})}function addNitroStepTransformPlugin(e,t){e.hooks.hook(`rollup:before`,(n,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({async transform(n,r){let i=await t(),a=resolveNitroModuleComparisonPath(e.options.rootDir,r);return i.has(normalizeStepTransformComparisonPath(a))?{code:(await applyWorkflowTransform(createRelativeTransformFilename(e.options.rootDir,a),n,`step`,a,e.options.rootDir)).code,map:null}:null},name:`eve:workflow-step-transform`})})}function addInstrumentationModuleSideEffectsPlugin(e,t){let n=new Set(t.map(normalizePath));e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`eve:instrumentation-module-side-effects`,resolveId(e){return n.has(normalizePath(e))?{id:e,moduleSideEffects:`no-treeshake`}:null}})})}function patchWorkflowTransformExcludePath(e,t){let n=normalizePath(t);e.hooks.hook(`rollup:before`,(e,t)=>{if(Array.isArray(t.plugins))for(let e of t.plugins){if(typeof e!=`object`||!e)continue;let t=e;if(t.name!==`workflow:transform`||t[WORKFLOW_TRANSFORM_PATCHED]===!0||typeof t.transform!=`function`)continue;let r=t.transform;t.transform=function(e,t,...i){return isWorkflowBundlePath(t,n)?null:r.call(this,e,t,...i)},t[WORKFLOW_TRANSFORM_PATCHED]=!0}})}function createApplicationNitroBundlerConfiguration(e,t){let{preset:n}=t,r=collectConfiguredSandboxProviderNames(e.compileResult.manifest),i=shouldPruneLocalSandboxProviders({configuredBackendNames:r,preset:n})?createCompiledSandboxProviderPrunePlugin():null,a=[],o=[];for(let[e,t]of Object.entries(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME))(r.has(e)?a:o).push(t);let s=createExtensionScopePlugin([e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({sourceRoot:e.sourceRoot,mountId:e.mountId})))),c=[e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts),l=[t.development?null:createDevelopmentRuntimePrunePlugin(),i,createOptionalEngineDependencyPlugin(o),createExtensionExternalDependencyPlugin(c),t.development?null:createExternalDependencyOutputCheckPlugin({appRoot:e.appRoot,externalDependencies:collectConfiguredExternalDependencies(e.compileResult.manifest)}),createExtensionMountPlugin(c,extensionOverridePaths(e.compileResult.manifest)),s].filter(e=>e!==null);return{nitroRolldownConfig:{output:{sourcemapIgnoreList:/node_modules/},tsconfig:resolveAuthoredTsConfigPath(e.appRoot)},nitroRollupConfig:createNitroBundlerConfig(l),tracedAppDependencies:collectHostedTraceDependencies(e,a),tracedAppDependencyPaths:resolveExtensionExternalDependencyPaths(c)}}function createApplicationNitroPlugins(e){let t=[e.compiledArtifacts.bootstrapPath,e.compiledArtifacts.workflowWorldPluginPath];return manifestHasWorkflowProgram(e.compileResult.manifest)&&t.push(resolvePackageSourceFilePath(`src/internal/nitro/host/workflow-sandbox-runtime-plugin.ts`)),e.compiledArtifacts.instrumentationPluginPath!==void 0&&t.push(e.compiledArtifacts.instrumentationPluginPath),t}function configureSharedApplicationNitro(e,t){t.compiledArtifacts.instrumentationPluginPath!==void 0&&configureInstrumentationEntry(e,t.compiledArtifacts.instrumentationPluginPath),addNitroRoutingImportSpecifierPlugin(e);let n=resolveWorkflowAliases();for(let[t,r]of Object.entries(n))e.options.alias[t]=r;for(let[t,n]of Object.entries(INSTRUMENTATION_ALIAS_PATHS))e.options.alias[t]=resolvePackageSourceFilePath(n);addWorkflowModuleSideEffectsPlugin(e,t.workflowBuildDir),patchWorkflowTransformExcludePath(e,t.workflowBuildDir),t.compiledArtifacts.instrumentationSourcePaths!==void 0&&addInstrumentationModuleSideEffectsPlugin(e,t.compiledArtifacts.instrumentationSourcePaths)}function configureNitroStepPlugins(e,t){let n,getTargets=()=>n??=collectNitroStepTransformTargets(t,e.options.rootDir),invalidate=()=>{n=void 0};return e.hooks.hook(`build:before`,invalidate),addNitroStepModuleSideEffectsPlugin(e,getTargets),addNitroStepTransformPlugin(e,getTargets),[invalidate]}function externalizeDevelopmentWorkflowBundle(e,t){let n=new Set([normalizePath(join(t.workflowBuildDir,`workflows.mjs`))]);e.hooks.hook(`rollup:before`,(e,t)=>{let r=t.external;t.external=(e,...t)=>{if(n.has(normalizePath(e)))return!0;if(typeof r==`function`)return r(e,...t)}})}async function createDevelopmentApplicationNitro(e){let t=e.workspace.nitroBuildDir,n=createApplicationNitroBundlerConfiguration(e,{development:!0,preset:void 0}),r=createApplicationNitroPlugins(e);usesLocalVercelSchedules(e.compileResult.manifest)&&r.push(resolvePackageSourceFilePath(`src/internal/nitro/host/local-schedules-runtime-plugin.ts`)),e.compiledArtifacts.instrumentationPluginPath===void 0&&r.unshift(resolvePackageSourceFilePath(`src/internal/nitro/host/local-tracing-runtime-plugin.ts`)),await prepareEveVersionedCacheDirectory(t);let i=await createNitro({_cli:{command:`dev`},builder:EVE_NITRO_BUILDER,buildDir:t,dev:!0,features:{websocket:!0},logLevel:1,output:{dir:e.workspace.nitroOutputDir},plugins:r,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:n.nitroRolldownConfig,rollupConfig:n.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:n.tracedAppDependencies,traceOpts:{nft:{paths:n.tracedAppDependencyPaths}},vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:!1}),watchOptions:createDevelopmentWatchOptions(e.appRoot)},{watch:!0});await writeEveVersionedCacheMetadata(t);let a=join(i.options.buildDir,`workflow`,`steps.mjs`);configureSharedApplicationNitro(i,e);let o=configureNitroStepPlugins(i,a);return i.hooks.hook(`dev:reload`,()=>{for(let e of o)e()}),externalizeDevelopmentWorkflowBundle(i,e),await configureDevelopmentNitroRoutes(i,e),await addNitroStepNoExternals(i,a),i}async function createProductionApplicationNitro(e,t){let n=resolveProductionNitroPreset(),r=createApplicationNitroBundlerConfiguration(e,{development:!1,preset:n}),i=createApplicationNitroPlugins(e);i.push(resolvePackageSourceFilePath(`src/internal/nitro/host/sandbox-shutdown-plugin.ts`)),await prepareEveVersionedCacheDirectory(t.buildDir);let{manifest:a,paths:o}=e.compileResult,s=await prepareSkillServerAssets({stagingDirectory:join(t.buildDir,`eve-skill-assets`),skills:a.skills.map(e=>e.name),skillsRoot:join(o.compileDirectoryPath,a.workspaceResourceRoot.logicalPath,`skills`)}),c=await createNitro({_cli:{command:`build`},builder:EVE_NITRO_BUILDER,buildDir:t.buildDir,dev:!1,features:{websocket:manifestHasWebSocketChannel(e.compileResult.manifest)},logging:{compressedSizes:!1},output:{dir:t.outputDir},preset:n,plugins:i,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:r.nitroRolldownConfig,rollupConfig:r.nitroRollupConfig,rootDir:e.appRoot,serverAssets:s,serverDir:!1,traceDeps:r.tracedAppDependencies,traceOpts:{nft:{paths:r.tracedAppDependencyPaths}},vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:n===`vercel`,hasVercelScheduleCollections:hasVercelScheduleCollections(e.compileResult.manifest),publicRoutePrefix:t.publicRoutePrefix,workspaceMember:t.workspaceMember})});if(await writeEveVersionedCacheMetadata(t.buildDir),c.options.serverAssets=c.options.serverAssets.filter(e=>e.baseName!==`server`),configureSharedApplicationNitro(c,e),configureNitroStepPlugins(c,join(e.workflowBuildDir,`steps.mjs`)),e.scheduleRegistrations.length>0){applyEveCronHandlerRoute(c);let t=createProductionNitroArtifactsConfig(e.appRoot);registerScheduleTaskHandlers(c,{artifactsConfig:t,dispatchModulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/schedule-task.ts`),registrations:e.scheduleRegistrations})}return await configureProductionNitroRoutes(c,e),await addNitroStepNoExternals(c,join(e.workflowBuildDir,`steps.mjs`)),c}export{createDevelopmentApplicationNitro,createProductionApplicationNitro,shouldPruneLocalSandboxProviders};
1
+ import{readFile}from"node:fs/promises";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{fileURLToPath}from"node:url";import{extensionOverridePaths}from"#compiler/extension-mount-bindings.js";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{resolveAuthoredTsConfigPath}from"#internal/authored-module-build-options.js";import{createExtensionMountPlugin}from"#internal/bundler/extension-mount-plugin.js";import{createExtensionScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{applyWorkflowTransform}from"#internal/workflow-bundle/workflow-builders.js";import{createExtensionExternalDependencyPlugin,resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createNitro}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{hasVercelScheduleCollections,usesLocalVercelSchedules}from"#internal/schedules/consumer-route.js";import{configureInstrumentationEntry}from"#internal/nitro/host/instrumentation-entry.js";import{createCompiledSandboxProviderPrunePlugin}from"#internal/nitro/host/compiled-sandbox-provider-prune-plugin.js";import{createDevelopmentRuntimePrunePlugin}from"#internal/nitro/host/development-runtime-prune-plugin.js";import{prepareSkillServerAssets}from"#internal/nitro/host/skill-server-assets.js";import{configureDevelopmentNitroRoutes,configureProductionNitroRoutes}from"#internal/nitro/host/configure-nitro-routes.js";import{applyEveCronHandlerRoute}from"#internal/nitro/host/cron-handler-route.js";import{createExternalDependencyOutputCheckPlugin}from"#internal/nitro/host/external-dependency-output-check-plugin.js";import{createNitroBundlerConfig}from"#internal/nitro/host/nitro-bundler-config.js";import{OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME,createOptionalEngineDependencyPlugin}from"#internal/nitro/host/optional-engine-dependency-plugin.js";import{addNitroRoutingImportSpecifierPlugin}from"#internal/nitro/host/nitro-routing-import-specifier-plugin.js";import{registerScheduleTaskHandlers}from"#internal/nitro/host/schedule-task-routes.js";import{createEveVercelOptions}from"#internal/nitro/host/vercel-build-output-config.js";const WORKFLOW_ALIAS_SPECIFIERS=[`workflow`,`workflow/api`,`workflow/errors`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`],INSTRUMENTATION_ALIAS_PATHS={"eve/instrumentation":`src/public/instrumentation/index.ts`,"eve/instrumentation/otel":`src/public/instrumentation/otel.ts`},WORKFLOW_TRANSFORM_PATCHED=Symbol(`eve.workflow-transform-patched`),EVE_NITRO_BUILDER=`rolldown`,LOCAL_SANDBOX_BACKEND_NAMES=new Set([`docker`,...Object.keys(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME)]);function resolveWorkflowAliases(){let e={};for(let t of WORKFLOW_ALIAS_SPECIFIERS)e[t]=resolveWorkflowModulePath(t);return e}function resolveProductionNitroPreset(){return process.env.VERCEL?`vercel`:void 0}function manifestHasWorkflowProgram(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>e.tools.some(e=>e.workflowProgram!==void 0))}function manifestHasWebSocketChannel(e){return e.channelRoutes.effective.some(e=>e.method===`WEBSOCKET`)}function collectHostedTraceDependencies(e,t){let n=new Set(collectExtensionExternalDependencies(e.compileResult.manifest)),r=collectConfiguredExternalDependencies(e.compileResult.manifest);return[...new Set([...t,...r,...[...n].map(e=>`${e}*`)])].filter(e=>e!==EVE_PACKAGE_NAME&&e!==`${EVE_PACKAGE_NAME}*`)}function collectConfiguredExternalDependencies(e){return[...e.config.build?.externalDependencies??[],...e.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])]}function collectExtensionExternalDependencies(e){return[e,...e.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.flatMap(e=>e.externalDependencies))}function collectConfiguredSandboxProviderNames(e){let t=[e,...e.subagents.map(e=>e.agent)];return new Set(t.map(e=>e.sandbox?.providerName).filter(e=>typeof e==`string`))}function shouldPruneLocalSandboxProviders(e){return e.preset===`vercel`&&![...e.configuredBackendNames].some(e=>LOCAL_SANDBOX_BACKEND_NAMES.has(e))}function createDevelopmentWatchOptions(e){return{ignored:[e,join(e,`**`)]}}function normalizePath(e){return e.replaceAll(`\\`,`/`)}function stripPathQueryAndHash(e){let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function stripFileSystemPrefix(e){return e.startsWith(`/@fs/`)?e.slice(4):e}function resolveNitroModuleComparisonPath(e,t){return t.startsWith(`file://`)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(fileURLToPath(t)))):isAbsolute(t)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(t))):normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(resolve(e,t))))}function isWorkflowBundlePath(e,t){let n=normalizePath(e);return n.startsWith(t)||n.includes(`/.eve/workflow-cache/`)}function normalizeStepTransformComparisonPath(e){let t=normalizePath(e);return process.platform===`win32`?t.toLowerCase():t}function parseImportedModuleSpecifiers(e){let t=/^\s*import\s+(?:.+?\s+from\s+)?["']([^"']+)["'];?\s*$/gm,n=[];for(let r of e.matchAll(t)){let e=r[1];e!==void 0&&n.push(e)}return n}function resolveNitroImportPath(e,t,n){return t.startsWith(`workflow`)?resolveWorkflowModulePath(t):t.startsWith(`.`)||t.startsWith(`/`)||t.startsWith(`file://`)?resolveNitroModuleComparisonPath(n===void 0?e:dirname(resolveNitroModuleComparisonPath(e,n)),t):null}async function collectNitroStepTransformTargets(e,t){let n=await readFile(e,`utf8`),r=new Set;for(let i of parseImportedModuleSpecifiers(n)){let n=resolveNitroImportPath(t,i,e);n!==null&&r.add(normalizeStepTransformComparisonPath(n))}return r}async function addNitroStepNoExternals(e,t){if(e.options.noExternals===!0)return;let n;try{n=await collectNitroStepTransformTargets(t,e.options.rootDir)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let r=Array.isArray(e.options.noExternals)?[...e.options.noExternals]:[];e.options.noExternals=[...new Set([...r,...n])]}function createRelativeTransformFilename(e,t){let n=createPackageRelativeTransformFilename(t);if(n!==void 0)return n;let r=normalizePath(e).replace(/\/$/,``),i=normalizePath(t),a=r.toLowerCase(),o=i.toLowerCase();if(o.startsWith(`${a}/`))return i.slice(r.length+1);if(o===a)return`.`;let s=relative(r,i).replaceAll(`\\`,`/`);if(s.startsWith(`../`)&&(s=s.split(`/`).filter(e=>e!==`..`).join(`/`)),s.includes(`:`)||s.startsWith(`/`)){let e=i.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return s}function createPackageRelativeTransformFilename(e){let t=normalizePath(resolvePackageRoot()).replace(/\/$/,``),n=normalizePath(e),r=t.toLowerCase(),i=n.toLowerCase(),a=`${t}/src/`,o=`${r}/src/`,s=`${t}/dist/src/`,c=`${r}/dist/src/`;if(i.startsWith(o))return`src/${n.slice(a.length)}`;if(i.startsWith(c))return`src/${n.slice(s.length)}`}function addWorkflowModuleSideEffectsPlugin(e,t){let n=[t,join(e.options.buildDir,`workflow`)].map(t=>resolveNitroModuleComparisonPath(e.options.rootDir,t));e.hooks.hook(`rollup:before`,(t,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`eve:workflow-module-side-effects`,resolveId(t,r){let i=resolveNitroImportPath(e.options.rootDir,t,r)??resolveNitroModuleComparisonPath(e.options.rootDir,t);return n.some(e=>isWorkflowBundlePath(i,e))?{id:i,moduleSideEffects:`no-treeshake`}:null}})})}function addNitroStepModuleSideEffectsPlugin(e,t){e.hooks.hook(`rollup:before`,(n,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`eve:workflow-step-module-side-effects`,async resolveId(n,r){let i=resolveNitroImportPath(e.options.rootDir,n,r);return i===null||!(await t()).has(normalizeStepTransformComparisonPath(i))?null:{id:i,moduleSideEffects:`no-treeshake`}}})})}function addNitroStepTransformPlugin(e,t){e.hooks.hook(`rollup:before`,(n,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({async transform(n,r){let i=await t(),a=resolveNitroModuleComparisonPath(e.options.rootDir,r);return i.has(normalizeStepTransformComparisonPath(a))?{code:(await applyWorkflowTransform(createRelativeTransformFilename(e.options.rootDir,a),n,`step`,a,e.options.rootDir)).code,map:null}:null},name:`eve:workflow-step-transform`})})}function addInstrumentationModuleSideEffectsPlugin(e,t){let n=new Set(t.map(normalizePath));e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`eve:instrumentation-module-side-effects`,resolveId(e){return n.has(normalizePath(e))?{id:e,moduleSideEffects:`no-treeshake`}:null}})})}function patchWorkflowTransformExcludePath(e,t){let n=normalizePath(t);e.hooks.hook(`rollup:before`,(e,t)=>{if(Array.isArray(t.plugins))for(let e of t.plugins){if(typeof e!=`object`||!e)continue;let t=e;if(t.name!==`workflow:transform`||t[WORKFLOW_TRANSFORM_PATCHED]===!0||typeof t.transform!=`function`)continue;let r=t.transform;t.transform=function(e,t,...i){return isWorkflowBundlePath(t,n)?null:r.call(this,e,t,...i)},t[WORKFLOW_TRANSFORM_PATCHED]=!0}})}function createApplicationNitroBundlerConfiguration(e,t){let{preset:n}=t,r=collectConfiguredSandboxProviderNames(e.compileResult.manifest),i=shouldPruneLocalSandboxProviders({configuredBackendNames:r,preset:n})?createCompiledSandboxProviderPrunePlugin():null,a=[],o=[];for(let[e,t]of Object.entries(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME))(r.has(e)?a:o).push(t);let s=createExtensionScopePlugin([e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({sourceRoot:e.sourceRoot,mountId:e.mountId})))),c=[e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts),l=[t.development?null:createDevelopmentRuntimePrunePlugin(),i,createOptionalEngineDependencyPlugin(o),createExtensionExternalDependencyPlugin(c),t.development?null:createExternalDependencyOutputCheckPlugin({appRoot:e.appRoot,externalDependencies:collectConfiguredExternalDependencies(e.compileResult.manifest)}),createExtensionMountPlugin(c,extensionOverridePaths(e.compileResult.manifest)),s].filter(e=>e!==null);return{nitroRolldownConfig:{output:{sourcemapIgnoreList:/node_modules/},tsconfig:resolveAuthoredTsConfigPath(e.appRoot)},nitroRollupConfig:createNitroBundlerConfig(l),tracedAppDependencies:collectHostedTraceDependencies(e,a),tracedAppDependencyPaths:resolveExtensionExternalDependencyPaths(c)}}function createApplicationNitroPlugins(e){let t=[e.compiledArtifacts.bootstrapPath,e.compiledArtifacts.workflowWorldPluginPath];return manifestHasWorkflowProgram(e.compileResult.manifest)&&t.push(resolvePackageSourceFilePath(`src/internal/nitro/host/workflow-sandbox-runtime-plugin.ts`)),e.compiledArtifacts.instrumentationPluginPath!==void 0&&t.push(e.compiledArtifacts.instrumentationPluginPath),t}function configureSharedApplicationNitro(e,t){t.compiledArtifacts.instrumentationPluginPath!==void 0&&configureInstrumentationEntry(e,t.compiledArtifacts.instrumentationPluginPath),addNitroRoutingImportSpecifierPlugin(e);let n=resolveWorkflowAliases();for(let[t,r]of Object.entries(n))e.options.alias[t]=r;for(let[t,n]of Object.entries(INSTRUMENTATION_ALIAS_PATHS))e.options.alias[t]=resolvePackageSourceFilePath(n);addWorkflowModuleSideEffectsPlugin(e,t.workflowBuildDir),patchWorkflowTransformExcludePath(e,t.workflowBuildDir),t.compiledArtifacts.instrumentationSourcePaths!==void 0&&addInstrumentationModuleSideEffectsPlugin(e,t.compiledArtifacts.instrumentationSourcePaths)}function configureNitroStepPlugins(e,t){let n,getTargets=()=>n??=collectNitroStepTransformTargets(t,e.options.rootDir),invalidate=()=>{n=void 0};return e.hooks.hook(`build:before`,invalidate),addNitroStepModuleSideEffectsPlugin(e,getTargets),addNitroStepTransformPlugin(e,getTargets),[invalidate]}function externalizeDevelopmentWorkflowBundle(e,t){let n=new Set([normalizePath(join(t.workflowBuildDir,`workflows.mjs`))]);e.hooks.hook(`rollup:before`,(e,t)=>{let r=t.external;t.external=(e,...t)=>{if(n.has(normalizePath(e)))return!0;if(typeof r==`function`)return r(e,...t)}})}async function createDevelopmentApplicationNitro(e){let t=e.workspace.nitroBuildDir,n=createApplicationNitroBundlerConfiguration(e,{development:!0,preset:void 0}),r=createApplicationNitroPlugins(e);usesLocalVercelSchedules(e.compileResult.manifest)&&r.push(resolvePackageSourceFilePath(`src/internal/nitro/host/local-schedules-runtime-plugin.ts`)),e.compiledArtifacts.instrumentationPluginPath===void 0&&r.unshift(resolvePackageSourceFilePath(`src/internal/nitro/host/local-tracing-runtime-plugin.ts`)),await prepareEveVersionedCacheDirectory(t);let i=await createNitro({_cli:{command:`dev`},builder:EVE_NITRO_BUILDER,buildDir:t,dev:!0,features:{websocket:!0},logLevel:1,output:{dir:e.workspace.nitroOutputDir},plugins:r,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:n.nitroRolldownConfig,rollupConfig:n.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:n.tracedAppDependencies,traceOpts:{nft:{paths:n.tracedAppDependencyPaths}},vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:!1}),watchOptions:createDevelopmentWatchOptions(e.appRoot)},{watch:!0});await writeEveVersionedCacheMetadata(t);let a=join(i.options.buildDir,`workflow`,`steps.mjs`);configureSharedApplicationNitro(i,e);let o=configureNitroStepPlugins(i,a);return i.hooks.hook(`dev:reload`,()=>{for(let e of o)e()}),externalizeDevelopmentWorkflowBundle(i,e),await configureDevelopmentNitroRoutes(i,e),await addNitroStepNoExternals(i,a),i}async function createProductionApplicationNitro(e,t){let n=resolveProductionNitroPreset(),r=createApplicationNitroBundlerConfiguration(e,{development:!1,preset:n}),i=createApplicationNitroPlugins(e);i.push(resolvePackageSourceFilePath(`src/internal/nitro/host/sandbox-shutdown-plugin.ts`)),await prepareEveVersionedCacheDirectory(t.buildDir);let{manifest:a,paths:o}=e.compileResult,s=await prepareSkillServerAssets({stagingDirectory:join(t.buildDir,`eve-skill-assets`),skills:a.skills.map(e=>e.name),skillsRoot:join(o.compileDirectoryPath,a.workspaceResourceRoot.logicalPath,`skills`)}),c=await createNitro({_cli:{command:`build`},builder:EVE_NITRO_BUILDER,buildDir:t.buildDir,dev:!1,features:{websocket:manifestHasWebSocketChannel(e.compileResult.manifest)},logging:{compressedSizes:!1},output:{dir:t.outputDir},preset:n,plugins:i,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:{...r.nitroRolldownConfig,experimental:{attachDebugInfo:`none`}},rollupConfig:r.nitroRollupConfig,rootDir:e.appRoot,serverAssets:s,serverDir:!1,traceDeps:r.tracedAppDependencies,traceOpts:{nft:{paths:r.tracedAppDependencyPaths}},vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:n===`vercel`,hasVercelScheduleCollections:hasVercelScheduleCollections(e.compileResult.manifest),publicRoutePrefix:t.publicRoutePrefix,workspaceMember:t.workspaceMember})});if(await writeEveVersionedCacheMetadata(t.buildDir),c.options.serverAssets=c.options.serverAssets.filter(e=>e.baseName!==`server`),configureSharedApplicationNitro(c,e),configureNitroStepPlugins(c,join(e.workflowBuildDir,`steps.mjs`)),e.scheduleRegistrations.length>0){applyEveCronHandlerRoute(c);let t=createProductionNitroArtifactsConfig(e.appRoot);registerScheduleTaskHandlers(c,{artifactsConfig:t,dispatchModulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/schedule-task.ts`),registrations:e.scheduleRegistrations})}return await configureProductionNitroRoutes(c,e),await addNitroStepNoExternals(c,join(e.workflowBuildDir,`steps.mjs`)),c}export{createDevelopmentApplicationNitro,createProductionApplicationNitro,shouldPruneLocalSandboxProviders};
@@ -1 +1 @@
1
- import{mkdir,readFile,rm,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{httpServerUrlSchema}from"#shared/network-address.js";import{join}from"node:path";const developmentServerStateSchema=z.object({url:httpServerUrlSchema}).strict();var DevelopmentServerState=class{appRoot;#e;#t;constructor(e){this.appRoot=e.appRoot,this.#e=join(this.appRoot,`.eve`),this.#t=join(this.#e,`dev-server-state.v1.json`)}async read(){let e;try{e=await readFile(this.#t,`utf8`)}catch(e){if(isErrnoException(e,`ENOENT`))return;throw e}try{let t=developmentServerStateSchema.safeParse(JSON.parse(e));return t.success?t.data.url:void 0}catch{return}}async write(e){let t=developmentServerStateSchema.parse({url:e});await mkdir(this.#e,{recursive:!0}),await writeFile(this.#t,`${JSON.stringify(t)}\n`,`utf8`)}async remove(){await rm(this.#t,{force:!0})}};function isErrnoException(e,t){return e instanceof Error&&`code`in e&&e.code===t}export{DevelopmentServerState};
1
+ import{mkdir,readFile,rm,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{httpServerUrlSchema}from"#shared/network-address.js";import{join}from"node:path";import{resolveDevelopmentStateDirectory}from"#internal/application/dev-environment.js";const developmentServerStateSchema=z.object({url:httpServerUrlSchema}).strict();var DevelopmentServerState=class{appRoot;#e;#t;constructor(e){this.appRoot=e.appRoot,this.#e=resolveDevelopmentStateDirectory(this.appRoot),this.#t=join(this.#e,`dev-server-state.v1.json`)}async read(){let e;try{e=await readFile(this.#t,`utf8`)}catch(e){if(isErrnoException(e,`ENOENT`))return;throw e}try{let t=developmentServerStateSchema.safeParse(JSON.parse(e));return t.success?t.data.url:void 0}catch{return}}async write(e){let t=developmentServerStateSchema.parse({url:e});await mkdir(this.#e,{recursive:!0}),await writeFile(this.#t,`${JSON.stringify(t)}\n`,`utf8`)}async remove(){await rm(this.#t,{force:!0})}};function isErrnoException(e,t){return e instanceof Error&&`code`in e&&e.code===t}export{DevelopmentServerState};
@@ -1 +1 @@
1
- import{createHash}from"node:crypto";import{mkdir,rm,writeFile}from"node:fs/promises";import{MAX_SKILL_FILE_BYTES,SKILL_FILES_INDEX_KEY,SKILL_FILES_INDEX_SERVER_ASSET_BASE,SKILL_FILES_SERVER_ASSET_BASE,comparePaths,createDiskSkillFileSource,skillFileStorageKey}from"#channel/skill-files.js";import{join,resolve}from"node:path";async function prepareSkillServerAssets(e){let t=createDiskSkillFileSource(resolve(e.skillsRoot)),n=join(e.stagingDirectory,`files`),r=join(e.stagingDirectory,`index`);await rm(e.stagingDirectory,{force:!0,recursive:!0}),await mkdir(n,{recursive:!0}),await mkdir(r,{recursive:!0});let i=[];for(let r of[...new Set(e.skills)].sort(comparePaths)){let e=[];for(let{path:i,size:a}of await t.listFiles(r)){if(a>MAX_SKILL_FILE_BYTES){e.push([i,a,null]);continue}let o=await t.readFile(r,i),s=createHash(`sha256`).update(o).digest(`hex`);await writeFile(join(n,skillFileStorageKey(s)),o),e.push([i,o.byteLength,s])}i.push([r,e,await t.listDirectories(r)])}let a={version:1,skills:i};return await writeFile(join(r,SKILL_FILES_INDEX_KEY),JSON.stringify(a)),[{baseName:SKILL_FILES_INDEX_SERVER_ASSET_BASE,dir:r},{baseName:SKILL_FILES_SERVER_ASSET_BASE,dir:n}]}export{prepareSkillServerAssets};
1
+ import{createHash}from"node:crypto";import{mkdir,rm,utimes,writeFile}from"node:fs/promises";import{MAX_SKILL_FILE_BYTES,SKILL_FILES_INDEX_KEY,SKILL_FILES_INDEX_SERVER_ASSET_BASE,SKILL_FILES_SERVER_ASSET_BASE,comparePaths,createDiskSkillFileSource,skillFileStorageKey}from"#channel/skill-files.js";import{join,resolve}from"node:path";async function prepareSkillServerAssets(e){let t=createDiskSkillFileSource(resolve(e.skillsRoot)),n=join(e.stagingDirectory,`files`),r=join(e.stagingDirectory,`index`);await rm(e.stagingDirectory,{force:!0,recursive:!0}),await mkdir(n,{recursive:!0}),await mkdir(r,{recursive:!0});let i=[];for(let r of[...new Set(e.skills)].sort(comparePaths)){let e=[];for(let{path:i,size:a}of await t.listFiles(r)){if(a>MAX_SKILL_FILE_BYTES){e.push([i,a,null]);continue}let o=await t.readFile(r,i),s=createHash(`sha256`).update(o).digest(`hex`),c=join(n,skillFileStorageKey(s));await writeFile(c,o),await utimes(c,0,0),e.push([i,o.byteLength,s])}i.push([r,e,await t.listDirectories(r)])}let a={version:1,skills:i},o=join(r,SKILL_FILES_INDEX_KEY);return await writeFile(o,JSON.stringify(a)),await utimes(o,0,0),[{baseName:SKILL_FILES_INDEX_SERVER_ASSET_BASE,dir:r},{baseName:SKILL_FILES_SERVER_ASSET_BASE,dir:n}]}export{prepareSkillServerAssets};
@@ -0,0 +1,2 @@
1
+ /** Hashes the staged output, installs the id in the World plugin, and returns the id. */
2
+ export declare function stageBuildDeploymentId(outputDirectory: string): Promise<string>;
@@ -0,0 +1 @@
1
+ import{createRequire}from"node:module";import{readFile,readdir,realpath,stat,writeFile}from"node:fs/promises";import{dirname,join}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{BUILD_DEPLOYMENT_ID_PLACEHOLDER,computeBuildDeploymentId,replaceBuildDeploymentId}from"#internal/nitro/host/build-deployment-id.js";async function optionalPeerIdentity(e){let t=createRequire(join(e,`server`,`index.mjs`)),n;try{n=t.resolve(`@opentelemetry/api`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`MODULE_NOT_FOUND`)return`@opentelemetry/api@absent`;throw e}for(let e=dirname(n);;e=dirname(e)){try{let t=JSON.parse(await readFile(join(e,`package.json`),`utf8`));if(typeof t==`object`&&t&&`name`in t&&t.name===`@opentelemetry/api`&&`version`in t&&typeof t.version==`string`)return`@opentelemetry/api@${t.version}`}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}if(dirname(e)===e)throw Error(`Cannot compute build deployment id: @opentelemetry/api has no package version.`)}}function mayContainPlaceholder(e){return e.startsWith(`server/`)&&e.endsWith(`.mjs`)&&!e.split(`/`).includes(`node_modules`)}async function stageBuildDeploymentId(e){let t=[];async function walk(n,r){let i=join(e,n),a=await realpath(i);if(r.has(a))throw Error(`Cannot hash build output: cyclic directory link at ${n}.`);let o=new Set([...r,a]);for(let r of await readdir(i,{withFileTypes:!0})){let i=n?`${n}/${r.name}`:r.name,a=r.isSymbolicLink()?await stat(join(e,i)):r;if(a.isDirectory())await walk(i,o);else if(a.isFile())t.push(i);else throw Error(`Cannot hash build output: unsupported file type at ${i}.`)}}await walk(``,new Set);let n=Buffer.from(BUILD_DEPLOYMENT_ID_PLACEHOLDER),r=[],i=await computeBuildDeploymentId(t,async t=>{let i=await readFile(join(e,t));return mayContainPlaceholder(t)&&i.includes(n)&&r.push({relativePath:t,bytes:i}),i},[`eve@${resolveInstalledPackageInfo().version}`,`node@${process.version}`,await optionalPeerIdentity(e)]),a=replaceBuildDeploymentId(r,i);return await writeFile(join(e,a.relativePath),a.bytes),i}export{stageBuildDeploymentId};
@@ -5,4 +5,5 @@ import type { ProductionServerHandle } from "#internal/nitro/host/types.js";
5
5
  export declare function startProductionServer(rootDir: string, options?: {
6
6
  host?: string;
7
7
  port?: number;
8
+ schedules?: boolean;
8
9
  }): Promise<ProductionServerHandle>;