eve 0.82.0 → 0.83.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 (480) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/NOTICE +1 -1
  3. package/dist/src/channel/pending-authorization.d.ts +5 -0
  4. package/dist/src/channel/pending-authorization.js +1 -1
  5. package/dist/src/channel/session.d.ts +2 -0
  6. package/dist/src/channel/session.js +1 -1
  7. package/dist/src/channel/types.d.ts +5 -0
  8. package/dist/src/chunks/{use-eve-agent-DlznYwQk.js → use-eve-agent-3-WRmJkd.js} +40 -5
  9. package/dist/src/chunks/{use-eve-agent-DTu78IAF.js → use-eve-agent-Ci5dr0aR.js} +40 -5
  10. package/dist/src/cli/dev/local-server-child.js +1 -1
  11. package/dist/src/cli/dev/local-server-cleanup.js +1 -1
  12. package/dist/src/cli/dev/tui/question-panel.d.ts +4 -1
  13. package/dist/src/cli/dev/tui/question-panel.js +1 -1
  14. package/dist/src/cli/dev/tui/terminal-renderer.js +4 -4
  15. package/dist/src/client/eve-agent-store.d.ts +1 -1
  16. package/dist/src/client/eve-agent-store.js +1 -1
  17. package/dist/src/client/index.d.ts +1 -0
  18. package/dist/src/client/session-controls.d.ts +6 -0
  19. package/dist/src/client/session-controls.js +1 -1
  20. package/dist/src/client/session.d.ts +4 -0
  21. package/dist/src/client/session.js +1 -1
  22. package/dist/src/compiled/.vendor-stamp.json +8 -8
  23. package/dist/src/compiled/@eve/catalog/index.js +1 -1
  24. package/dist/src/compiled/@workflow/core/events-consumer.d.ts +2 -0
  25. package/dist/src/compiled/@workflow/core/index.js +2 -2
  26. package/dist/src/compiled/@workflow/core/private.d.ts +5 -3
  27. package/dist/src/compiled/@workflow/core/private.js +1 -1
  28. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +1 -37
  29. package/dist/src/compiled/@workflow/core/runtime/event-limit-warning.d.ts +32 -0
  30. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +5 -6
  31. package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
  32. package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +8 -0
  33. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +16 -0
  34. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +15 -18
  35. package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +20 -0
  36. package/dist/src/compiled/@workflow/core/runtime.js +4 -4
  37. package/dist/src/compiled/@workflow/core/seeded-nanoid.d.ts +2 -0
  38. package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +14 -3
  39. package/dist/src/compiled/@workflow/core/serialization.d.ts +1 -1
  40. package/dist/src/compiled/@workflow/core/serialization.js +1 -1
  41. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +0 -18
  42. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  43. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  44. package/dist/src/compiled/@workflow/errors/index.d.ts +48 -0
  45. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  46. package/dist/src/compiled/@workflow/world/env-config.d.ts +24 -0
  47. package/dist/src/compiled/@workflow/world/events.d.ts +126 -7
  48. package/dist/src/compiled/@workflow/world/index.d.ts +3 -3
  49. package/dist/src/compiled/@workflow/world/interfaces.d.ts +59 -8
  50. package/dist/src/compiled/@workflow/world/queue.d.ts +71 -9
  51. package/dist/src/compiled/@workflow/world/recovery.d.ts +6 -0
  52. package/dist/src/compiled/@workflow/world/test-support/duplicate-event-fixtures.d.ts +3 -0
  53. package/dist/src/compiled/@workflow/world/test-support/in-band-fence-conformance.d.ts +46 -0
  54. package/dist/src/compiled/@workflow/world-local/index.js +5 -5
  55. package/dist/src/compiled/@workflow/world-vercel/index.js +18 -18
  56. package/dist/src/compiled/_chunks/workflow/{attribute-changes-BW-kbMMn.js → attribute-changes-7se_SE2q.js} +3 -3
  57. package/dist/src/compiled/_chunks/workflow/dist-CcnNPAp4.js +1 -0
  58. package/dist/src/compiled/_chunks/workflow/dist-S9cZRway.js +3 -0
  59. package/dist/src/compiled/_chunks/workflow/helpers-CxNRXH0a.js +1 -0
  60. package/dist/src/compiled/_chunks/workflow/private-DLYTSBbu.js +1 -0
  61. package/dist/src/compiled/_chunks/workflow/resume-hook-CPiIfe8r.js +1 -0
  62. package/dist/src/compiled/_chunks/workflow/{run-DzdAqdb1.js → run-BJSLCXR4.js} +6 -6
  63. package/dist/src/compiled/_chunks/workflow/serialization-B9gneT9Z.js +15 -0
  64. package/dist/src/compiled/_chunks/workflow/sleep-BL0oQs3R.js +1 -0
  65. package/dist/src/compiled/_chunks/workflow/{wait-until-xbRRDuUf.js → wait-until-BPou0RGO.js} +1 -1
  66. package/dist/src/compiled/_chunks/workflow/workflow-routes-BaljomCk.js +1 -0
  67. package/dist/src/compiled/{@ai-sdk/code-mode → run}/LICENSE +1 -1
  68. package/dist/src/compiled/run/index.d.ts +384 -0
  69. package/dist/src/compiled/run/index.js +650 -0
  70. package/dist/src/compiler/extension-compatibility.d.ts +21 -14
  71. package/dist/src/compiler/extension-compatibility.js +1 -1
  72. package/dist/src/compiler/manifest.js +1 -1
  73. package/dist/src/compiler/normalize-agent-config.js +1 -1
  74. package/dist/src/compiler/normalize-manifest.js +1 -1
  75. package/dist/src/compiler/normalize-sandbox.js +1 -1
  76. package/dist/src/compiler/workspace-resources.js +1 -1
  77. package/dist/src/context/build-callback-context.js +1 -1
  78. package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
  79. package/dist/src/context/providers/sandbox.js +1 -1
  80. package/dist/src/discover/extension-specifier.d.ts +1 -0
  81. package/dist/src/discover/extension-specifier.js +1 -1
  82. package/dist/src/evals/cli/eval.js +2 -2
  83. package/dist/src/evals/runner/artifacts.js +1 -1
  84. package/dist/src/evals/runner/derive-run-facts.d.ts +12 -0
  85. package/dist/src/evals/runner/derive-run-facts.js +1 -1
  86. package/dist/src/evals/runner/execute-task.js +1 -1
  87. package/dist/src/evals/types.d.ts +3 -2
  88. package/dist/src/eve-channel/index.js +1 -1
  89. package/dist/src/eve-channel/request.d.ts +0 -1
  90. package/dist/src/eve-channel/request.js +2 -2
  91. package/dist/src/execution/agent-sessions/context.d.ts +1 -1
  92. package/dist/src/execution/agent-sessions/context.js +1 -1
  93. package/dist/src/execution/coordination-dispatch-shared.d.ts +3 -0
  94. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  95. package/dist/src/execution/dynamic-workflow/program-step.d.ts +7 -7
  96. package/dist/src/execution/dynamic-workflow/program-step.js +1 -1
  97. package/dist/src/execution/dynamic-workflow/schema.d.ts +18 -11
  98. package/dist/src/execution/dynamic-workflow/schema.js +1 -1
  99. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  100. package/dist/src/execution/dynamic-workflow/workflow.js +1 -1
  101. package/dist/src/execution/eve-workflow-attributes.d.ts +3 -1
  102. package/dist/src/execution/eve-workflow-attributes.js +1 -1
  103. package/dist/src/execution/invoke-tool.js +1 -1
  104. package/dist/src/execution/sandbox/abort-bound-session.js +1 -1
  105. package/dist/src/execution/sandbox/active-connections.d.ts +28 -0
  106. package/dist/src/execution/sandbox/active-connections.js +1 -0
  107. package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +10 -2
  108. package/dist/src/execution/sandbox/bindings/docker-cli.js +2 -2
  109. package/dist/src/execution/sandbox/bindings/docker-connection.d.ts +15 -0
  110. package/dist/src/execution/sandbox/bindings/docker-connection.js +2 -0
  111. package/dist/src/execution/sandbox/bindings/docker-container.d.ts +2 -0
  112. package/dist/src/execution/sandbox/bindings/docker-container.js +1 -1
  113. package/dist/src/execution/sandbox/bindings/docker-network.d.ts +5 -0
  114. package/dist/src/execution/sandbox/bindings/docker-network.js +1 -1
  115. package/dist/src/execution/sandbox/bindings/docker-templates.js +1 -1
  116. package/dist/src/execution/sandbox/bindings/docker.d.ts +12 -15
  117. package/dist/src/execution/sandbox/bindings/docker.js +1 -1
  118. package/dist/src/execution/sandbox/bindings/just-bash-runtime.d.ts +19 -29
  119. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  120. package/dist/src/execution/sandbox/bindings/just-bash.d.ts +2 -4
  121. package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
  122. package/dist/src/execution/sandbox/bindings/local-provider-utils.d.ts +0 -20
  123. package/dist/src/execution/sandbox/bindings/local-provider-utils.js +1 -1
  124. package/dist/src/execution/sandbox/bindings/local.d.ts +4 -6
  125. package/dist/src/execution/sandbox/bindings/local.js +1 -1
  126. package/dist/src/execution/sandbox/bindings/vercel-base-runtime.d.ts +2 -0
  127. package/dist/src/execution/sandbox/bindings/vercel-base-runtime.js +2 -2
  128. package/dist/src/execution/sandbox/bindings/vercel-errors.js +2 -2
  129. package/dist/src/execution/sandbox/bindings/vercel-lifecycle.d.ts +7 -5
  130. package/dist/src/execution/sandbox/bindings/vercel-lifecycle.js +1 -1
  131. package/dist/src/execution/sandbox/bindings/vercel.d.ts +5 -11
  132. package/dist/src/execution/sandbox/bindings/vercel.js +1 -2
  133. package/dist/src/execution/sandbox/development-cleanup.d.ts +0 -1
  134. package/dist/src/execution/sandbox/development-cleanup.js +1 -1
  135. package/dist/src/execution/sandbox/development-lazy-prewarm.js +1 -1
  136. package/dist/src/execution/sandbox/development-run.d.ts +0 -2
  137. package/dist/src/execution/sandbox/development-run.js +1 -1
  138. package/dist/src/execution/sandbox/dockerfile.d.ts +0 -4
  139. package/dist/src/execution/sandbox/dockerfile.js +1 -1
  140. package/dist/src/execution/sandbox/ensure.d.ts +23 -11
  141. package/dist/src/execution/sandbox/ensure.js +1 -1
  142. package/dist/src/execution/sandbox/glob-tool.js +3 -3
  143. package/dist/src/execution/sandbox/grep-tool.js +1 -1
  144. package/dist/src/execution/sandbox/logging-session.js +1 -1
  145. package/dist/src/execution/sandbox/prewarm.d.ts +23 -3
  146. package/dist/src/execution/sandbox/prewarm.js +2 -1
  147. package/dist/src/execution/sandbox/read-file.js +1 -1
  148. package/dist/src/execution/sandbox/require-sandbox.d.ts +3 -2
  149. package/dist/src/execution/sandbox/require-sandbox.js +1 -1
  150. package/dist/src/execution/sandbox/ripgrep-probe.js +1 -1
  151. package/dist/src/execution/sandbox/session.d.ts +10 -20
  152. package/dist/src/execution/sandbox/session.js +2 -2
  153. package/dist/src/execution/session/admission.js +1 -1
  154. package/dist/src/execution/session/checkpoint-migrations.js +1 -1
  155. package/dist/src/execution/session/entry-input.d.ts +5 -4
  156. package/dist/src/execution/session/entry.js +1 -1
  157. package/dist/src/execution/session/handoff-state.d.ts +5 -0
  158. package/dist/src/execution/session/handoff-state.js +1 -0
  159. package/dist/src/execution/session/handoff-steps.d.ts +0 -5
  160. package/dist/src/execution/session/handoff-steps.js +1 -1
  161. package/dist/src/execution/session/handoff.d.ts +2 -1
  162. package/dist/src/execution/session/handoff.js +1 -1
  163. package/dist/src/execution/session/input-queue.d.ts +3 -0
  164. package/dist/src/execution/session/input-queue.js +1 -1
  165. package/dist/src/execution/session/next-input.d.ts +3 -0
  166. package/dist/src/execution/session/next-input.js +1 -1
  167. package/dist/src/execution/session/program.js +1 -1
  168. package/dist/src/execution/session/timeout-control.d.ts +4 -0
  169. package/dist/src/execution/session/timeout-control.js +1 -1
  170. package/dist/src/execution/session/turn-control.d.ts +5 -2
  171. package/dist/src/execution/session/turn-control.js +1 -1
  172. package/dist/src/execution/session/turn.js +1 -1
  173. package/dist/src/execution/session-inbox/inbox.d.ts +9 -1
  174. package/dist/src/execution/session-inbox/inbox.js +1 -1
  175. package/dist/src/execution/session-inbox/protocol.d.ts +2 -1
  176. package/dist/src/execution/session-inbox/protocol.js +1 -1
  177. package/dist/src/execution/session-inbox/resume.d.ts +2 -1
  178. package/dist/src/execution/session-inbox/resume.js +1 -1
  179. package/dist/src/execution/session-prewarm.d.ts +8 -0
  180. package/dist/src/execution/session-prewarm.js +1 -0
  181. package/dist/src/execution/skills/instructions.js +1 -1
  182. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  183. package/dist/src/execution/tools/workflow/body.js +1 -1
  184. package/dist/src/execution/tools/workflow/step-context.d.ts +11 -0
  185. package/dist/src/execution/tools/workflow/step-execution.js +1 -1
  186. package/dist/src/execution/tools/workflow/step.js +1 -1
  187. package/dist/src/execution/workflow-runtime.js +1 -1
  188. package/dist/src/extensions/git/extension/lib/github-shell-schema.js +1 -1
  189. package/dist/src/framework/sources/modules/sandbox.d.ts +1 -1
  190. package/dist/src/harness/attachment-staging.d.ts +0 -7
  191. package/dist/src/harness/attachment-staging.js +1 -1
  192. package/dist/src/harness/hitl/index.d.ts +2 -1
  193. package/dist/src/harness/hitl/index.js +1 -1
  194. package/dist/src/harness/hitl/view.d.ts +1 -0
  195. package/dist/src/harness/hitl/view.js +1 -0
  196. package/dist/src/harness/model-call/run.js +1 -1
  197. package/dist/src/harness/semantic-errors/rules/sandbox.d.ts +3 -5
  198. package/dist/src/harness/semantic-errors/rules/sandbox.js +1 -1
  199. package/dist/src/harness/step/prompt.js +1 -1
  200. package/dist/src/harness/tool-history-repair.d.ts +9 -0
  201. package/dist/src/harness/tool-history-repair.js +1 -0
  202. package/dist/src/harness/tool-model-output.d.ts +19 -3
  203. package/dist/src/harness/tool-model-output.js +1 -1
  204. package/dist/src/internal/application/compiled-artifacts.js +8 -4
  205. package/dist/src/internal/application/optional-package-import.d.ts +10 -0
  206. package/dist/src/internal/application/optional-package-import.js +1 -1
  207. package/dist/src/internal/application/stamped-package-version.js +1 -1
  208. package/dist/src/internal/attachments/limited-read.d.ts +2 -2
  209. package/dist/src/internal/authored-module-build-options.d.ts +6 -0
  210. package/dist/src/internal/authored-module-build-options.js +1 -1
  211. package/dist/src/internal/authored-module-cache.d.ts +10 -0
  212. package/dist/src/internal/authored-module-cache.js +1 -0
  213. package/dist/src/internal/authored-module-graph.js +1 -1
  214. package/dist/src/internal/authored-module-loader.js +1 -1
  215. package/dist/src/internal/authored-relative-extension-resolver.js +1 -1
  216. package/dist/src/internal/bundler/nitro-rolldown.d.ts +3 -1
  217. package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
  218. package/dist/src/internal/bundler/pseudo-packages.d.ts +11 -0
  219. package/dist/src/internal/bundler/pseudo-packages.js +1 -0
  220. package/dist/src/internal/nitro/host/build-extension.d.ts +6 -0
  221. package/dist/src/internal/nitro/host/build-extension.js +2 -2
  222. package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.d.ts +3 -1
  223. package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.js +3 -5
  224. package/dist/src/internal/nitro/host/create-application-nitro.d.ts +2 -3
  225. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  226. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.d.ts +2 -0
  227. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
  228. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  229. package/dist/src/internal/nitro/host/dev-build-host.d.ts +83 -0
  230. package/dist/src/internal/nitro/host/dev-build-host.js +1 -0
  231. package/dist/src/internal/nitro/host/dev-build-operations.d.ts +6 -0
  232. package/dist/src/internal/nitro/host/dev-build-operations.js +1 -0
  233. package/dist/src/internal/nitro/host/dev-build-process.d.ts +1 -0
  234. package/dist/src/internal/nitro/host/dev-build-process.js +1 -0
  235. package/dist/src/internal/nitro/host/development-runtime-prune-plugin.d.ts +4 -1
  236. package/dist/src/internal/nitro/host/development-runtime-prune-plugin.js +3 -2
  237. package/dist/src/internal/nitro/host/drained-nitro-dev-server.d.ts +13 -0
  238. package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -1
  239. package/dist/src/internal/nitro/host/optional-engine-dependency-plugin.js +1 -1
  240. package/dist/src/internal/nitro/host/prepare-application-host.d.ts +3 -0
  241. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  242. package/dist/src/internal/nitro/host/sandbox-shutdown-plugin.js +1 -1
  243. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  244. package/dist/src/internal/nitro/host/start-production-server.js +3 -3
  245. package/dist/src/internal/nitro/host/workflow-sandbox-runtime-plugin.js +1 -1
  246. package/dist/src/internal/nitro/host.js +1 -1
  247. package/dist/src/internal/workflow/local-world-delivery-auth.d.ts +17 -0
  248. package/dist/src/internal/workflow/local-world-delivery-auth.js +1 -0
  249. package/dist/src/internal/workflow/queue-namespace.d.ts +2 -0
  250. package/dist/src/internal/workflow/queue-namespace.js +1 -1
  251. package/dist/src/internal/workflow-bundle/builder-support.d.ts +0 -1
  252. package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
  253. package/dist/src/internal/workflow-bundle/builder.js +2 -2
  254. package/dist/src/internal/workflow-bundle/vercel-workflow-output.d.ts +1 -1
  255. package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
  256. package/dist/src/protocol/prewarm-session.d.ts +14 -0
  257. package/dist/src/protocol/prewarm-session.js +1 -0
  258. package/dist/src/protocol/routes.d.ts +2 -2
  259. package/dist/src/public/channels/discord/authorization.d.ts +45 -0
  260. package/dist/src/public/channels/discord/authorization.js +3 -0
  261. package/dist/src/public/channels/discord/defaults.d.ts +14 -3
  262. package/dist/src/public/channels/discord/defaults.js +2 -2
  263. package/dist/src/public/channels/discord/discordChannel.d.ts +15 -1
  264. package/dist/src/public/channels/discord/discordChannel.js +1 -1
  265. package/dist/src/public/channels/discord/gateway/connection.d.ts +26 -0
  266. package/dist/src/public/channels/discord/gateway/connection.js +1 -0
  267. package/dist/src/public/channels/discord/gateway/forwarder.d.ts +14 -0
  268. package/dist/src/public/channels/discord/gateway/forwarder.js +1 -0
  269. package/dist/src/public/channels/discord/gateway/index.d.ts +59 -0
  270. package/dist/src/public/channels/discord/gateway/index.js +1 -0
  271. package/dist/src/public/channels/discord/inbound.d.ts +10 -3
  272. package/dist/src/public/channels/discord/inbound.js +2 -2
  273. package/dist/src/public/channels/discord/index.d.ts +3 -2
  274. package/dist/src/public/channels/discord/index.js +1 -1
  275. package/dist/src/public/channels/discord/messages.d.ts +116 -0
  276. package/dist/src/public/channels/discord/messages.js +2 -0
  277. package/dist/src/public/channels/github/checkout.js +1 -1
  278. package/dist/src/public/channels/linq/linqChannel.d.ts +4 -1
  279. package/dist/src/public/channels/linq/linqChannel.js +1 -1
  280. package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
  281. package/dist/src/public/channels/same-environment-oidc.d.ts +7 -0
  282. package/dist/src/public/channels/same-environment-oidc.js +1 -0
  283. package/dist/src/public/definitions/channel.js +1 -1
  284. package/dist/src/public/definitions/sandbox.d.ts +1 -1
  285. package/dist/src/public/next/server.js +1 -1
  286. package/dist/src/public/sandbox/docker-sandbox.d.ts +6 -1
  287. package/dist/src/public/sandbox/docker.d.ts +1 -8
  288. package/dist/src/public/sandbox/index.d.ts +3 -3
  289. package/dist/src/public/sandbox/just-bash-sandbox.d.ts +87 -7
  290. package/dist/src/public/sandbox/just-bash.d.ts +1 -1
  291. package/dist/src/public/sandbox/provider.d.ts +5 -1
  292. package/dist/src/public/sandbox/provider.js +1 -1
  293. package/dist/src/public/sandbox/vercel-sandbox.d.ts +16 -9
  294. package/dist/src/public/sandbox/vercel.d.ts +0 -1
  295. package/dist/src/public/sandbox/vercel.js +1 -1
  296. package/dist/src/public/tools/agent.d.ts +8 -1
  297. package/dist/src/public/tools/agent.js +1 -1
  298. package/dist/src/react/use-eve-agent.d.ts +1 -1
  299. package/dist/src/runtime/agent/resolve-model.js +1 -1
  300. package/dist/src/runtime/connections/openapi-client.d.ts +2 -0
  301. package/dist/src/runtime/connections/openapi-client.js +1 -1
  302. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  303. package/dist/src/runtime/resolve-agent.js +1 -1
  304. package/dist/src/runtime/resolve-channel.js +1 -1
  305. package/dist/src/runtime/resolve-sandbox.js +1 -1
  306. package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -1
  307. package/dist/src/runtime/sandbox/registry.d.ts +2 -0
  308. package/dist/src/runtime/sandbox/registry.js +1 -1
  309. package/dist/src/runtime/subagents/workflow.d.ts +6 -0
  310. package/dist/src/runtime/subagents/workflow.js +1 -1
  311. package/dist/src/runtime/workspace/seed-files.d.ts +9 -12
  312. package/dist/src/runtime/workspace/seed-files.js +1 -1
  313. package/dist/src/runtime/workspace/spec.d.ts +1 -1
  314. package/dist/src/runtime/workspace/spec.js +1 -1
  315. package/dist/src/runtime/workspace/types.d.ts +2 -6
  316. package/dist/src/sandbox/provider.d.ts +185 -0
  317. package/dist/src/sandbox/provider.js +1 -0
  318. package/dist/src/sandbox/providers/default.d.ts +20 -19
  319. package/dist/src/sandbox/providers/default.js +1 -1
  320. package/dist/src/sandbox/providers/docker.d.ts +5 -2
  321. package/dist/src/sandbox/providers/docker.js +1 -1
  322. package/dist/src/sandbox/providers/just-bash.d.ts +4 -3
  323. package/dist/src/sandbox/providers/just-bash.js +1 -1
  324. package/dist/src/sandbox/providers/vercel.d.ts +4 -10
  325. package/dist/src/sandbox/providers/vercel.js +1 -1
  326. package/dist/src/sandbox/providers.d.ts +0 -1
  327. package/dist/src/sandbox/providers.js +1 -1
  328. package/dist/src/sandbox/state.d.ts +44 -0
  329. package/dist/src/sandbox/state.js +1 -1
  330. package/dist/src/self-modification/deployed-sandbox.d.ts +4 -9
  331. package/dist/src/self-modification/deployed-sandbox.js +1 -1
  332. package/dist/src/self-modification/filesystem.d.ts +3 -3
  333. package/dist/src/self-modification/remote/config.d.ts +2 -2
  334. package/dist/src/self-modification/remote/config.js +1 -1
  335. package/dist/src/self-modification/setup.d.ts +0 -1
  336. package/dist/src/self-modification/setup.js +8 -8
  337. package/dist/src/setup/integrations/discord/api.d.ts +7 -0
  338. package/dist/src/setup/integrations/discord/api.js +1 -1
  339. package/dist/src/setup/integrations/discord/daemon.d.ts +18 -0
  340. package/dist/src/setup/integrations/discord/daemon.js +21 -0
  341. package/dist/src/setup/integrations/discord/setup.d.ts +24 -4
  342. package/dist/src/setup/integrations/discord/setup.js +5 -4
  343. package/dist/src/setup/integrations/self-modification/setup.js +1 -1
  344. package/dist/src/setup/scaffold/create/project.js +1 -1
  345. package/dist/src/setup/scaffold/update/web-options.js +1 -1
  346. package/dist/src/setup/scaffold/version-tokens.d.ts +0 -1
  347. package/dist/src/setup/scaffold/version-tokens.js +1 -1
  348. package/dist/src/shared/agent-definition.d.ts +2 -0
  349. package/dist/src/shared/built-server-start-failure.d.ts +12 -0
  350. package/dist/src/shared/built-server-start-failure.js +3 -0
  351. package/dist/src/shared/framework-eve-server.d.ts +2 -0
  352. package/dist/src/shared/framework-eve-server.js +2 -2
  353. package/dist/src/shared/sandbox-environment.d.ts +4 -10
  354. package/dist/src/shared/sandbox-environment.js +1 -1
  355. package/dist/src/shared/sandbox-network-policy.d.ts +45 -9
  356. package/dist/src/shared/sandbox-provider.d.ts +0 -103
  357. package/dist/src/shared/sandbox-provider.js +1 -1
  358. package/dist/src/shared/sandbox-recorded-data-error.d.ts +4 -0
  359. package/dist/src/shared/sandbox-recorded-data-error.js +1 -0
  360. package/dist/src/shared/sandbox-session-gone-error.d.ts +12 -0
  361. package/dist/src/shared/sandbox-session-gone-error.js +1 -0
  362. package/dist/src/shared/sandbox-session.d.ts +97 -83
  363. package/dist/src/shared/sandbox-template-error.d.ts +19 -4
  364. package/dist/src/shared/sandbox-template-error.js +1 -1
  365. package/dist/src/shared/sandbox-tool-session-error.d.ts +4 -0
  366. package/dist/src/shared/sandbox-tool-session-error.js +1 -0
  367. package/dist/src/shared/skill-package.js +1 -1
  368. package/dist/src/shared/skill-paths.d.ts +4 -5
  369. package/dist/src/shared/skill-paths.js +2 -2
  370. package/dist/src/shared/workflow-sandbox.d.ts +4 -41
  371. package/dist/src/shared/workflow-sandbox.js +1 -1
  372. package/dist/src/svelte/index.js +1 -1
  373. package/dist/src/svelte/use-eve-agent.d.ts +1 -1
  374. package/dist/src/svelte/use-eve-agent.js +1 -1
  375. package/dist/src/tools/model-output.d.ts +23 -5
  376. package/dist/src/tools/model-output.js +1 -1
  377. package/dist/src/tools/provided/ask-question-workflow.js +1 -1
  378. package/dist/src/tools/provided/glob.js +1 -1
  379. package/dist/src/tools/provided/grep.js +1 -1
  380. package/dist/src/tools/provided/read-file.js +1 -1
  381. package/dist/src/tools/provided/sleep-workflow.js +1 -1
  382. package/dist/src/tools/provided/workflow.js +1 -1
  383. package/dist/src/tools/provided/write-file.js +1 -1
  384. package/dist/src/tools/workflow-definition.d.ts +19 -4
  385. package/dist/src/vue/index.js +1 -1
  386. package/dist/src/vue/use-eve-agent.d.ts +1 -1
  387. package/dist/src/vue/use-eve-agent.js +1 -1
  388. package/docs/channels/custom.mdx +3 -3
  389. package/docs/channels/discord.mdx +279 -7
  390. package/docs/channels/eve.mdx +13 -2
  391. package/docs/channels/linq.mdx +2 -2
  392. package/docs/channels/mcp.mdx +2 -2
  393. package/docs/channels/overview.mdx +1 -1
  394. package/docs/channels/photon.mdx +1 -1
  395. package/docs/concepts/built-in-tools.md +31 -8
  396. package/docs/concepts/execution-model-and-durability.mdx +6 -101
  397. package/docs/concepts/security-model.md +2 -0
  398. package/docs/concepts/sessions-runs-and-streaming.md +44 -36
  399. package/docs/connections/openapi.mdx +2 -0
  400. package/docs/evals/reporters.mdx +1 -1
  401. package/docs/evals/running.mdx +1 -1
  402. package/docs/guides/client/messages.mdx +1 -1
  403. package/docs/guides/deployment/overview.md +4 -4
  404. package/docs/guides/deployment/self-hosting.md +50 -1
  405. package/docs/guides/dev-tui.md +1 -1
  406. package/docs/guides/dynamic-capabilities.md +1 -1
  407. package/docs/guides/frontend/overview.mdx +26 -6
  408. package/docs/guides/instrumentation/agent-runs.mdx +16 -0
  409. package/docs/guides/self-modification.md +1 -1
  410. package/docs/guides/session-context.md +1 -1
  411. package/docs/instructions.mdx +1 -1
  412. package/docs/reference/agent-files.md +3 -3
  413. package/docs/reference/cli.md +7 -2
  414. package/docs/reference/typescript-api.md +9 -3
  415. package/docs/sandbox/custom-providers.mdx +254 -0
  416. package/docs/sandbox/default.mdx +71 -4
  417. package/docs/sandbox/docker.mdx +15 -3
  418. package/docs/sandbox/index.mdx +27 -103
  419. package/docs/sandbox/just-bash.mdx +54 -0
  420. package/docs/sandbox/meta.json +9 -1
  421. package/docs/sandbox/troubleshooting.mdx +215 -0
  422. package/docs/sandbox/vercel.mdx +48 -7
  423. package/docs/skills.mdx +1 -1
  424. package/docs/subagents/index.mdx +2 -2
  425. package/docs/tools/overview.mdx +19 -0
  426. package/docs/tools/workflows.mdx +73 -5
  427. package/docs/tutorial/run-analysis.mdx +2 -2
  428. package/package.json +14 -20
  429. package/dist/src/compiled/@ai-sdk/code-mode/_run.d.ts +0 -1
  430. package/dist/src/compiled/@ai-sdk/code-mode/index.d.ts +0 -325
  431. package/dist/src/compiled/@ai-sdk/code-mode/index.js +0 -660
  432. package/dist/src/compiled/_chunks/workflow/dist-CyBgVS7g.js +0 -1
  433. package/dist/src/compiled/_chunks/workflow/dist-T5NnW-0k.js +0 -3
  434. package/dist/src/compiled/_chunks/workflow/helpers-DlLD3ov_.js +0 -1
  435. package/dist/src/compiled/_chunks/workflow/private-tQUuwBoQ.js +0 -1
  436. package/dist/src/compiled/_chunks/workflow/resume-hook-DMsV_b4n.js +0 -1
  437. package/dist/src/compiled/_chunks/workflow/serialization-DPdYS_w2.js +0 -16
  438. package/dist/src/compiled/_chunks/workflow/sleep-BY6leHh8.js +0 -1
  439. package/dist/src/compiled/_chunks/workflow/workflow-routes-CwqB063q.js +0 -1
  440. package/dist/src/execution/sandbox/active-handles.d.ts +0 -32
  441. package/dist/src/execution/sandbox/active-handles.js +0 -1
  442. package/dist/src/execution/sandbox/bindings/docker-session.d.ts +0 -6
  443. package/dist/src/execution/sandbox/bindings/docker-session.js +0 -2
  444. package/dist/src/execution/sandbox/bindings/immutable-resources.d.ts +0 -15
  445. package/dist/src/execution/sandbox/bindings/immutable-resources.js +0 -2
  446. package/dist/src/execution/sandbox/bindings/microsandbox-create.d.ts +0 -12
  447. package/dist/src/execution/sandbox/bindings/microsandbox-create.js +0 -1
  448. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.d.ts +0 -42
  449. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +0 -1
  450. package/dist/src/execution/sandbox/bindings/microsandbox-metadata.d.ts +0 -29
  451. package/dist/src/execution/sandbox/bindings/microsandbox-metadata.js +0 -1
  452. package/dist/src/execution/sandbox/bindings/microsandbox-network.d.ts +0 -18
  453. package/dist/src/execution/sandbox/bindings/microsandbox-network.js +0 -1
  454. package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +0 -37
  455. package/dist/src/execution/sandbox/bindings/microsandbox-options.js +0 -1
  456. package/dist/src/execution/sandbox/bindings/microsandbox-platform.d.ts +0 -21
  457. package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +0 -21
  458. package/dist/src/execution/sandbox/bindings/microsandbox-process.d.ts +0 -3
  459. package/dist/src/execution/sandbox/bindings/microsandbox-process.js +0 -1
  460. package/dist/src/execution/sandbox/bindings/microsandbox-provider-state.d.ts +0 -11
  461. package/dist/src/execution/sandbox/bindings/microsandbox-provider-state.js +0 -1
  462. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.d.ts +0 -82
  463. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +0 -1
  464. package/dist/src/execution/sandbox/bindings/microsandbox-templates.d.ts +0 -12
  465. package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +0 -1
  466. package/dist/src/execution/sandbox/bindings/microsandbox.d.ts +0 -16
  467. package/dist/src/execution/sandbox/bindings/microsandbox.js +0 -1
  468. package/dist/src/execution/sandbox/provider-host-development.d.ts +0 -2
  469. package/dist/src/execution/sandbox/provider-host-development.js +0 -1
  470. package/dist/src/execution/sandbox/provider-host.d.ts +0 -2
  471. package/dist/src/execution/sandbox/provider-host.js +0 -1
  472. package/dist/src/execution/tool-session/sandbox.d.ts +0 -22
  473. package/dist/src/execution/tool-session/sandbox.js +0 -1
  474. package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +0 -48
  475. package/dist/src/public/sandbox/microsandbox-sandbox.js +0 -1
  476. package/dist/src/public/sandbox/microsandbox.d.ts +0 -9
  477. package/dist/src/public/sandbox/microsandbox.js +0 -1
  478. package/dist/src/sandbox/providers/microsandbox.d.ts +0 -12
  479. package/dist/src/sandbox/providers/microsandbox.js +0 -1
  480. package/docs/sandbox/microsandbox.mdx +0 -31
@@ -1,8 +1,18 @@
1
1
  import type { SandboxSession } from "#public/definitions/sandbox.js";
2
+ import type { SandboxProviderRuntime, SandboxSessionContext } from "#sandbox/provider.js";
2
3
  import type { SandboxEnvironmentIdentity } from "#shared/sandbox-environment.js";
3
4
  import type { SandboxDeleteOptions, SandboxPreparedArtifact } from "#shared/sandbox-provider.js";
4
5
  export type SandboxSessionEndReason = "completed" | "expired" | "failed";
5
6
  export interface SandboxSessionState {
7
+ /**
8
+ * Set anew each time this session's access calls `start()`, which is an upsert,
9
+ * and kept on resume. Providers name a session's sandbox deterministically, so
10
+ * without it a sandbox recreated after it was gone would look like the old one
11
+ * to dynamic skills, which then write their files into it at the next turn. A
12
+ * sandbox that a sharing subagent or a borrowed workflow step starts keeps this
13
+ * session's generation. Absent in state saved by earlier releases.
14
+ */
15
+ readonly generation?: string;
6
16
  readonly providerName: string;
7
17
  readonly state: SandboxPreparedArtifact;
8
18
  readonly stateProtocolVersion: number;
@@ -10,6 +20,39 @@ export interface SandboxSessionState {
10
20
  export interface SandboxState {
11
21
  readonly session: SandboxSessionState | null;
12
22
  }
23
+ /**
24
+ * Whether no provider can resume this persisted record, so callers treat it as
25
+ * no sandbox: records saved before the provider redesign (eve 0.64) have no
26
+ * `providerName`, and `microsandbox` was removed as a provider.
27
+ */
28
+ export declare function isRetiredSandboxSessionState(state: SandboxSessionState): boolean;
29
+ /** Converts a record another provider wrote into this provider's state, or `undefined`. */
30
+ type SandboxSessionStateAdopter = (state: SandboxSessionState) => SandboxPreparedArtifact | undefined;
31
+ /**
32
+ * Lets an eve-owned provider resume records that another provider name wrote,
33
+ * such as `DefaultSandbox` for sessions saved when it recorded the provider it
34
+ * picked. Internal, so the public provider API is unchanged.
35
+ */
36
+ export declare function withAdoptedSandboxSessionStates<Implementation extends object>(implementation: Implementation, adopt: SandboxSessionStateAdopter): Implementation;
37
+ /**
38
+ * The persisted record the current provider should resume, or `null` for no
39
+ * sandbox. A record the provider cannot adopt is returned as-is; resuming it
40
+ * starts a fresh sandbox, and handoff rejects it. An adopted record keeps its
41
+ * `generation`, because it still names the same live sandbox.
42
+ */
43
+ export declare function resolvePersistedSandboxSessionState(state: SandboxSessionState | null | undefined, provider: SandboxProviderRuntime | undefined): SandboxSessionState | null;
44
+ /** Session-end cleanup that also needs the current build's prepared artifact. */
45
+ type SandboxSessionEndWithArtifact = (context: SandboxSessionContext, state: SandboxPreparedArtifact | null, options: {
46
+ readonly artifact: SandboxPreparedArtifact | undefined;
47
+ readonly reason: SandboxSessionEndReason;
48
+ }) => Promise<void>;
49
+ /**
50
+ * Lets an eve-owned provider receive the prepared artifact at session end,
51
+ * such as `DefaultSandbox`, which finds the provider it selected there when
52
+ * no state was recorded. Internal, so the public provider API is unchanged.
53
+ */
54
+ export declare function withSessionEndArtifact<Implementation extends object>(implementation: Implementation, onSessionEnd: SandboxSessionEndWithArtifact): Implementation;
55
+ export declare function getSessionEndWithArtifact(implementation: object): SandboxSessionEndWithArtifact | undefined;
13
56
  export interface SandboxAccess {
14
57
  readonly environment?: SandboxEnvironmentIdentity;
15
58
  captureState(): Promise<SandboxState>;
@@ -17,3 +60,4 @@ export interface SandboxAccess {
17
60
  get(): Promise<SandboxSession | null>;
18
61
  stop(): Promise<void>;
19
62
  }
63
+ export {};
@@ -1 +1 @@
1
- export{};
1
+ function isRetiredSandboxSessionState(e){return e.providerName===void 0||e.providerName===`microsandbox`}const adopters=new WeakMap;function withAdoptedSandboxSessionStates(e,t){return adopters.set(e,t),e}function resolvePersistedSandboxSessionState(e,t){if(e==null||isRetiredSandboxSessionState(e))return null;if(t===void 0||e.providerName===t.providerName)return e;let n=adopters.get(t.implementation)?.(e);return n===void 0?e:{...e,providerName:t.providerName,state:n,stateProtocolVersion:t.stateProtocolVersion}}const sessionEndsWithArtifact=new WeakMap;function withSessionEndArtifact(e,t){return sessionEndsWithArtifact.set(e,t),e}function getSessionEndWithArtifact(e){return sessionEndsWithArtifact.get(e)}export{getSessionEndWithArtifact,isRetiredSandboxSessionState,resolvePersistedSandboxSessionState,withAdoptedSandboxSessionStates,withSessionEndArtifact};
@@ -1,14 +1,9 @@
1
- import { MicrosandboxSandbox } from "#sandbox/providers/microsandbox.js";
2
- import { type DefaultSandboxProbes } from "#sandbox/providers/default.js";
3
- import { VercelSandbox } from "#sandbox/providers/vercel.js";
4
1
  import { type SandboxSelector } from "#shared/sandbox-environment.js";
5
2
  import { type DeployedSelfModificationConfig } from "./remote/config.js";
6
- type Probes = Pick<DefaultSandboxProbes, "isDeployedOnVercel" | "isMicrosandboxSupported">;
7
- type DeployedSelfModificationEnvironment = ReturnType<typeof MicrosandboxSandbox.environment> | ReturnType<typeof VercelSandbox.environment>;
8
3
  /**
9
4
  * Defines the deployed child's sandbox. During `eve dev` the deployed child is never
10
- * offered, so its sandbox binds an inert environment instead of probing providers.
5
+ * offered, so its sandbox binds an inert environment. Other builds bind a Vercel
6
+ * environment, whose empty preparation is a no-op, so they compile on any host;
7
+ * the Vercel requirement is enforced when a deployed child opens its sandbox.
11
8
  */
12
- export declare function defineDeployedSelfModificationSandbox(config: DeployedSelfModificationConfig, probes?: Probes): SandboxSelector;
13
- export declare function selectDeployedSelfModificationEnvironment(probes: Probes): DeployedSelfModificationEnvironment;
14
- export {};
9
+ export declare function defineDeployedSelfModificationSandbox(config: DeployedSelfModificationConfig, isDeployedOnVercel?: () => boolean): SandboxSelector;
@@ -1 +1 @@
1
- import{createGitHubCredentialProvider}from"./credentials.js";import{SELF_MODIFICATION_BASELINE_NETWORK_POLICY}from"./network-policy.js";import{REPOSITORY_PATH,prepareSelfModificationWorkspace}from"./git-workspace.js";import{isDeployedRuntime}from"./mode.js";import{resolveDeployedSelfModificationConfig}from"./remote/config.js";import{bindSandboxEnvironment}from"#shared/sandbox-environment.js";import{shellQuote}from"#shared/shell-quote.js";import{defineSandbox}from"#public/definitions/sandbox.js";import{SANDBOX_PROVIDER_PROBES}from"#sandbox/providers/default.js";import{JustBashSandbox}from"#sandbox/providers/just-bash.js";import{MicrosandboxSandbox}from"#sandbox/providers/microsandbox.js";import{VercelSandbox}from"#sandbox/providers/vercel.js";function defineDeployedSelfModificationSandbox(e,t=SANDBOX_PROVIDER_PROBES){if(!isDeployedRuntime()){let e=JustBashSandbox.environment();return bindSandboxEnvironment(defineSandbox(()=>e.open()),e)}let n=resolveDeployedSelfModificationConfig(e),r=selectDeployedSelfModificationEnvironment(t);return bindSandboxEnvironment(defineSandbox(async({session:e})=>{let t=await r.open({networkPolicy:SELF_MODIFICATION_BASELINE_NETWORK_POLICY});if(e.parent===void 0)throw Error(`Production self-modification requires a child session.`);if(t.setNetworkPolicy===void 0)throw Error(`Production self-modification requires mutable sandbox network policy.`);let i={...t,setNetworkPolicy:t.setNetworkPolicy},a=await createGitHubCredentialProvider(n.credentials).resolve({capability:`checkout`,repository:n.repository});await prepareSelfModificationWorkspace({directory:n.directory,repository:n.repository,sandbox:i,targetBranch:n.targetBranch,token:a});let o=n.directory===`.`?REPOSITORY_PATH:`${REPOSITORY_PATH}/${n.directory}`;if((await t.run({command:`rm -rf /source && ln -s ${shellQuote(`${o}/agent`)} /source`})).exitCode!==0)throw Error(`Self-modification could not mount the agent source.`);return t}),r)}function selectDeployedSelfModificationEnvironment(e){if(e.isDeployedOnVercel())return VercelSandbox.environment();if(e.isMicrosandboxSupported())return MicrosandboxSandbox.environment();throw Error(`Deployed self-modification requires runtime credential transforms. No supported provider is available. Use Vercel Sandbox or microsandbox on a supported self-hosted system.`)}export{defineDeployedSelfModificationSandbox,selectDeployedSelfModificationEnvironment};
1
+ import{createGitHubCredentialProvider}from"./credentials.js";import{SELF_MODIFICATION_BASELINE_NETWORK_POLICY}from"./network-policy.js";import{REPOSITORY_PATH,prepareSelfModificationWorkspace}from"./git-workspace.js";import{isDeployedRuntime}from"./mode.js";import{resolveDeployedSelfModificationConfig}from"./remote/config.js";import{bindSandboxEnvironment}from"#shared/sandbox-environment.js";import{shellQuote}from"#shared/shell-quote.js";import{defineSandbox}from"#public/definitions/sandbox.js";import{JustBashSandbox}from"#sandbox/providers/just-bash.js";import{VercelSandbox}from"#sandbox/providers/vercel.js";function defineDeployedSelfModificationSandbox(e,t=()=>!!process.env.VERCEL){if(!isDeployedRuntime()){let e=JustBashSandbox.environment();return bindSandboxEnvironment(defineSandbox(()=>e.open()),e)}let n=resolveDeployedSelfModificationConfig(e),r=VercelSandbox.environment();return bindSandboxEnvironment(defineSandbox(async({session:e})=>{if(!t())throw Error(`Deployed self-modification requires deploying on Vercel, where Vercel Sandbox provides the runtime credential transforms that keep the GitHub token out of the sandbox. Deploy this agent to Vercel, or remove the eve/self-modification/remote extension mount from self-hosted deployments.`);let i=await r.open({networkPolicy:SELF_MODIFICATION_BASELINE_NETWORK_POLICY});if(e.parent===void 0)throw Error(`Production self-modification requires a child session.`);if(i.setNetworkPolicy===void 0)throw Error(`Production self-modification requires mutable sandbox network policy.`);let a={...i,setNetworkPolicy:i.setNetworkPolicy},o=await createGitHubCredentialProvider(n.credentials).resolve({capability:`checkout`,repository:n.repository});await prepareSelfModificationWorkspace({directory:n.directory,repository:n.repository,sandbox:a,targetBranch:n.targetBranch,token:o});let s=n.directory===`.`?REPOSITORY_PATH:`${REPOSITORY_PATH}/${n.directory}`;if((await i.run({command:`rm -rf /source && ln -s ${shellQuote(`${s}/agent`)} /source`})).exitCode!==0)throw Error(`Self-modification could not mount the agent source.`);return i}),r)}export{defineDeployedSelfModificationSandbox};
@@ -1,7 +1,7 @@
1
- import type { IFileSystem } from "just-bash";
1
+ import type { JustBashFilesystem } from "#public/sandbox/just-bash-sandbox.js";
2
2
  export declare function createSelfModificationFilesystem(input: {
3
3
  readonly appRoot?: string;
4
- readonly defaultFilesystem: IFileSystem;
4
+ readonly defaultFilesystem: JustBashFilesystem;
5
5
  resolveProjectPath?(path: string): string;
6
6
  readonly justBash: typeof import("just-bash");
7
- }): Promise<IFileSystem>;
7
+ }): Promise<JustBashFilesystem>;
@@ -41,8 +41,8 @@ export interface DeployedSelfModificationConfig {
41
41
  readonly authorize: SelfModificationAuthorization;
42
42
  readonly credentials?: GitHubCredentialProvider | {
43
43
  /**
44
- * Self-hosted exception. Reads `EVE_SELF_MODIFICATION_GITHUB_TOKEN` from
45
- * the trusted deployment environment; never injects it into the sandbox.
44
+ * Reads `EVE_SELF_MODIFICATION_GITHUB_TOKEN` from the trusted deployment
45
+ * environment; never injects it into the sandbox.
46
46
  */
47
47
  readonly pat: true;
48
48
  };
@@ -1 +1 @@
1
- import{assertGitRef,assertRepositoryPart}from"../identifiers.js";function resolveDeployedSelfModificationConfig(e){if(!isRecord(e))throw Error(`Deployed self-modification configuration must be an object.`);let{source:t,target:n,authorize:r,credentials:i}=e;if(t===void 0||n===void 0||r===void 0)throw Error(`Deployed self-modification requires source, target, and authorization configuration.`);if(!isRecord(t))throw Error(`Deployed self-modification source must be an object.`);if(!isRecord(t.git))throw Error(`Deployed self-modification source.git must be an object.`);if(!isRecord(n))throw Error(`Deployed self-modification target must be an object.`);if(typeof r!=`function`)throw Error(`Deployed self-modification authorize must be a function.`);let{git:a}=t;if(typeof a.repository!=`string`||typeof a.directory!=`string`)throw Error(`Deployed self-modification source.git.repository and source.git.directory must be strings.`);if(typeof n.branch!=`string`)throw Error(`Deployed self-modification target.branch must be a string.`);return{authorize:r,credentials:parseCredentials(i),directory:parseDirectory(a.directory),repository:parseGitHubRepository(a.repository),targetBranch:parseBranch(n.branch)}}function parseCredentials(e){if(!isRecord(e))throw Error(`Deployed self-modification credentials must explicitly configure a credential provider or the self-hosted PAT exception.`);let t=e.resolve!==void 0,n=e.pat!==void 0;if(t&&n)throw Error(`Deployed self-modification credentials must configure either a credential provider or pat, not both.`);if(n){if(e.pat!==!0)throw Error(`Deployed self-modification credentials.pat must be true.`);return{kind:`pat`}}if(!isGitHubCredentialProvider(e))throw Error(`Deployed self-modification credentials must be an object with a resolve function.`);return{kind:`provider`,provider:e}}function isGitHubCredentialProvider(e){return isRecord(e)&&typeof e.resolve==`function`}function parseGitHubRepository(e){let t=/^github\.com\/([^/]+)\/([^/]+)$/u.exec(e);if(t?.[1]===void 0||t[2]===void 0)throw Error(`Deployed self-modification source.git.repository must use github.com/owner/repo form.`);return assertRepositoryPart(t[1],`repository owner`),assertRepositoryPart(t[2],`repository name`),{owner:t[1],repo:t[2]}}function parseDirectory(e){if(e!==`.`&&(e.length===0||e.startsWith(`/`)||e.includes(`\\`)||e.split(`/`).some(e=>e===``||e===`.`||e===`..`)))throw Error(`Deployed self-modification source.git.directory must be a safe repository-relative path.`);return e}function parseBranch(e){if(assertGitRef(e,`target branch`),e.startsWith(`refs/`))throw Error(`Deployed self-modification target.branch must be a branch name, not a full Git ref.`);return e}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{resolveDeployedSelfModificationConfig};
1
+ import{assertGitRef,assertRepositoryPart}from"../identifiers.js";function resolveDeployedSelfModificationConfig(e){if(!isRecord(e))throw Error(`Deployed self-modification configuration must be an object.`);let{source:t,target:n,authorize:r,credentials:i}=e;if(t===void 0||n===void 0||r===void 0)throw Error(`Deployed self-modification requires source, target, and authorization configuration.`);if(!isRecord(t))throw Error(`Deployed self-modification source must be an object.`);if(!isRecord(t.git))throw Error(`Deployed self-modification source.git must be an object.`);if(!isRecord(n))throw Error(`Deployed self-modification target must be an object.`);if(typeof r!=`function`)throw Error(`Deployed self-modification authorize must be a function.`);let{git:a}=t;if(typeof a.repository!=`string`||typeof a.directory!=`string`)throw Error(`Deployed self-modification source.git.repository and source.git.directory must be strings.`);if(typeof n.branch!=`string`)throw Error(`Deployed self-modification target.branch must be a string.`);return{authorize:r,credentials:parseCredentials(i),directory:parseDirectory(a.directory),repository:parseGitHubRepository(a.repository),targetBranch:parseBranch(n.branch)}}function parseCredentials(e){if(!isRecord(e))throw Error("Deployed self-modification credentials must explicitly configure a credential provider or `{ pat: true }`.");let t=e.resolve!==void 0,n=e.pat!==void 0;if(t&&n)throw Error(`Deployed self-modification credentials must configure either a credential provider or pat, not both.`);if(n){if(e.pat!==!0)throw Error(`Deployed self-modification credentials.pat must be true.`);return{kind:`pat`}}if(!isGitHubCredentialProvider(e))throw Error(`Deployed self-modification credentials must be an object with a resolve function.`);return{kind:`provider`,provider:e}}function isGitHubCredentialProvider(e){return isRecord(e)&&typeof e.resolve==`function`}function parseGitHubRepository(e){let t=/^github\.com\/([^/]+)\/([^/]+)$/u.exec(e);if(t?.[1]===void 0||t[2]===void 0)throw Error(`Deployed self-modification source.git.repository must use github.com/owner/repo form.`);return assertRepositoryPart(t[1],`repository owner`),assertRepositoryPart(t[2],`repository name`),{owner:t[1],repo:t[2]}}function parseDirectory(e){if(e!==`.`&&(e.length===0||e.startsWith(`/`)||e.includes(`\\`)||e.split(`/`).some(e=>e===``||e===`.`||e===`..`)))throw Error(`Deployed self-modification source.git.directory must be a safe repository-relative path.`);return e}function parseBranch(e){if(assertGitRef(e,`target branch`),e.startsWith(`refs/`))throw Error(`Deployed self-modification target.branch must be a branch name, not a full Git ref.`);return e}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{resolveDeployedSelfModificationConfig};
@@ -9,7 +9,6 @@ export interface SelfModificationSetupValues {
9
9
  readonly connector: string;
10
10
  readonly directory: string;
11
11
  readonly repository: string;
12
- readonly vercelBackend: boolean;
13
12
  }
14
13
  export interface DetectedGitRepository {
15
14
  readonly branch?: string;
@@ -1,7 +1,4 @@
1
- import{renderLocalSelfModificationExtension}from"./scaffold.js";import{createHash}from"node:crypto";import{mkdir,readFile,writeFile}from"node:fs/promises";import{join,relative}from"node:path";import{execFile}from"node:child_process";import{promisify}from"node:util";import{stripLogicalPathExtension}from"#discover/filesystem.js";import{captureVercel,runVercelCaptureStdout}from"#setup/primitives/run-vercel.js";import{discoverAgent}from"#discover/discover-agent.js";const SELF_MODIFICATION_CONFIG_PATH=`agent/extensions/self-modification/extension.ts`,DEPLOYED_SELF_MODIFICATION_CONFIG_PATH=`agent/extensions/self-modification-remote/extension.ts`,runFile=promisify(execFile),DEFAULT_EXTENSION=renderLocalSelfModificationExtension(),LEGACY_DEFAULT_EXTENSION=DEFAULT_EXTENSION.replace(`"eve/self-modification/local"`,`"eve/self-modification"`),defaultDependencies={captureVercel,runVercelCaptureStdout};function connectorName(e,t){return`selfmod-${e}-${t}`.toLowerCase().replaceAll(/[^a-z0-9-]/gu,`-`)}function renderSelfModificationConfig(e){if(e===void 0)return DEFAULT_EXTENSION;let t=[...new Set(e.channelNames)].filter(e=>e!==`eve`).sort(),n=(e.vercelBackend?t:[]).map(e=>` case ${JSON.stringify(`channel:${e}`)}:
2
- // Authorize trusted principals for this channel before returning true.
3
- return false;`).join(`
4
- `),r=`${e.vercelBackend?` case "http": {
1
+ import{renderLocalSelfModificationExtension}from"./scaffold.js";import{createHash}from"node:crypto";import{mkdir,readFile,writeFile}from"node:fs/promises";import{join,relative}from"node:path";import{execFile}from"node:child_process";import{promisify}from"node:util";import{stripLogicalPathExtension}from"#discover/filesystem.js";import{captureVercel,runVercelCaptureStdout}from"#setup/primitives/run-vercel.js";import{discoverAgent}from"#discover/discover-agent.js";const SELF_MODIFICATION_CONFIG_PATH=`agent/extensions/self-modification/extension.ts`,DEPLOYED_SELF_MODIFICATION_CONFIG_PATH=`agent/extensions/self-modification-remote/extension.ts`,runFile=promisify(execFile),DEFAULT_EXTENSION=renderLocalSelfModificationExtension(),LEGACY_DEFAULT_EXTENSION=DEFAULT_EXTENSION.replace(`"eve/self-modification/local"`,`"eve/self-modification"`),defaultDependencies={captureVercel,runVercelCaptureStdout};function connectorName(e,t){return`selfmod-${e}-${t}`.toLowerCase().replaceAll(/[^a-z0-9-]/gu,`-`)}function renderSelfModificationConfig(e){if(e===void 0)return DEFAULT_EXTENSION;let t=` case "http": {
5
2
  const projectId = process.env.VERCEL_PROJECT_ID;
6
3
  return (
7
4
  projectId !== undefined &&
@@ -12,7 +9,10 @@ import{renderLocalSelfModificationExtension}from"./scaffold.js";import{createHas
12
9
  principal.attributes.project_id === projectId
13
10
  );
14
11
  }
15
- `:``}${n}`,i=`Self-modification could not obtain a GitHub credential from Vercel Connect for ${e.connector}. Install and attach the configured GitHub connector to this Vercel project, install the managed GitHub App for the configured repository, then retry.`,a=`import { getToken } from "@vercel/connect";
12
+ ${[...new Set(e.channelNames)].filter(e=>e!==`eve`).sort().map(e=>` case ${JSON.stringify(`channel:${e}`)}:
13
+ // Authorize trusted principals for this channel before returning true.
14
+ return false;`).join(`
15
+ `)}`,n=`Self-modification could not obtain a GitHub credential from Vercel Connect for ${e.connector}. Install and attach the configured GitHub connector to this Vercel project, install the managed GitHub App for the configured repository, then retry.`,r=`import { getToken } from "@vercel/connect";
16
16
  import selfModification from "eve/self-modification/remote";
17
17
 
18
18
  export default selfModification({
@@ -40,19 +40,19 @@ export default selfModification({
40
40
  subject: { type: "app" },
41
41
  });
42
42
  } catch (error) {
43
- throw new Error(${JSON.stringify(i)}, { cause: error });
43
+ throw new Error(${JSON.stringify(n)}, { cause: error });
44
44
  }
45
45
  },
46
46
  },
47
47
  authorize: ({ channel, principal }) => {
48
48
  switch (channel.kind) {
49
- ${r} default:
49
+ ${t} default:
50
50
  // Add another branch when you add a trusted channel.
51
51
  return false;
52
52
  }
53
53
  },
54
54
  });
55
- `;return`// eve-self-modification: generated-v1 digest:${createHash(`sha256`).update(a).digest(`hex`)}\n${a}`}function classifySelfModificationConfig(e){if(e===void 0)return`missing`;if(e===DEFAULT_EXTENSION||e===LEGACY_DEFAULT_EXTENSION||e===`import { defineSelfModificationConfig } from "eve/self-modification/config";
55
+ `;return`// eve-self-modification: generated-v1 digest:${createHash(`sha256`).update(r).digest(`hex`)}\n${r}`}function classifySelfModificationConfig(e){if(e===void 0)return`missing`;if(e===DEFAULT_EXTENSION||e===LEGACY_DEFAULT_EXTENSION||e===`import { defineSelfModificationConfig } from "eve/self-modification/config";
56
56
 
57
57
  export default defineSelfModificationConfig({});
58
58
  `)return`local`;let[t,...n]=e.split(`
@@ -13,4 +13,11 @@ export declare function registerDiscordCommand(applicationId: string, botToken:
13
13
  }, fetchImpl?: typeof fetch): Promise<void>;
14
14
  /** Points Discord HTTP Interactions at a persisted Connect connector. */
15
15
  export declare function configureDiscordInteractionsEndpoint(botToken: string, connectorId: string, fetchImpl?: typeof fetch): Promise<void>;
16
+ /**
17
+ * Turns on the Message Content intent, so messages that don't mention the bot,
18
+ * such as thread follow-ups, arrive with their text. Returns `false` when
19
+ * Discord refuses, as it does for a verified app in 100 or more servers, which
20
+ * needs Discord's approval instead.
21
+ */
22
+ export declare function enableDiscordMessageContentIntent(botToken: string, fetchImpl?: typeof fetch): Promise<boolean>;
16
23
  export {};
@@ -1 +1 @@
1
- import{z}from"#compiled/zod/index.js";const DiscordApplicationSchema=z.object({id:z.string(),name:z.string(),verify_key:z.string()});async function discordRequest(e,t,n,r){return r(`https://discord.com/api/v10${t}`,{...n,headers:{authorization:`Bot ${e}`,"content-type":`application/json`,...n.headers}})}async function resolveDiscordApplication(e,t=fetch){let n=await discordRequest(e,`/oauth2/applications/@me`,{method:`GET`},t);if(!n.ok)throw Error(`Discord rejected the bot token (HTTP ${n.status}).`);let r=DiscordApplicationSchema.safeParse(await n.json());if(!r.success)throw Error(`Discord returned incomplete application details.`);return{id:r.data.id,name:r.data.name,publicKey:r.data.verify_key}}async function registerDiscordCommand(e,t,n,r=fetch){let i=await discordRequest(t,`/applications/${encodeURIComponent(e)}/commands`,{method:`POST`,body:JSON.stringify({name:n.name,description:n.description,type:1,options:[{name:`message`,description:`What should the agent do?`,type:3,required:!0},{name:`file`,description:`A file for the agent to read`,type:11,required:!1}]})},r);if(!i.ok)throw Error(`Discord command registration failed (HTTP ${i.status}).`)}async function configureDiscordInteractionsEndpoint(e,t,n=fetch){let r=await discordRequest(e,`/applications/@me`,{method:`PATCH`,body:JSON.stringify({interactions_endpoint_url:`https://connect.vercel.com/trigger/${encodeURIComponent(t)}`})},n);if(!r.ok)throw Error(`Discord rejected the interactions endpoint (HTTP ${r.status}).`)}export{configureDiscordInteractionsEndpoint,registerDiscordCommand,resolveDiscordApplication};
1
+ import{z}from"#compiled/zod/index.js";const DiscordApplicationSchema=z.object({id:z.string(),name:z.string(),verify_key:z.string()});async function discordRequest(e,t,n,r){return r(`https://discord.com/api/v10${t}`,{...n,headers:{authorization:`Bot ${e}`,"content-type":`application/json`,...n.headers}})}async function resolveDiscordApplication(e,t=fetch){let n=await discordRequest(e,`/oauth2/applications/@me`,{method:`GET`},t);if(!n.ok)throw Error(`Discord rejected the bot token (HTTP ${n.status}).`);let r=DiscordApplicationSchema.safeParse(await n.json());if(!r.success)throw Error(`Discord returned incomplete application details.`);return{id:r.data.id,name:r.data.name,publicKey:r.data.verify_key}}async function registerDiscordCommand(e,t,n,r=fetch){let i=await discordRequest(t,`/applications/${encodeURIComponent(e)}/commands`,{method:`POST`,body:JSON.stringify({name:n.name,description:n.description,type:1,options:[{name:`message`,description:`What should the agent do?`,type:3,required:!0},{name:`file`,description:`A file for the agent to read`,type:11,required:!1}]})},r);if(!i.ok)throw Error(`Discord command registration failed (HTTP ${i.status}).`)}async function configureDiscordInteractionsEndpoint(e,t,n=fetch){let r=await discordRequest(e,`/applications/@me`,{method:`PATCH`,body:JSON.stringify({interactions_endpoint_url:`https://connect.vercel.com/trigger/${encodeURIComponent(t)}`})},n);if(!r.ok)throw Error(`Discord rejected the interactions endpoint (HTTP ${r.status}).`)}const DiscordApplicationFlagsSchema=z.object({flags:z.number().optional()});async function enableDiscordMessageContentIntent(e,t=fetch){let n=await discordRequest(e,`/applications/@me`,{method:`GET`},t);if(!n.ok)return!1;let r=DiscordApplicationFlagsSchema.safeParse(await n.json()).data?.flags??0;return r&786432?!0:(await discordRequest(e,`/applications/@me`,{method:`PATCH`,body:JSON.stringify({flags:r&565248|524288})},t)).ok}export{configureDiscordInteractionsEndpoint,enableDiscordMessageContentIntent,registerDiscordCommand,resolveDiscordApplication};
@@ -0,0 +1,18 @@
1
+ /** Name of the Vercel Daemon that holds the Discord Gateway connection. */
2
+ export declare const DISCORD_DAEMON_NAME = "discord-gateway";
3
+ /** Directory of the relay, relative to the project root. */
4
+ export declare const DISCORD_DAEMON_ROOT = "daemon";
5
+ /** The relay's files, by path relative to {@link DISCORD_DAEMON_ROOT}. */
6
+ export declare function discordDaemonFiles(connectorUid: string, options?: {
7
+ readonly messageContent: boolean;
8
+ }): Readonly<Record<string, string>>;
9
+ /** The `daemons` entry to add by hand to a project configured through `vercel.ts`. */
10
+ export declare function discordDaemonEntry(): string;
11
+ /**
12
+ * `vercel.json` with the relay's daemon added, given its current contents or
13
+ * `undefined` when there is none. Returns `undefined` when a daemon of the same
14
+ * name already exists, so the file is left as it is.
15
+ */
16
+ export declare function withDiscordDaemon(vercelJson: string | undefined): string | undefined;
17
+ /** Reads a text file, or `undefined` when there is none. */
18
+ export declare function readTextFile(path: string): Promise<string | undefined>;
@@ -0,0 +1,21 @@
1
+ import{readFile}from"node:fs/promises";import{isErrnoCode,isObject}from"#shared/guards.js";import{formatEveDependencySpecifier,resolveEvePackageContract}from"#setup/scaffold/create/project.js";import{DEFAULT_CONNECT_PACKAGE_VERSION}from"#setup/scaffold/version-tokens.js";const DISCORD_DAEMON_NAME=`discord-gateway`,DISCORD_DAEMON_ROOT=`daemon`;function discordDaemon(e){return{root:DISCORD_DAEMON_ROOT,entrypoint:`Dockerfile`,instances:{[e]:1}}}const DEFAULT_REGION=`iad1`;function discordDaemonFiles(e,t={messageContent:!1}){let n={private:!0,type:`module`,dependencies:{"@vercel/connect":DEFAULT_CONNECT_PACKAGE_VERSION,eve:formatEveDependencySpecifier(resolveEvePackageContract().version)}};return{".dockerignore":`node_modules
2
+ `,Dockerfile:`FROM node:24-slim
3
+ WORKDIR /app
4
+ ENV NODE_ENV=production
5
+ COPY package*.json ./
6
+ RUN npm install --omit=dev --no-audit --no-fund
7
+ COPY main.ts ./
8
+ USER node
9
+ CMD ["node", "main.ts"]
10
+ `,"main.ts":`import { connectDiscordCredentials } from "@vercel/connect/eve";
11
+ import { experimental_runDiscordGatewayRelay } from "eve/channels/discord/gateway";
12
+
13
+ await experimental_runDiscordGatewayRelay({
14
+ credentials: connectDiscordCredentials(${JSON.stringify(e)}),
15
+ // Lets thread follow-ups that don't mention the bot arrive with their text. Needs
16
+ // Message Content Intent under Bot in the Discord Developer Portal, or Discord refuses the relay.
17
+ messageContent: ${String(t.messageContent)},
18
+ // Defaults to the project's production URL; set EVE_URL to relay to \`eve dev\`.
19
+ url: process.env.EVE_URL,
20
+ });
21
+ `,"package.json":`${JSON.stringify(n,null,2)}\n`}}function discordDaemonEntry(){return`daemons: ${JSON.stringify({[DISCORD_DAEMON_NAME]:discordDaemon(DEFAULT_REGION)})}`}function withDiscordDaemon(e){let t={$schema:`https://openapi.vercel.sh/vercel.json`};if(e!==void 0){let n;try{n=JSON.parse(e)}catch{throw Error(`vercel.json contains invalid JSON; fix it, then run the setup again.`)}if(!isObject(n))throw Error(`vercel.json must contain a JSON object.`);t=n}if(t.daemons!==void 0&&!isObject(t.daemons))throw Error("vercel.json has a `daemons` value that isn't an object; fix it, then run the setup again.");let n=isObject(t.daemons)?t.daemons:{};if(n[`discord-gateway`]!==void 0)return;let r=discordDaemon(Array.isArray(t.regions)&&typeof t.regions[0]==`string`?t.regions[0]:DEFAULT_REGION);return`${JSON.stringify({...t,daemons:{...n,[DISCORD_DAEMON_NAME]:r}},null,2)}\n`}async function readTextFile(e){try{return await readFile(e,`utf8`)}catch(e){if(isErrnoCode(e,`ENOENT`))return;throw e}}export{DISCORD_DAEMON_NAME,DISCORD_DAEMON_ROOT,discordDaemonEntry,discordDaemonFiles,readTextFile,withDiscordDaemon};
@@ -2,30 +2,50 @@ import type { VercelProjectReference } from "#setup/project-resolution.js";
2
2
  import { deriveSlackConnectorSlug } from "#setup/scaffold/index.js";
3
3
  import { writeTextFile } from "#setup/scaffold/files.js";
4
4
  import { type SetupApplyContext, type SetupPrepareContext } from "../types.js";
5
- import { configureDiscordInteractionsEndpoint, registerDiscordCommand, resolveDiscordApplication } from "./api.js";
5
+ import { configureDiscordInteractionsEndpoint, enableDiscordMessageContentIntent, registerDiscordCommand, resolveDiscordApplication } from "./api.js";
6
6
  import { provisionDiscordConnector } from "./connect.js";
7
+ import { readTextFile } from "./daemon.js";
7
8
  export interface DiscordSetupDeps {
8
9
  configureEndpoint: typeof configureDiscordInteractionsEndpoint;
9
10
  deriveConnectorSlug: typeof deriveSlackConnectorSlug;
11
+ enableMessageContent: typeof enableDiscordMessageContentIntent;
10
12
  provisionConnector: typeof provisionDiscordConnector;
13
+ readTextFile: typeof readTextFile;
11
14
  registerCommand: typeof registerDiscordCommand;
12
15
  resolveApplication: typeof resolveDiscordApplication;
13
16
  writeTextFile: typeof writeTextFile;
14
17
  }
15
18
  interface DiscordSetupPlan {
16
19
  botToken: string;
17
- commandName: string;
18
- commandDescription: string;
20
+ /** The slash command to register; absent when the agent answers messages instead. */
21
+ command?: {
22
+ readonly name: string;
23
+ readonly description: string;
24
+ };
25
+ /** How to register the Gateway relay; absent for slash commands only. */
26
+ gateway?: DiscordGatewayPlan;
19
27
  project: VercelProjectReference;
20
28
  slug: string;
21
29
  }
30
+ /** The project's Vercel config, checked before anything is written. */
31
+ type DiscordGatewayPlan =
32
+ /** `vercel.json` with the daemon added, or `undefined` when it's already there. */
33
+ {
34
+ readonly vercelJson: string | undefined;
35
+ }
36
+ /** The project configures Vercel in `vercel.ts`, which setup doesn't edit. */
37
+ | {
38
+ readonly vercelTs: {
39
+ readonly registered: boolean;
40
+ };
41
+ };
22
42
  export declare function prepareDiscordSetup(context: SetupPrepareContext, deps?: DiscordSetupDeps): Promise<DiscordSetupPlan>;
23
43
  export declare function applyDiscordSetup(plan: DiscordSetupPlan, context: SetupApplyContext, deps?: DiscordSetupDeps): Promise<{
24
44
  deploymentRequired: true;
25
45
  facts: {
26
46
  label: string;
27
47
  value: string;
28
- kind: "url";
48
+ kind?: "url";
29
49
  }[];
30
50
  }>;
31
51
  export declare const DISCORD_SETUP: import("../types.js").SetupIntegration;
@@ -1,9 +1,10 @@
1
- import{configureDiscordInteractionsEndpoint,registerDiscordCommand,resolveDiscordApplication}from"./api.js";import{provisionDiscordConnector}from"./connect.js";import{defineSetupIntegration}from"../types.js";import{join}from"node:path";import{deriveSlackConnectorSlug}from"#setup/scaffold/index.js";import{writeTextFile}from"#setup/scaffold/files.js";import{text}from"#setup/ask.js";const defaultDeps={configureEndpoint:configureDiscordInteractionsEndpoint,deriveConnectorSlug:deriveSlackConnectorSlug,provisionConnector:provisionDiscordConnector,registerCommand:registerDiscordCommand,resolveApplication:resolveDiscordApplication,writeTextFile};function validateCommandName(e){let t=e.trim();return t?t.length>32?`Command name must be 32 characters or fewer.`:/^[a-z0-9_-]+$/.test(t)?null:`Use lowercase letters, numbers, hyphens, or underscores.`:`Command name is required.`}function connectTemplate(e){return`import { connectDiscordCredentials } from "@vercel/connect/eve";
1
+ import{configureDiscordInteractionsEndpoint,enableDiscordMessageContentIntent,registerDiscordCommand,resolveDiscordApplication}from"./api.js";import{provisionDiscordConnector}from"./connect.js";import{DISCORD_DAEMON_NAME,DISCORD_DAEMON_ROOT,discordDaemonEntry,discordDaemonFiles,readTextFile,withDiscordDaemon}from"./daemon.js";import{defineSetupIntegration}from"../types.js";import{join,relative}from"node:path";import{deriveSlackConnectorSlug}from"#setup/scaffold/index.js";import{WriteFileExistsError,writeTextFile}from"#setup/scaffold/files.js";import{select,text}from"#setup/ask.js";const defaultDeps={configureEndpoint:configureDiscordInteractionsEndpoint,deriveConnectorSlug:deriveSlackConnectorSlug,enableMessageContent:enableDiscordMessageContentIntent,provisionConnector:provisionDiscordConnector,readTextFile,registerCommand:registerDiscordCommand,resolveApplication:resolveDiscordApplication,writeTextFile};function validateCommandName(e){let t=e.trim();return t?t.length>32?`Command name must be 32 characters or fewer.`:/^[a-z0-9_-]+$/.test(t)?null:`Use lowercase letters, numbers, hyphens, or underscores.`:`Command name is required.`}function connectTemplate(e,t){return`import { connectDiscordCredentials } from "@vercel/connect/eve";
2
2
  import { discordChannel } from "eve/channels/discord";
3
3
 
4
4
  export default discordChannel({
5
- credentials: connectDiscordCredentials(${JSON.stringify(e)}),
5
+ credentials: connectDiscordCredentials(${JSON.stringify(e)}),${t?`
6
+ gateway: {},`:``}
6
7
  });
7
- `}async function prepareDiscordSetup(e,t=defaultDeps){e.presenter.log.info(`Create a Discord application or open an existing one, then go to Bot → Reset Token and copy the new bot token.
8
+ `}async function prepareDiscordSetup(e,t=defaultDeps){let n=await e.asker.ask(select({key:`discord-messages`,message:`How should people reach the agent in Discord?`,options:[{id:`gateway`,value:`gateway`,label:`DMs, mentions, and threads`,hint:`Adds an experimental Discord Gateway relay that runs as a Vercel Daemon`},{id:`commands`,value:`commands`,label:`A slash command`,hint:`No long-running process`}],recommended:`commands`,required:!0}));e.presenter.log.info(`Create a Discord application or open an existing one, then go to Bot → Reset Token and copy the new bot token.
8
9
  Create: https://discord.com/developers/applications?new_application=true
9
- Existing applications: https://discord.com/developers/applications`);let n=(await e.asker.ask(text({key:`discord-bot-token`,message:`Discord bot token`,required:!0,sensitive:!0,environment:`DISCORD_BOT_TOKEN`}))).trim(),r=await e.asker.ask(text({key:`discord-command-name`,message:`Discord command name`,detected:`ask`,required:!0,validate:validateCommandName})),i=await e.asker.ask(text({key:`discord-command-description`,message:`Discord command description`,detected:`Ask the eve agent`,required:!0,validate:e=>e.trim().length===0?`Command description is required.`:e.trim().length>100?`Command description must be 100 characters or fewer.`:null})),a=await e.resolveVercelProject(`Discord`);return{botToken:n,commandName:r.trim(),commandDescription:i.trim(),project:a,slug:await t.deriveConnectorSlug(e.appRoot)}}async function applyDiscordSetup(e,t,n=defaultDeps){let r=await n.resolveApplication(e.botToken),i=await n.provisionConnector({botToken:e.botToken,log:t.presenter.log,project:e.project,projectRoot:t.projectRoot,slug:e.slug,signal:t.signal});await n.registerCommand(r.id,e.botToken,{name:e.commandName,description:e.commandDescription}),await n.configureEndpoint(e.botToken,i.id),await n.writeTextFile(join(t.appRoot,`agent/channels/discord.ts`),connectTemplate(i.uid),{force:t.force});let a=`https://discord.com/oauth2/authorize?client_id=${encodeURIComponent(r.id)}&scope=bot%20applications.commands&permissions=3072`;return t.presenter.nextSteps([`Install the Discord application, then try /${e.commandName}: ${a}`]),{deploymentRequired:!0,facts:[{label:`Discord application dashboard`,value:`https://discord.com/developers/applications/${r.id}/information`,kind:`url`}]}}const DISCORD_SETUP=defineSetupIntegration({kind:`discord`,label:`Discord`,hint:`Slash commands and interactions`,prepare:prepareDiscordSetup,apply:applyDiscordSetup});export{DISCORD_SETUP,applyDiscordSetup,prepareDiscordSetup};
10
+ Existing applications: https://discord.com/developers/applications`);let r=(await e.asker.ask(text({key:`discord-bot-token`,message:`Discord bot token`,required:!0,sensitive:!0,environment:`DISCORD_BOT_TOKEN`}))).trim(),i=n===`commands`?await askCommand(e):void 0,a=await preflightFiles(e,n===`gateway`,t),o={botToken:r,project:await e.resolveVercelProject(`Discord`),slug:await t.deriveConnectorSlug(e.appRoot)};return i!==void 0&&(o.command=i),a!==void 0&&(o.gateway=a),o}async function askCommand(e){let t=await e.asker.ask(text({key:`discord-command-name`,message:`Discord command name`,detected:`ask`,required:!0,validate:validateCommandName})),n=await e.asker.ask(text({key:`discord-command-description`,message:`Discord command description`,detected:`Ask the eve agent`,required:!0,validate:e=>e.trim().length===0?`Command description is required.`:e.trim().length>100?`Command description must be 100 characters or fewer.`:null}));return{name:t.trim(),description:n.trim()}}async function preflightFiles(e,t,n){let r=[join(e.appRoot,`agent/channels/discord.ts`),...t?Object.keys(discordDaemonFiles(``)).map(t=>join(e.projectRoot,DISCORD_DAEMON_ROOT,t)):[]];if(!e.force){for(let e of r)if(await n.readTextFile(e)!==void 0)throw new WriteFileExistsError(e)}if(!t)return;let i=await n.readTextFile(join(e.projectRoot,`vercel.ts`));return i===void 0?{vercelJson:withDiscordDaemon(await n.readTextFile(join(e.projectRoot,`vercel.json`)))}:{vercelTs:{registered:i.includes(DISCORD_DAEMON_NAME)}}}async function applyDiscordSetup(e,t,n=defaultDeps){let r=await n.resolveApplication(e.botToken),i=await n.provisionConnector({botToken:e.botToken,log:t.presenter.log,project:e.project,projectRoot:t.projectRoot,slug:e.slug,signal:t.signal});e.command!==void 0&&await n.registerCommand(r.id,e.botToken,e.command),await n.configureEndpoint(e.botToken,i.id);let{gateway:a}=e;await n.writeTextFile(join(t.appRoot,`agent/channels/discord.ts`),connectTemplate(i.uid,a!==void 0),{force:t.force});let o=[];if(a!==void 0){let r=await n.enableMessageContent(e.botToken).catch(()=>!1);r||o.push({label:`Enable Message Content`,value:`Discord didn't let setup turn on Message Content Intent, so thread follow-ups must mention the bot. Turn it on under Bot in the Discord Developer Portal, then set messageContent: true in ${DISCORD_DAEMON_ROOT}/main.ts.`});for(let[e,a]of Object.entries(discordDaemonFiles(i.uid,{messageContent:r})))await n.writeTextFile(join(t.projectRoot,DISCORD_DAEMON_ROOT,e),a,{force:t.force});`vercelJson`in a&&a.vercelJson!==void 0&&await n.writeTextFile(join(t.projectRoot,`vercel.json`),a.vercelJson,{force:!0}),`vercelTs`in a&&!a.vercelTs.registered&&o.push({label:`Add to the config ${relative(t.appRoot,join(t.projectRoot,`vercel.ts`))||`vercel.ts`} exports`,value:discordDaemonEntry()})}let s=`https://discord.com/oauth2/authorize?client_id=${encodeURIComponent(r.id)}&scope=bot%20applications.commands&permissions=${a===void 0?`3072`:`309237713920`}`;return t.presenter.nextSteps([e.command===void 0?`Install the bot from its install URL, then DM it or mention it in a channel.`:`Install the bot from its install URL, then try /${e.command.name}.`,...a===void 0?[]:[`Deploy to start the experimental Gateway relay in ${DISCORD_DAEMON_ROOT}/. Run one instance per bot.`]]),{deploymentRequired:!0,facts:[{label:`Discord bot install URL`,value:s,kind:`url`},{label:`Discord application dashboard`,value:`https://discord.com/developers/applications/${r.id}/information`,kind:`url`},...o]}}const DISCORD_SETUP=defineSetupIntegration({kind:`discord`,label:`Discord`,hint:`Messages, DMs, and slash commands`,prepare:prepareDiscordSetup,apply:applyDiscordSetup});export{DISCORD_SETUP,applyDiscordSetup,prepareDiscordSetup};
@@ -1 +1 @@
1
- import{defineSetupIntegration}from"../types.js";import{describeIntegrationSetupEnvironment}from"../shared/environment.js";import{installScaffoldDependencies}from"../shared/scaffold.js";import{relative}from"node:path";import{ensurePackageDependencies}from"#setup/scaffold/index.js";import{confirm,select,text}from"#setup/ask.js";import{DEPLOYED_SELF_MODIFICATION_CONFIG_PATH,SELF_MODIFICATION_CONFIG_PATH,classifySelfModificationConfig,connectorName,defaultSelfModificationSetupOperations,directoryError,gitRefError,renderSelfModificationConfig,repositoryPartError}from"#self-modification/setup.js";import{detectLegacySelfModificationScaffold,removeLegacySelfModificationScaffold}from"#self-modification/migration.js";import{DEFAULT_CONNECT_PACKAGE_VERSION,DEFAULT_MICROSANDBOX_PACKAGE_VERSION}from"#setup/scaffold/version-tokens.js";const defaultApplyDependencies={ensurePackageDependencies,installScaffoldDependencies},SELF_MODIFICATION_PRODUCTION_DEPENDENCIES={"@vercel/connect":DEFAULT_CONNECT_PACKAGE_VERSION,microsandbox:DEFAULT_MICROSANDBOX_PACKAGE_VERSION};function validationResult(e){return e??null}async function prepareLegacyScaffoldCleanup(e){let t=await detectLegacySelfModificationScaffold(e.appRoot);return t===void 0?void 0:await e.asker.ask(confirm({key:`self-modification-cleanup`,message:`A legacy self-modification scaffold was found at ${relative(e.appRoot,t.root)}. This scaffold format is no longer supported. Do you want to remove it?`,recommended:!0,required:!0}))?t:void 0}function withLegacyScaffold(e,t){return t===void 0?e:{...e,legacyScaffold:t}}async function prepareSelfModificationSetup(e,t=defaultSelfModificationSetupOperations(e.appRoot,void 0,e.projectRoot)){let n=await prepareLegacyScaffoldCleanup(e),r=await t.readConfig();if(classifySelfModificationConfig(r)===`authored`)return e.presenter.note(`The existing ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH} contains authored configuration and was not overwritten.`,`Manual update required`,{tone:`warning`}),withLegacyScaffold({kind:`authored`},n);if(await e.asker.ask(select({key:`self-modification-mode`,message:`How should self-modification be enabled?`,options:[{id:`deployed`,value:`deployed`,label:`Enable for deployed`,hint:`Let deployed agents propose source changes through draft pull requests`},{id:`local`,value:`local`,label:`Keep local`,hint:`Only enable source editing during local development`}],recommended:`local`,required:!0}))===`local`)return withLegacyScaffold({kind:`local`},n);let[i,a,o]=await Promise.all([e.resolveVercelProject(`self-modification`),t.detectGitRepository(),t.detectChannelNames()]),s=await e.asker.ask(text({key:`self-modification-repository-owner`,message:`GitHub repository owner`,detected:a.owner,required:!0,validate:e=>validationResult(repositoryPartError(e))})),c=await e.asker.ask(text({key:`self-modification-repository-name`,message:`GitHub repository name`,detected:a.repo,required:!0,validate:e=>validationResult(repositoryPartError(e))})),l=await e.asker.ask(text({key:`self-modification-repository-directory`,message:`Application directory relative to the repository root`,detected:a.directory??`.`,required:!0,validate:e=>validationResult(directoryError(e))})),u=await e.asker.ask(text({key:`self-modification-target-branch`,message:`Target branch`,detected:a.branch??`main`,required:!0,validate:e=>validationResult(gitRefError(e))})),d=connectorName(s,c),f={branch:u,channelNames:o,connector:`github/${d}`,directory:l,repository:`github.com/${s}/${c}`,vercelBackend:!0};return e.presenter.note(renderSelfModificationConfig(f),`Generated ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}`),e.presenter.note(`Vercel Connect will issue short-lived GitHub App credentials restricted to this repository. Install the managed GitHub App and select only this repository. Review, merge, and deployment remain separate operator boundaries.`,`Security summary`),withLegacyScaffold(await e.asker.ask(confirm({key:`self-modification-confirm`,message:`Create or attach this GitHub connector and write this configuration?`,recommended:!1,required:!0}))?{kind:`deployed`,connectorName:d,project:i,values:f}:{kind:`local`},n)}async function applySelfModificationSetup(e,t,n=defaultSelfModificationSetupOperations(t.appRoot,void 0,t.projectRoot),r=defaultApplyDependencies){if(e.legacyScaffold!==void 0&&(await removeLegacySelfModificationScaffold(t.appRoot,e.legacyScaffold),t.presenter.log.success(`Removed the retired self-modification scaffold.`)),e.kind===`authored`)return{facts:[{label:`Self-modification`,value:`manual configuration update required`}]};if(e.kind===`local`)return{facts:[]};let i=await n.findOrCreateConnector(e.connectorName,e.project);await n.attachConnector(i,e.project);let a=await r.ensurePackageDependencies({dependencies:SELF_MODIFICATION_PRODUCTION_DEPENDENCIES,projectRoot:t.appRoot});return await r.installScaffoldDependencies({changed:a.length>0,log:t.presenter.log,projectPath:t.appRoot,signal:t.signal}),await n.writeConfig(renderSelfModificationConfig({...e.values,connector:i})),t.presenter.log.success(`Updated ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}.`),t.presenter.nextSteps([`Install the managed GitHub App for the configured repository, then deploy or redeploy.`,e.values.vercelBackend?`After deployment, try self-modification by running \`eve dev <deployment-url>\` from this linked project. The generated policy admits its Vercel OIDC identity over HTTP; configured channels remain denied until you update \`${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}\`.`:`Before deployment, configure \`authorize\` in \`${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}\` to admit a trusted principal for your deployment's channel. After deployment, use that channel to try self-modification.`]),{deploymentRequired:!0,facts:[{label:`Repository`,value:e.values.repository},{label:`Application directory`,value:e.values.directory},{label:`Target branch`,value:e.values.branch},{label:`Credential`,value:i}]}}async function prepareLocalSelfModificationSetup(e,t=defaultSelfModificationSetupOperations(e.appRoot,void 0,e.projectRoot)){let n=await prepareLegacyScaffoldCleanup(e),r=await t.readLocalConfig();return classifySelfModificationConfig(r)===`authored`?(e.presenter.note(`The existing ${SELF_MODIFICATION_CONFIG_PATH} contains authored configuration and was not overwritten.`,`Manual update required`,{tone:`warning`}),withLegacyScaffold({kind:`authored`},n)):withLegacyScaffold({kind:`local`},n)}function describeEnvironment(e){if(e.vercel.kind===`available`)return describeIntegrationSetupEnvironment(e);switch(e.vercel.reason){case`logged-out`:return`No authenticated Vercel account found. Local editing remains available; deployed proposals require Vercel Connect.`;case`cli-missing`:return`Vercel CLI not found. Local editing remains available; deployed proposals require Vercel Connect.`;case`unavailable`:return`Could not verify the Vercel account. Local editing remains available; deployed proposals require Vercel Connect.`}}const SELF_MODIFICATION_SETUP=defineSetupIntegration({kind:`self-modification`,label:`Self-modification`,hint:`Local source editing is enabled`,describeEnvironment,prepare:prepareLocalSelfModificationSetup,apply:applySelfModificationSetup}),SELF_MODIFICATION_PRODUCTION_SETUP=defineSetupIntegration({kind:`self-modification-production`,label:`Self-modification production`,hint:`Configure deployed draft pull requests`,describeEnvironment,prepare:prepareSelfModificationSetup,apply:applySelfModificationSetup});export{SELF_MODIFICATION_PRODUCTION_SETUP,SELF_MODIFICATION_SETUP,applySelfModificationSetup,prepareLocalSelfModificationSetup,prepareSelfModificationSetup};
1
+ import{defineSetupIntegration}from"../types.js";import{describeIntegrationSetupEnvironment}from"../shared/environment.js";import{installScaffoldDependencies}from"../shared/scaffold.js";import{relative}from"node:path";import{ensurePackageDependencies}from"#setup/scaffold/index.js";import{confirm,select,text}from"#setup/ask.js";import{DEFAULT_CONNECT_PACKAGE_VERSION}from"#setup/scaffold/version-tokens.js";import{DEPLOYED_SELF_MODIFICATION_CONFIG_PATH,SELF_MODIFICATION_CONFIG_PATH,classifySelfModificationConfig,connectorName,defaultSelfModificationSetupOperations,directoryError,gitRefError,renderSelfModificationConfig,repositoryPartError}from"#self-modification/setup.js";import{detectLegacySelfModificationScaffold,removeLegacySelfModificationScaffold}from"#self-modification/migration.js";const defaultApplyDependencies={ensurePackageDependencies,installScaffoldDependencies},SELF_MODIFICATION_PRODUCTION_DEPENDENCIES={"@vercel/connect":DEFAULT_CONNECT_PACKAGE_VERSION};function validationResult(e){return e??null}async function prepareLegacyScaffoldCleanup(e){let t=await detectLegacySelfModificationScaffold(e.appRoot);return t===void 0?void 0:await e.asker.ask(confirm({key:`self-modification-cleanup`,message:`A legacy self-modification scaffold was found at ${relative(e.appRoot,t.root)}. This scaffold format is no longer supported. Do you want to remove it?`,recommended:!0,required:!0}))?t:void 0}function withLegacyScaffold(e,t){return t===void 0?e:{...e,legacyScaffold:t}}async function prepareSelfModificationSetup(e,t=defaultSelfModificationSetupOperations(e.appRoot,void 0,e.projectRoot)){let n=await prepareLegacyScaffoldCleanup(e),r=await t.readConfig();if(classifySelfModificationConfig(r)===`authored`)return e.presenter.note(`The existing ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH} contains authored configuration and was not overwritten.`,`Manual update required`,{tone:`warning`}),withLegacyScaffold({kind:`authored`},n);if(await e.asker.ask(select({key:`self-modification-mode`,message:`How should self-modification be enabled?`,options:[{id:`deployed`,value:`deployed`,label:`Enable for deployed`,hint:`Let deployed agents propose source changes through draft pull requests`},{id:`local`,value:`local`,label:`Keep local`,hint:`Only enable source editing during local development`}],recommended:`local`,required:!0}))===`local`)return withLegacyScaffold({kind:`local`},n);let[i,a,o]=await Promise.all([e.resolveVercelProject(`self-modification`),t.detectGitRepository(),t.detectChannelNames()]),s=await e.asker.ask(text({key:`self-modification-repository-owner`,message:`GitHub repository owner`,detected:a.owner,required:!0,validate:e=>validationResult(repositoryPartError(e))})),c=await e.asker.ask(text({key:`self-modification-repository-name`,message:`GitHub repository name`,detected:a.repo,required:!0,validate:e=>validationResult(repositoryPartError(e))})),l=await e.asker.ask(text({key:`self-modification-repository-directory`,message:`Application directory relative to the repository root`,detected:a.directory??`.`,required:!0,validate:e=>validationResult(directoryError(e))})),u=await e.asker.ask(text({key:`self-modification-target-branch`,message:`Target branch`,detected:a.branch??`main`,required:!0,validate:e=>validationResult(gitRefError(e))})),d=connectorName(s,c),f={branch:u,channelNames:o,connector:`github/${d}`,directory:l,repository:`github.com/${s}/${c}`};return e.presenter.note(renderSelfModificationConfig(f),`Generated ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}`),e.presenter.note(`Vercel Connect will issue short-lived GitHub App credentials restricted to this repository. Install the managed GitHub App and select only this repository. Review, merge, and deployment remain separate operator boundaries.`,`Security summary`),withLegacyScaffold(await e.asker.ask(confirm({key:`self-modification-confirm`,message:`Create or attach this GitHub connector and write this configuration?`,recommended:!1,required:!0}))?{kind:`deployed`,connectorName:d,project:i,values:f}:{kind:`local`},n)}async function applySelfModificationSetup(e,t,n=defaultSelfModificationSetupOperations(t.appRoot,void 0,t.projectRoot),r=defaultApplyDependencies){if(e.legacyScaffold!==void 0&&(await removeLegacySelfModificationScaffold(t.appRoot,e.legacyScaffold),t.presenter.log.success(`Removed the retired self-modification scaffold.`)),e.kind===`authored`)return{facts:[{label:`Self-modification`,value:`manual configuration update required`}]};if(e.kind===`local`)return{facts:[]};let i=await n.findOrCreateConnector(e.connectorName,e.project);await n.attachConnector(i,e.project);let a=await r.ensurePackageDependencies({dependencies:SELF_MODIFICATION_PRODUCTION_DEPENDENCIES,projectRoot:t.appRoot});return await r.installScaffoldDependencies({changed:a.length>0,log:t.presenter.log,projectPath:t.appRoot,signal:t.signal}),await n.writeConfig(renderSelfModificationConfig({...e.values,connector:i})),t.presenter.log.success(`Updated ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}.`),t.presenter.nextSteps([`Install the managed GitHub App for the configured repository, then deploy or redeploy.`,`After deployment, try self-modification by running \`eve dev <deployment-url>\` from this linked project. The generated policy admits its Vercel OIDC identity over HTTP; configured channels remain denied until you update \`${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}\`.`]),{deploymentRequired:!0,facts:[{label:`Repository`,value:e.values.repository},{label:`Application directory`,value:e.values.directory},{label:`Target branch`,value:e.values.branch},{label:`Credential`,value:i}]}}async function prepareLocalSelfModificationSetup(e,t=defaultSelfModificationSetupOperations(e.appRoot,void 0,e.projectRoot)){let n=await prepareLegacyScaffoldCleanup(e),r=await t.readLocalConfig();return classifySelfModificationConfig(r)===`authored`?(e.presenter.note(`The existing ${SELF_MODIFICATION_CONFIG_PATH} contains authored configuration and was not overwritten.`,`Manual update required`,{tone:`warning`}),withLegacyScaffold({kind:`authored`},n)):withLegacyScaffold({kind:`local`},n)}function describeEnvironment(e){if(e.vercel.kind===`available`)return describeIntegrationSetupEnvironment(e);switch(e.vercel.reason){case`logged-out`:return`No authenticated Vercel account found. Local editing remains available; deployed proposals require Vercel Connect.`;case`cli-missing`:return`Vercel CLI not found. Local editing remains available; deployed proposals require Vercel Connect.`;case`unavailable`:return`Could not verify the Vercel account. Local editing remains available; deployed proposals require Vercel Connect.`}}const SELF_MODIFICATION_SETUP=defineSetupIntegration({kind:`self-modification`,label:`Self-modification`,hint:`Local source editing is enabled`,describeEnvironment,prepare:prepareLocalSelfModificationSetup,apply:applySelfModificationSetup}),SELF_MODIFICATION_PRODUCTION_SETUP=defineSetupIntegration({kind:`self-modification-production`,label:`Self-modification production`,hint:`Configure deployed draft pull requests`,describeEnvironment,prepare:prepareSelfModificationSetup,apply:applySelfModificationSetup});export{SELF_MODIFICATION_PRODUCTION_SETUP,SELF_MODIFICATION_SETUP,applySelfModificationSetup,prepareLocalSelfModificationSetup,prepareSelfModificationSetup};
@@ -1,4 +1,4 @@
1
- import{pinnedNodeEngineMajor}from"../../node-engine.js";import{parseChatGptModelSelection}from"../../../shared/chatgpt-model.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{DEFAULT_CONNECT_PACKAGE_VERSION,resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_CHANNEL_TEMPLATES}from"./web-template.js";import{AGENT_INSTRUCTIONS_TEMPLATE}from"./instructions-template.js";import{SCAFFOLDED_AGENT_PATHS}from"./agent-paths.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.137`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.82.0`,nodeEngine:`>=24`};function resolveEvePackageContract(e=DEFAULT_EVE_PACKAGE_CONTRACT){return{version:resolveVersionToken(`evePackage.version`,e.version),nodeEngine:resolveVersionToken(`evePackage.nodeEngine`,e.nodeEngine)}}function modelProviderSlug(e){let t=(e.split(`/`)[0]??``).replaceAll(/[^A-Za-z0-9._-]/gu,``);return t.length>0?t:`anthropic`}function byokProviderEnvVar(e){let t=modelProviderSlug(e).toUpperCase().replaceAll(/[^A-Z0-9]/gu,`_`);return`${/^[0-9]/.test(t)?`_`:``}${t}_API_KEY`}function agentTemplateFiles(e,t){return{[SCAFFOLDED_AGENT_PATHS.config]:renderAgentTemplate(e,t),[SCAFFOLDED_AGENT_PATHS.channel]:WEB_CHANNEL_TEMPLATES.default,[SCAFFOLDED_AGENT_PATHS.instructions]:AGENT_INSTRUCTIONS_TEMPLATE}}function renderAgentTemplate(e,t){let n=parseChatGptModelSelection(e);return n===void 0?BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t)):`import { defineAgent } from "eve";\nimport { chatgpt } from "eve/models/openai";\n\nexport default defineAgent({\n model: chatgpt(${JSON.stringify(n)}),\n${reasoningTemplateLine(t)}});\n`}function reasoningTemplateLine(e){return e===void 0||e===`provider-default`?``:` reasoning: "${e}",\n`}function renderTemplate(e,t){return e===BASE_AGENT_TEMPLATE&&parseChatGptModelSelection(t.model)!==void 0?renderAgentTemplate(t.model,t.reasoning):e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t.reasoning)).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TYPESCRIPT_VERSION__`,t.typescriptPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
1
+ import{pinnedNodeEngineMajor}from"../../node-engine.js";import{parseChatGptModelSelection}from"../../../shared/chatgpt-model.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{DEFAULT_CONNECT_PACKAGE_VERSION,resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_CHANNEL_TEMPLATES}from"./web-template.js";import{AGENT_INSTRUCTIONS_TEMPLATE}from"./instructions-template.js";import{SCAFFOLDED_AGENT_PATHS}from"./agent-paths.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.137`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.83.0`,nodeEngine:`>=24`};function resolveEvePackageContract(e=DEFAULT_EVE_PACKAGE_CONTRACT){return{version:resolveVersionToken(`evePackage.version`,e.version),nodeEngine:resolveVersionToken(`evePackage.nodeEngine`,e.nodeEngine)}}function modelProviderSlug(e){let t=(e.split(`/`)[0]??``).replaceAll(/[^A-Za-z0-9._-]/gu,``);return t.length>0?t:`anthropic`}function byokProviderEnvVar(e){let t=modelProviderSlug(e).toUpperCase().replaceAll(/[^A-Z0-9]/gu,`_`);return`${/^[0-9]/.test(t)?`_`:``}${t}_API_KEY`}function agentTemplateFiles(e,t){return{[SCAFFOLDED_AGENT_PATHS.config]:renderAgentTemplate(e,t),[SCAFFOLDED_AGENT_PATHS.channel]:WEB_CHANNEL_TEMPLATES.default,[SCAFFOLDED_AGENT_PATHS.instructions]:AGENT_INSTRUCTIONS_TEMPLATE}}function renderAgentTemplate(e,t){let n=parseChatGptModelSelection(e);return n===void 0?BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t)):`import { defineAgent } from "eve";\nimport { chatgpt } from "eve/models/openai";\n\nexport default defineAgent({\n model: chatgpt(${JSON.stringify(n)}),\n${reasoningTemplateLine(t)}});\n`}function reasoningTemplateLine(e){return e===void 0||e===`provider-default`?``:` reasoning: "${e}",\n`}function renderTemplate(e,t){return e===BASE_AGENT_TEMPLATE&&parseChatGptModelSelection(t.model)!==void 0?renderAgentTemplate(t.model,t.reasoning):e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t.reasoning)).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TYPESCRIPT_VERSION__`,t.typescriptPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
2
2
 
3
3
  export default defineAgent({
4
4
  model: "__EVE_INIT_MODEL__",
@@ -1 +1 @@
1
- import{DEFAULT_EVE_PACKAGE_CONTRACT}from"../create/project.js";function resolveWebPackageVersions(e,t){return{evePackage:e?.evePackage??DEFAULT_EVE_PACKAGE_CONTRACT,aiPackageVersion:e?.aiPackageVersion??`^7.0.137`,betterAuthPackageVersion:e?.betterAuthPackageVersion??`1.6.26`,nextPackageVersion:e?.nextPackageVersion??(t===`sign-in-with-vercel`?`16.3.0`:`16.3.4`),reactPackageVersion:e?.reactPackageVersion??`19.2.6`,reactDomPackageVersion:e?.reactDomPackageVersion??`19.2.6`,streamdownPackageVersion:e?.streamdownPackageVersion??`2.5.0`,zodPackageVersion:e?.zodPackageVersion??`4.5.4`,typesReactPackageVersion:e?.typesReactPackageVersion??`19.2.15`,typesReactDomPackageVersion:e?.typesReactDomPackageVersion??`19.2.3`}}export{resolveWebPackageVersions};
1
+ import{DEFAULT_EVE_PACKAGE_CONTRACT}from"../create/project.js";function resolveWebPackageVersions(e,t){return{evePackage:e?.evePackage??DEFAULT_EVE_PACKAGE_CONTRACT,aiPackageVersion:e?.aiPackageVersion??`^7.0.137`,betterAuthPackageVersion:e?.betterAuthPackageVersion??`1.6.26`,nextPackageVersion:e?.nextPackageVersion??(t===`sign-in-with-vercel`?`16.3.0`:`16.3.8`),reactPackageVersion:e?.reactPackageVersion??`19.2.6`,reactDomPackageVersion:e?.reactDomPackageVersion??`19.2.6`,streamdownPackageVersion:e?.streamdownPackageVersion??`2.5.0`,zodPackageVersion:e?.zodPackageVersion??`4.5.4`,typesReactPackageVersion:e?.typesReactPackageVersion??`19.2.15`,typesReactDomPackageVersion:e?.typesReactDomPackageVersion??`19.2.3`}}export{resolveWebPackageVersions};
@@ -1,5 +1,4 @@
1
1
  export declare const DEFAULT_CONNECT_PACKAGE_VERSION = "2.5.2";
2
- export declare const DEFAULT_MICROSANDBOX_PACKAGE_VERSION = "0.5.5";
3
2
  /**
4
3
  * Returns a scaffold version value, resolving a build-stamp token at the point
5
4
  * of need when the running code is unstamped. The published package is stamped
@@ -1 +1 @@
1
- import{existsSync,readFileSync,realpathSync}from"node:fs";import{dirname,join}from"node:path";import{fileURLToPath}from"node:url";function versionToken(e){return`__${e}_VERSION__`}function bareToken(e){return`__${e}__`}const NODE_ENGINE_TOKEN=bareToken(`NODE_ENGINE`),DEFAULT_CONNECT_PACKAGE_VERSION=`2.5.2`,DEFAULT_MICROSANDBOX_PACKAGE_VERSION=`0.5.5`,TOKEN_SOURCES={[versionToken(`EVE_PACKAGE`)]:{kind:`eve-version`},[versionToken(`EVE_PACKAGE_DEPENDENCY`)]:{kind:`eve-version`},[NODE_ENGINE_TOKEN]:{kind:`eve-node-engine`},[versionToken(`AI_SDK`)]:{kind:`catalog`,packageName:`ai`},[versionToken(`NEXT`)]:{kind:`catalog`,packageName:`next`},[versionToken(`REACT`)]:{kind:`catalog`,packageName:`react`},[versionToken(`REACT_DOM`)]:{kind:`catalog`,packageName:`react-dom`},[versionToken(`STREAMDOWN`)]:{kind:`catalog`,packageName:`streamdown`},[versionToken(`ZOD`)]:{kind:`catalog`,packageName:`zod`},[versionToken(`TYPESCRIPT`)]:{kind:`catalog`,packageName:`typescript`},[versionToken(`TYPES_REACT`)]:{kind:`catalog`,packageName:`@types/react`},[versionToken(`TYPES_REACT_DOM`)]:{kind:`catalog`,packageName:`@types/react-dom`}},resolvedTokens=new Map;function findEvePackageRoot(){let e=dirname(realpathSync(fileURLToPath(import.meta.url)));for(;;){let t=join(e,`package.json`);if(existsSync(t)&&JSON.parse(readFileSync(t,`utf8`)).name===`eve`)return e;let n=dirname(e);if(n===e)return;e=n}}function findWorkspaceManifest(e){let t=e;for(;;){let e=join(t,`pnpm-workspace.yaml`);if(existsSync(e))return e;let n=dirname(t);if(n===t)return;t=n}}function readCatalogVersion(e,t){let n=readFileSync(e,`utf8`).split(/\r?\n/),r=!1;for(let e of n){if(/^catalog:\s*$/.test(e)){r=!0;continue}if(!r)continue;if(/^\S/.test(e))break;let n=e.match(/^\s+(?:"([^"]+)"|([\w@/.-]+)):\s*"([^"]+)"/);if(n&&(n[1]??n[2])===t)return n[3]}}function resolveTokenFromDevTree(e){let t=TOKEN_SOURCES[e];if(t!==void 0)try{let e=findEvePackageRoot();if(e===void 0||!existsSync(join(e,`scripts/stamp-version-tokens.mjs`)))return;if(t.kind===`eve-version`){let t=JSON.parse(readFileSync(join(e,`package.json`),`utf8`));return typeof t.version==`string`?t.version:void 0}if(t.kind===`eve-node-engine`){let t=JSON.parse(readFileSync(join(e,`package.json`),`utf8`)).engines?.node;return typeof t==`string`?t:void 0}let n=findWorkspaceManifest(e);return n===void 0?void 0:readCatalogVersion(n,t.packageName)}catch{return}}function resolveVersionToken(e,t){if(!t.startsWith(`__`))return t;let n=resolvedTokens.get(t);if(n!==void 0)return n;let r=resolveTokenFromDevTree(t);if(r===void 0)throw Error(`Scaffold received unstamped version token (${e}=${t}). Build eve before using its dist entrypoint.`);return resolvedTokens.set(t,r),r}export{DEFAULT_CONNECT_PACKAGE_VERSION,DEFAULT_MICROSANDBOX_PACKAGE_VERSION,resolveVersionToken};
1
+ import{existsSync,readFileSync,realpathSync}from"node:fs";import{dirname,join}from"node:path";import{fileURLToPath}from"node:url";function versionToken(e){return`__${e}_VERSION__`}function bareToken(e){return`__${e}__`}const NODE_ENGINE_TOKEN=bareToken(`NODE_ENGINE`),DEFAULT_CONNECT_PACKAGE_VERSION=`2.5.2`,TOKEN_SOURCES={[versionToken(`EVE_PACKAGE`)]:{kind:`eve-version`},[versionToken(`EVE_PACKAGE_DEPENDENCY`)]:{kind:`eve-version`},[NODE_ENGINE_TOKEN]:{kind:`eve-node-engine`},[versionToken(`AI_SDK`)]:{kind:`catalog`,packageName:`ai`},[versionToken(`NEXT`)]:{kind:`catalog`,packageName:`next`},[versionToken(`REACT`)]:{kind:`catalog`,packageName:`react`},[versionToken(`REACT_DOM`)]:{kind:`catalog`,packageName:`react-dom`},[versionToken(`STREAMDOWN`)]:{kind:`catalog`,packageName:`streamdown`},[versionToken(`ZOD`)]:{kind:`catalog`,packageName:`zod`},[versionToken(`TYPESCRIPT`)]:{kind:`catalog`,packageName:`typescript`},[versionToken(`TYPES_REACT`)]:{kind:`catalog`,packageName:`@types/react`},[versionToken(`TYPES_REACT_DOM`)]:{kind:`catalog`,packageName:`@types/react-dom`}},resolvedTokens=new Map;function findEvePackageRoot(){let e=dirname(realpathSync(fileURLToPath(import.meta.url)));for(;;){let t=join(e,`package.json`);if(existsSync(t)&&JSON.parse(readFileSync(t,`utf8`)).name===`eve`)return e;let n=dirname(e);if(n===e)return;e=n}}function findWorkspaceManifest(e){let t=e;for(;;){let e=join(t,`pnpm-workspace.yaml`);if(existsSync(e))return e;let n=dirname(t);if(n===t)return;t=n}}function readCatalogVersion(e,t){let n=readFileSync(e,`utf8`).split(/\r?\n/),r=!1;for(let e of n){if(/^catalog:\s*$/.test(e)){r=!0;continue}if(!r)continue;if(/^\S/.test(e))break;let n=e.match(/^\s+(?:"([^"]+)"|([\w@/.-]+)):\s*"([^"]+)"/);if(n&&(n[1]??n[2])===t)return n[3]}}function resolveTokenFromDevTree(e){let t=TOKEN_SOURCES[e];if(t!==void 0)try{let e=findEvePackageRoot();if(e===void 0||!existsSync(join(e,`scripts/stamp-version-tokens.mjs`)))return;if(t.kind===`eve-version`){let t=JSON.parse(readFileSync(join(e,`package.json`),`utf8`));return typeof t.version==`string`?t.version:void 0}if(t.kind===`eve-node-engine`){let t=JSON.parse(readFileSync(join(e,`package.json`),`utf8`)).engines?.node;return typeof t==`string`?t:void 0}let n=findWorkspaceManifest(e);return n===void 0?void 0:readCatalogVersion(n,t.packageName)}catch{return}}function resolveVersionToken(e,t){if(!t.startsWith(`__`))return t;let n=resolvedTokens.get(t);if(n!==void 0)return n;let r=resolveTokenFromDevTree(t);if(r===void 0)throw Error(`Scaffold received unstamped version token (${e}=${t}). Build eve before using its dist entrypoint.`);return resolvedTokens.set(t,r),r}export{DEFAULT_CONNECT_PACKAGE_VERSION,resolveVersionToken};
@@ -70,6 +70,8 @@ export type InternalAgentModelDefinition = {
70
70
  contextWindowTokens?: number;
71
71
  maxOutputTokens?: number;
72
72
  source?: ModuleSourceRef;
73
+ /** Field of the `source` agent config export that holds this model; absent means `model`. */
74
+ sourceField?: "compaction.model";
73
75
  providerOptions?: Record<string, JsonObject>;
74
76
  promptCache?: AgentPromptCacheDefinition;
75
77
  };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Detects a built eve server that reported a failed start in `output`.
3
+ *
4
+ * srvx only logs a failed bind and sets `process.exitCode`, so the process can
5
+ * stay alive without serving anything. Callers must treat this output as fatal
6
+ * and stop the process themselves.
7
+ */
8
+ export declare function readBuiltServerStartFailure(output: string, listen: {
9
+ readonly host: string;
10
+ readonly port: number | string;
11
+ readonly retryHint: string;
12
+ }): Error | undefined;
@@ -0,0 +1,3 @@
1
+ function readBuiltServerStartFailure(e,t){let n=e.indexOf(`[srvx] Failed to start server:`),r=n===-1?-1:e.indexOf(`
2
+ `,n);if(r===-1)return;let i=e.slice(n);return e.slice(n,r).includes(`EADDRINUSE`)?Error(`Port ${String(t.port)} on ${t.host} is already in use. Another process is listening there; stop it or ${t.retryHint}.`):Error([`Built eve server failed to start on ${t.host}:${String(t.port)}.`,i].join(`
3
+ `))}export{readBuiltServerStartFailure};
@@ -26,6 +26,8 @@ export declare function startEveProductionServer(input: {
26
26
  readonly appRoot: string;
27
27
  readonly host: EveFrameworkHost;
28
28
  readonly origin: string;
29
+ /** How to pick another port, completing "stop it or ..." when the port is taken. */
30
+ readonly portRetryHint: string;
29
31
  }): Promise<EveProcessHandle>;
30
32
  /**
31
33
  * Resolve a shared eve dev server for `appRoot`, reusing a healthy registered
@@ -1,2 +1,2 @@
1
- import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";import{isLoopbackHostname}from"#shared/network-address.js";import{existsSync}from"node:fs";import{join}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{spawn}from"node:child_process";import{readDevelopmentRuntimeArtifactsRevision}from"#services/dev-client/runtime-artifacts.js";const DEFAULT_EVE_SERVER_TIMEOUT_MS=18e4,ANSI_ESCAPE_PATTERN=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`),SERVER_URL_CANDIDATE_PATTERN=/https?:\/\/[^\s"'<>]+/g;function normalizeOrigin(e){return new URL(e).origin}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,t){return join(resolveEveCacheDirectory(e),`${t.slug}-dev-server.json`)}function resolveEveDevServerLockPath(e,t){return join(resolveEveCacheDirectory(e),`${t.slug}-dev-server.lock`)}function resolveDevServerTimeout(e,t){if(e!==void 0){if(!Number.isFinite(e)||e<=0)throw Error(`eve ${t.label} development server timeout must be a positive number.`);return e}}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 readUsableEveDevServerRegistry(e,t){try{let n=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e,t),`utf8`)));return n===void 0||n.appRoot!==e||await readDevelopmentRuntimeArtifactsRevision({serverUrl:n.origin,timeoutMs:1e3})===void 0?void 0:n.origin}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t,n){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e,t),`${JSON.stringify({appRoot:e,origin:n.origin,pid:n.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,n){let r=resolveEveCacheDirectory(e),i=resolveEveDevServerLockPath(e,t),a=Date.now()+n;for(await mkdir(r,{recursive:!0});;)try{let e=await open(i,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(i,{force:!0})}}catch(r){if(!isNodeErrorWithCode(r,`EEXIST`))throw r;if(await readUsableEveDevServerRegistry(e,t)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(i),Date.now()>a)throw Error(`Timed out after ${n}ms waiting for another ${t.label} process to start eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}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=parseLocalServerOrigin(t[0]);if(e!==void 0)return e}}function formatEveDevOutputLine(e,t){let n=e.replace(/\r$/,``),r=n.replace(ANSI_ESCAPE_PATTERN,``).trim();if(r.length===0||/^☰eve\b/.test(r)||r===`CONFIGURATION_FIELD_CONFLICT`||r.startsWith(`[CONFIGURATION_FIELD_CONFLICT]`))return;let i=t===void 0?`[eve:dev]`:`[eve:dev:${t}]`,a=/server listening at\s+(https?:\/\/[^\s]+)/i.exec(n);return a===null?`${i} ${n}`:`${i} server listening at ${a[1]}`}function createEveDevOutputWriter(e){let t=``,writeLine=t=>{let n=formatEveDevOutputLine(t,e.logLabel);n!==void 0&&e.stream.write(`${n}\n`)};return{flush(){t.length!==0&&(writeLine(t),t=``)},write(e){t+=e.toString(`utf8`);let n=t.split(`
2
- `);t=n.pop()??``;for(let e of n)writeLine(e)}}}function startServerProcess(e){let t=e.timeoutMs??18e4;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=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stderr}),o=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stdout}),s=setTimeout(()=>{i.kill(),r(Error(`Timed out after ${t}ms waiting for eve to print its server URL.`))},t),cleanup=()=>{clearTimeout(s),i.off(`error`,handleError),i.off(`exit`,handleEarlyExit)},flushOutput=()=>{o.flush(),a.flush()},handleError=e=>{flushOutput(),cleanup(),r(e)},handleEarlyExit=(e,t)=>{flushOutput(),cleanup(),r(Error(`eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},handleOutput=e=>{let t=findLocalServerOrigin(e.toString(`utf8`));t!==void 0&&(cleanup(),n({origin:t,process:i}))};i.once(`error`,handleError),i.once(`exit`,handleEarlyExit),i.stdout.on(`data`,e=>{o.write(e),handleOutput(e)}),i.stderr.on(`data`,e=>{a.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){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`,...e.workspaceAgentName===void 0?[]:[`--agent`,e.workspaceAgentName]],command:process.execPath,cwd:e.appRoot,logLabel:e.logLabel,timeoutMs:e.timeoutMs}).then(installProcessShutdown)}function startEveProductionServer(e){let t=new URL(e.origin),n=t.port,r=join(e.appRoot,`.output`,`server`,`index.mjs`);if(!existsSync(r))throw Error(`eve production output is missing at ${r}. Run eve build from ${e.appRoot} before starting ${e.host.label}.`);return startServerProcess({args:[r],command:process.execPath,cwd:e.appRoot,env:{HOST:t.hostname,NITRO_HOST:t.hostname,NITRO_PORT:n,PORT:n}}).then(installProcessShutdown)}async function resolveSharedEveDevServer(e){let t=e.timeoutMs??18e4,n=await readUsableEveDevServerRegistry(e.appRoot,e.host);if(n!==void 0)return{origin:n};let r=await acquireEveDevServerLock(e.appRoot,e.host,t);try{let n=await readUsableEveDevServerRegistry(e.appRoot,e.host);if(n!==void 0)return{origin:n};let r=await startEveDevServer({appRoot:e.appRoot,logLabel:e.logLabel,timeoutMs:t,workspaceAgentName:e.workspaceAgentName});return await writeEveDevServerRegistry(e.appRoot,e.host,r),r}finally{await r()}}export{DEFAULT_EVE_SERVER_TIMEOUT_MS,resolveDevServerTimeout,resolveSharedEveDevServer,startEveProductionServer};
1
+ import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";import{isLoopbackHostname}from"#shared/network-address.js";import{existsSync}from"node:fs";import{join}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{spawn}from"node:child_process";import{readDevelopmentRuntimeArtifactsRevision}from"#services/dev-client/runtime-artifacts.js";import{readBuiltServerStartFailure}from"#shared/built-server-start-failure.js";const DEFAULT_EVE_SERVER_TIMEOUT_MS=18e4,ANSI_ESCAPE_PATTERN=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`),SERVER_URL_CANDIDATE_PATTERN=/https?:\/\/[^\s"'<>]+/g;function normalizeOrigin(e){return new URL(e).origin}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,t){return join(resolveEveCacheDirectory(e),`${t.slug}-dev-server.json`)}function resolveEveDevServerLockPath(e,t){return join(resolveEveCacheDirectory(e),`${t.slug}-dev-server.lock`)}function resolveDevServerTimeout(e,t){if(e!==void 0){if(!Number.isFinite(e)||e<=0)throw Error(`eve ${t.label} development server timeout must be a positive number.`);return e}}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 readUsableEveDevServerRegistry(e,t){try{let n=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e,t),`utf8`)));return n===void 0||n.appRoot!==e||await readDevelopmentRuntimeArtifactsRevision({serverUrl:n.origin,timeoutMs:1e3})===void 0?void 0:n.origin}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t,n){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e,t),`${JSON.stringify({appRoot:e,origin:n.origin,pid:n.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,n){let r=resolveEveCacheDirectory(e),i=resolveEveDevServerLockPath(e,t),a=Date.now()+n;for(await mkdir(r,{recursive:!0});;)try{let e=await open(i,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(i,{force:!0})}}catch(r){if(!isNodeErrorWithCode(r,`EEXIST`))throw r;if(await readUsableEveDevServerRegistry(e,t)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(i),Date.now()>a)throw Error(`Timed out after ${n}ms waiting for another ${t.label} process to start eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}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=parseLocalServerOrigin(t[0]);if(e!==void 0)return e}}function formatEveDevOutputLine(e,t){let n=e.replace(/\r$/,``),r=n.replace(ANSI_ESCAPE_PATTERN,``).trim();if(r.length===0||/^☰eve\b/.test(r)||r===`CONFIGURATION_FIELD_CONFLICT`||r.startsWith(`[CONFIGURATION_FIELD_CONFLICT]`))return;let i=t===void 0?`[eve:dev]`:`[eve:dev:${t}]`,a=/server listening at\s+(https?:\/\/[^\s]+)/i.exec(n);return a===null?`${i} ${n}`:`${i} server listening at ${a[1]}`}function createEveDevOutputWriter(e){let t=``,writeLine=t=>{let n=formatEveDevOutputLine(t,e.logLabel);n!==void 0&&e.stream.write(`${n}\n`)};return{flush(){t.length!==0&&(writeLine(t),t=``)},write(e){t+=e.toString(`utf8`);let n=t.split(`
2
+ `);t=n.pop()??``;for(let e of n)writeLine(e)}}}function startServerProcess(e){let t=e.timeoutMs??18e4;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=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stderr}),o=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stdout}),s=setTimeout(()=>{i.kill(),r(Error(`Timed out after ${t}ms waiting for eve to print its server URL.`))},t),c=!1,l=``,cleanup=()=>{c=!0,l=``,clearTimeout(s),i.off(`error`,handleError),i.off(`exit`,handleEarlyExit)},flushOutput=()=>{o.flush(),a.flush()},handleError=e=>{flushOutput(),cleanup(),r(e)},handleEarlyExit=(e,t)=>{flushOutput(),cleanup(),r(Error(`eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},handleOutput=t=>{if(c)return;let a=t.toString(`utf8`);l+=a;let o=e.listen===void 0?void 0:readBuiltServerStartFailure(l,e.listen);if(o!==void 0){flushOutput(),cleanup(),i.kill(),r(o);return}let s=findLocalServerOrigin(a);s!==void 0&&(cleanup(),n({origin:s,process:i}))};i.once(`error`,handleError),i.once(`exit`,handleEarlyExit),i.stdout.on(`data`,e=>{o.write(e),handleOutput(e)}),i.stderr.on(`data`,e=>{a.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){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`,...e.workspaceAgentName===void 0?[]:[`--agent`,e.workspaceAgentName]],command:process.execPath,cwd:e.appRoot,logLabel:e.logLabel,timeoutMs:e.timeoutMs}).then(installProcessShutdown)}function startEveProductionServer(e){let t=new URL(e.origin),n=t.port,r=join(e.appRoot,`.output`,`server`,`index.mjs`);if(!existsSync(r))throw Error(`eve production output is missing at ${r}. Run eve build from ${e.appRoot} before starting ${e.host.label}.`);return startServerProcess({args:[r],command:process.execPath,cwd:e.appRoot,env:{HOST:t.hostname,NITRO_HOST:t.hostname,NITRO_PORT:n,PORT:n},listen:{host:t.hostname,port:n,retryHint:e.portRetryHint}}).then(installProcessShutdown)}async function resolveSharedEveDevServer(e){let t=e.timeoutMs??18e4,n=await readUsableEveDevServerRegistry(e.appRoot,e.host);if(n!==void 0)return{origin:n};let r=await acquireEveDevServerLock(e.appRoot,e.host,t);try{let n=await readUsableEveDevServerRegistry(e.appRoot,e.host);if(n!==void 0)return{origin:n};let r=await startEveDevServer({appRoot:e.appRoot,logLabel:e.logLabel,timeoutMs:t,workspaceAgentName:e.workspaceAgentName});return await writeEveDevServerRegistry(e.appRoot,e.host,r),r}finally{await r()}}export{DEFAULT_EVE_SERVER_TIMEOUT_MS,resolveDevServerTimeout,resolveSharedEveDevServer,startEveProductionServer};
@@ -1,9 +1,8 @@
1
1
  import type { SessionAuth, SessionParent, SessionTurn } from "#context/keys.js";
2
- import type { SandboxProviderRuntime } from "#shared/sandbox-provider.js";
2
+ import type { SandboxProviderRuntime } from "#sandbox/provider.js";
3
3
  import type { RuntimeSandboxSession, RuntimeSandboxSessionFor, SandboxSession } from "#shared/sandbox-session.js";
4
4
  declare const ENVIRONMENT: unique symbol;
5
5
  declare const PROVIDER_RUNTIME: unique symbol;
6
- declare const CONFIGURATION_HASH: unique symbol;
7
6
  export interface SandboxSelectorContext {
8
7
  readonly session: {
9
8
  readonly auth: SessionAuth;
@@ -15,9 +14,9 @@ export interface SandboxSelectorContext {
15
14
  export type SandboxSelector = (context: SandboxSelectorContext) => Promise<RuntimeSandboxSession> | RuntimeSandboxSession;
16
15
  export type SandboxOpenArguments<Options> = Options extends undefined ? [] : Record<never, never> extends Options ? [options?: Options] : [options: Options];
17
16
  export interface SandboxEnvironmentIdentity {
18
- readonly [CONFIGURATION_HASH]: string;
19
17
  readonly [ENVIRONMENT]: true;
20
- readonly [PROVIDER_RUNTIME]: SandboxProviderRuntime;
18
+ /** A {@link SandboxProviderRuntime}, opaque so the public type does not carry core internals. */
19
+ readonly [PROVIDER_RUNTIME]: unknown;
21
20
  readonly provider: string;
22
21
  }
23
22
  export interface SandboxEnvironment<Options extends object | undefined = object, Session extends SandboxSession = SandboxSession> extends SandboxEnvironmentIdentity {
@@ -25,17 +24,12 @@ export interface SandboxEnvironment<Options extends object | undefined = object,
25
24
  }
26
25
  interface ConstructorRuntime {
27
26
  open(input: {
28
- readonly configurationHash: string;
29
27
  readonly environment: object;
30
- readonly environmentConfigurationHash: string;
31
28
  readonly options: object | undefined;
32
29
  readonly provider: SandboxProviderRuntime;
33
30
  }): Promise<RuntimeSandboxSession>;
34
31
  }
35
- export declare function createSandboxEnvironment<Options extends object | undefined = object, Session extends SandboxSession = SandboxSession>(input: {
36
- readonly configuration?: unknown;
37
- readonly runtime: SandboxProviderRuntime;
38
- }): SandboxEnvironment<Options, Session>;
32
+ export declare function createSandboxEnvironment<Options extends object | undefined = object, Session extends SandboxSession = SandboxSession>(runtime: SandboxProviderRuntime): SandboxEnvironment<Options, Session>;
39
33
  export declare function getSandboxEnvironmentRuntime(environment: SandboxEnvironmentIdentity): SandboxProviderRuntime;
40
34
  export declare function bindSandboxEnvironment(selector: SandboxSelector, environment: SandboxEnvironmentIdentity): SandboxSelector;
41
35
  export declare function getBoundSandboxEnvironment(value: unknown): SandboxEnvironmentIdentity | undefined;
@@ -1 +1 @@
1
- import{createHash}from"node:crypto";import{ContextContainer,contextStorage}from"#context/container.js";const ENVIRONMENT=Symbol.for(`eve.sandbox-environment`),PROVIDER_RUNTIME=Symbol.for(`eve.sandbox-provider-runtime`),CONFIGURATION_HASH=Symbol.for(`eve.sandbox-environment-configuration-hash`),SELECTOR_ENVIRONMENT=Symbol.for(`eve.sandbox-selector-environment`),RUNTIMES=Symbol.for(`eve.sandbox-constructor-runtimes`),globals=globalThis,runtimes=globals[RUNTIMES]??=new WeakMap;function createSandboxEnvironment(e){let t;return t={[CONFIGURATION_HASH]:hashConstructorOptions({environment:e.configuration,sandbox:{}}),[ENVIRONMENT]:!0,[PROVIDER_RUNTIME]:e.runtime,provider:e.runtime.providerName,async open(...n){let r=n[0],i=contextStorage.getStore(),a=i===void 0?void 0:runtimes.get(i);if(a===void 0)throw Error(`Sandbox environments can only open sandboxes inside defineSandbox().`);return await a.open({configurationHash:hashConstructorOptions({environment:e.configuration,sandbox:r}),environment:t,environmentConfigurationHash:t[CONFIGURATION_HASH],options:r,provider:e.runtime})}},t}function hashConstructorOptions(e){return createHash(`sha256`).update(stableSerialize(e)).digest(`hex`)}function stableSerialize(e,t=new WeakSet){if(e===null||typeof e==`boolean`||typeof e==`number`||typeof e==`string`)return JSON.stringify(e);if(typeof e==`function`)return`function:${e.toString()}`;if(Array.isArray(e))return`[${e.map(e=>stableSerialize(e,t)).join(`,`)}]`;if(typeof e==`object`){if(t.has(e))return`[circular]`;t.add(e);let n=e.constructor?.name??`Object`,r=`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>`${JSON.stringify(e)}:${stableSerialize(n,t)}`).join(`,`)}}`;return t.delete(e),`${n}:${r}`}return typeof e}function getSandboxEnvironmentRuntime(e){return e[PROVIDER_RUNTIME]}function bindSandboxEnvironment(e,t){return Object.defineProperty(e,SELECTOR_ENVIRONMENT,{value:t}),e}function getBoundSandboxEnvironment(e){let t=typeof e==`function`?Reflect.get(e,SELECTOR_ENVIRONMENT):void 0;return isSandboxEnvironment(t)?t:void 0}function isSandboxEnvironment(e){return typeof e==`object`&&!!e&&Reflect.get(e,ENVIRONMENT)===!0&&typeof Reflect.get(e,`provider`)==`string`&&typeof Reflect.get(e,`open`)==`function`}async function runWithSandboxConstructorRuntime(e,t){let n=contextStorage.getStore(),r=n??new ContextContainer,i=runtimes.get(r);runtimes.set(r,e);try{return n===void 0?await contextStorage.run(r,t):await t()}finally{i===void 0?runtimes.delete(r):runtimes.set(r,i)}}export{bindSandboxEnvironment,createSandboxEnvironment,getBoundSandboxEnvironment,getSandboxEnvironmentRuntime,isSandboxEnvironment,runWithSandboxConstructorRuntime};
1
+ import{ContextContainer,contextStorage}from"#context/container.js";const ENVIRONMENT=Symbol.for(`eve.sandbox-environment`),PROVIDER_RUNTIME=Symbol.for(`eve.sandbox-provider-runtime`),SELECTOR_ENVIRONMENT=Symbol.for(`eve.sandbox-selector-environment`),RUNTIMES=Symbol.for(`eve.sandbox-constructor-runtimes`),globals=globalThis,runtimes=globals[RUNTIMES]??=new WeakMap;function createSandboxEnvironment(e){let t={[ENVIRONMENT]:!0,[PROVIDER_RUNTIME]:e,provider:e.providerName,async open(...n){let r=n[0],i=contextStorage.getStore(),a=i===void 0?void 0:runtimes.get(i);if(a===void 0)throw Error("Sandbox environments can only open sandboxes inside defineSandbox(). Use `ctx.getSandbox()` to reach the session's sandbox from tools and other runtime code.");return await a.open({environment:t,options:r,provider:e})}};return t}function getSandboxEnvironmentRuntime(e){return e[PROVIDER_RUNTIME]}function bindSandboxEnvironment(e,t){return Object.defineProperty(e,SELECTOR_ENVIRONMENT,{value:t}),e}function getBoundSandboxEnvironment(e){let t=typeof e==`function`?Reflect.get(e,SELECTOR_ENVIRONMENT):void 0;return isSandboxEnvironment(t)?t:void 0}function isSandboxEnvironment(e){return typeof e==`object`&&!!e&&Reflect.get(e,ENVIRONMENT)===!0&&typeof Reflect.get(e,`provider`)==`string`&&typeof Reflect.get(e,`open`)==`function`}async function runWithSandboxConstructorRuntime(e,t){let n=contextStorage.getStore(),r=n??new ContextContainer,i=runtimes.get(r);runtimes.set(r,e);try{return n===void 0?await contextStorage.run(r,t):await t()}finally{i===void 0?runtimes.delete(r):runtimes.set(r,i)}}export{bindSandboxEnvironment,createSandboxEnvironment,getBoundSandboxEnvironment,getSandboxEnvironmentRuntime,isSandboxEnvironment,runWithSandboxConstructorRuntime};