eve 0.82.0 → 0.83.1

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 (528) hide show
  1. package/CHANGELOG.md +81 -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-DTu78IAF.js → use-eve-agent-DnbG9c7c.js} +73 -14
  9. package/dist/src/chunks/{use-eve-agent-DlznYwQk.js → use-eve-agent-ZY7NQ2VW.js} +73 -14
  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/cli/run.js +1 -1
  16. package/dist/src/client/eve-agent-store.d.ts +1 -1
  17. package/dist/src/client/eve-agent-store.js +1 -1
  18. package/dist/src/client/index.d.ts +1 -0
  19. package/dist/src/client/message-response.d.ts +18 -0
  20. package/dist/src/client/message-response.js +1 -1
  21. package/dist/src/client/session-controls.d.ts +6 -0
  22. package/dist/src/client/session-controls.js +1 -1
  23. package/dist/src/client/session.d.ts +4 -0
  24. package/dist/src/client/session.js +1 -1
  25. package/dist/src/compiled/.vendor-stamp.json +8 -8
  26. package/dist/src/compiled/@eve/catalog/index.js +1 -1
  27. package/dist/src/compiled/@workflow/core/events-consumer.d.ts +2 -0
  28. package/dist/src/compiled/@workflow/core/index.js +2 -2
  29. package/dist/src/compiled/@workflow/core/private.d.ts +5 -3
  30. package/dist/src/compiled/@workflow/core/private.js +1 -1
  31. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +1 -37
  32. package/dist/src/compiled/@workflow/core/runtime/event-limit-warning.d.ts +32 -0
  33. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +5 -6
  34. package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
  35. package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +8 -0
  36. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +16 -0
  37. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +15 -18
  38. package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +20 -0
  39. package/dist/src/compiled/@workflow/core/runtime.js +4 -4
  40. package/dist/src/compiled/@workflow/core/seeded-nanoid.d.ts +2 -0
  41. package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +14 -3
  42. package/dist/src/compiled/@workflow/core/serialization.d.ts +1 -1
  43. package/dist/src/compiled/@workflow/core/serialization.js +1 -1
  44. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +0 -18
  45. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  46. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  47. package/dist/src/compiled/@workflow/errors/index.d.ts +48 -0
  48. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  49. package/dist/src/compiled/@workflow/world/env-config.d.ts +24 -0
  50. package/dist/src/compiled/@workflow/world/events.d.ts +126 -7
  51. package/dist/src/compiled/@workflow/world/index.d.ts +3 -3
  52. package/dist/src/compiled/@workflow/world/interfaces.d.ts +59 -8
  53. package/dist/src/compiled/@workflow/world/queue.d.ts +71 -9
  54. package/dist/src/compiled/@workflow/world/recovery.d.ts +6 -0
  55. package/dist/src/compiled/@workflow/world/test-support/duplicate-event-fixtures.d.ts +3 -0
  56. package/dist/src/compiled/@workflow/world/test-support/in-band-fence-conformance.d.ts +46 -0
  57. package/dist/src/compiled/@workflow/world-local/index.js +5 -5
  58. package/dist/src/compiled/@workflow/world-vercel/index.js +18 -18
  59. package/dist/src/compiled/_chunks/workflow/{attribute-changes-BW-kbMMn.js → attribute-changes-7se_SE2q.js} +3 -3
  60. package/dist/src/compiled/_chunks/workflow/dist-CcnNPAp4.js +1 -0
  61. package/dist/src/compiled/_chunks/workflow/dist-S9cZRway.js +3 -0
  62. package/dist/src/compiled/_chunks/workflow/helpers-CxNRXH0a.js +1 -0
  63. package/dist/src/compiled/_chunks/workflow/private-DLYTSBbu.js +1 -0
  64. package/dist/src/compiled/_chunks/workflow/resume-hook-CPiIfe8r.js +1 -0
  65. package/dist/src/compiled/_chunks/workflow/{run-DzdAqdb1.js → run-BJSLCXR4.js} +6 -6
  66. package/dist/src/compiled/_chunks/workflow/serialization-B9gneT9Z.js +15 -0
  67. package/dist/src/compiled/_chunks/workflow/sleep-BL0oQs3R.js +1 -0
  68. package/dist/src/compiled/_chunks/workflow/{wait-until-xbRRDuUf.js → wait-until-BPou0RGO.js} +1 -1
  69. package/dist/src/compiled/_chunks/workflow/workflow-routes-BaljomCk.js +1 -0
  70. package/dist/src/compiled/{@ai-sdk/code-mode → run}/LICENSE +1 -1
  71. package/dist/src/compiled/run/index.d.ts +384 -0
  72. package/dist/src/compiled/run/index.js +650 -0
  73. package/dist/src/compiler/extension-compatibility.d.ts +21 -14
  74. package/dist/src/compiler/extension-compatibility.js +1 -1
  75. package/dist/src/compiler/manifest.js +1 -1
  76. package/dist/src/compiler/normalize-agent-config.js +1 -1
  77. package/dist/src/compiler/normalize-manifest.js +1 -1
  78. package/dist/src/compiler/normalize-sandbox.js +1 -1
  79. package/dist/src/compiler/workspace-resources.js +1 -1
  80. package/dist/src/context/build-callback-context.js +1 -1
  81. package/dist/src/context/build-dynamic-tools.js +1 -1
  82. package/dist/src/context/dynamic-skill-lifecycle.d.ts +2 -2
  83. package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
  84. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  85. package/dist/src/context/prewarm.d.ts +27 -0
  86. package/dist/src/context/prewarm.js +1 -0
  87. package/dist/src/context/providers/sandbox.d.ts +7 -0
  88. package/dist/src/context/providers/sandbox.js +1 -1
  89. package/dist/src/context/run-step.js +1 -1
  90. package/dist/src/discover/extension-specifier.d.ts +1 -0
  91. package/dist/src/discover/extension-specifier.js +1 -1
  92. package/dist/src/discover/lib.d.ts +4 -3
  93. package/dist/src/discover/lib.js +1 -1
  94. package/dist/src/discover/named-source-directory.d.ts +3 -2
  95. package/dist/src/evals/cli/eval.d.ts +2 -0
  96. package/dist/src/evals/cli/eval.js +2 -2
  97. package/dist/src/evals/define-eval-config.d.ts +5 -4
  98. package/dist/src/evals/define-eval-config.js +1 -1
  99. package/dist/src/evals/index.d.ts +1 -1
  100. package/dist/src/evals/runner/artifacts.js +2 -2
  101. package/dist/src/evals/runner/attempt-label.d.ts +2 -0
  102. package/dist/src/evals/runner/attempt-label.js +1 -0
  103. package/dist/src/evals/runner/derive-run-facts.d.ts +12 -0
  104. package/dist/src/evals/runner/derive-run-facts.js +1 -1
  105. package/dist/src/evals/runner/execute-task.js +1 -1
  106. package/dist/src/evals/runner/reporters/braintrust.js +1 -1
  107. package/dist/src/evals/runner/reporters/console.js +1 -1
  108. package/dist/src/evals/runner/reporters/datadog.js +1 -1
  109. package/dist/src/evals/runner/reporters/junit.js +2 -2
  110. package/dist/src/evals/runner/reporters/types.d.ts +2 -0
  111. package/dist/src/evals/runner/run-evals.d.ts +5 -0
  112. package/dist/src/evals/runner/run-evals.js +1 -1
  113. package/dist/src/evals/session-manager.js +1 -1
  114. package/dist/src/evals/session.d.ts +4 -1
  115. package/dist/src/evals/session.js +2 -2
  116. package/dist/src/evals/types.d.ts +39 -2
  117. package/dist/src/eve-channel/index.js +1 -1
  118. package/dist/src/eve-channel/request.d.ts +0 -1
  119. package/dist/src/eve-channel/request.js +2 -2
  120. package/dist/src/execution/agent-sessions/context.d.ts +1 -1
  121. package/dist/src/execution/agent-sessions/context.js +1 -1
  122. package/dist/src/execution/coordination-dispatch-shared.d.ts +3 -0
  123. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  124. package/dist/src/execution/dynamic-workflow/program-step.d.ts +7 -7
  125. package/dist/src/execution/dynamic-workflow/program-step.js +1 -1
  126. package/dist/src/execution/dynamic-workflow/schema.d.ts +18 -11
  127. package/dist/src/execution/dynamic-workflow/schema.js +1 -1
  128. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  129. package/dist/src/execution/dynamic-workflow/workflow.js +1 -1
  130. package/dist/src/execution/eve-workflow-attributes.d.ts +3 -1
  131. package/dist/src/execution/eve-workflow-attributes.js +1 -1
  132. package/dist/src/execution/invoke-tool.js +1 -1
  133. package/dist/src/execution/sandbox/abort-bound-session.js +1 -1
  134. package/dist/src/execution/sandbox/active-connections.d.ts +28 -0
  135. package/dist/src/execution/sandbox/active-connections.js +1 -0
  136. package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +10 -2
  137. package/dist/src/execution/sandbox/bindings/docker-cli.js +2 -2
  138. package/dist/src/execution/sandbox/bindings/docker-connection.d.ts +15 -0
  139. package/dist/src/execution/sandbox/bindings/docker-connection.js +2 -0
  140. package/dist/src/execution/sandbox/bindings/docker-container.d.ts +2 -0
  141. package/dist/src/execution/sandbox/bindings/docker-container.js +1 -1
  142. package/dist/src/execution/sandbox/bindings/docker-network.d.ts +5 -0
  143. package/dist/src/execution/sandbox/bindings/docker-network.js +1 -1
  144. package/dist/src/execution/sandbox/bindings/docker-templates.js +1 -1
  145. package/dist/src/execution/sandbox/bindings/docker.d.ts +12 -15
  146. package/dist/src/execution/sandbox/bindings/docker.js +1 -1
  147. package/dist/src/execution/sandbox/bindings/just-bash-runtime.d.ts +19 -29
  148. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  149. package/dist/src/execution/sandbox/bindings/just-bash.d.ts +2 -4
  150. package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
  151. package/dist/src/execution/sandbox/bindings/local-provider-utils.d.ts +0 -20
  152. package/dist/src/execution/sandbox/bindings/local-provider-utils.js +1 -1
  153. package/dist/src/execution/sandbox/bindings/local.d.ts +4 -6
  154. package/dist/src/execution/sandbox/bindings/local.js +1 -1
  155. package/dist/src/execution/sandbox/bindings/vercel-base-runtime.d.ts +2 -0
  156. package/dist/src/execution/sandbox/bindings/vercel-base-runtime.js +2 -2
  157. package/dist/src/execution/sandbox/bindings/vercel-errors.js +2 -2
  158. package/dist/src/execution/sandbox/bindings/vercel-lifecycle.d.ts +7 -5
  159. package/dist/src/execution/sandbox/bindings/vercel-lifecycle.js +1 -1
  160. package/dist/src/execution/sandbox/bindings/vercel.d.ts +5 -11
  161. package/dist/src/execution/sandbox/bindings/vercel.js +1 -2
  162. package/dist/src/execution/sandbox/development-cleanup.d.ts +0 -1
  163. package/dist/src/execution/sandbox/development-cleanup.js +1 -1
  164. package/dist/src/execution/sandbox/development-lazy-prewarm.js +1 -1
  165. package/dist/src/execution/sandbox/development-run.d.ts +0 -2
  166. package/dist/src/execution/sandbox/development-run.js +1 -1
  167. package/dist/src/execution/sandbox/dockerfile.d.ts +0 -4
  168. package/dist/src/execution/sandbox/dockerfile.js +1 -1
  169. package/dist/src/execution/sandbox/ensure.d.ts +31 -11
  170. package/dist/src/execution/sandbox/ensure.js +1 -1
  171. package/dist/src/execution/sandbox/glob-tool.js +3 -3
  172. package/dist/src/execution/sandbox/grep-tool.js +1 -1
  173. package/dist/src/execution/sandbox/logging-session.js +1 -1
  174. package/dist/src/execution/sandbox/prewarm.d.ts +23 -3
  175. package/dist/src/execution/sandbox/prewarm.js +2 -1
  176. package/dist/src/execution/sandbox/read-file.js +1 -1
  177. package/dist/src/execution/sandbox/require-sandbox.d.ts +3 -2
  178. package/dist/src/execution/sandbox/require-sandbox.js +1 -1
  179. package/dist/src/execution/sandbox/ripgrep-probe.js +1 -1
  180. package/dist/src/execution/sandbox/session.d.ts +10 -20
  181. package/dist/src/execution/sandbox/session.js +2 -2
  182. package/dist/src/execution/session/admission.js +1 -1
  183. package/dist/src/execution/session/checkpoint-migrations.js +1 -1
  184. package/dist/src/execution/session/entry-input.d.ts +5 -4
  185. package/dist/src/execution/session/entry.js +1 -1
  186. package/dist/src/execution/session/handoff-state.d.ts +5 -0
  187. package/dist/src/execution/session/handoff-state.js +1 -0
  188. package/dist/src/execution/session/handoff-steps.d.ts +1 -5
  189. package/dist/src/execution/session/handoff-steps.js +1 -1
  190. package/dist/src/execution/session/handoff.d.ts +2 -1
  191. package/dist/src/execution/session/handoff.js +1 -1
  192. package/dist/src/execution/session/handover-tracing.d.ts +3 -0
  193. package/dist/src/execution/session/handover-tracing.js +1 -0
  194. package/dist/src/execution/session/input-queue.d.ts +3 -0
  195. package/dist/src/execution/session/input-queue.js +1 -1
  196. package/dist/src/execution/session/next-input.d.ts +3 -0
  197. package/dist/src/execution/session/next-input.js +1 -1
  198. package/dist/src/execution/session/prewarm-step.d.ts +13 -0
  199. package/dist/src/execution/session/prewarm-step.js +1 -0
  200. package/dist/src/execution/session/program.d.ts +4 -1
  201. package/dist/src/execution/session/program.js +1 -1
  202. package/dist/src/execution/session/state-cursor.d.ts +11 -0
  203. package/dist/src/execution/session/state-cursor.js +1 -1
  204. package/dist/src/execution/session/timeout-control.d.ts +4 -0
  205. package/dist/src/execution/session/timeout-control.js +1 -1
  206. package/dist/src/execution/session/turn-control.d.ts +5 -2
  207. package/dist/src/execution/session/turn-control.js +1 -1
  208. package/dist/src/execution/session/turn-step-types.d.ts +2 -0
  209. package/dist/src/execution/session/turn-step.js +1 -1
  210. package/dist/src/execution/session/turn.d.ts +1 -0
  211. package/dist/src/execution/session/turn.js +1 -1
  212. package/dist/src/execution/session-inbox/inbox.d.ts +17 -1
  213. package/dist/src/execution/session-inbox/inbox.js +1 -1
  214. package/dist/src/execution/session-inbox/protocol.d.ts +2 -1
  215. package/dist/src/execution/session-inbox/protocol.js +1 -1
  216. package/dist/src/execution/session-inbox/resume.d.ts +2 -1
  217. package/dist/src/execution/session-inbox/resume.js +1 -1
  218. package/dist/src/execution/session-prewarm.d.ts +8 -0
  219. package/dist/src/execution/session-prewarm.js +1 -0
  220. package/dist/src/execution/skills/instructions.js +1 -1
  221. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  222. package/dist/src/execution/tools/workflow/body.js +1 -1
  223. package/dist/src/execution/tools/workflow/step-context.d.ts +11 -0
  224. package/dist/src/execution/tools/workflow/step-execution.js +1 -1
  225. package/dist/src/execution/tools/workflow/step.js +1 -1
  226. package/dist/src/execution/workflow-runtime.js +1 -1
  227. package/dist/src/extensions/git/extension/lib/github-shell-schema.js +1 -1
  228. package/dist/src/framework/sources/modules/sandbox.d.ts +1 -1
  229. package/dist/src/harness/attachment-staging.d.ts +3 -7
  230. package/dist/src/harness/attachment-staging.js +1 -1
  231. package/dist/src/harness/hitl/index.d.ts +2 -1
  232. package/dist/src/harness/hitl/index.js +1 -1
  233. package/dist/src/harness/hitl/view.d.ts +1 -0
  234. package/dist/src/harness/hitl/view.js +1 -0
  235. package/dist/src/harness/model-call/run.js +1 -1
  236. package/dist/src/harness/semantic-errors/rules/sandbox.d.ts +3 -5
  237. package/dist/src/harness/semantic-errors/rules/sandbox.js +1 -1
  238. package/dist/src/harness/step/prompt.js +1 -1
  239. package/dist/src/harness/tool-history-repair.d.ts +9 -0
  240. package/dist/src/harness/tool-history-repair.js +1 -0
  241. package/dist/src/harness/tool-model-output.d.ts +19 -3
  242. package/dist/src/harness/tool-model-output.js +1 -1
  243. package/dist/src/internal/application/compiled-artifacts.js +8 -4
  244. package/dist/src/internal/application/optional-package-import.d.ts +10 -0
  245. package/dist/src/internal/application/optional-package-import.js +1 -1
  246. package/dist/src/internal/application/stamped-package-version.js +1 -1
  247. package/dist/src/internal/attachments/limited-read.d.ts +2 -2
  248. package/dist/src/internal/authored-module-build-options.d.ts +6 -0
  249. package/dist/src/internal/authored-module-build-options.js +1 -1
  250. package/dist/src/internal/authored-module-cache.d.ts +10 -0
  251. package/dist/src/internal/authored-module-cache.js +1 -0
  252. package/dist/src/internal/authored-module-graph.js +1 -1
  253. package/dist/src/internal/authored-module-loader.js +1 -1
  254. package/dist/src/internal/authored-relative-extension-resolver.js +1 -1
  255. package/dist/src/internal/bundler/nitro-rolldown.d.ts +3 -1
  256. package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
  257. package/dist/src/internal/bundler/pseudo-packages.d.ts +11 -0
  258. package/dist/src/internal/bundler/pseudo-packages.js +1 -0
  259. package/dist/src/internal/nitro/host/build-extension.d.ts +6 -0
  260. package/dist/src/internal/nitro/host/build-extension.js +2 -2
  261. package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.d.ts +3 -1
  262. package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.js +3 -5
  263. package/dist/src/internal/nitro/host/create-application-nitro.d.ts +2 -3
  264. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  265. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.d.ts +2 -0
  266. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
  267. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  268. package/dist/src/internal/nitro/host/dev-build-host.d.ts +83 -0
  269. package/dist/src/internal/nitro/host/dev-build-host.js +1 -0
  270. package/dist/src/internal/nitro/host/dev-build-operations.d.ts +6 -0
  271. package/dist/src/internal/nitro/host/dev-build-operations.js +1 -0
  272. package/dist/src/internal/nitro/host/dev-build-process.d.ts +1 -0
  273. package/dist/src/internal/nitro/host/dev-build-process.js +1 -0
  274. package/dist/src/internal/nitro/host/development-runtime-prune-plugin.d.ts +4 -1
  275. package/dist/src/internal/nitro/host/development-runtime-prune-plugin.js +3 -2
  276. package/dist/src/internal/nitro/host/drained-nitro-dev-server.d.ts +13 -0
  277. package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -1
  278. package/dist/src/internal/nitro/host/optional-engine-dependency-plugin.js +1 -1
  279. package/dist/src/internal/nitro/host/prepare-application-host.d.ts +3 -0
  280. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  281. package/dist/src/internal/nitro/host/sandbox-shutdown-plugin.js +1 -1
  282. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  283. package/dist/src/internal/nitro/host/start-production-server.js +3 -3
  284. package/dist/src/internal/nitro/host/workflow-sandbox-runtime-plugin.js +1 -1
  285. package/dist/src/internal/nitro/host.js +1 -1
  286. package/dist/src/internal/workflow/local-world-delivery-auth.d.ts +17 -0
  287. package/dist/src/internal/workflow/local-world-delivery-auth.js +1 -0
  288. package/dist/src/internal/workflow/queue-namespace.d.ts +2 -0
  289. package/dist/src/internal/workflow/queue-namespace.js +1 -1
  290. package/dist/src/internal/workflow-bundle/builder-support.d.ts +0 -1
  291. package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
  292. package/dist/src/internal/workflow-bundle/builder.js +2 -2
  293. package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +1 -1
  294. package/dist/src/internal/workflow-bundle/vercel-workflow-output.d.ts +1 -1
  295. package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
  296. package/dist/src/protocol/prewarm-session.d.ts +14 -0
  297. package/dist/src/protocol/prewarm-session.js +1 -0
  298. package/dist/src/protocol/routes.d.ts +2 -2
  299. package/dist/src/public/channels/discord/authorization.d.ts +45 -0
  300. package/dist/src/public/channels/discord/authorization.js +3 -0
  301. package/dist/src/public/channels/discord/defaults.d.ts +14 -3
  302. package/dist/src/public/channels/discord/defaults.js +2 -2
  303. package/dist/src/public/channels/discord/discordChannel.d.ts +15 -1
  304. package/dist/src/public/channels/discord/discordChannel.js +1 -1
  305. package/dist/src/public/channels/discord/gateway/connection.d.ts +26 -0
  306. package/dist/src/public/channels/discord/gateway/connection.js +1 -0
  307. package/dist/src/public/channels/discord/gateway/forwarder.d.ts +14 -0
  308. package/dist/src/public/channels/discord/gateway/forwarder.js +1 -0
  309. package/dist/src/public/channels/discord/gateway/index.d.ts +59 -0
  310. package/dist/src/public/channels/discord/gateway/index.js +1 -0
  311. package/dist/src/public/channels/discord/inbound.d.ts +10 -3
  312. package/dist/src/public/channels/discord/inbound.js +2 -2
  313. package/dist/src/public/channels/discord/index.d.ts +3 -2
  314. package/dist/src/public/channels/discord/index.js +1 -1
  315. package/dist/src/public/channels/discord/messages.d.ts +116 -0
  316. package/dist/src/public/channels/discord/messages.js +2 -0
  317. package/dist/src/public/channels/github/checkout.js +1 -1
  318. package/dist/src/public/channels/linq/linqChannel.d.ts +4 -1
  319. package/dist/src/public/channels/linq/linqChannel.js +1 -1
  320. package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
  321. package/dist/src/public/channels/same-environment-oidc.d.ts +7 -0
  322. package/dist/src/public/channels/same-environment-oidc.js +1 -0
  323. package/dist/src/public/definitions/channel.js +1 -1
  324. package/dist/src/public/definitions/sandbox.d.ts +1 -1
  325. package/dist/src/public/next/server.js +1 -1
  326. package/dist/src/public/sandbox/docker-sandbox.d.ts +6 -1
  327. package/dist/src/public/sandbox/docker.d.ts +1 -8
  328. package/dist/src/public/sandbox/index.d.ts +3 -3
  329. package/dist/src/public/sandbox/just-bash-sandbox.d.ts +87 -7
  330. package/dist/src/public/sandbox/just-bash.d.ts +1 -1
  331. package/dist/src/public/sandbox/provider.d.ts +5 -1
  332. package/dist/src/public/sandbox/provider.js +1 -1
  333. package/dist/src/public/sandbox/vercel-sandbox.d.ts +16 -9
  334. package/dist/src/public/sandbox/vercel.d.ts +0 -1
  335. package/dist/src/public/sandbox/vercel.js +1 -1
  336. package/dist/src/public/tools/agent.d.ts +8 -1
  337. package/dist/src/public/tools/agent.js +1 -1
  338. package/dist/src/react/use-eve-agent.d.ts +1 -1
  339. package/dist/src/runtime/agent/resolve-model.js +1 -1
  340. package/dist/src/runtime/connections/openapi-client.d.ts +2 -0
  341. package/dist/src/runtime/connections/openapi-client.js +1 -1
  342. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  343. package/dist/src/runtime/resolve-agent.js +1 -1
  344. package/dist/src/runtime/resolve-channel.js +1 -1
  345. package/dist/src/runtime/resolve-sandbox.js +1 -1
  346. package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -1
  347. package/dist/src/runtime/sandbox/registry.d.ts +2 -0
  348. package/dist/src/runtime/sandbox/registry.js +1 -1
  349. package/dist/src/runtime/subagents/workflow.d.ts +6 -0
  350. package/dist/src/runtime/subagents/workflow.js +1 -1
  351. package/dist/src/runtime/workspace/seed-files.d.ts +9 -12
  352. package/dist/src/runtime/workspace/seed-files.js +1 -1
  353. package/dist/src/runtime/workspace/spec.d.ts +1 -1
  354. package/dist/src/runtime/workspace/spec.js +1 -1
  355. package/dist/src/runtime/workspace/types.d.ts +2 -6
  356. package/dist/src/sandbox/provider.d.ts +185 -0
  357. package/dist/src/sandbox/provider.js +1 -0
  358. package/dist/src/sandbox/providers/default.d.ts +20 -19
  359. package/dist/src/sandbox/providers/default.js +1 -1
  360. package/dist/src/sandbox/providers/docker.d.ts +5 -2
  361. package/dist/src/sandbox/providers/docker.js +1 -1
  362. package/dist/src/sandbox/providers/just-bash.d.ts +4 -3
  363. package/dist/src/sandbox/providers/just-bash.js +1 -1
  364. package/dist/src/sandbox/providers/vercel.d.ts +4 -10
  365. package/dist/src/sandbox/providers/vercel.js +1 -1
  366. package/dist/src/sandbox/providers.d.ts +0 -1
  367. package/dist/src/sandbox/providers.js +1 -1
  368. package/dist/src/sandbox/state.d.ts +61 -0
  369. package/dist/src/sandbox/state.js +1 -1
  370. package/dist/src/self-modification/deployed-sandbox.d.ts +4 -9
  371. package/dist/src/self-modification/deployed-sandbox.js +1 -1
  372. package/dist/src/self-modification/filesystem.d.ts +3 -3
  373. package/dist/src/self-modification/remote/config.d.ts +2 -2
  374. package/dist/src/self-modification/remote/config.js +1 -1
  375. package/dist/src/self-modification/setup.d.ts +0 -1
  376. package/dist/src/self-modification/setup.js +8 -8
  377. package/dist/src/setup/integrations/discord/api.d.ts +7 -0
  378. package/dist/src/setup/integrations/discord/api.js +1 -1
  379. package/dist/src/setup/integrations/discord/daemon.d.ts +18 -0
  380. package/dist/src/setup/integrations/discord/daemon.js +21 -0
  381. package/dist/src/setup/integrations/discord/setup.d.ts +24 -4
  382. package/dist/src/setup/integrations/discord/setup.js +5 -4
  383. package/dist/src/setup/integrations/self-modification/setup.js +1 -1
  384. package/dist/src/setup/scaffold/create/project.js +1 -1
  385. package/dist/src/setup/scaffold/update/web-options.js +1 -1
  386. package/dist/src/setup/scaffold/version-tokens.d.ts +0 -1
  387. package/dist/src/setup/scaffold/version-tokens.js +1 -1
  388. package/dist/src/shared/agent-definition.d.ts +2 -0
  389. package/dist/src/shared/built-server-start-failure.d.ts +12 -0
  390. package/dist/src/shared/built-server-start-failure.js +3 -0
  391. package/dist/src/shared/framework-eve-server.d.ts +2 -0
  392. package/dist/src/shared/framework-eve-server.js +2 -2
  393. package/dist/src/shared/sandbox-environment.d.ts +4 -10
  394. package/dist/src/shared/sandbox-environment.js +1 -1
  395. package/dist/src/shared/sandbox-network-policy.d.ts +45 -9
  396. package/dist/src/shared/sandbox-provider.d.ts +0 -103
  397. package/dist/src/shared/sandbox-provider.js +1 -1
  398. package/dist/src/shared/sandbox-recorded-data-error.d.ts +4 -0
  399. package/dist/src/shared/sandbox-recorded-data-error.js +1 -0
  400. package/dist/src/shared/sandbox-session-gone-error.d.ts +12 -0
  401. package/dist/src/shared/sandbox-session-gone-error.js +1 -0
  402. package/dist/src/shared/sandbox-session.d.ts +97 -83
  403. package/dist/src/shared/sandbox-template-error.d.ts +19 -4
  404. package/dist/src/shared/sandbox-template-error.js +1 -1
  405. package/dist/src/shared/sandbox-tool-session-error.d.ts +4 -0
  406. package/dist/src/shared/sandbox-tool-session-error.js +1 -0
  407. package/dist/src/shared/skill-package.js +1 -1
  408. package/dist/src/shared/skill-paths.d.ts +4 -5
  409. package/dist/src/shared/skill-paths.js +2 -2
  410. package/dist/src/shared/workflow-sandbox.d.ts +4 -41
  411. package/dist/src/shared/workflow-sandbox.js +1 -1
  412. package/dist/src/svelte/index.js +1 -1
  413. package/dist/src/svelte/use-eve-agent.d.ts +1 -1
  414. package/dist/src/svelte/use-eve-agent.js +1 -1
  415. package/dist/src/tools/definition.js +1 -1
  416. package/dist/src/tools/durable-callbacks.d.ts +5 -1
  417. package/dist/src/tools/durable-callbacks.js +1 -1
  418. package/dist/src/tools/dynamic.d.ts +3 -3
  419. package/dist/src/tools/model-output.d.ts +23 -5
  420. package/dist/src/tools/model-output.js +1 -1
  421. package/dist/src/tools/provided/ask-question-workflow.js +1 -1
  422. package/dist/src/tools/provided/glob.js +1 -1
  423. package/dist/src/tools/provided/grep.js +1 -1
  424. package/dist/src/tools/provided/read-file.js +1 -1
  425. package/dist/src/tools/provided/sleep-workflow.js +1 -1
  426. package/dist/src/tools/provided/workflow.js +1 -1
  427. package/dist/src/tools/provided/write-file.js +1 -1
  428. package/dist/src/tools/workflow-definition.d.ts +19 -4
  429. package/dist/src/vue/index.js +1 -1
  430. package/dist/src/vue/use-eve-agent.d.ts +1 -1
  431. package/dist/src/vue/use-eve-agent.js +1 -1
  432. package/docs/channels/custom.mdx +3 -3
  433. package/docs/channels/discord.mdx +279 -7
  434. package/docs/channels/eve.mdx +13 -2
  435. package/docs/channels/linq.mdx +2 -2
  436. package/docs/channels/mcp.mdx +2 -2
  437. package/docs/channels/overview.mdx +1 -1
  438. package/docs/channels/photon.mdx +1 -1
  439. package/docs/concepts/built-in-tools.md +31 -8
  440. package/docs/concepts/execution-model-and-durability.mdx +6 -101
  441. package/docs/concepts/security-model.md +2 -0
  442. package/docs/concepts/sessions-runs-and-streaming.md +44 -36
  443. package/docs/connections/openapi.mdx +2 -0
  444. package/docs/evals/overview.mdx +1 -1
  445. package/docs/evals/reporters.mdx +5 -5
  446. package/docs/evals/running.mdx +19 -1
  447. package/docs/guides/client/messages.mdx +1 -1
  448. package/docs/guides/deployment/overview.md +4 -4
  449. package/docs/guides/deployment/self-hosting.md +50 -1
  450. package/docs/guides/dev-tui.md +1 -1
  451. package/docs/guides/dynamic-capabilities.md +2 -2
  452. package/docs/guides/frontend/overview.mdx +34 -10
  453. package/docs/guides/instrumentation/agent-runs.mdx +16 -0
  454. package/docs/guides/instrumentation/otel.mdx +23 -0
  455. package/docs/guides/self-modification.md +1 -1
  456. package/docs/guides/session-context.md +1 -1
  457. package/docs/instructions.mdx +1 -1
  458. package/docs/meta.json +1 -0
  459. package/docs/reference/agent-files.md +4 -4
  460. package/docs/reference/cli.md +24 -17
  461. package/docs/reference/typescript-api.md +9 -3
  462. package/docs/sandbox/custom-providers.mdx +254 -0
  463. package/docs/sandbox/default.mdx +71 -4
  464. package/docs/sandbox/docker.mdx +15 -3
  465. package/docs/sandbox/index.mdx +32 -106
  466. package/docs/sandbox/just-bash.mdx +54 -0
  467. package/docs/sandbox/meta.json +9 -1
  468. package/docs/sandbox/troubleshooting.mdx +215 -0
  469. package/docs/sandbox/vercel.mdx +48 -7
  470. package/docs/skills.mdx +1 -1
  471. package/docs/subagents/index.mdx +2 -2
  472. package/docs/tools/overview.mdx +20 -1
  473. package/docs/tools/workflows.mdx +73 -5
  474. package/docs/tutorial/run-analysis.mdx +2 -2
  475. package/docs/use-cases.mdx +250 -0
  476. package/package.json +14 -20
  477. package/dist/src/compiled/@ai-sdk/code-mode/_run.d.ts +0 -1
  478. package/dist/src/compiled/@ai-sdk/code-mode/index.d.ts +0 -325
  479. package/dist/src/compiled/@ai-sdk/code-mode/index.js +0 -660
  480. package/dist/src/compiled/_chunks/workflow/dist-CyBgVS7g.js +0 -1
  481. package/dist/src/compiled/_chunks/workflow/dist-T5NnW-0k.js +0 -3
  482. package/dist/src/compiled/_chunks/workflow/helpers-DlLD3ov_.js +0 -1
  483. package/dist/src/compiled/_chunks/workflow/private-tQUuwBoQ.js +0 -1
  484. package/dist/src/compiled/_chunks/workflow/resume-hook-DMsV_b4n.js +0 -1
  485. package/dist/src/compiled/_chunks/workflow/serialization-DPdYS_w2.js +0 -16
  486. package/dist/src/compiled/_chunks/workflow/sleep-BY6leHh8.js +0 -1
  487. package/dist/src/compiled/_chunks/workflow/workflow-routes-CwqB063q.js +0 -1
  488. package/dist/src/execution/sandbox/active-handles.d.ts +0 -32
  489. package/dist/src/execution/sandbox/active-handles.js +0 -1
  490. package/dist/src/execution/sandbox/bindings/docker-session.d.ts +0 -6
  491. package/dist/src/execution/sandbox/bindings/docker-session.js +0 -2
  492. package/dist/src/execution/sandbox/bindings/immutable-resources.d.ts +0 -15
  493. package/dist/src/execution/sandbox/bindings/immutable-resources.js +0 -2
  494. package/dist/src/execution/sandbox/bindings/microsandbox-create.d.ts +0 -12
  495. package/dist/src/execution/sandbox/bindings/microsandbox-create.js +0 -1
  496. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.d.ts +0 -42
  497. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +0 -1
  498. package/dist/src/execution/sandbox/bindings/microsandbox-metadata.d.ts +0 -29
  499. package/dist/src/execution/sandbox/bindings/microsandbox-metadata.js +0 -1
  500. package/dist/src/execution/sandbox/bindings/microsandbox-network.d.ts +0 -18
  501. package/dist/src/execution/sandbox/bindings/microsandbox-network.js +0 -1
  502. package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +0 -37
  503. package/dist/src/execution/sandbox/bindings/microsandbox-options.js +0 -1
  504. package/dist/src/execution/sandbox/bindings/microsandbox-platform.d.ts +0 -21
  505. package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +0 -21
  506. package/dist/src/execution/sandbox/bindings/microsandbox-process.d.ts +0 -3
  507. package/dist/src/execution/sandbox/bindings/microsandbox-process.js +0 -1
  508. package/dist/src/execution/sandbox/bindings/microsandbox-provider-state.d.ts +0 -11
  509. package/dist/src/execution/sandbox/bindings/microsandbox-provider-state.js +0 -1
  510. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.d.ts +0 -82
  511. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +0 -1
  512. package/dist/src/execution/sandbox/bindings/microsandbox-templates.d.ts +0 -12
  513. package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +0 -1
  514. package/dist/src/execution/sandbox/bindings/microsandbox.d.ts +0 -16
  515. package/dist/src/execution/sandbox/bindings/microsandbox.js +0 -1
  516. package/dist/src/execution/sandbox/provider-host-development.d.ts +0 -2
  517. package/dist/src/execution/sandbox/provider-host-development.js +0 -1
  518. package/dist/src/execution/sandbox/provider-host.d.ts +0 -2
  519. package/dist/src/execution/sandbox/provider-host.js +0 -1
  520. package/dist/src/execution/tool-session/sandbox.d.ts +0 -22
  521. package/dist/src/execution/tool-session/sandbox.js +0 -1
  522. package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +0 -48
  523. package/dist/src/public/sandbox/microsandbox-sandbox.js +0 -1
  524. package/dist/src/public/sandbox/microsandbox.d.ts +0 -9
  525. package/dist/src/public/sandbox/microsandbox.js +0 -1
  526. package/dist/src/sandbox/providers/microsandbox.d.ts +0 -12
  527. package/dist/src/sandbox/providers/microsandbox.js +0 -1
  528. package/docs/sandbox/microsandbox.mdx +0 -31
@@ -0,0 +1,185 @@
1
+ import { type SandboxEnvironment, type SandboxSelectorContext } from "#shared/sandbox-environment.js";
2
+ import type { SandboxPreparedArtifact, SandboxProviderFiles } from "#shared/sandbox-provider.js";
3
+ import type { SandboxProcess, SandboxRemovePathOptions, SandboxSession, SandboxWriteFilesOptions } from "#shared/sandbox-session.js";
4
+ /** A JSON-compatible value: what a provider may return as an artifact or session state. */
5
+ export type SandboxJson = SandboxPreparedArtifact;
6
+ /** Members eve owns on every live sandbox, which a connection's extensions cannot replace. */
7
+ type ReservedSessionMember = keyof SandboxSession | "delete" | "stop";
8
+ /**
9
+ * The byte-level connection to one sandbox that a provider implements. eve
10
+ * derives the full {@link SandboxSession} from it.
11
+ *
12
+ * Every path a connection receives is absolute, and `workingDirectory` is
13
+ * always set: eve resolves relative paths from {@link workspaceRoot}.
14
+ */
15
+ export interface SandboxConnection<Extensions extends object = {}> {
16
+ /**
17
+ * The absolute sandbox directory that relative paths resolve from and
18
+ * commands start in by default. Defaults to `/workspace`. The directory
19
+ * must exist when eve first runs a command.
20
+ */
21
+ readonly workspaceRoot?: string;
22
+ /**
23
+ * Runs `command` as a Bash login-shell script (`bash -lc`) in
24
+ * `workingDirectory`, with the sandbox's environment plus `env`. `env`
25
+ * holds only the per-call variables. Aborting kills the process tree.
26
+ */
27
+ spawn(options: {
28
+ readonly abortSignal?: AbortSignal;
29
+ readonly command: string;
30
+ readonly env: Readonly<Record<string, string>>;
31
+ readonly workingDirectory: string;
32
+ }): Promise<SandboxProcess>;
33
+ /**
34
+ * Resolves to `null` only when the path does not exist. A directory or an
35
+ * unreadable path rejects. Return bytes or a stream, whichever the backend has.
36
+ */
37
+ readFile(options: {
38
+ readonly abortSignal?: AbortSignal;
39
+ readonly path: string;
40
+ }): Promise<Uint8Array | ReadableStream<Uint8Array> | null>;
41
+ /** Creates missing parent directories and overwrites existing files. The only write primitive. */
42
+ writeFiles(options: SandboxWriteFilesOptions): Promise<void>;
43
+ /** `force` ignores a missing path; `recursive` removes a non-empty directory. */
44
+ removePath(options: SandboxRemovePathOptions): Promise<void>;
45
+ /** Releases compute and keeps the sandbox's files. */
46
+ stop(): Promise<void>;
47
+ /** Releases what this process holds, such as a local interpreter, without touching the sandbox. */
48
+ close?(): Promise<void>;
49
+ /**
50
+ * Provider capabilities merged onto the session, such as `setNetworkPolicy`.
51
+ * A plain object: eve merges its own enumerable properties, so use closures
52
+ * rather than class methods. A member named like a session method is a type
53
+ * error, and eve rejects it.
54
+ */
55
+ readonly extensions?: Extensions & {
56
+ readonly [Key in ReservedSessionMember]?: never;
57
+ };
58
+ }
59
+ /** What eve passes to `start()`, `resume()`, and `onSessionEnd()`. */
60
+ export interface SandboxSessionContext {
61
+ /**
62
+ * The session that owns the sandbox. Derive native names from `session.id`:
63
+ * for a subagent that shares its parent's sandbox it is the parent's id, and
64
+ * for a keyed `invokeTool` call it is the derived tool-session id.
65
+ */
66
+ readonly session: SandboxSelectorContext["session"];
67
+ /** `"tool-session"` for a keyed `invokeTool` call's sandbox, `"session"` otherwise. */
68
+ readonly kind: "session" | "tool-session";
69
+ /** A host directory the provider may use for local state. */
70
+ readonly storagePath: string;
71
+ /** Resolves a path relative to the app's project root on the host. */
72
+ resolveProjectPath(path: string): string;
73
+ }
74
+ /**
75
+ * Values hashed into a template key: JSON values, `undefined` (omitted),
76
+ * plain objects and arrays, and functions (hashed by their source). Other
77
+ * values and circular structures reject.
78
+ */
79
+ export type SandboxIdentity = {
80
+ readonly [key: string]: unknown;
81
+ };
82
+ /**
83
+ * What eve passes to `prepare()` while it builds a template. Not generic over
84
+ * the provider's extensions, so TypeScript infers them from `start()`.
85
+ */
86
+ export interface SandboxPrepareContext {
87
+ /** Authored files under the agent's `sandbox/` directory. */
88
+ readonly files: SandboxProviderFiles;
89
+ /** `true` when there are no workspace or skill files and no authored `prepare`. */
90
+ readonly isEmpty: boolean;
91
+ readonly storagePath: string;
92
+ /** Reports build progress, such as `eve build` output. */
93
+ log(message: string): void;
94
+ /**
95
+ * Seeds the connection's workspace root and `$HOME/.agents/skills`, then
96
+ * runs the authored `prepare` with a session over `connection`. With
97
+ * `mountedAt`, the provider has mounted {@link resourcesDirectory}
98
+ * read-only at that sandbox path, and eve copies from it instead of
99
+ * writing every file.
100
+ */
101
+ populate(connection: SandboxConnection<object>, options?: {
102
+ readonly mountedAt?: string;
103
+ }): Promise<void>;
104
+ resolveProjectPath(path: string): string;
105
+ /** A stable read-only host directory holding `workspace/` and `skills/`, when one exists. */
106
+ resourcesDirectory(): Promise<string | undefined>;
107
+ /**
108
+ * Hashes `identity` together with the workspace files, skill files, and
109
+ * sandbox source revision into a stable SHA-256 hex key. `resources` and
110
+ * `sourceRevision` are reserved.
111
+ */
112
+ templateKey(identity: SandboxIdentity): string;
113
+ }
114
+ export interface SandboxSessionEndOptions {
115
+ readonly abortSignal?: AbortSignal;
116
+ readonly reason: "completed" | "expired" | "failed" | "deleted";
117
+ }
118
+ /** The lifecycle one sandbox environment implements. */
119
+ export interface SandboxProviderImplementation<OpenOptions extends object | undefined, Artifact extends SandboxJson, State extends SandboxJson, Extensions extends object> {
120
+ /**
121
+ * Builds a template during `eve build`, or on first access in `eve dev`, and
122
+ * returns the JSON artifact that ships with the deployment. Call
123
+ * `ctx.populate()` on the build instance before capturing it.
124
+ */
125
+ prepare(ctx: SandboxPrepareContext): Promise<Artifact>;
126
+ /**
127
+ * Returns the sandbox for `ctx.session.id`, creating it when none exists.
128
+ * An idempotent upsert: repeated, concurrent, cross-process, and
129
+ * cross-deployment calls return the same sandbox while it exists. Derive
130
+ * native identity from `ctx.session.id` and a provider-level namespace
131
+ * only; `options` and `artifact` apply only when this call creates it.
132
+ */
133
+ start(ctx: SandboxSessionContext, options: Readonly<OpenOptions> | undefined, artifact: Readonly<Artifact>): Promise<{
134
+ readonly connection: SandboxConnection<Extensions>;
135
+ readonly state: State;
136
+ }>;
137
+ /**
138
+ * Reconnects to the sandbox `state` names, never recreating it. Throw
139
+ * `SandboxSessionGoneError` when it no longer exists.
140
+ */
141
+ resume(ctx: SandboxSessionContext, artifact: Readonly<Artifact>, state: Readonly<State>): Promise<SandboxConnection<Extensions>>;
142
+ /**
143
+ * Deletes whatever exists for `ctx.session.id`. `state` is `null` when the
144
+ * session never recorded it. Must succeed when nothing exists and be
145
+ * idempotent. `sandbox.delete()` also lands here, with `reason: "deleted"`.
146
+ */
147
+ onSessionEnd(ctx: SandboxSessionContext, state: Readonly<State> | null, options: SandboxSessionEndOptions): Promise<void>;
148
+ /**
149
+ * Lets a keyed `invokeTool` call keep its sandbox between calls. eve never
150
+ * ends a keyed sandbox, so the provider must bound its retention.
151
+ */
152
+ readonly toolSessions?: true;
153
+ }
154
+ export interface SandboxPrepareOption<Session> {
155
+ /** Runs once per template, after eve seeds workspace and skill files. */
156
+ readonly prepare?: (sandbox: Session) => void | Promise<void>;
157
+ }
158
+ /** Environment options plus the standard `prepare` option. */
159
+ export type WithPrepareOption<Options extends object, Session> = Options & SandboxPrepareOption<Session>;
160
+ export interface SandboxProviderDefinition<EnvironmentOptions extends object, OpenOptions extends object | undefined, Artifact extends SandboxJson, State extends SandboxJson, Extensions extends object> {
161
+ readonly name: string;
162
+ /** Bump when `State` changes incompatibly; recorded state from another version starts fresh. */
163
+ readonly stateProtocolVersion?: number;
164
+ /**
165
+ * Receives the environment options without `prepare`, which eve runs in
166
+ * `ctx.populate()`. Always an object: `{}` when the caller passes none.
167
+ */
168
+ environment(options: EnvironmentOptions): SandboxProviderImplementation<OpenOptions, Artifact, State, Extensions>;
169
+ }
170
+ type SandboxOptionArguments<Options extends object | undefined> = Options extends undefined ? [options?: undefined] : Record<never, never> extends Options ? [options?: Readonly<Options>] : [options: Readonly<Options>];
171
+ export interface SandboxProvider<EnvironmentOptions extends object | undefined, OpenOptions extends object | undefined, Session extends SandboxSession> {
172
+ readonly name: string;
173
+ environment(...args: SandboxOptionArguments<EnvironmentOptions>): SandboxEnvironment<OpenOptions, Session>;
174
+ }
175
+ /** What core runs for one environment: the provider's lifecycle with its types erased. */
176
+ export interface SandboxProviderRuntime {
177
+ readonly implementation: SandboxProviderImplementation<object | undefined, SandboxJson, SandboxJson, object>;
178
+ /** The authored `prepare` option, which eve runs in `ctx.populate()`. */
179
+ readonly prepare: ((sandbox: SandboxSession) => void | Promise<void>) | undefined;
180
+ readonly providerName: string;
181
+ readonly stateProtocolVersion: number;
182
+ }
183
+ /** Defines a sandbox provider from a connection and a lifecycle. */
184
+ export declare function defineSandboxProvider<EnvironmentOptions extends object = {}, OpenOptions extends object | undefined = undefined, Artifact extends SandboxJson = SandboxJson, State extends SandboxJson = SandboxJson, Extensions extends object = {}>(definition: SandboxProviderDefinition<EnvironmentOptions, OpenOptions, Artifact, State, Extensions>): SandboxProvider<WithPrepareOption<EnvironmentOptions, SandboxSession & Extensions>, OpenOptions, SandboxSession & Extensions>;
185
+ export {};
@@ -0,0 +1 @@
1
+ import{createSandboxEnvironment}from"#shared/sandbox-environment.js";function defineSandboxProvider(e){return{name:e.name,environment(t){let{prepare:n,...r}=t??{};return createSandboxEnvironment({implementation:e.environment(r),prepare:n,providerName:e.name,stateProtocolVersion:e.stateProtocolVersion??1})}}}export{defineSandboxProvider};
@@ -1,27 +1,28 @@
1
1
  import type { DockerSandboxEnvironmentOptions } from "#public/sandbox/docker-sandbox.js";
2
- import type { JustBashSandboxCreateOptions } from "#public/sandbox/just-bash-sandbox.js";
3
- import type { MicrosandboxSandboxCreateOptions } from "#public/sandbox/microsandbox-sandbox.js";
2
+ import type { SandboxSession } from "#public/sandbox/index.js";
3
+ import { type SandboxProvider } from "#public/sandbox/provider.js";
4
4
  import type { VercelSandboxCreateOptions } from "#public/sandbox/vercel-sandbox.js";
5
- import type { SandboxEnvironment } from "#shared/sandbox-environment.js";
6
- import type { SandboxSession } from "#shared/sandbox-session.js";
5
+ import { type JustBashEnvironmentOptions } from "#sandbox/providers/just-bash.js";
6
+ import type { SandboxNetworkOptions, SandboxNetworkPolicy } from "#shared/sandbox-network-policy.js";
7
7
  export interface DefaultSandboxEnvironmentOptions {
8
8
  readonly docker?: DockerSandboxEnvironmentOptions;
9
- readonly justBash?: JustBashSandboxCreateOptions;
10
- readonly microsandbox?: MicrosandboxSandboxCreateOptions;
9
+ readonly justBash?: JustBashEnvironmentOptions;
11
10
  readonly prepare?: (sandbox: SandboxSession) => Promise<void> | void;
12
11
  readonly vercel?: VercelSandboxCreateOptions;
13
12
  }
14
- export interface DefaultSandboxProbes {
15
- readonly isDeployedOnVercel: () => boolean;
16
- readonly isDockerAvailable: () => boolean;
17
- readonly isMicrosandboxSupported: () => boolean;
13
+ /** Options applied when eve creates one live sandbox from a `DefaultSandbox` environment. */
14
+ export type DefaultSandboxRuntimeOptions = SandboxNetworkOptions;
15
+ /** Live sandbox capabilities exposed by a `DefaultSandbox` environment. */
16
+ export interface DefaultSandboxSession extends SandboxSession {
17
+ /**
18
+ * Applies a network policy to the live sandbox. Docker accepts only
19
+ * `"allow-all"` and `"deny-all"`; just-bash accepts only `"allow-all"`.
20
+ */
21
+ setNetworkPolicy(policy: SandboxNetworkPolicy): Promise<void>;
18
22
  }
19
- export declare const SANDBOX_PROVIDER_PROBES: DefaultSandboxProbes;
20
- export declare const DefaultSandbox: {
21
- name: string;
22
- environment(options?: DefaultSandboxEnvironmentOptions): SandboxEnvironment<undefined>;
23
- };
24
- export declare function defineDefaultSandboxProvider(probes: DefaultSandboxProbes): {
25
- name: string;
26
- environment(options?: DefaultSandboxEnvironmentOptions): SandboxEnvironment<undefined>;
27
- };
23
+ /**
24
+ * Selects Vercel Sandbox on Vercel, Docker when a daemon is reachable, and
25
+ * just-bash in development. Preparation records the choice, so the runtime
26
+ * uses the provider the build selected and never probes the host.
27
+ */
28
+ export declare const DefaultSandbox: SandboxProvider<DefaultSandboxEnvironmentOptions, DefaultSandboxRuntimeOptions, DefaultSandboxSession>;
@@ -1 +1 @@
1
- import{isLinuxDockerDaemonAvailableSync,isMicrosandboxPlatformSupported}from"#execution/sandbox/bindings/local.js";import{DockerSandbox}from"#sandbox/providers/docker.js";import{JustBashSandbox}from"#sandbox/providers/just-bash.js";import{MicrosandboxSandbox}from"#sandbox/providers/microsandbox.js";import{createDefaultVercelEnvironment}from"#sandbox/providers/vercel.js";const SANDBOX_PROVIDER_PROBES={isDeployedOnVercel:()=>!!process.env.VERCEL,isDockerAvailable:()=>isLinuxDockerDaemonAvailableSync(),isMicrosandboxSupported:()=>isMicrosandboxPlatformSupported()},DefaultSandbox=defineDefaultSandboxProvider(SANDBOX_PROVIDER_PROBES);function defineDefaultSandboxProvider(e){return{name:`default`,environment(t={}){return e.isDeployedOnVercel()?withoutOpenOptions(createDefaultVercelEnvironment(withPreparation(t.vercel,t.prepare))):e.isDockerAvailable()?withoutOpenOptions(DockerSandbox.environment(withPreparation(t.docker,t.prepare))):e.isMicrosandboxSupported()?withoutOpenOptions(MicrosandboxSandbox.environment(withPreparation(t.microsandbox,t.prepare))):JustBashSandbox.environment(withPreparation(t.justBash,t.prepare))}}}function withPreparation(e,t){return Object.assign({},e,t===void 0?{}:{prepare:t})}function withoutOpenOptions(e){return e}export{DefaultSandbox,SANDBOX_PROVIDER_PROBES,defineDefaultSandboxProvider};
1
+ import{isObject}from"#shared/guards.js";import{isLinuxDockerDaemonAvailableSync}from"#execution/sandbox/bindings/local.js";import{getSandboxEnvironmentRuntime}from"#shared/sandbox-environment.js";import{isEveDevEnvironment}from"#internal/application/dev-environment.js";import{ToolSessionSandboxUnsupportedError}from"#shared/sandbox-tool-session-error.js";import{SandboxSessionGoneError,defineSandboxProvider}from"#public/sandbox/provider.js";import{withAdoptedSandboxSessionStates,withSessionEndArtifact}from"#sandbox/state.js";import{DockerSandbox}from"#sandbox/providers/docker.js";import{JustBashSandbox}from"#sandbox/providers/just-bash.js";import{VercelSandbox}from"#sandbox/providers/vercel.js";const SELECTED_PROVIDERS=[`docker`,`just-bash`,`vercel`],NO_PROVIDER_MESSAGE=`DefaultSandbox has no sandbox provider for this build: it did not run on Vercel, no Docker daemon was reachable, and production builds do not fall back to just-bash. Start Docker and rebuild, deploy to Vercel, or select a provider explicitly in your sandbox module, such as agent/sandbox/sandbox.ts.`,JUST_BASH_NETWORK_POLICY_MESSAGE=`DefaultSandbox selected just-bash, which always allows network access and accepts only the "allow-all" network policy. Start Docker so DefaultSandbox selects it, or select VercelSandbox or DockerSandbox explicitly.`,DefaultSandbox=defineSandboxProvider({name:`default`,environment(e){let t=new Map,provider=n=>{let r=t.get(n);return r===void 0&&(r=getSandboxEnvironmentRuntime(createEnvironment(n,e)),t.set(n,r)),r};function requireProvider(e,t){let n=provider(e);if(t===`tool-session`&&n.implementation.toolSessions!==!0)throw new ToolSessionSandboxUnsupportedError(e);return n}async function endSession(e,t,n,r){let i=t?.provider??n?.provider??null;if(i===null)return;let a=provider(i),o=t?.stateProtocolVersion===a.stateProtocolVersion?t.state:null;await a.implementation.onSessionEnd(e,o,r)}let n={onSessionEnd:(e,t,n)=>endSession(e,t,void 0,n),async prepare(e){let t=selectProvider();return t===null?(e.log(NO_PROVIDER_MESSAGE),{provider:null}):{artifact:await provider(t).implementation.prepare(e),provider:t}},async start(e,t,n){if(n.provider===null)throw Error(NO_PROVIDER_MESSAGE);let r=requireProvider(n.provider,e.kind),i=await r.implementation.start(e,innerOpenOptions(n.provider,t),n.artifact);return{connection:withNetworkPolicy(i.connection),state:{provider:n.provider,state:i.state,stateProtocolVersion:r.stateProtocolVersion}}},async resume(e,t,n){if(t.provider===null||t.provider!==n.provider)throw new SandboxSessionGoneError(`The session's ${n.provider} sandbox cannot resume because this build selected ${t.provider??`no provider`}.`);let r=requireProvider(n.provider,e.kind);if(n.stateProtocolVersion!==r.stateProtocolVersion)throw new SandboxSessionGoneError(`The session's ${n.provider} sandbox state uses protocol ${n.stateProtocolVersion}, not ${r.stateProtocolVersion}.`);return withNetworkPolicy(await r.implementation.resume(e,t.artifact,n.state))},toolSessions:!0};return withSessionEndArtifact(n,async(e,t,{artifact:n,reason:r})=>{await endSession(e,isDefaultSandboxSessionState(t)?t:null,isDefaultSandboxPreparedArtifact(n)?n:void 0,{reason:r})}),withAdoptedSandboxSessionStates(n,e=>{let t=e.providerName;if(isSelectedProvider(t))return{provider:t,state:e.state,stateProtocolVersion:e.stateProtocolVersion}})}});function selectProvider(){return process.env.VERCEL?.trim()?`vercel`:isLinuxDockerDaemonAvailableSync()?`docker`:isEveDevEnvironment()?`just-bash`:null}function createEnvironment(e,t){switch(e){case`docker`:return DockerSandbox.environment(t.docker??{});case`just-bash`:return JustBashSandbox.environment(t.justBash??{});case`vercel`:return VercelSandbox.environment(t.vercel??{})}}function innerOpenOptions(e,t){if(e!==`just-bash`)return t;if(t?.networkPolicy!==void 0&&t.networkPolicy!==`allow-all`)throw Error(JUST_BASH_NETWORK_POLICY_MESSAGE)}function withNetworkPolicy(e){let t=e.extensions??{};return typeof Reflect.get(t,`setNetworkPolicy`)==`function`?e:{...e,extensions:{...t,setNetworkPolicy:rejectJustBashNetworkPolicy}}}async function rejectJustBashNetworkPolicy(e){if(e!==`allow-all`)throw Error(JUST_BASH_NETWORK_POLICY_MESSAGE)}function isSelectedProvider(e){return SELECTED_PROVIDERS.some(t=>t===e)}function isDefaultSandboxSessionState(e){return isObject(e)&&isSelectedProvider(e.provider)&&typeof e.stateProtocolVersion==`number`&&`state`in e}function isDefaultSandboxPreparedArtifact(e){return isObject(e)&&(e.provider===null||isSelectedProvider(e.provider)&&`artifact`in e)}export{DefaultSandbox};
@@ -1,8 +1,11 @@
1
- import type { DockerSandboxSession } from "#public/sandbox/docker.js";
2
- import type { DockerSandboxEnvironmentOptions, DockerSandboxRuntimeOptions } from "#public/sandbox/docker-sandbox.js";
1
+ import type { DockerCli } from "#execution/sandbox/bindings/docker-cli.js";
2
+ import type { DockerSandboxEnvironmentOptions, DockerSandboxRuntimeOptions, DockerSandboxSession } from "#public/sandbox/docker-sandbox.js";
3
+ import { type SandboxProvider } from "#public/sandbox/provider.js";
3
4
  import type { SandboxEnvironment } from "#shared/sandbox-environment.js";
4
5
  export type { DockerSandboxEnvironmentOptions, DockerSandboxRuntimeOptions, } from "#public/sandbox/docker-sandbox.js";
5
6
  type DockerfileEnvironmentInput = Omit<DockerSandboxEnvironmentOptions, "image">;
7
+ /** Defines the Docker provider over `dockerCli`, the real `docker` CLI unless tests inject one. */
8
+ export declare function defineDockerSandboxProvider(dockerCli?: DockerCli): SandboxProvider<DockerSandboxEnvironmentOptions, DockerSandboxRuntimeOptions, DockerSandboxSession>;
6
9
  export declare const DockerSandbox: {
7
10
  name: string;
8
11
  environment(options?: Readonly<DockerSandboxEnvironmentOptions> | undefined): SandboxEnvironment<DockerSandboxRuntimeOptions, DockerSandboxSession>;
@@ -1 +1 @@
1
- import{createDockerSandboxProvider}from"#execution/sandbox/bindings/local.js";import{defineSandboxProvider}from"#shared/sandbox-provider.js";const provider=defineSandboxProvider({name:`docker`,environment(e){return createDockerSandboxProvider(e)}}),DockerSandbox={...provider,dockerfile(e={}){return provider.environment(e)},image(e,t={}){return provider.environment({...t,image:e})}};export{DockerSandbox};
1
+ import{DOCKER_PROVIDER_NAME,createDockerSandboxProvider}from"#execution/sandbox/bindings/local.js";import{defineSandboxProvider}from"#public/sandbox/provider.js";function defineDockerSandboxProvider(e){return defineSandboxProvider({name:DOCKER_PROVIDER_NAME,environment:t=>createDockerSandboxProvider(t,e)})}const provider=defineDockerSandboxProvider(),DockerSandbox={...provider,dockerfile(e={}){return provider.environment(e)},image(e,t={}){return provider.environment({...t,image:e})}};export{DockerSandbox,defineDockerSandboxProvider};
@@ -1,4 +1,5 @@
1
1
  import type { JustBashSandboxCreateOptions } from "#public/sandbox/just-bash-sandbox.js";
2
- import type { SandboxSession } from "#shared/sandbox-session.js";
3
- export type JustBashEnvironmentOptions = JustBashSandboxCreateOptions;
4
- export declare const JustBashSandbox: import("#shared/sandbox-provider.js").SandboxProvider<JustBashSandboxCreateOptions, undefined, SandboxSession>;
2
+ import { type WithPrepareOption } from "#public/sandbox/provider.js";
3
+ import type { SandboxSession } from "#public/sandbox/index.js";
4
+ export type JustBashEnvironmentOptions = WithPrepareOption<JustBashSandboxCreateOptions, SandboxSession>;
5
+ export declare const JustBashSandbox: import("#public/sandbox/provider.js").SandboxProvider<WithPrepareOption<JustBashSandboxCreateOptions, SandboxSession>, undefined, SandboxSession>;
@@ -1 +1 @@
1
- import{createJustBashSandboxProvider}from"#execution/sandbox/bindings/local.js";import{defineSandboxProvider}from"#shared/sandbox-provider.js";const JustBashSandbox=defineSandboxProvider({name:`just-bash`,environment:e=>createJustBashSandboxProvider(e)});export{JustBashSandbox};
1
+ import{createJustBashSandboxProvider}from"#execution/sandbox/bindings/local.js";import{defineSandboxProvider}from"#public/sandbox/provider.js";const JustBashSandbox=defineSandboxProvider({name:`just-bash`,environment:e=>createJustBashSandboxProvider(e)});export{JustBashSandbox};
@@ -1,13 +1,7 @@
1
1
  import type { VercelSandboxSession } from "#public/sandbox/vercel.js";
2
+ import { type SandboxProvider, type WithPrepareOption } from "#public/sandbox/provider.js";
2
3
  import type { VercelSandboxCreateOptions, VercelSandboxRuntimeOptions } from "#public/sandbox/vercel-sandbox.js";
3
- import type { SandboxEnvironment } from "#shared/sandbox-environment.js";
4
- import type { SandboxSession } from "#shared/sandbox-session.js";
5
- export type VercelSandboxEnvironmentOptions = VercelSandboxCreateOptions & {
6
- readonly prepare?: (sandbox: SandboxSession) => Promise<void> | void;
7
- };
4
+ /** Vercel create options plus `prepare`, which receives a {@link VercelSandboxSession}. */
5
+ export type VercelSandboxEnvironmentOptions = WithPrepareOption<VercelSandboxCreateOptions, VercelSandboxSession>;
8
6
  export type { VercelSandboxRuntimeOptions } from "#public/sandbox/vercel-sandbox.js";
9
- export declare function createDefaultVercelEnvironment(options?: VercelSandboxEnvironmentOptions): SandboxEnvironment<VercelSandboxRuntimeOptions, VercelSandboxSession>;
10
- export declare const VercelSandbox: {
11
- name: string;
12
- environment(options?: VercelSandboxEnvironmentOptions): SandboxEnvironment<VercelSandboxRuntimeOptions, VercelSandboxSession>;
13
- };
7
+ export declare const VercelSandbox: SandboxProvider<VercelSandboxEnvironmentOptions | undefined, VercelSandboxRuntimeOptions, VercelSandboxSession>;
@@ -1 +1 @@
1
- import{defineSandboxProvider}from"#shared/sandbox-provider.js";import{createVercelSandbox,createVercelSandboxProvider}from"#execution/sandbox/bindings/vercel.js";const defaultProvider=defineSandboxProvider({name:`vercel`,environment:e=>{let{prepare:t,...n}=e??{};return createVercelSandbox({createOptions:n,prepare:t,skipEmptyPreparation:!0})}}),provider=defineSandboxProvider({name:`vercel`,environment:e=>createVercelSandboxProvider(e)});function createDefaultVercelEnvironment(e){return defaultProvider.environment(e)}const VercelSandbox={name:`vercel`,environment(e){return provider.environment(e)}};export{VercelSandbox,createDefaultVercelEnvironment};
1
+ import{defineSandboxProvider}from"#public/sandbox/provider.js";import{createVercelSandbox}from"#execution/sandbox/bindings/vercel.js";const VercelSandbox=defineSandboxProvider({name:`vercel`,environment:e=>createVercelSandbox({createOptions:e})});export{VercelSandbox};
@@ -1,5 +1,4 @@
1
1
  export { DefaultSandbox } from "#sandbox/providers/default.js";
2
2
  export { DockerSandbox } from "#sandbox/providers/docker.js";
3
3
  export { JustBashSandbox } from "#sandbox/providers/just-bash.js";
4
- export { MicrosandboxSandbox } from "#sandbox/providers/microsandbox.js";
5
4
  export { VercelSandbox } from "#sandbox/providers/vercel.js";
@@ -1 +1 @@
1
- import{DockerSandbox}from"#sandbox/providers/docker.js";import{DefaultSandbox}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";export{DefaultSandbox,DockerSandbox,JustBashSandbox,MicrosandboxSandbox,VercelSandbox};
1
+ import{DockerSandbox}from"#sandbox/providers/docker.js";import{DefaultSandbox}from"#sandbox/providers/default.js";import{JustBashSandbox}from"#sandbox/providers/just-bash.js";import{VercelSandbox}from"#sandbox/providers/vercel.js";export{DefaultSandbox,DockerSandbox,JustBashSandbox,VercelSandbox};
@@ -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,10 +20,61 @@ 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;
56
+ /**
57
+ * Background work that may need the sandbox. It calls `open` only when it
58
+ * does, so work that turns out to have nothing to do never opens it. Calling
59
+ * the access's `get()` from the work waits on the work itself.
60
+ */
61
+ export type SandboxPreparation = (open: () => Promise<SandboxSession>) => Promise<void>;
13
62
  export interface SandboxAccess {
14
63
  readonly environment?: SandboxEnvironmentIdentity;
15
64
  captureState(): Promise<SandboxState>;
16
65
  delete?(options?: SandboxDeleteOptions): Promise<void>;
66
+ /** Resolves once the sandbox is open and every queued preparation has run. */
17
67
  get(): Promise<SandboxSession | null>;
68
+ /**
69
+ * Opens the sandbox without waiting for queued preparation, for framework
70
+ * work that needs only the connection, such as staging attachments.
71
+ */
72
+ open(): Promise<SandboxSession | null>;
73
+ /**
74
+ * Queues `work` to run in the background, in order; without `work`, opens
75
+ * the sandbox in the background. Returns at once and never throws.
76
+ */
77
+ prepare(work?: SandboxPreparation): void;
18
78
  stop(): Promise<void>;
19
79
  }
80
+ 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>;