eve 0.11.1 → 0.11.3

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 (314) hide show
  1. package/CHANGELOG.md +17 -2
  2. package/README.md +11 -11
  3. package/bin/eve.d.ts +1 -1
  4. package/bin/eve.js +6 -6
  5. package/dist/src/channel/routes.d.ts +4 -4
  6. package/dist/src/channel/types.d.ts +2 -2
  7. package/dist/src/channel/websocket-upgrade-server.d.ts +3 -3
  8. package/dist/src/chunks/{use-eve-agent-CdETo3qQ.js → use-eve-agent-D9ZhQhyV.js} +2 -2
  9. package/dist/src/chunks/{use-eve-agent-ClyM-_UT.js → use-eve-agent-DFI0POM9.js} +2 -2
  10. package/dist/src/cli/banner.d.ts +1 -1
  11. package/dist/src/cli/banner.js +1 -1
  12. package/dist/src/cli/commands/channel-add-conflicts.js +1 -1
  13. package/dist/src/cli/commands/channels.js +1 -1
  14. package/dist/src/cli/commands/deploy.js +1 -1
  15. package/dist/src/cli/commands/info.js +1 -1
  16. package/dist/src/cli/commands/init-agent-instructions.md +1 -1
  17. package/dist/src/cli/commands/init-git.js +1 -1
  18. package/dist/src/cli/commands/init.d.ts +1 -1
  19. package/dist/src/cli/commands/link.js +1 -1
  20. package/dist/src/cli/commands/preconditions.d.ts +2 -2
  21. package/dist/src/cli/commands/preconditions.js +1 -1
  22. package/dist/src/cli/dev/environment.d.ts +1 -1
  23. package/dist/src/cli/dev/tui/runner.js +1 -1
  24. package/dist/src/cli/dev/tui/setup-issues.d.ts +2 -0
  25. package/dist/src/cli/dev/tui/setup-issues.js +1 -1
  26. package/dist/src/cli/dev/tui/terminal-renderer.js +2 -2
  27. package/dist/src/cli/dev/tui/theme.d.ts +1 -1
  28. package/dist/src/cli/dev/tui/tui.d.ts +1 -1
  29. package/dist/src/cli/dev/url.d.ts +1 -1
  30. package/dist/src/cli/run.d.ts +1 -1
  31. package/dist/src/cli/run.js +2 -2
  32. package/dist/src/cli/ui/output.d.ts +1 -1
  33. package/dist/src/client/client-error.d.ts +1 -1
  34. package/dist/src/client/client.d.ts +3 -3
  35. package/dist/src/client/eve-agent-store.d.ts +1 -1
  36. package/dist/src/client/eve-agent-store.js +1 -1
  37. package/dist/src/client/message-reducer-types.d.ts +3 -3
  38. package/dist/src/client/message-reducer.d.ts +3 -3
  39. package/dist/src/client/output-schema.d.ts +1 -1
  40. package/dist/src/client/reducer.d.ts +5 -5
  41. package/dist/src/client/session.d.ts +1 -1
  42. package/dist/src/client/types.d.ts +1 -1
  43. package/dist/src/client/url.d.ts +2 -2
  44. package/dist/src/compiled/.vendor-stamp.json +1 -1
  45. package/dist/src/compiled/@vercel/detect-agent/index.d.ts +1 -1
  46. package/dist/src/compiler/channel-instrumentation-types.js +1 -1
  47. package/dist/src/compiler/model-catalog.d.ts +1 -1
  48. package/dist/src/compiler/module-map.js +1 -1
  49. package/dist/src/compiler/normalize-agent-config.js +1 -1
  50. package/dist/src/compiler/normalize-channel.js +1 -1
  51. package/dist/src/compiler/normalize-connection.js +1 -1
  52. package/dist/src/compiler/normalize-instructions.js +1 -1
  53. package/dist/src/compiler/normalize-sandbox.js +1 -1
  54. package/dist/src/compiler/normalize-schedule.js +1 -1
  55. package/dist/src/compiler/normalize-skill.js +1 -1
  56. package/dist/src/compiler/normalize-subagent.js +1 -1
  57. package/dist/src/compiler/normalize-tool.js +1 -1
  58. package/dist/src/compiler/workspace-resources.js +1 -1
  59. package/dist/src/context/build-callback-context.js +1 -1
  60. package/dist/src/context/container.d.ts +4 -4
  61. package/dist/src/context/container.js +1 -1
  62. package/dist/src/discover/diagnostics.d.ts +1 -1
  63. package/dist/src/discover/project.d.ts +2 -2
  64. package/dist/src/discover/project.js +1 -1
  65. package/dist/src/evals/cli/eval-client.d.ts +1 -1
  66. package/dist/src/evals/define-eval.d.ts +1 -1
  67. package/dist/src/evals/runner/execute-eval.d.ts +1 -1
  68. package/dist/src/evals/runner/execute-task.d.ts +1 -1
  69. package/dist/src/evals/types.d.ts +6 -6
  70. package/dist/src/execution/durable-session-migrations/chain.js +1 -1
  71. package/dist/src/execution/sandbox/bash-tool.js +1 -1
  72. package/dist/src/execution/sandbox/bindings/docker-options.d.ts +1 -1
  73. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  74. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
  75. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  76. package/dist/src/execution/sandbox/development-prewarm.js +1 -1
  77. package/dist/src/execution/sandbox/ensure.js +1 -1
  78. package/dist/src/execution/sandbox/prewarm.js +1 -1
  79. package/dist/src/execution/session-callback-step.d.ts +1 -1
  80. package/dist/src/harness/attachment-staging.js +1 -1
  81. package/dist/src/harness/code-mode-lifecycle.d.ts +1 -1
  82. package/dist/src/harness/code-mode.js +1 -1
  83. package/dist/src/harness/emission.d.ts +1 -1
  84. package/dist/src/harness/runtime-actions.d.ts +1 -1
  85. package/dist/src/harness/tool-loop.js +1 -1
  86. package/dist/src/harness/tools.d.ts +12 -0
  87. package/dist/src/harness/tools.js +1 -1
  88. package/dist/src/internal/application/cache-metadata.d.ts +2 -2
  89. package/dist/src/internal/application/compiled-artifacts.js +2 -2
  90. package/dist/src/internal/application/package.d.ts +7 -7
  91. package/dist/src/internal/application/package.js +1 -1
  92. package/dist/src/internal/authored-module-bundle.js +1 -1
  93. package/dist/src/internal/helpers/markdown.js +1 -1
  94. package/dist/src/internal/instrumentation.d.ts +1 -1
  95. package/dist/src/internal/nitro/host/build-application.d.ts +1 -1
  96. package/dist/src/internal/nitro/host/channel-routes.d.ts +3 -3
  97. package/dist/src/internal/nitro/host/configure-nitro-routes.d.ts +1 -1
  98. package/dist/src/internal/nitro/host/configure-nitro-routes.js +1 -1
  99. package/dist/src/internal/nitro/host/create-application-nitro.d.ts +1 -1
  100. package/dist/src/internal/nitro/host/cron-handler-route.d.ts +3 -3
  101. package/dist/src/internal/nitro/host/nitro-bundler-config.d.ts +1 -1
  102. package/dist/src/internal/nitro/host/optional-engine-dependency-plugin.d.ts +2 -2
  103. package/dist/src/internal/nitro/host/schedule-task-routes.d.ts +2 -2
  104. package/dist/src/internal/nitro/host/start-development-server.d.ts +1 -1
  105. package/dist/src/internal/nitro/host/start-development-server.js +1 -1
  106. package/dist/src/internal/nitro/host/start-production-server.d.ts +1 -1
  107. package/dist/src/internal/nitro/host/start-production-server.js +2 -2
  108. package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.js +1 -1
  109. package/dist/src/internal/nitro/routes/health.d.ts +1 -1
  110. package/dist/src/internal/nitro/routes/info.d.ts +1 -1
  111. package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -1
  112. package/dist/src/internal/nitro/routes/schedule-task.d.ts +1 -1
  113. package/dist/src/internal/package-name.d.ts +1 -1
  114. package/dist/src/internal/vercel-agent-summary.d.ts +6 -6
  115. package/dist/src/internal/workflow/builtins.d.ts +3 -3
  116. package/dist/src/internal/workflow-bundle/nitro-step-entry.js +1 -1
  117. package/dist/src/internal/workflow-bundle/vercel-workflow-output.d.ts +7 -7
  118. package/dist/src/internal/workflow-bundle/workflow-core-shim.d.ts +4 -4
  119. package/dist/src/internal/workflow-bundle/workflow-core-shim.js +1 -1
  120. package/dist/src/packages/eve-catalog/src/index.js +1 -1
  121. package/dist/src/protocol/message.d.ts +2 -2
  122. package/dist/src/protocol/routes.d.ts +3 -3
  123. package/dist/src/public/agents/auth.d.ts +1 -1
  124. package/dist/src/public/channels/auth.d.ts +1 -1
  125. package/dist/src/public/channels/discord/api.d.ts +2 -2
  126. package/dist/src/public/channels/discord/discordChannel.d.ts +2 -2
  127. package/dist/src/public/channels/discord/hitl.d.ts +4 -4
  128. package/dist/src/public/channels/discord/verify.d.ts +1 -1
  129. package/dist/src/public/channels/eve.d.ts +5 -5
  130. package/dist/src/public/channels/github/api.d.ts +1 -1
  131. package/dist/src/public/channels/github/defaults.d.ts +1 -1
  132. package/dist/src/public/channels/github/inbound.d.ts +1 -1
  133. package/dist/src/public/channels/index.d.ts +2 -2
  134. package/dist/src/public/channels/linear/auth.d.ts +1 -1
  135. package/dist/src/public/channels/linear/hitl.d.ts +4 -4
  136. package/dist/src/public/channels/linear/inbound.d.ts +1 -1
  137. package/dist/src/public/channels/linear/verify.d.ts +1 -1
  138. package/dist/src/public/channels/slack/constants.d.ts +1 -1
  139. package/dist/src/public/channels/teams/api.d.ts +4 -4
  140. package/dist/src/public/channels/teams/hitl.d.ts +4 -4
  141. package/dist/src/public/channels/teams/limits.d.ts +3 -3
  142. package/dist/src/public/channels/teams/verify.d.ts +2 -2
  143. package/dist/src/public/channels/telegram/api.d.ts +1 -1
  144. package/dist/src/public/channels/telegram/hitl.d.ts +3 -3
  145. package/dist/src/public/channels/telegram/verify.d.ts +1 -1
  146. package/dist/src/public/channels/twilio/api.d.ts +1 -1
  147. package/dist/src/public/context/index.d.ts +1 -1
  148. package/dist/src/public/definitions/defineChannel.d.ts +2 -2
  149. package/dist/src/public/definitions/hook.d.ts +1 -1
  150. package/dist/src/public/definitions/remote-agent.d.ts +5 -5
  151. package/dist/src/public/definitions/sandbox.d.ts +1 -1
  152. package/dist/src/public/definitions/source.d.ts +2 -2
  153. package/dist/src/public/definitions/state.d.ts +2 -2
  154. package/dist/src/public/definitions/state.js +1 -1
  155. package/dist/src/public/instrumentation/index.d.ts +3 -3
  156. package/dist/src/public/next/index.d.ts +12 -12
  157. package/dist/src/public/next/index.js +1 -1
  158. package/dist/src/public/next/server.js +1 -1
  159. package/dist/src/public/next/vercel-output-config.js +1 -1
  160. package/dist/src/public/nuxt/dev-server.d.ts +2 -2
  161. package/dist/src/public/nuxt/dev-server.js +1 -1
  162. package/dist/src/public/nuxt/module.d.ts +10 -10
  163. package/dist/src/public/nuxt/routing.d.ts +6 -6
  164. package/dist/src/public/nuxt/routing.js +1 -1
  165. package/dist/src/public/nuxt/vercel-json.d.ts +2 -2
  166. package/dist/src/public/sandbox/backends/just-bash.d.ts +1 -1
  167. package/dist/src/public/sandbox/backends/microsandbox.d.ts +1 -1
  168. package/dist/src/public/sandbox/backends/vercel.d.ts +1 -1
  169. package/dist/src/public/sandbox/docker-sandbox.d.ts +1 -1
  170. package/dist/src/public/sandbox/just-bash-sandbox.d.ts +1 -1
  171. package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +3 -3
  172. package/dist/src/public/sandbox/vercel-sandbox.d.ts +2 -2
  173. package/dist/src/public/sveltekit/dev-server.d.ts +2 -2
  174. package/dist/src/public/sveltekit/dev-server.js +1 -1
  175. package/dist/src/public/sveltekit/index.d.ts +11 -11
  176. package/dist/src/public/sveltekit/routing.d.ts +5 -5
  177. package/dist/src/public/sveltekit/routing.js +1 -1
  178. package/dist/src/public/sveltekit/vercel-json.d.ts +2 -2
  179. package/dist/src/public/tool-result-narrowing.js +1 -1
  180. package/dist/src/public/types/json.d.ts +1 -1
  181. package/dist/src/react/use-eve-agent.d.ts +8 -8
  182. package/dist/src/runtime/agent/bootstrap-model.js +1 -1
  183. package/dist/src/runtime/agent/bootstrap.d.ts +1 -1
  184. package/dist/src/runtime/agent/bootstrap.js +1 -1
  185. package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
  186. package/dist/src/runtime/agent/resolve-model.js +1 -1
  187. package/dist/src/runtime/attributes/emit.d.ts +2 -2
  188. package/dist/src/runtime/connections/callback-route.d.ts +1 -1
  189. package/dist/src/runtime/connections/principal.js +1 -1
  190. package/dist/src/runtime/connections/scoped-authorization.d.ts +1 -1
  191. package/dist/src/runtime/connections/types.d.ts +4 -4
  192. package/dist/src/runtime/framework-tools/final-output.d.ts +1 -1
  193. package/dist/src/runtime/governance/auth/http-basic.d.ts +1 -1
  194. package/dist/src/runtime/governance/auth/token-claims.d.ts +1 -1
  195. package/dist/src/runtime/governance/auth/types.d.ts +1 -1
  196. package/dist/src/runtime/loaders/artifact-paths.d.ts +1 -1
  197. package/dist/src/runtime/loaders/compile-metadata.js +1 -1
  198. package/dist/src/runtime/loaders/manifest.js +1 -1
  199. package/dist/src/runtime/loaders/module-map.js +1 -1
  200. package/dist/src/runtime/prompt/compose.js +1 -1
  201. package/dist/src/runtime/resolve-channel.js +1 -1
  202. package/dist/src/runtime/schedules/register.js +1 -1
  203. package/dist/src/runtime/sessions/auth.d.ts +1 -1
  204. package/dist/src/runtime/sessions/runtime-session.d.ts +1 -1
  205. package/dist/src/runtime/types.d.ts +1 -1
  206. package/dist/src/runtime/workspace/types.d.ts +1 -1
  207. package/dist/src/services/dev-client/request-headers.d.ts +2 -2
  208. package/dist/src/services/dev-client/vercel-auth-error.d.ts +1 -1
  209. package/dist/src/services/inspect-application.d.ts +1 -1
  210. package/dist/src/setup/boxes/add-channels.d.ts +1 -1
  211. package/dist/src/setup/boxes/add-channels.js +1 -1
  212. package/dist/src/setup/boxes/deploy-project.js +1 -1
  213. package/dist/src/setup/boxes/resolve-target.d.ts +2 -2
  214. package/dist/src/setup/boxes/scaffold.d.ts +4 -4
  215. package/dist/src/setup/boxes/scaffold.js +1 -1
  216. package/dist/src/setup/channel-add-conflicts.js +1 -1
  217. package/dist/src/setup/cli/rail-log.d.ts +1 -1
  218. package/dist/src/setup/flows/model.d.ts +3 -5
  219. package/dist/src/setup/flows/model.js +1 -1
  220. package/dist/src/setup/node-engine.d.ts +5 -5
  221. package/dist/src/setup/node-engine.js +1 -1
  222. package/dist/src/setup/onboarding.d.ts +2 -2
  223. package/dist/src/setup/primitives/open-url.d.ts +1 -1
  224. package/dist/src/setup/primitives/pm/pnpm.js +1 -1
  225. package/dist/src/setup/primitives/pm/run.d.ts +1 -1
  226. package/dist/src/setup/primitives/pm/types.d.ts +1 -1
  227. package/dist/src/setup/scaffold/connections/catalog.d.ts +1 -1
  228. package/dist/src/setup/scaffold/create/add-to-project.d.ts +2 -2
  229. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  230. package/dist/src/setup/scaffold/create/project.d.ts +5 -5
  231. package/dist/src/setup/scaffold/create/project.js +3 -3
  232. package/dist/src/setup/scaffold/create/web-template.d.ts +2 -2
  233. package/dist/src/setup/scaffold/create/web-template.js +2 -2
  234. package/dist/src/setup/scaffold/update/package-json.d.ts +1 -1
  235. package/dist/src/setup/slack-connect-lifecycle.d.ts +2 -2
  236. package/dist/src/setup/slack-connect-lifecycle.js +1 -1
  237. package/dist/src/setup/slackbot.d.ts +1 -1
  238. package/dist/src/setup/slackbot.js +1 -1
  239. package/dist/src/setup/validate-gateway-key.d.ts +1 -1
  240. package/dist/src/setup/vercel-project.js +1 -1
  241. package/dist/src/shared/agent-definition.d.ts +15 -15
  242. package/dist/src/shared/code-mode.d.ts +3 -3
  243. package/dist/src/shared/json-schema.d.ts +1 -1
  244. package/dist/src/shared/model-endpoint-status.d.ts +2 -2
  245. package/dist/src/shared/sandbox-backend.d.ts +4 -4
  246. package/dist/src/shared/sandbox-definition.d.ts +3 -3
  247. package/dist/src/shared/sandbox-network-policy.d.ts +1 -1
  248. package/dist/src/shared/sandbox-session.d.ts +2 -2
  249. package/dist/src/shared/skill-package.d.ts +1 -1
  250. package/dist/src/shared/skill-package.js +1 -1
  251. package/dist/src/shared/tool-definition.d.ts +1 -1
  252. package/dist/src/svelte/index.js +1 -1
  253. package/dist/src/svelte/use-eve-agent.d.ts +7 -7
  254. package/dist/src/svelte/use-eve-agent.js +1 -1
  255. package/dist/src/vue/index.js +1 -1
  256. package/dist/src/vue/use-eve-agent.d.ts +7 -7
  257. package/dist/src/vue/use-eve-agent.js +1 -1
  258. package/docs/README.md +11 -11
  259. package/docs/agent-config.md +2 -2
  260. package/docs/channels/custom.mdx +5 -5
  261. package/docs/channels/discord.mdx +3 -3
  262. package/docs/channels/eve.mdx +7 -7
  263. package/docs/channels/linear.mdx +6 -6
  264. package/docs/channels/overview.mdx +11 -11
  265. package/docs/channels/slack.mdx +4 -4
  266. package/docs/channels/teams.mdx +2 -2
  267. package/docs/channels/telegram.mdx +3 -3
  268. package/docs/channels/twilio.mdx +1 -1
  269. package/docs/concepts/context-control.md +5 -5
  270. package/docs/concepts/default-harness.md +16 -16
  271. package/docs/concepts/execution-model-and-durability.md +9 -9
  272. package/docs/concepts/security-model.md +9 -9
  273. package/docs/concepts/sessions-runs-and-streaming.md +30 -30
  274. package/docs/connections.mdx +11 -11
  275. package/docs/evals/judge.mdx +2 -2
  276. package/docs/evals/overview.mdx +2 -2
  277. package/docs/evals/reporters.mdx +2 -2
  278. package/docs/getting-started.mdx +12 -10
  279. package/docs/guides/auth-and-route-protection.md +6 -6
  280. package/docs/guides/client/continuations.mdx +3 -3
  281. package/docs/guides/client/output-schema.mdx +1 -1
  282. package/docs/guides/client/overview.mdx +5 -5
  283. package/docs/guides/client/streaming.mdx +1 -1
  284. package/docs/guides/deployment.md +7 -7
  285. package/docs/guides/dev-tui.md +2 -2
  286. package/docs/guides/frontend/nextjs.mdx +13 -13
  287. package/docs/guides/frontend/nuxt.mdx +7 -7
  288. package/docs/guides/frontend/overview.mdx +13 -13
  289. package/docs/guides/frontend/sveltekit.mdx +7 -7
  290. package/docs/guides/frontend/use-eve-agent-svelte.mdx +6 -6
  291. package/docs/guides/frontend/use-eve-agent-vue.mdx +6 -6
  292. package/docs/guides/hooks.md +2 -2
  293. package/docs/guides/instrumentation.md +12 -12
  294. package/docs/guides/remote-agents.md +4 -4
  295. package/docs/guides/session-context.md +4 -4
  296. package/docs/guides/state.md +1 -1
  297. package/docs/instructions.mdx +4 -4
  298. package/docs/introduction.mdx +14 -12
  299. package/docs/reference/cli.md +5 -5
  300. package/docs/reference/project-layout.md +4 -4
  301. package/docs/responsible-use.md +3 -3
  302. package/docs/sandbox.mdx +8 -8
  303. package/docs/schedules.mdx +1 -1
  304. package/docs/skills.mdx +4 -4
  305. package/docs/subagents.mdx +3 -3
  306. package/docs/tools/human-in-the-loop.md +83 -0
  307. package/docs/tools/meta.json +4 -0
  308. package/docs/{tools.mdx → tools/overview.mdx} +14 -37
  309. package/docs/tutorial/connect-a-warehouse.mdx +3 -3
  310. package/docs/tutorial/first-agent.mdx +2 -2
  311. package/docs/tutorial/how-it-runs.mdx +2 -2
  312. package/docs/tutorial/query-sample-data.mdx +1 -1
  313. package/docs/tutorial/ship-it.mdx +4 -4
  314. package/package.json +1 -1
@@ -75,7 +75,7 @@ export interface ChannelDefinition<TState = undefined, TCtx = void, TReceiveTarg
75
75
  /**
76
76
  * Builds the per-step channel context handed to `events` and `deliver`.
77
77
  * Receives the live {@link SessionHandle}, so a factory can close over it to
78
- * register late-bound callbacks. Eve writes state mutations made inside the
78
+ * register late-bound callbacks. eve writes state mutations made inside the
79
79
  * returned context back through `adapter.state`.
80
80
  *
81
81
  * Return the channel-owned context (thread handles, API clients, etc.). The
@@ -100,7 +100,7 @@ export interface ChannelDefinition<TState = undefined, TCtx = void, TReceiveTarg
100
100
  * Channel-owned metadata exposed to instrumentation callbacks. This is the
101
101
  * channel's public observability surface, not a dump of durable adapter state,
102
102
  * so keep it small. Return an object of JSON primitives, arrays, and plain
103
- * objects: Eve omits `undefined` properties and drops projections containing
103
+ * objects: eve omits `undefined` properties and drops projections containing
104
104
  * values such as `Date` or `Map`.
105
105
  */
106
106
  readonly metadata?: (state: NonNullable<TState>) => TMetadata;
@@ -42,7 +42,7 @@ export type StreamEventHooks = {
42
42
  * Public hook definition authored in `agent/hooks/*.ts`.
43
43
  *
44
44
  * Hook files declare stream-event subscribers (under `events:`) that
45
- * fire after Eve has accepted and durably recorded each event.
45
+ * fire after eve has accepted and durably recorded each event.
46
46
  * Handlers are observe-only: they cannot inject model context. To
47
47
  * contribute runtime model messages, use `defineDynamic` +
48
48
  * `defineInstructions` in `agent/instructions/`.
@@ -3,7 +3,7 @@ import type { HeadersValue } from "#client/types.js";
3
3
  import type { OutboundAuthFn } from "#public/agents/auth.js";
4
4
  import type { JsonObject } from "#shared/json.js";
5
5
  /**
6
- * Public definition for a remote Eve agent. The compiler lowers it to a
6
+ * Public definition for a remote eve agent. The compiler lowers it to a
7
7
  * subagent tool.
8
8
  */
9
9
  export interface RemoteAgentDefinition {
@@ -22,17 +22,17 @@ export interface RemoteAgentDefinition {
22
22
  */
23
23
  readonly outputSchema?: StandardJSONSchemaV1<unknown, unknown> | JsonObject;
24
24
  /**
25
- * Route Eve appends to `url` for the create-session request. Defaults to the
25
+ * Route eve appends to `url` for the create-session request. Defaults to the
26
26
  * framework create-session route (`/eve/v1/session`).
27
27
  */
28
28
  readonly path: string;
29
29
  /**
30
- * Base URL of the remote Eve deployment to call.
30
+ * Base URL of the remote eve deployment to call.
31
31
  */
32
32
  readonly url: string;
33
33
  }
34
34
  /**
35
- * Authored input that {@link defineRemoteAgent} accepts. Eve derives identity
35
+ * Authored input that {@link defineRemoteAgent} accepts. eve derives identity
36
36
  * from the file path under `agent/subagents/`; authored definitions do not
37
37
  * carry a `name` field.
38
38
  */
@@ -40,7 +40,7 @@ export type RemoteAgentDefinitionInput = Omit<RemoteAgentDefinition, "kind" | "p
40
40
  readonly path?: string;
41
41
  };
42
42
  /**
43
- * Defines a remote Eve agent that the parent can call as a subagent tool. The
43
+ * Defines a remote eve agent that the parent can call as a subagent tool. The
44
44
  * compiler lowers it at compile time from the file path under `agent/subagents/`.
45
45
  *
46
46
  * Stamps `kind: "remote"` and, when `path` is omitted, defaults it to the
@@ -5,7 +5,7 @@ export type { SandboxBootstrapUseFn, SandboxRevalidationKeyFn, SandboxSessionUse
5
5
  /**
6
6
  * The shape passed to {@link defineSandbox}: a discriminated union over
7
7
  * whether a `bootstrap` hook is present. `backend` is optional here (it is
8
- * required on the shared base): when omitted, Eve substitutes
8
+ * required on the shared base): when omitted, eve substitutes
9
9
  * `defaultBackend()` at runtime. `BO`/`SO` type the options for the
10
10
  * bootstrap-use and session-use functions respectively.
11
11
  */
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Supported runtime contract for one module-authored Eve definition.
2
+ * Supported runtime contract for one module-authored eve definition.
3
3
  *
4
4
  * Module-backed authored sources may export the public definition directly or
5
5
  * export a zero-argument factory that returns the definition synchronously or
6
- * asynchronously when Eve loads the module in Node.js at runtime.
6
+ * asynchronously when eve loads the module in Node.js at runtime.
7
7
  */
8
8
  export type ModuleDefinitionExport<TDefinition> = TDefinition | (() => TDefinition | Promise<TDefinition>);
@@ -2,7 +2,7 @@
2
2
  * Typed handle returned by {@link defineState}. Reads and updates a
3
3
  * named context slot.
4
4
  *
5
- * All operations require an active Eve context (ALS scope) and throw
5
+ * All operations require an active eve context (ALS scope) and throw
6
6
  * when called outside one.
7
7
  */
8
8
  export interface StateHandle<T> {
@@ -18,7 +18,7 @@ export interface StateHandle<T> {
18
18
  * The name must not start with the reserved `"eve."` prefix (reserved
19
19
  * for framework context keys); doing so throws.
20
20
  *
21
- * All operations require an active Eve context. Calling `get()` or
21
+ * All operations require an active eve context. Calling `get()` or
22
22
  * `update()` outside of tools, hooks, or other framework-managed code
23
23
  * throws.
24
24
  *
@@ -1 +1 @@
1
- import{loadContext}from"#context/container.js";import{ContextKey}from"#context/key.js";const RESERVED_STATE_NAME_PREFIX=`eve.`;function defineState(n,r){if(n.startsWith(RESERVED_STATE_NAME_PREFIX))throw Error(`defineState() name "${n}" uses the reserved "${RESERVED_STATE_NAME_PREFIX}" prefix, which Eve reserves for its own framework context keys (e.g. "eve.channel", "eve.bundle"). Colliding with one silently corrupts context serialization. Use your own namespace, e.g. "my-agent.${n.slice(4)}".`);let i=new ContextKey(n);return{get(){return loadContext().ensure(i,r)},update(e){let t=loadContext(),n=t.ensure(i,r);t.set(i,e(n))}}}export{defineState};
1
+ import{loadContext}from"#context/container.js";import{ContextKey}from"#context/key.js";const RESERVED_STATE_NAME_PREFIX=`eve.`;function defineState(n,r){if(n.startsWith(RESERVED_STATE_NAME_PREFIX))throw Error(`defineState() name "${n}" uses the reserved "${RESERVED_STATE_NAME_PREFIX}" prefix, which eve reserves for its own framework context keys (e.g. "eve.channel", "eve.bundle"). Colliding with one silently corrupts context serialization. Use your own namespace, e.g. "my-agent.${n.slice(4)}".`);let i=new ContextKey(n);return{get(){return loadContext().ensure(i,r)},update(e){let t=loadContext(),n=t.ensure(i,r);t.set(i,e(n))}}}export{defineState};
@@ -67,7 +67,7 @@ export interface InstrumentationModelInput {
67
67
  readonly messages: readonly ModelMessage[];
68
68
  }
69
69
  /**
70
- * Input passed to `events["step.started"]`. Eve runs the callback after
70
+ * Input passed to `events["step.started"]`. eve runs the callback after
71
71
  * building the final model input for this attempt and before constructing
72
72
  * the AI SDK model call.
73
73
  */
@@ -79,7 +79,7 @@ export interface InstrumentationStepStartedEventInput {
79
79
  readonly turn: InstrumentationTurn;
80
80
  }
81
81
  /**
82
- * Result of a `step.started` callback. Eve merges `runtimeContext` into the
82
+ * Result of a `step.started` callback. eve merges `runtimeContext` into the
83
83
  * AI SDK telemetry span; child spans inherit the values. Keys beginning with
84
84
  * `eve.` and non-JSON-serializable values are dropped. Return `undefined` to
85
85
  * contribute no context.
@@ -136,7 +136,7 @@ export interface InstrumentationDefinition {
136
136
  readonly setup?: (context: InstrumentationSetupContext) => void;
137
137
  }
138
138
  /**
139
- * Export the result as the default export of `agent/instrumentation.ts`. Eve
139
+ * Export the result as the default export of `agent/instrumentation.ts`. eve
140
140
  * reads these settings at server startup and applies them to every AI SDK
141
141
  * model call. The `setup` callback runs later with the resolved agent name,
142
142
  * not during `defineInstrumentation` itself.
@@ -1,6 +1,6 @@
1
1
  import type { NextConfig } from "next";
2
2
  /**
3
- * Default private route namespace for hosting Eve as a separate experimental
3
+ * Default private route namespace for hosting eve as a separate experimental
4
4
  * Vercel service behind the Next.js app. {@link WithEveOptions.servicePrefix}
5
5
  * defaults to this value.
6
6
  */
@@ -46,41 +46,41 @@ export type EveNextConfigInput<TConfig extends EveNextConfig = EveNextConfig> =
46
46
  */
47
47
  export interface WithEveOptions {
48
48
  /**
49
- * Maximum time in milliseconds to wait for the Eve development server to
49
+ * Maximum time in milliseconds to wait for the eve development server to
50
50
  * start, including waiting for another Next.js process to start it. Defaults
51
51
  * to 180000 (three minutes).
52
52
  */
53
53
  readonly devServerTimeoutMs?: number;
54
54
  /**
55
- * Path to the Eve application root, relative to `process.cwd()` unless
55
+ * Path to the eve application root, relative to `process.cwd()` unless
56
56
  * absolute. Defaults to the Next.js app root.
57
57
  */
58
58
  readonly eveRoot?: string;
59
59
  /**
60
- * Build command for the generated Eve Vercel service. Defaults to `eve build`.
61
- * Use this when the Eve service needs project-specific prework before the
60
+ * Build command for the generated eve Vercel service. Defaults to `eve build`.
61
+ * Use this when the eve service needs project-specific prework before the
62
62
  * framework build, without changing the Next.js service build command.
63
63
  */
64
64
  readonly eveBuildCommand?: string;
65
65
  /**
66
- * Private Vercel service prefix for the Eve deployment. Defaults to
66
+ * Private Vercel service prefix for the eve deployment. Defaults to
67
67
  * {@link EVE_NEXT_SERVICE_PREFIX} (`/_eve_internal/eve`). `withEve` normalizes
68
68
  * the prefix (adds a leading slash, strips trailing slashes) and rejects a
69
- * prefix that resolves to the root route. The prefix must match the Eve
69
+ * prefix that resolves to the root route. The prefix must match the eve
70
70
  * service's mount in Vercel Build Output config.
71
71
  */
72
72
  readonly servicePrefix?: string;
73
73
  }
74
74
  /**
75
- * Wraps a Next.js config so same-origin Eve endpoints proxy to a separate Eve
75
+ * Wraps a Next.js config so same-origin eve endpoints proxy to a separate eve
76
76
  * service.
77
77
  *
78
- * In development, starts `eve dev --no-ui --port 0` for the Eve app and
79
- * rewrites Eve protocol endpoints to that local URL. In Vercel production,
80
- * rewrites to the resolved private Eve service prefix.
78
+ * In development, starts `eve dev --no-ui --port 0` for the eve app and
79
+ * rewrites eve protocol endpoints to that local URL. In Vercel production,
80
+ * rewrites to the resolved private eve service prefix.
81
81
  * Outside Vercel production, serves an existing `.output/server/index.mjs` build
82
82
  * on a stable local port when present; otherwise set `EVE_NEXT_PRODUCTION_ORIGIN`
83
- * to the origin serving the Eve service namespace.
83
+ * to the origin serving the eve service namespace.
84
84
  */
85
85
  export declare function withEve<TConfig extends EveNextConfig>(configOrFunction: EveNextConfigInput<TConfig>, options?: WithEveOptions): EveNextConfigFunction<TConfig>;
86
86
  export {};
@@ -1 +1 @@
1
- import{resolveEveDestinationPrefix}from"./server.js";import{ensureEveVercelOutputConfig}from"./vercel-output-config.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isAbsolute,resolve}from"node:path";const EVE_NEXT_SERVICE_PREFIX=`/_eve_internal/eve`,EVE_NEXT_PRODUCTION_PORT_ENV=`EVE_NEXT_PRODUCTION_PORT`,EVE_PROXY_REWRITE_SOURCES=[`${EVE_ROUTE_PREFIX}/:path+`];function resolveApplicationRoot(e){return e===void 0||e.length===0?process.cwd():isAbsolute(e)?e:resolve(process.cwd(),e)}function resolveDevServerTimeout(e){if(e!==void 0){if(!Number.isFinite(e)||e<=0)throw Error(`Eve Next.js development server timeout must be a positive number.`);return e}}function normalizeRoutePrefix(e){let t=(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``);if(t.length===0)throw Error(`Eve Next.js service prefix cannot resolve to the root route.`);return t}function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function normalizeOrigin(e){return new URL(e.trim()).origin}function readLocalProductionPort(){let e=process.env[EVE_NEXT_PRODUCTION_PORT_ENV];if(e===void 0||e.trim().length===0)return 4274;let t=Number.parseInt(e,10);if(String(t)!==e.trim()||t<1||t>65535)throw Error(`${EVE_NEXT_PRODUCTION_PORT_ENV} must be an integer between 1 and 65535.`);return t}function resolveProductionDestination(e){if(process.env.VERCEL)return{destinationPrefix:e};let t=process.env.EVE_NEXT_PRODUCTION_ORIGIN;if(t!==void 0&&t.trim().length>0)return{destinationPrefix:joinRoutePrefix(normalizeOrigin(t),e)};let n=`http://127.0.0.1:${String(readLocalProductionPort())}`;return{destinationPrefix:n,localServerOrigin:n}}function createEveRewriteRules(e){return EVE_PROXY_REWRITE_SOURCES.map(t=>({destination:joinRoutePrefix(e,t),source:t}))}async function resolveExistingRewrites(e){return await e?.()}function mergeRewriteRules(e,t){return e===void 0?{beforeFiles:t}:isRewriteSections(e)?{...e,beforeFiles:[...t,...e.beforeFiles??[]]}:{afterFiles:e,beforeFiles:t}}function isRewriteSections(e){return!Array.isArray(e)}async function resolveNextConfig(e,t,n){return typeof e==`function`?await e(t,n):e}function withEve(n,r={}){let i=process.cwd(),a=resolveApplicationRoot(r.eveRoot),o=resolveDevServerTimeout(r.devServerTimeoutMs),s=normalizeRoutePrefix(r.servicePrefix??`/_eve_internal/eve`);return async function(c,l){let u=await resolveNextConfig(n,c,l),d=u.rewrites,f=resolveProductionDestination((await ensureEveVercelOutputConfig({appRoot:a,eveBuildCommand:r.eveBuildCommand??`eve build`,nextRoot:i,servicePrefix:s})).servicePrefix);return{...u,async rewrites(){let[t,n]=await Promise.all([resolveExistingRewrites(d),resolveEveDestinationPrefix({appRoot:a,devServerTimeoutMs:o,phase:c,productionDestinationPrefix:f.destinationPrefix,productionServerOrigin:f.localServerOrigin})]);return mergeRewriteRules(t,createEveRewriteRules(n))}}}}export{EVE_NEXT_SERVICE_PREFIX,withEve};
1
+ import{resolveEveDestinationPrefix}from"./server.js";import{ensureEveVercelOutputConfig}from"./vercel-output-config.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isAbsolute,resolve}from"node:path";const EVE_NEXT_SERVICE_PREFIX=`/_eve_internal/eve`,EVE_NEXT_PRODUCTION_PORT_ENV=`EVE_NEXT_PRODUCTION_PORT`,EVE_PROXY_REWRITE_SOURCES=[`${EVE_ROUTE_PREFIX}/:path+`];function resolveApplicationRoot(e){return e===void 0||e.length===0?process.cwd():isAbsolute(e)?e:resolve(process.cwd(),e)}function resolveDevServerTimeout(e){if(e!==void 0){if(!Number.isFinite(e)||e<=0)throw Error(`eve Next.js development server timeout must be a positive number.`);return e}}function normalizeRoutePrefix(e){let t=(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``);if(t.length===0)throw Error(`eve Next.js service prefix cannot resolve to the root route.`);return t}function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function normalizeOrigin(e){return new URL(e.trim()).origin}function readLocalProductionPort(){let e=process.env[EVE_NEXT_PRODUCTION_PORT_ENV];if(e===void 0||e.trim().length===0)return 4274;let t=Number.parseInt(e,10);if(String(t)!==e.trim()||t<1||t>65535)throw Error(`${EVE_NEXT_PRODUCTION_PORT_ENV} must be an integer between 1 and 65535.`);return t}function resolveProductionDestination(e){if(process.env.VERCEL)return{destinationPrefix:e};let t=process.env.EVE_NEXT_PRODUCTION_ORIGIN;if(t!==void 0&&t.trim().length>0)return{destinationPrefix:joinRoutePrefix(normalizeOrigin(t),e)};let n=`http://127.0.0.1:${String(readLocalProductionPort())}`;return{destinationPrefix:n,localServerOrigin:n}}function createEveRewriteRules(e){return EVE_PROXY_REWRITE_SOURCES.map(t=>({destination:joinRoutePrefix(e,t),source:t}))}async function resolveExistingRewrites(e){return await e?.()}function mergeRewriteRules(e,t){return e===void 0?{beforeFiles:t}:isRewriteSections(e)?{...e,beforeFiles:[...t,...e.beforeFiles??[]]}:{afterFiles:e,beforeFiles:t}}function isRewriteSections(e){return!Array.isArray(e)}async function resolveNextConfig(e,t,n){return typeof e==`function`?await e(t,n):e}function withEve(n,r={}){let i=process.cwd(),a=resolveApplicationRoot(r.eveRoot),o=resolveDevServerTimeout(r.devServerTimeoutMs),s=normalizeRoutePrefix(r.servicePrefix??`/_eve_internal/eve`);return async function(c,l){let u=await resolveNextConfig(n,c,l),d=u.rewrites,f=resolveProductionDestination((await ensureEveVercelOutputConfig({appRoot:a,eveBuildCommand:r.eveBuildCommand??`eve build`,nextRoot:i,servicePrefix:s})).servicePrefix);return{...u,async rewrites(){let[t,n]=await Promise.all([resolveExistingRewrites(d),resolveEveDestinationPrefix({appRoot:a,devServerTimeoutMs:o,phase:c,productionDestinationPrefix:f.destinationPrefix,productionServerOrigin:f.localServerOrigin})]);return mergeRewriteRules(t,createEveRewriteRules(n))}}}}export{EVE_NEXT_SERVICE_PREFIX,withEve};
@@ -1 +1 @@
1
- import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{resolvePackageRoot}from"#internal/application/package.js";import{existsSync}from"node:fs";import{join}from"node:path";import{spawn}from"node:child_process";import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";const EVE_BASE_URL_ENV=`EVE_BASE_URL`,DEFAULT_SERVER_READY_TIMEOUT_MS=18e4,SERVER_URL_CANDIDATE_PATTERN=/https?:\/\/[^\s"'<>]+/g,globalStateSymbol=Symbol.for(`eve.next.state`);function getGlobalState(){let e=globalThis;return e[globalStateSymbol]??={servers:new Map},e[globalStateSymbol]}function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function normalizeOrigin(e){return new URL(e).origin}function readEveBaseUrlEnvironment(){let e=process.env[EVE_BASE_URL_ENV];if(!(e===void 0||e.trim().length===0))return normalizeOrigin(e)}function isNodeErrorWithCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function delay(e){return new Promise(t=>setTimeout(t,e))}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function resolveEveCacheDirectory(e){return join(e,`.eve`)}function resolveEveDevServerRegistryPath(e){return join(resolveEveCacheDirectory(e),`next-dev-server.json`)}function resolveEveDevServerLockPath(e){return join(resolveEveCacheDirectory(e),`next-dev-server.lock`)}function normalizeDevServerRegistry(e){if(isRecord(e)&&!(typeof e.appRoot!=`string`||typeof e.origin!=`string`||typeof e.updatedAt!=`string`)&&!(e.pid!==null&&typeof e.pid!=`number`))try{return{appRoot:e.appRoot,origin:normalizeOrigin(e.origin),pid:e.pid,updatedAt:e.updatedAt}}catch{return}}async function isEveServerHealthy(t){let n=new AbortController,r=setTimeout(()=>{n.abort()},1e3);try{return(await fetch(joinRoutePrefix(t,`${EVE_ROUTE_PREFIX}/health`),{signal:n.signal})).ok}catch{return!1}finally{clearTimeout(r)}}async function readUsableEveDevServerRegistry(e){try{let t=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e),`utf8`)));return t===void 0||t.appRoot!==e||!await isEveServerHealthy(t.origin)?void 0:(process.env[EVE_BASE_URL_ENV]=t.origin,t.origin)}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e),`${JSON.stringify({appRoot:e,origin:t.origin,pid:t.process?.pid??null,updatedAt:new Date().toISOString()},null,2)}\n`)}async function removeStaleEveDevServerLock(e){try{let t=await stat(e);Date.now()-t.mtimeMs>3e4&&await rm(e,{force:!0})}catch(e){if(!isNodeErrorWithCode(e,`ENOENT`))throw e}}async function acquireEveDevServerLock(e,t){let n=resolveEveCacheDirectory(e),r=resolveEveDevServerLockPath(e),i=Date.now()+t;for(await mkdir(n,{recursive:!0});;)try{let e=await open(r,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(r,{force:!0})}}catch(n){if(!isNodeErrorWithCode(n,`EEXIST`))throw n;if(await readUsableEveDevServerRegistry(e)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(r),Date.now()>i)throw Error(`Timed out after ${t}ms waiting for another Next.js process to start Eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}function isLoopbackHostname(e){return e===`localhost`||e===`::1`||e===`[::1]`||/^127(?:\.\d{1,3}){3}$/.test(e)}function parseLocalServerOrigin(e){let t=URL.parse(e);if(!(t===null||t.protocol!==`http:`&&t.protocol!==`https:`||!isLoopbackHostname(t.hostname)||t.port.length===0))return t.origin}function findLocalServerOrigin(e){for(let t of e.matchAll(SERVER_URL_CANDIDATE_PATTERN)){let e=t[0],n=parseLocalServerOrigin(e);if(n!==void 0)return n}}function startServerProcess(e){return new Promise((t,n)=>{let r=spawn(e.command,e.args,{cwd:e.cwd,env:{...process.env,...e.env},stdio:[`ignore`,`pipe`,`pipe`]}),a=setTimeout(()=>{r.kill(),n(Error(`Timed out after ${e.timeoutMs??DEFAULT_SERVER_READY_TIMEOUT_MS}ms waiting for Eve to print its server URL.`))},e.timeoutMs??DEFAULT_SERVER_READY_TIMEOUT_MS),cleanup=()=>{clearTimeout(a),r.off(`error`,handleError),r.off(`exit`,handleEarlyExit)},handleError=e=>{cleanup(),n(e)},handleEarlyExit=(e,t)=>{cleanup(),n(Error(`Eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},handleOutput=e=>{let n=findLocalServerOrigin(e.toString(`utf8`));n!==void 0&&(cleanup(),t({origin:n,process:r}))};r.once(`error`,handleError),r.once(`exit`,handleEarlyExit),r.stdout.on(`data`,e=>{process.stdout.write(e),handleOutput(e)}),r.stderr.on(`data`,e=>{process.stderr.write(e),handleOutput(e)})})}function installProcessShutdown(e){let t=e.process;if(t===void 0)return e;let close=()=>{t.killed||t.kill()};return process.once(`beforeExit`,close),process.once(`exit`,close),e}function startEveDevServer(e,t){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`],command:process.execPath,cwd:e,timeoutMs:t}).then(e=>(process.env[EVE_BASE_URL_ENV]=e.origin,installProcessShutdown(e)))}function startEveProductionServer(e){let t=new URL(e.origin),i=t.port,a=join(e.appRoot,`.output`,`server`,`index.mjs`);if(existsSync(a))return startServerProcess({args:[a],command:process.execPath,cwd:e.appRoot,env:{HOST:t.hostname,NITRO_HOST:t.hostname,NITRO_PORT:i,PORT:i}}).then(installProcessShutdown)}async function resolveSharedEveDevServer(e,t){let n=await readUsableEveDevServerRegistry(e);if(n!==void 0)return{origin:n};let r=await acquireEveDevServerLock(e,t);try{let n=await readUsableEveDevServerRegistry(e);if(n!==void 0)return{origin:n};let r=await startEveDevServer(e,t);return await writeEveDevServerRegistry(e,r),r}finally{await r()}}async function resolveEveDestinationPrefix(e){let t=getGlobalState();if(process.env.NODE_ENV===`production`){if(e.phase===`phase-production-build`)return e.productionDestinationPrefix;let n=`production:${e.appRoot}`,r=t.servers.get(n);return r===void 0&&(r=process.env.VERCEL||e.productionServerOrigin===void 0?void 0:startEveProductionServer({appRoot:e.appRoot,origin:e.productionServerOrigin}),r!==void 0&&(r=r.catch(e=>{throw t.servers.delete(n),e}),t.servers.set(n,r))),r===void 0?e.productionDestinationPrefix:(await r).origin}let n=readEveBaseUrlEnvironment();if(n!==void 0)return n;if(process.env.NODE_ENV!==`development`)return e.productionDestinationPrefix;let r=`dev:${e.appRoot}`,i=t.servers.get(r);return i===void 0&&(i=resolveSharedEveDevServer(e.appRoot,e.devServerTimeoutMs??18e4).catch(e=>{throw t.servers.delete(r),e}),t.servers.set(r,i)),(await i).origin}export{resolveEveDestinationPrefix};
1
+ import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{resolvePackageRoot}from"#internal/application/package.js";import{existsSync}from"node:fs";import{join}from"node:path";import{spawn}from"node:child_process";import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";const EVE_BASE_URL_ENV=`EVE_BASE_URL`,DEFAULT_SERVER_READY_TIMEOUT_MS=18e4,SERVER_URL_CANDIDATE_PATTERN=/https?:\/\/[^\s"'<>]+/g,globalStateSymbol=Symbol.for(`eve.next.state`);function getGlobalState(){let e=globalThis;return e[globalStateSymbol]??={servers:new Map},e[globalStateSymbol]}function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function normalizeOrigin(e){return new URL(e).origin}function readEveBaseUrlEnvironment(){let e=process.env[EVE_BASE_URL_ENV];if(!(e===void 0||e.trim().length===0))return normalizeOrigin(e)}function isNodeErrorWithCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function delay(e){return new Promise(t=>setTimeout(t,e))}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function resolveEveCacheDirectory(e){return join(e,`.eve`)}function resolveEveDevServerRegistryPath(e){return join(resolveEveCacheDirectory(e),`next-dev-server.json`)}function resolveEveDevServerLockPath(e){return join(resolveEveCacheDirectory(e),`next-dev-server.lock`)}function normalizeDevServerRegistry(e){if(isRecord(e)&&!(typeof e.appRoot!=`string`||typeof e.origin!=`string`||typeof e.updatedAt!=`string`)&&!(e.pid!==null&&typeof e.pid!=`number`))try{return{appRoot:e.appRoot,origin:normalizeOrigin(e.origin),pid:e.pid,updatedAt:e.updatedAt}}catch{return}}async function isEveServerHealthy(t){let n=new AbortController,r=setTimeout(()=>{n.abort()},1e3);try{return(await fetch(joinRoutePrefix(t,`${EVE_ROUTE_PREFIX}/health`),{signal:n.signal})).ok}catch{return!1}finally{clearTimeout(r)}}async function readUsableEveDevServerRegistry(e){try{let t=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e),`utf8`)));return t===void 0||t.appRoot!==e||!await isEveServerHealthy(t.origin)?void 0:(process.env[EVE_BASE_URL_ENV]=t.origin,t.origin)}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e),`${JSON.stringify({appRoot:e,origin:t.origin,pid:t.process?.pid??null,updatedAt:new Date().toISOString()},null,2)}\n`)}async function removeStaleEveDevServerLock(e){try{let t=await stat(e);Date.now()-t.mtimeMs>3e4&&await rm(e,{force:!0})}catch(e){if(!isNodeErrorWithCode(e,`ENOENT`))throw e}}async function acquireEveDevServerLock(e,t){let n=resolveEveCacheDirectory(e),r=resolveEveDevServerLockPath(e),i=Date.now()+t;for(await mkdir(n,{recursive:!0});;)try{let e=await open(r,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(r,{force:!0})}}catch(n){if(!isNodeErrorWithCode(n,`EEXIST`))throw n;if(await readUsableEveDevServerRegistry(e)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(r),Date.now()>i)throw Error(`Timed out after ${t}ms waiting for another Next.js process to start eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}function isLoopbackHostname(e){return e===`localhost`||e===`::1`||e===`[::1]`||/^127(?:\.\d{1,3}){3}$/.test(e)}function parseLocalServerOrigin(e){let t=URL.parse(e);if(!(t===null||t.protocol!==`http:`&&t.protocol!==`https:`||!isLoopbackHostname(t.hostname)||t.port.length===0))return t.origin}function findLocalServerOrigin(e){for(let t of e.matchAll(SERVER_URL_CANDIDATE_PATTERN)){let e=t[0],n=parseLocalServerOrigin(e);if(n!==void 0)return n}}function startServerProcess(e){return new Promise((t,n)=>{let r=spawn(e.command,e.args,{cwd:e.cwd,env:{...process.env,...e.env},stdio:[`ignore`,`pipe`,`pipe`]}),a=setTimeout(()=>{r.kill(),n(Error(`Timed out after ${e.timeoutMs??DEFAULT_SERVER_READY_TIMEOUT_MS}ms waiting for eve to print its server URL.`))},e.timeoutMs??DEFAULT_SERVER_READY_TIMEOUT_MS),cleanup=()=>{clearTimeout(a),r.off(`error`,handleError),r.off(`exit`,handleEarlyExit)},handleError=e=>{cleanup(),n(e)},handleEarlyExit=(e,t)=>{cleanup(),n(Error(`eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},handleOutput=e=>{let n=findLocalServerOrigin(e.toString(`utf8`));n!==void 0&&(cleanup(),t({origin:n,process:r}))};r.once(`error`,handleError),r.once(`exit`,handleEarlyExit),r.stdout.on(`data`,e=>{process.stdout.write(e),handleOutput(e)}),r.stderr.on(`data`,e=>{process.stderr.write(e),handleOutput(e)})})}function installProcessShutdown(e){let t=e.process;if(t===void 0)return e;let close=()=>{t.killed||t.kill()};return process.once(`beforeExit`,close),process.once(`exit`,close),e}function startEveDevServer(e,t){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`],command:process.execPath,cwd:e,timeoutMs:t}).then(e=>(process.env[EVE_BASE_URL_ENV]=e.origin,installProcessShutdown(e)))}function startEveProductionServer(e){let t=new URL(e.origin),i=t.port,a=join(e.appRoot,`.output`,`server`,`index.mjs`);if(existsSync(a))return startServerProcess({args:[a],command:process.execPath,cwd:e.appRoot,env:{HOST:t.hostname,NITRO_HOST:t.hostname,NITRO_PORT:i,PORT:i}}).then(installProcessShutdown)}async function resolveSharedEveDevServer(e,t){let n=await readUsableEveDevServerRegistry(e);if(n!==void 0)return{origin:n};let r=await acquireEveDevServerLock(e,t);try{let n=await readUsableEveDevServerRegistry(e);if(n!==void 0)return{origin:n};let r=await startEveDevServer(e,t);return await writeEveDevServerRegistry(e,r),r}finally{await r()}}async function resolveEveDestinationPrefix(e){let t=getGlobalState();if(process.env.NODE_ENV===`production`){if(e.phase===`phase-production-build`)return e.productionDestinationPrefix;let n=`production:${e.appRoot}`,r=t.servers.get(n);return r===void 0&&(r=process.env.VERCEL||e.productionServerOrigin===void 0?void 0:startEveProductionServer({appRoot:e.appRoot,origin:e.productionServerOrigin}),r!==void 0&&(r=r.catch(e=>{throw t.servers.delete(n),e}),t.servers.set(n,r))),r===void 0?e.productionDestinationPrefix:(await r).origin}let n=readEveBaseUrlEnvironment();if(n!==void 0)return n;if(process.env.NODE_ENV!==`development`)return e.productionDestinationPrefix;let r=`dev:${e.appRoot}`,i=t.servers.get(r);return i===void 0&&(i=resolveSharedEveDevServer(e.appRoot,e.devServerTimeoutMs??18e4).catch(e=>{throw t.servers.delete(r),e}),t.servers.set(r,i)),(await i).origin}export{resolveEveDestinationPrefix};
@@ -1 +1 @@
1
- import{dirname,join,relative}from"node:path";import{mkdir,readFile,writeFile}from"node:fs/promises";import{findClosestLinkedVercelDirectory,findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";const VERCEL_JSON_FILE_NAME=`vercel.json`,VERCEL_OUTPUT_CONFIG_FILE_NAME=`.vercel/output/config.json`;function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hasServices(e){return e!==void 0&&Object.keys(e).length>0}function resolveRelativeEntrypoint(e,t){let r=relative(e,t);return r.length===0?`.`:r.replaceAll(`\\`,`/`)}async function resolveVercelOutputConfigLocation(n){let r=await findClosestLinkedVercelDirectory(n),i=r===void 0?n:dirname(r),a=await findClosestVercelOutputDirectory(n);return a===void 0?r===void 0?{canWriteGeneratedOutput:!1,outputConfigPath:join(n,VERCEL_OUTPUT_CONFIG_FILE_NAME),projectRoot:i}:{canWriteGeneratedOutput:!0,outputConfigPath:join(r,`output`,`config.json`),projectRoot:i}:{canWriteGeneratedOutput:!0,outputConfigPath:join(a,`config.json`),projectRoot:i}}function normalizeVercelServicesConfig(e,t){if(!isRecord(e))throw Error(`${t} must contain a JSON object.`);let n=e.experimentalServices;if(n!==void 0&&!isRecord(n))throw Error(`${t} experimentalServices must be a JSON object.`);return e}async function readVercelServicesConfig(e,t){try{return normalizeVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),t)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}}function findServiceByFramework(e,t){return Object.values(e).find(e=>e.framework===t)}function resolveServicePrefix(e){if(e!==void 0){if(typeof e.routePrefix==`string`&&e.routePrefix.trim().length>0)return e.routePrefix.trim();if(typeof e.mount==`string`&&e.mount.trim().length>0)return e.mount.trim();if(isRecord(e.mount)&&typeof e.mount.path==`string`&&e.mount.path.trim().length>0)return e.mount.path.trim()}}function resolveConfiguredServicePrefix(e){return resolveServicePrefix(findServiceByFramework(e.services,`eve`))??e.servicePrefix}function assertRootServicesAreComplete(e){let t=findServiceByFramework(e.services,`eve`),n=findServiceByFramework(e.services,`nextjs`);if(t!==void 0&&n!==void 0)return resolveServicePrefix(t)??e.servicePrefix;throw Error(`${VERCEL_JSON_FILE_NAME} already defines experimentalServices, so withEve cannot add generated services through ${VERCEL_OUTPUT_CONFIG_FILE_NAME}. Add both the Next.js and Eve services to ${VERCEL_JSON_FILE_NAME}, or remove experimentalServices from ${VERCEL_JSON_FILE_NAME}.`)}async function ensureEveVercelOutputConfig(n){let{canWriteGeneratedOutput:i,outputConfigPath:o,projectRoot:s}=await resolveVercelOutputConfigLocation(n.nextRoot),c=(await readVercelServicesConfig(join(s,VERCEL_JSON_FILE_NAME),VERCEL_JSON_FILE_NAME)).experimentalServices;if(hasServices(c))return{servicePrefix:assertRootServicesAreComplete({services:c,servicePrefix:n.servicePrefix})};let l=await readVercelServicesConfig(o,VERCEL_OUTPUT_CONFIG_FILE_NAME),u=resolveRelativeEntrypoint(n.nextRoot,n.appRoot),d=l.experimentalServices??{},f=findServiceByFramework(d,`eve`),p=findServiceByFramework(d,`nextjs`),m=resolveConfiguredServicePrefix({services:d,servicePrefix:n.servicePrefix});if(!i)return{servicePrefix:m};let h={...d};p===void 0&&(h.web={entrypoint:`.`,framework:`nextjs`,mount:`/`,type:`web`}),f===void 0&&(h.eve={buildCommand:n.eveBuildCommand,entrypoint:u,framework:`eve`,mount:m,type:`web`});let g={...l,version:3,experimentalServices:h};return JSON.stringify(l)!==JSON.stringify(g)&&(await mkdir(dirname(o),{recursive:!0}),await writeFile(o,`${JSON.stringify(g,null,2)}\n`)),{servicePrefix:m}}export{ensureEveVercelOutputConfig};
1
+ import{dirname,join,relative}from"node:path";import{mkdir,readFile,writeFile}from"node:fs/promises";import{findClosestLinkedVercelDirectory,findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";const VERCEL_JSON_FILE_NAME=`vercel.json`,VERCEL_OUTPUT_CONFIG_FILE_NAME=`.vercel/output/config.json`;function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hasServices(e){return e!==void 0&&Object.keys(e).length>0}function resolveRelativeEntrypoint(e,t){let r=relative(e,t);return r.length===0?`.`:r.replaceAll(`\\`,`/`)}async function resolveVercelOutputConfigLocation(n){let r=await findClosestLinkedVercelDirectory(n),i=r===void 0?n:dirname(r),a=await findClosestVercelOutputDirectory(n);return a===void 0?r===void 0?{canWriteGeneratedOutput:!1,outputConfigPath:join(n,VERCEL_OUTPUT_CONFIG_FILE_NAME),projectRoot:i}:{canWriteGeneratedOutput:!0,outputConfigPath:join(r,`output`,`config.json`),projectRoot:i}:{canWriteGeneratedOutput:!0,outputConfigPath:join(a,`config.json`),projectRoot:i}}function normalizeVercelServicesConfig(e,t){if(!isRecord(e))throw Error(`${t} must contain a JSON object.`);let n=e.experimentalServices;if(n!==void 0&&!isRecord(n))throw Error(`${t} experimentalServices must be a JSON object.`);return e}async function readVercelServicesConfig(e,t){try{return normalizeVercelServicesConfig(JSON.parse(await readFile(e,`utf8`)),t)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}}function findServiceByFramework(e,t){return Object.values(e).find(e=>e.framework===t)}function resolveServicePrefix(e){if(e!==void 0){if(typeof e.routePrefix==`string`&&e.routePrefix.trim().length>0)return e.routePrefix.trim();if(typeof e.mount==`string`&&e.mount.trim().length>0)return e.mount.trim();if(isRecord(e.mount)&&typeof e.mount.path==`string`&&e.mount.path.trim().length>0)return e.mount.path.trim()}}function resolveConfiguredServicePrefix(e){return resolveServicePrefix(findServiceByFramework(e.services,`eve`))??e.servicePrefix}function assertRootServicesAreComplete(e){let t=findServiceByFramework(e.services,`eve`),n=findServiceByFramework(e.services,`nextjs`);if(t!==void 0&&n!==void 0)return resolveServicePrefix(t)??e.servicePrefix;throw Error(`${VERCEL_JSON_FILE_NAME} already defines experimentalServices, so withEve cannot add generated services through ${VERCEL_OUTPUT_CONFIG_FILE_NAME}. Add both the Next.js and eve services to ${VERCEL_JSON_FILE_NAME}, or remove experimentalServices from ${VERCEL_JSON_FILE_NAME}.`)}async function ensureEveVercelOutputConfig(n){let{canWriteGeneratedOutput:i,outputConfigPath:o,projectRoot:s}=await resolveVercelOutputConfigLocation(n.nextRoot),c=(await readVercelServicesConfig(join(s,VERCEL_JSON_FILE_NAME),VERCEL_JSON_FILE_NAME)).experimentalServices;if(hasServices(c))return{servicePrefix:assertRootServicesAreComplete({services:c,servicePrefix:n.servicePrefix})};let l=await readVercelServicesConfig(o,VERCEL_OUTPUT_CONFIG_FILE_NAME),u=resolveRelativeEntrypoint(n.nextRoot,n.appRoot),d=l.experimentalServices??{},f=findServiceByFramework(d,`eve`),p=findServiceByFramework(d,`nextjs`),m=resolveConfiguredServicePrefix({services:d,servicePrefix:n.servicePrefix});if(!i)return{servicePrefix:m};let h={...d};p===void 0&&(h.web={entrypoint:`.`,framework:`nextjs`,mount:`/`,type:`web`}),f===void 0&&(h.eve={buildCommand:n.eveBuildCommand,entrypoint:u,framework:`eve`,mount:m,type:`web`});let g={...l,version:3,experimentalServices:h};return JSON.stringify(l)!==JSON.stringify(g)&&(await mkdir(dirname(o),{recursive:!0}),await writeFile(o,`${JSON.stringify(g,null,2)}\n`)),{servicePrefix:m}}export{ensureEveVercelOutputConfig};
@@ -17,8 +17,8 @@ export interface EveDevServerRegistry {
17
17
  */
18
18
  export declare function normalizeDevServerRegistry(value: unknown): EveDevServerRegistry | undefined;
19
19
  /**
20
- * Resolve a shared Eve dev server for {@link appRoot}, reusing a healthy
20
+ * Resolve a shared eve dev server for {@link appRoot}, reusing a healthy
21
21
  * registered server when one exists and otherwise spawning a new one behind a
22
- * cross-process lock so concurrent Nuxt processes don't each boot Eve.
22
+ * cross-process lock so concurrent Nuxt processes don't each boot eve.
23
23
  */
24
24
  export declare function resolveSharedEveDevServer(appRoot: string): Promise<EveProcessHandle>;
@@ -1 +1 @@
1
- import{joinRoutePrefix,normalizeOrigin}from"./routing.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{resolvePackageRoot}from"#internal/application/package.js";import{join}from"node:path";import{spawn}from"node:child_process";import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";const EVE_BASE_URL_ENV=`EVE_BASE_URL`,DEFAULT_SERVER_READY_TIMEOUT_MS=3e4,DEV_SERVER_REGISTRY_TIMEOUT_MS=3e4,LOCAL_SERVER_URL_PATTERN=/https?:\/\/(?:\[[^\]\s]+\]|[^\s/:[\]]+)(?::\d+)?/;function isNodeErrorWithCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function delay(e){return new Promise(t=>setTimeout(t,e))}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function resolveEveCacheDirectory(e){return join(e,`.eve`)}function resolveEveDevServerRegistryPath(e){return join(resolveEveCacheDirectory(e),`nuxt-dev-server.json`)}function resolveEveDevServerLockPath(e){return join(resolveEveCacheDirectory(e),`nuxt-dev-server.lock`)}function normalizeDevServerRegistry(e){if(isRecord(e)&&!(typeof e.appRoot!=`string`||typeof e.origin!=`string`||typeof e.updatedAt!=`string`)&&!(e.pid!==null&&typeof e.pid!=`number`))try{return{appRoot:e.appRoot,origin:normalizeOrigin(e.origin),pid:e.pid,updatedAt:e.updatedAt}}catch{return}}async function isEveServerHealthy(t){let r=new AbortController,i=setTimeout(()=>r.abort(),1e3);try{return(await fetch(joinRoutePrefix(t,`${EVE_ROUTE_PREFIX}/health`),{signal:r.signal})).ok}catch{return!1}finally{clearTimeout(i)}}async function readUsableEveDevServerRegistry(e){try{let t=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e),`utf8`)));return t===void 0||t.appRoot!==e||!await isEveServerHealthy(t.origin)?void 0:t.origin}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e),`${JSON.stringify({appRoot:e,origin:t.origin,pid:t.process?.pid??null,updatedAt:new Date().toISOString()},null,2)}\n`)}async function removeStaleEveDevServerLock(e){try{let t=await stat(e);Date.now()-t.mtimeMs>3e4&&await rm(e,{force:!0})}catch(e){if(!isNodeErrorWithCode(e,`ENOENT`))throw e}}async function acquireEveDevServerLock(e){let t=resolveEveCacheDirectory(e),n=resolveEveDevServerLockPath(e),r=Date.now()+DEV_SERVER_REGISTRY_TIMEOUT_MS;for(await mkdir(t,{recursive:!0});;)try{let e=await open(n,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(n,{force:!0})}}catch(t){if(!isNodeErrorWithCode(t,`EEXIST`))throw t;if(await readUsableEveDevServerRegistry(e)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(n),Date.now()>r)throw Error(`Timed out after ${DEV_SERVER_REGISTRY_TIMEOUT_MS}ms waiting for another Nuxt process to start Eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}function startServerProcess(e){return new Promise((n,r)=>{let i=spawn(e.command,e.args,{cwd:e.cwd,env:{...process.env,...e.env},stdio:[`ignore`,`pipe`,`pipe`]}),a=setTimeout(()=>{i.kill(),r(Error(`Timed out after ${DEFAULT_SERVER_READY_TIMEOUT_MS}ms waiting for Eve to print its server URL.`))},DEFAULT_SERVER_READY_TIMEOUT_MS),cleanup=()=>{clearTimeout(a),i.off(`error`,handleError),i.off(`exit`,handleEarlyExit)},handleError=e=>{cleanup(),r(e)},handleEarlyExit=(e,t)=>{cleanup(),r(Error(`Eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},o=!1,handleOutput=e=>{if(o)return;let r=LOCAL_SERVER_URL_PATTERN.exec(e.toString(`utf8`));r!==null&&(o=!0,cleanup(),n({origin:normalizeOrigin(r[0]),process:i}))};i.once(`error`,handleError),i.once(`exit`,handleEarlyExit),i.stdout.on(`data`,e=>{process.stdout.write(e),handleOutput(e)}),i.stderr.on(`data`,e=>{process.stderr.write(e),handleOutput(e)})})}function installProcessShutdown(e){let t=e.process;if(t===void 0)return e;let close=()=>{process.off(`beforeExit`,close),process.off(`exit`,close),t.killed||t.kill()};return process.once(`beforeExit`,close),process.once(`exit`,close),e}function startEveDevServer(e){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`],command:process.execPath,cwd:e}).then(e=>(process.env[EVE_BASE_URL_ENV]=e.origin,installProcessShutdown(e)))}async function resolveSharedEveDevServer(e){let t=await readUsableEveDevServerRegistry(e);if(t!==void 0)return process.env[EVE_BASE_URL_ENV]=t,{origin:t};let n=await acquireEveDevServerLock(e);try{let t=await readUsableEveDevServerRegistry(e);if(t!==void 0)return process.env[EVE_BASE_URL_ENV]=t,{origin:t};let n=await startEveDevServer(e);return await writeEveDevServerRegistry(e,n),n}finally{await n()}}export{EVE_BASE_URL_ENV,normalizeDevServerRegistry,resolveSharedEveDevServer};
1
+ import{joinRoutePrefix,normalizeOrigin}from"./routing.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{resolvePackageRoot}from"#internal/application/package.js";import{join}from"node:path";import{spawn}from"node:child_process";import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";const EVE_BASE_URL_ENV=`EVE_BASE_URL`,DEFAULT_SERVER_READY_TIMEOUT_MS=3e4,DEV_SERVER_REGISTRY_TIMEOUT_MS=3e4,LOCAL_SERVER_URL_PATTERN=/https?:\/\/(?:\[[^\]\s]+\]|[^\s/:[\]]+)(?::\d+)?/;function isNodeErrorWithCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function delay(e){return new Promise(t=>setTimeout(t,e))}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function resolveEveCacheDirectory(e){return join(e,`.eve`)}function resolveEveDevServerRegistryPath(e){return join(resolveEveCacheDirectory(e),`nuxt-dev-server.json`)}function resolveEveDevServerLockPath(e){return join(resolveEveCacheDirectory(e),`nuxt-dev-server.lock`)}function normalizeDevServerRegistry(e){if(isRecord(e)&&!(typeof e.appRoot!=`string`||typeof e.origin!=`string`||typeof e.updatedAt!=`string`)&&!(e.pid!==null&&typeof e.pid!=`number`))try{return{appRoot:e.appRoot,origin:normalizeOrigin(e.origin),pid:e.pid,updatedAt:e.updatedAt}}catch{return}}async function isEveServerHealthy(t){let r=new AbortController,i=setTimeout(()=>r.abort(),1e3);try{return(await fetch(joinRoutePrefix(t,`${EVE_ROUTE_PREFIX}/health`),{signal:r.signal})).ok}catch{return!1}finally{clearTimeout(i)}}async function readUsableEveDevServerRegistry(e){try{let t=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e),`utf8`)));return t===void 0||t.appRoot!==e||!await isEveServerHealthy(t.origin)?void 0:t.origin}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e),`${JSON.stringify({appRoot:e,origin:t.origin,pid:t.process?.pid??null,updatedAt:new Date().toISOString()},null,2)}\n`)}async function removeStaleEveDevServerLock(e){try{let t=await stat(e);Date.now()-t.mtimeMs>3e4&&await rm(e,{force:!0})}catch(e){if(!isNodeErrorWithCode(e,`ENOENT`))throw e}}async function acquireEveDevServerLock(e){let t=resolveEveCacheDirectory(e),n=resolveEveDevServerLockPath(e),r=Date.now()+DEV_SERVER_REGISTRY_TIMEOUT_MS;for(await mkdir(t,{recursive:!0});;)try{let e=await open(n,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(n,{force:!0})}}catch(t){if(!isNodeErrorWithCode(t,`EEXIST`))throw t;if(await readUsableEveDevServerRegistry(e)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(n),Date.now()>r)throw Error(`Timed out after ${DEV_SERVER_REGISTRY_TIMEOUT_MS}ms waiting for another Nuxt process to start eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}function startServerProcess(e){return new Promise((n,r)=>{let i=spawn(e.command,e.args,{cwd:e.cwd,env:{...process.env,...e.env},stdio:[`ignore`,`pipe`,`pipe`]}),a=setTimeout(()=>{i.kill(),r(Error(`Timed out after ${DEFAULT_SERVER_READY_TIMEOUT_MS}ms waiting for eve to print its server URL.`))},DEFAULT_SERVER_READY_TIMEOUT_MS),cleanup=()=>{clearTimeout(a),i.off(`error`,handleError),i.off(`exit`,handleEarlyExit)},handleError=e=>{cleanup(),r(e)},handleEarlyExit=(e,t)=>{cleanup(),r(Error(`eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},o=!1,handleOutput=e=>{if(o)return;let r=LOCAL_SERVER_URL_PATTERN.exec(e.toString(`utf8`));r!==null&&(o=!0,cleanup(),n({origin:normalizeOrigin(r[0]),process:i}))};i.once(`error`,handleError),i.once(`exit`,handleEarlyExit),i.stdout.on(`data`,e=>{process.stdout.write(e),handleOutput(e)}),i.stderr.on(`data`,e=>{process.stderr.write(e),handleOutput(e)})})}function installProcessShutdown(e){let t=e.process;if(t===void 0)return e;let close=()=>{process.off(`beforeExit`,close),process.off(`exit`,close),t.killed||t.kill()};return process.once(`beforeExit`,close),process.once(`exit`,close),e}function startEveDevServer(e){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`],command:process.execPath,cwd:e}).then(e=>(process.env[EVE_BASE_URL_ENV]=e.origin,installProcessShutdown(e)))}async function resolveSharedEveDevServer(e){let t=await readUsableEveDevServerRegistry(e);if(t!==void 0)return process.env[EVE_BASE_URL_ENV]=t,{origin:t};let n=await acquireEveDevServerLock(e);try{let t=await readUsableEveDevServerRegistry(e);if(t!==void 0)return process.env[EVE_BASE_URL_ENV]=t,{origin:t};let n=await startEveDevServer(e);return await writeEveDevServerRegistry(e,n),n}finally{await n()}}export{EVE_BASE_URL_ENV,normalizeDevServerRegistry,resolveSharedEveDevServer};
@@ -1,42 +1,42 @@
1
1
  import { EVE_NUXT_SERVICE_PREFIX } from "./routing.js";
2
2
  export { EVE_NUXT_SERVICE_PREFIX };
3
3
  /**
4
- * Options for the Eve Nuxt module.
4
+ * Options for the eve Nuxt module.
5
5
  */
6
6
  export interface EveNuxtModuleOptions {
7
7
  /**
8
- * Path to the Eve application root, resolved relative to the Nuxt project
8
+ * Path to the eve application root, resolved relative to the Nuxt project
9
9
  * root unless absolute. Defaults to the Nuxt project root. The dev server is
10
- * spawned here and written as the Eve service entrypoint in `vercel.json`
10
+ * spawned here and written as the eve service entrypoint in `vercel.json`
11
11
  * (relative to the Nuxt root).
12
12
  */
13
13
  eveRoot?: string;
14
14
  /**
15
- * Build command for the generated Eve Vercel service. Defaults to `"eve build"`.
15
+ * Build command for the generated eve Vercel service. Defaults to `"eve build"`.
16
16
  */
17
17
  eveBuildCommand?: string;
18
18
  /**
19
19
  * Set to `false` to skip creating or updating `vercel.json`. By default the
20
20
  * module ensures `vercel.json` contains `experimentalServices` for the Nuxt
21
- * app and Eve app.
21
+ * app and eve app.
22
22
  */
23
23
  configureVercelJson?: boolean;
24
24
  /**
25
- * Private Vercel service prefix Eve transport is proxied to. Defaults to
25
+ * Private Vercel service prefix eve transport is proxied to. Defaults to
26
26
  * {@link EVE_NUXT_SERVICE_PREFIX}. When `configureVercelJson` is enabled, it
27
- * is written as the Eve service `routePrefix`, but an existing `routePrefix`
27
+ * is written as the eve service `routePrefix`, but an existing `routePrefix`
28
28
  * in `vercel.json` takes precedence. Normalized to a leading-slash,
29
29
  * no-trailing-slash route; cannot resolve to `/`.
30
30
  */
31
31
  servicePrefix?: string;
32
32
  }
33
33
  /**
34
- * Nuxt module that wires an Eve agent into a Nuxt app. Register under `modules`
34
+ * Nuxt module that wires an eve agent into a Nuxt app. Register under `modules`
35
35
  * (configured via the `eve` config key). It auto-imports the `useEveAgent()`
36
- * composable, routes Eve transport requests (`/eve/v1/**`) to the Eve service
36
+ * composable, routes eve transport requests (`/eve/v1/**`) to the eve service
37
37
  * (a shared dev server spawned on demand in dev, a Vercel sibling service or a
38
38
  * configured origin/port in production), and unless `configureVercelJson` is
39
- * `false`, ensures `vercel.json` declares both the Nuxt and Eve services.
39
+ * `false`, ensures `vercel.json` declares both the Nuxt and eve services.
40
40
  * Requires Nuxt >= 4.0.0. Configure via {@link EveNuxtModuleOptions}.
41
41
  */
42
42
  declare const _default: import("nuxt/schema").NuxtModule<EveNuxtModuleOptions, EveNuxtModuleOptions, false>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Private route namespace used when a Vercel deployment hosts Eve as a
2
+ * Private route namespace used when a Vercel deployment hosts eve as a
3
3
  * separate experimental service behind the Nuxt app.
4
4
  */
5
5
  export declare const EVE_NUXT_SERVICE_PREFIX = "/_eve_internal/eve";
@@ -18,7 +18,7 @@ export declare function joinRoutePrefix(prefix: string, path: string): string;
18
18
  */
19
19
  export declare function normalizeOrigin(origin: string): string;
20
20
  /**
21
- * Resolve the local production port the module proxies to when an Eve service
21
+ * Resolve the local production port the module proxies to when an eve service
22
22
  * runs alongside a non-Vercel Nuxt deployment. Defaults to
23
23
  * {@link DEFAULT_EVE_NUXT_PRODUCTION_PORT}.
24
24
  */
@@ -31,14 +31,14 @@ export interface EveVercelRewriteRoute {
31
31
  readonly dest: string;
32
32
  /**
33
33
  * Re-run route matching against the rewritten `dest`. Required so the
34
- * rewritten Eve service path is routed to the sibling Eve service instead of
34
+ * rewritten eve service path is routed to the sibling eve service instead of
35
35
  * being resolved inside the host service's own filesystem (which 404s).
36
36
  */
37
37
  readonly check: true;
38
38
  }
39
39
  /**
40
- * Build the edge-level Vercel rewrite that forwards Eve transport requests
41
- * (`/eve/v1/**`) to the Eve service prefix (`/_eve_internal/eve/eve/v1/**`).
40
+ * Build the edge-level Vercel rewrite that forwards eve transport requests
41
+ * (`/eve/v1/**`) to the eve service prefix (`/_eve_internal/eve/eve/v1/**`).
42
42
  *
43
43
  * Mirrors the Next.js integration's `beforeFiles` rewrite. A Nitro runtime
44
44
  * `proxy` route rule cannot reach a sibling Vercel service — the proxied
@@ -47,7 +47,7 @@ export interface EveVercelRewriteRoute {
47
47
  */
48
48
  export declare function createEveVercelRewriteRoute(servicePrefix: string): EveVercelRewriteRoute;
49
49
  /**
50
- * Resolve the proxy destination for Eve routes in production.
50
+ * Resolve the proxy destination for eve routes in production.
51
51
  *
52
52
  * On Vercel the destination is the private service prefix. Off Vercel it is an
53
53
  * explicit origin override (`EVE_NUXT_PRODUCTION_ORIGIN`) or a local port.
@@ -1 +1 @@
1
- import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";const EVE_NUXT_SERVICE_PREFIX=`/_eve_internal/eve`,EVE_NUXT_PRODUCTION_PORT_ENV=`EVE_NUXT_PRODUCTION_PORT`;function normalizeRoutePrefix(e){let t=(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``);if(t.length===0)throw Error(`Eve Nuxt service prefix cannot resolve to the root route.`);return t}function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function normalizeOrigin(e){return new URL(e.trim()).origin}function readLocalProductionPort(){let e=process.env[EVE_NUXT_PRODUCTION_PORT_ENV];if(e===void 0||e.trim().length===0)return 4274;let t=Number.parseInt(e,10);if(String(t)!==e.trim()||t<1||t>65535)throw Error(`${EVE_NUXT_PRODUCTION_PORT_ENV} must be an integer between 1 and 65535.`);return t}function createEveVercelRewriteRoute(t){let n=joinRoutePrefix(t,EVE_ROUTE_PREFIX);return{src:`^${EVE_ROUTE_PREFIX}/(.*)$`,dest:`${n}/$1`,check:!0}}function resolveProductionTarget(t){if(process.env.VERCEL)return joinRoutePrefix(t,EVE_ROUTE_PREFIX);let n=process.env.EVE_NUXT_PRODUCTION_ORIGIN;return n!==void 0&&n.trim().length>0?joinRoutePrefix(normalizeOrigin(n),EVE_ROUTE_PREFIX):joinRoutePrefix(`http://127.0.0.1:${String(readLocalProductionPort())}`,EVE_ROUTE_PREFIX)}export{EVE_NUXT_SERVICE_PREFIX,createEveVercelRewriteRoute,joinRoutePrefix,normalizeOrigin,normalizeRoutePrefix,readLocalProductionPort,resolveProductionTarget};
1
+ import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";const EVE_NUXT_SERVICE_PREFIX=`/_eve_internal/eve`,EVE_NUXT_PRODUCTION_PORT_ENV=`EVE_NUXT_PRODUCTION_PORT`;function normalizeRoutePrefix(e){let t=(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``);if(t.length===0)throw Error(`eve Nuxt service prefix cannot resolve to the root route.`);return t}function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function normalizeOrigin(e){return new URL(e.trim()).origin}function readLocalProductionPort(){let e=process.env[EVE_NUXT_PRODUCTION_PORT_ENV];if(e===void 0||e.trim().length===0)return 4274;let t=Number.parseInt(e,10);if(String(t)!==e.trim()||t<1||t>65535)throw Error(`${EVE_NUXT_PRODUCTION_PORT_ENV} must be an integer between 1 and 65535.`);return t}function createEveVercelRewriteRoute(t){let n=joinRoutePrefix(t,EVE_ROUTE_PREFIX);return{src:`^${EVE_ROUTE_PREFIX}/(.*)$`,dest:`${n}/$1`,check:!0}}function resolveProductionTarget(t){if(process.env.VERCEL)return joinRoutePrefix(t,EVE_ROUTE_PREFIX);let n=process.env.EVE_NUXT_PRODUCTION_ORIGIN;return n!==void 0&&n.trim().length>0?joinRoutePrefix(normalizeOrigin(n),EVE_ROUTE_PREFIX):joinRoutePrefix(`http://127.0.0.1:${String(readLocalProductionPort())}`,EVE_ROUTE_PREFIX)}export{EVE_NUXT_SERVICE_PREFIX,createEveVercelRewriteRoute,joinRoutePrefix,normalizeOrigin,normalizeRoutePrefix,readLocalProductionPort,resolveProductionTarget};
@@ -2,10 +2,10 @@ export interface EnsureVercelJsonResult {
2
2
  readonly servicePrefix: string;
3
3
  }
4
4
  /**
5
- * Ensure `vercel.json` declares the Nuxt web service and the Eve agent
5
+ * Ensure `vercel.json` declares the Nuxt web service and the eve agent
6
6
  * service so a Vercel deployment ships both from one project.
7
7
  *
8
- * Existing services are preserved untouched; an already-configured Eve
8
+ * Existing services are preserved untouched; an already-configured eve
9
9
  * service's `routePrefix` wins over {@link input.servicePrefix}. The file is
10
10
  * only rewritten when the resulting config differs from what is on disk.
11
11
  */
@@ -7,7 +7,7 @@ import type { JustBashSandboxCreateOptions } from "#public/sandbox/just-bash-san
7
7
  * real binaries (`git`, `node`, package managers) and no network
8
8
  * isolation.
9
9
  *
10
- * The `just-bash` package is not bundled with Eve. When it is missing,
10
+ * The `just-bash` package is not bundled with eve. When it is missing,
11
11
  * `eve dev` installs it into the application automatically (disable
12
12
  * with `autoInstall: false`); production processes fail with an
13
13
  * actionable install error instead. Configuring this backend pins it
@@ -7,7 +7,7 @@ import type { MicrosandboxBootstrapUseOptions, MicrosandboxCreateOptions, Micros
7
7
  * network policies and credential brokering.
8
8
  *
9
9
  * Supported hosts: macOS on Apple Silicon, or Linux (glibc) with KVM
10
- * enabled. The `microsandbox` package is not bundled with Eve. When it
10
+ * enabled. The `microsandbox` package is not bundled with eve. When it
11
11
  * (or its VM runtime) is missing, `eve dev` installs both
12
12
  * automatically (disable with `setup: { autoInstall: false }`);
13
13
  * production processes fail with actionable errors instead.
@@ -17,7 +17,7 @@ import type { VercelSandboxBootstrapUseOptions, VercelSandboxCreateOptions, Verc
17
17
  * the author's snapshot, git revision, or tarball becomes the base
18
18
  * layer of the template. Bootstrap, seed files, and framework setup
19
19
  * still run on top, and every session derives from the resulting
20
- * Eve-owned snapshot. `source` is stripped from session creates so the
20
+ * eve-owned snapshot. `source` is stripped from session creates so the
21
21
  * framework's snapshot always wins.
22
22
  *
23
23
  * `bootstrap({ use })` applies its options to the template via
@@ -22,7 +22,7 @@ export type DockerSandboxNetworkPolicy = "allow-all" | "deny-all";
22
22
  export interface DockerSandboxCreateOptions {
23
23
  /**
24
24
  * Base container image for templates and sessions. Defaults to
25
- * `ghcr.io/vercel/eve:latest` — Eve's published sandbox runtime image.
25
+ * `ghcr.io/vercel/eve:latest` — eve's published sandbox runtime image.
26
26
  * Framework setup creates `/workspace` and verifies Bash. Install any
27
27
  * authored runtime tools in sandbox bootstrap or provide them through a
28
28
  * custom image.
@@ -4,7 +4,7 @@
4
4
  * The just-bash backend runs the workspace under the pure-JS `just-bash`
5
5
  * interpreter with a virtual filesystem — no daemon or VM required, but
6
6
  * no real binaries either. The `just-bash` package is not bundled with
7
- * Eve; it is loaded lazily from the application install.
7
+ * eve; it is loaded lazily from the application install.
8
8
  */
9
9
  export interface JustBashSandboxCreateOptions {
10
10
  /**
@@ -4,13 +4,13 @@ import type { SandboxNetworkPolicy } from "#shared/sandbox-network-policy.js";
4
4
  *
5
5
  * The microsandbox backend runs sandboxes in lightweight local VMs via
6
6
  * [microsandbox](https://www.npmjs.com/package/microsandbox). Options
7
- * are Eve-owned rather than a raw passthrough so the public surface can
7
+ * are eve-owned rather than a raw passthrough so the public surface can
8
8
  * stay stable while the underlying runtime evolves. Supported hosts:
9
9
  * macOS on Apple Silicon, or Linux (glibc) with KVM enabled.
10
10
  */
11
11
  export interface MicrosandboxCreateOptions {
12
12
  /**
13
- * OCI image used as the base runtime. Eve prepares this image with
13
+ * OCI image used as the base runtime. eve prepares this image with
14
14
  * Bash, the framework workspace, and the sandbox user before authored
15
15
  * bootstrap code runs. Install authored runtime tools such as Node,
16
16
  * Python, or ripgrep in sandbox bootstrap or provide them through a
@@ -29,7 +29,7 @@ export interface MicrosandboxCreateOptions {
29
29
  readonly pullPolicy?: "always" | "if-missing" | "never";
30
30
  /**
31
31
  * Installation behavior for the microsandbox npm package and its VM
32
- * runtime. By default Eve installs both automatically when missing —
32
+ * runtime. By default eve installs both automatically when missing —
33
33
  * the npm package with the project's package manager (during
34
34
  * `eve dev` only), the runtime via microsandbox's own installer.
35
35
  */
@@ -6,7 +6,7 @@ import type { Sandbox as SdkSandbox, SandboxUpdateParams } from "#compiled/@verc
6
6
  * Skipped on resume (`Sandbox.get`) since no create happens there.
7
7
  *
8
8
  * `networkPolicy` is deferred until after framework-owned base setup
9
- * for fresh templates and template-less sessions, so Eve can install
9
+ * for fresh templates and template-less sessions, so eve can install
10
10
  * required packages before authored bootstrap code runs. Template-backed
11
11
  * session creates receive it at creation time because the template
12
12
  * already contains the prepared base runtime.
@@ -20,7 +20,7 @@ import type { Sandbox as SdkSandbox, SandboxUpdateParams } from "#compiled/@verc
20
20
  * base layer for the template. Framework setup, bootstrap, and seed
21
21
  * files all run on top, and the resulting
22
22
  * framework-owned snapshot is what every later session derives from,
23
- * so `source` is stripped from the session-create path. Eve does not
23
+ * so `source` is stripped from the session-create path. eve does not
24
24
  * detect external snapshot changes; to pick up a rebuilt external
25
25
  * snapshot, force a template rebuild (e.g. by changing the sandbox
26
26
  * definition so its template key changes).
@@ -17,8 +17,8 @@ export interface EveDevServerRegistry {
17
17
  */
18
18
  export declare function normalizeDevServerRegistry(value: unknown): EveDevServerRegistry | undefined;
19
19
  /**
20
- * Resolve a shared Eve dev server for {@link appRoot}, reusing a healthy
20
+ * Resolve a shared eve dev server for {@link appRoot}, reusing a healthy
21
21
  * registered server when one exists and otherwise spawning a new one behind a
22
- * cross-process lock so concurrent SvelteKit processes don't each boot Eve.
22
+ * cross-process lock so concurrent SvelteKit processes don't each boot eve.
23
23
  */
24
24
  export declare function resolveSharedEveDevServer(appRoot: string): Promise<EveProcessHandle>;
@@ -1 +1 @@
1
- import{joinRoutePrefix,normalizeOrigin}from"./routing.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{resolvePackageRoot}from"#internal/application/package.js";import{join}from"node:path";import{spawn}from"node:child_process";import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";const EVE_BASE_URL_ENV=`EVE_BASE_URL`,DEFAULT_SERVER_READY_TIMEOUT_MS=3e4,DEV_SERVER_REGISTRY_TIMEOUT_MS=3e4,LOCAL_SERVER_URL_PATTERN=/https?:\/\/(?:\[[^\]\s]+\]|[^\s/:[\]]+)(?::\d+)?/;function isNodeErrorWithCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function delay(e){return new Promise(t=>setTimeout(t,e))}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function resolveEveCacheDirectory(e){return join(e,`.eve`)}function resolveEveDevServerRegistryPath(e){return join(resolveEveCacheDirectory(e),`sveltekit-dev-server.json`)}function resolveEveDevServerLockPath(e){return join(resolveEveCacheDirectory(e),`sveltekit-dev-server.lock`)}function normalizeDevServerRegistry(e){if(isRecord(e)&&!(typeof e.appRoot!=`string`||typeof e.origin!=`string`||typeof e.updatedAt!=`string`)&&!(e.pid!==null&&typeof e.pid!=`number`))try{return{appRoot:e.appRoot,origin:normalizeOrigin(e.origin),pid:e.pid,updatedAt:e.updatedAt}}catch{return}}async function isEveServerHealthy(t){let r=new AbortController,i=setTimeout(()=>r.abort(),1e3);try{return(await fetch(joinRoutePrefix(t,`${EVE_ROUTE_PREFIX}/health`),{signal:r.signal})).ok}catch{return!1}finally{clearTimeout(i)}}async function readUsableEveDevServerRegistry(e){try{let t=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e),`utf8`)));return t===void 0||t.appRoot!==e||!await isEveServerHealthy(t.origin)?void 0:t.origin}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e),`${JSON.stringify({appRoot:e,origin:t.origin,pid:t.process?.pid??null,updatedAt:new Date().toISOString()},null,2)}\n`)}async function removeStaleEveDevServerLock(e){try{let t=await stat(e);Date.now()-t.mtimeMs>3e4&&await rm(e,{force:!0})}catch(e){if(!isNodeErrorWithCode(e,`ENOENT`))throw e}}async function acquireEveDevServerLock(e){let t=resolveEveCacheDirectory(e),n=resolveEveDevServerLockPath(e),r=Date.now()+DEV_SERVER_REGISTRY_TIMEOUT_MS;for(await mkdir(t,{recursive:!0});;)try{let e=await open(n,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(n,{force:!0})}}catch(t){if(!isNodeErrorWithCode(t,`EEXIST`))throw t;if(await readUsableEveDevServerRegistry(e)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(n),Date.now()>r)throw Error(`Timed out after ${DEV_SERVER_REGISTRY_TIMEOUT_MS}ms waiting for another SvelteKit process to start Eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}function startServerProcess(e){return new Promise((n,r)=>{let i=spawn(e.command,e.args,{cwd:e.cwd,env:{...process.env,...e.env},stdio:[`ignore`,`pipe`,`pipe`]}),a=setTimeout(()=>{i.kill(),r(Error(`Timed out after ${DEFAULT_SERVER_READY_TIMEOUT_MS}ms waiting for Eve to print its server URL.`))},DEFAULT_SERVER_READY_TIMEOUT_MS),cleanup=()=>{clearTimeout(a),i.off(`error`,handleError),i.off(`exit`,handleEarlyExit)},handleError=e=>{cleanup(),r(e)},handleEarlyExit=(e,t)=>{cleanup(),r(Error(`Eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},o=!1,handleOutput=e=>{if(o)return;let r=LOCAL_SERVER_URL_PATTERN.exec(e.toString(`utf8`));r!==null&&(o=!0,cleanup(),n({origin:normalizeOrigin(r[0]),process:i}))};i.once(`error`,handleError),i.once(`exit`,handleEarlyExit),i.stdout.on(`data`,e=>{process.stdout.write(e),handleOutput(e)}),i.stderr.on(`data`,e=>{process.stderr.write(e),handleOutput(e)})})}function installProcessShutdown(e){let t=e.process;if(t===void 0)return e;let close=()=>{process.off(`beforeExit`,close),process.off(`exit`,close),t.killed||t.kill()};return process.once(`beforeExit`,close),process.once(`exit`,close),e}function startEveDevServer(e){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`],command:process.execPath,cwd:e}).then(e=>(process.env[EVE_BASE_URL_ENV]=e.origin,installProcessShutdown(e)))}async function resolveSharedEveDevServer(e){let t=await readUsableEveDevServerRegistry(e);if(t!==void 0)return process.env[EVE_BASE_URL_ENV]=t,{origin:t};let n=await acquireEveDevServerLock(e);try{let t=await readUsableEveDevServerRegistry(e);if(t!==void 0)return process.env[EVE_BASE_URL_ENV]=t,{origin:t};let n=await startEveDevServer(e);return await writeEveDevServerRegistry(e,n),n}finally{await n()}}export{EVE_BASE_URL_ENV,normalizeDevServerRegistry,resolveSharedEveDevServer};
1
+ import{joinRoutePrefix,normalizeOrigin}from"./routing.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{resolvePackageRoot}from"#internal/application/package.js";import{join}from"node:path";import{spawn}from"node:child_process";import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";const EVE_BASE_URL_ENV=`EVE_BASE_URL`,DEFAULT_SERVER_READY_TIMEOUT_MS=3e4,DEV_SERVER_REGISTRY_TIMEOUT_MS=3e4,LOCAL_SERVER_URL_PATTERN=/https?:\/\/(?:\[[^\]\s]+\]|[^\s/:[\]]+)(?::\d+)?/;function isNodeErrorWithCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function delay(e){return new Promise(t=>setTimeout(t,e))}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function resolveEveCacheDirectory(e){return join(e,`.eve`)}function resolveEveDevServerRegistryPath(e){return join(resolveEveCacheDirectory(e),`sveltekit-dev-server.json`)}function resolveEveDevServerLockPath(e){return join(resolveEveCacheDirectory(e),`sveltekit-dev-server.lock`)}function normalizeDevServerRegistry(e){if(isRecord(e)&&!(typeof e.appRoot!=`string`||typeof e.origin!=`string`||typeof e.updatedAt!=`string`)&&!(e.pid!==null&&typeof e.pid!=`number`))try{return{appRoot:e.appRoot,origin:normalizeOrigin(e.origin),pid:e.pid,updatedAt:e.updatedAt}}catch{return}}async function isEveServerHealthy(t){let r=new AbortController,i=setTimeout(()=>r.abort(),1e3);try{return(await fetch(joinRoutePrefix(t,`${EVE_ROUTE_PREFIX}/health`),{signal:r.signal})).ok}catch{return!1}finally{clearTimeout(i)}}async function readUsableEveDevServerRegistry(e){try{let t=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e),`utf8`)));return t===void 0||t.appRoot!==e||!await isEveServerHealthy(t.origin)?void 0:t.origin}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e),`${JSON.stringify({appRoot:e,origin:t.origin,pid:t.process?.pid??null,updatedAt:new Date().toISOString()},null,2)}\n`)}async function removeStaleEveDevServerLock(e){try{let t=await stat(e);Date.now()-t.mtimeMs>3e4&&await rm(e,{force:!0})}catch(e){if(!isNodeErrorWithCode(e,`ENOENT`))throw e}}async function acquireEveDevServerLock(e){let t=resolveEveCacheDirectory(e),n=resolveEveDevServerLockPath(e),r=Date.now()+DEV_SERVER_REGISTRY_TIMEOUT_MS;for(await mkdir(t,{recursive:!0});;)try{let e=await open(n,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(n,{force:!0})}}catch(t){if(!isNodeErrorWithCode(t,`EEXIST`))throw t;if(await readUsableEveDevServerRegistry(e)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(n),Date.now()>r)throw Error(`Timed out after ${DEV_SERVER_REGISTRY_TIMEOUT_MS}ms waiting for another SvelteKit process to start eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}function startServerProcess(e){return new Promise((n,r)=>{let i=spawn(e.command,e.args,{cwd:e.cwd,env:{...process.env,...e.env},stdio:[`ignore`,`pipe`,`pipe`]}),a=setTimeout(()=>{i.kill(),r(Error(`Timed out after ${DEFAULT_SERVER_READY_TIMEOUT_MS}ms waiting for eve to print its server URL.`))},DEFAULT_SERVER_READY_TIMEOUT_MS),cleanup=()=>{clearTimeout(a),i.off(`error`,handleError),i.off(`exit`,handleEarlyExit)},handleError=e=>{cleanup(),r(e)},handleEarlyExit=(e,t)=>{cleanup(),r(Error(`eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},o=!1,handleOutput=e=>{if(o)return;let r=LOCAL_SERVER_URL_PATTERN.exec(e.toString(`utf8`));r!==null&&(o=!0,cleanup(),n({origin:normalizeOrigin(r[0]),process:i}))};i.once(`error`,handleError),i.once(`exit`,handleEarlyExit),i.stdout.on(`data`,e=>{process.stdout.write(e),handleOutput(e)}),i.stderr.on(`data`,e=>{process.stderr.write(e),handleOutput(e)})})}function installProcessShutdown(e){let t=e.process;if(t===void 0)return e;let close=()=>{process.off(`beforeExit`,close),process.off(`exit`,close),t.killed||t.kill()};return process.once(`beforeExit`,close),process.once(`exit`,close),e}function startEveDevServer(e){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`],command:process.execPath,cwd:e}).then(e=>(process.env[EVE_BASE_URL_ENV]=e.origin,installProcessShutdown(e)))}async function resolveSharedEveDevServer(e){let t=await readUsableEveDevServerRegistry(e);if(t!==void 0)return process.env[EVE_BASE_URL_ENV]=t,{origin:t};let n=await acquireEveDevServerLock(e);try{let t=await readUsableEveDevServerRegistry(e);if(t!==void 0)return process.env[EVE_BASE_URL_ENV]=t,{origin:t};let n=await startEveDevServer(e);return await writeEveDevServerRegistry(e,n),n}finally{await n()}}export{EVE_BASE_URL_ENV,normalizeDevServerRegistry,resolveSharedEveDevServer};