eve 0.62.0 → 0.64.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 (593) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/src/ai/evaluate.js +1 -1
  3. package/dist/src/channel/channel-address.d.ts +4 -1
  4. package/dist/src/channel/channel-address.js +1 -1
  5. package/dist/src/channel/channel-operations.d.ts +4 -1
  6. package/dist/src/channel/cross-channel-receive.d.ts +4 -1
  7. package/dist/src/channel/cross-channel-receive.js +1 -1
  8. package/dist/src/channel/session.d.ts +3 -1
  9. package/dist/src/channel/session.js +1 -1
  10. package/dist/src/channel/types.d.ts +7 -0
  11. package/dist/src/chunks/{use-eve-agent-C5-yqRuq.js → use-eve-agent-BdKlQF32.js} +8 -8
  12. package/dist/src/chunks/{use-eve-agent-CVWk5KKy.js → use-eve-agent-IIuxkn6y.js} +8 -8
  13. package/dist/src/cli/commands/build.js +1 -1
  14. package/dist/src/cli/commands/init-agent-workspace.d.ts +2 -0
  15. package/dist/src/cli/commands/init.js +1 -1
  16. package/dist/src/cli/dev/tui/line-editor.d.ts +11 -1
  17. package/dist/src/cli/dev/tui/line-editor.js +3 -3
  18. package/dist/src/cli/dev/tui/model-picker.d.ts +50 -0
  19. package/dist/src/cli/dev/tui/model-picker.js +1 -0
  20. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  21. package/dist/src/cli/dev/tui/runner.js +2 -2
  22. package/dist/src/cli/dev/tui/setup-commands.d.ts +1 -1
  23. package/dist/src/cli/dev/tui/setup-commands.js +1 -1
  24. package/dist/src/cli/dev/tui/setup-flow.d.ts +2 -2
  25. package/dist/src/cli/dev/tui/setup-panel.d.ts +1 -26
  26. package/dist/src/cli/dev/tui/setup-panel.js +3 -3
  27. package/dist/src/cli/dev/tui/setup-selection-input.js +1 -1
  28. package/dist/src/cli/dev/tui/stream-format.d.ts +6 -7
  29. package/dist/src/cli/dev/tui/stream-format.js +2 -2
  30. package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
  31. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  32. package/dist/src/cli/dev/tui/test/fake-setup-flow-renderer.js +1 -1
  33. package/dist/src/cli/dev/tui/test/mock-terminal.js +1 -1
  34. package/dist/src/cli/dev/tui/theme.d.ts +0 -8
  35. package/dist/src/cli/dev/tui/theme.js +1 -1
  36. package/dist/src/cli/run.js +1 -1
  37. package/dist/src/client/agent-info-schema.d.ts +8 -14
  38. package/dist/src/client/agent-info-schema.js +1 -1
  39. package/dist/src/client/eve-agent-store.js +1 -1
  40. package/dist/src/client/session.js +1 -1
  41. package/dist/src/client/types.d.ts +4 -2
  42. package/dist/src/compiled/.vendor-stamp.json +11 -11
  43. package/dist/src/compiled/@chat-adapter/slack/_chat-adapter-shared.d.ts +1 -0
  44. package/dist/src/compiled/@chat-adapter/slack/api.d.ts +3 -2
  45. package/dist/src/compiled/@chat-adapter/slack/api.js +1 -1
  46. package/dist/src/compiled/@chat-adapter/slack/blocks.js +1 -1
  47. package/dist/src/compiled/@chat-adapter/slack/format.js +1 -1
  48. package/dist/src/compiled/@chat-adapter/slack/index.d.ts +410 -63
  49. package/dist/src/compiled/@chat-adapter/slack/index.js +47 -25
  50. package/dist/src/compiled/@chat-adapter/twilio/api.d.ts +5 -1
  51. package/dist/src/compiled/@chat-adapter/twilio/api.js +1 -1
  52. package/dist/src/compiled/@chat-adapter/twilio/index.d.ts +37 -3
  53. package/dist/src/compiled/@chat-adapter/twilio/index.js +5 -1
  54. package/dist/src/compiled/@chat-adapter/twilio/webhook.d.ts +2 -2
  55. package/dist/src/compiled/@chat-adapter/twilio/webhook.js +1 -1
  56. package/dist/src/compiled/@linqapp/chat-sdk-adapter/index.js +6 -6
  57. package/dist/src/compiled/@photon-ai/chat-adapter-imessage/index.js +50 -50
  58. package/dist/src/compiled/@vercel/sandbox/index.js +4 -4
  59. package/dist/src/compiled/@workflow/core/attribute-changes.d.ts +2 -1
  60. package/dist/src/compiled/@workflow/core/events-consumer.d.ts +6 -3
  61. package/dist/src/compiled/@workflow/core/index.js +2 -2
  62. package/dist/src/compiled/@workflow/core/private.d.ts +37 -5
  63. package/dist/src/compiled/@workflow/core/private.js +1 -1
  64. package/dist/src/compiled/@workflow/core/runtime/deployment-guard.d.ts +2 -1
  65. package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
  66. package/dist/src/compiled/@workflow/core/runtime/invocations.d.ts +35 -0
  67. package/dist/src/compiled/@workflow/core/runtime/lifecycle-hooks.d.ts +90 -0
  68. package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +2 -1
  69. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +8 -6
  70. package/dist/src/compiled/@workflow/core/runtime/step-single-flight.d.ts +1 -1
  71. package/dist/src/compiled/@workflow/core/runtime.js +4 -4
  72. package/dist/src/compiled/@workflow/core/serialization.d.ts +5 -1
  73. package/dist/src/compiled/@workflow/core/serialization.js +1 -1
  74. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  75. package/dist/src/compiled/@workflow/core/workflow/set-attributes.d.ts +4 -0
  76. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  77. package/dist/src/compiled/@workflow/world/analytics.d.ts +1 -1
  78. package/dist/src/compiled/@workflow/world/attributes-validation.d.ts +5 -0
  79. package/dist/src/compiled/@workflow/world/events.d.ts +2 -2
  80. package/dist/src/compiled/@workflow/world/index.d.ts +2 -1
  81. package/dist/src/compiled/@workflow/world/interfaces.d.ts +12 -1
  82. package/dist/src/compiled/@workflow/world/invocation.d.ts +19 -0
  83. package/dist/src/compiled/@workflow/world/queue.d.ts +24 -3
  84. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  85. package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
  86. package/dist/src/compiled/_chunks/node/chunk-6QHBXN7B-gl4n6nmi.js +12 -0
  87. package/dist/src/compiled/_chunks/node/chunk-7WDLOIRP-B_IWkVtZ.js +1 -0
  88. package/dist/src/compiled/_chunks/node/chunk-KBOOTKHF-DJqFk2r1.js +1 -0
  89. package/dist/src/compiled/_chunks/node/chunk-TREVQR3E-CLsTAn-O.js +1 -0
  90. package/dist/src/compiled/_chunks/node/dist-DYDVZ-FS.js +98 -0
  91. package/dist/src/compiled/_chunks/node/dist-iEFkK9qw.js +6 -0
  92. package/dist/src/compiled/_chunks/workflow/attribute-changes-DFx4eluc.js +6 -0
  93. package/dist/src/compiled/_chunks/workflow/{dist-D38gP7YF.js → dist-DjECvUyK.js} +1 -1
  94. package/dist/src/compiled/_chunks/workflow/{frames-QcJfYHmh.js → frames-D_Q-7A1N.js} +2 -2
  95. package/dist/src/compiled/_chunks/workflow/{helpers-6kObVbfS.js → helpers-Bw52uyzw.js} +1 -1
  96. package/dist/src/compiled/_chunks/workflow/{logger-NN5YHpYy.js → logger-DFNCa8Nl.js} +1 -1
  97. package/dist/src/compiled/_chunks/workflow/resume-hook-BhA_nDEV.js +1 -0
  98. package/dist/src/compiled/_chunks/workflow/{run-DJevv8zz.js → run-BT6SQv5f.js} +1 -1
  99. package/dist/src/compiled/_chunks/workflow/{serialization-C5KgPESk.js → serialization-Cl0SYU0I.js} +3 -3
  100. package/dist/src/compiled/_chunks/workflow/sleep-DB4AH9-A.js +1 -0
  101. package/dist/src/compiled/_chunks/workflow/{wait-until-BMY_tOr-.js → wait-until-Dzhr6tzf.js} +1 -1
  102. package/dist/src/compiled/_chunks/workflow/{ws-transport-DSDcKH08.js → ws-transport-BpTMh40s.js} +1 -1
  103. package/dist/src/compiled/chat/index.d.ts +1 -725
  104. package/dist/src/compiled/chat/index.js +1 -1
  105. package/dist/src/compiler/artifacts.d.ts +1 -0
  106. package/dist/src/compiler/artifacts.js +1 -1
  107. package/dist/src/compiler/extension-compatibility.d.ts +42 -15
  108. package/dist/src/compiler/extension-compatibility.js +1 -1
  109. package/dist/src/compiler/manifest.d.ts +14 -18
  110. package/dist/src/compiler/manifest.js +1 -1
  111. package/dist/src/compiler/normalize-agent-config.js +1 -1
  112. package/dist/src/compiler/normalize-helpers.js +1 -1
  113. package/dist/src/compiler/normalize-sandbox.d.ts +2 -7
  114. package/dist/src/compiler/normalize-sandbox.js +1 -1
  115. package/dist/src/compiler/normalize-tool.js +1 -1
  116. package/dist/src/compiler/workspace-resources.js +1 -1
  117. package/dist/src/context/build-callback-context.d.ts +2 -0
  118. package/dist/src/context/build-callback-context.js +1 -1
  119. package/dist/src/context/build-dynamic-tools.js +1 -1
  120. package/dist/src/context/container.d.ts +1 -1
  121. package/dist/src/context/container.js +1 -1
  122. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  123. package/dist/src/context/key-names.d.ts +1 -0
  124. package/dist/src/context/key-names.js +1 -1
  125. package/dist/src/context/keys.d.ts +7 -2
  126. package/dist/src/context/keys.js +1 -1
  127. package/dist/src/context/providers/sandbox.js +1 -1
  128. package/dist/src/context/providers/session.d.ts +19 -2
  129. package/dist/src/context/session-context.d.ts +1 -1
  130. package/dist/src/discover/sandbox.js +1 -1
  131. package/dist/src/evals/cli/eval.js +1 -1
  132. package/dist/src/evals/context.d.ts +1 -0
  133. package/dist/src/evals/context.js +1 -1
  134. package/dist/src/evals/define-eval-config.d.ts +7 -7
  135. package/dist/src/evals/define-eval-config.js +1 -1
  136. package/dist/src/evals/define-eval.d.ts +5 -2
  137. package/dist/src/evals/index.d.ts +1 -1
  138. package/dist/src/evals/runner/derive-run-facts.js +1 -1
  139. package/dist/src/evals/runner/execute-eval.d.ts +2 -0
  140. package/dist/src/evals/runner/execute-eval.js +1 -1
  141. package/dist/src/evals/runner/execute-task.d.ts +2 -0
  142. package/dist/src/evals/runner/execute-task.js +1 -1
  143. package/dist/src/evals/runner/run-evals.d.ts +2 -0
  144. package/dist/src/evals/runner/run-evals.js +1 -1
  145. package/dist/src/evals/target.js +1 -1
  146. package/dist/src/evals/types.d.ts +26 -9
  147. package/dist/src/eve-channel/create-request.d.ts +2 -1
  148. package/dist/src/eve-channel/delivery-policy-request.d.ts +4 -0
  149. package/dist/src/eve-channel/delivery-policy-request.js +1 -0
  150. package/dist/src/eve-channel/index.js +1 -1
  151. package/dist/src/eve-channel/request.d.ts +2 -1
  152. package/dist/src/eve-channel/request.js +1 -1
  153. package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
  154. package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +2 -1
  155. package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -1
  156. package/dist/src/execution/coordination-dispatch-shared.d.ts +3 -7
  157. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  158. package/dist/src/execution/coordination-dispatch-step.js +1 -1
  159. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  160. package/dist/src/execution/legacy-session/interrupt-step.js +1 -1
  161. package/dist/src/execution/node-step.js +1 -1
  162. package/dist/src/execution/proxied-deliver-step.js +1 -1
  163. package/dist/src/execution/route-child-delivery.js +3 -1
  164. package/dist/src/execution/runtime-context.js +1 -1
  165. package/dist/src/execution/sandbox/active-handles.d.ts +7 -8
  166. package/dist/src/execution/sandbox/active-handles.js +1 -1
  167. package/dist/src/execution/sandbox/bash.js +1 -1
  168. package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +1 -1
  169. package/dist/src/execution/sandbox/bindings/docker-cli.js +1 -1
  170. package/dist/src/execution/sandbox/bindings/docker-container.d.ts +2 -2
  171. package/dist/src/execution/sandbox/bindings/docker-container.js +1 -1
  172. package/dist/src/execution/sandbox/bindings/docker-network.d.ts +1 -1
  173. package/dist/src/execution/sandbox/bindings/docker-network.js +1 -1
  174. package/dist/src/execution/sandbox/bindings/docker-options.d.ts +4 -5
  175. package/dist/src/execution/sandbox/bindings/docker-options.js +1 -1
  176. package/dist/src/execution/sandbox/bindings/docker-session.d.ts +0 -1
  177. package/dist/src/execution/sandbox/bindings/docker-session.js +2 -2
  178. package/dist/src/execution/sandbox/bindings/docker.d.ts +16 -18
  179. package/dist/src/execution/sandbox/bindings/docker.js +1 -1
  180. package/dist/src/execution/sandbox/bindings/immutable-resources.d.ts +21 -0
  181. package/dist/src/execution/sandbox/bindings/immutable-resources.js +2 -0
  182. package/dist/src/execution/sandbox/bindings/just-bash-runtime.d.ts +9 -5
  183. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  184. package/dist/src/execution/sandbox/bindings/just-bash.d.ts +13 -26
  185. package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
  186. package/dist/src/execution/sandbox/bindings/{local-backend-utils.d.ts → local-provider-utils.d.ts} +7 -5
  187. package/dist/src/execution/sandbox/bindings/local-provider-utils.js +1 -0
  188. package/dist/src/execution/sandbox/bindings/local.d.ts +3 -3
  189. package/dist/src/execution/sandbox/bindings/local.js +1 -1
  190. package/dist/src/execution/sandbox/bindings/microsandbox-create.js +1 -1
  191. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.d.ts +30 -8
  192. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +1 -1
  193. package/dist/src/execution/sandbox/bindings/microsandbox-metadata.d.ts +9 -1
  194. package/dist/src/execution/sandbox/bindings/microsandbox-metadata.js +1 -1
  195. package/dist/src/execution/sandbox/bindings/microsandbox-network.js +1 -1
  196. package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +10 -4
  197. package/dist/src/execution/sandbox/bindings/microsandbox-options.js +1 -1
  198. package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +1 -1
  199. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.d.ts +7 -5
  200. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
  201. package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +1 -1
  202. package/dist/src/execution/sandbox/bindings/microsandbox.d.ts +11 -21
  203. package/dist/src/execution/sandbox/bindings/microsandbox.js +1 -1
  204. package/dist/src/execution/sandbox/bindings/vercel-base-runtime.js +2 -2
  205. package/dist/src/execution/sandbox/bindings/vercel-credentials.js +1 -1
  206. package/dist/src/execution/sandbox/bindings/vercel-errors.js +1 -1
  207. package/dist/src/execution/sandbox/bindings/vercel-lifecycle.d.ts +2 -2
  208. package/dist/src/execution/sandbox/bindings/vercel-lifecycle.js +1 -1
  209. package/dist/src/execution/sandbox/bindings/vercel-lookup.js +1 -1
  210. package/dist/src/execution/sandbox/bindings/vercel-options.d.ts +1 -2
  211. package/dist/src/execution/sandbox/bindings/vercel-options.js +1 -1
  212. package/dist/src/execution/sandbox/bindings/vercel.d.ts +20 -12
  213. package/dist/src/execution/sandbox/bindings/vercel.js +2 -2
  214. package/dist/src/execution/sandbox/development-cleanup.js +1 -1
  215. package/dist/src/execution/sandbox/development-prewarm.d.ts +5 -0
  216. package/dist/src/execution/sandbox/development-prewarm.js +1 -1
  217. package/dist/src/execution/sandbox/development-run.d.ts +2 -3
  218. package/dist/src/execution/sandbox/dockerfile.d.ts +25 -0
  219. package/dist/src/execution/sandbox/dockerfile.js +1 -0
  220. package/dist/src/execution/sandbox/ensure.d.ts +0 -17
  221. package/dist/src/execution/sandbox/ensure.js +1 -1
  222. package/dist/src/execution/sandbox/logging-session.js +1 -1
  223. package/dist/src/execution/sandbox/prewarm.d.ts +23 -27
  224. package/dist/src/execution/sandbox/prewarm.js +1 -2
  225. package/dist/src/execution/sandbox/provider-files.d.ts +2 -0
  226. package/dist/src/execution/sandbox/provider-files.js +1 -0
  227. package/dist/src/execution/sandbox/provider-host-development.d.ts +2 -0
  228. package/dist/src/execution/sandbox/provider-host-development.js +1 -0
  229. package/dist/src/execution/sandbox/provider-host.d.ts +2 -0
  230. package/dist/src/execution/sandbox/provider-host.js +1 -0
  231. package/dist/src/execution/sandbox/provider-identity.d.ts +1 -0
  232. package/dist/src/execution/sandbox/provider-identity.js +1 -0
  233. package/dist/src/execution/sandbox/ripgrep-probe.d.ts +0 -7
  234. package/dist/src/execution/sandbox/ripgrep-probe.js +1 -1
  235. package/dist/src/execution/sandbox/session.d.ts +8 -8
  236. package/dist/src/execution/sandbox/session.js +1 -1
  237. package/dist/src/execution/session/admission.js +1 -1
  238. package/dist/src/execution/session/handoff-steps.js +1 -1
  239. package/dist/src/execution/session/handoff.d.ts +2 -1
  240. package/dist/src/execution/session/handoff.js +1 -1
  241. package/dist/src/execution/session/input-queue.d.ts +4 -1
  242. package/dist/src/execution/session/input-queue.js +1 -1
  243. package/dist/src/execution/session/next-input.js +1 -1
  244. package/dist/src/execution/session/program.js +1 -1
  245. package/dist/src/execution/session/turn-step.js +1 -1
  246. package/dist/src/execution/session/turn.js +1 -1
  247. package/dist/src/execution/session-inbox/protocol.js +1 -1
  248. package/dist/src/execution/session-workflow-tool-run.js +1 -1
  249. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  250. package/dist/src/execution/stable-workflow-names.d.ts +0 -1
  251. package/dist/src/execution/stable-workflow-names.js +1 -1
  252. package/dist/src/execution/tasks/child/notify.d.ts +44 -0
  253. package/dist/src/execution/tasks/child/notify.js +1 -0
  254. package/dist/src/execution/tasks/parent/control-shared.d.ts +2 -5
  255. package/dist/src/execution/tasks/parent/control-shared.js +1 -1
  256. package/dist/src/execution/tasks/parent/delegate.d.ts +8 -36
  257. package/dist/src/execution/tasks/parent/delegate.js +1 -1
  258. package/dist/src/execution/tasks/parent/dispatch.d.ts +3 -5
  259. package/dist/src/execution/tasks/parent/dispatch.js +1 -1
  260. package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +4 -1
  261. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
  262. package/dist/src/execution/tasks/parent/run-parent.d.ts +5 -19
  263. package/dist/src/execution/tasks/parent/run-parent.js +1 -1
  264. package/dist/src/execution/tasks/parent/task-cancel.d.ts +6 -5
  265. package/dist/src/execution/tasks/parent/task-cancel.js +1 -1
  266. package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
  267. package/dist/src/execution/tool-auth.d.ts +3 -9
  268. package/dist/src/execution/tool-auth.js +1 -1
  269. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  270. package/dist/src/execution/tools/sleep-workflow.js +1 -1
  271. package/dist/src/execution/tools/subagent/accept-event-step.js +1 -1
  272. package/dist/src/execution/tools/subagent/emit-event-step.d.ts +11 -0
  273. package/dist/src/execution/tools/subagent/emit-event-step.js +1 -0
  274. package/dist/src/execution/tools/subagent/invoke-agent.d.ts +5 -7
  275. package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
  276. package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -1
  277. package/dist/src/execution/tools/subagent/invoke-step.d.ts +3 -2
  278. package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
  279. package/dist/src/execution/tools/subagent/start.d.ts +1 -0
  280. package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +0 -1
  281. package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -1
  282. package/dist/src/execution/tools/subagent/task-cancel.d.ts +1 -1
  283. package/dist/src/execution/tools/subagent/task-cancel.js +1 -1
  284. package/dist/src/execution/tools/workflow/background.d.ts +1 -1
  285. package/dist/src/execution/tools/workflow/background.js +1 -1
  286. package/dist/src/execution/tools/workflow/body.d.ts +0 -2
  287. package/dist/src/execution/tools/workflow/body.js +1 -1
  288. package/dist/src/execution/tools/workflow/cancel.d.ts +4 -3
  289. package/dist/src/execution/tools/workflow/cancel.js +1 -1
  290. package/dist/src/execution/tools/workflow/cancellation-policy.d.ts +2 -0
  291. package/dist/src/execution/tools/workflow/cancellation-policy.js +1 -0
  292. package/dist/src/execution/tools/workflow/messages.d.ts +0 -1
  293. package/dist/src/execution/tools/workflow/owner-channels.d.ts +6 -6
  294. package/dist/src/execution/tools/workflow/owner-inbox.d.ts +5 -9
  295. package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
  296. package/dist/src/execution/tools/workflow/owner.d.ts +6 -2
  297. package/dist/src/execution/tools/workflow/owner.js +1 -1
  298. package/dist/src/execution/tools/workflow/start.js +1 -1
  299. package/dist/src/execution/tools/workflow/types.d.ts +11 -19
  300. package/dist/src/execution/tools/workflow/types.js +1 -1
  301. package/dist/src/execution/tools/workflow/workflow-owner-background.d.ts +13 -0
  302. package/dist/src/execution/tools/workflow/workflow-owner-background.js +1 -0
  303. package/dist/src/execution/tools/workflow/workflow-owner-blocking.d.ts +12 -0
  304. package/dist/src/execution/tools/workflow/workflow-owner-blocking.js +1 -0
  305. package/dist/src/execution/tools/workflow/workflow.d.ts +3 -3
  306. package/dist/src/execution/tools/workflow/workflow.js +1 -1
  307. package/dist/src/execution/workflow-runtime.d.ts +0 -4
  308. package/dist/src/execution/workflow-runtime.js +1 -1
  309. package/dist/src/framework/sources/modules/sandbox.d.ts +2 -1
  310. package/dist/src/framework/sources/modules/sandbox.js +1 -1
  311. package/dist/src/harness/approval-delivery-coordinator.js +1 -1
  312. package/dist/src/harness/background-tools.d.ts +3 -5
  313. package/dist/src/harness/coordination.js +1 -1
  314. package/dist/src/harness/emission.js +1 -1
  315. package/dist/src/harness/execute-tool.d.ts +2 -29
  316. package/dist/src/harness/hitl/approval-input-requests.d.ts +1 -1
  317. package/dist/src/harness/hitl/approval-input-requests.js +1 -1
  318. package/dist/src/harness/input-requests.d.ts +6 -0
  319. package/dist/src/harness/input-requests.js +1 -1
  320. package/dist/src/harness/messages.d.ts +2 -1
  321. package/dist/src/harness/messages.js +1 -1
  322. package/dist/src/harness/pending-input-batches.d.ts +1 -0
  323. package/dist/src/harness/pending-input-batches.js +1 -1
  324. package/dist/src/harness/tool-loop.js +2 -2
  325. package/dist/src/harness/tool-model-output.js +1 -1
  326. package/dist/src/harness/tools.js +1 -1
  327. package/dist/src/harness/workflow-tool-runs.d.ts +53 -18
  328. package/dist/src/harness/workflow-tool-runs.js +1 -1
  329. package/dist/src/instrumentation/ai-sdk-warnings.d.ts +6 -0
  330. package/dist/src/instrumentation/ai-sdk-warnings.js +1 -0
  331. package/dist/src/instrumentation/runtime.d.ts +1 -0
  332. package/dist/src/instrumentation/runtime.js +1 -1
  333. package/dist/src/internal/application/compiled-artifacts.d.ts +2 -0
  334. package/dist/src/internal/application/compiled-artifacts.js +2 -2
  335. package/dist/src/internal/application/package.js +1 -1
  336. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  337. package/dist/src/internal/nitro/host/artifacts-config.d.ts +6 -1
  338. package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
  339. package/dist/src/internal/nitro/host/build-application.js +1 -1
  340. package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.d.ts +16 -0
  341. package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.js +5 -0
  342. package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
  343. package/dist/src/internal/nitro/host/create-application-nitro.d.ts +3 -3
  344. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  345. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
  346. package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
  347. package/dist/src/internal/nitro/host/prepare-application-host.d.ts +1 -0
  348. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  349. package/dist/src/internal/nitro/host/sandbox-shutdown-plugin.js +1 -1
  350. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  351. package/dist/src/internal/nitro/host/start-production-server.js +2 -2
  352. package/dist/src/internal/nitro/host/types.d.ts +1 -1
  353. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  354. package/dist/src/internal/nitro/routes/runtime-artifacts.d.ts +1 -0
  355. package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -1
  356. package/dist/src/internal/runtime-registry.d.ts +2 -2
  357. package/dist/src/internal/vercel/build-agent-workspace.d.ts +3 -1
  358. package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
  359. package/dist/src/protocol/message.d.ts +4 -4
  360. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +4 -5
  361. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
  362. package/dist/src/public/channels/github/checkout.js +1 -1
  363. package/dist/src/public/channels/index.d.ts +1 -1
  364. package/dist/src/public/channels/slack/slackChannel.d.ts +3 -1
  365. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  366. package/dist/src/public/definitions/channel.d.ts +1 -1
  367. package/dist/src/public/definitions/sandbox.d.ts +5 -43
  368. package/dist/src/public/definitions/sandbox.js +1 -1
  369. package/dist/src/public/local-dev.d.ts +4 -5
  370. package/dist/src/public/sandbox/docker-sandbox.d.ts +16 -40
  371. package/dist/src/public/sandbox/docker.d.ts +2 -2
  372. package/dist/src/public/sandbox/docker.js +1 -1
  373. package/dist/src/public/sandbox/index.d.ts +4 -9
  374. package/dist/src/public/sandbox/index.js +1 -1
  375. package/dist/src/public/sandbox/just-bash-sandbox.d.ts +11 -6
  376. package/dist/src/public/sandbox/just-bash.d.ts +2 -2
  377. package/dist/src/public/sandbox/just-bash.js +1 -1
  378. package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +11 -17
  379. package/dist/src/public/sandbox/microsandbox.d.ts +2 -2
  380. package/dist/src/public/sandbox/microsandbox.js +1 -1
  381. package/dist/src/public/sandbox/provider.d.ts +1 -0
  382. package/dist/src/public/sandbox/provider.js +1 -0
  383. package/dist/src/public/sandbox/vercel-sandbox.d.ts +10 -41
  384. package/dist/src/public/sandbox/vercel.d.ts +2 -2
  385. package/dist/src/public/sandbox/vercel.js +1 -1
  386. package/dist/src/public/tools/index.d.ts +2 -2
  387. package/dist/src/runtime/agent/resolve-model.js +1 -1
  388. package/dist/src/runtime/cache-key.js +1 -1
  389. package/dist/src/runtime/compiled-artifacts-source.d.ts +6 -1
  390. package/dist/src/runtime/compiled-artifacts-source.js +1 -1
  391. package/dist/src/runtime/connections/scoped-authorization.js +1 -1
  392. package/dist/src/runtime/loaders/artifact-paths.d.ts +1 -0
  393. package/dist/src/runtime/loaders/artifact-paths.js +1 -1
  394. package/dist/src/runtime/loaders/bundled-artifacts.d.ts +3 -0
  395. package/dist/src/runtime/loaders/bundled-artifacts.js +1 -1
  396. package/dist/src/runtime/loaders/compile-metadata.js +1 -1
  397. package/dist/src/runtime/loaders/manifest.js +1 -1
  398. package/dist/src/runtime/loaders/module-map.js +1 -1
  399. package/dist/src/runtime/local-dev-capability.d.ts +14 -12
  400. package/dist/src/runtime/local-dev-capability.js +1 -1
  401. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  402. package/dist/src/runtime/resolve-sandbox.d.ts +1 -10
  403. package/dist/src/runtime/resolve-sandbox.js +1 -1
  404. package/dist/src/runtime/sandbox/prepared-artifacts.d.ts +13 -0
  405. package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -0
  406. package/dist/src/runtime/sandbox/registry.d.ts +2 -9
  407. package/dist/src/runtime/sandbox/registry.js +1 -1
  408. package/dist/src/runtime/sessions/runtime-session.js +1 -1
  409. package/dist/src/runtime/sessions/turn.d.ts +10 -8
  410. package/dist/src/runtime/subagents/registry.js +1 -1
  411. package/dist/src/runtime/subagents/workflow.js +1 -1
  412. package/dist/src/runtime/tools/registry.js +1 -1
  413. package/dist/src/runtime/types.d.ts +13 -26
  414. package/dist/src/runtime/workspace/types.d.ts +1 -1
  415. package/dist/src/sandbox/providers/default.d.ts +27 -0
  416. package/dist/src/sandbox/providers/default.js +1 -0
  417. package/dist/src/sandbox/providers/docker.d.ts +11 -0
  418. package/dist/src/sandbox/providers/docker.js +1 -0
  419. package/dist/src/sandbox/providers/just-bash.d.ts +4 -0
  420. package/dist/src/sandbox/providers/just-bash.js +1 -0
  421. package/dist/src/sandbox/providers/microsandbox.d.ts +12 -0
  422. package/dist/src/sandbox/providers/microsandbox.js +1 -0
  423. package/dist/src/sandbox/providers/vercel.d.ts +12 -0
  424. package/dist/src/sandbox/providers/vercel.js +1 -0
  425. package/dist/src/sandbox/providers.d.ts +5 -0
  426. package/dist/src/sandbox/providers.js +1 -0
  427. package/dist/src/sandbox/state.d.ts +6 -25
  428. package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +1 -1
  429. package/dist/src/self-modification/extension/subagents/agent/agent.js +1 -1
  430. package/dist/src/self-modification/extension/subagents/agent/sandbox.d.ts +2 -25
  431. package/dist/src/self-modification/extension/subagents/agent/sandbox.js +1 -1
  432. package/dist/src/self-modification/extension/subagents/agent/tools/publish.js +1 -1
  433. package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.js +1 -1
  434. package/dist/src/self-modification/filesystem.d.ts +3 -1
  435. package/dist/src/self-modification/filesystem.js +1 -1
  436. package/dist/src/self-modification/git-workspace.d.ts +1 -1
  437. package/dist/src/self-modification/git.d.ts +1 -1
  438. package/dist/src/self-modification/sandbox.d.ts +14 -9
  439. package/dist/src/self-modification/sandbox.js +1 -1
  440. package/dist/src/setup/boxes/select-model.js +1 -1
  441. package/dist/src/setup/cli/select-state.d.ts +4 -2
  442. package/dist/src/setup/cli/select-state.js +1 -1
  443. package/dist/src/setup/flows/model-login.js +1 -1
  444. package/dist/src/setup/flows/model.d.ts +5 -5
  445. package/dist/src/setup/primitives/pm/pnpm.js +3 -2
  446. package/dist/src/setup/scaffold/create/project.js +1 -1
  447. package/dist/src/shared/action-types.d.ts +0 -4
  448. package/dist/src/shared/action-types.js +1 -1
  449. package/dist/src/shared/default-agent-model.d.ts +1 -1
  450. package/dist/src/shared/default-agent-model.js +1 -1
  451. package/dist/src/shared/sandbox-environment.d.ts +45 -0
  452. package/dist/src/shared/sandbox-environment.js +1 -0
  453. package/dist/src/shared/sandbox-network-policy.d.ts +8 -3
  454. package/dist/src/shared/sandbox-network-policy.js +1 -1
  455. package/dist/src/shared/sandbox-prepared-artifacts.d.ts +16 -0
  456. package/dist/src/shared/sandbox-prepared-artifacts.js +1 -0
  457. package/dist/src/shared/sandbox-provider.d.ts +110 -0
  458. package/dist/src/shared/sandbox-provider.js +1 -0
  459. package/dist/src/shared/sandbox-session.d.ts +18 -41
  460. package/dist/src/shared/sandbox-template-error.d.ts +9 -0
  461. package/dist/src/shared/sandbox-template-error.js +1 -0
  462. package/dist/src/subagents/tool.d.ts +1 -1
  463. package/dist/src/subagents/tool.js +1 -1
  464. package/dist/src/svelte/index.js +1 -1
  465. package/dist/src/svelte/use-eve-agent.js +1 -1
  466. package/dist/src/tasks/delivery-context.d.ts +6 -4
  467. package/dist/src/tasks/delivery-context.js +2 -2
  468. package/dist/src/tasks/delivery-policy.d.ts +2 -0
  469. package/dist/src/tasks/delivery-policy.js +1 -1
  470. package/dist/src/tasks/notification.d.ts +4 -0
  471. package/dist/src/tasks/notification.js +1 -0
  472. package/dist/src/tasks/session-task-cohorts.d.ts +1 -12
  473. package/dist/src/tasks/session-task-cohorts.js +1 -1
  474. package/dist/src/tasks/transitions.d.ts +5 -2
  475. package/dist/src/tasks/transitions.js +1 -1
  476. package/dist/src/tasks/types.d.ts +2 -52
  477. package/dist/src/tasks/types.js +1 -1
  478. package/dist/src/tools/definition.d.ts +1 -25
  479. package/dist/src/tools/definition.js +1 -1
  480. package/dist/src/tools/dynamic.d.ts +1 -3
  481. package/dist/src/tools/framework/agent-contract.js +1 -1
  482. package/dist/src/tools/framework/agent.d.ts +16 -22
  483. package/dist/src/tools/framework/agent.js +1 -1
  484. package/dist/src/tools/workflow-definition.d.ts +16 -5
  485. package/dist/src/tracing/agent-invocation-coordinator.js +1 -1
  486. package/dist/src/tracing/agent-trace-context-store.js +1 -1
  487. package/dist/src/vue/index.js +1 -1
  488. package/dist/src/vue/use-eve-agent.js +1 -1
  489. package/docs/README.md +40 -45
  490. package/docs/agent-config.md +2 -2
  491. package/docs/channels/eve.mdx +1 -1
  492. package/docs/channels/overview.mdx +48 -0
  493. package/docs/concepts/execution-model-and-durability.mdx +5 -6
  494. package/docs/concepts/sessions-runs-and-streaming.md +5 -5
  495. package/docs/dynamic-configuration/meta.json +5 -0
  496. package/docs/evals/assertions.mdx +5 -1
  497. package/docs/evals/overview.mdx +43 -0
  498. package/docs/getting-started.mdx +1 -1
  499. package/docs/guides/client/overview.mdx +1 -1
  500. package/docs/guides/deployment/overview.md +1 -1
  501. package/docs/guides/deployment/self-hosting.md +5 -5
  502. package/docs/guides/deployment/vercel.mdx +10 -12
  503. package/docs/guides/dev-tui.md +22 -10
  504. package/docs/guides/frontend/overview.mdx +1 -1
  505. package/docs/guides/hooks.md +4 -0
  506. package/docs/memory/meta.json +1 -1
  507. package/docs/memory/overview.mdx +4 -0
  508. package/docs/meta.json +13 -16
  509. package/docs/patterns/meta.json +2 -2
  510. package/docs/protocols/acp.md +1 -1
  511. package/docs/protocols/ucp.mdx +1 -1
  512. package/docs/reference/cli.md +10 -9
  513. package/docs/reference/meta.json +4 -1
  514. package/docs/reference/typescript-api.md +1 -24
  515. package/docs/sandbox/default.mdx +17 -0
  516. package/docs/sandbox/docker.mdx +29 -0
  517. package/docs/sandbox/index.mdx +216 -0
  518. package/docs/sandbox/just-bash.mdx +18 -0
  519. package/docs/sandbox/meta.json +5 -0
  520. package/docs/sandbox/microsandbox.mdx +31 -0
  521. package/docs/sandbox/vercel.mdx +106 -0
  522. package/docs/schedules.mdx +35 -1
  523. package/docs/subagents/index.mdx +27 -6
  524. package/docs/subagents/meta.json +1 -1
  525. package/docs/tools/overview.mdx +37 -37
  526. package/docs/tools/workflows.mdx +31 -24
  527. package/docs/tutorial/run-analysis.mdx +6 -5
  528. package/package.json +20 -11
  529. package/dist/src/cli/dev/tui/model-editor.d.ts +0 -103
  530. package/dist/src/cli/dev/tui/model-editor.js +0 -1
  531. package/dist/src/compiled/_chunks/node/chunk-5OX2R7AJ-CxVV-owP.js +0 -1
  532. package/dist/src/compiled/_chunks/node/chunk-AYN7QRWH-B__hKQV7.js +0 -1
  533. package/dist/src/compiled/_chunks/node/chunk-QZV7YRVM-Dzw4WEBv.js +0 -1
  534. package/dist/src/compiled/_chunks/node/dist-CweJdVFE.js +0 -6
  535. package/dist/src/compiled/_chunks/node/dist-Da54NuK8.js +0 -96
  536. package/dist/src/compiled/_chunks/workflow/attribute-changes-A6HfMNG3.js +0 -6
  537. package/dist/src/compiled/_chunks/workflow/resume-hook-CAqlhwic.js +0 -1
  538. package/dist/src/compiled/_chunks/workflow/sleep-CbUwdv6O.js +0 -1
  539. package/dist/src/compiled/chat/_mdast.d.ts +0 -24
  540. package/dist/src/compiled/chat/_workflow-serde.d.ts +0 -3
  541. package/dist/src/compiled/chat/jsx-runtime-_JEEAotp.d.ts +0 -907
  542. package/dist/src/execution/sandbox/bindings/local-backend-utils.js +0 -1
  543. package/dist/src/execution/sandbox/lazy-backend.d.ts +0 -15
  544. package/dist/src/execution/sandbox/lazy-backend.js +0 -1
  545. package/dist/src/execution/sandbox/template-prewarm-lock.d.ts +0 -8
  546. package/dist/src/execution/sandbox/template-prewarm-lock.js +0 -1
  547. package/dist/src/execution/tasks/child/steps.d.ts +0 -81
  548. package/dist/src/execution/tasks/child/steps.js +0 -1
  549. package/dist/src/execution/tasks/child/workflow.d.ts +0 -28
  550. package/dist/src/execution/tasks/child/workflow.js +0 -1
  551. package/dist/src/execution/tools/subagent/emit-called-step.d.ts +0 -9
  552. package/dist/src/execution/tools/subagent/emit-called-step.js +0 -1
  553. package/dist/src/execution/tools/workflow/run-control.d.ts +0 -14
  554. package/dist/src/execution/tools/workflow/run-control.js +0 -1
  555. package/dist/src/internal/authored-definition/sandbox.d.ts +0 -17
  556. package/dist/src/internal/authored-definition/sandbox.js +0 -1
  557. package/dist/src/internal/nitro/host/compiled-sandbox-backend-prune-plugin.d.ts +0 -16
  558. package/dist/src/internal/nitro/host/compiled-sandbox-backend-prune-plugin.js +0 -2
  559. package/dist/src/public/definitions/sandbox-backend.d.ts +0 -17
  560. package/dist/src/public/definitions/sandbox-backend.js +0 -1
  561. package/dist/src/public/sandbox/backends/default.d.ts +0 -1
  562. package/dist/src/public/sandbox/backends/default.js +0 -1
  563. package/dist/src/public/sandbox/backends/docker.d.ts +0 -1
  564. package/dist/src/public/sandbox/backends/docker.js +0 -1
  565. package/dist/src/public/sandbox/backends/just-bash.d.ts +0 -1
  566. package/dist/src/public/sandbox/backends/just-bash.js +0 -1
  567. package/dist/src/public/sandbox/backends/microsandbox.d.ts +0 -1
  568. package/dist/src/public/sandbox/backends/microsandbox.js +0 -1
  569. package/dist/src/public/sandbox/backends/vercel.d.ts +0 -1
  570. package/dist/src/public/sandbox/backends/vercel.js +0 -1
  571. package/dist/src/runtime/sandbox/keys.d.ts +0 -42
  572. package/dist/src/runtime/sandbox/keys.js +0 -1
  573. package/dist/src/runtime/sandbox/template-plan.d.ts +0 -24
  574. package/dist/src/runtime/sandbox/template-plan.js +0 -1
  575. package/dist/src/sandbox/backends/default.d.ts +0 -42
  576. package/dist/src/sandbox/backends/default.js +0 -1
  577. package/dist/src/sandbox/backends/docker.d.ts +0 -14
  578. package/dist/src/sandbox/backends/docker.js +0 -1
  579. package/dist/src/sandbox/backends/just-bash.d.ts +0 -17
  580. package/dist/src/sandbox/backends/just-bash.js +0 -1
  581. package/dist/src/sandbox/backends/microsandbox.d.ts +0 -17
  582. package/dist/src/sandbox/backends/microsandbox.js +0 -1
  583. package/dist/src/sandbox/backends/vercel.d.ts +0 -30
  584. package/dist/src/sandbox/backends/vercel.js +0 -1
  585. package/dist/src/shared/sandbox-backend.d.ts +0 -176
  586. package/dist/src/shared/sandbox-backend.js +0 -1
  587. package/dist/src/shared/sandbox-definition.d.ts +0 -112
  588. package/dist/src/shared/sandbox-definition.js +0 -1
  589. package/dist/src/tasks/session-index.d.ts +0 -65
  590. package/dist/src/tasks/session-index.js +0 -1
  591. package/dist/src/tools/task.d.ts +0 -55
  592. package/dist/src/tools/task.js +0 -1
  593. package/docs/sandbox.mdx +0 -342
@@ -1,26 +1,61 @@
1
- import type { HarnessSession, SessionStateMap } from "#harness/types.js";
2
1
  import type { RuntimeToolResultActionResult } from "#shared/action-types.js";
3
- /** A workflow tool run the active turn waits on. Background runs live in the task index. */
4
- export interface WorkflowToolRunRecord {
2
+ import type { SessionStateMap } from "#harness/types.js";
3
+ import { type ActivityWorkIdentityV1 } from "#protocol/activity.js";
4
+ import { type TaskMetadata, type TaskView } from "#tasks/types.js";
5
+ import type { DurableDynamicSubagentSelection, SessionAuth } from "#context/keys.js";
6
+ export declare const WORKFLOW_TOOL_RUNS_STATE_KEY = "eve.workflowTool";
7
+ export interface WorkflowTaskPayload {
8
+ readonly taskId: string;
9
+ readonly metadata: TaskMetadata;
10
+ readonly dispatchContext: TaskAgentDispatchContext;
11
+ readonly activityWorkIdentity?: ActivityWorkIdentityV1;
12
+ readonly cohortId?: string;
13
+ /** Parent-owned outcome. Read through readWorkflowTaskView before consuming it. */
14
+ readonly outcome?: unknown;
15
+ }
16
+ interface WorkflowToolRunBase {
5
17
  readonly callId: string;
6
- readonly hookToken: string;
7
- readonly runId: string;
8
18
  readonly toolName: string;
9
- readonly resultKind?: "subagent" | "tool";
19
+ readonly origin: {
20
+ readonly turnId: string;
21
+ readonly stepIndex: number;
22
+ };
23
+ readonly address: {
24
+ readonly runId: string;
25
+ readonly hookToken: string;
26
+ };
27
+ }
28
+ export type BlockingWorkflowToolRun = WorkflowToolRunBase & {
29
+ readonly lifetime: "turn";
30
+ };
31
+ export type BackgroundWorkflowToolRun = WorkflowToolRunBase & {
32
+ readonly lifetime: "session";
33
+ readonly task: WorkflowTaskPayload;
34
+ };
35
+ export type WorkflowToolRun = BlockingWorkflowToolRun | BackgroundWorkflowToolRun;
36
+ export interface TaskAgentDispatchContext {
37
+ readonly auth: SessionAuth;
38
+ readonly sessionDynamicSubagentSelections?: Readonly<Record<string, DurableDynamicSubagentSelection>>;
39
+ readonly turnDynamicSubagentSelections?: Readonly<Record<string, DurableDynamicSubagentSelection>>;
10
40
  }
11
- export declare function getWorkflowToolRuns(state: SessionStateMap | undefined): readonly WorkflowToolRunRecord[];
12
- export declare function findWorkflowToolRun(state: SessionStateMap | undefined, callId: string): WorkflowToolRunRecord | undefined;
13
- export declare function recordWorkflowToolRun<T extends {
41
+ /** Decode retained output only when it is consumed, independently of ownership reads. */
42
+ export declare function readWorkflowTaskView(task: WorkflowTaskPayload): TaskView | undefined;
43
+ export declare function getWorkflowToolRuns(state: SessionStateMap | undefined): readonly WorkflowToolRun[];
44
+ export declare function getBackgroundWorkflowToolRuns(state: SessionStateMap | undefined): readonly BackgroundWorkflowToolRun[];
45
+ export declare function getBlockingWorkflowToolRuns(state: SessionStateMap | undefined, turnId?: string): readonly BlockingWorkflowToolRun[];
46
+ export declare function findBackgroundWorkflowToolRun(state: SessionStateMap | undefined, taskId: string): BackgroundWorkflowToolRun | undefined;
47
+ /** Registration is idempotent by originating turn and call; retained task facts survive replay. */
48
+ export declare function registerWorkflowToolRun<T extends {
14
49
  readonly state?: SessionStateMap;
15
- }>(session: T, record: WorkflowToolRunRecord): T;
16
- export declare function removeWorkflowToolRun<T extends {
50
+ }>(session: T, entry: WorkflowToolRun): T;
51
+ /** Task payloads remain available for the session lifetime, including after report delivery. */
52
+ export declare function recordWorkflowTaskView(state: SessionStateMap | undefined, view: TaskView): SessionStateMap | undefined;
53
+ /** Removes only this turn's waiting calls. Session-owned task payloads are never pruned here. */
54
+ export declare function removeBlockingWorkflowToolRuns<T extends {
17
55
  readonly state?: SessionStateMap;
18
- }>(session: T, callId: string): T;
19
- export declare function clearWorkflowToolRuns(session: HarnessSession): HarnessSession;
56
+ }>(session: T, turnId: string, callId?: string): T;
57
+ /** Results without an originating turn may bind only when exactly one recorded turn owns the call. */
58
+ export declare function findBlockingWorkflowToolRun(state: SessionStateMap | undefined, callId: string, turnId?: string): BlockingWorkflowToolRun | undefined;
20
59
  /** The turn inbox is shared; a result settles a call only if the turn recorded that run. */
21
60
  export declare function isInboxToolResultFromRecordedWorkflowToolRun(state: SessionStateMap | undefined, result: RuntimeToolResultActionResult): boolean;
22
- /** A child result reported through a shared subagent execute run. */
23
- export declare function isInboxSubagentResultFromRecordedWorkflowToolRun(state: SessionStateMap | undefined, result: {
24
- readonly callId: string;
25
- readonly subagentName: string;
26
- }): boolean;
61
+ export {};
@@ -1 +1 @@
1
- const WORKFLOW_TOOL_RUNS_STATE_KEY=`eve.runtime.workflowToolRuns`;function getWorkflowToolRuns(e){let t=e?.[WORKFLOW_TOOL_RUNS_STATE_KEY];return Array.isArray(t)?t:[]}function findWorkflowToolRun(e,t){return getWorkflowToolRuns(e).find(e=>e.callId===t)}function recordWorkflowToolRun(e,t){return writeWorkflowToolRuns(e,[...getWorkflowToolRuns(e.state).filter(e=>e.callId!==t.callId),t])}function removeWorkflowToolRun(e,t){let n=getWorkflowToolRuns(e.state),r=n.filter(e=>e.callId!==t);return r.length===n.length?e:writeWorkflowToolRuns(e,r)}function clearWorkflowToolRuns(e){return getWorkflowToolRuns(e.state).length===0?e:writeWorkflowToolRuns(e,[])}function isInboxToolResultFromRecordedWorkflowToolRun(e,t){let n=findWorkflowToolRun(e,t.callId);return n!==void 0&&n.resultKind!==`subagent`&&n.toolName===t.toolName}function isInboxSubagentResultFromRecordedWorkflowToolRun(e,t){let n=findWorkflowToolRun(e,t.callId);return n?.resultKind===`subagent`&&n.toolName===t.subagentName}function writeWorkflowToolRuns(e,t){let n={...e.state};return t.length===0?delete n[WORKFLOW_TOOL_RUNS_STATE_KEY]:n[WORKFLOW_TOOL_RUNS_STATE_KEY]=t,{...e,state:Object.keys(n).length>0?n:void 0}}export{clearWorkflowToolRuns,findWorkflowToolRun,getWorkflowToolRuns,isInboxSubagentResultFromRecordedWorkflowToolRun,isInboxToolResultFromRecordedWorkflowToolRun,recordWorkflowToolRun,removeWorkflowToolRun};
1
+ import{isNonEmptyString,isObject}from"#shared/guards.js";import{parseActivityWorkIdentityV1}from"#protocol/activity.js";import{sameTaskMetadata}from"#tasks/types.js";const WORKFLOW_TOOL_RUNS_STATE_KEY=`eve.workflowTool`;function isTaskMetadata(e){return isObject(e)&&isNonEmptyString(e.kind)&&isNonEmptyString(e.name)}function isRecord(e){if(!isObject(e))return!1;let t=e.constructor;return typeof t!=`function`||isObject(t.prototype)&&Object.hasOwn(t.prototype,`isPrototypeOf`)}function isSessionAuthContext(e){return e===null||isObject(e)&&Object.keys(e).every(e=>[`attributes`,`authenticator`,`issuer`,`principalId`,`principalType`,`subject`].includes(e))&&isRecord(e.attributes)&&Object.values(e.attributes).every(e=>typeof e==`string`||Array.isArray(e)&&Array.from(e).every(e=>typeof e==`string`))&&typeof e.authenticator==`string`&&typeof e.principalId==`string`&&typeof e.principalType==`string`&&(e.issuer===void 0||typeof e.issuer==`string`)&&(e.subject===void 0||typeof e.subject==`string`)}function isTaskAgentDispatchContext(e){return isObject(e)&&Object.keys(e).every(e=>[`auth`,`sessionDynamicSubagentSelections`,`turnDynamicSubagentSelections`].includes(e))&&isObject(e.auth)&&Object.keys(e.auth).every(e=>e===`current`||e===`initiator`)&&isSessionAuthContext(e.auth.current)&&isSessionAuthContext(e.auth.initiator)&&(e.sessionDynamicSubagentSelections===void 0||isRecord(e.sessionDynamicSubagentSelections))&&(e.turnDynamicSubagentSelections===void 0||isRecord(e.turnDynamicSubagentSelections))}function isWorkflowToolRun(e){if(!isObject(e)||!isNonEmptyString(e.callId)||!isNonEmptyString(e.toolName)||!isObject(e.origin)||!isNonEmptyString(e.origin.turnId)||typeof e.origin.stepIndex!=`number`||!Number.isSafeInteger(e.origin.stepIndex)||e.origin.stepIndex<0||!isObject(e.address)||!isNonEmptyString(e.address.runId)||!isNonEmptyString(e.address.hookToken))return!1;if(e.lifetime===`turn`)return e.task===void 0;if(e.lifetime!==`session`||!isObject(e.task))return!1;let t=e.task;return isNonEmptyString(t.taskId)&&isTaskMetadata(t.metadata)&&isTaskAgentDispatchContext(t.dispatchContext)&&(t.cohortId===void 0||isNonEmptyString(t.cohortId))&&(t.activityWorkIdentity===void 0||parseActivityWorkIdentityV1(t.activityWorkIdentity)!==void 0)}function parseRegistry(e){if(!isObject(e)||e.version!==3||!Array.isArray(e.runs)||!Array.from(e.runs).every(isWorkflowToolRun))throw Error(`Corrupt workflow tool run registry: invalid version or run.`);let t=new Set,n=new Set;for(let r of e.runs){let e=JSON.stringify([r.origin.turnId,r.callId]);if(t.has(e))throw Error(`Corrupt workflow tool run registry: Run identities must be unique.`);if(t.add(e),r.lifetime===`session`){if(n.has(r.task.taskId))throw Error(`Corrupt workflow tool run registry: Task ids must be unique.`);n.add(r.task.taskId)}}return{...e,version:3,runs:e.runs.map(copyWorkflowToolRun)}}function copySessionAuthContext(e){return e===null?null:{...e,attributes:Object.fromEntries(Object.entries(e.attributes).map(([e,t])=>[e,typeof t==`string`?t:Object.freeze([...t])]))}}function copyWorkflowToolRun(e){let t={...e,origin:{...e.origin},address:{...e.address}};if(e.lifetime===`turn`)return t;let n=e.task.dispatchContext,r={...n,auth:{current:copySessionAuthContext(n.auth.current),initiator:copySessionAuthContext(n.auth.initiator)}};return n.sessionDynamicSubagentSelections!==void 0&&(r.sessionDynamicSubagentSelections={...n.sessionDynamicSubagentSelections}),n.turnDynamicSubagentSelections!==void 0&&(r.turnDynamicSubagentSelections={...n.turnDynamicSubagentSelections}),{...t,lifetime:`session`,task:{...e.task,metadata:{...e.task.metadata},dispatchContext:r}}}function parseTaskOutcome(e){if(!isObject(e)||e.inputRequests!==void 0)return;let t=e.usage;if(t!==void 0&&(!isObject(t)||![t.cacheReadTokens,t.cacheWriteTokens,t.inputTokens,t.outputTokens,...t.costUsd===void 0?[]:[t.costUsd]].every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0)))return;if(e.status===`cancelled`){if(e.lastOutput!==void 0)return}else{if(e.status!==`completed`&&e.status!==`failed`)return;let t=e.status===`completed`?`result`:`error`;if(!isObject(e.lastOutput)||e.lastOutput.type!==t)return}let n={...e};return t!==void 0&&(n.usage={...t}),isObject(e.lastOutput)&&(n.lastOutput={...e.lastOutput}),n}function readWorkflowTaskView(e){if(e.outcome===void 0)return;let t=parseTaskOutcome(e.outcome);if(t===void 0)throw Error(`Corrupt workflow task result "${e.taskId}": invalid outcome.`);return{...t,taskId:e.taskId,metadata:{...e.metadata}}}function readRegistry(e){if(e?.[`eve.tasks`]!==void 0||e?.[`eve.runtime.workflowToolRuns`]!==void 0)throw Error(`Unsupported workflow tool run state: start a new session or import its conversation.`);let t=e?.[WORKFLOW_TOOL_RUNS_STATE_KEY];return t===void 0?{version:3,runs:[]}:parseRegistry(t)}function getWorkflowToolRuns(e){return readRegistry(e).runs}function getBackgroundWorkflowToolRuns(e){return getWorkflowToolRuns(e).filter(e=>e.lifetime===`session`)}function getBlockingWorkflowToolRuns(e,t){return getWorkflowToolRuns(e).filter(e=>e.lifetime===`turn`&&(t===void 0||e.origin.turnId===t))}function findBackgroundWorkflowToolRun(e,t){return getBackgroundWorkflowToolRuns(e).find(e=>e.task.taskId===t)}function writeRegistry(e,t){if(t.runs.length===0){let t={...e};return delete t[WORKFLOW_TOOL_RUNS_STATE_KEY],Object.keys(t).length===0?void 0:t}return{...e,[WORKFLOW_TOOL_RUNS_STATE_KEY]:parseRegistry(t)}}function registerWorkflowToolRun(e,t){let n=readRegistry(e.state),r=[...n.runs],i=r.findIndex(e=>e.origin.turnId===t.origin.turnId&&e.callId===t.callId),a=r[i];if(a!==void 0&&(a.lifetime!==t.lifetime||a.toolName!==t.toolName))throw Error(`Replayed invocation changed its ownership or tool identity.`);if(t.lifetime===`session`){if(a?.lifetime===`session`){if(t.task.taskId!==a.task.taskId)throw Error(`Replayed invocation changed its task identity.`);t={...t,task:{...a.task,...t.task,metadata:{...a.task.metadata,...t.task.metadata},activityWorkIdentity:t.task.activityWorkIdentity===void 0?a.task.activityWorkIdentity:{...a.task.activityWorkIdentity,...t.task.activityWorkIdentity},cohortId:a.task.cohortId,dispatchContext:a.task.dispatchContext,outcome:a.task.outcome??t.task.outcome}}}else{let e=r.find(e=>e.lifetime===`session`&&e.task.outcome===void 0);t={...t,task:{...t.task,cohortId:e===void 0?void 0:e.task.cohortId??e.task.taskId}}}}return t.lifetime===`session`&&readWorkflowTaskView(t.task),a===void 0?r.push(t):r[i]={...a,...t,origin:a.origin,address:{...a.address,...t.address}},{...e,state:writeRegistry(e.state,{...n,runs:r})}}function recordWorkflowTaskView(e,t){let{taskId:n,metadata:r,...i}=t,a=parseTaskOutcome(i);if(!isNonEmptyString(n)||!isTaskMetadata(r)||a===void 0)throw Error(`Invalid terminal workflow task view.`);let o=readRegistry(e),s=[...o.runs],c=s.findIndex(e=>e.lifetime===`session`&&e.task.taskId===n),l=s[c];if(l===void 0||l.lifetime!==`session`)return e;if(!sameTaskMetadata(l.task.metadata,r))throw Error(`Task view metadata does not match invocation "${t.taskId}".`);return readWorkflowTaskView(l.task)===void 0?(s[c]={...l,task:{...l.task,outcome:a}},writeRegistry(e,{...o,runs:s})):e}function removeBlockingWorkflowToolRuns(e,t,n){let r=readRegistry(e.state),i=r.runs,a=i.filter(e=>e.lifetime!==`turn`||e.origin.turnId!==t||n!==void 0&&e.callId!==n);return a.length===i.length?e:{...e,state:writeRegistry(e.state,{...r,runs:a})}}function findBlockingWorkflowToolRun(e,t,n){let r=getBlockingWorkflowToolRuns(e,n).filter(e=>e.callId===t);return r.length===1?r[0]:void 0}function isInboxToolResultFromRecordedWorkflowToolRun(e,t){let n=findBlockingWorkflowToolRun(e,t.callId);return n!==void 0&&n.toolName===t.toolName}export{WORKFLOW_TOOL_RUNS_STATE_KEY,findBackgroundWorkflowToolRun,findBlockingWorkflowToolRun,getBackgroundWorkflowToolRuns,getBlockingWorkflowToolRuns,getWorkflowToolRuns,isInboxToolResultFromRecordedWorkflowToolRun,readWorkflowTaskView,recordWorkflowTaskView,registerWorkflowToolRun,removeBlockingWorkflowToolRuns};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Routes AI SDK provider warnings through eve's logger unless the application
3
+ * already configured the SDK's global warning hook. AI SDK warnings are
4
+ * successful-call diagnostics, so they use the info channel instead of stderr.
5
+ */
6
+ export declare function ensureAiSdkWarningLogger(): void;
@@ -0,0 +1 @@
1
+ import{createLogger}from"#internal/logging.js";const log=createLogger(`harness.ai-sdk-warnings`);function ensureAiSdkWarningLogger(){globalThis.AI_SDK_LOG_WARNINGS===void 0&&(globalThis.AI_SDK_LOG_WARNINGS=process.env.AI_SDK_LOG_WARNINGS!==`false`&&logAiSdkWarnings)}const logAiSdkWarnings=({warnings:e,provider:t,model:n})=>{for(let r of e){let e={model:n,provider:t,warning:r},i=`message`in r?r.message:r.details??r.feature;r.type===`compatibility`?log.info(i,e):log.warn(i,e)}};export{ensureAiSdkWarningLogger};
@@ -73,6 +73,7 @@ export interface InstrumentationRuntime {
73
73
  }
74
74
  /** Worker-bound instrumentation operations consumed by one session execution. */
75
75
  export interface SessionInstrumentation {
76
+ readonly installAiSdkWarningLogger: () => void;
76
77
  readonly runStep: <TSession extends InstrumentedStepSession, TResult>(input: {
77
78
  readonly environment: string;
78
79
  readonly eveVersion: string;
@@ -1 +1 @@
1
- import{recordErrorOnSpan}from"#internal/logging.js";import{applyLiveDeliveryAudienceCeiling}from"#shared/forwarded-trace-policy.js";import{contextStorage}from"#context/container.js";import{ConversationIdKey,ParentSessionKey}from"#context/keys.js";import{createMemoryInstrumentation}from"#instrumentation/memory.js";import{readConversationId}from"#tracing/conversation-context.js";import{readSessionTraceDecision}from"#tracing/agent-trace-context-store.js";import{shouldCaptureInstrumentationContent}from"#shared/instrumentation-content.js";import{isSampledTrace,resolveTracePolicy,resolveTracePolicyDecision}from"#tracing/sampled-trace.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{attemptIdempotencyKey}from"#instrumentation/lifecycle.js";import{createInstrumentationHandleEvent,publishInputResolutions}from"#instrumentation/native-events.js";import{instrumentChannelDelivery}from"#instrumentation/channel-delivery.js";import{buildTelemetryRuntimeContext,snapshotInstrumentationRuntimeContext}from"#instrumentation/runtime-context.js";import{ensureOtelIntegration,getRegisteredTelemetryIntegrations}from"#instrumentation/ai-sdk-telemetry.js";import{createAiSdkHookBridge}from"#instrumentation/ai-sdk-hook-bridge.js";import{createBackgroundTaskInstrumentation}from"#instrumentation/background-task-runtime.js";import{prepareTurnTraceContext}from"#instrumentation/prepare-trace-context.js";import"#tracing/agent-span-id-generator.js";import{withErrorContent}from"#tracing/error-content-context.js";import{readInstrumentationSessionContext}from"#instrumentation/session-context.js";import{readInstrumentationDecision}from"#shared/instrumentation-decision.js";import{getInstrumentationRuntime,registerInstrumentationRuntime}from"#instrumentation/runtime-global.js";import{initializeSessionInstrumentation}from"#instrumentation/session-init.js";const TURN_TRACE_STATE_KEY=`eve.harness.turnTrace`;function bindInstrumentationRuntime(e,t,n){if(readConversationId(t.get(ConversationIdKey))===void 0&&t.set(ConversationIdKey,t.get(ParentSessionKey)?.rootSessionId??n.rootSessionId),e===void 0)return;let r=e.hooks,readSessionContext=()=>readInstrumentationSessionContext(contextStorage.getStore()??t),bindHooks=e=>r.forTrace?.({agentName:n.agentName,...e.conversation})??r,captureExecutionRuntime=()=>{let t=e.otelSettings,n=e.ownsAgentSpans===!0;return t!==void 0&&!n&&ensureOtelIntegration(),{ownsAgentSpans:n,otelSettings:t,runtimeContextResolvers:e.runtimeContextResolvers,tracer:t===void 0?void 0:trace.getTracer(`eve`)}},preparePreamble=(t,r)=>prepareTurnTraceContext({...t,instrumentation:e,principals:r.principals,session:{agentName:n.agentName,channelAudience:r.conversation.audience,channelKind:r.conversation.channel.kind,channelType:r.instrumentation?.channelType,parentLineage:r.parentLineage,parentTraceContext:r.parentTraceContext,rootSessionId:r.parent?.rootSessionId??n.rootSessionId,scheduleId:r.scheduleId,sessionId:n.sessionId,title:r.title,traceSeed:r.traceSeed}}),i=e.memoryOperations===!0?createMemoryInstrumentation({resolveContext:()=>{let e=readSessionContext();return{hooks:bindHooks(e),rootSessionId:e.parent?.rootSessionId??n.rootSessionId}},runInContext:e.runInContext,sessionId:n.sessionId}):void 0,prepareExecution=()=>{let t=captureExecutionRuntime();return{runStep:async(r,i)=>{let a=readSessionContext(),o=bindHooks(a),s=t.otelSettings,c=resolveStepInstrumentationDecision(s,n.agentName,a.conversation,a.traceSeed,readSessionTraceDecision(a.context,n.sessionId)),l=t.tracer,u={"eve.environment":r.environment,"eve.session.id":r.session.sessionId,"eve.version":r.eveVersion},d=s?.functionId??n.agentName;d&&(u[`ai.telemetry.functionId`]=d);let f=l!==void 0&&!t.ownsAgentSpans&&c?.action!==`drop`&&r.hasInput?l.startSpan(`ai.eve.turn`,{attributes:u}):void 0,p=f?.spanContext(),m=p===void 0?r.session:{...r.session,state:{...r.session.state,[TURN_TRACE_STATE_KEY]:{spanId:p.spanId,traceFlags:p.traceFlags,traceId:p.traceId}}},h=f===void 0?void 0:trace.setSpan(context.active(),f);if(h===void 0&&l!==void 0){let e=r.session.state?.[TURN_TRACE_STATE_KEY];e!==void 0&&(h=trace.setSpan(context.active(),trace.wrapSpanContext({...e,isRemote:!0})))}let g=readSessionContext(),_=snapshotInstrumentationRuntimeContext(g.context),v=g.conversation,y=v.audience,b=shouldCaptureInstrumentationContent(v),x=c===void 0?c:applyLiveDeliveryAudienceCeiling(c,y,g.forwardedTracePolicy,v.environment),S=x===void 0?b:x.action===`record`&&x.recordInputs,C=c?.action===`drop`,w={recordInputs:!C&&(x?.action===`record`?x.recordInputs:b)&&(s?.recordInputs??!1),recordOutputs:!C&&(x?.action===`record`?x.recordOutputs:b)&&(s?.recordOutputs??!1)},telemetry=e=>{if(s===void 0&&e.bridgeIntegration===void 0)return;let r={};for(let t of Object.keys(e.runtimeContext??{}))r[t]=!0;let i=s!==void 0&&!(w.recordInputs&&w.recordOutputs),integrations=()=>getRegisteredTelemetryIntegrations({...t.ownsAgentSpans?{excludeEveOtelIntegration:!0}:void 0,sanitizeEveOtelErrors:i});return{functionId:s?.functionId??n.agentName,includeRuntimeContext:r,integrations:e.bridgeIntegration===void 0?i?[...integrations()]:void 0:[e.bridgeIntegration,...integrations()],isEnabled:!0,recordInputs:w.recordInputs,recordOutputs:w.recordOutputs}},run=()=>i({createHandleEvent:e=>createInstrumentationHandleEvent({...e,agentName:n.agentName,channelAudience:y,channelKind:v.channel.kind,hooks:o,parentLineage:g.parentLineage,parentTraceContext:g.parentTraceContext,rootSessionId:g.parent?.rootSessionId,scheduleId:g.scheduleId,sessionId:n.sessionId,title:g.title}),prepareAttempt:t=>{let r={attemptId:`${n.sessionId}:${t.turnId}:${t.stepIndex}:${t.attemptIndex}`,attemptIndex:t.attemptIndex,channelAudience:y,functionId:s?.functionId??n.agentName,rootSessionId:g.parent?.rootSessionId??n.sessionId,sessionId:n.sessionId,stepIndex:t.stepIndex,turnId:t.turnId},i=createAiSdkHookBridge(r,o,e.runInContext,t.runtimeContext);return{complete:()=>o.publish({idempotencyKey:attemptIdempotencyKey(r),scope:r,type:`step.attempt.completed`}),fail:e=>o.publish({error:e,idempotencyKey:attemptIdempotencyKey(r),scope:r,type:`step.attempt.failed`}),scope:r,telemetry:telemetry({bridgeIntegration:i,runtimeContext:t.runtimeContext})}},preparePreamble:e=>preparePreamble(e,g),publishInputResolutions:e=>publishInputResolutions({...e,hooks:o}),recordError:e=>{f!==void 0&&recordErrorOnSpan(f,e)},resolveRuntimeContext:e=>buildTelemetryRuntimeContext({...e,capturesContent:S,context:_,providerResolvers:t.runtimeContextResolvers}),session:m,setTurnId:e=>f?.setAttribute(`eve.turn.id`,e),telemetry:()=>telemetry({}),traceContext:p===void 0||!isValidSpanContext(p)?void 0:{spanId:p.spanId,traceFlags:p.traceFlags,traceId:p.traceId}});try{return await context.with(withErrorContent(h??context.active(),w.recordOutputs),run)}finally{f?.end(),f=void 0}}}};return{...createBackgroundTaskInstrumentation({ctx:t,hooks:()=>bindHooks(readSessionContext()),sessionId:n.sessionId}),createHandleEvent:e=>{let t=readSessionContext();return createInstrumentationHandleEvent({agentName:n.agentName,channelKind:t.conversation.channel.kind,handleEvent:e.handleEvent,hooks:bindHooks(t),scheduleId:t.scheduleId,sessionId:n.sessionId,title:t.title,turnId:e.turnId})},flush:e.forceFlush,instrumentChannelDelivery:e=>instrumentChannelDelivery({...e,hooks:r,policyAgentName:n.agentName}),memory:i,prepareExecution,preparePreamble:e=>preparePreamble(e,readSessionContext())}}function bindSessionInstrumentation(e){return bindInstrumentationRuntime(getInstrumentationRuntime(),e.ctx,{agentName:e.agentName,rootSessionId:e.rootSessionId,sessionId:e.sessionId})}function resolveStepInstrumentationDecision(e,t,n,r,i){if(e!==void 0)return r?.decision===void 0?i===void 0?r===void 0?resolveTracePolicy(e.tracePolicy,{agentName:t,...n}):resolveTracePolicyDecision(isSampledTrace(r),n):i:readInstrumentationDecision(r.decision)}function isValidSpanContext(e){return/^[0-9a-f]{32}$/u.test(e.traceId)&&e.traceId!==`00000000000000000000000000000000`&&/^[0-9a-f]{16}$/u.test(e.spanId)&&e.spanId!==`0000000000000000`}export{bindInstrumentationRuntime,bindSessionInstrumentation,getInstrumentationRuntime,initializeSessionInstrumentation,registerInstrumentationRuntime};
1
+ import{ensureAiSdkWarningLogger}from"#instrumentation/ai-sdk-warnings.js";import{recordErrorOnSpan}from"#internal/logging.js";import{applyLiveDeliveryAudienceCeiling}from"#shared/forwarded-trace-policy.js";import{contextStorage}from"#context/container.js";import{ConversationIdKey,ParentSessionKey}from"#context/keys.js";import{createMemoryInstrumentation}from"#instrumentation/memory.js";import{readConversationId}from"#tracing/conversation-context.js";import{readSessionTraceDecision}from"#tracing/agent-trace-context-store.js";import{shouldCaptureInstrumentationContent}from"#shared/instrumentation-content.js";import{isSampledTrace,resolveTracePolicy,resolveTracePolicyDecision}from"#tracing/sampled-trace.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{attemptIdempotencyKey}from"#instrumentation/lifecycle.js";import{createInstrumentationHandleEvent,publishInputResolutions}from"#instrumentation/native-events.js";import{instrumentChannelDelivery}from"#instrumentation/channel-delivery.js";import{buildTelemetryRuntimeContext,snapshotInstrumentationRuntimeContext}from"#instrumentation/runtime-context.js";import{ensureOtelIntegration,getRegisteredTelemetryIntegrations}from"#instrumentation/ai-sdk-telemetry.js";import{createAiSdkHookBridge}from"#instrumentation/ai-sdk-hook-bridge.js";import{createBackgroundTaskInstrumentation}from"#instrumentation/background-task-runtime.js";import{prepareTurnTraceContext}from"#instrumentation/prepare-trace-context.js";import"#tracing/agent-span-id-generator.js";import{withErrorContent}from"#tracing/error-content-context.js";import{readInstrumentationSessionContext}from"#instrumentation/session-context.js";import{readInstrumentationDecision}from"#shared/instrumentation-decision.js";import{getInstrumentationRuntime,registerInstrumentationRuntime}from"#instrumentation/runtime-global.js";import{initializeSessionInstrumentation}from"#instrumentation/session-init.js";const TURN_TRACE_STATE_KEY=`eve.harness.turnTrace`;function bindInstrumentationRuntime(e,t,n){if(readConversationId(t.get(ConversationIdKey))===void 0&&t.set(ConversationIdKey,t.get(ParentSessionKey)?.rootSessionId??n.rootSessionId),e===void 0)return;let r=e.hooks,readSessionContext=()=>readInstrumentationSessionContext(contextStorage.getStore()??t),bindHooks=e=>r.forTrace?.({agentName:n.agentName,...e.conversation})??r,captureExecutionRuntime=()=>{let t=e.otelSettings,n=e.ownsAgentSpans===!0;return t!==void 0&&!n&&ensureOtelIntegration(),{ownsAgentSpans:n,otelSettings:t,runtimeContextResolvers:e.runtimeContextResolvers,tracer:t===void 0?void 0:trace.getTracer(`eve`)}},preparePreamble=(t,r)=>prepareTurnTraceContext({...t,instrumentation:e,principals:r.principals,session:{agentName:n.agentName,channelAudience:r.conversation.audience,channelKind:r.conversation.channel.kind,channelType:r.instrumentation?.channelType,parentLineage:r.parentLineage,parentTraceContext:r.parentTraceContext,rootSessionId:r.parent?.rootSessionId??n.rootSessionId,scheduleId:r.scheduleId,sessionId:n.sessionId,title:r.title,traceSeed:r.traceSeed}}),i=e.memoryOperations===!0?createMemoryInstrumentation({resolveContext:()=>{let e=readSessionContext();return{hooks:bindHooks(e),rootSessionId:e.parent?.rootSessionId??n.rootSessionId}},runInContext:e.runInContext,sessionId:n.sessionId}):void 0,prepareExecution=()=>{let t=captureExecutionRuntime();return{installAiSdkWarningLogger:ensureAiSdkWarningLogger,runStep:async(r,i)=>{let a=readSessionContext(),o=bindHooks(a),s=t.otelSettings,c=resolveStepInstrumentationDecision(s,n.agentName,a.conversation,a.traceSeed,readSessionTraceDecision(a.context,n.sessionId)),l=t.tracer,u={"eve.environment":r.environment,"eve.session.id":r.session.sessionId,"eve.version":r.eveVersion},d=s?.functionId??n.agentName;d&&(u[`ai.telemetry.functionId`]=d);let f=l!==void 0&&!t.ownsAgentSpans&&c?.action!==`drop`&&r.hasInput?l.startSpan(`ai.eve.turn`,{attributes:u}):void 0,p=f?.spanContext(),m=p===void 0?r.session:{...r.session,state:{...r.session.state,[TURN_TRACE_STATE_KEY]:{spanId:p.spanId,traceFlags:p.traceFlags,traceId:p.traceId}}},h=f===void 0?void 0:trace.setSpan(context.active(),f);if(h===void 0&&l!==void 0){let e=r.session.state?.[TURN_TRACE_STATE_KEY];e!==void 0&&(h=trace.setSpan(context.active(),trace.wrapSpanContext({...e,isRemote:!0})))}let g=readSessionContext(),_=snapshotInstrumentationRuntimeContext(g.context),v=g.conversation,y=v.audience,b=shouldCaptureInstrumentationContent(v),x=c===void 0?c:applyLiveDeliveryAudienceCeiling(c,y,g.forwardedTracePolicy,v.environment),S=x===void 0?b:x.action===`record`&&x.recordInputs,C=c?.action===`drop`,w={recordInputs:!C&&(x?.action===`record`?x.recordInputs:b)&&(s?.recordInputs??!1),recordOutputs:!C&&(x?.action===`record`?x.recordOutputs:b)&&(s?.recordOutputs??!1)},telemetry=e=>{if(s===void 0&&e.bridgeIntegration===void 0)return;let r={};for(let t of Object.keys(e.runtimeContext??{}))r[t]=!0;let i=s!==void 0&&!(w.recordInputs&&w.recordOutputs),integrations=()=>getRegisteredTelemetryIntegrations({...t.ownsAgentSpans?{excludeEveOtelIntegration:!0}:void 0,sanitizeEveOtelErrors:i});return{functionId:s?.functionId??n.agentName,includeRuntimeContext:r,integrations:e.bridgeIntegration===void 0?i?[...integrations()]:void 0:[e.bridgeIntegration,...integrations()],isEnabled:!0,recordInputs:w.recordInputs,recordOutputs:w.recordOutputs}},run=()=>i({createHandleEvent:e=>createInstrumentationHandleEvent({...e,agentName:n.agentName,channelAudience:y,channelKind:v.channel.kind,hooks:o,parentLineage:g.parentLineage,parentTraceContext:g.parentTraceContext,rootSessionId:g.parent?.rootSessionId,scheduleId:g.scheduleId,sessionId:n.sessionId,title:g.title}),prepareAttempt:t=>{let r={attemptId:`${n.sessionId}:${t.turnId}:${t.stepIndex}:${t.attemptIndex}`,attemptIndex:t.attemptIndex,channelAudience:y,functionId:s?.functionId??n.agentName,rootSessionId:g.parent?.rootSessionId??n.sessionId,sessionId:n.sessionId,stepIndex:t.stepIndex,turnId:t.turnId},i=createAiSdkHookBridge(r,o,e.runInContext,t.runtimeContext);return{complete:()=>o.publish({idempotencyKey:attemptIdempotencyKey(r),scope:r,type:`step.attempt.completed`}),fail:e=>o.publish({error:e,idempotencyKey:attemptIdempotencyKey(r),scope:r,type:`step.attempt.failed`}),scope:r,telemetry:telemetry({bridgeIntegration:i,runtimeContext:t.runtimeContext})}},preparePreamble:e=>preparePreamble(e,g),publishInputResolutions:e=>publishInputResolutions({...e,hooks:o}),recordError:e=>{f!==void 0&&recordErrorOnSpan(f,e)},resolveRuntimeContext:e=>buildTelemetryRuntimeContext({...e,capturesContent:S,context:_,providerResolvers:t.runtimeContextResolvers}),session:m,setTurnId:e=>f?.setAttribute(`eve.turn.id`,e),telemetry:()=>telemetry({}),traceContext:p===void 0||!isValidSpanContext(p)?void 0:{spanId:p.spanId,traceFlags:p.traceFlags,traceId:p.traceId}});try{return await context.with(withErrorContent(h??context.active(),w.recordOutputs),run)}finally{f?.end(),f=void 0}}}};return{...createBackgroundTaskInstrumentation({ctx:t,hooks:()=>bindHooks(readSessionContext()),sessionId:n.sessionId}),createHandleEvent:e=>{let t=readSessionContext();return createInstrumentationHandleEvent({agentName:n.agentName,channelKind:t.conversation.channel.kind,handleEvent:e.handleEvent,hooks:bindHooks(t),scheduleId:t.scheduleId,sessionId:n.sessionId,title:t.title,turnId:e.turnId})},flush:e.forceFlush,instrumentChannelDelivery:e=>instrumentChannelDelivery({...e,hooks:r,policyAgentName:n.agentName}),memory:i,prepareExecution,preparePreamble:e=>preparePreamble(e,readSessionContext())}}function bindSessionInstrumentation(e){return bindInstrumentationRuntime(getInstrumentationRuntime(),e.ctx,{agentName:e.agentName,rootSessionId:e.rootSessionId,sessionId:e.sessionId})}function resolveStepInstrumentationDecision(e,t,n,r,i){if(e!==void 0)return r?.decision===void 0?i===void 0?r===void 0?resolveTracePolicy(e.tracePolicy,{agentName:t,...n}):resolveTracePolicyDecision(isSampledTrace(r),n):i:readInstrumentationDecision(r.decision)}function isValidSpanContext(e){return/^[0-9a-f]{32}$/u.test(e.traceId)&&e.traceId!==`00000000000000000000000000000000`&&/^[0-9a-f]{16}$/u.test(e.spanId)&&e.spanId!==`0000000000000000`}export{bindInstrumentationRuntime,bindSessionInstrumentation,getInstrumentationRuntime,initializeSessionInstrumentation,registerInstrumentationRuntime};
@@ -2,6 +2,7 @@ import type { AuthoredWorkflowModules } from "#internal/workflow-bundle/builder-
2
2
  import type { CompileMetadata } from "#compiler/artifacts.js";
3
3
  import type { CompileAgentResult } from "#compiler/compile-agent.js";
4
4
  import type { AgentWorkflowWorldDefinition } from "#shared/agent-definition.js";
5
+ import { type SandboxPreparedArtifactsManifest } from "#shared/sandbox-prepared-artifacts.js";
5
6
  export type BuiltInWorkflowWorldTarget = "local" | "vercel";
6
7
  export interface GeneratedInstrumentationLayout {
7
8
  readonly kind: "directory";
@@ -56,6 +57,7 @@ export declare function createCompiledArtifactsBootstrapSource(input: {
56
57
  installModulePath: string;
57
58
  metadata: CompileMetadata;
58
59
  moduleMapImportPath: string;
60
+ sandboxPreparedArtifacts: SandboxPreparedArtifactsManifest;
59
61
  }): string;
60
62
  export declare function createWorkflowWorldPluginSource(input: {
61
63
  compiledArtifactsBootstrapPath: string;
@@ -1,5 +1,5 @@
1
- import{copyFile,mkdir,writeFile}from"node:fs/promises";import{join}from"node:path";import{resolvePackageCompiledFilePath,resolvePackageSourceFilePath}from"#internal/application/package.js";import{buildPackageUserAgent}from"#internal/user-agent.js";import{stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{prepareAuthoredRuntimeModules}from"#internal/authored-runtime-modules.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import"#internal/instrumentation-layout.js";import{resolveWorkflowWorldImport}from"#internal/workflow/world-target.js";async function writeCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),n=join(e.outDir,`compiled-artifacts-module-map.mjs`),r=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),i=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),a=await prepareAuthoredRuntimeModules({manifest:e.compileResult.manifest,moduleMapPath:e.compileResult.paths.moduleMapPath});await mkdir(e.outDir,{recursive:!0}),await writeFile(n,a.moduleMapCode),await writeFile(t,createCompiledArtifactsBootstrapSource({compileResult:e.compileResult,installModulePath:resolvePackageSourceFilePath(`src/runtime/loaders/bundled-artifacts.ts`),metadata:e.compileResult.metadata,moduleMapImportPath:n})),await writeFile(i,createWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world,defaultWorld:e.defaultWorkflowWorld}));let o={authoredWorkflowModules:a.authoredWorkflowModules,bootstrapPath:t,workflowWorldPluginPath:i},s=await writePreparedInstrumentation({instrumentation:a.instrumentation,outDir:e.outDir});return await writeFile(r,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,layout:s})),o.instrumentationPluginPath=r,o.instrumentationLayout=generatedInstrumentationLayout(s),o.instrumentationSourcePaths=instrumentationSourcePathsOf(s),o}async function writePreparedInstrumentation(e){let writeOne=async(t,n)=>{let r=join(e.outDir,`compiled-artifacts-instrumentation-${t}.mjs`);return await writeFile(r,n),r},t={};for(let[n,r]of Object.entries(e.instrumentation.moduleCodeBySlot))t[n]=await writeOne(n,r);return{kind:`directory`,modulePathsBySlot:t}}function instrumentationSourcePathsOf(e){return Object.values(e.modulePathsBySlot)}async function writeDevelopmentCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),n=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),r=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),i=await readMaterializedAuthoredModuleIndex(e.runtimeAppRoot);if(i===void 0)throw Error(`Development generation at "${e.runtimeAppRoot}" is not materialized.`);await mkdir(e.outDir,{recursive:!0}),await writeFile(t,createDevelopmentCompiledArtifactsBootstrapSource(e.compileResult.manifest.config.name)),await writeFile(r,createDevelopmentWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world}));let a={authoredWorkflowModules:e.authoredWorkflowModules,bootstrapPath:t,workflowWorldPluginPath:r};if(i.instrumentation!==void 0){let t=await copyMaterializedInstrumentation({instrumentation:i.instrumentation,outDir:e.outDir,runtimeAppRoot:e.runtimeAppRoot});await writeFile(n,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,layout:t})),a.instrumentationPluginPath=n,a.instrumentationLayout=generatedInstrumentationLayout(t),a.instrumentationSourcePaths=instrumentationSourcePathsOf(t)}return a}function generatedInstrumentationLayout(e){return{kind:`directory`,slots:Object.keys(e.modulePathsBySlot)}}async function copyMaterializedInstrumentation(e){let t=join(e.runtimeAppRoot,`.eve`,`compile`),copyOne=async(n,r)=>{let i=join(e.outDir,`compiled-artifacts-instrumentation-${n}.mjs`);return await copyFile(join(t,r),i),i},n={};for(let[t,r]of Object.entries(e.instrumentation.modulePathsBySlot))n[t]=await copyOne(t,r);return{kind:`directory`,modulePathsBySlot:n}}function createDevelopmentCompiledArtifactsBootstrapSource(e){return[`// Generated by eve. Do not edit by hand.`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,``,`installEveWorkflowQueueNamespace(${JSON.stringify(e)});`,``,`export default function installDevelopmentCompiledArtifactsPlugin() {}`,``].join(`
2
- `)}function createCompiledArtifactsBootstrapSource(e){let t=e.compileResult.manifest.config.name;return[`// Generated by eve. Do not edit by hand.`,`import moduleMap from ${stringifyEsmImportSpecifier(e.moduleMapImportPath)};`,`import { installBundledCompiledArtifacts } from ${stringifyEsmImportSpecifier(e.installModulePath)};`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,``,`installEveWorkflowQueueNamespace(${JSON.stringify(t)});`,``,`const metadata = ${JSON.stringify(e.metadata,null,2)};`,``,`const manifest = ${JSON.stringify(e.compileResult.manifest,null,2)};`,``,`export { moduleMap };`,``,`export function installCompiledArtifactsBootstrap() {`,` installBundledCompiledArtifacts({`,` manifest,`,` metadata,`,` moduleMap,`,` });`,`}`,``,`installCompiledArtifactsBootstrap();`,``,`// Default export satisfies the Nitro plugin contract so this file`,`// can be used directly as a Nitro plugin without a separate wrapper.`,`export default function installCompiledArtifactsPlugin() {`,` // Already installed on import above.`,`}`,``].join(`
1
+ import{copyFile,mkdir,readFile,writeFile}from"node:fs/promises";import{join}from"node:path";import{resolvePackageCompiledFilePath,resolvePackageSourceFilePath}from"#internal/application/package.js";import{buildPackageUserAgent}from"#internal/user-agent.js";import{sandboxPreparedArtifactsManifestSchema}from"#shared/sandbox-prepared-artifacts.js";import{stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{prepareAuthoredRuntimeModules}from"#internal/authored-runtime-modules.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import"#internal/instrumentation-layout.js";import{resolveWorkflowWorldImport}from"#internal/workflow/world-target.js";async function writeCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),n=join(e.outDir,`compiled-artifacts-module-map.mjs`),r=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),i=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),a=sandboxPreparedArtifactsManifestSchema.parse(JSON.parse(await readFile(e.compileResult.paths.sandboxPreparedArtifactsPath,`utf8`))),o=await prepareAuthoredRuntimeModules({manifest:e.compileResult.manifest,moduleMapPath:e.compileResult.paths.moduleMapPath});await mkdir(e.outDir,{recursive:!0}),await writeFile(n,o.moduleMapCode),await writeFile(t,createCompiledArtifactsBootstrapSource({compileResult:e.compileResult,installModulePath:resolvePackageSourceFilePath(`src/runtime/loaders/bundled-artifacts.ts`),metadata:e.compileResult.metadata,moduleMapImportPath:n,sandboxPreparedArtifacts:a})),await writeFile(i,createWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world,defaultWorld:e.defaultWorkflowWorld}));let s={authoredWorkflowModules:o.authoredWorkflowModules,bootstrapPath:t,workflowWorldPluginPath:i},c=await writePreparedInstrumentation({instrumentation:o.instrumentation,outDir:e.outDir});return await writeFile(r,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,layout:c})),s.instrumentationPluginPath=r,s.instrumentationLayout=generatedInstrumentationLayout(c),s.instrumentationSourcePaths=instrumentationSourcePathsOf(c),s}async function writePreparedInstrumentation(e){let writeOne=async(t,n)=>{let r=join(e.outDir,`compiled-artifacts-instrumentation-${t}.mjs`);return await writeFile(r,n),r},t={};for(let[n,r]of Object.entries(e.instrumentation.moduleCodeBySlot))t[n]=await writeOne(n,r);return{kind:`directory`,modulePathsBySlot:t}}function instrumentationSourcePathsOf(e){return Object.values(e.modulePathsBySlot)}async function writeDevelopmentCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),n=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),r=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),i=await readMaterializedAuthoredModuleIndex(e.runtimeAppRoot);if(i===void 0)throw Error(`Development generation at "${e.runtimeAppRoot}" is not materialized.`);await mkdir(e.outDir,{recursive:!0}),await writeFile(t,createDevelopmentCompiledArtifactsBootstrapSource(e.compileResult.manifest.config.name)),await writeFile(r,createDevelopmentWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world}));let a={authoredWorkflowModules:e.authoredWorkflowModules,bootstrapPath:t,workflowWorldPluginPath:r};if(i.instrumentation!==void 0){let t=await copyMaterializedInstrumentation({instrumentation:i.instrumentation,outDir:e.outDir,runtimeAppRoot:e.runtimeAppRoot});await writeFile(n,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,layout:t})),a.instrumentationPluginPath=n,a.instrumentationLayout=generatedInstrumentationLayout(t),a.instrumentationSourcePaths=instrumentationSourcePathsOf(t)}return a}function generatedInstrumentationLayout(e){return{kind:`directory`,slots:Object.keys(e.modulePathsBySlot)}}async function copyMaterializedInstrumentation(e){let t=join(e.runtimeAppRoot,`.eve`,`compile`),copyOne=async(n,r)=>{let i=join(e.outDir,`compiled-artifacts-instrumentation-${n}.mjs`);return await copyFile(join(t,r),i),i},n={};for(let[t,r]of Object.entries(e.instrumentation.modulePathsBySlot))n[t]=await copyOne(t,r);return{kind:`directory`,modulePathsBySlot:n}}function createDevelopmentCompiledArtifactsBootstrapSource(e){return[`// Generated by eve. Do not edit by hand.`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,``,`installEveWorkflowQueueNamespace(${JSON.stringify(e)});`,``,`export default function installDevelopmentCompiledArtifactsPlugin() {}`,``].join(`
2
+ `)}function createCompiledArtifactsBootstrapSource(e){let t=e.compileResult.manifest.config.name;return[`// Generated by eve. Do not edit by hand.`,`import moduleMap from ${stringifyEsmImportSpecifier(e.moduleMapImportPath)};`,`import { installBundledCompiledArtifacts } from ${stringifyEsmImportSpecifier(e.installModulePath)};`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,``,`installEveWorkflowQueueNamespace(${JSON.stringify(t)});`,``,`const metadata = ${JSON.stringify(e.metadata,null,2)};`,``,`const manifest = ${JSON.stringify(e.compileResult.manifest,null,2)};`,``,`const sandboxPreparedArtifacts = ${JSON.stringify(e.sandboxPreparedArtifacts,null,2)};`,``,`export { moduleMap };`,``,`export function installCompiledArtifactsBootstrap() {`,` installBundledCompiledArtifacts({`,` manifest,`,` metadata,`,` moduleMap,`,` sandboxPreparedArtifacts,`,` });`,`}`,``,`installCompiledArtifactsBootstrap();`,``,`// Default export satisfies the Nitro plugin contract so this file`,`// can be used directly as a Nitro plugin without a separate wrapper.`,`export default function installCompiledArtifactsPlugin() {`,` // Already installed on import above.`,`}`,``].join(`
3
3
  `)}function resolveWorkflowWorldWiring(e){if(e===`@workflow/world-local`){let t=stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/local-world-data-directory.ts`)),n=stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/local-world-delivery-timeouts.ts`));return{moduleImportSpecifier:resolvePackageCompiledFilePath(`src/compiled/${e}/index.js`),extraImportLines:`
4
4
  import { applyLocalWorkflowWorldDeliveryTimeoutDefaults } from ${n};
5
5
  import { resolveLocalWorkflowWorldDataDirectory } from ${t};`.trimStart().split(`
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.62.0`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function tryResolveVerifiedPackageRoot(e){try{let t=realpathSync.native(e);return tryReadInstalledPackageInfo(t,EVE_PACKAGE_NAME)===void 0?void 0:dirname(t)}catch{return}}function findNearestVerifiedPackageRoot(e){let t=e;for(;;){let e=tryResolveVerifiedPackageRoot(join(t,`package.json`));if(e!==void 0)return e;let n=dirname(t);if(n===t)return;t=n}}function tryResolveDirectBuildLocation(e){let t=dirname(e);for(;;){if(basename(t)===`dist`){let e=tryResolveVerifiedPackageRoot(join(dirname(t),`package.json`));if(e!==void 0)return{packageBuildRoot:t,packageRoot:e}}let e=dirname(t);if(e===t)return;t=e}}function isSourceCheckout(e){return existsSync(join(e,`src`,`internal`,`application`,`package.ts`))}function tryCreatePackageLocation(e){if(isSourceCheckout(e))return{packageBuildRoot:null,packageRoot:e};let t=join(e,`dist`);if(existsSync(t))return{packageBuildRoot:t,packageRoot:e}}function resolveSelfPackageJsonPath(e){return createRequire(e).resolve(`${EVE_PACKAGE_NAME}/package.json`)}function resolvePackageLocationFromModulePath(e,t=resolveSelfPackageJsonPath){let n=realpathSync.native(e),r=tryResolveDirectBuildLocation(n);if(r!==void 0)return r;let i=findNearestVerifiedPackageRoot(dirname(n));if(i!==void 0&&isSourceCheckout(i))return{packageBuildRoot:null,packageRoot:i};try{let e=tryResolveVerifiedPackageRoot(t(n)),r=e===void 0?void 0:tryCreatePackageLocation(e);if(r!==void 0)return r}catch{}let a=i===void 0?void 0:tryCreatePackageLocation(i);if(a!==void 0)return a;throw Error(`Failed to resolve the eve package root from "${e}".`)}function resolvePackageLocation(){return cachedPackageLocation??=resolvePackageLocationFromModulePath(resolveCurrentModulePath()),cachedPackageLocation}function resolvePackageBuildRoot(){return resolvePackageLocation().packageBuildRoot}function resolvePackageRoot(){return resolvePackageLocation().packageRoot}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(typeof t.name==`string`&&typeof t.version==`string`)return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageLocationFromModulePath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
1
+ import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.64.0`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function tryResolveVerifiedPackageRoot(e){try{let t=realpathSync.native(e);return tryReadInstalledPackageInfo(t,EVE_PACKAGE_NAME)===void 0?void 0:dirname(t)}catch{return}}function findNearestVerifiedPackageRoot(e){let t=e;for(;;){let e=tryResolveVerifiedPackageRoot(join(t,`package.json`));if(e!==void 0)return e;let n=dirname(t);if(n===t)return;t=n}}function tryResolveDirectBuildLocation(e){let t=dirname(e);for(;;){if(basename(t)===`dist`){let e=tryResolveVerifiedPackageRoot(join(dirname(t),`package.json`));if(e!==void 0)return{packageBuildRoot:t,packageRoot:e}}let e=dirname(t);if(e===t)return;t=e}}function isSourceCheckout(e){return existsSync(join(e,`src`,`internal`,`application`,`package.ts`))}function tryCreatePackageLocation(e){if(isSourceCheckout(e))return{packageBuildRoot:null,packageRoot:e};let t=join(e,`dist`);if(existsSync(t))return{packageBuildRoot:t,packageRoot:e}}function resolveSelfPackageJsonPath(e){return createRequire(e).resolve(`${EVE_PACKAGE_NAME}/package.json`)}function resolvePackageLocationFromModulePath(e,t=resolveSelfPackageJsonPath){let n=realpathSync.native(e),r=tryResolveDirectBuildLocation(n);if(r!==void 0)return r;let i=findNearestVerifiedPackageRoot(dirname(n));if(i!==void 0&&isSourceCheckout(i))return{packageBuildRoot:null,packageRoot:i};try{let e=tryResolveVerifiedPackageRoot(t(n)),r=e===void 0?void 0:tryCreatePackageLocation(e);if(r!==void 0)return r}catch{}let a=i===void 0?void 0:tryCreatePackageLocation(i);if(a!==void 0)return a;throw Error(`Failed to resolve the eve package root from "${e}".`)}function resolvePackageLocation(){return cachedPackageLocation??=resolvePackageLocationFromModulePath(resolveCurrentModulePath()),cachedPackageLocation}function resolvePackageBuildRoot(){return resolvePackageLocation().packageBuildRoot}function resolvePackageRoot(){return resolvePackageLocation().packageRoot}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(typeof t.name==`string`&&typeof t.version==`string`)return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageLocationFromModulePath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
@@ -1 +1 @@
1
- import{randomUUID}from"node:crypto";import{cp,mkdir,readFile,rm,symlink,writeFile}from"node:fs/promises";import{dirname,join,relative,resolve,sep}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{existsSync,readFileSync}from"node:fs";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createDevelopmentSourceSnapshotPlan,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts-retention.js";const DEV_RUNTIME_ARTIFACTS_DIRECTORY=`dev-runtime`;function resolveDevelopmentRuntimeArtifactsPointerPath(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`current.json`)}function resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`snapshots`)}function isDevelopmentRuntimeArtifactsSnapshotRoot(e,t){return dirname(resolve(t))===resolve(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e))}async function stageDevelopmentRuntimeArtifactsSnapshot(e){let t=join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.project.appRoot),`${Date.now().toString(36)}-${randomUUID()}`),n=await createDevelopmentSourceSnapshotPlan({appRoot:e.project.appRoot,authoredSourceRoots:collectExtensionMountSourceRoots(e.manifest),snapshotRoot:t});try{await copyDevelopmentSourceSnapshot(n),await mountFrameworkPackage(n.runtimeAppRoot),await mountExtensionExternalDependencies({manifest:e.manifest,runtimeAppRoot:n.runtimeAppRoot}),await cp(e.paths.compileDirectoryPath,join(n.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,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`),runtimeAppRoot:n.runtimeAppRoot}),await writeFile(join(t,`generation.json`),`${JSON.stringify({runtimeAppRoot:n.runtimeAppRoot})}\n`)}catch(e){throw await rm(t,{force:!0,recursive:!0}).catch(()=>{}),e}return{sourceWatchPaths:n.watchPaths,runtimeAppRoot:n.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}}async function mountFrameworkPackage(e){let t=join(e,`node_modules`,`eve`);await mkdir(dirname(t),{recursive:!0}),await rm(t,{force:!0,recursive:!0}),await symlink(resolvePackageRoot(),t,`junction`)}async function mountExtensionExternalDependencies(e){if(e.manifest===void 0)return;let t=[e.manifest,...(e.manifest.subagents??[]).map(e=>e.agent)].flatMap(e=>e.extensionMounts??[]).filter(e=>(e.externalDependencies??[]).length>0);for(let[n,r]of Object.entries(resolveExtensionExternalDependencyPaths(t))){let t=findPackageRoot(r,n),i=join(e.runtimeAppRoot,`node_modules`,...n.split(`/`));await mkdir(dirname(i),{recursive:!0}),await rm(i,{force:!0,recursive:!0}),await symlink(t,i,`junction`)}}function findPackageRoot(e,t){let n=dirname(e);for(;;){let e=join(n,`package.json`);if(existsSync(e))try{if(JSON.parse(readFileSync(e,`utf8`)).name===t)return n}catch{}let r=dirname(n);if(r===n)throw Error(`Cannot locate package root for extension external dependency "${t}".`);n=r}}async function activateDevelopmentRuntimeArtifactsSnapshot(e){(await activateDevelopmentRuntimeArtifactsSnapshotTransaction(e)).commit()}async function activateDevelopmentRuntimeArtifactsSnapshotTransaction(e){let t=await readMaterializedAuthoredModuleIndex(e.snapshot.runtimeAppRoot);if(t===void 0||!existsSync(join(e.snapshot.runtimeAppRoot,`.eve`,`compile`,t.moduleMap)))throw Error(`Cannot activate development runtime generation "${e.snapshot.snapshotRoot}" before its authored modules are materialized.`);let n=join(e.snapshot.snapshotRoot,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),r=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),i=readDevelopmentRuntimeArtifactsPointer(r),a=await readOptionalFile(r);try{await writeFile(n,``),await writeDevelopmentRuntimeArtifactsPointer(e),i?.version===2&&i.snapshotRoot!==e.snapshot.snapshotRoot&&isDevelopmentRuntimeArtifactsSnapshotRoot(e.appRoot,i.snapshotRoot)&&await recordRetiredDevelopmentRuntimeArtifactsSnapshot(i.snapshotRoot).catch(e=>{console.warn(`[eve:dev] failed to record retired runtime generation "${i.snapshotRoot}": ${String(e)}`)})}catch(e){throw await rollbackFailedActivation({cause:e,markerPath:n,pointerPath:r,previousPointerSource:a})}let o=!1;return{commit(){o=!0},async rollback(){if(o)return;o=!0;let e=await restoreDevelopmentRuntimeArtifactsActivation({markerPath:n,pointerPath:r,previousPointerSource:a});if(e!==void 0)throw e}}}function readDevelopmentRuntimeArtifactsSnapshotRoot(e){let t=readDevelopmentRuntimeArtifactsPointer(e);if(t!==void 0)return t.version===1?t.appRoot:t.runtimeAppRoot}function readActiveDevelopmentRuntimeArtifactsSnapshot(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e));if(t!==void 0&&t.version!==1)return{runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot}}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function pruneDevelopmentRuntimeArtifactsSnapshots(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot));await pruneDevelopmentRuntimeArtifactsSnapshotDirectory({activeSnapshotRoot:t?.version===2?t.snapshotRoot:void 0,gracePeriodMs:e.gracePeriodMs,now:e.now,protectAll:t?.version===1,retainCount:e.retainCount,snapshotsDirectory:resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.appRoot)})}function collectExtensionMountSourceRoots(e){return e===void 0?[]:[e,...(e.subagents??[]).map(e=>e.agent)].flatMap(e=>(e.extensionMounts??[]).map(e=>e.sourceRoot))}function readDevelopmentRuntimeArtifactsPointer(e){if(e!==void 0&&existsSync(e))try{let t=JSON.parse(readFileSync(e,`utf8`));return t.kind!==`eve-dev-runtime-artifacts-pointer`||typeof t.version!=`number`?void 0:t.version===1&&typeof t.appRoot==`string`&&t.appRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:t.version===2&&typeof t.appRoot==`string`&&typeof t.runtimeAppRoot==`string`&&t.runtimeAppRoot.length>0&&typeof t.snapshotRoot==`string`&&t.snapshotRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot,version:2}:void 0}catch{return}}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,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]=rewritePathWithinAppRoot({appRoot:e.appRoot,path:r,runtimeAppRoot:e.runtimeAppRoot});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,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))return e.path;let t=relative(e.appRoot,e.path);return t.length===0?e.runtimeAppRoot:join(e.runtimeAppRoot,t)}async function writeDevelopmentRuntimeArtifactsPointer(e){let t=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),n={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await writeDevelopmentRuntimeArtifactsPointerSource(t,`${JSON.stringify(n,null,2)}\n`)}async function writeDevelopmentRuntimeArtifactsPointerSource(e,t){let 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.runtimeAppRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime app root "${e.runtimeAppRoot}".`)}function collectManifestRootPaths(e){if(Array.isArray(e))return e.flatMap(e=>collectManifestRootPaths(e));if(typeof e!=`object`||!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if((n===`appRoot`||n===`agentRoot`)&&typeof r==`string`){t.push(r);continue}t.push(...collectManifestRootPaths(r))}return t}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{activateDevelopmentRuntimeArtifactsSnapshot,activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,readActiveDevelopmentRuntimeArtifactsSnapshot,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
1
+ import{randomUUID}from"node:crypto";import{cp,mkdir,readFile,rm,symlink,writeFile}from"node:fs/promises";import{dirname,join,relative,resolve,sep}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{existsSync,readFileSync}from"node:fs";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createDevelopmentSourceSnapshotPlan,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts-retention.js";const DEV_RUNTIME_ARTIFACTS_DIRECTORY=`dev-runtime`;function resolveDevelopmentRuntimeArtifactsPointerPath(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`current.json`)}function resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`snapshots`)}function isDevelopmentRuntimeArtifactsSnapshotRoot(e,t){return dirname(resolve(t))===resolve(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e))}async function stageDevelopmentRuntimeArtifactsSnapshot(e){let t=join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.project.appRoot),`${Date.now().toString(36)}-${randomUUID()}`),n=await createDevelopmentSourceSnapshotPlan({appRoot:e.project.appRoot,authoredSourceRoots:collectExtensionMountSourceRoots(e.manifest),snapshotRoot:t});try{await copyDevelopmentSourceSnapshot(n),await mountFrameworkPackage(n.runtimeAppRoot),await mountExtensionExternalDependencies({manifest:e.manifest,runtimeAppRoot:n.runtimeAppRoot}),await cp(e.paths.compileDirectoryPath,join(n.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),snapshotSourceRoot:n.snapshotSourceRoot}),await writeFile(join(t,`generation.json`),`${JSON.stringify({runtimeAppRoot:n.runtimeAppRoot})}\n`)}catch(e){throw await rm(t,{force:!0,recursive:!0}).catch(()=>{}),e}return{sourceWatchPaths:n.watchPaths,runtimeAppRoot:n.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}}async function mountFrameworkPackage(e){let t=join(e,`node_modules`,`eve`);await mkdir(dirname(t),{recursive:!0}),await rm(t,{force:!0,recursive:!0}),await symlink(resolvePackageRoot(),t,`junction`)}async function mountExtensionExternalDependencies(e){if(e.manifest===void 0)return;let t=[e.manifest,...(e.manifest.subagents??[]).map(e=>e.agent)].flatMap(e=>e.extensionMounts??[]).filter(e=>(e.externalDependencies??[]).length>0);for(let[n,r]of Object.entries(resolveExtensionExternalDependencyPaths(t))){let t=findPackageRoot(r,n),i=join(e.runtimeAppRoot,`node_modules`,...n.split(`/`));await mkdir(dirname(i),{recursive:!0}),await rm(i,{force:!0,recursive:!0}),await symlink(t,i,`junction`)}}function findPackageRoot(e,t){let n=dirname(e);for(;;){let e=join(n,`package.json`);if(existsSync(e))try{if(JSON.parse(readFileSync(e,`utf8`)).name===t)return n}catch{}let r=dirname(n);if(r===n)throw Error(`Cannot locate package root for extension external dependency "${t}".`);n=r}}async function activateDevelopmentRuntimeArtifactsSnapshot(e){(await activateDevelopmentRuntimeArtifactsSnapshotTransaction(e)).commit()}async function activateDevelopmentRuntimeArtifactsSnapshotTransaction(e){let t=await readMaterializedAuthoredModuleIndex(e.snapshot.runtimeAppRoot);if(t===void 0||!existsSync(join(e.snapshot.runtimeAppRoot,`.eve`,`compile`,t.moduleMap)))throw Error(`Cannot activate development runtime generation "${e.snapshot.snapshotRoot}" before its authored modules are materialized.`);let n=join(e.snapshot.snapshotRoot,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),r=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),i=readDevelopmentRuntimeArtifactsPointer(r),a=await readOptionalFile(r);try{await writeFile(n,``),await writeDevelopmentRuntimeArtifactsPointer(e),i?.version===2&&i.snapshotRoot!==e.snapshot.snapshotRoot&&isDevelopmentRuntimeArtifactsSnapshotRoot(e.appRoot,i.snapshotRoot)&&await recordRetiredDevelopmentRuntimeArtifactsSnapshot(i.snapshotRoot).catch(e=>{console.warn(`[eve:dev] failed to record retired runtime generation "${i.snapshotRoot}": ${String(e)}`)})}catch(e){throw await rollbackFailedActivation({cause:e,markerPath:n,pointerPath:r,previousPointerSource:a})}let o=!1;return{commit(){o=!0},async rollback(){if(o)return;o=!0;let e=await restoreDevelopmentRuntimeArtifactsActivation({markerPath:n,pointerPath:r,previousPointerSource:a});if(e!==void 0)throw e}}}function readDevelopmentRuntimeArtifactsSnapshotRoot(e){let t=readDevelopmentRuntimeArtifactsPointer(e);if(t!==void 0)return t.version===1?t.appRoot:t.runtimeAppRoot}function readActiveDevelopmentRuntimeArtifactsSnapshot(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e));if(t!==void 0&&t.version!==1)return{runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot}}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function pruneDevelopmentRuntimeArtifactsSnapshots(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot));await pruneDevelopmentRuntimeArtifactsSnapshotDirectory({activeSnapshotRoot:t?.version===2?t.snapshotRoot:void 0,gracePeriodMs:e.gracePeriodMs,now:e.now,protectAll:t?.version===1,retainCount:e.retainCount,snapshotsDirectory:resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.appRoot)})}function collectExtensionMountSourceRoots(e){return e===void 0?[]:[e,...(e.subagents??[]).map(e=>e.agent)].flatMap(e=>(e.extensionMounts??[]).map(e=>e.sourceRoot))}function readDevelopmentRuntimeArtifactsPointer(e){if(e!==void 0&&existsSync(e))try{let t=JSON.parse(readFileSync(e,`utf8`));return t.kind!==`eve-dev-runtime-artifacts-pointer`||typeof t.version!=`number`?void 0:t.version===1&&typeof t.appRoot==`string`&&t.appRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:t.version===2&&typeof t.appRoot==`string`&&typeof t.runtimeAppRoot==`string`&&t.runtimeAppRoot.length>0&&typeof t.snapshotRoot==`string`&&t.snapshotRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot,version:2}:void 0}catch{return}}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,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)?rewritePathWithinAppRoot({appRoot:e.appRoot,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,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))return e.path;let t=relative(e.appRoot,e.path);return t.length===0?e.runtimeAppRoot:join(e.runtimeAppRoot,t)}async function writeDevelopmentRuntimeArtifactsPointer(e){let t=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),n={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await writeDevelopmentRuntimeArtifactsPointerSource(t,`${JSON.stringify(n,null,2)}\n`)}async function writeDevelopmentRuntimeArtifactsPointerSource(e,t){let n=`${e}.${randomUUID()}.tmp`;await mkdir(dirname(e),{recursive:!0}),await writeFile(n,t);try{await renameWithTransientBusyRetry(n,e)}catch(e){throw await rm(n,{force:!0}).catch(()=>{}),e}}async function readOptionalFile(e){try{return await readFile(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}}async function rollbackFailedActivation(e){let t=await restoreDevelopmentRuntimeArtifactsActivation(e);return t===void 0?e.cause:AggregateError([e.cause,t],`Development runtime activation and rollback failed.`,{cause:e.cause})}async function restoreDevelopmentRuntimeArtifactsActivation(e){let t=(await Promise.allSettled([e.previousPointerSource===void 0?rm(e.pointerPath,{force:!0}):writeDevelopmentRuntimeArtifactsPointerSource(e.pointerPath,e.previousPointerSource),rm(e.markerPath,{force:!0})])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length!==0)return AggregateError(t,`Failed to restore development runtime activation.`)}async function validateSnapshotCompiledManifestRoots(e){let t=collectManifestRootPaths(JSON.parse(await readFile(e.manifestPath,`utf8`)));for(let n of t)if(!isPathInsideOrEqual(n,e.snapshotSourceRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime snapshot source root "${e.snapshotSourceRoot}".`)}function collectManifestRootPaths(e){if(Array.isArray(e))return e.flatMap(e=>collectManifestRootPaths(e));if(typeof e!=`object`||!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if((n===`appRoot`||n===`agentRoot`)&&typeof r==`string`){t.push(r);continue}t.push(...collectManifestRootPaths(r))}return t}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{activateDevelopmentRuntimeArtifactsSnapshot,activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,readActiveDevelopmentRuntimeArtifactsSnapshot,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
@@ -5,6 +5,11 @@ import type { AgentWorkflowWorldDefinition } from "#shared/agent-definition.js";
5
5
  * artifacts from the authored app root via the snapshot pointer so hot
6
6
  * reload can swap them.
7
7
  */
8
+ export declare function createDevelopmentGenerationArtifactsSource(input: {
9
+ readonly appRoot: string;
10
+ readonly configuredWorld?: AgentWorkflowWorldDefinition;
11
+ readonly runtimeAppRoot: string;
12
+ }): import("#runtime/compiled-artifacts-source.js").RuntimeDiskCompiledArtifactsSource;
8
13
  export declare function createDevelopmentNitroArtifactsConfig(input: {
9
14
  readonly appRoot: string;
10
15
  readonly configuredWorld?: AgentWorkflowWorldDefinition;
@@ -13,4 +18,4 @@ export declare function createDevelopmentNitroArtifactsConfig(input: {
13
18
  * Runtime-artifacts wiring for built output: routes require the artifacts
14
19
  * bundled into the server at build time and never touch the filesystem.
15
20
  */
16
- export declare function createProductionNitroArtifactsConfig(): ProductionNitroArtifactsConfig;
21
+ export declare function createProductionNitroArtifactsConfig(appRoot: string): ProductionNitroArtifactsConfig;
@@ -1 +1 @@
1
- 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 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(){return{kind:`production`}}export{createDevelopmentNitroArtifactsConfig,createProductionNitroArtifactsConfig};
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 +1 @@
1
- import{readFile}from"node:fs/promises";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isObject}from"#shared/guards.js";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{toErrorMessage}from"#shared/errors.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{ApplicationBuildProfiler,createApplicationBuildProfile,measureApplicationBuildOutput,writeApplicationBuildProfile}from"#internal/application/build-profile.js";import{RecoverablePublicationError,publishApplicationBuildArtifacts}from"#internal/application/output-publication.js";import{stageProductionCompilerArtifacts}from"#internal/application/production-compiler-artifacts.js";import{materializeVercelWorkflowFunctionOutput,normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{copyHostMiddlewareFunctions}from"#internal/nitro/host/copy-host-middleware.js";import{normalizeVercelServiceCrons}from"#internal/nitro/host/normalize-vercel-service-crons.js";import{prepareProductionApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-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=await measureBuildPhase(n,`nitro.create`,()=>createProductionApplicationNitro(r,{buildDir:e.nitro.buildDir,outputDir:e.publication.output.stagedDir,publicRoutePrefix:c,workspaceMember:t.workspaceMember}));try{i&&!t.skipVercelSandboxPrewarm&&await measureBuildPhase(n,`sandbox.prewarm`,()=>runVercelBuildPrewarm({appRoot:r.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(e.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:r.appRoot}),log(e){console.log(e)}})),await buildNitroOutput(l,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})),i||await measureBuildPhase(n,`compiler-artifacts.stage`,()=>stageProductionCompilerArtifacts({compilerArtifactsRoot:e.compiler.artifactsDir,outputDir:e.publication.output.stagedDir}))}finally{await measureBuildPhase(n,`nitro.close`,()=>l.close())}return await measureBuildPhase(n,`output.publish`,()=>publishCompletedApplicationBuild(e)),e.publication.output.finalDir}async function publishCompletedApplicationBuild(e){await publishApplicationBuildArtifacts({appRoot:e.appRoot,finalOutputDir:e.publication.output.finalDir,finalSummaryPath:e.publication.summary.finalPath,scratchDir:e.rootDir,stagedOutputDir:e.publication.output.stagedDir,stagedSummaryPath:e.publication.summary.stagedPath})}export{buildApplication};
1
+ import{readFile}from"node:fs/promises";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isObject}from"#shared/guards.js";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{toErrorMessage}from"#shared/errors.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{ApplicationBuildProfiler,createApplicationBuildProfile,measureApplicationBuildOutput,writeApplicationBuildProfile}from"#internal/application/build-profile.js";import{RecoverablePublicationError,publishApplicationBuildArtifacts}from"#internal/application/output-publication.js";import{stageProductionCompilerArtifacts}from"#internal/application/production-compiler-artifacts.js";import{materializeVercelWorkflowFunctionOutput,normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{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})),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};
@@ -0,0 +1,16 @@
1
+ interface BundlerPluginShape {
2
+ readonly enforce?: "pre";
3
+ readonly name: string;
4
+ load?(id: string): string | null | undefined;
5
+ resolveId?(source: string, importer: string | undefined): string | {
6
+ id: string;
7
+ } | null | undefined;
8
+ }
9
+ /**
10
+ * Creates the bundler plugin that prunes the local sandbox providers
11
+ * (Docker, just-bash, microsandbox) from hosted Nitro server bundles.
12
+ * Stubs both the aggregate local facade and individual provider bindings so
13
+ * framework default selection cannot retain local engine implementations.
14
+ */
15
+ export declare function createCompiledSandboxProviderPrunePlugin(): BundlerPluginShape;
16
+ export {};
@@ -0,0 +1,5 @@
1
+ const PRUNED_DEFAULT_SANDBOX_MODULE_ID=`\0eve-pruned-default-sandbox-provider`,PRUNED_LOCAL_SANDBOX_MODULE_ID=`\0eve-pruned-local-sandbox-providers`,PRUNED_LOCAL_SANDBOX_PROVIDER_MODULE_ID=`\0eve-pruned-local-sandbox-provider-constructors`,PRUNED_OPTIONAL_ENGINE_INSTALL_MODULE_ID=`\0eve-pruned-optional-engine-install`,DEFAULT_PROVIDER_SOURCE_RE=/(?:^|[/\\#])sandbox[/\\]providers[/\\]default\.(?:js|ts)$/,LOCAL_BINDING_SOURCE_RE=/[/\\]bindings[/\\](?:docker|just-bash|local|microsandbox)\.(?:js|ts)$/,LOCAL_PROVIDER_SOURCE_RE=/(?:^|[/\\#])sandbox[/\\]providers[/\\](?:docker|just-bash|microsandbox)\.(?:js|ts)$/,OPTIONAL_ENGINE_INSTALL_SOURCE_RE=/[/\\]internal[/\\]application[/\\]optional-package-install\.(?:js|ts)$/;function createCompiledSandboxProviderPrunePlugin(){return{enforce:`pre`,name:`eve-hosted-sandbox-provider-prune`,load(e){let t=e.split(/[?#]/u,1)[0]??e;return e===PRUNED_DEFAULT_SANDBOX_MODULE_ID||DEFAULT_PROVIDER_SOURCE_RE.test(t)?[`import { createDefaultVercelEnvironment } from "#sandbox/providers/vercel.js";`,`function environment(options = {}) {`,` const vercelOptions = Object.assign({}, options.vercel, options.prepare === undefined ? {} : { prepare: options.prepare });`,` return createDefaultVercelEnvironment(vercelOptions);`,`}`,`export const DefaultSandbox = { name: "default", environment };`,`export const SANDBOX_PROVIDER_PROBES = {};`,`export function defineDefaultSandboxProvider() { return { name: "default", environment }; }`,``].join(`
2
+ `):e===PRUNED_OPTIONAL_ENGINE_INSTALL_MODULE_ID||OPTIONAL_ENGINE_INSTALL_SOURCE_RE.test(t)?[`function pruned() {`,` throw new Error("Optional local sandbox engines cannot be installed in hosted server runtimes.");`,`}`,`export const detectProjectPackageManager = pruned;`,`export const importInstalledEnginePackage = pruned;`,`export const installPackageIntoProject = pruned;`,`export const loadOptionalEnginePackage = pruned;`,``].join(`
3
+ `):e===PRUNED_LOCAL_SANDBOX_PROVIDER_MODULE_ID||LOCAL_PROVIDER_SOURCE_RE.test(t)?[`function pruned() {`,` throw new Error("Local sandbox providers are pruned from hosted server bundles.");`,`}`,`export const DockerSandbox = { name: "docker", environment: pruned, dockerfile: pruned, image: pruned };`,`export const JustBashSandbox = { name: "just-bash", environment: pruned };`,`export const MicrosandboxSandbox = { name: "microsandbox", environment: pruned, dockerfile: pruned, image: pruned };`,``].join(`
4
+ `):e!==PRUNED_LOCAL_SANDBOX_MODULE_ID&&!LOCAL_BINDING_SOURCE_RE.test(t)?null:[`function pruned() {`,` throw new Error("Local sandbox providers are pruned from hosted server bundles.");`,`}`,`export const createDockerSandboxProvider = pruned;`,`export const createJustBashSandboxProvider = pruned;`,`export const createMicrosandboxSandboxProvider = pruned;`,`export const DOCKER_PROVIDER_NAME = "docker";`,`export const DOCKER_TEMPLATE_IMAGE_REPOSITORY = "eve-sandbox-template";`,`export const JUST_BASH_PROVIDER_NAME = "just-bash";`,`export const MICROSANDBOX_PROVIDER_NAME = "microsandbox";`,`export const isLinuxDockerDaemonAvailableSync = () => false;`,`export const isMicrosandboxPlatformSupported = () => false;`,`export const pruneDockerSandboxTemplates = pruned;`,`export const pruneJustBashSandboxTemplates = pruned;`,`export const pruneMicrosandboxTemplates = pruned;`,`export const pruneLocalSandboxTemplates = pruned;`,`export const pruneLocalSandboxTemplatesInBackground = pruned;`,`export const stopDevelopmentSandboxResources = pruned;`,``].join(`
5
+ `)},resolveId(e){let t=e.split(/[?#]/u,1)[0]??e;return DEFAULT_PROVIDER_SOURCE_RE.test(t)?PRUNED_DEFAULT_SANDBOX_MODULE_ID:LOCAL_PROVIDER_SOURCE_RE.test(t)?PRUNED_LOCAL_SANDBOX_PROVIDER_MODULE_ID:OPTIONAL_ENGINE_INSTALL_SOURCE_RE.test(t)?PRUNED_OPTIONAL_ENGINE_INSTALL_MODULE_ID:LOCAL_BINDING_SOURCE_RE.test(t)?PRUNED_LOCAL_SANDBOX_MODULE_ID:null}}}export{createCompiledSandboxProviderPrunePlugin};
@@ -1,3 +1,3 @@
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{createApplicationRouteRegistry}from"#internal/nitro/host/application-route-registry.js";import{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{createDevelopmentNitroArtifactsConfig,createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.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";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(),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);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};
@@ -1,12 +1,12 @@
1
1
  import type { Nitro } from "nitro/types";
2
2
  import type { PreparedApplicationHost, PreparedDevelopmentApplicationHost } from "#internal/nitro/host/types.js";
3
3
  /**
4
- * Hosted Vercel builds can prune local sandbox backends only when the
4
+ * Hosted Vercel builds can prune local sandbox providers only when the
5
5
  * app did not explicitly configure one. Omitted backends resolve through
6
- * `defaultSandbox()`, which selects Vercel on hosted Vercel and never
6
+ * `DefaultSandbox.environment()`, which selects Vercel on hosted Vercel and never
7
7
  * needs local runtime code there.
8
8
  */
9
- export declare function shouldPruneLocalSandboxBackends(input: {
9
+ export declare function shouldPruneLocalSandboxProviders(input: {
10
10
  readonly configuredBackendNames: ReadonlySet<string>;
11
11
  readonly preset: "vercel" | undefined;
12
12
  }): boolean;
@@ -1 +1 @@
1
- import{readFile}from"node:fs/promises";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{fileURLToPath}from"node:url";import{resolveAuthoredTsConfigPath}from"#internal/authored-module-loader.js";import{EVE_PACKAGE_NAME}from"#internal/package-name.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{createCompiledSandboxBackendPrunePlugin}from"#internal/nitro/host/compiled-sandbox-backend-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 collectConfiguredSandboxBackendNames(e){let t=[e,...e.subagents.map(e=>e.agent)];return new Set(t.map(e=>e.sandbox?.backendName).filter(e=>typeof e==`string`))}function shouldPruneLocalSandboxBackends(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 n=collectConfiguredSandboxBackendNames(e.compileResult.manifest),r=shouldPruneLocalSandboxBackends({configuredBackendNames:n,preset:t})?createCompiledSandboxBackendPrunePlugin():null,i=[],a=[];for(let[e,t]of Object.entries(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME))(n.has(e)?i:a).push(t);let o=createExtensionScopePlugin([e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({sourceRoot:e.sourceRoot,packageNamespace:e.packageNamespace})))),s=[e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts),c=[r,createOptionalEngineDependencyPlugin(a),createExtensionExternalDependencyPlugin(s),o].filter(e=>e!==null);return{nitroRolldownConfig:{tsconfig:resolveAuthoredTsConfigPath(e.appRoot)},nitroRollupConfig:createNitroBundlerConfig(c),tracedAppDependencies:collectHostedTraceDependencies(e,i),tracedAppDependencyPaths:resolveExtensionExternalDependencyPaths(s)}}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){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,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,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)},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();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,shouldPruneLocalSandboxBackends};
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{EVE_PACKAGE_NAME}from"#internal/package-name.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{createCompiledSandboxProviderPrunePlugin}from"#internal/nitro/host/compiled-sandbox-provider-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 n=collectConfiguredSandboxProviderNames(e.compileResult.manifest),r=shouldPruneLocalSandboxProviders({configuredBackendNames:n,preset:t})?createCompiledSandboxProviderPrunePlugin():null,i=[],a=[];for(let[e,t]of Object.entries(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME))(n.has(e)?i:a).push(t);let o=createExtensionScopePlugin([e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({sourceRoot:e.sourceRoot,packageNamespace:e.packageNamespace})))),s=[e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts),c=[r,createOptionalEngineDependencyPlugin(a),createExtensionExternalDependencyPlugin(s),o].filter(e=>e!==null);return{nitroRolldownConfig:{tsconfig:resolveAuthoredTsConfigPath(e.appRoot)},nitroRollupConfig:createNitroBundlerConfig(c),tracedAppDependencies:collectHostedTraceDependencies(e,i),tracedAppDependencyPaths:resolveExtensionExternalDependencyPaths(s)}}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){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,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,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)},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 +1 @@
1
- import{stageDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{relative,resolve}from"node:path";import{startDevelopmentSandboxPrewarmInBackground}from"#execution/sandbox/development-prewarm.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{createDevelopmentApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{prepareDevelopmentApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createDevelopmentNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{buildDevelopmentHostCandidate}from"#internal/nitro/host/dev-host-candidate.js";import{computeDevelopmentHostFingerprint}from"#internal/nitro/host/dev-host-fingerprint.js";import{removeDevelopmentHostWorkspace}from"#internal/nitro/host/dev-host-workspace.js";import"#internal/nitro/host/drained-nitro-dev-server.js";import{activateDevelopmentGeneration,discardDevelopmentGeneration}from"#internal/nitro/development-generation.js";import{resolveNitroCompiledArtifactsSource}from"#internal/nitro/routes/runtime-artifacts.js";var PostCommitDevelopmentRebuildError=class extends Error{constructor(e){super(`The development worker was replaced but its generation failed to activate. The server keeps serving the previous generation; the next rebuild retries activation.`,{cause:e}),this.name=`PostCommitDevelopmentRebuildError`}},DevelopmentWorkflowWorldChangeRequiresRestartError=class extends Error{constructor(){super(`Changing experimental.workflow.world between the parent-owned local World and a custom World requires restarting eve dev.`),this.name=`DevelopmentWorkflowWorldChangeRequiresRestartError`}};async function createDevelopmentAuthoredRebuildCoordinator(e){return new TransactionalDevelopmentAuthoredRebuildCoordinator({currentHostFingerprint:await computeDevelopmentHostFingerprint(e.initialHost),currentRuntimeFingerprint:e.initialHost.generation.fingerprint,devServer:e.devServer,initialHost:e.initialHost})}var TransactionalDevelopmentAuthoredRebuildCoordinator=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.initialHost,this.#t=e.currentHostFingerprint,this.#n=e.currentRuntimeFingerprint,this.#r=e.devServer,this.#i=usesParentDevelopmentWorkflowWorld(e.initialHost.compileResult.manifest.config.experimental?.workflow?.world)}async rebuild(e){let t=this.#e,n=stageDevelopmentEnvironmentFiles(t.appRoot),r;try{if(r=await prepareDevelopmentApplicationHost(t.appRoot,{changedPaths:e.changedPaths,previousExtensions:t.workspaceExtensions}),usesParentDevelopmentWorkflowWorld(r.compileResult.manifest.config.experimental?.workflow?.world)!==this.#i)throw new DevelopmentWorkflowWorldChangeRequiresRestartError;let i=await computeDevelopmentHostFingerprint(r),a=r.generation.fingerprint,o=i!==this.#t,s=a!==this.#n;if(!o&&!s){let e={...t,workspaceExtensions:r.workspaceExtensions};return await discardPreparedHost(r),r=void 0,this.#o(e,this.#t,this.#n),n.commit(),{host:e,kind:`unchanged`}}if(!o){await removeDevelopmentHostWorkspace(r.workspace);let o=retainActiveHostWorkspace(t,r);return await activateDevelopmentGeneration({appRoot:o.appRoot,generation:o.generation}),this.#o(o,i,a),r=void 0,n.commit(),startSandboxPrewarmAfterCommit(o,e.changedPaths),{host:o,kind:`runtime`}}let c=await this.#a({hasRuntimeChange:s,nextHost:r,nextHostFingerprint:i,nextRuntimeFingerprint:a});return r=void 0,n.commit(),startSandboxPrewarmAfterCommit(c.host,e.changedPaths),c}catch(e){throw e instanceof PostCommitDevelopmentRebuildError?(n.commit(),e):(n.rollback(),r===void 0?e:await discardFailedHost(e,r))}}async#a(e){let t=e.nextHost;e.hasRuntimeChange||(await discardDevelopmentGeneration(e.nextHost.generation),t={...e.nextHost,generation:this.#e.generation});let n=await createDevelopmentApplicationNitro(t),r=await buildDevelopmentHostCandidate({host:t,nitro:n}),i=t.workspace;if(await this.#r.replaceWorker({dispose:async()=>await removeDevelopmentHostWorkspace(i),entry:r.entry,workerData:r.workerData}),e.hasRuntimeChange)try{await activateDevelopmentGeneration({appRoot:t.appRoot,generation:t.generation})}catch(n){throw await discardDevelopmentGeneration(t.generation).catch(()=>void 0),this.#o({...t,generation:this.#e.generation},e.nextHostFingerprint,this.#n),new PostCommitDevelopmentRebuildError(n)}return this.#o(t,e.nextHostFingerprint,e.hasRuntimeChange?e.nextRuntimeFingerprint:this.#n),{host:t,kind:`structural`}}#o(e,t,n){this.#e=e,this.#t=t,this.#n=n}};function retainActiveHostWorkspace(e,t){return{...t,compiledArtifacts:e.compiledArtifacts,workflowBuildDir:e.workflowBuildDir,workspace:e.workspace}}function startSandboxPrewarmAfterCommit(e,t){if(!hasSandboxRelatedChange(e.compileResult.project.agentRoot,t))return;let n=createDevelopmentNitroArtifactsConfig({appRoot:e.appRoot,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world});startDevelopmentSandboxPrewarmInBackground({appRoot:e.appRoot,compiledArtifactsSource:resolveNitroCompiledArtifactsSource(n),log:e=>console.log(e)})}function hasSandboxRelatedChange(e,t){return t.some(t=>{let n=relative(resolve(e),resolve(t)),r=n.split(/[\\/]/u);return r[0]===`..`||n===``?!1:r[0]===`sandbox.ts`||r[0]===`sandbox`||r[0]===`workspace`||r[0]===`skills`})}async function discardPreparedHost(e){let t=(await Promise.allSettled([discardDevelopmentGeneration(e.generation),removeDevelopmentHostWorkspace(e.workspace)])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length>0)throw AggregateError(t,`Failed to discard development host "${e.workspace.rootDir}".`)}async function discardFailedHost(e,t){try{return await discardPreparedHost(t),e}catch(t){return AggregateError([e,t],`Development rebuild rollback failed.`,{cause:e})}}export{DevelopmentWorkflowWorldChangeRequiresRestartError,PostCommitDevelopmentRebuildError,createDevelopmentAuthoredRebuildCoordinator};
1
+ import{stageDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{prewarmDevelopmentSandboxes}from"#execution/sandbox/development-prewarm.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{createDevelopmentApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{prepareDevelopmentApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createDevelopmentGenerationArtifactsSource}from"#internal/nitro/host/artifacts-config.js";import{buildDevelopmentHostCandidate}from"#internal/nitro/host/dev-host-candidate.js";import{computeDevelopmentHostFingerprint}from"#internal/nitro/host/dev-host-fingerprint.js";import{removeDevelopmentHostWorkspace}from"#internal/nitro/host/dev-host-workspace.js";import"#internal/nitro/host/drained-nitro-dev-server.js";import{activateDevelopmentGeneration,discardDevelopmentGeneration}from"#internal/nitro/development-generation.js";var PostCommitDevelopmentRebuildError=class extends Error{constructor(e){super(`The development worker was replaced but its generation failed to activate. The server keeps serving the previous generation; the next rebuild retries activation.`,{cause:e}),this.name=`PostCommitDevelopmentRebuildError`}},DevelopmentWorkflowWorldChangeRequiresRestartError=class extends Error{constructor(){super(`Changing experimental.workflow.world between the parent-owned local World and a custom World requires restarting eve dev.`),this.name=`DevelopmentWorkflowWorldChangeRequiresRestartError`}};async function createDevelopmentAuthoredRebuildCoordinator(e){return new TransactionalDevelopmentAuthoredRebuildCoordinator({currentHostFingerprint:await computeDevelopmentHostFingerprint(e.initialHost),currentRuntimeFingerprint:e.initialHost.generation.fingerprint,devServer:e.devServer,initialHost:e.initialHost})}var TransactionalDevelopmentAuthoredRebuildCoordinator=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.initialHost,this.#t=e.currentHostFingerprint,this.#n=e.currentRuntimeFingerprint,this.#r=e.devServer,this.#i=usesParentDevelopmentWorkflowWorld(e.initialHost.compileResult.manifest.config.experimental?.workflow?.world)}async rebuild(e){let t=this.#e,n=stageDevelopmentEnvironmentFiles(t.appRoot),r;try{if(r=await prepareDevelopmentApplicationHost(t.appRoot,{changedPaths:e.changedPaths,previousExtensions:t.workspaceExtensions}),usesParentDevelopmentWorkflowWorld(r.compileResult.manifest.config.experimental?.workflow?.world)!==this.#i)throw new DevelopmentWorkflowWorldChangeRequiresRestartError;await prewarmDevelopmentHost(r);let i=await computeDevelopmentHostFingerprint(r),a=r.generation.fingerprint,o=i!==this.#t,s=a!==this.#n;if(!o&&!s){let e={...t,workspaceExtensions:r.workspaceExtensions};return await discardPreparedHost(r),r=void 0,this.#o(e,this.#t,this.#n),n.commit(),{host:e,kind:`unchanged`}}if(!o){await removeDevelopmentHostWorkspace(r.workspace);let e=retainActiveHostWorkspace(t,r);return await activateDevelopmentGeneration({appRoot:e.appRoot,generation:e.generation}),this.#o(e,i,a),r=void 0,n.commit(),{host:e,kind:`runtime`}}let c=await this.#a({hasRuntimeChange:s,nextHost:r,nextHostFingerprint:i,nextRuntimeFingerprint:a});return r=void 0,n.commit(),c}catch(e){throw e instanceof PostCommitDevelopmentRebuildError?(n.commit(),e):(n.rollback(),r===void 0?e:await discardFailedHost(e,r))}}async#a(e){let t=e.nextHost;e.hasRuntimeChange||(await discardDevelopmentGeneration(e.nextHost.generation),t={...e.nextHost,generation:this.#e.generation});let n=await createDevelopmentApplicationNitro(t),r=await buildDevelopmentHostCandidate({host:t,nitro:n}),i=t.workspace;if(await this.#r.replaceWorker({dispose:async()=>await removeDevelopmentHostWorkspace(i),entry:r.entry,workerData:r.workerData}),e.hasRuntimeChange)try{await activateDevelopmentGeneration({appRoot:t.appRoot,generation:t.generation})}catch(n){throw await discardDevelopmentGeneration(t.generation).catch(()=>void 0),this.#o({...t,generation:this.#e.generation},e.nextHostFingerprint,this.#n),new PostCommitDevelopmentRebuildError(n)}return this.#o(t,e.nextHostFingerprint,e.hasRuntimeChange?e.nextRuntimeFingerprint:this.#n),{host:t,kind:`structural`}}#o(e,t,n){this.#e=e,this.#t=t,this.#n=n}};function retainActiveHostWorkspace(e,t){return{...t,compiledArtifacts:e.compiledArtifacts,workflowBuildDir:e.workflowBuildDir,workspace:e.workspace}}async function prewarmDevelopmentHost(e){await prewarmDevelopmentSandboxes({appRoot:e.appRoot,compiledArtifactsSource:createDevelopmentGenerationArtifactsSource({appRoot:e.appRoot,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world,runtimeAppRoot:e.generation.runtimeAppRoot}),log:e=>console.log(e)})}async function discardPreparedHost(e){let t=(await Promise.allSettled([discardDevelopmentGeneration(e.generation),removeDevelopmentHostWorkspace(e.workspace)])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length>0)throw AggregateError(t,`Failed to discard development host "${e.workspace.rootDir}".`)}async function discardFailedHost(e,t){try{return await discardPreparedHost(t),e}catch(t){return AggregateError([e,t],`Development rebuild rollback failed.`,{cause:e})}}export{DevelopmentWorkflowWorldChangeRequiresRestartError,PostCommitDevelopmentRebuildError,createDevelopmentAuthoredRebuildCoordinator};