eve 0.72.1 → 0.74.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 (575) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/src/_virtual/_rolldown/runtime.js +1 -1
  3. package/dist/src/channel/agent-description.d.ts +49 -9
  4. package/dist/src/channel/agent-description.js +1 -1
  5. package/dist/src/channel/invoke-tool.d.ts +26 -4
  6. package/dist/src/channel/invoke-tool.js +1 -1
  7. package/dist/src/channel/principal-identity.d.ts +9 -0
  8. package/dist/src/channel/principal-identity.js +1 -0
  9. package/dist/src/channel/prompt-queue.d.ts +31 -0
  10. package/dist/src/channel/prompt-queue.js +1 -0
  11. package/dist/src/channel/routes.d.ts +19 -4
  12. package/dist/src/channel/schedule.d.ts +20 -6
  13. package/dist/src/channel/schedule.js +1 -1
  14. package/dist/src/channel/skill-files.d.ts +114 -0
  15. package/dist/src/channel/skill-files.js +1 -0
  16. package/dist/src/channel/types.d.ts +4 -0
  17. package/dist/src/chunks/{use-eve-agent-C1GYGCtb.js → use-eve-agent-DOOXadF0.js} +13 -3
  18. package/dist/src/chunks/{use-eve-agent-hZJ7CB8t.js → use-eve-agent-mP0M7SrL.js} +13 -3
  19. package/dist/src/cli/commands/agent-instructions.js +1 -1
  20. package/dist/src/cli/commands/extension-init.js +1 -1
  21. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  22. package/dist/src/cli/commands/init-project.js +1 -1
  23. package/dist/src/cli/commands/init.js +1 -1
  24. package/dist/src/cli/dev/diagnostic-dump.js +1 -1
  25. package/dist/src/cli/dev/tui/blocks.d.ts +6 -0
  26. package/dist/src/cli/dev/tui/blocks.js +2 -2
  27. package/dist/src/cli/dev/tui/markdown.d.ts +5 -0
  28. package/dist/src/cli/dev/tui/markdown.js +2 -2
  29. package/dist/src/cli/dev/tui/stream-format.js +2 -2
  30. package/dist/src/cli/dev/tui/transcript-parts.d.ts +4 -1
  31. package/dist/src/cli/dev/tui/transcript-parts.js +2 -2
  32. package/dist/src/cli/dev/tui/transcript.js +1 -1
  33. package/dist/src/client/message-reducer.js +1 -1
  34. package/dist/src/compiled/.vendor-stamp.json +9 -8
  35. package/dist/src/compiled/@eve/catalog/index.js +1 -1
  36. package/dist/src/compiled/@modelcontextprotocol/server/index.d.ts +68 -7
  37. package/dist/src/compiled/@vercel/schedules/index.d.ts +158 -0
  38. package/dist/src/compiled/@vercel/schedules/index.js +17 -0
  39. package/dist/src/compiled/@workflow/core/capabilities.d.ts +33 -6
  40. package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +2 -0
  41. package/dist/src/compiled/@workflow/core/index.d.ts +1 -0
  42. package/dist/src/compiled/@workflow/core/index.js +2 -2
  43. package/dist/src/compiled/@workflow/core/private.js +1 -1
  44. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +6 -0
  45. package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
  46. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  47. package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +8 -8
  48. package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +13 -5
  49. package/dist/src/compiled/@workflow/core/serialization.d.ts +9 -9
  50. package/dist/src/compiled/@workflow/core/serialization.js +1 -1
  51. package/dist/src/compiled/@workflow/core/symbols.d.ts +2 -0
  52. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +2 -2
  53. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  54. package/dist/src/compiled/@workflow/core/workflow/index.d.ts +1 -0
  55. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  56. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  57. package/dist/src/compiled/@workflow/world/events.d.ts +11 -0
  58. package/dist/src/compiled/@workflow/world/hooks.d.ts +2 -0
  59. package/dist/src/compiled/@workflow/world/interfaces.d.ts +6 -0
  60. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  61. package/dist/src/compiled/@workflow/world-vercel/index.js +13 -13
  62. package/dist/src/compiled/_chunks/workflow/{attribute-changes-VaTKT4K8.js → attribute-changes-CSqvJx6j.js} +2 -2
  63. package/dist/src/compiled/_chunks/workflow/{dist-B7NC1c9-.js → dist-DmXynLVH.js} +1 -1
  64. package/dist/src/compiled/_chunks/workflow/dist-T5NnW-0k.js +3 -0
  65. package/dist/src/compiled/_chunks/workflow/helpers-BXCuoPUb.js +1 -0
  66. package/dist/src/compiled/_chunks/workflow/private-Dlf90Zvn.js +1 -0
  67. package/dist/src/compiled/_chunks/workflow/resume-hook-CvENCrxc.js +1 -0
  68. package/dist/src/compiled/_chunks/workflow/{run-DYKeqbob.js → run-8pLWuR2U.js} +6 -6
  69. package/dist/src/compiled/_chunks/workflow/serialization-vDozzDhh.js +16 -0
  70. package/dist/src/compiled/_chunks/workflow/sleep-BMqbraZM.js +1 -0
  71. package/dist/src/compiled/_chunks/workflow/wait-until-A344L2AG.js +1 -0
  72. package/dist/src/compiled/shadcn-registry/index.js +3408 -35163
  73. package/dist/src/compiler/artifacts.js +1 -1
  74. package/dist/src/compiler/compile-agent.js +1 -1
  75. package/dist/src/compiler/development-extensions.js +1 -1
  76. package/dist/src/compiler/extension-compatibility.d.ts +18 -18
  77. package/dist/src/compiler/extension-compatibility.js +1 -1
  78. package/dist/src/compiler/load-binding-namespace.d.ts +5 -0
  79. package/dist/src/compiler/load-binding-namespace.js +1 -1
  80. package/dist/src/compiler/manifest.d.ts +39 -0
  81. package/dist/src/compiler/manifest.js +1 -1
  82. package/dist/src/compiler/memory-wrapper-candidates.d.ts +2 -0
  83. package/dist/src/compiler/memory-wrapper-candidates.js +1 -0
  84. package/dist/src/compiler/module-lifecycle.d.ts +1 -1
  85. package/dist/src/compiler/module-lifecycle.js +1 -1
  86. package/dist/src/compiler/module-map.js +1 -1
  87. package/dist/src/compiler/normalize-agent-config.js +1 -1
  88. package/dist/src/compiler/normalize-manifest.js +1 -1
  89. package/dist/src/compiler/normalize-schedule-collection.d.ts +3 -0
  90. package/dist/src/compiler/normalize-schedule-collection.js +1 -0
  91. package/dist/src/compiler/normalize-schedule.d.ts +2 -2
  92. package/dist/src/compiler/normalize-schedule.js +1 -1
  93. package/dist/src/compiler/resolve-workspace-subagent.js +1 -1
  94. package/dist/src/compiler/schedule-collection-wrapper-candidates.d.ts +2 -0
  95. package/dist/src/compiler/schedule-collection-wrapper-candidates.js +1 -0
  96. package/dist/src/compiler/validate-artifact.js +1 -1
  97. package/dist/src/context/build-callback-context.js +1 -1
  98. package/dist/src/context/dynamic-resolve-context.js +1 -1
  99. package/dist/src/context/key-names.d.ts +1 -0
  100. package/dist/src/context/key-names.js +1 -1
  101. package/dist/src/context/keys.d.ts +2 -0
  102. package/dist/src/context/keys.js +1 -1
  103. package/dist/src/context/providers/session.js +1 -1
  104. package/dist/src/context/schedule-collection-tools.d.ts +9 -0
  105. package/dist/src/context/schedule-collection-tools.js +1 -0
  106. package/dist/src/context/session-context.d.ts +4 -1
  107. package/dist/src/context/session-schedule.d.ts +9 -0
  108. package/dist/src/context/session-schedule.js +1 -0
  109. package/dist/src/context/turn-principals.d.ts +12 -0
  110. package/dist/src/context/turn-principals.js +1 -0
  111. package/dist/src/dynamic/definition.d.ts +1 -0
  112. package/dist/src/evals/cli/eval-client.js +1 -1
  113. package/dist/src/evals/cli/eval.js +1 -1
  114. package/dist/src/execution/agent-sessions/context.d.ts +2 -0
  115. package/dist/src/execution/agent-sessions/context.js +1 -1
  116. package/dist/src/execution/agent-sessions/steps.js +1 -1
  117. package/dist/src/execution/cancelled-model-call-batch.js +1 -1
  118. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  119. package/dist/src/execution/invoke-tool.d.ts +6 -2
  120. package/dist/src/execution/invoke-tool.js +1 -1
  121. package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
  122. package/dist/src/execution/node-step.d.ts +1 -0
  123. package/dist/src/execution/node-step.js +1 -1
  124. package/dist/src/execution/publish-session-events.js +1 -1
  125. package/dist/src/execution/runtime-context.js +1 -1
  126. package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
  127. package/dist/src/execution/sandbox/bindings/vercel-errors.d.ts +11 -0
  128. package/dist/src/execution/sandbox/bindings/vercel-errors.js +2 -1
  129. package/dist/src/execution/sandbox/bindings/vercel-tool-sessions.d.ts +7 -0
  130. package/dist/src/execution/sandbox/bindings/vercel-tool-sessions.js +1 -0
  131. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  132. package/dist/src/execution/sandbox/development-lazy-prewarm.js +1 -1
  133. package/dist/src/execution/sandbox/ensure.d.ts +14 -1
  134. package/dist/src/execution/sandbox/ensure.js +1 -1
  135. package/dist/src/execution/sandbox/prewarm.js +1 -1
  136. package/dist/src/execution/session/active-turn.d.ts +2 -1
  137. package/dist/src/execution/session/active-turn.js +1 -1
  138. package/dist/src/execution/session/entry.d.ts +10 -1
  139. package/dist/src/execution/session/entry.js +1 -1
  140. package/dist/src/execution/session/program.d.ts +4 -0
  141. package/dist/src/execution/session/program.js +1 -1
  142. package/dist/src/execution/session/timeout-control.d.ts +1 -2
  143. package/dist/src/execution/session/timeout-control.js +1 -1
  144. package/dist/src/execution/session/turn-control.d.ts +7 -0
  145. package/dist/src/execution/session/turn-control.js +1 -0
  146. package/dist/src/execution/session/turn-step.js +1 -1
  147. package/dist/src/execution/session/turn.d.ts +2 -0
  148. package/dist/src/execution/session/turn.js +1 -1
  149. package/dist/src/execution/session-inbox/protocol.js +1 -1
  150. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  151. package/dist/src/execution/tool-session/id.d.ts +22 -0
  152. package/dist/src/execution/tool-session/id.js +1 -0
  153. package/dist/src/execution/tool-session/sandbox.d.ts +22 -0
  154. package/dist/src/execution/tool-session/sandbox.js +1 -0
  155. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  156. package/dist/src/execution/tools/connection-tools.js +1 -1
  157. package/dist/src/framework/sources/modules/schedule-collection-wrapper.d.ts +2 -0
  158. package/dist/src/framework/sources/modules/schedule-collection-wrapper.js +1 -0
  159. package/dist/src/framework/sources/registry.d.ts +1 -0
  160. package/dist/src/framework/sources/registry.js +1 -1
  161. package/dist/src/harness/compaction/step.js +1 -1
  162. package/dist/src/harness/emission.d.ts +1 -0
  163. package/dist/src/harness/emission.js +1 -1
  164. package/dist/src/harness/hitl/approvals.d.ts +1 -1
  165. package/dist/src/harness/hitl/approvals.js +1 -1
  166. package/dist/src/harness/hitl/delivery.d.ts +9 -2
  167. package/dist/src/harness/hitl/delivery.js +1 -1
  168. package/dist/src/harness/hitl/intake.js +1 -1
  169. package/dist/src/harness/model-call/call.d.ts +5 -0
  170. package/dist/src/harness/model-call/call.js +1 -1
  171. package/dist/src/harness/model-call/usage.js +1 -1
  172. package/dist/src/harness/open-input-request.d.ts +8 -0
  173. package/dist/src/harness/open-input-request.js +1 -0
  174. package/dist/src/harness/session-machine/current.js +1 -1
  175. package/dist/src/harness/session-machine/transitions.d.ts +13 -0
  176. package/dist/src/harness/session-machine/transitions.js +1 -1
  177. package/dist/src/harness/stream-actions.d.ts +6 -1
  178. package/dist/src/harness/stream-actions.js +1 -1
  179. package/dist/src/harness/tool-loop.js +1 -1
  180. package/dist/src/harness/tools.js +1 -1
  181. package/dist/src/harness/types.d.ts +2 -0
  182. package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
  183. package/dist/src/instrumentation/lifecycle.d.ts +1 -0
  184. package/dist/src/internal/application/cache-metadata.js +1 -1
  185. package/dist/src/internal/application/compiled-artifacts.js +1 -1
  186. package/dist/src/internal/application/package.js +1 -1
  187. package/dist/src/internal/application/paths.js +1 -1
  188. package/dist/src/internal/application/runtime-compiled-artifacts-source.js +1 -1
  189. package/dist/src/internal/authored-definition/connection.js +1 -1
  190. package/dist/src/internal/authored-definition/schedule-collection.d.ts +2 -0
  191. package/dist/src/internal/authored-definition/schedule-collection.js +1 -0
  192. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  193. package/dist/src/internal/authored-module-loader.d.ts +7 -0
  194. package/dist/src/internal/authored-module-loader.js +2 -2
  195. package/dist/src/internal/authored-module-map-loader.js +1 -1
  196. package/dist/src/internal/authored-package-boundary.js +1 -1
  197. package/dist/src/internal/authored-runtime-modules.d.ts +1 -0
  198. package/dist/src/internal/authored-runtime-modules.js +1 -1
  199. package/dist/src/internal/invocation/metadata.js +1 -1
  200. package/dist/src/internal/mcp/forwarded-principal-header.d.ts +31 -0
  201. package/dist/src/internal/mcp/forwarded-principal-header.js +1 -0
  202. package/dist/src/internal/mcp/published-tools.d.ts +9 -2
  203. package/dist/src/internal/mcp/published-tools.js +1 -1
  204. package/dist/src/internal/mcp/skills.d.ts +57 -0
  205. package/dist/src/internal/mcp/skills.js +1 -0
  206. package/dist/src/internal/mcp/streamable-http-server.d.ts +38 -6
  207. package/dist/src/internal/mcp/streamable-http-server.js +1 -1
  208. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  209. package/dist/src/internal/nitro/development-generation.js +1 -1
  210. package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
  211. package/dist/src/internal/nitro/host/build-application.js +1 -1
  212. package/dist/src/internal/nitro/host/build-extension.js +1 -1
  213. package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
  214. package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
  215. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  216. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  217. package/dist/src/internal/nitro/host/dev-runner.js +1 -1
  218. package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -1
  219. package/dist/src/internal/nitro/host/local-tracing-runtime-plugin.js +1 -1
  220. package/dist/src/internal/nitro/host/skill-server-assets.d.ts +29 -0
  221. package/dist/src/internal/nitro/host/skill-server-assets.js +1 -0
  222. package/dist/src/internal/nitro/host/start-production-server.js +1 -1
  223. package/dist/src/internal/nitro/host/vercel-build-output-config.d.ts +12 -0
  224. package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
  225. package/dist/src/internal/nitro/host/workspace-extensions.js +1 -1
  226. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
  227. package/dist/src/internal/nitro/routes/channel-route-context.d.ts +4 -0
  228. package/dist/src/internal/nitro/routes/channel-route-context.js +1 -1
  229. package/dist/src/internal/nitro/routes/schedule-collection-consumer.d.ts +3 -0
  230. package/dist/src/internal/nitro/routes/schedule-collection-consumer.js +1 -0
  231. package/dist/src/internal/schedules/consumer-route.d.ts +17 -0
  232. package/dist/src/internal/schedules/consumer-route.js +1 -0
  233. package/dist/src/internal/schedules/verify-delivery.d.ts +25 -0
  234. package/dist/src/internal/schedules/verify-delivery.js +1 -0
  235. package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
  236. package/dist/src/internal/workflow/development-world-client.js +1 -1
  237. package/dist/src/internal/workflow/validate-world.js +1 -1
  238. package/dist/src/internal/workflow/vercel-world-defaults.js +1 -1
  239. package/dist/src/internal/workflow-bundle/builder-support.js +1 -1
  240. package/dist/src/internal/workflow-bundle/builder.js +1 -1
  241. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  242. package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/cli-config.js +1 -0
  243. package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/cred-storage.js +1 -0
  244. package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/index.js +1 -0
  245. package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/schema.js +1 -0
  246. package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/schema.zod.js +1 -0
  247. package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/types.js +1 -0
  248. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/envpath.js +1 -0
  249. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/errors.js +2 -0
  250. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/errutils.js +1 -0
  251. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/exec.js +1 -0
  252. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/fsutils.js +1 -0
  253. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/index.js +1 -0
  254. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/lookup.js +1 -0
  255. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/safety.js +1 -0
  256. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/auth-errors.js +1 -0
  257. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/exchange-vercel-oidc-token.js +1 -0
  258. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/get-context.js +1 -0
  259. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-sync.js +1 -0
  260. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-with-refresh.js +2 -0
  261. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/index.js +1 -0
  262. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/oauth.js +1 -0
  263. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/token-error.js +1 -0
  264. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/token-io.js +1 -0
  265. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/token-util.js +2 -0
  266. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/token.js +1 -0
  267. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/verify-vercel-oidc-token.js +1 -0
  268. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/version.js +1 -0
  269. package/dist/src/node_modules/.pnpm/@vercel_queue@0.5.1_@opentelemetry_api@1.9.1/node_modules/@vercel/queue/dist/index.js +36 -0
  270. package/dist/src/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js +1 -0
  271. package/dist/src/node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js +1 -0
  272. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js +1 -0
  273. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js +1 -0
  274. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js +1 -0
  275. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js +1 -0
  276. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js +1 -0
  277. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js +1 -0
  278. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js +1 -0
  279. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/command.js +1 -0
  280. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js +2 -0
  281. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/kill.js +1 -0
  282. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/promise.js +1 -0
  283. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stdio.js +1 -0
  284. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stream.js +1 -0
  285. package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/buffer-stream.js +1 -0
  286. package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/index.js +1 -0
  287. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/core.js +1 -0
  288. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/main.js +1 -0
  289. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/realtime.js +1 -0
  290. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/signals.js +1 -0
  291. package/dist/src/node_modules/.pnpm/is-stream@2.0.1/node_modules/is-stream/index.js +1 -0
  292. package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js +1 -0
  293. package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js +1 -0
  294. package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js +1 -0
  295. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/index.js +1 -0
  296. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/decrypt.js +1 -0
  297. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/encrypt.js +1 -0
  298. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/decrypt.js +1 -0
  299. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/encrypt.js +1 -0
  300. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/decrypt.js +1 -0
  301. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/encrypt.js +1 -0
  302. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/embedded.js +1 -0
  303. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/thumbprint.js +1 -0
  304. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/local.js +1 -0
  305. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/remote.js +1 -0
  306. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/sign.js +1 -0
  307. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/verify.js +1 -0
  308. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/sign.js +1 -0
  309. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/verify.js +1 -0
  310. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/sign.js +1 -0
  311. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/verify.js +1 -0
  312. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/decrypt.js +1 -0
  313. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/encrypt.js +1 -0
  314. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/produce.js +1 -0
  315. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/sign.js +1 -0
  316. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/unsecured.js +1 -0
  317. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/verify.js +1 -0
  318. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/export.js +1 -0
  319. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_key_pair.js +1 -0
  320. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_secret.js +1 -0
  321. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/import.js +1 -0
  322. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/aesgcmkw.js +1 -0
  323. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/buffer_utils.js +1 -0
  324. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/cek.js +1 -0
  325. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_iv_length.js +1 -0
  326. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_key_type.js +1 -0
  327. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_p2s.js +1 -0
  328. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/crypto_key.js +1 -0
  329. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/decrypt_key_management.js +1 -0
  330. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/encrypt_key_management.js +1 -0
  331. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/epoch.js +1 -0
  332. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/invalid_key_input.js +1 -0
  333. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_disjoint.js +1 -0
  334. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_jwk.js +1 -0
  335. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_object.js +1 -0
  336. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/iv.js +1 -0
  337. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/jwt_claims_set.js +1 -0
  338. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/private_symbols.js +1 -0
  339. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/secs.js +1 -0
  340. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_algorithms.js +1 -0
  341. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_crit.js +1 -0
  342. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/aeskw.js +1 -0
  343. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/asn1.js +1 -0
  344. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/base64url.js +1 -0
  345. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/cbc_tag.js +1 -0
  346. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_cek_length.js +1 -0
  347. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_key_length.js +1 -0
  348. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ciphers.js +1 -0
  349. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/decrypt.js +1 -0
  350. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/digest.js +1 -0
  351. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/dsa_digest.js +1 -0
  352. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ecdhes.js +1 -0
  353. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/encrypt.js +1 -0
  354. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/fetch_jwks.js +1 -0
  355. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/generate.js +1 -0
  356. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_named_curve.js +1 -0
  357. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_sign_verify_key.js +1 -0
  358. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/hmac_digest.js +1 -0
  359. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_like.js +1 -0
  360. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_object.js +1 -0
  361. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/jwk_to_key.js +1 -0
  362. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/key_to_jwk.js +1 -0
  363. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/node_key.js +1 -0
  364. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/normalize_key.js +1 -0
  365. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/pbes2kw.js +1 -0
  366. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/random.js +1 -0
  367. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/rsaes.js +1 -0
  368. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/runtime.js +1 -0
  369. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/sign.js +1 -0
  370. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/timing_safe_equal.js +1 -0
  371. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/verify.js +1 -0
  372. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/webcrypto.js +1 -0
  373. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/base64url.js +1 -0
  374. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_jwt.js +1 -0
  375. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_protected_header.js +1 -0
  376. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/errors.js +1 -0
  377. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/runtime.js +1 -0
  378. package/dist/src/node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js +1 -0
  379. package/dist/src/node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js +1 -0
  380. package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js +1 -0
  381. package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js +1 -0
  382. package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js +1 -0
  383. package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js +1 -0
  384. package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js +1 -0
  385. package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js +1 -0
  386. package/dist/src/node_modules/.pnpm/mixpart@0.0.6/node_modules/mixpart/dist/index.js +7 -0
  387. package/dist/src/node_modules/.pnpm/npm-run-path@4.0.1/node_modules/npm-run-path/index.js +1 -0
  388. package/dist/src/node_modules/.pnpm/onetime@5.1.2/node_modules/onetime/index.js +1 -0
  389. package/dist/src/node_modules/.pnpm/os-paths@4.4.0/node_modules/os-paths/src/lib/index.js +1 -0
  390. package/dist/src/node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js +1 -0
  391. package/dist/src/node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js +1 -0
  392. package/dist/src/node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js +1 -0
  393. package/dist/src/node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js +1 -0
  394. package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js +1 -0
  395. package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js +1 -0
  396. package/dist/src/node_modules/.pnpm/strip-final-newline@2.0.0/node_modules/strip-final-newline/index.js +2 -0
  397. package/dist/src/node_modules/.pnpm/which@2.0.2/node_modules/which/which.js +1 -0
  398. package/dist/src/node_modules/.pnpm/xdg-app-paths@5.5.1/node_modules/xdg-app-paths/src/lib/index.js +1 -0
  399. package/dist/src/node_modules/.pnpm/xdg-portable@7.3.0/node_modules/xdg-portable/src/lib/index.js +1 -0
  400. package/dist/src/public/channels/chat-sdk/authorization.js +1 -1
  401. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +7 -1
  402. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
  403. package/dist/src/public/channels/discord/defaults.d.ts +8 -7
  404. package/dist/src/public/channels/discord/discordChannel.d.ts +21 -1
  405. package/dist/src/public/channels/discord/discordChannel.js +1 -1
  406. package/dist/src/public/channels/discord/index.d.ts +1 -1
  407. package/dist/src/public/channels/github/defaults.js +3 -3
  408. package/dist/src/public/channels/github/githubChannel.d.ts +4 -1
  409. package/dist/src/public/channels/github/state.d.ts +2 -1
  410. package/dist/src/public/channels/index.d.ts +1 -1
  411. package/dist/src/public/channels/linear/defaults.js +1 -1
  412. package/dist/src/public/channels/linear/linearChannel.d.ts +4 -1
  413. package/dist/src/public/channels/mcp.d.ts +26 -5
  414. package/dist/src/public/channels/mcp.js +1 -1
  415. package/dist/src/public/channels/slack/index.d.ts +1 -0
  416. package/dist/src/public/channels/slack/index.js +1 -1
  417. package/dist/src/public/channels/slack/interactions.js +1 -1
  418. package/dist/src/public/channels/slack/slackChannel.d.ts +6 -0
  419. package/dist/src/public/channels/twilio/defaults.js +2 -4
  420. package/dist/src/public/channels/twilio/twilioChannel.d.ts +4 -1
  421. package/dist/src/public/definitions/channel.d.ts +1 -1
  422. package/dist/src/public/definitions/connections/mcp.d.ts +11 -0
  423. package/dist/src/public/experimental/schedules/client.d.ts +7 -0
  424. package/dist/src/public/experimental/schedules/client.js +1 -0
  425. package/dist/src/public/experimental/schedules/index.d.ts +5 -0
  426. package/dist/src/public/experimental/schedules/index.js +1 -0
  427. package/dist/src/public/experimental/schedules/testing.d.ts +2 -0
  428. package/dist/src/public/experimental/schedules/testing.js +1 -0
  429. package/dist/src/public/experimental/schedules/vercel.d.ts +2 -0
  430. package/dist/src/public/experimental/schedules/vercel.js +1 -0
  431. package/dist/src/public/memory/scope.js +1 -1
  432. package/dist/src/public/schedules/provider-types.d.ts +16 -0
  433. package/dist/src/public/schedules/provider-types.js +1 -0
  434. package/dist/src/public/schedules/providers/in-memory.d.ts +5 -0
  435. package/dist/src/public/schedules/providers/in-memory.js +1 -0
  436. package/dist/src/public/schedules/providers/vercel.d.ts +10 -0
  437. package/dist/src/public/schedules/providers/vercel.js +1 -0
  438. package/dist/src/public/schedules/scope.d.ts +2 -0
  439. package/dist/src/public/schedules/scope.js +1 -0
  440. package/dist/src/public/schedules/subscription.d.ts +259 -0
  441. package/dist/src/public/schedules/subscription.js +1 -0
  442. package/dist/src/public/schedules/testing.d.ts +1 -0
  443. package/dist/src/public/schedules/testing.js +1 -0
  444. package/dist/src/public/sveltekit/dev-server.js +1 -1
  445. package/dist/src/runtime/cache-key.js +1 -1
  446. package/dist/src/runtime/connections/mcp-client.js +1 -1
  447. package/dist/src/runtime/loaders/compile-metadata.js +1 -1
  448. package/dist/src/runtime/loaders/manifest.js +1 -1
  449. package/dist/src/runtime/loaders/module-map.js +1 -1
  450. package/dist/src/runtime/resolve-connection.js +1 -1
  451. package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -1
  452. package/dist/src/runtime/schedules/collection-client.d.ts +20 -0
  453. package/dist/src/runtime/schedules/collection-client.js +1 -0
  454. package/dist/src/runtime/schedules/dispatch-occurrence.d.ts +12 -0
  455. package/dist/src/runtime/schedules/dispatch-occurrence.js +1 -0
  456. package/dist/src/runtime/schedules/load-collection.d.ts +14 -0
  457. package/dist/src/runtime/schedules/load-collection.js +1 -0
  458. package/dist/src/runtime/schedules/payload.d.ts +24 -0
  459. package/dist/src/runtime/schedules/payload.js +1 -0
  460. package/dist/src/runtime/schedules/provider-types.d.ts +1 -0
  461. package/dist/src/runtime/schedules/provider-types.js +1 -0
  462. package/dist/src/runtime/schedules/queue-namespace.d.ts +2 -0
  463. package/dist/src/runtime/schedules/queue-namespace.js +1 -0
  464. package/dist/src/runtime/schedules/record.d.ts +4 -0
  465. package/dist/src/runtime/schedules/record.js +1 -0
  466. package/dist/src/runtime/schedules/validation.d.ts +6 -0
  467. package/dist/src/runtime/schedules/validation.js +1 -0
  468. package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
  469. package/dist/src/runtime/sessions/runtime-context-keys.js +1 -1
  470. package/dist/src/runtime/sessions/runtime-session.d.ts +10 -0
  471. package/dist/src/runtime/sessions/runtime-session.js +1 -1
  472. package/dist/src/runtime/types.d.ts +2 -0
  473. package/dist/src/self-modification/config.d.ts +4 -63
  474. package/dist/src/self-modification/config.js +1 -1
  475. package/dist/src/self-modification/credentials.d.ts +1 -1
  476. package/dist/src/self-modification/deployed-sandbox.d.ts +14 -0
  477. package/dist/src/self-modification/deployed-sandbox.js +1 -0
  478. package/dist/src/self-modification/extension/config-schema.d.ts +2 -17
  479. package/dist/src/self-modification/extension/config-schema.js +1 -1
  480. package/dist/src/self-modification/extension/local-only.d.ts +1 -1
  481. package/dist/src/self-modification/extension/local-only.js +1 -1
  482. package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +1 -1
  483. package/dist/src/self-modification/extension/subagents/agent/agent.js +1 -1
  484. package/dist/src/self-modification/extension/subagents/agent/instructions.js +3 -35
  485. package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.d.ts +3 -31
  486. package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.js +1 -1
  487. package/dist/src/self-modification/git-workspace.d.ts +1 -2
  488. package/dist/src/self-modification/git-workspace.js +1 -1
  489. package/dist/src/self-modification/github-publisher.d.ts +1 -1
  490. package/dist/src/self-modification/mode.d.ts +4 -4
  491. package/dist/src/self-modification/mode.js +1 -1
  492. package/dist/src/self-modification/proposal.js +1 -1
  493. package/dist/src/self-modification/remote/config-schema.d.ts +20 -0
  494. package/dist/src/self-modification/remote/config-schema.js +1 -0
  495. package/dist/src/self-modification/remote/config.d.ts +66 -0
  496. package/dist/src/self-modification/remote/config.js +1 -0
  497. package/dist/src/self-modification/remote/extension.d.ts +5 -0
  498. package/dist/src/self-modification/remote/extension.js +1 -0
  499. package/dist/src/self-modification/remote/production-registry-add.js +1 -0
  500. package/dist/src/self-modification/remote/subagents/agent/agent.d.ts +4 -0
  501. package/dist/src/self-modification/remote/subagents/agent/agent.js +1 -0
  502. package/dist/src/self-modification/remote/subagents/agent/instructions.d.ts +2 -0
  503. package/dist/src/self-modification/remote/subagents/agent/instructions.js +5 -0
  504. package/dist/src/self-modification/remote/subagents/agent/sandbox.d.ts +2 -0
  505. package/dist/src/self-modification/remote/subagents/agent/sandbox.js +1 -0
  506. package/dist/src/self-modification/remote/subagents/agent/tools/edit_file.d.ts +1 -0
  507. package/dist/src/self-modification/remote/subagents/agent/tools/edit_file.js +1 -0
  508. package/dist/src/self-modification/remote/subagents/agent/tools/publish.js +1 -0
  509. package/dist/src/self-modification/remote/subagents/agent/tools/registry_add.d.ts +32 -0
  510. package/dist/src/self-modification/remote/subagents/agent/tools/registry_add.js +1 -0
  511. package/dist/src/self-modification/remote/subagents/agent/tools/search_models.d.ts +1 -0
  512. package/dist/src/self-modification/remote/subagents/agent/tools/search_models.js +1 -0
  513. package/dist/src/self-modification/remote/subagents/agent/tools/search_registry.d.ts +1 -0
  514. package/dist/src/self-modification/remote/subagents/agent/tools/search_registry.js +1 -0
  515. package/dist/src/self-modification/sandbox.d.ts +1 -6
  516. package/dist/src/self-modification/sandbox.js +1 -1
  517. package/dist/src/self-modification/scaffold.js +1 -1
  518. package/dist/src/self-modification/setup.d.ts +6 -0
  519. package/dist/src/self-modification/setup.js +46 -48
  520. package/dist/src/self-modification/subagent-guidance.d.ts +15 -0
  521. package/dist/src/self-modification/subagent-guidance.js +29 -0
  522. package/dist/src/services/dev-client/request-headers.js +1 -1
  523. package/dist/src/setup/flows/model-source-change.js +1 -1
  524. package/dist/src/setup/integrations/self-modification/setup.js +1 -1
  525. package/dist/src/setup/project-resolution.js +1 -1
  526. package/dist/src/setup/scaffold/create/project.js +1 -1
  527. package/dist/src/setup/verified-remote-client.d.ts +3 -0
  528. package/dist/src/setup/verified-remote-client.js +1 -1
  529. package/dist/src/shared/framework-eve-server.js +1 -1
  530. package/dist/src/shared/principal-scope.d.ts +2 -0
  531. package/dist/src/shared/principal-scope.js +1 -0
  532. package/dist/src/shared/schedule-collection-definition.d.ts +11 -0
  533. package/dist/src/shared/schedule-collection-definition.js +1 -0
  534. package/dist/src/shared/schedule-collection-tools.d.ts +1 -0
  535. package/dist/src/shared/schedule-collection-tools.js +1 -0
  536. package/dist/src/subagents/hitl-proxy.js +1 -1
  537. package/dist/src/subagents/tool.d.ts +1 -0
  538. package/dist/src/subagents/tool.js +1 -1
  539. package/dist/src/svelte/index.js +1 -1
  540. package/dist/src/svelte/use-eve-agent.js +1 -1
  541. package/dist/src/tools/framework/agent.js +1 -1
  542. package/dist/src/tools/provided/ask-question-workflow.js +1 -1
  543. package/dist/src/tools/provided/read-file.js +1 -1
  544. package/dist/src/tools/provided/sleep-workflow.js +1 -1
  545. package/dist/src/tracing/agent-otel-content.d.ts +2 -0
  546. package/dist/src/tracing/agent-otel-content.js +2 -2
  547. package/dist/src/tracing/agent-otel-provider.js +1 -1
  548. package/dist/src/tracing/invoke-tool-span.d.ts +1 -0
  549. package/dist/src/vue/index.js +1 -1
  550. package/dist/src/vue/use-eve-agent.js +1 -1
  551. package/docs/channels/chat-sdk.mdx +27 -0
  552. package/docs/channels/custom.mdx +5 -2
  553. package/docs/channels/discord.mdx +22 -0
  554. package/docs/channels/mcp.mdx +102 -4
  555. package/docs/channels/slack.mdx +1 -1
  556. package/docs/connections/mcp.mdx +19 -0
  557. package/docs/evals/targets.mdx +5 -1
  558. package/docs/guides/self-modification.md +50 -3
  559. package/docs/tools/human-in-the-loop.md +14 -2
  560. package/docs/tools/workflows.mdx +6 -4
  561. package/docs/tutorial/guard-the-spend.mdx +1 -1
  562. package/package.json +46 -8
  563. package/dist/src/compiled/@workflow/core/runtime/vm-serde-bundle.generated.d.ts +0 -14
  564. package/dist/src/compiled/_chunks/workflow/dist-CaNNONeg.js +0 -3
  565. package/dist/src/compiled/_chunks/workflow/global-DKbOgrts.js +0 -1
  566. package/dist/src/compiled/_chunks/workflow/helpers-CP9TjeO8.js +0 -1
  567. package/dist/src/compiled/_chunks/workflow/logger-oqfblE3p.js +0 -14
  568. package/dist/src/compiled/_chunks/workflow/resume-hook-yq-NAdBu.js +0 -1
  569. package/dist/src/compiled/_chunks/workflow/serialization-APSKphN5.js +0 -3
  570. package/dist/src/compiled/_chunks/workflow/sleep-Ba8SExMt.js +0 -1
  571. package/dist/src/compiled/_chunks/workflow/wait-until-Dc9s3yyP.js +0 -1
  572. package/dist/src/self-modification/extension/production-registry-add.js +0 -1
  573. package/dist/src/self-modification/extension/subagents/agent/tools/publish.js +0 -1
  574. /package/dist/src/self-modification/{extension → remote}/production-registry-add.d.ts +0 -0
  575. /package/dist/src/self-modification/{extension → remote}/subagents/agent/tools/publish.d.ts +0 -0
@@ -0,0 +1,57 @@
1
+ import type { AgentSkillDescription } from "#channel/agent-description.js";
2
+ import { type SkillFileSource } from "#channel/skill-files.js";
3
+ import { type McpServerFeature } from "#internal/mcp/streamable-http-server.js";
4
+ /** SEP-2640 extension identifier. */
5
+ export declare const MCP_SKILLS_EXTENSION = "io.modelcontextprotocol/skills";
6
+ /** SEP-2640 limits a conforming host must accept; skills over them are not served. */
7
+ export declare const MCP_SKILL_MAX_RESOURCES = 512;
8
+ export declare const MCP_SKILL_MAX_TOTAL_BYTES: number;
9
+ /** The skills the feature serves and where their files are. */
10
+ export interface McpSkillSource {
11
+ /** The agent's skills as `describe()` lists them. */
12
+ readonly skills: readonly AgentSkillDescription[];
13
+ readonly files: SkillFileSource;
14
+ }
15
+ /**
16
+ * An MCP server feature publishing an agent's compiled skills per SEP-2640:
17
+ * `skills/list`, `skills/get`, `resources/list`, `resources/templates/list`,
18
+ * `resources/read`, and `resources/directory/read`, all under `skill://`.
19
+ *
20
+ * The feature owns the server's resource methods. They are set on the
21
+ * low-level server rather than through `McpServer.registerResource`, whose
22
+ * `resources/read` normalizes the URI with `new URL()` (which resolves `..`)
23
+ * before matching.
24
+ *
25
+ * A skill is served whole or not at all, and an unserved skill is absent
26
+ * from every method. It is served when:
27
+ *
28
+ * - its name and every file path are valid `skill://` segments, and exactly
29
+ * one top-level file is its entry (`SKILL.md` in any case, served as
30
+ * `SKILL.md`);
31
+ * - it has at most 512 files, none over the 512 KiB skill file cap, and at
32
+ * most 16 MiB in total;
33
+ * - every file reads, and the served `SKILL.md` frontmatter meets the Agent
34
+ * Skills format (name rules, description of 1-1024 characters).
35
+ *
36
+ * `SKILL.md` frontmatter that already carries the skill's `name` and a
37
+ * `description` is served byte for byte. Otherwise (flat and module skills,
38
+ * whose materialized `SKILL.md` has no frontmatter, or a package whose `name`
39
+ * differs from its directory) the served document carries rewritten
40
+ * frontmatter, and `frontmatter` and the digest describe that document.
41
+ *
42
+ * Snapshots are keyed by the `skills` array, which `describe()` keeps for
43
+ * as long as the compiled artifacts stay the same, so a skill's files are
44
+ * listed and read once per build: once per process in production, once per
45
+ * recompile under `eve dev`.
46
+ */
47
+ export declare function createMcpSkillsFeature(source: McpSkillSource): McpServerFeature;
48
+ /**
49
+ * Parses `skill://<skill>[/<path>]` strictly. Rejected: other schemes, a
50
+ * query or fragment, whitespace, backslashes, empty segments (so `//` and a
51
+ * trailing `/`), `.` and `..` segments (decoded too), percent-encoded `/`,
52
+ * `\`, or NUL, and malformed percent-encoding.
53
+ */
54
+ export declare function parseSkillUri(uri: string): {
55
+ readonly skill: string;
56
+ readonly path?: string;
57
+ } | undefined;
@@ -0,0 +1 @@
1
+ import{createHash}from"node:crypto";import{createLogger}from"#internal/logging.js";import{MAX_SKILL_FILE_BYTES,SKILL_ENTRY_FILE_NAME,SkillReadError,comparePaths,isSkillEntryFileName}from"#channel/skill-files.js";import{z}from"#compiled/zod/index.js";import{parseFrontmatter}from"#internal/helpers/frontmatter.js";import{ProtocolError,ProtocolErrorCode,ResourceNotFoundError}from"#compiled/@modelcontextprotocol/server/index.js";import{MCP_LIST_CACHE_HINT}from"#internal/mcp/streamable-http-server.js";import{Buffer}from"node:buffer";const MCP_SKILLS_EXTENSION=`io.modelcontextprotocol/skills`,MCP_SKILL_MAX_RESOURCES=512,MCP_SKILL_MAX_TOTAL_BYTES=16777216,SKILL_URI_PREFIX=`skill://`,log=createLogger(`mcp.skills`),warned=new Set;function warnOnce(e){warned.has(e)||(warned.add(e),log.warn(e))}function createMcpSkillsFeature(e){return{capabilities:{resources:{listChanged:!1},extensions:{[MCP_SKILLS_EXTENSION]:{directoryRead:!0}}},register(t){registerSkillHandlers(t,e.files,createSkillCatalog(e))}}}const snapshotCache=new WeakMap;function createSkillCatalog({files:e,skills:t}){let n=snapshotCache.get(t)??new Map;snapshotCache.set(t,n);let snapshot=async r=>{let i=t.find(e=>e.name===r);if(i===void 0)return;let a=n.get(r);return a===void 0&&(a=snapshotSkill(e,i),n.set(r,a),a.catch(()=>n.delete(r))),await a};return{async served(){let e=t.map(e=>e.name).sort(comparePaths),n=[];for(let t of e){let e=await snapshot(t);e!==void 0&&n.push(e)}return n},skill:snapshot}}function registerSkillHandlers(e,t,n){let r=e.server;r.setRequestHandler(`skills/list`,{params:z.looseObject({cursor:z.string().optional()})},async e=>(rejectCursor(e.cursor),{skills:(await n.served()).map(e=>e.entry),...MCP_LIST_CACHE_HINT})),r.setRequestHandler(`skills/get`,{params:z.looseObject({uri:z.string()})},async e=>{let t=parseSkillUri(e.uri),r=t?.path===SKILL_ENTRY_FILE_NAME?await n.skill(t.skill):void 0;if(r===void 0)throw new ProtocolError(ProtocolErrorCode.InvalidParams,`Unknown skill: ${e.uri}`,{uri:e.uri});return{skill:r.entry,...MCP_LIST_CACHE_HINT}}),r.setRequestHandler(`resources/directory/read`,{params:z.looseObject({uri:z.string(),cursor:z.string().optional()})},async e=>{rejectCursor(e.cursor);let t=parseSkillUri(e.uri),r=t===void 0?void 0:await n.skill(t.skill),i=r===void 0?void 0:listDirectory(r,t?.path);if(i===void 0)throw new ResourceNotFoundError(e.uri);return{resources:i,...MCP_LIST_CACHE_HINT}}),r.setRequestHandler(`resources/list`,async e=>(rejectCursor(e.params?.cursor),{resources:(await n.served()).map(e=>({uri:e.entry.uri,name:e.name,description:e.description,mimeType:mimeTypeFor(SKILL_ENTRY_FILE_NAME),size:e.document.bytes.byteLength}))})),r.setRequestHandler(`resources/templates/list`,async e=>(rejectCursor(e.params?.cursor),{resourceTemplates:[]})),r.setRequestHandler(`resources/read`,async e=>{let r=e.params?.uri;if(typeof r!=`string`)throw new ProtocolError(ProtocolErrorCode.InvalidParams,`params.uri must be a string.`);let i=parseSkillUri(r),a=i?.path===void 0?void 0:await n.skill(i.skill),o=i?.path===void 0?void 0:a?.files.get(i.path);if(a===void 0||i?.path===void 0||o===void 0)throw new ResourceNotFoundError(r);let s=i.path===SKILL_ENTRY_FILE_NAME?a.document:toServedFile(await readListedFile(t,a.name,i.path,r));return{contents:[s.text===void 0?{uri:r,mimeType:o.mimeType,blob:Buffer.from(s.bytes).toString(`base64`)}:{uri:r,mimeType:o.mimeType,text:s.text}]}})}async function readListedFile(e,t,n,r){try{return await e.readFile(t,n)}catch(e){throw e instanceof SkillReadError&&e.code===`unknown-file`?new ResourceNotFoundError(r):e}}function toServedFile(e){let t=decodeText(e);return t===void 0?{bytes:e}:{bytes:e,text:t}}function decodeText(e){if(!e.includes(0))try{return new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}).decode(e)}catch{return}}function servedPaths(e,t,n){if(!isSafeSegment(e))return`its name is not a valid skill:// segment`;let r=n.find(e=>!e.split(`/`).every(isSafeSegment));if(r!==void 0)return`its directory "${r}" is not a valid skill:// path`;if(t.length>512)return`it has more than 512 files`;let i=new Map,a=0;for(let{path:e,size:n}of t){if(!e.split(`/`).every(isSafeSegment))return`its file "${e}" is not a valid skill:// path`;if(n>MAX_SKILL_FILE_BYTES)return`its file "${e}" is over ${MAX_SKILL_FILE_BYTES} bytes`;a+=n;let t=!e.includes(`/`)&&isSkillEntryFileName(e)?SKILL_ENTRY_FILE_NAME:e;if(i.has(t))return`it has more than one ${SKILL_ENTRY_FILE_NAME}`;i.set(t,e)}return i.has(SKILL_ENTRY_FILE_NAME)?a>16777216?`its files total more than ${MCP_SKILL_MAX_TOTAL_BYTES} bytes`:i:`it has no ${SKILL_ENTRY_FILE_NAME}`}async function snapshotSkill(e,t){let unserved=e=>{warnOnce(`mcpChannel does not serve the skill "${t.name}": ${e}.`)},[n,r]=await Promise.all([e.listFiles(t.name),e.listDirectories(t.name)]),i=servedPaths(t.name,n,r);if(typeof i==`string`)return unserved(i);let a=[...i.entries()].sort(([e],[t])=>comparePaths(e,t)),o=await mapWithConcurrency(a,8,async([,n])=>{try{return toServedFile(await e.readFile(t.name,n))}catch(e){if(e instanceof SkillReadError)return e.message;throw e}}),s=o.find(e=>typeof e==`string`);if(s!==void 0)return unserved(`a file did not read (${s})`);let c=o,l=a.findIndex(([e])=>e===SKILL_ENTRY_FILE_NAME),u=entryDocument(t,c[l]);if(u===void 0)return unserved(`its ${SKILL_ENTRY_FILE_NAME} is not UTF-8 text with frontmatter that meets the Agent Skills format`);if(c[l]=u,c.reduce((e,t)=>e+t.bytes.byteLength,0)>16777216||c.some(e=>e.bytes.byteLength>MAX_SKILL_FILE_BYTES))return unserved(`its files as read are over the size limits`);let d=new Map,f=[];for(let[e,[n]]of a.entries()){let r=c[e];d.set(n,{mimeType:servedMimeType(n,r),size:r.bytes.byteLength}),f.push({uri:skillFileUri(t.name,n),digest:`sha256:${createHash(`sha256`).update(r.bytes).digest(`hex`)}`,size:r.bytes.byteLength})}return{name:t.name,description:u.description,document:u,entry:{uri:skillFileUri(t.name,SKILL_ENTRY_FILE_NAME),frontmatter:u.frontmatter,resources:f},files:d,directories:new Set(r)}}function entryDocument(e,t){if(t.text===void 0)return;let n=parseFrontmatterJson(t.text);if(n===void 0)return;if(n.present&&n.data.name===e.name&&typeof n.data.description==`string`)return conforming({bytes:t.bytes,description:n.data.description,frontmatter:n.data,text:t.text});let r=typeof n.data.description==`string`?n.data.description:e.description,{name:i,description:a,...o}=n.data,s=`---\n${renderFrontmatter({name:e.name,description:r,...o})}---\n${n.content}`,c=parseFrontmatterJson(s);if(c!==void 0&&c.data.name===e.name)return conforming({bytes:new TextEncoder().encode(s),description:r,frontmatter:c.data,text:s})}const SKILL_NAME_PATTERN=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function conforming(e){let{name:t,description:n}=e.frontmatter;if(typeof t==`string`&&typeof n==`string`&&!(Array.from(t).length>64||!SKILL_NAME_PATTERN.test(t))&&!(n.trim().length===0||Array.from(n).length>1024))return e}function renderFrontmatter(e){return Object.entries(e).map(([e,t])=>`${/^[A-Za-z_][A-Za-z0-9_-]*$/u.test(e)?e:JSON.stringify(e)}: ${JSON.stringify(t)}\n`).join(``)}function parseFrontmatterJson(e){let t,n;try{n=parseFrontmatter(e),t=JSON.parse(JSON.stringify(n?.data??{}))}catch{return}if(typeof t==`object`&&t&&!Array.isArray(t))return{content:n?.content??e,data:t,present:n!==void 0}}function listDirectory(e,t){if(t!==void 0&&!e.directories.has(t))return;let n=t===void 0?``:`${t}/`,r=[],add=(t,i)=>{let a=t.slice(n.length);t.startsWith(n)&&!a.includes(`/`)&&r.push({uri:skillFileUri(e.name,t),name:a,mimeType:i})};for(let[t,n]of e.files)add(t,n.mimeType);for(let t of e.directories)add(t,`inode/directory`);return r.sort((e,t)=>comparePaths(e.name,t.name))}function parseSkillUri(e){if(!e.startsWith(SKILL_URI_PREFIX))return;let t=e.slice(8);if(/[?#\\\s]/u.test(t))return;let n=[];for(let e of t.split(`/`)){let t;try{t=decodeURIComponent(e)}catch{return}if(!isSafeSegment(t))return;n.push(t)}let[r,...i]=n;if(r!==void 0)return i.length===0?{skill:r}:{skill:r,path:i.join(`/`)}}function isSafeSegment(e){return e.length>0&&e!==`.`&&e!==`..`&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function skillFileUri(e,t){let n=t.split(`/`).map(encodeURIComponent).join(`/`);return`${SKILL_URI_PREFIX}${encodeURIComponent(e)}/${n}`}function rejectCursor(e){if(e!==void 0)throw new ProtocolError(ProtocolErrorCode.InvalidParams,`Unknown cursor.`)}const MIME_TYPES=new Map([[`css`,`text/css`],[`csv`,`text/csv`],[`gif`,`image/gif`],[`htm`,`text/html`],[`html`,`text/html`],[`jpeg`,`image/jpeg`],[`jpg`,`image/jpeg`],[`js`,`text/javascript`],[`json`,`application/json`],[`md`,`text/markdown`],[`mjs`,`text/javascript`],[`pdf`,`application/pdf`],[`png`,`image/png`],[`py`,`text/x-python`],[`sh`,`text/x-shellscript`],[`svg`,`image/svg+xml`],[`ts`,`text/typescript`],[`txt`,`text/plain`],[`webp`,`image/webp`],[`xml`,`application/xml`],[`yaml`,`application/yaml`],[`yml`,`application/yaml`]]);function servedMimeType(e,t){let n=e.slice(e.lastIndexOf(`/`)+1),r=n.lastIndexOf(`.`);return(r<=0?void 0:MIME_TYPES.get(n.slice(r+1).toLowerCase()))??(t.text===void 0?`application/octet-stream`:`text/plain`)}function mimeTypeFor(e){return servedMimeType(e,{bytes:new Uint8Array})}async function mapWithConcurrency(e,t,n){let r=Array.from({length:e.length}),i=0;return await Promise.all(Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let t=i;i+=1,r[t]=await n(e[t])}})),r}export{MCP_SKILLS_EXTENSION,MCP_SKILL_MAX_RESOURCES,MCP_SKILL_MAX_TOTAL_BYTES,createMcpSkillsFeature,parseSkillUri};
@@ -1,4 +1,4 @@
1
- import { McpServer, type McpToolAnnotations, type StandardSchemaWithJSON } from "#compiled/@modelcontextprotocol/server/index.js";
1
+ import { McpServer, type McpJsonObject, type McpToolAnnotations, type StandardSchemaWithJSON } from "#compiled/@modelcontextprotocol/server/index.js";
2
2
  import type { SessionAuthContext } from "#channel/types.js";
3
3
  export declare const MCP_PROTOCOL_VERSION = "2026-07-28";
4
4
  /**
@@ -6,6 +6,17 @@ export declare const MCP_PROTOCOL_VERSION = "2026-07-28";
6
6
  * largest legitimate payload is an `outputSchema`, itself capped at 64 KiB.
7
7
  */
8
8
  export declare const MCP_REQUEST_BODY_MAX_BYTES: number;
9
+ /**
10
+ * Cache hint for the tool lists, skill lists, and skill reads eve serves.
11
+ * They are fixed per deployment, but clients cache per URL, and a production
12
+ * alias serves a new deployment under the same URL, so the TTL is how long a
13
+ * client may see the old lists after a deploy. `private`: route auth
14
+ * admitted this caller, and a shared cache cannot rerun it for the next one.
15
+ */
16
+ export declare const MCP_LIST_CACHE_HINT: {
17
+ readonly cacheScope: "private";
18
+ readonly ttlMs: number;
19
+ };
9
20
  interface McpToolDefinition<TInputSchema extends StandardSchemaWithJSON = StandardSchemaWithJSON> {
10
21
  readonly name: string;
11
22
  readonly description?: string;
@@ -51,25 +62,46 @@ export declare class McpToolOperationError extends Error {
51
62
  readonly code: McpToolOperationErrorCode;
52
63
  constructor(code: McpToolOperationErrorCode, message: string);
53
64
  }
65
+ /** What a tool handler sees of one `tools/call`. */
66
+ export interface McpToolCallContext {
67
+ readonly auth: SessionAuthContext | null;
68
+ /**
69
+ * The capabilities a 2026-07-28 request declared in its envelope. 2025-era
70
+ * requests declare none per request, so they get `undefined`.
71
+ */
72
+ readonly clientCapabilities: unknown;
73
+ /** The request's `_meta`, without the reserved `io.modelcontextprotocol/*` keys. */
74
+ readonly meta: Readonly<Record<string, unknown>> | undefined;
75
+ readonly signal: AbortSignal;
76
+ }
54
77
  export interface McpServerTool {
55
78
  readonly name: string;
56
79
  register(server: McpServer, auth: SessionAuthContext | null): void;
57
80
  }
81
+ /**
82
+ * A set of MCP handlers beside the tools, such as skills. Every request
83
+ * builds a fresh server, so `register` runs once per request, after
84
+ * `capabilities` are merged one level deep into the server's own.
85
+ * Declaring a capability obliges `register` to set its handlers.
86
+ */
87
+ export interface McpServerFeature {
88
+ readonly capabilities: McpJsonObject;
89
+ register(server: McpServer): void;
90
+ }
58
91
  type InferSchemaOutput<TSchema> = TSchema extends StandardSchemaWithJSON<unknown, infer TOutput> ? TOutput : never;
59
92
  /** Keeps a schema and its inferred handler input coupled while erasing heterogeneous storage. */
60
93
  export declare function defineMcpTool<const TInputSchema extends StandardSchemaWithJSON<unknown, unknown>, TStructured = Readonly<Record<string, unknown>>>(input: {
61
94
  readonly definition: McpToolDefinition<TInputSchema>;
62
- call(value: InferSchemaOutput<TInputSchema>, context: {
63
- readonly auth: SessionAuthContext | null;
64
- readonly signal: AbortSignal;
65
- }): Promise<McpCallToolResult<TStructured>>;
95
+ call(value: InferSchemaOutput<TInputSchema>, context: McpToolCallContext): Promise<McpCallToolResult<TStructured>>;
66
96
  }): McpServerTool;
67
97
  interface McpStreamableHttpServerOptions {
68
98
  readonly name: string;
69
99
  readonly version: string;
70
100
  /** Server-level usage guidance returned from `initialize` and `server/discover`. */
71
101
  readonly instructions?: string;
72
- readonly tools: readonly McpServerTool[];
102
+ /** When set, the server declares `tools`, even for an empty list. */
103
+ readonly tools?: readonly McpServerTool[];
104
+ readonly features?: readonly McpServerFeature[];
73
105
  authenticate(request: Request): Promise<SessionAuthContext | null | Response>;
74
106
  }
75
107
  /**
@@ -1 +1 @@
1
- import{createLogger,logError}from"#internal/logging.js";import{context}from"#compiled/@opentelemetry/api/index.js";import{McpServer,createMcpHandler}from"#compiled/@modelcontextprotocol/server/index.js";import{withMcpRequestTraceContext}from"#internal/mcp/request-trace-context.js";const log=createLogger(`mcp.server`),MCP_PROTOCOL_VERSION=`2026-07-28`,MCP_REQUEST_BODY_MAX_BYTES=1048576;var McpToolOperationError=class extends Error{code;constructor(e,t){super(t),this.name=`McpToolOperationError`,this.code=e}};const RETRYABLE_CODES=new Set([`conflict`]);function defineMcpTool(e){return{name:e.definition.name,register(t,n){t.registerTool(e.definition.name,{...e.definition.annotations===void 0?{}:{annotations:e.definition.annotations},...e.definition.description===void 0?{}:{description:e.definition.description},inputSchema:advertiseOnly(e.definition.inputSchema),...e.definition.outputSchema===void 0?{}:{outputSchema:e.definition.outputSchema}},async(t,r)=>{let i=await e.definition.inputSchema[`~standard`].validate(t);return i.issues===void 0?await callTool(e.call,i.value,r.mcpReq.signal,n):toolError({code:`invalid_input`,message:`Invalid arguments for tool ${e.definition.name}: ${i.issues.map(formatIssue).join(`, `)}`,retryable:!1})})}}}function advertiseOnly(e){let t=e[`~standard`];return{"~standard":{jsonSchema:t.jsonSchema,validate:e=>({value:e}),vendor:t.vendor,version:t.version}}}function formatIssue(e){return e.path===void 0||e.path.length===0?e.message:`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`}function createMcpStreamableHttpServer(e){let t=new Map(e.tools.map(e=>[e.name,e]));if(t.size!==e.tools.length)throw Error(`MCP tool names must be unique.`);return async n=>{let r=await e.authenticate(n);if(r instanceof Response)return r;let i=createMcpHandler(()=>createServer(e,t,r),{legacy:`stateless`});if(n.method.toUpperCase()!==`POST`)return await i.fetch(n);let a=await inspectRequestBody(n);if(a.tooLarge)return requestBodyTooLargeResponse();if(a.invalidJson)return invalidJsonResponse();let o=a.value;if(o===void 0)return await i.fetch(n);let s=await preflightModernRequest(n,o);return s===void 0?await context.with(withMcpRequestTraceContext(context.active(),o),()=>i.fetch(n,{parsedBody:o})):s}}async function preflightModernRequest(e,t){return e.headers.has(`mcp-protocol-version`)||!claimsCurrentProtocolVersion(t)?void 0:await probeEarlierValidationFailure(e,t)??headerMismatchResponse(t)}async function inspectRequestBody(e){let t=e.body;if(t===null)return{tooLarge:!1};let n=Number(e.headers.get(`content-length`));if(Number.isFinite(n)&&n>1048576)return await t.cancel().catch(()=>{}),{tooLarge:!0};let r=t.getReader(),i=[],a=0;try{for(;;){let e=await r.read();if(e.done)break;if(a+=e.value.byteLength,a>1048576)return await r.cancel(),{tooLarge:!0};i.push(e.value)}let e=new Uint8Array(a),t=0;for(let n of i)e.set(n,t),t+=n.byteLength;return{tooLarge:!1,value:JSON.parse(new TextDecoder().decode(e))}}catch{return{invalidJson:!0,tooLarge:!1}}}function invalidJsonResponse(){return Response.json({error:{code:-32700,message:`Parse error`},id:null,jsonrpc:`2.0`},{status:400})}function requestBodyTooLargeResponse(){return Response.json({error:{code:-32e3,message:`Request body too large`},id:null,jsonrpc:`2.0`},{status:413,statusText:`Request Entity Too Large`})}function claimsCurrentProtocolVersion(e){return isPlainRecord(e)&&isPlainRecord(e.params)&&isPlainRecord(e.params._meta)&&e.params._meta[`io.modelcontextprotocol/protocolVersion`]===`2026-07-28`}function isPlainRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function probeEarlierValidationFailure(e,t){let n=new Headers(e.headers);n.set(`mcp-protocol-version`,MCP_PROTOCOL_VERSION);let r=new Request(e.url,{body:JSON.stringify(t),headers:n,method:e.method}),i=createMcpHandler(()=>new McpServer({name:`eve-mcp-preflight`,version:`0`}),{legacy:`reject`});try{let e=await i.fetch(r,{parsedBody:t});if(e.status===406||e.status===415)return e;if(e.status===400){let t=await e.clone().json().catch(()=>void 0);if(t?.error?.code===-32700||t?.error?.code===-32600||t?.error?.code===-32602||t?.error?.code===-32022)return e}await e.body?.cancel();return}finally{await i.close().catch(()=>{})}}function headerMismatchResponse(e){let t=`the body carries a modern MCP envelope but the required MCP-Protocol-Version header is absent`;return Response.json({error:{code:-32020,data:{mismatch:{body:t,header:`(missing)`}},message:`Bad Request: the request headers and body disagree: ${t}`},id:readJsonRpcRequestId(e),jsonrpc:`2.0`},{status:400})}function readJsonRpcRequestId(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=Reflect.get(e,`id`);return typeof t==`string`||typeof t==`number`?t:null}function createServer(e,t,n){let r={capabilities:{tools:{listChanged:!1}}};e.instructions!==void 0&&(r.instructions=e.instructions);let i=new McpServer({name:e.name,version:e.version},r);for(let e of t.values())e.register(i,n);return i}async function callTool(e,t,n,r){try{return await e(t,{auth:r,signal:n})}catch(e){return e instanceof McpToolOperationError?toolError({code:e.code,message:e.message,retryable:RETRYABLE_CODES.has(e.code)}):toolError({code:`internal`,errorId:logError(log,`MCP tool call failed`,e),message:`The server could not complete this tool call.`,retryable:!1})}}function toolError(e){return{content:[{type:`text`,text:e.errorId===void 0?e.message:`${e.message} (errorId: ${e.errorId})`}],isError:!0,structuredContent:{error:e}}}export{MCP_PROTOCOL_VERSION,MCP_REQUEST_BODY_MAX_BYTES,McpToolOperationError,createMcpStreamableHttpServer,defineMcpTool};
1
+ import{createLogger,logError}from"#internal/logging.js";import{context}from"#compiled/@opentelemetry/api/index.js";import{McpServer,createMcpHandler}from"#compiled/@modelcontextprotocol/server/index.js";import{withMcpRequestTraceContext}from"#internal/mcp/request-trace-context.js";const log=createLogger(`mcp.server`),MCP_PROTOCOL_VERSION=`2026-07-28`,MCP_REQUEST_BODY_MAX_BYTES=1048576,MCP_LIST_CACHE_HINT={cacheScope:`private`,ttlMs:3e5},CACHE_HINTED_METHODS=[`resources/list`,`resources/read`,`resources/templates/list`,`server/discover`,`tools/list`];var McpToolOperationError=class extends Error{code;constructor(e,t){super(t),this.name=`McpToolOperationError`,this.code=e}};const RETRYABLE_CODES=new Set([`conflict`]);function defineMcpTool(e){return{name:e.definition.name,register(t,n){t.registerTool(e.definition.name,{...e.definition.annotations===void 0?{}:{annotations:e.definition.annotations},...e.definition.description===void 0?{}:{description:e.definition.description},inputSchema:advertiseOnly(e.definition.inputSchema),...e.definition.outputSchema===void 0?{}:{outputSchema:e.definition.outputSchema}},async(t,r)=>{let i=await e.definition.inputSchema[`~standard`].validate(t);return i.issues===void 0?await callTool(e.call,i.value,{auth:n,clientCapabilities:declaredClientCapabilities(r.mcpReq.envelope),meta:r.mcpReq._meta,signal:r.mcpReq.signal}):toolError({code:`invalid_input`,message:`Invalid arguments for tool ${e.definition.name}: ${i.issues.map(formatIssue).join(`, `)}`,retryable:!1})})}}}function advertiseOnly(e){let t=e[`~standard`];return{"~standard":{jsonSchema:t.jsonSchema,validate:e=>({value:e}),vendor:t.vendor,version:t.version}}}function formatIssue(e){return e.path===void 0||e.path.length===0?e.message:`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`}function createMcpStreamableHttpServer(e){let t=new Map((e.tools??[]).map(e=>[e.name,e]));if(t.size!==(e.tools?.length??0))throw Error(`MCP tool names must be unique.`);return async n=>{let r=await e.authenticate(n);if(r instanceof Response)return r;let i=createMcpHandler(()=>createServer(e,t,r),{legacy:`stateless`});if(n.method.toUpperCase()!==`POST`)return await i.fetch(n);let a=await inspectRequestBody(n);if(a.tooLarge)return requestBodyTooLargeResponse();if(a.invalidJson)return invalidJsonResponse();let o=a.value;if(o===void 0)return await i.fetch(n);let s=await preflightModernRequest(n,o);return s===void 0?await context.with(withMcpRequestTraceContext(context.active(),o),()=>i.fetch(n,{parsedBody:o})):s}}async function preflightModernRequest(e,t){return e.headers.has(`mcp-protocol-version`)||!claimsCurrentProtocolVersion(t)?void 0:await probeEarlierValidationFailure(e,t)??headerMismatchResponse(t)}async function inspectRequestBody(e){let t=e.body;if(t===null)return{tooLarge:!1};let n=Number(e.headers.get(`content-length`));if(Number.isFinite(n)&&n>1048576)return await t.cancel().catch(()=>{}),{tooLarge:!0};let r=t.getReader(),i=[],a=0;try{for(;;){let e=await r.read();if(e.done)break;if(a+=e.value.byteLength,a>1048576)return await r.cancel(),{tooLarge:!0};i.push(e.value)}let e=new Uint8Array(a),t=0;for(let n of i)e.set(n,t),t+=n.byteLength;return{tooLarge:!1,value:JSON.parse(new TextDecoder().decode(e))}}catch{return{invalidJson:!0,tooLarge:!1}}}function invalidJsonResponse(){return Response.json({error:{code:-32700,message:`Parse error`},id:null,jsonrpc:`2.0`},{status:400})}function requestBodyTooLargeResponse(){return Response.json({error:{code:-32e3,message:`Request body too large`},id:null,jsonrpc:`2.0`},{status:413,statusText:`Request Entity Too Large`})}function claimsCurrentProtocolVersion(e){return isPlainRecord(e)&&isPlainRecord(e.params)&&isPlainRecord(e.params._meta)&&e.params._meta[`io.modelcontextprotocol/protocolVersion`]===`2026-07-28`}function isPlainRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function probeEarlierValidationFailure(e,t){let n=new Headers(e.headers);n.set(`mcp-protocol-version`,MCP_PROTOCOL_VERSION);let r=new Request(e.url,{body:JSON.stringify(t),headers:n,method:e.method}),i=createMcpHandler(()=>new McpServer({name:`eve-mcp-preflight`,version:`0`}),{legacy:`reject`});try{let e=await i.fetch(r,{parsedBody:t});if(e.status===406||e.status===415)return e;if(e.status===400){let t=await e.clone().json().catch(()=>void 0);if(t?.error?.code===-32700||t?.error?.code===-32600||t?.error?.code===-32602||t?.error?.code===-32022)return e}await e.body?.cancel();return}finally{await i.close().catch(()=>{})}}function headerMismatchResponse(e){let t=`the body carries a modern MCP envelope but the required MCP-Protocol-Version header is absent`;return Response.json({error:{code:-32020,data:{mismatch:{body:t,header:`(missing)`}},message:`Bad Request: the request headers and body disagree: ${t}`},id:readJsonRpcRequestId(e),jsonrpc:`2.0`},{status:400})}function readJsonRpcRequestId(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=Reflect.get(e,`id`);return typeof t==`string`||typeof t==`number`?t:null}function createServer(e,t,n){let r=e.tools===void 0?{}:{tools:{listChanged:!1}};for(let t of e.features??[])for(let[e,n]of Object.entries(t.capabilities))r[e]={...r[e],...n};let i={cacheHints:Object.fromEntries(CACHE_HINTED_METHODS.map(e=>[e,MCP_LIST_CACHE_HINT])),capabilities:r};e.instructions!==void 0&&(i.instructions=e.instructions);let a=new McpServer({name:e.name,version:e.version},i);for(let e of t.values())e.register(a,n);for(let t of e.features??[])t.register(a);return a}function declaredClientCapabilities(e){if(e?.[`io.modelcontextprotocol/protocolVersion`]===`2026-07-28`)return e[`io.modelcontextprotocol/clientCapabilities`]}async function callTool(e,t,n){try{return await e(t,n)}catch(e){return e instanceof McpToolOperationError?toolError({code:e.code,message:e.message,retryable:RETRYABLE_CODES.has(e.code)}):toolError({code:`internal`,errorId:logError(log,`MCP tool call failed`,e),message:`The server could not complete this tool call.`,retryable:!1})}}function toolError(e){return{content:[{type:`text`,text:e.errorId===void 0?e.message:`${e.message} (errorId: ${e.errorId})`}],isError:!0,structuredContent:{error:e}}}export{MCP_LIST_CACHE_HINT,MCP_PROTOCOL_VERSION,MCP_REQUEST_BODY_MAX_BYTES,McpToolOperationError,createMcpStreamableHttpServer,defineMcpTool};
@@ -1 +1 @@
1
- import{randomUUID}from"node:crypto";import{cp,mkdir,readFile,rm,symlink,writeFile}from"node:fs/promises";import{resolvePackageRoot}from"#internal/application/package.js";import{existsSync,readFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createDevelopmentSourceSnapshotPlan,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts-retention.js";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{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 +1 @@
1
- import{rm}from"node:fs/promises";import{prepareAuthoredRuntimeModules}from"#internal/authored-runtime-modules.js";import{writeMaterializedAuthoredModules}from"#internal/materialized-authored-modules.js";import{activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,stageDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts.js";const developmentGenerationPruneStates=new Map;async function stageDevelopmentGeneration(e){let[t,n]=await Promise.allSettled([prepareAuthoredRuntimeModules({appRoot:e.project.appRoot,manifest:e.manifest,moduleMapPath:e.paths.moduleMapPath}),stageDevelopmentRuntimeArtifactsSnapshot(e)]);if(n.status===`rejected`)throw t.status===`rejected`?AggregateError([t.reason,n.reason],`Failed to stage development generation.`):n.reason;let r=n.value;try{if(t.status===`rejected`)throw t.reason;let e=t.value,n=await writeMaterializedAuthoredModules({prepared:e,runtimeAppRoot:r.runtimeAppRoot});return e.workflowSourceFingerprint===void 0?{...r,authoredWorkflowModules:e.authoredWorkflowModules,fingerprint:n.fingerprint}:{...r,authoredWorkflowModules:e.authoredWorkflowModules,fingerprint:n.fingerprint,workflowSourceFingerprint:e.workflowSourceFingerprint}}catch(e){try{await rm(r.snapshotRoot,{force:!0,recursive:!0})}catch(t){throw AggregateError([e,t],`Failed to materialize and discard development generation "${r.snapshotRoot}".`)}throw e}}async function activateDevelopmentGeneration(e){(await activateDevelopmentGenerationTransaction(e)).commit()}async function activateDevelopmentGenerationTransaction(e){let t=await activateDevelopmentRuntimeArtifactsSnapshotTransaction({appRoot:e.appRoot,snapshot:e.generation}),n=!1;return{commit(){n||(n=!0,t.commit(),requestDevelopmentGenerationPrune(e.appRoot,e.onRuntimePruned))},async rollback(){n||(n=!0,await t.rollback())}}}async function discardDevelopmentGeneration(e){await rm(e.snapshotRoot,{force:!0,recursive:!0})}function requestDevelopmentGenerationPrune(e,t){let n=developmentGenerationPruneStates.get(e)??{requested:!1,reconciliationPending:!1,running:void 0};developmentGenerationPruneStates.set(e,n),n.requested=!0,n.onRuntimePruned=t,n.running===void 0&&startDevelopmentGenerationPruning(e,n)}function startDevelopmentGenerationPruning(e,t){t.running=(async()=>{for(;t.requested;){t.requested=!1;let n=t.onRuntimePruned,r;try{r=await pruneDevelopmentRuntimeArtifactsSnapshots({appRoot:e})}catch(e){throw t.reconciliationPending||=n!==void 0,e}t.reconciliationPending||=r&&n!==void 0;try{t.reconciliationPending&&n!==void 0&&(await n(),t.reconciliationPending=!1)}catch(e){console.warn(`[eve:dev] failed to reconcile expired Workflow runs: ${String(e)}`)}}})().catch(e=>{console.warn(`[eve:dev] failed to prune runtime generations: ${String(e)}`)}).finally(()=>{t.running=void 0,t.requested?startDevelopmentGenerationPruning(e,t):t.reconciliationPending?t.onRuntimePruned=void 0:developmentGenerationPruneStates.delete(e)})}export{activateDevelopmentGeneration,activateDevelopmentGenerationTransaction,discardDevelopmentGeneration,stageDevelopmentGeneration};
1
+ import{rm}from"node:fs/promises";import{prepareAuthoredRuntimeModules}from"#internal/authored-runtime-modules.js";import{writeMaterializedAuthoredModules}from"#internal/materialized-authored-modules.js";import{isPathInsideOrEqual}from"#internal/nitro/dev-runtime-source-snapshot-local-roots.js";import{activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,stageDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts.js";const developmentGenerationPruneStates=new Map;async function stageDevelopmentGeneration(e){let[t,n]=await Promise.allSettled([prepareAuthoredRuntimeModules({appRoot:e.project.appRoot,manifest:e.manifest,moduleMapPath:e.paths.moduleMapPath}),stageDevelopmentRuntimeArtifactsSnapshot(e)]);if(n.status===`rejected`)throw t.status===`rejected`?AggregateError([t.reason,n.reason],`Failed to stage development generation.`):n.reason;let r=n.value;try{if(t.status===`rejected`)throw t.reason;let n=t.value,i=await writeMaterializedAuthoredModules({prepared:n,runtimeAppRoot:r.runtimeAppRoot}),a={...r,authoredWorkflowModules:n.authoredWorkflowModules,fingerprint:i.fingerprint,sourceWatchPaths:[...r.sourceWatchPaths??[],...n.sourceModules.filter(t=>!isPathInsideOrEqual(t,e.manifest.agentRoot))]};return n.workflowSourceFingerprint===void 0?a:{...a,workflowSourceFingerprint:n.workflowSourceFingerprint}}catch(e){try{await rm(r.snapshotRoot,{force:!0,recursive:!0})}catch(t){throw AggregateError([e,t],`Failed to materialize and discard development generation "${r.snapshotRoot}".`)}throw e}}async function activateDevelopmentGeneration(e){(await activateDevelopmentGenerationTransaction(e)).commit()}async function activateDevelopmentGenerationTransaction(e){let t=await activateDevelopmentRuntimeArtifactsSnapshotTransaction({appRoot:e.appRoot,snapshot:e.generation}),n=!1;return{commit(){n||(n=!0,t.commit(),requestDevelopmentGenerationPrune(e.appRoot,e.onRuntimePruned))},async rollback(){n||(n=!0,await t.rollback())}}}async function discardDevelopmentGeneration(e){await rm(e.snapshotRoot,{force:!0,recursive:!0})}function requestDevelopmentGenerationPrune(e,t){let n=developmentGenerationPruneStates.get(e)??{requested:!1,reconciliationPending:!1,running:void 0};developmentGenerationPruneStates.set(e,n),n.requested=!0,n.onRuntimePruned=t,n.running===void 0&&startDevelopmentGenerationPruning(e,n)}function startDevelopmentGenerationPruning(e,t){t.running=(async()=>{for(;t.requested;){t.requested=!1;let n=t.onRuntimePruned,r;try{r=await pruneDevelopmentRuntimeArtifactsSnapshots({appRoot:e})}catch(e){throw t.reconciliationPending||=n!==void 0,e}t.reconciliationPending||=r&&n!==void 0;try{t.reconciliationPending&&n!==void 0&&(await n(),t.reconciliationPending=!1)}catch(e){console.warn(`[eve:dev] failed to reconcile expired Workflow runs: ${String(e)}`)}}})().catch(e=>{console.warn(`[eve:dev] failed to prune runtime generations: ${String(e)}`)}).finally(()=>{t.running=void 0,t.requested?startDevelopmentGenerationPruning(e,t):t.reconciliationPending?t.onRuntimePruned=void 0:developmentGenerationPruneStates.delete(e)})}export{activateDevelopmentGeneration,activateDevelopmentGenerationTransaction,discardDevelopmentGeneration,stageDevelopmentGeneration};
@@ -1 +1 @@
1
- import{createHash}from"node:crypto";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{resolveDevelopmentRuntimeArtifactsPointerPath}from"#internal/nitro/dev-runtime-artifacts.js";function createDevelopmentGenerationArtifactsSource(e){return createDiskRuntimeCompiledArtifactsSource(e.runtimeAppRoot,{durableReference:usesParentDevelopmentWorkflowWorld(e.configuredWorld)?`development-generation`:void 0,moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:e.appRoot})}function createDevelopmentNitroArtifactsConfig(e){return{appRoot:e.appRoot,devRuntimeArtifactsPointerPath:resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),durableArtifactsReference:usesParentDevelopmentWorkflowWorld(e.configuredWorld)?`development-generation`:void 0,kind:`development`,moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`)}}function createProductionNitroArtifactsConfig(e){return{kind:`production`,sandboxScope:createHash(`sha256`).update(e).digest(`hex`).slice(0,16)}}export{createDevelopmentGenerationArtifactsSource,createDevelopmentNitroArtifactsConfig,createProductionNitroArtifactsConfig};
1
+ import{createHash}from"node:crypto";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{resolveDevelopmentRuntimeArtifactsPointerPath}from"#internal/nitro/dev-runtime-artifacts.js";function createDevelopmentGenerationArtifactsSource(e){return createDiskRuntimeCompiledArtifactsSource(e.runtimeAppRoot,{durableReference:usesParentDevelopmentWorkflowWorld(e.configuredWorld)?`development-generation`:void 0,moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:e.appRoot})}function createDevelopmentNitroArtifactsConfig(e){return{appRoot:e.appRoot,devRuntimeArtifactsPointerPath:resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),durableArtifactsReference:usesParentDevelopmentWorkflowWorld(e.configuredWorld)?`development-generation`:void 0,kind:`development`,moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`)}}function createProductionNitroArtifactsConfig(e){return{kind:`production`,sandboxScope:createHash(`sha256`).update(e).digest(`hex`).slice(0,16)}}export{createDevelopmentGenerationArtifactsSource,createDevelopmentNitroArtifactsConfig,createProductionNitroArtifactsConfig};
@@ -1 +1 @@
1
- import{readFile}from"node:fs/promises";import{isObject}from"#shared/guards.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{resolveDiscoveryProject}from"#discover/project.js";import{resolveInstalledPackageInfo,resolvePackageSourceFilePath}from"#internal/application/package.js";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{toErrorMessage}from"#shared/errors.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{ApplicationBuildProfiler,createApplicationBuildProfile,measureApplicationBuildOutput,writeApplicationBuildProfile}from"#internal/application/build-profile.js";import{RecoverablePublicationError,publishApplicationBuildArtifacts}from"#internal/application/output-publication.js";import{stageProductionCompilerArtifacts}from"#internal/application/production-compiler-artifacts.js";import{materializeVercelWorkflowFunctionOutput,normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{emitConnectManifest}from"#internal/external-resources.js";import{copyHostMiddlewareFunctions}from"#internal/nitro/host/copy-host-middleware.js";import{normalizeVercelServiceCrons}from"#internal/nitro/host/normalize-vercel-service-crons.js";import{prepareProductionApplicationHost,refreshProductionCompiledArtifacts}from"#internal/nitro/host/prepare-application-host.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";import{resolveEveServicePrefixByRoot}from"#internal/vercel/vercel-service-config-operations.js";import{parseVercelServicesConfig}from"#internal/vercel/vercel-services-config.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}async function measureBuildPhase(e,t,n){return e===void 0?n():e.measure(t,n)}function isPathInside(e,t){let n=relative(e,t);return n.length===0||!n.startsWith(`..${sep}`)&&n!==`..`&&!isAbsolute(n)}function assertProfileOutputOutsideBuildOutput(e,t){if(e!==void 0&&isPathInside(t,e))throw Error(`Build profile path ${e} must be outside the published output directory ${t}.`)}async function writeOptionalApplicationBuildProfile(e){try{assertProfileOutputOutsideBuildOutput(e.profileOutputPath,e.outputDirectory);let t=e.profiler.finish(),n=await measureApplicationBuildOutput(e.outputDirectory);await writeApplicationBuildProfile(e.profileOutputPath,createApplicationBuildProfile({output:n,target:process.env.VERCEL?`vercel`:`local`,timing:t}))}catch(t){console.warn(`eve: failed to write optional build profile to ${e.profileOutputPath}; continuing with the published build output: ${toErrorMessage(t)}`)}}async function resolveEveServicePrefixForVercelFunctionOutput(e,t){let n=Array.from(new Set([resolve(e),resolve(t)])),r=await findClosestVercelOutputDirectory(e);if(r!==void 0)try{let e=join(r,`config.json`),t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),i=resolveEveServicePrefixByRoot({appRoots:n,configRoot:await resolveVercelOutputConfigRoot(r),config:t});if(i!==void 0)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let i=e;for(;;){for(let e of[join(i,`vercel.json`),join(i,`.vercel`,`output`,`config.json`)])try{let t=parseVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),e),r=e.endsWith(`vercel.json`)?i:await resolveVercelOutputConfigRoot(dirname(e)),a=resolveEveServicePrefixByRoot({appRoots:n,configRoot:r,config:t});if(a!==void 0)return a}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let e=dirname(i);if(e===i)return;i=e}}async function resolveVercelOutputConfigRoot(e){let t=dirname(dirname(e));try{let e=JSON.parse(await readFile(join(t,`.vercel`,`project.json`),`utf8`));if(isObject(e)&&isObject(e.settings)){let n=e.settings.rootDirectory;if(typeof n==`string`&&n.trim().length>0)return resolve(t,n)}}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return t}async function buildNitroOutput(e,t,n){let r=trimTrailingSlash(e.options.output.dir);return await measureBuildPhase(t,`${n}.cache.prepare`,()=>prepareEveVersionedCacheDirectory(r)),await measureBuildPhase(t,`${n}.prepare`,()=>prepare(e)),await measureBuildPhase(t,`${n}.public-assets`,()=>copyPublicAssets(e)),await measureBuildPhase(t,`${n}.prerender`,()=>prerender(e)),await measureBuildPhase(t,`${n}.bundle`,()=>build(e)),await measureBuildPhase(t,`${n}.cache.write`,()=>writeEveVersionedCacheMetadata(r)),r}async function buildApplication(e,t){let n=t.profileOutputPath===void 0?void 0:resolve(t.profileOutputPath),r=n===void 0?void 0:new ApplicationBuildProfiler,i=await measureBuildPhase(r,`extension.check`,()=>tryReadExtensionBuildConfig(e));if(i!==null)throw Error(`Package "${i.packageName}" is an eve extension. Run \`eve extension build\` instead of \`eve build\`.`);let a=await measureBuildPhase(r,`project.resolve`,()=>resolveDiscoveryProject(e)),o=await measureBuildPhase(r,`workspace.create`,()=>createApplicationBuildWorkspace(a.appRoot,t.vercelServiceOutput?.serviceOutputDirectory)),s=!1,c;try{c=await buildApplicationInWorkspace(o,t,r)}catch(e){throw s=e instanceof RecoverablePublicationError,e}finally{s||await measureBuildPhase(r,`workspace.remove`,()=>removeApplicationBuildWorkspace(o))}return r!==void 0&&n!==void 0&&await writeOptionalApplicationBuildProfile({outputDirectory:c,profileOutputPath:n,profiler:r}),c}async function buildApplicationInWorkspace(e,t,n){let r=await measureBuildPhase(n,`host.prepare`,()=>prepareProductionApplicationHost(e)),i=!!process.env.VERCEL,a=i?await measureBuildPhase(n,`vercel.service-prefix.resolve`,()=>resolveEveServicePrefixForVercelFunctionOutput(r.appRoot,r.compileResult.project.agentRoot)):void 0,o=normalizePublicRoutePrefix(a),s=o===EVE_ROUTE_PREFIX?void 0:o;if(t.publicRoutePrefix!==void 0&&s!==void 0&&t.publicRoutePrefix!==s)throw Error(`EVE_PUBLIC_ROUTE_PREFIX ${JSON.stringify(t.publicRoutePrefix)} conflicts with the configured Vercel service prefix ${JSON.stringify(a)}.`);let c=t.publicRoutePrefix??s,l=createProductionNitroArtifactsConfig(e.appRoot).sandboxScope,u=await measureBuildPhase(n,`nitro.create`,()=>createProductionApplicationNitro(r,{buildDir:e.nitro.buildDir,outputDir:e.publication.output.stagedDir,publicRoutePrefix:c,workspaceMember:t.workspaceMember}));try{if(!t.skipSandboxPrewarm){let t={appRoot:r.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(e.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:r.appRoot,sandboxScope:l}),log(e){console.log(e)}};await measureBuildPhase(n,`sandbox.prewarm`,async()=>{i?await runVercelBuildPrewarm(t):await prewarmAppSandboxes(t)}),await refreshProductionCompiledArtifacts(r,e.host.artifactsDir)}await buildNitroOutput(u,n,`nitro`),i&&await measureBuildPhase(n,`vercel.workflow-function.materialize`,()=>materializeVercelWorkflowFunctionOutput(e.publication.output.stagedDir)),a!==void 0&&await measureBuildPhase(n,`vercel.functions.normalize`,()=>normalizeEveVercelFunctionOutput(e.publication.output.stagedDir,{servicePrefix:a}));let o=t.vercelServiceOutput;o!==void 0&&(await measureBuildPhase(n,`vercel.service-crons.normalize`,()=>normalizeVercelServiceCrons({publicRoutePrefix:c,serviceOutputDirectory:e.publication.output.stagedDir})),await measureBuildPhase(n,`vercel.host-middleware.copy`,()=>copyHostMiddlewareFunctions({hostOutputDirectory:o.hostOutputDirectory,serviceOutputDirectory:e.publication.output.stagedDir}))),await measureBuildPhase(n,`agent-summary.emit`,()=>emitVercelAgentSummary({manifest:r.compileResult.manifest,outputPath:e.publication.summary.stagedPath})),await measureBuildPhase(n,`connect-manifest.emit`,()=>emitConnectManifest({appRoot:r.appRoot,generatorVersion:resolveInstalledPackageInfo().version,manifest:r.compileResult.manifest,outputDirectory:e.publication.output.stagedDir,publicRoutePrefix:c})),i||await measureBuildPhase(n,`compiler-artifacts.stage`,()=>stageProductionCompilerArtifacts({compilerArtifactsRoot:e.compiler.artifactsDir,outputDir:e.publication.output.stagedDir}))}finally{await measureBuildPhase(n,`nitro.close`,()=>u.close())}return await measureBuildPhase(n,`output.publish`,()=>publishCompletedApplicationBuild(e)),e.publication.output.finalDir}async function publishCompletedApplicationBuild(e){await publishApplicationBuildArtifacts({appRoot:e.appRoot,finalOutputDir:e.publication.output.finalDir,finalSummaryPath:e.publication.summary.finalPath,scratchDir:e.rootDir,stagedOutputDir:e.publication.output.stagedDir,stagedSummaryPath:e.publication.summary.stagedPath})}export{buildApplication};
1
+ 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,2 +1,2 @@
1
- import{mkdir,mkdtemp,rm}from"node:fs/promises";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{join,relative,resolve}from"node:path";import{discoverAgent}from"#discover/discover-agent.js";import{createDiskProjectSource}from"#discover/project-source.js";import{discoverFlatModuleSource,readSortedDirectoryEntries}from"#discover/grammar.js";import{EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,writeExtensionCompatibilityManifest}from"#compiler/extension-compatibility.js";import{ensureExtensionExports,tryReadExtensionBuildConfig}from"#internal/nitro/host/extension-build-config.js";import{deriveExtensionCapabilityRequirements}from"#internal/nitro/host/extension-capability-requirements.js";import{ExtensionOutputRestoreError,emitExtensionDistribution,replaceExtensionBuildOutput}from"#internal/nitro/host/extension-distribution.js";async function buildExtensionPackage(e,t){let n=resolve(e),r=createDiskProjectSource(),{diagnostics:i,manifest:a}=await discoverAgent({agentRoot:t.sourceRoot,appRoot:n,source:r,role:`extension`}),o=i.filter(e=>e.severity===`error`);if(o.length>0)throw Error(`Cannot build extension "${t.packageName}":\n${o.map(e=>` - ${e.message}`).join(`
1
+ import{mkdir,mkdtemp,rm}from"node:fs/promises";import{join,relative,resolve}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{discoverAgent}from"#discover/discover-agent.js";import{createDiskProjectSource}from"#discover/project-source.js";import{discoverFlatModuleSource,readSortedDirectoryEntries}from"#discover/grammar.js";import{EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,writeExtensionCompatibilityManifest}from"#compiler/extension-compatibility.js";import{ensureExtensionExports,tryReadExtensionBuildConfig}from"#internal/nitro/host/extension-build-config.js";import{deriveExtensionCapabilityRequirements}from"#internal/nitro/host/extension-capability-requirements.js";import{ExtensionOutputRestoreError,emitExtensionDistribution,replaceExtensionBuildOutput}from"#internal/nitro/host/extension-distribution.js";async function buildExtensionPackage(e,t){let n=resolve(e),r=createDiskProjectSource(),{diagnostics:i,manifest:a}=await discoverAgent({agentRoot:t.sourceRoot,appRoot:n,source:r,role:`extension`}),o=i.filter(e=>e.severity===`error`);if(o.length>0)throw Error(`Cannot build extension "${t.packageName}":\n${o.map(e=>` - ${e.message}`).join(`
2
2
  `)}`);let s=discoverFlatModuleSource({rootEntries:await readSortedDirectoryEntries(r,t.sourceRoot),rootPath:t.sourceRoot,slotName:`extension`}).module;if(s===void 0)throw Error(`Cannot build extension "${t.packageName}": its source root "${t.sourceRoot}" is missing an "extension.<ext>" declaration. Add \`export default defineExtension(...)\` there (with or without config).`);let c=await mkdtemp(join(n,`.eve-extension-build-`)),l=join(c,`output`),u=join(l,relative(t.outDir,t.distRoot)),d=!1;try{await mkdir(u,{recursive:!0});let e=await emitExtensionDistribution({appRoot:n,declarationModule:s,declarationsRoot:join(c,`declarations`),manifest:a,runtimeDependencies:t.runtimeDependencies,shortName:t.shortName,sourceRoot:t.sourceRoot,stagedDistRoot:u,stagedOutDir:l,transactionRoot:c});return await ensureExtensionExports(n,t.outDir),await writeExtensionCompatibilityManifest(u,{kind:EXTENSION_COMPATIBILITY_MANIFEST_KIND,formatVersion:EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,builtWithEve:resolveInstalledPackageInfo().version,...t.externalDependencies.length===0?{}:{build:{externalDependencies:t.externalDependencies}},requires:await deriveExtensionCapabilityRequirements({runtimeImports:e,runtimeRoot:l,declarationModule:s,manifest:a,packageName:t.packageName,runtimeDependencies:t.runtimeDependencies,shortName:t.shortName,sourceRoot:t.sourceRoot})}),await replaceExtensionBuildOutput({outDir:t.outDir,stagedOutDir:l,transactionRoot:c}),t.outDir}catch(e){throw d=e instanceof ExtensionOutputRestoreError,e}finally{d||await rm(c,{force:!0,recursive:!0})}}export{buildExtensionPackage,tryReadExtensionBuildConfig};
@@ -1 +1 @@
1
- import{mkdir,writeFile}from"node:fs/promises";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{dirname}from"node:path";import{VERCEL_EVE_AGENT_SUMMARY_KIND,VERCEL_EVE_AGENT_SUMMARY_VERSION,normalizeChannelKindForDisplay}from"#internal/vercel-agent-summary.js";function buildVercelAgentSummary(e){let{manifest:t}=e;return{kind:VERCEL_EVE_AGENT_SUMMARY_KIND,schemaVersion:VERCEL_EVE_AGENT_SUMMARY_VERSION,generatorVersion:e.generatorVersion??resolveInstalledPackageInfo().version,agent:t.config.dynamicModel===void 0?{name:t.config.name,description:t.config.description,modelId:t.config.model.id}:{name:t.config.name,description:t.config.description,modelRouting:{kind:`dynamic`}},instructions:t.instructions.map(toInstructionsEntry),schedules:t.schedules.map(toScheduleEntry),tools:t.tools.map(toToolEntry),skills:t.skills.map(toSkillEntry),connections:t.connections.map(toConnectionEntry),channels:t.channelRoutes.effective.map(toChannelEntry),sandbox:t.sandbox===null?null:{logicalPath:t.sandbox.logicalPath},subagents:t.subagents.map(toSubagentEntry),diagnostics:{errors:t.diagnosticsSummary.errors,warnings:t.diagnosticsSummary.warnings}}}async function emitVercelAgentSummary(e){let t=buildVercelAgentSummary({generatorVersion:e.generatorVersion,manifest:e.manifest});return await mkdir(dirname(e.outputPath),{recursive:!0}),await writeFile(e.outputPath,`${JSON.stringify(t,null,2)}\n`),e.outputPath}function toInstructionsEntry(e){return{content:e.content,logicalPath:e.logicalPath,role:e.role,sourceKind:e.sourceKind}}function toScheduleEntry(e){return{name:e.name,cron:e.cron,logicalPath:e.logicalPath}}function toToolEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function toSkillEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath,sourceKind:e.sourceKind}}function toConnectionEntry(e){let t={name:e.connectionName,description:e.description,url:e.url,logicalPath:e.logicalPath,type:e.protocol};return e.vercelConnect===void 0?t:{...t,vercelConnect:{connector:e.vercelConnect.connector}}}function toChannelEntry(e){let t={name:e.name,method:e.method,urlPath:e.urlPath,type:normalizeChannelKindForDisplay(e.adapterKind),logicalPath:e.logicalPath};return e.adapterKind===void 0?t:{...t,adapterKind:e.adapterKind}}function toSubagentEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}export{buildVercelAgentSummary,emitVercelAgentSummary};
1
+ import{mkdir,writeFile}from"node:fs/promises";import{dirname}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{VERCEL_EVE_AGENT_SUMMARY_KIND,VERCEL_EVE_AGENT_SUMMARY_VERSION,normalizeChannelKindForDisplay}from"#internal/vercel-agent-summary.js";function buildVercelAgentSummary(e){let{manifest:t}=e;return{kind:VERCEL_EVE_AGENT_SUMMARY_KIND,schemaVersion:VERCEL_EVE_AGENT_SUMMARY_VERSION,generatorVersion:e.generatorVersion??resolveInstalledPackageInfo().version,agent:t.config.dynamicModel===void 0?{name:t.config.name,description:t.config.description,modelId:t.config.model.id}:{name:t.config.name,description:t.config.description,modelRouting:{kind:`dynamic`}},instructions:t.instructions.map(toInstructionsEntry),schedules:t.schedules.map(toScheduleEntry),tools:t.tools.map(toToolEntry),skills:t.skills.map(toSkillEntry),connections:t.connections.map(toConnectionEntry),channels:t.channelRoutes.effective.map(toChannelEntry),sandbox:t.sandbox===null?null:{logicalPath:t.sandbox.logicalPath},subagents:t.subagents.map(toSubagentEntry),diagnostics:{errors:t.diagnosticsSummary.errors,warnings:t.diagnosticsSummary.warnings}}}async function emitVercelAgentSummary(e){let t=buildVercelAgentSummary({generatorVersion:e.generatorVersion,manifest:e.manifest});return await mkdir(dirname(e.outputPath),{recursive:!0}),await writeFile(e.outputPath,`${JSON.stringify(t,null,2)}\n`),e.outputPath}function toInstructionsEntry(e){return{content:e.content,logicalPath:e.logicalPath,role:e.role,sourceKind:e.sourceKind}}function toScheduleEntry(e){return{name:e.name,cron:e.cron,logicalPath:e.logicalPath}}function toToolEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function toSkillEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath,sourceKind:e.sourceKind}}function toConnectionEntry(e){let t={name:e.connectionName,description:e.description,url:e.url,logicalPath:e.logicalPath,type:e.protocol};return e.vercelConnect===void 0?t:{...t,vercelConnect:{connector:e.vercelConnect.connector}}}function toChannelEntry(e){let t={name:e.name,method:e.method,urlPath:e.urlPath,type:normalizeChannelKindForDisplay(e.adapterKind),logicalPath:e.logicalPath};return e.adapterKind===void 0?t:{...t,adapterKind:e.adapterKind}}function toSubagentEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}export{buildVercelAgentSummary,emitVercelAgentSummary};
@@ -1,3 +1,3 @@
1
- import{mkdir,writeFile}from"node:fs/promises";import{resolvePackageRoot,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{dirname,join,relative}from"node:path";import{isVercelBuildEnvironment}from"#internal/application/paths.js";import{normalizeEsmImportSpecifier,stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{createDevelopmentNitroArtifactsConfig,createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{createApplicationRouteRegistry}from"#internal/nitro/host/application-route-registry.js";import{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{deriveEveWorkflowQueuePrefix}from"#internal/workflow/queue-namespace.js";import{registerChannelVirtualHandlers}from"#internal/nitro/host/channel-routes.js";function resolveNitroWorkflowBuildDirectory(e){return join(e.options.buildDir,`workflow`)}function createRelativeImportSpecifier(e,t){let n=relative(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function addWorkflowFileHandler(e,t){let n=join(resolveNitroWorkflowBuildDirectory(e),`${t.bundleName}-handler.mjs`),r=dirname(n),i=createRelativeImportSpecifier(r,t.bundlePath),a=t.directHandlers??[],o=a.length>0&&t.workflowWorldPluginPath!==void 0?createRelativeImportSpecifier(r,t.workflowWorldPluginPath):void 0,s=a.map(e=>{let t=createRelativeImportSpecifier(r,e.bundlePath);return{importSpecifier:t,isOwnBundle:t===i,queuePrefix:e.queuePrefix}});await mkdir(r,{recursive:!0}),await writeFile(n,buildWorkflowFileHandlerSource({bundlePath:i,directHandlers:s,runtimeImportSpecifier:t.runtimeImportSpecifier,workflowWorldPluginImportSpecifier:o})),e.options.handlers.push({handler:n,route:t.route})}function buildWorkflowFileHandlerSource(e){let t=[`// Generated by eve. Do not edit by hand.`,`import { POST } from ${JSON.stringify(e.bundlePath)};`];if(e.directHandlers.length>0&&e.runtimeImportSpecifier!==void 0){let n=0,r=e.directHandlers.map(e=>{if(e.isOwnBundle)return{...e,binding:`POST`};let t=`__eveWorkflowDirectHandler${n}`;return n+=1,{...e,binding:t}});for(let e of r)e.isOwnBundle||t.push(`import { POST as ${e.binding} } from ${JSON.stringify(e.importSpecifier)};`);e.workflowWorldPluginImportSpecifier!==void 0&&t.push(`import ${JSON.stringify(e.workflowWorldPluginImportSpecifier)};`),t.push(`import { getWorld as __eveGetWorkflowWorld } from ${JSON.stringify(e.runtimeImportSpecifier)};`,``,`try {`,` const __eveWorkflowWorld = await __eveGetWorkflowWorld();`,` if (typeof __eveWorkflowWorld?.registerHandler === "function") {`);for(let e of r)t.push(` __eveWorkflowWorld.registerHandler(${JSON.stringify(e.queuePrefix)}, ${e.binding});`);t.push(` }`,`} catch (err) {`,` console.warn("[eve] Failed to register direct workflow queue handlers:", err);`,`}`)}return t.push(``,`export default async ({ req }) => {`,` return await POST(req);`,`};`,``),t.join(`
1
+ import{mkdir,writeFile}from"node:fs/promises";import{dirname,join,relative}from"node:path";import{resolvePackageRoot,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{isVercelBuildEnvironment}from"#internal/application/paths.js";import{normalizeEsmImportSpecifier,stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{createDevelopmentNitroArtifactsConfig,createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{createApplicationRouteRegistry}from"#internal/nitro/host/application-route-registry.js";import{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{deriveEveWorkflowQueuePrefix}from"#internal/workflow/queue-namespace.js";import{registerChannelVirtualHandlers}from"#internal/nitro/host/channel-routes.js";import{EVE_SCHEDULE_COLLECTION_CONSUMER_ROUTE_PATH,hasVercelScheduleCollections}from"#internal/schedules/consumer-route.js";function resolveNitroWorkflowBuildDirectory(e){return join(e.options.buildDir,`workflow`)}function createRelativeImportSpecifier(e,t){let n=relative(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function addWorkflowFileHandler(e,t){let n=join(resolveNitroWorkflowBuildDirectory(e),`${t.bundleName}-handler.mjs`),r=dirname(n),i=createRelativeImportSpecifier(r,t.bundlePath),a=t.directHandlers??[],o=a.length>0&&t.workflowWorldPluginPath!==void 0?createRelativeImportSpecifier(r,t.workflowWorldPluginPath):void 0,s=a.map(e=>{let t=createRelativeImportSpecifier(r,e.bundlePath);return{importSpecifier:t,isOwnBundle:t===i,queuePrefix:e.queuePrefix}});await mkdir(r,{recursive:!0}),await writeFile(n,buildWorkflowFileHandlerSource({bundlePath:i,directHandlers:s,runtimeImportSpecifier:t.runtimeImportSpecifier,workflowWorldPluginImportSpecifier:o})),e.options.handlers.push({handler:n,route:t.route})}function buildWorkflowFileHandlerSource(e){let t=[`// Generated by eve. Do not edit by hand.`,`import { POST } from ${JSON.stringify(e.bundlePath)};`];if(e.directHandlers.length>0&&e.runtimeImportSpecifier!==void 0){let n=0,r=e.directHandlers.map(e=>{if(e.isOwnBundle)return{...e,binding:`POST`};let t=`__eveWorkflowDirectHandler${n}`;return n+=1,{...e,binding:t}});for(let e of r)e.isOwnBundle||t.push(`import { POST as ${e.binding} } from ${JSON.stringify(e.importSpecifier)};`);e.workflowWorldPluginImportSpecifier!==void 0&&t.push(`import ${JSON.stringify(e.workflowWorldPluginImportSpecifier)};`),t.push(`import { getWorld as __eveGetWorkflowWorld } from ${JSON.stringify(e.runtimeImportSpecifier)};`,``,`try {`,` const __eveWorkflowWorld = await __eveGetWorkflowWorld();`,` if (typeof __eveWorkflowWorld?.registerHandler === "function") {`);for(let e of r)t.push(` __eveWorkflowWorld.registerHandler(${JSON.stringify(e.queuePrefix)}, ${e.binding});`);t.push(` }`,`} catch (err) {`,` console.warn("[eve] Failed to register direct workflow queue handlers:", err);`,`}`)}return t.push(``,`export default async ({ req }) => {`,` return await POST(req);`,`};`,``),t.join(`
2
2
  `)}function addHostVirtualHandler(e,t){let n=`#eve-route${t.route}`,r=stringifyEsmImportSpecifier(t.modulePath);e.options.handlers.push({handler:n,method:t.method,route:t.route}),e.options.virtual[n]=[`import { ${t.handlerExport} } from ${r};`,`export default async (event) => ${t.handlerExport}(${t.args}, event.req);`].join(`
3
- `)}async function registerWorkflowArtifactBuildHook(e,t){let n=!0;await t(),e.hooks.hook(`build:before`,async()=>{if(n){n=!1;return}await t()})}function registerApplicationRoutes(e,t,n){for(let r of n.routes)switch(r.kind){case`channel`:case`channel-preflight`:registerChannelVirtualHandlers(e,{artifactsConfig:t,routes:[r]});break;case`development-artifacts`:addHostVirtualHandler(e,{args:JSON.stringify({appRoot:t.appRoot}),handlerExport:`handleDevRuntimeArtifactsRequest`,method:r.method,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-runtime-artifacts.ts`),route:r.path});break;case`development-schedule`:addHostVirtualHandler(e,{args:JSON.stringify(t),handlerExport:`handleDevScheduleDispatchRequest`,method:r.method,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-schedule-dispatch.ts`),route:r.path})}}function findWorkflowRoute(e){return e.routes.find(e=>e.kind===`workflow`)?.path}function createWorkflowDirectHandlerEntry(e,t){return{bundlePath:t,queuePrefix:deriveEveWorkflowQueuePrefix(e.compileResult.manifest.config.name)}}async function registerWorkflowRoute(e,t,n,r,i){await addWorkflowFileHandler(e,{bundleName:`workflows`,bundlePath:n,directHandlers:r,route:i,runtimeImportSpecifier:r.length===0?void 0:normalizeEsmImportSpecifier(resolveWorkflowModulePath(`workflow/runtime`)),workflowWorldPluginPath:t.compiledArtifacts.workflowWorldPluginPath})}async function configureDevelopmentNitroRoutes(e,t){let n=resolveNitroWorkflowBuildDirectory(e),r=new WorkflowBundleBuilder({authoredWorkflowModules:t.compiledArtifacts.authoredWorkflowModules,agentName:t.compileResult.manifest.config.name,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,outDir:t.workflowBuildDir,rootDir:resolvePackageRoot(),watch:!0});await registerWorkflowArtifactBuildHook(e,async()=>{await r.build({nitroStepOutfile:join(n,`steps.mjs`),nitroWorkflowOutfile:join(n,`workflows.mjs`)})});let i=createDevelopmentNitroArtifactsConfig({appRoot:t.appRoot,configuredWorld:t.compileResult.manifest.config.experimental?.workflow?.world}),a=createApplicationRouteRegistry(t,{development:!0});registerApplicationRoutes(e,i,a);let o=join(n,`workflows.mjs`),s=[];usesParentDevelopmentWorkflowWorld(t.compileResult.manifest.config.experimental?.workflow?.world)||s.push(createWorkflowDirectHandlerEntry(t,o));let c=findWorkflowRoute(a);c!==void 0&&await registerWorkflowRoute(e,t,o,s,c),e.routing.sync()}async function configureProductionNitroRoutes(e,t){let n=new WorkflowBundleBuilder({authoredWorkflowModules:t.compiledArtifacts.authoredWorkflowModules,agentName:t.compileResult.manifest.config.name,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,outDir:t.workflowBuildDir,rootDir:resolvePackageRoot(),watch:!1});await registerWorkflowArtifactBuildHook(e,async()=>{await n.build({nitroStepOutfile:join(resolveNitroWorkflowBuildDirectory(e),`steps.mjs`)})});let r=createApplicationRouteRegistry(t);registerApplicationRoutes(e,createProductionNitroArtifactsConfig(t.appRoot),r);let i=join(t.workflowBuildDir,`workflows.mjs`),a=t.compileResult.manifest.config.experimental?.workflow?.world!==void 0,o=!isVercelBuildEnvironment()&&a?[createWorkflowDirectHandlerEntry(t,i)]:[],s=findWorkflowRoute(r);s!==void 0&&await registerWorkflowRoute(e,t,i,o,s),e.routing.sync()}export{configureDevelopmentNitroRoutes,configureProductionNitroRoutes};
3
+ `)}async function registerWorkflowArtifactBuildHook(e,t){let n=!0;await t(),e.hooks.hook(`build:before`,async()=>{if(n){n=!1;return}await t()})}function registerApplicationRoutes(e,t,n){for(let r of n.routes)switch(r.kind){case`channel`:case`channel-preflight`:registerChannelVirtualHandlers(e,{artifactsConfig:t,routes:[r]});break;case`development-artifacts`:addHostVirtualHandler(e,{args:JSON.stringify({appRoot:t.appRoot}),handlerExport:`handleDevRuntimeArtifactsRequest`,method:r.method,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-runtime-artifacts.ts`),route:r.path});break;case`development-schedule`:addHostVirtualHandler(e,{args:JSON.stringify(t),handlerExport:`handleDevScheduleDispatchRequest`,method:r.method,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-schedule-dispatch.ts`),route:r.path})}}function findWorkflowRoute(e){return e.routes.find(e=>e.kind===`workflow`)?.path}function createWorkflowDirectHandlerEntry(e,t){return{bundlePath:t,queuePrefix:deriveEveWorkflowQueuePrefix(e.compileResult.manifest.config.name)}}async function registerWorkflowRoute(e,t,n,r,i){await addWorkflowFileHandler(e,{bundleName:`workflows`,bundlePath:n,directHandlers:r,route:i,runtimeImportSpecifier:r.length===0?void 0:normalizeEsmImportSpecifier(resolveWorkflowModulePath(`workflow/runtime`)),workflowWorldPluginPath:t.compiledArtifacts.workflowWorldPluginPath})}async function configureDevelopmentNitroRoutes(e,t){let n=resolveNitroWorkflowBuildDirectory(e),r=new WorkflowBundleBuilder({authoredWorkflowModules:t.compiledArtifacts.authoredWorkflowModules,agentName:t.compileResult.manifest.config.name,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,outDir:t.workflowBuildDir,rootDir:resolvePackageRoot(),watch:!0});await registerWorkflowArtifactBuildHook(e,async()=>{await r.build({nitroStepOutfile:join(n,`steps.mjs`),nitroWorkflowOutfile:join(n,`workflows.mjs`)})});let i=createDevelopmentNitroArtifactsConfig({appRoot:t.appRoot,configuredWorld:t.compileResult.manifest.config.experimental?.workflow?.world}),a=createApplicationRouteRegistry(t,{development:!0});registerApplicationRoutes(e,i,a);let o=join(n,`workflows.mjs`),s=[];usesParentDevelopmentWorkflowWorld(t.compileResult.manifest.config.experimental?.workflow?.world)||s.push(createWorkflowDirectHandlerEntry(t,o));let c=findWorkflowRoute(a);c!==void 0&&await registerWorkflowRoute(e,t,o,s,c),e.routing.sync()}async function configureProductionNitroRoutes(e,t){let n=new WorkflowBundleBuilder({authoredWorkflowModules:t.compiledArtifacts.authoredWorkflowModules,agentName:t.compileResult.manifest.config.name,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,outDir:t.workflowBuildDir,rootDir:resolvePackageRoot(),watch:!1});await registerWorkflowArtifactBuildHook(e,async()=>{await n.build({nitroStepOutfile:join(resolveNitroWorkflowBuildDirectory(e),`steps.mjs`)})});let r=createApplicationRouteRegistry(t),i=createProductionNitroArtifactsConfig(t.appRoot);registerApplicationRoutes(e,i,r),isVercelBuildEnvironment()&&hasVercelScheduleCollections(t.compileResult.manifest)&&addHostVirtualHandler(e,{args:JSON.stringify(i),handlerExport:`handleScheduleCollectionConsumer`,method:`POST`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/schedule-collection-consumer.ts`),route:EVE_SCHEDULE_COLLECTION_CONSUMER_ROUTE_PATH});let a=join(t.workflowBuildDir,`workflows.mjs`),o=t.compileResult.manifest.config.experimental?.workflow?.world!==void 0,s=!isVercelBuildEnvironment()&&o?[createWorkflowDirectHandlerEntry(t,a)]:[],c=findWorkflowRoute(r);c!==void 0&&await registerWorkflowRoute(e,t,a,s,c),e.routing.sync()}export{configureDevelopmentNitroRoutes,configureProductionNitroRoutes};
@@ -1 +1 @@
1
- import{readFile}from"node:fs/promises";import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{dirname,isAbsolute,join,relative,resolve}from"node:path";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{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{configureDevelopmentNitroRoutes,configureProductionNitroRoutes}from"#internal/nitro/host/configure-nitro-routes.js";import{applyEveCronHandlerRoute}from"#internal/nitro/host/cron-handler-route.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`),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=[...e.compileResult.manifest.config.build?.externalDependencies??[],...e.compileResult.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])];return[...new Set([...t,...r,...[...n].map(e=>`${e}*`)])].filter(e=>e!==EVE_PACKAGE_NAME&&e!==`${EVE_PACKAGE_NAME}*`)}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),createExtensionMountPlugin(c,extensionOverridePaths(e.compileResult.manifest)),s].filter(e=>e!==null);return{nitroRolldownConfig:{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);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`},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 a=await createNitro({_cli:{command:`build`},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,serverDir:!1,traceDeps:r.tracedAppDependencies,traceOpts:{nft:{paths:r.tracedAppDependencyPaths}},vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:n===`vercel`,publicRoutePrefix:t.publicRoutePrefix,workspaceMember:t.workspaceMember})});if(await writeEveVersionedCacheMetadata(t.buildDir),configureSharedApplicationNitro(a,e),configureNitroStepPlugins(a,join(e.workflowBuildDir,`steps.mjs`)),e.scheduleRegistrations.length>0){applyEveCronHandlerRoute(a);let t=createProductionNitroArtifactsConfig(e.appRoot);registerScheduleTaskHandlers(a,{artifactsConfig:t,dispatchModulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/schedule-task.ts`),registrations:e.scheduleRegistrations})}return await configureProductionNitroRoutes(a,e),await addNitroStepNoExternals(a,join(e.workflowBuildDir,`steps.mjs`)),a}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{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}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{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`),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=[...e.compileResult.manifest.config.build?.externalDependencies??[],...e.compileResult.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])];return[...new Set([...t,...r,...[...n].map(e=>`${e}*`)])].filter(e=>e!==EVE_PACKAGE_NAME&&e!==`${EVE_PACKAGE_NAME}*`)}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),createExtensionMountPlugin(c,extensionOverridePaths(e.compileResult.manifest)),s].filter(e=>e!==null);return{nitroRolldownConfig:{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);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`},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`},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 +1 @@
1
- import{getDevelopmentEnvironmentFilePaths}from"#cli/dev/environment.js";import{existsSync}from"node:fs";import{dirname,join,normalize,resolve,sep}from"node:path";import{toErrorMessage}from"#shared/errors.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{resolveDevelopmentSourceSnapshotWatchPaths}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{watch as watch$1}from"#compiled/chokidar/index.js";const WATCHED_LOCKFILE_NAMES=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],WATCH_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WATCHER_IGNORED_DIRECTORY_NAMES=new Set([`.devtools`,`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`build`,`dist`,`node_modules`]);async function startAuthoredSourceWatcher(e){let t=e.preparedHost,n=!1,r=Promise.resolve(),i,a=!1,o=new Set,s=new Map,c=new Set,l=await resolveAuthoredWatchPaths(t),u=createWatchPathMap(l),d=watch$1(l,{awaitWriteFinish:{pollInterval:50,stabilityThreshold:160},followSymlinks:!1,ignoreInitial:!0,ignored:e=>shouldIgnoreWatcherPath(e,t.workspaceExtensions)}),f=waitForWatcherReady(d),rebuild=async(i,a=!1)=>{n||o.size>0||(r=r.then(async()=>{if(n)return;let r=[...s.values()];if(!i&&r.length===0)return;let o=[...c];s.clear(),c.clear();let l=t;!a&&r.length>0&&console.log(formatChangeDetectedLogLine(l.appRoot,r));try{let n=await e.coordinator.rebuild({changedPaths:o});t=n.host,a||(n.kind===`structural`?console.log(STRUCTURAL_RELOAD_LOG_LINE):console.log(AUTHORED_ARTIFACTS_UPDATED_LOG_LINE)),u=syncWatcherPaths({nextWatchPaths:await resolveAuthoredWatchPaths(t),previousWatchPathsByKey:u,watcher:d})}catch(e){console.error(`[eve:dev] rebuild failed: ${toErrorMessage(e)}`)}}).catch(e=>{console.error(`[eve:dev] rebuild queue error: ${toErrorMessage(e)}`)}),await r)},flush=async()=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!1)},forceRebuild=async(e=!1)=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!0,e)};return d.on(`all`,(e,t)=>{!n&&a&&e!==`addDir`&&e!==`unlinkDir`&&(s.set(`${e}:${t}`,{event:e,path:t}),c.add(t),i!==void 0&&clearTimeout(i),i=setTimeout(()=>{i=void 0,flush()},120))}),await f,a=!0,{async close(){n=!0,i!==void 0&&(clearTimeout(i),i=void 0),await d.close(),await r},flush,rebuild:forceRebuild,async suspend(e){o.has(e)||(o.add(e),i!==void 0&&(clearTimeout(i),i=void 0),await r)},async resume(e,t){o.delete(e)&&o.size===0&&await forceRebuild(t?.silent)}}}async function waitForWatcherReady(e){await new Promise((t,n)=>{e.on(`ready`,()=>{t()}),e.on(`error`,e=>{n(e)})})}async function resolveAuthoredWatchPaths(e){let t=new Set([e.compileResult.project.agentRoot,join(e.appRoot,`package.json`),join(e.appRoot,`jsconfig.json`),join(e.appRoot,`tsconfig.json`),join(e.appRoot,`tsconfig.*.json`)]),n=await resolveTsConfigWatchPaths(e.appRoot),r=e.generation.sourceWatchPaths??await resolveDevelopmentSourceSnapshotWatchPaths(e.appRoot);for(let n of e.workspaceExtensions){t.add(n.config.sourceRoot);for(let e of n.buildConfigPaths)t.add(e)}for(let n of getDevelopmentEnvironmentFilePaths(e.appRoot))t.add(n);for(let e of r)t.add(e);for(let e of n)t.add(e);for(let n of resolveLockfileSearchDirectories(e.appRoot))for(let e of WATCHED_LOCKFILE_NAMES)t.add(join(n,e));return[...t].sort((e,t)=>e.localeCompare(t))}function createWatchPathMap(e){let t=new Map;for(let n of e)t.set(toWatchPathKey(n),n);return t}function syncWatcherPaths(e){let t=createWatchPathMap(e.nextWatchPaths),n=[],r=[];for(let[r,i]of t)e.previousWatchPathsByKey.has(r)||n.push(i);for(let[n,i]of e.previousWatchPathsByKey)t.has(n)||r.push(i);return n.length>0&&e.watcher.add(n),r.length>0&&e.watcher.unwatch(r),t}function toWatchPathKey(e){return normalize(resolve(e))}function resolveLockfileSearchDirectories(e){let t=resolve(e),n=[t],r=t;for(;;){if(hasWatchRootMarker(r))return n;let e=dirname(r);if(e===r)return[t];r=e,n.push(r)}}function hasWatchRootMarker(e){return WATCH_ROOT_MARKER_NAMES.some(t=>existsSync(join(e,t)))}async function resolveTsConfigWatchPaths(e){return await resolveTsConfigDependencyPaths(e)}function shouldIgnoreWatcherPath(e,t){return normalize(e).split(sep).filter(Boolean).some(e=>WATCHER_IGNORED_DIRECTORY_NAMES.has(e))||t.some(t=>isPathInsideOrEqual(e,t.config.outDir))}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{startAuthoredSourceWatcher};
1
+ import{existsSync}from"node:fs";import{dirname,join,normalize,resolve,sep}from"node:path";import{getDevelopmentEnvironmentFilePaths}from"#cli/dev/environment.js";import{toErrorMessage}from"#shared/errors.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{resolveDevelopmentSourceSnapshotWatchPaths}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{watch as watch$1}from"#compiled/chokidar/index.js";const WATCHED_LOCKFILE_NAMES=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],WATCH_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WATCHER_IGNORED_DIRECTORY_NAMES=new Set([`.devtools`,`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`build`,`dist`,`node_modules`]);async function startAuthoredSourceWatcher(e){let t=e.preparedHost,n=!1,r=Promise.resolve(),i,a=!1,o=new Set,s=new Map,c=new Set,l=await resolveAuthoredWatchPaths(t),u=createWatchPathMap(l),d=watch$1(l,{awaitWriteFinish:{pollInterval:50,stabilityThreshold:160},followSymlinks:!1,ignoreInitial:!0,ignored:e=>shouldIgnoreWatcherPath(e,t.workspaceExtensions)}),f=waitForWatcherReady(d),rebuild=async(i,a=!1)=>{n||o.size>0||(r=r.then(async()=>{if(n)return;let r=[...s.values()];if(!i&&r.length===0)return;let o=[...c];s.clear(),c.clear();let l=t;!a&&r.length>0&&console.log(formatChangeDetectedLogLine(l.appRoot,r));try{let n=await e.coordinator.rebuild({changedPaths:o});t=n.host,a||(n.kind===`structural`?console.log(STRUCTURAL_RELOAD_LOG_LINE):console.log(AUTHORED_ARTIFACTS_UPDATED_LOG_LINE)),u=syncWatcherPaths({nextWatchPaths:await resolveAuthoredWatchPaths(t),previousWatchPathsByKey:u,watcher:d})}catch(e){console.error(`[eve:dev] rebuild failed: ${toErrorMessage(e)}`)}}).catch(e=>{console.error(`[eve:dev] rebuild queue error: ${toErrorMessage(e)}`)}),await r)},flush=async()=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!1)},forceRebuild=async(e=!1)=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!0,e)};return d.on(`all`,(e,t)=>{!n&&a&&e!==`addDir`&&e!==`unlinkDir`&&(s.set(`${e}:${t}`,{event:e,path:t}),c.add(t),i!==void 0&&clearTimeout(i),i=setTimeout(()=>{i=void 0,flush()},120))}),await f,a=!0,{async close(){n=!0,i!==void 0&&(clearTimeout(i),i=void 0),await d.close(),await r},flush,rebuild:forceRebuild,async suspend(e){o.has(e)||(o.add(e),i!==void 0&&(clearTimeout(i),i=void 0),await r)},async resume(e,t){o.delete(e)&&o.size===0&&await forceRebuild(t?.silent)}}}async function waitForWatcherReady(e){await new Promise((t,n)=>{e.on(`ready`,()=>{t()}),e.on(`error`,e=>{n(e)})})}async function resolveAuthoredWatchPaths(e){let t=new Set([e.compileResult.project.agentRoot,join(e.appRoot,`package.json`),join(e.appRoot,`jsconfig.json`),join(e.appRoot,`tsconfig.json`),join(e.appRoot,`tsconfig.*.json`)]),n=await resolveTsConfigWatchPaths(e.appRoot),r=e.generation.sourceWatchPaths??await resolveDevelopmentSourceSnapshotWatchPaths(e.appRoot);for(let n of e.workspaceExtensions){t.add(n.config.sourceRoot);for(let e of n.buildConfigPaths)t.add(e)}for(let n of getDevelopmentEnvironmentFilePaths(e.appRoot))t.add(n);for(let e of r)t.add(e);for(let e of n)t.add(e);for(let n of resolveLockfileSearchDirectories(e.appRoot))for(let e of WATCHED_LOCKFILE_NAMES)t.add(join(n,e));return[...t].sort((e,t)=>e.localeCompare(t))}function createWatchPathMap(e){let t=new Map;for(let n of e)t.set(toWatchPathKey(n),n);return t}function syncWatcherPaths(e){let t=createWatchPathMap(e.nextWatchPaths),n=[],r=[];for(let[r,i]of t)e.previousWatchPathsByKey.has(r)||n.push(i);for(let[n,i]of e.previousWatchPathsByKey)t.has(n)||r.push(i);return n.length>0&&e.watcher.add(n),r.length>0&&e.watcher.unwatch(r),t}function toWatchPathKey(e){return normalize(resolve(e))}function resolveLockfileSearchDirectories(e){let t=resolve(e),n=[t],r=t;for(;;){if(hasWatchRootMarker(r))return n;let e=dirname(r);if(e===r)return[t];r=e,n.push(r)}}function hasWatchRootMarker(e){return WATCH_ROOT_MARKER_NAMES.some(t=>existsSync(join(e,t)))}async function resolveTsConfigWatchPaths(e){return await resolveTsConfigDependencyPaths(e)}function shouldIgnoreWatcherPath(e,t){return normalize(e).split(sep).filter(Boolean).some(e=>WATCHER_IGNORED_DIRECTORY_NAMES.has(e))||t.some(t=>isPathInsideOrEqual(e,t.config.outDir))}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{startAuthoredSourceWatcher};
@@ -1 +1 @@
1
- import{resolvePackageCompiledFilePath}from"#internal/application/package.js";import{existsSync}from"node:fs";import{Worker}from"node:worker_threads";import{BaseEnvRunner}from"#compiled/env-runner/index.js";var NodeDevelopmentRunner=class extends BaseEnvRunner{#e;#t=new Set;#n;#r;#i=!1;constructor(e){let t=resolvePackageCompiledFilePath(`src/compiled/env-runner/node-worker.js`);super({data:{entry:e.entry,...e.workerData},hooks:{onClose:(e,t)=>{let n=[...this.#t];this.#t.clear();for(let e of n)e(t)}},name:e.name,workerEntry:t}),this._initWithVirtualData(()=>this.#a())}onceClosed(e){if(this.closed){e(this.#e);return}this.#t.add(e)}sendMessage(e){if(this.#n===void 0)throw Error(`Development worker is not initialized.`);this.#n.postMessage(e)}async waitForReady(e){try{await super.waitForReady(e)}catch(e){throw this.#e===void 0?e:Error(`Development worker failed before readiness: ${this.#e instanceof Error?this.#e.message:String(this.#e)}`,{cause:this.#e})}}_hasRuntime(){return this.#n!==void 0}_runtimeType(){return`worker`}async _closeRuntime(){let e=this.#n;if(e===void 0)return;let t=this.#r;this.#n=void 0,this.#r=void 0;try{this.#i||e.postMessage({event:`shutdown`}),!this.#i&&t!==void 0&&!await waitForWorkerExit(t)&&await e.terminate()}finally{e.removeAllListeners()}}_handleMessage(e){isWorkerInitializationError(e)&&(this.#e=Error(e.error)),super._handleMessage(e)}#a(){if(!existsSync(this._workerEntry)){this.close(`Development worker entry not found at "${this._workerEntry}".`);return}let e=new Worker(this._workerEntry,{env:process.env,workerData:{name:this._name,...this._data}});this.#n=e,this.#i=!1;let t;this.#r=new Promise(e=>{t=e}),e.once(`error`,e=>{this.#e=e,this.close(e)}),e.once(`exit`,e=>{if(this.#i=!0,t(),!this.closed){let t=Error(`Development worker exited with code ${String(e)}.`);this.#e??=t,this.close(t)}}),e.on(`message`,e=>this._handleMessage(e))}};const createNodeDevelopmentRunner=e=>new NodeDevelopmentRunner(e);async function waitForWorkerExit(e){let t;try{return await Promise.race([e.then(()=>!0),new Promise(e=>{t=setTimeout(()=>e(!1),15e3),t.unref()})])}finally{clearTimeout(t)}}function isWorkerInitializationError(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.event===`init-error`&&typeof t.error==`string`}export{createNodeDevelopmentRunner};
1
+ import{existsSync}from"node:fs";import{resolvePackageCompiledFilePath}from"#internal/application/package.js";import{Worker}from"node:worker_threads";import{BaseEnvRunner}from"#compiled/env-runner/index.js";var NodeDevelopmentRunner=class extends BaseEnvRunner{#e;#t=new Set;#n;#r;#i=!1;constructor(e){let t=resolvePackageCompiledFilePath(`src/compiled/env-runner/node-worker.js`);super({data:{entry:e.entry,...e.workerData},hooks:{onClose:(e,t)=>{let n=[...this.#t];this.#t.clear();for(let e of n)e(t)}},name:e.name,workerEntry:t}),this._initWithVirtualData(()=>this.#a())}onceClosed(e){if(this.closed){e(this.#e);return}this.#t.add(e)}sendMessage(e){if(this.#n===void 0)throw Error(`Development worker is not initialized.`);this.#n.postMessage(e)}async waitForReady(e){try{await super.waitForReady(e)}catch(e){throw this.#e===void 0?e:Error(`Development worker failed before readiness: ${this.#e instanceof Error?this.#e.message:String(this.#e)}`,{cause:this.#e})}}_hasRuntime(){return this.#n!==void 0}_runtimeType(){return`worker`}async _closeRuntime(){let e=this.#n;if(e===void 0)return;let t=this.#r;this.#n=void 0,this.#r=void 0;try{this.#i||e.postMessage({event:`shutdown`}),!this.#i&&t!==void 0&&!await waitForWorkerExit(t)&&await e.terminate()}finally{e.removeAllListeners()}}_handleMessage(e){isWorkerInitializationError(e)&&(this.#e=Error(e.error)),super._handleMessage(e)}#a(){if(!existsSync(this._workerEntry)){this.close(`Development worker entry not found at "${this._workerEntry}".`);return}let e=new Worker(this._workerEntry,{env:process.env,workerData:{name:this._name,...this._data}});this.#n=e,this.#i=!1;let t;this.#r=new Promise(e=>{t=e}),e.once(`error`,e=>{this.#e=e,this.close(e)}),e.once(`exit`,e=>{if(this.#i=!0,t(),!this.closed){let t=Error(`Development worker exited with code ${String(e)}.`);this.#e??=t,this.close(t)}}),e.on(`message`,e=>this._handleMessage(e))}};const createNodeDevelopmentRunner=e=>new NodeDevelopmentRunner(e);async function waitForWorkerExit(e){let t;try{return await Promise.race([e.then(()=>!0),new Promise(e=>{t=setTimeout(()=>e(!1),15e3),t.unref()})])}finally{clearTimeout(t)}}function isWorkerInitializationError(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.event===`init-error`&&typeof t.error==`string`}export{createNodeDevelopmentRunner};
@@ -1 +1 @@
1
- import{join}from"node:path";import{extensionMountId}from"#compiler/source-graph.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";import{createCompiledBindingNamespaceLoader}from"#compiler/load-binding-namespace.js";import{compileInstructionsEntry}from"#compiler/normalize-instructions.js";import{compileSkillSource}from"#compiler/normalize-skill.js";import{compileToolEntry}from"#compiler/normalize-tool.js";import{EXTENSION_CAPABILITY_VERSIONS}from"#compiler/extension-compatibility.js";import{extensionUsesState}from"#internal/nitro/host/extension-state-usage.js";async function deriveExtensionCapabilityRequirements(e){let t=new Set([`extension`]),n=collectSubagentManifests(e.manifest),[r,i,a,o,s]=await Promise.all([Promise.all(n.flatMap(t=>t.tools.map(n=>compileToolEntry(t.agentRoot,n,createLoadOptions(e,n,t.agentRoot))))),Promise.all(n.flatMap(t=>t.skills.map(n=>compileSkillSource(t.agentRoot,n,createLoadOptions(e,n,t.agentRoot))))),Promise.all(n.flatMap(t=>t.instructions.map(n=>compileInstructionsEntry(t.agentRoot,n,createLoadOptions(e,n,t.agentRoot))))),loadAuthoredModuleNamespace(join(e.sourceRoot,e.declarationModule.logicalPath),{externalDependencies:e.runtimeDependencies}),extensionUsesState(e.runtimeRoot)]);r.length>0&&t.add(`tool`),r.some(e=>e.kind===`dynamic-tool`)&&t.add(`dynamicTool`),n.some(e=>e.channels.length>0)&&t.add(`channel`),n.some(e=>e.connections.length>0)&&t.add(`connection`),n.some(e=>e.hooks.length>0)&&t.add(`hook`),n.some(e=>e.schedules.length>0)&&t.add(`schedule`),n.some(e=>e.subagents.length>0)&&t.add(`subagent`),i.length>0&&t.add(`skill`),i.some(e=>e.kind===`dynamic-skill`)&&t.add(`dynamicSkill`),a.length>0&&t.add(`instructions`),a.some(e=>e.kind===`dynamic-instructions`)&&t.add(`dynamicInstructions`);let c=o[e.declarationModule.exportName??`default`];return(typeof c==`function`||typeof c==`object`&&c)&&`schema`in c&&c.schema!==void 0&&t.add(`config`),s&&t.add(`state`),e.runtimeImports.includes(`eve/ai`)&&t.add(`tool`),e.runtimeImports.includes(`eve/models`)&&t.add(`dynamicTool`),Object.fromEntries(Object.keys(EXTENSION_CAPABILITY_VERSIONS).filter(e=>t.has(e)).map(e=>[e,EXTENSION_CAPABILITY_VERSIONS[e]]))}function createLoadOptions(e,t,n){let r={kind:`extension`,mountId:extensionMountId(``,e.shortName),namespace:e.shortName,packageName:e.packageName},i={backing:{externalDependencies:e.runtimeDependencies,extensionScope:{namespace:e.shortName,sourceRoot:e.sourceRoot},kind:`filesystem`,sourcePath:join(n,t.logicalPath)},logicalPath:t.logicalPath,owner:r};return{binding:i,loadNamespace:createCompiledBindingNamespaceLoader({bindings:{[t.sourceId]:i},registries:[]}),owner:r}}function collectSubagentManifests(e){return[e,...e.subagents.flatMap(e=>collectSubagentManifests(e.manifest))]}export{deriveExtensionCapabilityRequirements};
1
+ import{join}from"node:path";import{extensionMountId}from"#compiler/source-graph.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";import{createCompiledBindingNamespaceLoader}from"#compiler/load-binding-namespace.js";import{compileInstructionsEntry}from"#compiler/normalize-instructions.js";import{compileSkillSource}from"#compiler/normalize-skill.js";import{compileToolEntry}from"#compiler/normalize-tool.js";import{EXTENSION_CAPABILITY_VERSIONS}from"#compiler/extension-compatibility.js";import{extensionUsesState}from"#internal/nitro/host/extension-state-usage.js";async function deriveExtensionCapabilityRequirements(e){let t=new Set([`extension`]),n=collectSubagentManifests(e.manifest),[r,i,a,o,s]=await Promise.all([Promise.all(n.flatMap(t=>t.tools.map(n=>compileToolEntry(t.agentRoot,n,createLoadOptions(e,n,t.agentRoot))))),Promise.all(n.flatMap(t=>t.skills.map(n=>compileSkillSource(t.agentRoot,n,createLoadOptions(e,n,t.agentRoot))))),Promise.all(n.flatMap(t=>t.instructions.map(n=>compileInstructionsEntry(t.agentRoot,n,createLoadOptions(e,n,t.agentRoot))))),loadAuthoredModuleNamespace(join(e.sourceRoot,e.declarationModule.logicalPath),{externalDependencies:e.runtimeDependencies}),extensionUsesState(e.runtimeRoot)]);r.length>0&&t.add(`tool`),r.some(e=>e.kind===`dynamic-tool`)&&t.add(`dynamicTool`),n.some(e=>e.channels.length>0)&&t.add(`channel`),n.some(e=>e.connections.length>0)&&t.add(`connection`),n.some(e=>e.hooks.length>0)&&t.add(`hook`),n.some(e=>e.schedules.length>0)&&t.add(`schedule`),n.some(e=>e.subagents.length>0)&&t.add(`subagent`),i.length>0&&t.add(`skill`),i.some(e=>e.kind===`dynamic-skill`)&&t.add(`dynamicSkill`),a.length>0&&t.add(`instructions`),a.some(e=>e.kind===`dynamic-instructions`)&&t.add(`dynamicInstructions`);let c=o[e.declarationModule.exportName??`default`];return(typeof c==`function`||typeof c==`object`&&c)&&`schema`in c&&c.schema!==void 0&&t.add(`config`),s&&t.add(`state`),e.runtimeImports.includes(`eve/ai`)&&t.add(`tool`),e.runtimeImports.includes(`eve/models`)&&t.add(`dynamicTool`),Object.fromEntries(Object.keys(EXTENSION_CAPABILITY_VERSIONS).filter(e=>t.has(e)).map(e=>[e,EXTENSION_CAPABILITY_VERSIONS[e]]))}function createLoadOptions(e,t,n){let r={kind:`extension`,mountId:extensionMountId(``,e.shortName),namespace:e.shortName,packageName:e.packageName},i={backing:{externalDependencies:e.runtimeDependencies,extensionScope:{namespace:e.shortName,sourceRoot:e.sourceRoot},kind:`filesystem`,sourcePath:join(n,t.logicalPath)},logicalPath:t.logicalPath,owner:r};return{binding:i,loadNamespace:createCompiledBindingNamespaceLoader({appRoot:void 0,bindings:{[t.sourceId]:i},registries:[]}),owner:r}}function collectSubagentManifests(e){return[e,...e.subagents.flatMap(e=>collectSubagentManifests(e.manifest))]}export{deriveExtensionCapabilityRequirements};
@@ -1 +1 @@
1
- import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{basename}from"node:path";import{DEVELOPMENT_WORKER_APP_ROOT_ENV}from"#internal/workflow/development-world-protocol.js";import{installLocalInstrumentationRuntime}from"#tracing/local-instrumentation-runtime.js";const appRoot=process.env[DEVELOPMENT_WORKER_APP_ROOT_ENV];if(appRoot===void 0)throw Error(`${DEVELOPMENT_WORKER_APP_ROOT_ENV} is required for local tracing.`);const runtime=installLocalInstrumentationRuntime({appRoot,frameworkVersion:resolveInstalledPackageInfo().version,serviceName:basename(appRoot)});function installLocalTracingRuntimePlugin(e){e?.hooks?.hook(`close`,()=>runtime.shutdown())}export{installLocalTracingRuntimePlugin as default};
1
+ import{basename}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{DEVELOPMENT_WORKER_APP_ROOT_ENV}from"#internal/workflow/development-world-protocol.js";import{installLocalInstrumentationRuntime}from"#tracing/local-instrumentation-runtime.js";const appRoot=process.env[DEVELOPMENT_WORKER_APP_ROOT_ENV];if(appRoot===void 0)throw Error(`${DEVELOPMENT_WORKER_APP_ROOT_ENV} is required for local tracing.`);const runtime=installLocalInstrumentationRuntime({appRoot,frameworkVersion:resolveInstalledPackageInfo().version,serviceName:basename(appRoot)});function installLocalTracingRuntimePlugin(e){e?.hooks?.hook(`close`,()=>runtime.shutdown())}export{installLocalTracingRuntimePlugin as default};
@@ -0,0 +1,29 @@
1
+ /** One Nitro `serverAssets` entry. */
2
+ export interface SkillServerAssetDirectory {
3
+ readonly baseName: string;
4
+ readonly dir: string;
5
+ }
6
+ /**
7
+ * Stages the root agent's materialized `skills/` tree as Nitro server assets
8
+ * for a production build, and returns the `serverAssets` entries to register.
9
+ *
10
+ * The listing and bytes come from {@link createDiskSkillFileSource}, the same
11
+ * source dev reads, so both modes agree on which files exist.
12
+ *
13
+ * Nitro picks how to inline a server asset from its file name: text MIME
14
+ * types become UTF-8 strings, which loses bytes that are not valid UTF-8,
15
+ * unstorage decodes any string starting with `base64:`, and an empty string
16
+ * is dropped by Nitro's `r.default || r`. So each shipped file is written as
17
+ * `<stagingDirectory>/files/<sha256>.bin`, which Nitro always inlines as a
18
+ * `Uint8Array`. Identical files share one asset. Real paths, sizes, and
19
+ * digests go into an eve-owned index registered as its own server asset.
20
+ * Files over {@link MAX_SKILL_FILE_BYTES} are indexed by size only, and
21
+ * directories are indexed so empty ones survive the build.
22
+ */
23
+ export declare function prepareSkillServerAssets(input: {
24
+ /** Build-owned directory the staged assets and the index are written to. */
25
+ readonly stagingDirectory: string;
26
+ readonly skills: readonly string[];
27
+ /** The materialized `skills/` directory of the root agent's workspace resources. */
28
+ readonly skillsRoot: string;
29
+ }): Promise<SkillServerAssetDirectory[]>;
@@ -0,0 +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,3 +1,3 @@
1
- import{createConnection,createServer}from"node:net";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{existsSync}from"node:fs";import{join,resolve}from"node:path";import{spawn}from"node:child_process";import{setTimeout}from"node:timers/promises";const HEALTH_TIMEOUT_MS=6e4,LOCAL_SERVER_URL_PATTERN=/https?:\/\/(?:\[[^\]\s]+\]|[^\s/:[\]]+)(?::\d+)?/,WILDCARD_LISTEN_HOSTNAMES=new Set([`[::]`,`::`,`0.0.0.0`]);function resolveOutputServerEntry(e){return join(resolve(e),`.output`,`server`,`index.mjs`)}function readEnvironmentPort(){let e=process.env.PORT;if(e===void 0||e.trim()===``)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>65535)throw Error(`Invalid PORT environment variable "${e}". Expected an integer between 0 and 65535.`);return t}function normalizeServerClientUrl(e){let t=new URL(e);return WILDCARD_LISTEN_HOSTNAMES.has(t.hostname)&&(t.hostname=`127.0.0.1`),t.toString()}function formatClientHost(e){return WILDCARD_LISTEN_HOSTNAMES.has(e)?`127.0.0.1`:e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function createKnownPortUrl(e){return`http://${formatClientHost(e.host)}:${String(e.port)}/`}async function resolveListenPort(e){if(e.port!==0)return e.port;let t=createServer();return await new Promise((n,r)=>{t.once(`error`,r),t.listen(0,e.host,()=>{let e=t.address();t.close(t=>{if(t){r(t);return}if(e===null||typeof e==`string`){r(Error(`Failed to resolve an available port for eve start.`));return}n(e.port)})})})}function parseServerUrlFromOutput(e){let t=LOCAL_SERVER_URL_PATTERN.exec(e);if(t!==null)return normalizeServerClientUrl(t[0])}async function isListening(e){let t=new URL(e),n=Number(t.port||(t.protocol===`https:`?443:80));return await new Promise(e=>{let r=createConnection({host:t.hostname,port:n}),finish=t=>{r.destroy(),e(t)};r.setTimeout(2e3,()=>finish(!1)),r.once(`connect`,()=>finish(!0)),r.once(`error`,()=>finish(!1))})}async function waitForReady(e){let t=Date.now()+HEALTH_TIMEOUT_MS;for(;Date.now()<t;){let t=e.getStartError();if(t!==void 0)throw t;let n=parseServerUrlFromOutput(e.getOutput()),r=n??e.knownUrl;if(r!==void 0&&(n!==void 0||await isListening(r)))return new URL(r).toString();if(e.child.exitCode!==null||e.child.signalCode!==null)throw Error(`Built server process exited (code=${String(e.child.exitCode)}, signal=${String(e.child.signalCode)}) before printing its URL.`);await setTimeout(250)}throw Error([`Built server did not become ready within ${HEALTH_TIMEOUT_MS/1e3}s.`,`Output:`,e.getOutput()].join(`
1
+ import{createConnection,createServer}from"node:net";import{existsSync}from"node:fs";import{join,resolve}from"node:path";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{spawn}from"node:child_process";import{setTimeout}from"node:timers/promises";const HEALTH_TIMEOUT_MS=6e4,LOCAL_SERVER_URL_PATTERN=/https?:\/\/(?:\[[^\]\s]+\]|[^\s/:[\]]+)(?::\d+)?/,WILDCARD_LISTEN_HOSTNAMES=new Set([`[::]`,`::`,`0.0.0.0`]);function resolveOutputServerEntry(e){return join(resolve(e),`.output`,`server`,`index.mjs`)}function readEnvironmentPort(){let e=process.env.PORT;if(e===void 0||e.trim()===``)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>65535)throw Error(`Invalid PORT environment variable "${e}". Expected an integer between 0 and 65535.`);return t}function normalizeServerClientUrl(e){let t=new URL(e);return WILDCARD_LISTEN_HOSTNAMES.has(t.hostname)&&(t.hostname=`127.0.0.1`),t.toString()}function formatClientHost(e){return WILDCARD_LISTEN_HOSTNAMES.has(e)?`127.0.0.1`:e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function createKnownPortUrl(e){return`http://${formatClientHost(e.host)}:${String(e.port)}/`}async function resolveListenPort(e){if(e.port!==0)return e.port;let t=createServer();return await new Promise((n,r)=>{t.once(`error`,r),t.listen(0,e.host,()=>{let e=t.address();t.close(t=>{if(t){r(t);return}if(e===null||typeof e==`string`){r(Error(`Failed to resolve an available port for eve start.`));return}n(e.port)})})})}function parseServerUrlFromOutput(e){let t=LOCAL_SERVER_URL_PATTERN.exec(e);if(t!==null)return normalizeServerClientUrl(t[0])}async function isListening(e){let t=new URL(e),n=Number(t.port||(t.protocol===`https:`?443:80));return await new Promise(e=>{let r=createConnection({host:t.hostname,port:n}),finish=t=>{r.destroy(),e(t)};r.setTimeout(2e3,()=>finish(!1)),r.once(`connect`,()=>finish(!0)),r.once(`error`,()=>finish(!1))})}async function waitForReady(e){let t=Date.now()+HEALTH_TIMEOUT_MS;for(;Date.now()<t;){let t=e.getStartError();if(t!==void 0)throw t;let n=parseServerUrlFromOutput(e.getOutput()),r=n??e.knownUrl;if(r!==void 0&&(n!==void 0||await isListening(r)))return new URL(r).toString();if(e.child.exitCode!==null||e.child.signalCode!==null)throw Error(`Built server process exited (code=${String(e.child.exitCode)}, signal=${String(e.child.signalCode)}) before printing its URL.`);await setTimeout(250)}throw Error([`Built server did not become ready within ${HEALTH_TIMEOUT_MS/1e3}s.`,`Output:`,e.getOutput()].join(`
2
2
  `))}async function terminate(e){e.exitCode!==null||e.killed||(e.kill(`SIGTERM`),await Promise.race([once(e,`exit`),setTimeout(2e4).then(()=>`timeout`)])===`timeout`&&e.exitCode===null&&(e.kill(`SIGKILL`),await once(e,`exit`)),e.stdout?.destroy(),e.stderr?.destroy())}function once(e,t){return new Promise(n=>{e.once(t,()=>n())})}async function startProductionServer(e,t={}){let n=resolve(e),r=resolveOutputServerEntry(n);if(!existsSync(r))throw Error(`Missing eve build output at ${r}. Run "eve build" before "eve start".`);await loadDevelopmentEnvironmentFiles(n);let i=t.host??`0.0.0.0`,a=await resolveListenPort({host:i,port:t.port??readEnvironmentPort()??3e3}),o=createKnownPortUrl({host:i,port:a}),s=``,c=!1,l,u=spawn(process.execPath,[r],{cwd:n,env:{...process.env,HOST:i,NITRO_HOST:i,NITRO_PORT:String(a),PORT:String(a)},stdio:[`ignore`,`pipe`,`pipe`]});u.stdout?.on(`data`,e=>{s+=e.toString(`utf8`),process.stdout.write(e)}),u.stderr?.on(`data`,e=>{s+=e.toString(`utf8`),process.stderr.write(e)});let d=new Promise((e,t)=>{u.once(`error`,e=>{l=e,t(e)}),u.once(`exit`,(n,r)=>{if(c||n===0){e();return}t(Error([`Built server process exited unexpectedly (code=${String(n)}, signal=${String(r)}).`,s].join(`
3
3
  `)))})});d.catch(()=>void 0);try{return{async close(){c=!0,await terminate(u)},url:await waitForReady({child:u,getStartError:()=>l,getOutput:()=>s,knownUrl:o}),async wait(){await d}}}catch(e){throw c=!0,await terminate(u),e instanceof Error&&e.name===`AbortError`?Error(`Timed out waiting for built eve server to respond.`,{cause:e}):e}}export{startProductionServer};