eve 0.29.3 → 0.29.5

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 (326) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/src/acp/adapter.d.ts +43 -0
  3. package/dist/src/acp/adapter.js +1 -0
  4. package/dist/src/acp/line-limit.d.ts +3 -0
  5. package/dist/src/acp/line-limit.js +1 -0
  6. package/dist/src/acp/server.d.ts +24 -0
  7. package/dist/src/acp/server.js +1 -0
  8. package/dist/src/channel/clear-session.d.ts +4 -0
  9. package/dist/src/channel/clear-session.js +1 -0
  10. package/dist/src/channel/compact-session.d.ts +4 -0
  11. package/dist/src/channel/compact-session.js +1 -0
  12. package/dist/src/channel/routes.d.ts +34 -6
  13. package/dist/src/channel/types.d.ts +61 -9
  14. package/dist/src/chunks/{use-eve-agent-DaH3cf8K.js → use-eve-agent-BXMIf5fR.js} +130 -11
  15. package/dist/src/chunks/{use-eve-agent-CyDt3Lny.js → use-eve-agent-k-XHfrJT.js} +130 -11
  16. package/dist/src/cli/acp/command.d.ts +22 -0
  17. package/dist/src/cli/acp/command.js +4 -0
  18. package/dist/src/cli/commands/agent-prompt/build-and-verify.md +4 -0
  19. package/dist/src/cli/commands/extension-init.js +1 -1
  20. package/dist/src/cli/commands/init-git.js +1 -1
  21. package/dist/src/cli/commands/init-repl.js +1 -1
  22. package/dist/src/cli/commands/init.js +1 -1
  23. package/dist/src/cli/commands/logs.js +2 -2
  24. package/dist/src/cli/commands/register-integration-commands.js +1 -1
  25. package/dist/src/cli/commands/register-registry-commands.js +1 -1
  26. package/dist/src/cli/commands/registry-project.js +1 -1
  27. package/dist/src/cli/commands/registry-setup-command.js +1 -1
  28. package/dist/src/cli/commands/registry.d.ts +14 -2
  29. package/dist/src/cli/commands/registry.js +1 -1
  30. package/dist/src/cli/commands/trace.d.ts +2 -2
  31. package/dist/src/cli/dev/command-options.d.ts +22 -0
  32. package/dist/src/cli/dev/command-options.js +1 -0
  33. package/dist/src/cli/dev/diagnostic-dump.js +1 -1
  34. package/dist/src/cli/dev/diagnostic-sink.js +1 -1
  35. package/dist/src/cli/dev/local-server-cleanup.js +1 -1
  36. package/dist/src/cli/dev/local-server-process.js +1 -1
  37. package/dist/src/cli/dev/tui/command-typeahead.js +1 -1
  38. package/dist/src/cli/dev/tui/message-queue.d.ts +9 -13
  39. package/dist/src/cli/dev/tui/message-queue.js +1 -1
  40. package/dist/src/cli/dev/tui/prompt-commands.d.ts +13 -5
  41. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  42. package/dist/src/cli/dev/tui/remote-auth.d.ts +6 -3
  43. package/dist/src/cli/dev/tui/remote-connection-probe.js +1 -1
  44. package/dist/src/cli/dev/tui/runner.d.ts +7 -7
  45. package/dist/src/cli/dev/tui/runner.js +1 -1
  46. package/dist/src/cli/dev/tui/stream-format.d.ts +14 -0
  47. package/dist/src/cli/dev/tui/stream-format.js +2 -2
  48. package/dist/src/cli/dev/tui/subagent-pump.d.ts +5 -5
  49. package/dist/src/cli/dev/tui/terminal-background.d.ts +23 -0
  50. package/dist/src/cli/dev/tui/terminal-background.js +1 -0
  51. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  52. package/dist/src/cli/dev/tui/traces/trace-content.d.ts +7 -0
  53. package/dist/src/cli/dev/tui/traces/trace-content.js +2 -2
  54. package/dist/src/cli/dev/tui/traces/trace-conversation.d.ts +10 -5
  55. package/dist/src/cli/dev/tui/traces/trace-conversation.js +1 -1
  56. package/dist/src/cli/dev/tui/traces/trace-store.js +1 -1
  57. package/dist/src/cli/dev/tui/traces/trace-surfaces.d.ts +40 -0
  58. package/dist/src/cli/dev/tui/traces/trace-surfaces.js +1 -0
  59. package/dist/src/cli/dev/tui/traces/trace-view.d.ts +8 -1
  60. package/dist/src/cli/dev/tui/traces/trace-view.js +2 -2
  61. package/dist/src/cli/dev/tui/traces/trace-viewer-session.d.ts +13 -0
  62. package/dist/src/cli/dev/tui/traces/trace-viewer-session.js +1 -1
  63. package/dist/src/cli/dev/tui/traces/trace-viewer-state.js +1 -1
  64. package/dist/src/cli/dev/tui/tui.js +1 -1
  65. package/dist/src/cli/invoke/invoke.js +1 -1
  66. package/dist/src/cli/invoke/result.js +1 -1
  67. package/dist/src/cli/run.d.ts +3 -0
  68. package/dist/src/cli/run.js +3 -3
  69. package/dist/src/cli/ui/terminal-text.d.ts +0 -3
  70. package/dist/src/cli/ui/terminal-text.js +1 -1
  71. package/dist/src/client/agent-info-schema.d.ts +2 -2
  72. package/dist/src/client/agent-info-schema.js +1 -1
  73. package/dist/src/client/index.d.ts +1 -1
  74. package/dist/src/client/open-stream.js +1 -1
  75. package/dist/src/client/session.d.ts +29 -1
  76. package/dist/src/client/session.js +1 -1
  77. package/dist/src/client/types.d.ts +29 -0
  78. package/dist/src/compiled/.vendor-stamp.json +2 -1
  79. package/dist/src/compiled/@agentclientprotocol/sdk/LICENSE +191 -0
  80. package/dist/src/compiled/@agentclientprotocol/sdk/index.d.ts +1835 -0
  81. package/dist/src/compiled/@agentclientprotocol/sdk/index.js +65 -0
  82. package/dist/src/compiled/@agentclientprotocol/sdk/jsonrpc.d.ts +603 -0
  83. package/dist/src/compiled/@agentclientprotocol/sdk/schema/guards.gen.d.ts +199 -0
  84. package/dist/src/compiled/@agentclientprotocol/sdk/schema/index.d.ts +51 -0
  85. package/dist/src/compiled/@agentclientprotocol/sdk/schema/types.gen.d.ts +6118 -0
  86. package/dist/src/compiled/@agentclientprotocol/sdk/stream.d.ts +35 -0
  87. package/dist/src/compiler/artifacts.js +1 -1
  88. package/dist/src/compiler/extension-compatibility.d.ts +8 -8
  89. package/dist/src/compiler/extension-compatibility.js +1 -1
  90. package/dist/src/compiler/manifest.d.ts +11 -22
  91. package/dist/src/compiler/manifest.js +1 -1
  92. package/dist/src/compiler/model-catalog.js +1 -1
  93. package/dist/src/compiler/normalize-agent-config.d.ts +3 -1
  94. package/dist/src/compiler/normalize-agent-config.js +1 -1
  95. package/dist/src/compiler/normalize-manifest.js +1 -1
  96. package/dist/src/compiler/normalize-sandbox.js +1 -1
  97. package/dist/src/compiler/normalize-subagent.d.ts +1 -0
  98. package/dist/src/compiler/normalize-subagent.js +1 -1
  99. package/dist/src/compiler/remote-agent-node.d.ts +3 -0
  100. package/dist/src/compiler/workspace-resources.js +1 -1
  101. package/dist/src/context/dynamic-subagent-lifecycle.d.ts +22 -0
  102. package/dist/src/context/dynamic-subagent-lifecycle.js +1 -0
  103. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  104. package/dist/src/context/keys.d.ts +13 -2
  105. package/dist/src/context/keys.js +1 -1
  106. package/dist/src/context/run-step.js +1 -1
  107. package/dist/src/discover/project-source.js +1 -1
  108. package/dist/src/evals/cli/eval.js +2 -2
  109. package/dist/src/evals/loaders/json.js +1 -1
  110. package/dist/src/evals/loaders/yaml.js +1 -1
  111. package/dist/src/evals/runner/artifacts.js +1 -1
  112. package/dist/src/evals/runner/discover.js +1 -1
  113. package/dist/src/evals/runner/reporters/junit.js +1 -1
  114. package/dist/src/evals/session.js +1 -1
  115. package/dist/src/execution/create-session-step.d.ts +2 -0
  116. package/dist/src/execution/create-session-step.js +1 -1
  117. package/dist/src/execution/delegation-tool.d.ts +3 -0
  118. package/dist/src/execution/delegation-tool.js +1 -0
  119. package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
  120. package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
  121. package/dist/src/execution/effective-agent-config.d.ts +12 -0
  122. package/dist/src/execution/effective-agent-config.js +1 -0
  123. package/dist/src/execution/node-step.d.ts +4 -0
  124. package/dist/src/execution/node-step.js +1 -1
  125. package/dist/src/execution/runtime-context.d.ts +2 -0
  126. package/dist/src/execution/runtime-context.js +1 -1
  127. package/dist/src/execution/sandbox/bindings/docker-cli.js +1 -1
  128. package/dist/src/execution/sandbox/bindings/docker-templates.js +1 -1
  129. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  130. package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
  131. package/dist/src/execution/sandbox/bindings/local-backend-utils.js +1 -1
  132. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +1 -1
  133. package/dist/src/execution/sandbox/bindings/microsandbox-metadata.js +1 -1
  134. package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +1 -1
  135. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
  136. package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +1 -1
  137. package/dist/src/execution/sandbox/development-cleanup.js +1 -1
  138. package/dist/src/execution/sandbox/template-prewarm-lock.js +1 -1
  139. package/dist/src/execution/session-callback-request.d.ts +5 -0
  140. package/dist/src/execution/session-callback-request.js +1 -0
  141. package/dist/src/execution/session-delivery-hook.d.ts +1 -0
  142. package/dist/src/execution/session-delivery-hook.js +1 -1
  143. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  144. package/dist/src/execution/subagent-event-proxy-step.js +1 -1
  145. package/dist/src/execution/workflow-entry.js +1 -1
  146. package/dist/src/execution/workflow-runtime.d.ts +2 -0
  147. package/dist/src/execution/workflow-runtime.js +1 -1
  148. package/dist/src/execution/workflow-steps.js +1 -1
  149. package/dist/src/harness/agent-handles.d.ts +238 -0
  150. package/dist/src/harness/agent-handles.js +2 -0
  151. package/dist/src/harness/attachment-staging.js +1 -1
  152. package/dist/src/harness/compaction.d.ts +1 -1
  153. package/dist/src/harness/compaction.js +1 -1
  154. package/dist/src/harness/tool-loop.js +2 -2
  155. package/dist/src/harness/types.d.ts +16 -0
  156. package/dist/src/internal/application/build-profile.js +1 -1
  157. package/dist/src/internal/application/build-workspace.js +1 -1
  158. package/dist/src/internal/application/cache-metadata.js +1 -1
  159. package/dist/src/internal/application/compiled-artifacts.js +8 -8
  160. package/dist/src/internal/application/optional-package-install.js +2 -2
  161. package/dist/src/internal/application/output-publication-artifacts.js +1 -1
  162. package/dist/src/internal/application/output-publication-journal.js +1 -1
  163. package/dist/src/internal/application/output-publication-lock.js +1 -1
  164. package/dist/src/internal/application/output-publication.js +1 -1
  165. package/dist/src/internal/application/package.js +1 -1
  166. package/dist/src/internal/application/paths.js +1 -1
  167. package/dist/src/internal/application/production-compiler-artifacts.js +1 -1
  168. package/dist/src/internal/application/tsconfig-dependencies.js +1 -1
  169. package/dist/src/internal/authored-asset-import-plugin.js +1 -1
  170. package/dist/src/internal/authored-definition/core.js +1 -1
  171. package/dist/src/internal/authored-module-loader.js +3 -3
  172. package/dist/src/internal/authored-package-tsconfig-paths.js +1 -1
  173. package/dist/src/internal/materialized-authored-modules.js +1 -1
  174. package/dist/src/internal/nitro/dev-runtime-artifacts-retention.js +1 -1
  175. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  176. package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
  177. package/dist/src/internal/nitro/dev-runtime-source-snapshot.js +1 -1
  178. package/dist/src/internal/nitro/host/build-application.js +1 -1
  179. package/dist/src/internal/nitro/host/build-extension.js +1 -1
  180. package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
  181. package/dist/src/internal/nitro/host/configure-nitro-routes.js +3 -3
  182. package/dist/src/internal/nitro/host/copy-host-middleware.js +1 -1
  183. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  184. package/dist/src/internal/nitro/host/cron-handler-route.js +1 -1
  185. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
  186. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  187. package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
  188. package/dist/src/internal/nitro/host/dev-host-workspace.js +1 -1
  189. package/dist/src/internal/nitro/host/dev-server-http.js +1 -1
  190. package/dist/src/internal/nitro/host/dev-server-state.js +1 -1
  191. package/dist/src/internal/nitro/host/dev-workspace-extensions.js +1 -1
  192. package/dist/src/internal/nitro/host/extension-build-config.js +1 -1
  193. package/dist/src/internal/nitro/host/extension-declarations.js +2 -2
  194. package/dist/src/internal/nitro/host/extension-distribution.js +3 -3
  195. package/dist/src/internal/nitro/host/extension-state-usage.js +1 -1
  196. package/dist/src/internal/nitro/host/normalize-vercel-service-crons.js +1 -1
  197. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  198. package/dist/src/internal/nitro/host/start-production-server.js +2 -2
  199. package/dist/src/internal/nitro/host/types.d.ts +2 -0
  200. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
  201. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +1 -1
  202. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  203. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
  204. package/dist/src/internal/vercel/project-link.js +1 -1
  205. package/dist/src/internal/vercel-agent-summary.d.ts +1 -1
  206. package/dist/src/internal/workflow/development-world-client.js +1 -1
  207. package/dist/src/internal/workflow-bundle/builder-support.js +6 -6
  208. package/dist/src/internal/workflow-bundle/builder.js +3 -3
  209. package/dist/src/internal/workflow-bundle/nitro-step-entry.js +2 -2
  210. package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
  211. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  212. package/dist/src/protocol/clear-session.d.ts +14 -0
  213. package/dist/src/protocol/clear-session.js +1 -0
  214. package/dist/src/protocol/compact-session.d.ts +14 -0
  215. package/dist/src/protocol/compact-session.js +1 -0
  216. package/dist/src/protocol/message.d.ts +19 -1
  217. package/dist/src/protocol/message.js +1 -1
  218. package/dist/src/protocol/routes.d.ts +10 -0
  219. package/dist/src/protocol/routes.js +1 -1
  220. package/dist/src/public/channels/discord/discordChannel.js +1 -1
  221. package/dist/src/public/channels/discord/verify.js +1 -1
  222. package/dist/src/public/channels/eve.js +1 -1
  223. package/dist/src/public/channels/github/auth.js +2 -2
  224. package/dist/src/public/channels/github/githubChannel.js +1 -1
  225. package/dist/src/public/channels/github/verify.js +1 -1
  226. package/dist/src/public/channels/index.d.ts +1 -1
  227. package/dist/src/public/channels/linear/inbound.js +2 -2
  228. package/dist/src/public/channels/linear/linearChannel.js +1 -1
  229. package/dist/src/public/channels/linear/verify.js +1 -1
  230. package/dist/src/public/channels/teams/teamsChannel.js +1 -1
  231. package/dist/src/public/channels/telegram/verify.js +1 -1
  232. package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
  233. package/dist/src/public/definitions/agent.d.ts +32 -1
  234. package/dist/src/public/definitions/agent.js +1 -1
  235. package/dist/src/public/definitions/channel.d.ts +5 -2
  236. package/dist/src/public/definitions/channel.js +1 -1
  237. package/dist/src/public/definitions/hook.d.ts +1 -0
  238. package/dist/src/public/definitions/tool.d.ts +4 -1
  239. package/dist/src/public/index.d.ts +1 -2
  240. package/dist/src/public/index.js +1 -1
  241. package/dist/src/public/models/openai/chatgpt/auth.js +1 -1
  242. package/dist/src/public/next/server.js +2 -2
  243. package/dist/src/public/next/vercel-output-config.js +1 -1
  244. package/dist/src/public/nuxt/dev-server.js +1 -1
  245. package/dist/src/public/nuxt/vercel-services.js +1 -1
  246. package/dist/src/public/sveltekit/dev-server.js +1 -1
  247. package/dist/src/public/sveltekit/vercel-json.js +1 -1
  248. package/dist/src/runtime/framework-tools/connection-search-dynamic.d.ts +2 -18
  249. package/dist/src/runtime/framework-tools/connection-search-dynamic.js +2 -2
  250. package/dist/src/runtime/framework-tools/file-state.js +1 -1
  251. package/dist/src/runtime/framework-tools/index.d.ts +7 -2
  252. package/dist/src/runtime/framework-tools/index.js +1 -1
  253. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  254. package/dist/src/runtime/resolve-agent.js +1 -1
  255. package/dist/src/runtime/resolve-dynamic-subagent.d.ts +12 -0
  256. package/dist/src/runtime/resolve-dynamic-subagent.js +1 -0
  257. package/dist/src/runtime/resolve-dynamic-tool.d.ts +15 -0
  258. package/dist/src/runtime/resolve-dynamic-tool.js +1 -1
  259. package/dist/src/runtime/sandbox/keys.js +1 -1
  260. package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +22 -0
  261. package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -0
  262. package/dist/src/runtime/subagents/registry.d.ts +10 -2
  263. package/dist/src/runtime/subagents/registry.js +1 -1
  264. package/dist/src/runtime/types.d.ts +11 -2
  265. package/dist/src/runtime/workspace/seed-files.js +1 -1
  266. package/dist/src/setup/boxes/detect-ai-gateway.js +1 -1
  267. package/dist/src/setup/flows/registry.js +1 -1
  268. package/dist/src/setup/index.d.ts +1 -0
  269. package/dist/src/setup/index.js +1 -1
  270. package/dist/src/setup/integrations/discord/api.d.ts +15 -0
  271. package/dist/src/setup/integrations/discord/api.js +1 -0
  272. package/dist/src/setup/integrations/discord/connect.d.ts +24 -0
  273. package/dist/src/setup/integrations/discord/connect.js +1 -0
  274. package/dist/src/setup/integrations/discord/setup.d.ts +19 -0
  275. package/dist/src/setup/integrations/discord/setup.js +8 -0
  276. package/dist/src/setup/integrations/registry.js +1 -1
  277. package/dist/src/setup/package-manager.js +1 -1
  278. package/dist/src/setup/primitives/pm/pnpm.js +3 -3
  279. package/dist/src/setup/project-resolution.js +1 -1
  280. package/dist/src/setup/prompter.js +1 -1
  281. package/dist/src/setup/registry-setup-client.d.ts +6 -2
  282. package/dist/src/setup/registry-setup-client.js +1 -1
  283. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  284. package/dist/src/setup/scaffold/create/extension.js +1 -1
  285. package/dist/src/setup/scaffold/create/project.js +2 -9
  286. package/dist/src/setup/scaffold/files.js +1 -1
  287. package/dist/src/setup/scaffold/update/channels.js +2 -2
  288. package/dist/src/setup/scaffold/update/connections.js +1 -1
  289. package/dist/src/setup/scaffold/workspace-root.js +1 -1
  290. package/dist/src/setup/slack-connect-lifecycle.js +1 -1
  291. package/dist/src/setup/vercel-project-framework.js +1 -1
  292. package/dist/src/shared/agent-definition.d.ts +7 -0
  293. package/dist/src/shared/agent-turn-outcome.d.ts +47 -0
  294. package/dist/src/shared/agent-turn-outcome.js +1 -0
  295. package/dist/src/shared/dynamic-tool-definition.d.ts +1 -5
  296. package/dist/src/shared/dynamic-tool-definition.js +1 -1
  297. package/dist/src/shared/guards.d.ts +2 -0
  298. package/dist/src/shared/guards.js +1 -1
  299. package/dist/src/shared/skill-package.js +1 -1
  300. package/dist/src/shared/skill-paths.d.ts +4 -4
  301. package/dist/src/shared/skill-paths.js +2 -2
  302. package/dist/src/shared/vercel-output-directory.js +1 -1
  303. package/dist/src/source-change/static-source-change.js +1 -1
  304. package/dist/src/svelte/index.js +1 -1
  305. package/dist/src/svelte/use-eve-agent.js +1 -1
  306. package/dist/src/tracing/local-instrumentation-runtime.js +1 -1
  307. package/dist/src/tracing/local-trace-reader.d.ts +22 -5
  308. package/dist/src/tracing/local-trace-reader.js +1 -1
  309. package/dist/src/tracing/local-trace-retention.js +1 -1
  310. package/dist/src/tracing/local-trace-span-processor.js +1 -1
  311. package/dist/src/vue/index.js +1 -1
  312. package/dist/src/vue/use-eve-agent.js +1 -1
  313. package/docs/channels/custom.mdx +41 -1
  314. package/docs/channels/discord.mdx +30 -14
  315. package/docs/channels/eve.mdx +26 -1
  316. package/docs/concepts/default-harness.md +4 -0
  317. package/docs/guides/acp.md +91 -0
  318. package/docs/guides/client/streaming.mdx +38 -0
  319. package/docs/guides/dev-tui.md +10 -7
  320. package/docs/guides/dynamic-capabilities.md +49 -6
  321. package/docs/guides/meta.json +1 -0
  322. package/docs/reference/cli.md +3 -0
  323. package/docs/reference/project-layout.md +1 -1
  324. package/docs/reference/typescript-api.md +48 -48
  325. package/docs/subagents.mdx +32 -2
  326. package/package.json +3 -2
@@ -1 +1 @@
1
- import{object,string}from"../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js";import"../node_modules/.pnpm/zod@4.4.3/node_modules/zod/index.js";import{parseSlackConnectorDetails,parseSlackConnectors}from"./slack-connect.js";import{join}from"node:path";import{SLACK_CHANNEL_DEFAULT_ROUTE}from"#setup/scaffold/index.js";import{readFile}from"node:fs/promises";import"#setup/primitives/run-vercel.js";import"#setup/cli/index.js";import{CONNECT_MUTATION_TIMEOUT_MS,replaceConnectTrigger}from"#setup/connect-provisioning.js";const CONNECT_LOOKUP_TIMEOUT_MS=6e4,VercelProjectLinkSchema=object({projectId:string().min(1),orgId:string().min(1)});async function listSlackConnectors(e,t,n,i){let a=await e.captureVercel([`connect`,`list`,`-F`,`json`,`--all-projects`],{cwd:t,onOutput:n,timeoutMs:CONNECT_LOOKUP_TIMEOUT_MS,signal:i});if(!a.ok)return{state:`failed`,message:a.failure.message};try{let e=JSON.parse(a.stdout);if(typeof e!=`object`||!e)return{state:`failed`,message:`Vercel returned a malformed connector list.`};let t=e;return Array.isArray(t.connectors??t.clients)?{state:`ok`,body:e,connectors:parseSlackConnectors(e)}:{state:`failed`,message:`Vercel returned a malformed connector list.`}}catch{return{state:`failed`,message:`Vercel returned invalid JSON for the connector list.`}}}async function readProjectLink(e){try{let t=await readFile(join(e,`.vercel`,`project.json`),`utf8`),n=VercelProjectLinkSchema.safeParse(JSON.parse(t));return n.success?n.data:void 0}catch{return}}async function findSlackConnector(e,t,n,r,i,a){let o=await listSlackConnectors(e,t,i,a);if(o.state===`failed`)return o;let s=new Set(o.connectors.map(e=>e.uid));if(n===void 0)return{state:`not-found`,connectorUids:s};let c=o.connectors.filter(e=>e.id!==void 0&&e.projectIds.includes(n)).sort((e,t)=>t.createdAt-e.createdAt).map(({uid:e,id:t})=>({uid:e,id:t}));if(c.length===0)return{state:`not-found`,connectorUids:s};let l=c.find(e=>e.uid===r);return l===void 0?{state:`found`,connectors:c,connectorUids:s}:{state:`found`,connectors:c,preferred:l,connectorUids:s}}async function attachSlackConnector(e,t,n,r,i){return replaceConnectTrigger({connectorUid:n.uid,projectRoot:t,triggerPath:SLACK_CHANNEL_DEFAULT_ROUTE,onOutput:r,signal:i,deps:e})}async function fetchSlackConnectorDetails(e){let t=e.orgId===void 0?``:`?teamId=${encodeURIComponent(e.orgId)}`,r=[`api`,`/v1/connect/connectors/${encodeURIComponent(e.connectorId)}${t}`];e.orgId!==void 0&&r.push(`--scope`,e.orgId);let i=await e.deps.captureVercel(r,{cwd:e.projectRoot,onOutput:e.onOutput,timeoutMs:e.timeoutMs,signal:e.signal});if(!i.ok)return{state:`failed`,message:i.failure.message};try{let t=parseSlackConnectorDetails(JSON.parse(i.stdout));return t?.ref.id===e.connectorId?{state:`found`,details:t}:{state:`failed`,message:`Vercel returned an invalid Slack connector.`}}catch{return{state:`failed`,message:`Vercel returned invalid JSON for the Slack connector.`}}}async function fetchSlackWorkspace(e){let t=await fetchSlackConnectorDetails(e);return t.state===`failed`?t:t.details.workspace===void 0?{state:`pending`}:{state:`connected`,workspace:t.details.workspace}}async function cleanupConnectorUid(e,t){let{log:n,deps:r,projectRoot:i,onOutput:a}=e;return await r.runVercel([`connect`,`remove`,t,`--disconnect-all`,`--yes`],{cwd:i,onOutput:a,timeoutMs:CONNECT_MUTATION_TIMEOUT_MS})?!0:(n.warning(`Could not remove the abandoned Slack connector. Run \`vercel connect remove ${t} --disconnect-all --yes\` to clean it up.`),!1)}async function cleanupConnectorUids(e,t){let n=[];for(let r of new Set(t))await cleanupConnectorUid(e,r)||n.push(r);return n.length===0?{state:`clean`}:{state:`failed`,connectorUids:n}}async function cleanupCreatedAttempt(e,t){if(t.createdRef)return cleanupConnectorUids(e,[t.createdRef.uid]);e.log.warning(`Vercel returned no connector UID for the abandoned Slack Connect request, so eve cannot prove that request was cancelled. No connector was removed; do not retry until the browser request is no longer usable.`);let n=await listSlackConnectors(e.deps,e.projectRoot,e.onOutput);return n.state===`failed`?{state:`failed`,connectorUids:[]}:{state:`failed`,connectorUids:n.connectors.map(e=>e.uid).filter(e=>(e===t.expectedUid||e.startsWith(`${t.expectedUid}-`))&&!t.baselineConnectorUids.has(e))}}export{CONNECT_LOOKUP_TIMEOUT_MS,attachSlackConnector,cleanupCreatedAttempt,fetchSlackConnectorDetails,fetchSlackWorkspace,findSlackConnector,listSlackConnectors,readProjectLink};
1
+ import{object,string}from"../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js";import"../node_modules/.pnpm/zod@4.4.3/node_modules/zod/index.js";import{parseSlackConnectorDetails,parseSlackConnectors}from"./slack-connect.js";import{readFile}from"node:fs/promises";import{join}from"node:path";import{SLACK_CHANNEL_DEFAULT_ROUTE}from"#setup/scaffold/index.js";import"#setup/primitives/run-vercel.js";import"#setup/cli/index.js";import{CONNECT_MUTATION_TIMEOUT_MS,replaceConnectTrigger}from"#setup/connect-provisioning.js";const CONNECT_LOOKUP_TIMEOUT_MS=6e4,VercelProjectLinkSchema=object({projectId:string().min(1),orgId:string().min(1)});async function listSlackConnectors(e,t,n,i){let a=await e.captureVercel([`connect`,`list`,`-F`,`json`,`--all-projects`],{cwd:t,onOutput:n,timeoutMs:CONNECT_LOOKUP_TIMEOUT_MS,signal:i});if(!a.ok)return{state:`failed`,message:a.failure.message};try{let e=JSON.parse(a.stdout);if(typeof e!=`object`||!e)return{state:`failed`,message:`Vercel returned a malformed connector list.`};let t=e;return Array.isArray(t.connectors??t.clients)?{state:`ok`,body:e,connectors:parseSlackConnectors(e)}:{state:`failed`,message:`Vercel returned a malformed connector list.`}}catch{return{state:`failed`,message:`Vercel returned invalid JSON for the connector list.`}}}async function readProjectLink(e){try{let t=await readFile(join(e,`.vercel`,`project.json`),`utf8`),n=VercelProjectLinkSchema.safeParse(JSON.parse(t));return n.success?n.data:void 0}catch{return}}async function findSlackConnector(e,t,n,r,i,a){let o=await listSlackConnectors(e,t,i,a);if(o.state===`failed`)return o;let s=new Set(o.connectors.map(e=>e.uid));if(n===void 0)return{state:`not-found`,connectorUids:s};let c=o.connectors.filter(e=>e.id!==void 0&&e.projectIds.includes(n)).sort((e,t)=>t.createdAt-e.createdAt).map(({uid:e,id:t})=>({uid:e,id:t}));if(c.length===0)return{state:`not-found`,connectorUids:s};let l=c.find(e=>e.uid===r);return l===void 0?{state:`found`,connectors:c,connectorUids:s}:{state:`found`,connectors:c,preferred:l,connectorUids:s}}async function attachSlackConnector(e,t,n,r,i){return replaceConnectTrigger({connectorUid:n.uid,projectRoot:t,triggerPath:SLACK_CHANNEL_DEFAULT_ROUTE,onOutput:r,signal:i,deps:e})}async function fetchSlackConnectorDetails(e){let t=e.orgId===void 0?``:`?teamId=${encodeURIComponent(e.orgId)}`,r=[`api`,`/v1/connect/connectors/${encodeURIComponent(e.connectorId)}${t}`];e.orgId!==void 0&&r.push(`--scope`,e.orgId);let i=await e.deps.captureVercel(r,{cwd:e.projectRoot,onOutput:e.onOutput,timeoutMs:e.timeoutMs,signal:e.signal});if(!i.ok)return{state:`failed`,message:i.failure.message};try{let t=parseSlackConnectorDetails(JSON.parse(i.stdout));return t?.ref.id===e.connectorId?{state:`found`,details:t}:{state:`failed`,message:`Vercel returned an invalid Slack connector.`}}catch{return{state:`failed`,message:`Vercel returned invalid JSON for the Slack connector.`}}}async function fetchSlackWorkspace(e){let t=await fetchSlackConnectorDetails(e);return t.state===`failed`?t:t.details.workspace===void 0?{state:`pending`}:{state:`connected`,workspace:t.details.workspace}}async function cleanupConnectorUid(e,t){let{log:n,deps:r,projectRoot:i,onOutput:a}=e;return await r.runVercel([`connect`,`remove`,t,`--disconnect-all`,`--yes`],{cwd:i,onOutput:a,timeoutMs:CONNECT_MUTATION_TIMEOUT_MS})?!0:(n.warning(`Could not remove the abandoned Slack connector. Run \`vercel connect remove ${t} --disconnect-all --yes\` to clean it up.`),!1)}async function cleanupConnectorUids(e,t){let n=[];for(let r of new Set(t))await cleanupConnectorUid(e,r)||n.push(r);return n.length===0?{state:`clean`}:{state:`failed`,connectorUids:n}}async function cleanupCreatedAttempt(e,t){if(t.createdRef)return cleanupConnectorUids(e,[t.createdRef.uid]);e.log.warning(`Vercel returned no connector UID for the abandoned Slack Connect request, so eve cannot prove that request was cancelled. No connector was removed; do not retry until the browser request is no longer usable.`);let n=await listSlackConnectors(e.deps,e.projectRoot,e.onOutput);return n.state===`failed`?{state:`failed`,connectorUids:[]}:{state:`failed`,connectorUids:n.connectors.map(e=>e.uid).filter(e=>(e===t.expectedUid||e.startsWith(`${t.expectedUid}-`))&&!t.baselineConnectorUids.has(e))}}export{CONNECT_LOOKUP_TIMEOUT_MS,attachSlackConnector,cleanupCreatedAttempt,fetchSlackConnectorDetails,fetchSlackWorkspace,findSlackConnector,listSlackConnectors,readProjectLink};
@@ -1 +1 @@
1
- import{object,string}from"../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js";import"../node_modules/.pnpm/zod@4.4.3/node_modules/zod/index.js";import{readProjectLink}from"./project-resolution.js";import{resolveVercelHostFrameworkPreset}from"./scaffold/update/channels.js";import"./scaffold/index.js";import{isForbiddenApiFailure,normalizeVercelApiResult}from"./vercel-api-failure.js";import{VERCEL_PROJECT_REQUEST_TIMEOUT_MS,parseVercelJson,requireVercelTeamAccess}from"./vercel-project-api.js";import{extname,join}from"node:path";import*as fs from"node:fs/promises";import{captureVercel}from"#setup/primitives/index.js";import"#setup/cli/index.js";const VercelProjectFrameworkSchema=object({framework:string().min(1).nullish()}),EVE_FRAMEWORK_INTEGRATIONS={nextjs:{label:`Next.js`,importSpecifier:`eve/next`},nuxt:{label:`Nuxt`,importSpecifier:`eve/nuxt`},nuxtjs:{label:`Nuxt`,importSpecifier:`eve/nuxt`},sveltekit:{label:`SvelteKit`,importSpecifier:`eve/sveltekit`}},FRAMEWORK_INTEGRATION_SOURCE_EXTENSIONS=new Set([`.cjs`,`.cts`,`.js`,`.json`,`.jsx`,`.mjs`,`.mts`,`.svelte`,`.ts`,`.tsx`,`.vue`]),FRAMEWORK_INTEGRATION_IGNORED_DIRECTORIES=new Set([`.eve`,`.git`,`.next`,`.nuxt`,`.output`,`.svelte-kit`,`.turbo`,`.vercel`,`build`,`coverage`,`dist`,`node_modules`]);function parseProjectFramework(e,t){let n=VercelProjectFrameworkSchema.safeParse(parseVercelJson(e,t));if(!n.success)throw Error(`Could not read Vercel project framework from ${t}.`);return n.data.framework??void 0}async function fetchProjectFramework(e,t,n,r){let s=normalizeVercelApiResult(await captureVercel([`api`,`/v9/projects/${n}`,`--scope`,t,`--raw`],{cwd:e,signal:r.signal,timeoutMs:VERCEL_PROJECT_REQUEST_TIMEOUT_MS}));if(s.ok)return parseProjectFramework(s.stdout,`project ${n}`);throw isForbiddenApiFailure(s.failure)&&requireVercelTeamAccess(s.failure),Error(`Could not inspect Vercel project "${n}". ${s.failure.message}`)}async function setProjectFramework(e,t,n,r,s,l){let u=normalizeVercelApiResult(await captureVercel([`api`,`/v9/projects/${n}`,`--scope`,t,`--method`,`PATCH`,`--raw-field`,`framework=${r}`,`--raw`],{cwd:e,onOutput:s,signal:l.signal,timeoutMs:VERCEL_PROJECT_REQUEST_TIMEOUT_MS}));if(!u.ok)throw isForbiddenApiFailure(u.failure)&&requireVercelTeamAccess(u.failure),Error(`Could not set Vercel project "${n}" framework to ${r}. ${u.failure.message}`)}async function confirmDetectedFramework(e,t,n){return await e.select({message:`Vercel detected ${n.label}. Is this project using ${n.importSpecifier}?`,options:[{value:!0,label:`Yes, keep ${t}`,hint:`Use this for a host app that integrates eve through ${n.importSpecifier}.`},{value:!1,label:`No, switch to eve`,hint:`Use this for a standalone eve agent.`}]})?`keep`:`switch-to-eve`}function sourceMentionsPackageSpecifier(e,t){return e.includes(`"${t}"`)||e.includes(`'${t}'`)||e.includes(`\`${t}\``)}async function directoryContainsPackageSpecifier(e,t){let n;try{n=await fs.readdir(e,{encoding:`utf8`,withFileTypes:!0})}catch{return!1}for(let r of n){let n=join(e,r.name);if(r.isDirectory()){if(FRAMEWORK_INTEGRATION_IGNORED_DIRECTORIES.has(r.name))continue;if(await directoryContainsPackageSpecifier(n,t))return!0;continue}if(!(!r.isFile()||!FRAMEWORK_INTEGRATION_SOURCE_EXTENSIONS.has(extname(r.name))))try{if(sourceMentionsPackageSpecifier(await fs.readFile(n,`utf8`),t))return!0}catch{continue}}return!1}async function detectFrameworkIntegrationImport(e,t){return directoryContainsPackageSpecifier(e,t)}async function resolveDetectedFrameworkAction(e,t,n,r){let i=EVE_FRAMEWORK_INTEGRATIONS[n];return i===void 0?`switch-to-eve`:await(r.detectFrameworkIntegrationImport??detectFrameworkIntegrationImport)(t,i.importSpecifier)?`keep`:r.headless?`switch-to-eve`:confirmDetectedFramework(e,n,i)}function frameworkPresetLabel(e){return EVE_FRAMEWORK_INTEGRATIONS[e]?.label??e}function describeError(e){return e instanceof Error?e.message:String(e)}async function syncHostFrameworkPreset(e,t,i,a){let o=await resolveVercelHostFrameworkPreset(t);if(o===void 0)return;let s=await readProjectLink(t);if(s===void 0)return;let c=frameworkPresetLabel(o),l;try{l=await fetchProjectFramework(t,s.orgId,s.projectId,a)}catch(t){if(a.signal?.aborted)throw t;e.log.warning(`Could not check this Vercel project's Framework Preset (${describeError(t)}). If it is not already ${c}, set it under Project Settings → Build and Deployment → Framework Settings before deploying.`);return}if(l===o)return;let u=l===void 0?void 0:frameworkPresetLabel(l),d=u===void 0?`had no Framework Preset set`:`was set to "${u}"`;try{await setProjectFramework(t,s.orgId,s.projectId,o,i,a)}catch(t){if(a.signal?.aborted)throw t;e.log.warning(`${describeError(t)} Set this Vercel project's Framework Preset to ${c} (Project Settings → Build and Deployment → Framework Settings) before deploying, or the deployment will not build your ${c} app.`);return}e.log.info(`This project uses ${c}, but its Vercel Framework Preset ${d}; switched it to ${c} so the deployment builds your app.`)}async function ensureCreatedProjectFramework(e,t,n,r,i,a){let o=await fetchProjectFramework(t,n,r,a);o!==`eve`&&(o===void 0?`switch-to-eve`:await resolveDetectedFrameworkAction(e,t,o,a))===`switch-to-eve`&&await setProjectFramework(t,n,r,`eve`,i,a)}export{ensureCreatedProjectFramework,syncHostFrameworkPreset};
1
+ import{object,string}from"../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js";import"../node_modules/.pnpm/zod@4.4.3/node_modules/zod/index.js";import{readProjectLink}from"./project-resolution.js";import{resolveVercelHostFrameworkPreset}from"./scaffold/update/channels.js";import"./scaffold/index.js";import{isForbiddenApiFailure,normalizeVercelApiResult}from"./vercel-api-failure.js";import{VERCEL_PROJECT_REQUEST_TIMEOUT_MS,parseVercelJson,requireVercelTeamAccess}from"./vercel-project-api.js";import*as fs from"node:fs/promises";import{extname,join}from"node:path";import{captureVercel}from"#setup/primitives/index.js";import"#setup/cli/index.js";const VercelProjectFrameworkSchema=object({framework:string().min(1).nullish()}),EVE_FRAMEWORK_INTEGRATIONS={nextjs:{label:`Next.js`,importSpecifier:`eve/next`},nuxt:{label:`Nuxt`,importSpecifier:`eve/nuxt`},nuxtjs:{label:`Nuxt`,importSpecifier:`eve/nuxt`},sveltekit:{label:`SvelteKit`,importSpecifier:`eve/sveltekit`}},FRAMEWORK_INTEGRATION_SOURCE_EXTENSIONS=new Set([`.cjs`,`.cts`,`.js`,`.json`,`.jsx`,`.mjs`,`.mts`,`.svelte`,`.ts`,`.tsx`,`.vue`]),FRAMEWORK_INTEGRATION_IGNORED_DIRECTORIES=new Set([`.eve`,`.git`,`.next`,`.nuxt`,`.output`,`.svelte-kit`,`.turbo`,`.vercel`,`build`,`coverage`,`dist`,`node_modules`]);function parseProjectFramework(e,t){let n=VercelProjectFrameworkSchema.safeParse(parseVercelJson(e,t));if(!n.success)throw Error(`Could not read Vercel project framework from ${t}.`);return n.data.framework??void 0}async function fetchProjectFramework(e,t,n,r){let s=normalizeVercelApiResult(await captureVercel([`api`,`/v9/projects/${n}`,`--scope`,t,`--raw`],{cwd:e,signal:r.signal,timeoutMs:VERCEL_PROJECT_REQUEST_TIMEOUT_MS}));if(s.ok)return parseProjectFramework(s.stdout,`project ${n}`);throw isForbiddenApiFailure(s.failure)&&requireVercelTeamAccess(s.failure),Error(`Could not inspect Vercel project "${n}". ${s.failure.message}`)}async function setProjectFramework(e,t,n,r,s,l){let u=normalizeVercelApiResult(await captureVercel([`api`,`/v9/projects/${n}`,`--scope`,t,`--method`,`PATCH`,`--raw-field`,`framework=${r}`,`--raw`],{cwd:e,onOutput:s,signal:l.signal,timeoutMs:VERCEL_PROJECT_REQUEST_TIMEOUT_MS}));if(!u.ok)throw isForbiddenApiFailure(u.failure)&&requireVercelTeamAccess(u.failure),Error(`Could not set Vercel project "${n}" framework to ${r}. ${u.failure.message}`)}async function confirmDetectedFramework(e,t,n){return await e.select({message:`Vercel detected ${n.label}. Is this project using ${n.importSpecifier}?`,options:[{value:!0,label:`Yes, keep ${t}`,hint:`Use this for a host app that integrates eve through ${n.importSpecifier}.`},{value:!1,label:`No, switch to eve`,hint:`Use this for a standalone eve agent.`}]})?`keep`:`switch-to-eve`}function sourceMentionsPackageSpecifier(e,t){return e.includes(`"${t}"`)||e.includes(`'${t}'`)||e.includes(`\`${t}\``)}async function directoryContainsPackageSpecifier(e,t){let n;try{n=await fs.readdir(e,{encoding:`utf8`,withFileTypes:!0})}catch{return!1}for(let r of n){let n=join(e,r.name);if(r.isDirectory()){if(FRAMEWORK_INTEGRATION_IGNORED_DIRECTORIES.has(r.name))continue;if(await directoryContainsPackageSpecifier(n,t))return!0;continue}if(!(!r.isFile()||!FRAMEWORK_INTEGRATION_SOURCE_EXTENSIONS.has(extname(r.name))))try{if(sourceMentionsPackageSpecifier(await fs.readFile(n,`utf8`),t))return!0}catch{continue}}return!1}async function detectFrameworkIntegrationImport(e,t){return directoryContainsPackageSpecifier(e,t)}async function resolveDetectedFrameworkAction(e,t,n,r){let i=EVE_FRAMEWORK_INTEGRATIONS[n];return i===void 0?`switch-to-eve`:await(r.detectFrameworkIntegrationImport??detectFrameworkIntegrationImport)(t,i.importSpecifier)?`keep`:r.headless?`switch-to-eve`:confirmDetectedFramework(e,n,i)}function frameworkPresetLabel(e){return EVE_FRAMEWORK_INTEGRATIONS[e]?.label??e}function describeError(e){return e instanceof Error?e.message:String(e)}async function syncHostFrameworkPreset(e,t,i,a){let o=await resolveVercelHostFrameworkPreset(t);if(o===void 0)return;let s=await readProjectLink(t);if(s===void 0)return;let c=frameworkPresetLabel(o),l;try{l=await fetchProjectFramework(t,s.orgId,s.projectId,a)}catch(t){if(a.signal?.aborted)throw t;e.log.warning(`Could not check this Vercel project's Framework Preset (${describeError(t)}). If it is not already ${c}, set it under Project Settings → Build and Deployment → Framework Settings before deploying.`);return}if(l===o)return;let u=l===void 0?void 0:frameworkPresetLabel(l),d=u===void 0?`had no Framework Preset set`:`was set to "${u}"`;try{await setProjectFramework(t,s.orgId,s.projectId,o,i,a)}catch(t){if(a.signal?.aborted)throw t;e.log.warning(`${describeError(t)} Set this Vercel project's Framework Preset to ${c} (Project Settings → Build and Deployment → Framework Settings) before deploying, or the deployment will not build your ${c} app.`);return}e.log.info(`This project uses ${c}, but its Vercel Framework Preset ${d}; switched it to ${c} so the deployment builds your app.`)}async function ensureCreatedProjectFramework(e,t,n,r,i,a){let o=await fetchProjectFramework(t,n,r,a);o!==`eve`&&(o===void 0?`switch-to-eve`:await resolveDetectedFrameworkAction(e,t,o,a))===`switch-to-eve`&&await setProjectFramework(t,n,r,`eve`,i,a)}export{ensureCreatedProjectFramework,syncHostFrameworkPreset};
@@ -165,6 +165,13 @@ export interface AgentLimitsDefinition {
165
165
  * These options are unstable and may change or be removed in any release.
166
166
  */
167
167
  export interface AgentExperimentalDefinition {
168
+ /**
169
+ * Keeps this agent's delegated subagent sessions alive after they answer.
170
+ * The model can pass `agentId` to a subagent tool to continue a previous
171
+ * delegation, and the system prompt documents the `<agents>` listing.
172
+ * When unset, delegated children run as one-shot tasks.
173
+ */
174
+ readonly subagentPersistentSessions?: boolean;
168
175
  /**
169
176
  * Durable Workflow runtime configuration. Root agents may use this to select
170
177
  * the Workflow world backing sessions and runs.
@@ -0,0 +1,47 @@
1
+ import { z } from "#compiled/zod/index.js";
2
+ import type { JsonValue } from "#shared/json.js";
3
+ import { type TokenUsage } from "#shared/token-usage.js";
4
+ /**
5
+ * What one delegated child turn produced, independent of whether the child
6
+ * session survived it.
7
+ */
8
+ export type AgentTurnResult = {
9
+ readonly kind: "succeeded";
10
+ readonly output: JsonValue;
11
+ } | {
12
+ readonly kind: "failed";
13
+ readonly error: JsonValue;
14
+ } | {
15
+ readonly kind: "cancelled";
16
+ };
17
+ /**
18
+ * How one delegated child turn settled.
19
+ *
20
+ * `parked` means the child session survived the turn and can accept another
21
+ * delivery; `terminal` means the child session ended with this turn. The
22
+ * lifecycle is carried explicitly: a failed turn can leave the child parked,
23
+ * and a succeeded turn can be terminal (task mode). Consumers must never
24
+ * infer lifecycle from success or error codes.
25
+ *
26
+ * `usageDelta` is the provider-reported usage this turn added to the child's
27
+ * session subtree: the child captures its session totals at turn entry and
28
+ * reports final-minus-entry when the turn settles. The parent folds each
29
+ * delta exactly once, so repeated turns of a persistent child never re-report
30
+ * earlier turns.
31
+ */
32
+ export type AgentTurnOutcome = {
33
+ readonly kind: "parked";
34
+ readonly result: AgentTurnResult;
35
+ readonly usageDelta: TokenUsage;
36
+ } | {
37
+ readonly kind: "terminal";
38
+ readonly result: AgentTurnResult;
39
+ readonly usageDelta: TokenUsage;
40
+ };
41
+ /**
42
+ * Zod schema for {@link AgentTurnOutcome}.
43
+ *
44
+ * Validates outcomes crossing the process boundary (remote session
45
+ * callbacks). Local notification paths construct the type directly.
46
+ */
47
+ export declare const agentTurnOutcomeSchema: z.ZodType<AgentTurnOutcome>;
@@ -0,0 +1 @@
1
+ import{z}from"#compiled/zod/index.js";import{tokenUsageSchema}from"#shared/token-usage.js";const jsonValueSchema=z.lazy(()=>z.union([z.null(),z.boolean(),z.number(),z.string(),z.array(jsonValueSchema),z.record(z.string(),jsonValueSchema)])),agentTurnResultSchema=z.discriminatedUnion(`kind`,[z.strictObject({kind:z.literal(`succeeded`),output:jsonValueSchema}),z.strictObject({error:jsonValueSchema,kind:z.literal(`failed`)}),z.strictObject({kind:z.literal(`cancelled`)})]),agentTurnOutcomeSchema=z.discriminatedUnion(`kind`,[z.strictObject({kind:z.literal(`parked`),result:agentTurnResultSchema,usageDelta:tokenUsageSchema}),z.strictObject({kind:z.literal(`terminal`),result:agentTurnResultSchema,usageDelta:tokenUsageSchema})]);export{agentTurnOutcomeSchema};
@@ -116,7 +116,7 @@ export declare const DYNAMIC_SENTINEL_KIND: "eve:dynamic";
116
116
  /**
117
117
  * Return value of `defineDynamic`: the runtime shape of a dynamic export,
118
118
  * stamped with a sentinel kind the compiler/normalizer detects. `TFallback`
119
- * is `never` except for dynamic agent models, the only slot with a fallback.
119
+ * is used by dynamic agent models.
120
120
  */
121
121
  export type DynamicSentinel<TResult = unknown, TFallback = never> = {
122
122
  readonly kind: typeof DYNAMIC_SENTINEL_KIND;
@@ -124,10 +124,6 @@ export type DynamicSentinel<TResult = unknown, TFallback = never> = {
124
124
  } & ([TFallback] extends [never] ? object : {
125
125
  readonly fallback: TFallback;
126
126
  });
127
- /**
128
- * Throws when a dynamic sentinel outside the agent `model` slot carries a
129
- * `fallback` — anywhere else it would be silently dead configuration.
130
- */
131
127
  export declare function rejectDynamicSentinelFallback(sentinel: DynamicSentinel, message: string): void;
132
128
  export declare function isDynamicSentinel(value: unknown): value is DynamicSentinel;
133
129
  /**
@@ -1 +1 @@
1
- const ALLOWED_DYNAMIC_TOOL_EVENTS=new Set([`session.started`,`turn.started`,`step.started`]),ALLOWED_DYNAMIC_INSTRUCTION_EVENTS=new Set([`session.started`,`turn.started`]),ALLOWED_DYNAMIC_SKILL_EVENTS=new Set([`session.started`,`turn.started`]),DYNAMIC_SENTINEL_KIND=`eve:dynamic`;function rejectDynamicSentinelFallback(e,t){if(`fallback`in e)throw Error(`${t} "fallback" is only supported on a dynamic agent model (the "model" field in agent.ts). For dynamic tools, skills, and instructions, author a static entry as the default or return null.`)}function isDynamicSentinel(e){return typeof e==`object`&&!!e&&e.kind===`eve:dynamic`}const TOOL_BRAND=Symbol.for(`eve:tool-brand`);function isBrandedToolEntry(e){return typeof e==`object`&&!!e&&e[TOOL_BRAND]===!0}const INSTRUCTIONS_BRAND=Symbol.for(`eve:instructions-brand`);function isBrandedInstructionsEntry(e){return typeof e==`object`&&!!e&&e[INSTRUCTIONS_BRAND]===!0}const SKILL_BRAND=Symbol.for(`eve:skill-brand`);function isBrandedSkillEntry(e){return typeof e==`object`&&!!e&&e[SKILL_BRAND]===!0}export{ALLOWED_DYNAMIC_INSTRUCTION_EVENTS,ALLOWED_DYNAMIC_SKILL_EVENTS,ALLOWED_DYNAMIC_TOOL_EVENTS,DYNAMIC_SENTINEL_KIND,INSTRUCTIONS_BRAND,SKILL_BRAND,TOOL_BRAND,isBrandedInstructionsEntry,isBrandedSkillEntry,isBrandedToolEntry,isDynamicSentinel,rejectDynamicSentinelFallback};
1
+ const ALLOWED_DYNAMIC_TOOL_EVENTS=new Set([`session.started`,`turn.started`,`step.started`]),ALLOWED_DYNAMIC_INSTRUCTION_EVENTS=new Set([`session.started`,`turn.started`]),ALLOWED_DYNAMIC_SKILL_EVENTS=new Set([`session.started`,`turn.started`]),DYNAMIC_SENTINEL_KIND=`eve:dynamic`;function rejectDynamicSentinelFallback(e,t){if(`fallback`in e)throw Error(`${t} "fallback" is only supported on a dynamic agent model. For dynamic tools, skills, instructions, and subagents, return null when the capability should be omitted.`)}function isDynamicSentinel(e){return typeof e==`object`&&!!e&&e.kind===`eve:dynamic`}const TOOL_BRAND=Symbol.for(`eve:tool-brand`);function isBrandedToolEntry(e){return typeof e==`object`&&!!e&&e[TOOL_BRAND]===!0}const INSTRUCTIONS_BRAND=Symbol.for(`eve:instructions-brand`);function isBrandedInstructionsEntry(e){return typeof e==`object`&&!!e&&e[INSTRUCTIONS_BRAND]===!0}const SKILL_BRAND=Symbol.for(`eve:skill-brand`);function isBrandedSkillEntry(e){return typeof e==`object`&&!!e&&e[SKILL_BRAND]===!0}export{ALLOWED_DYNAMIC_INSTRUCTION_EVENTS,ALLOWED_DYNAMIC_SKILL_EVENTS,ALLOWED_DYNAMIC_TOOL_EVENTS,DYNAMIC_SENTINEL_KIND,INSTRUCTIONS_BRAND,SKILL_BRAND,TOOL_BRAND,isBrandedInstructionsEntry,isBrandedSkillEntry,isBrandedToolEntry,isDynamicSentinel,rejectDynamicSentinelFallback};
@@ -29,6 +29,8 @@ export declare function isObject(value: unknown): value is Record<string, unknow
29
29
  * meaningful value by display or correlation logic.
30
30
  */
31
31
  export declare function isNonEmptyString(value: unknown): value is string;
32
+ /** Returns a non-empty string or `undefined` for any other value. */
33
+ export declare function readNonEmptyString(value: unknown): string | undefined;
32
34
  /**
33
35
  * Returns `true` when `value` is a thenable — an object with a `then`
34
36
  * function. Used to reject async instrumentation metadata projectors
@@ -1 +1 @@
1
- function isObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function isNonEmptyString(e){return typeof e==`string`&&e.length>0}function isThenable(e){return isObject(e)&&typeof e.then==`function`}function isErrnoCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function isPlainRecord(e){if(!isObject(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}export{isErrnoCode,isNonEmptyString,isObject,isPlainRecord,isThenable};
1
+ function isObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function isNonEmptyString(e){return typeof e==`string`&&e.length>0}function readNonEmptyString(e){return isNonEmptyString(e)?e:void 0}function isThenable(e){return isObject(e)&&typeof e.then==`function`}function isErrnoCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function isPlainRecord(e){if(!isObject(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}export{isErrnoCode,isNonEmptyString,isObject,isPlainRecord,isThenable,readNonEmptyString};
@@ -1 +1 @@
1
- import{dirname,join}from"node:path";import{mkdir,writeFile}from"node:fs/promises";import{resolveSandboxSkillRoot,resolveSandboxSkillWritePath}from"#shared/skill-paths.js";import{Buffer}from"node:buffer";function normalizeSkillPackage(e){assertSafeSkillPackageName(e.name);let t=[{content:Buffer.from(e.markdown,`utf8`),relativePath:`SKILL.md`}];for(let[n,r]of Object.entries(e.files??{}))assertSafeSkillPackageFilePath(n),t.push({content:contentToBuffer(r),relativePath:n});return t.sort((e,t)=>comparePaths(e.relativePath,t.relativePath)),{description:e.description,files:t,license:e.license,markdown:e.markdown,metadata:e.metadata===void 0?void 0:{...e.metadata},name:e.name}}async function writeSkillPackageDirectory(i){for(let a of i.skill.files){let o=join(i.rootPath,`skills`,i.skill.name,a.relativePath);await mkdir(dirname(o),{recursive:!0}),await writeFile(o,a.content)}}async function writeSkillPackageToSandbox(e){for(let t of e.skill.files)await e.sandbox.writeBinaryFile({content:t.content,path:await resolveSandboxSkillWritePath({name:e.skill.name,relativePath:t.relativePath,sandbox:e.sandbox})})}async function removeSkillPackageFromSandbox(e){assertSafeSkillPackageName(e.name);let t=await resolveSandboxSkillRoot({sandbox:e.sandbox});await e.sandbox.removePath({force:!0,path:`${t}/${e.name}`,recursive:!0})}function assertSafeSkillPackageName(e){if(e.length===0||e.startsWith(`.`)||e.includes(`/`)||e.includes(`\\`)||e.includes(`..`)||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(e)||/^[A-Za-z]:/.test(e))throw Error(`Expected skill name to be a non-empty shell-safe path segment starting with an alphanumeric character and containing only alphanumerics, ".", "_", or "-".`)}function assertSafeSkillPackageFilePath(e){if(e===`SKILL.md`)throw Error(`Skill package files must not include "SKILL.md"; eve generates it.`);if(e.length===0||e.startsWith(`/`)||e.includes(`\\`)||/^[A-Za-z]:/.test(e)||e.split(`/`).some(e=>e.length===0||e===`.`||e===`..`))throw Error(`Expected skill package file paths to be relative POSIX paths.`)}function contentToBuffer(e){return typeof e==`string`?Buffer.from(e,`utf8`):Buffer.from(e)}function comparePaths(e,t){return e<t?-1:+(e>t)}export{assertSafeSkillPackageName,normalizeSkillPackage,removeSkillPackageFromSandbox,writeSkillPackageDirectory,writeSkillPackageToSandbox};
1
+ import{mkdir,writeFile}from"node:fs/promises";import{dirname,join}from"node:path";import{resolveSandboxSkillRoot,resolveSandboxSkillWritePath}from"#shared/skill-paths.js";import{Buffer}from"node:buffer";function normalizeSkillPackage(e){assertSafeSkillPackageName(e.name);let t=[{content:Buffer.from(e.markdown,`utf8`),relativePath:`SKILL.md`}];for(let[n,r]of Object.entries(e.files??{}))assertSafeSkillPackageFilePath(n),t.push({content:contentToBuffer(r),relativePath:n});return t.sort((e,t)=>comparePaths(e.relativePath,t.relativePath)),{description:e.description,files:t,license:e.license,markdown:e.markdown,metadata:e.metadata===void 0?void 0:{...e.metadata},name:e.name}}async function writeSkillPackageDirectory(i){for(let a of i.skill.files){let o=join(i.rootPath,`skills`,i.skill.name,a.relativePath);await mkdir(dirname(o),{recursive:!0}),await writeFile(o,a.content)}}async function writeSkillPackageToSandbox(e){for(let t of e.skill.files)await e.sandbox.writeBinaryFile({content:t.content,path:await resolveSandboxSkillWritePath({name:e.skill.name,relativePath:t.relativePath,sandbox:e.sandbox})})}async function removeSkillPackageFromSandbox(e){assertSafeSkillPackageName(e.name);let t=await resolveSandboxSkillRoot({sandbox:e.sandbox});await e.sandbox.removePath({force:!0,path:`${t}/${e.name}`,recursive:!0})}function assertSafeSkillPackageName(e){if(e.length===0||e.startsWith(`.`)||e.includes(`/`)||e.includes(`\\`)||e.includes(`..`)||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(e)||/^[A-Za-z]:/.test(e))throw Error(`Expected skill name to be a non-empty shell-safe path segment starting with an alphanumeric character and containing only alphanumerics, ".", "_", or "-".`)}function assertSafeSkillPackageFilePath(e){if(e===`SKILL.md`)throw Error(`Skill package files must not include "SKILL.md"; eve generates it.`);if(e.length===0||e.startsWith(`/`)||e.includes(`\\`)||/^[A-Za-z]:/.test(e)||e.split(`/`).some(e=>e.length===0||e===`.`||e===`..`))throw Error(`Expected skill package file paths to be relative POSIX paths.`)}function contentToBuffer(e){return typeof e==`string`?Buffer.from(e,`utf8`):Buffer.from(e)}function comparePaths(e,t){return e<t?-1:+(e>t)}export{assertSafeSkillPackageName,normalizeSkillPackage,removeSkillPackageFromSandbox,writeSkillPackageDirectory,writeSkillPackageToSandbox};
@@ -9,6 +9,10 @@ export declare function formatFallbackSkillPath(input: {
9
9
  readonly name: string;
10
10
  readonly relativePath: string;
11
11
  }): string;
12
+ /**
13
+ * Resolves where skills live in the sandbox: under the probed home when it has
14
+ * one, and under {@link FALLBACK_SKILL_ROOT} when it does not.
15
+ */
12
16
  export declare function resolveSandboxSkillRoot(input: {
13
17
  readonly sandbox: SandboxSession;
14
18
  }): Promise<string>;
@@ -32,7 +36,3 @@ export declare function resolveSandboxSkillWritePath(input: {
32
36
  readonly relativePath: string;
33
37
  readonly sandbox: SandboxSession;
34
38
  }): Promise<string>;
35
- export declare function resolveSandboxSeedFilePath(input: {
36
- readonly path: string;
37
- readonly sandbox: SandboxSession;
38
- }): Promise<string>;
@@ -1,2 +1,2 @@
1
- const MODEL_SKILL_ROOT=`$HOME/.agents/skills`,FALLBACK_SKILL_ROOT=`/workspace/skills`,MODEL_HOME_ROOT=`$HOME`,sandboxHomeCache=new WeakMap;function formatSkillModelPath(t){return formatSkillPath({name:t.name,relativePath:t.relativePath,root:MODEL_SKILL_ROOT})}function formatFallbackSkillPath(e){return formatSkillPath({name:e.name,relativePath:e.relativePath,root:FALLBACK_SKILL_ROOT})}async function resolveSandboxSkillRoot(e){let n=await resolveSandboxHome(e.sandbox);return n===null?FALLBACK_SKILL_ROOT:joinHomeSkillRoot(n)}async function resolveSandboxModelPath(e){if(!isModelHomePath(e.path))return e.path;let n=await resolveSandboxHome(e.sandbox);if(n!==null){let t=e.path.slice(5);return t.length===0?n:`${n===`/`?``:n}${t}`}return isModelSkillPath(e.path)?`${FALLBACK_SKILL_ROOT}${e.path.slice(20)}`:e.path}async function resolveSandboxSkillReadPaths(e){return[formatSkillPath({name:e.name,relativePath:e.relativePath,root:await resolveSandboxSkillRoot({sandbox:e.sandbox})})]}async function resolveSandboxSkillWritePath(e){return formatSkillPath({name:e.name,relativePath:e.relativePath,root:await resolveSandboxSkillRoot({sandbox:e.sandbox})})}async function resolveSandboxSeedFilePath(e){return isModelSkillPath(e.path)?await resolveSandboxModelPath(e):e.path}function formatSkillPath(e){return`${e.root}/${e.name}/${e.relativePath}`}async function resolveSandboxHome(e){let t=sandboxHomeCache.get(e);if(t!==void 0)return await t;let n=probeSandboxHome(e);return sandboxHomeCache.set(e,n),await n}async function probeSandboxHome(e){try{let t=await e.run({command:`printf '%s\\n' "$HOME"`});if(t.exitCode!==0)return null;let n=t.stdout.trim();return isUsableSandboxHome(n)?normalizeSandboxHome(n):null}catch{return null}}function isModelHomePath(e){return e===MODEL_HOME_ROOT||e.startsWith(`${MODEL_HOME_ROOT}/`)}function isModelSkillPath(e){return e===`$HOME/.agents/skills`||e.startsWith(`$HOME/.agents/skills/`)}function isUsableSandboxHome(e){return e.length>0&&e.startsWith(`/`)&&!e.includes(`\0`)&&!e.includes(`
2
- `)&&!e.includes(`\r`)}function joinHomeSkillRoot(e){return`${e===`/`?``:e}/.agents/skills`}function normalizeSandboxHome(e){return e===`/`?e:e.replace(/\/+$/,``)}export{FALLBACK_SKILL_ROOT,MODEL_SKILL_ROOT,formatFallbackSkillPath,formatSkillModelPath,resolveSandboxModelPath,resolveSandboxSeedFilePath,resolveSandboxSkillReadPaths,resolveSandboxSkillRoot,resolveSandboxSkillWritePath};
1
+ const MODEL_HOME_ROOT=`$HOME`,MODEL_SKILL_ROOT=`${MODEL_HOME_ROOT}/.agents/skills`,FALLBACK_SKILL_ROOT=`/workspace/skills`,sandboxHomeCache=new WeakMap;function formatSkillModelPath(e){return formatSkillPath({name:e.name,relativePath:e.relativePath,root:MODEL_SKILL_ROOT})}function formatFallbackSkillPath(e){return formatSkillPath({name:e.name,relativePath:e.relativePath,root:FALLBACK_SKILL_ROOT})}async function resolveSandboxSkillRoot(e){return await resolveSandboxModelPath({path:MODEL_SKILL_ROOT,sandbox:e.sandbox})}async function resolveSandboxModelPath(e){if(!isModelHomePath(e.path))return e.path;let r=await resolveSandboxHome(e.sandbox);if(r!==null){let t=e.path.slice(5);return t.length===0?r:`${r===`/`?``:r}${t}`}return isModelSkillPath(e.path)?`${FALLBACK_SKILL_ROOT}${e.path.slice(MODEL_SKILL_ROOT.length)}`:e.path}async function resolveSandboxSkillReadPaths(e){return[formatSkillPath({name:e.name,relativePath:e.relativePath,root:await resolveSandboxSkillRoot({sandbox:e.sandbox})})]}async function resolveSandboxSkillWritePath(e){return formatSkillPath({name:e.name,relativePath:e.relativePath,root:await resolveSandboxSkillRoot({sandbox:e.sandbox})})}function formatSkillPath(e){return`${e.root}/${e.name}/${e.relativePath}`}async function resolveSandboxHome(e){let t=sandboxHomeCache.get(e);if(t!==void 0)return await t;let n=probeSandboxHome(e);return sandboxHomeCache.set(e,n),await n}async function probeSandboxHome(e){try{let t=await e.run({command:`printf '%s\\n' "$HOME"`});if(t.exitCode!==0)return null;let n=t.stdout.trim();return isUsableSandboxHome(n)?normalizeSandboxHome(n):null}catch{return null}}function isModelHomePath(t){return t===MODEL_HOME_ROOT||t.startsWith(`${MODEL_HOME_ROOT}/`)}function isModelSkillPath(e){return e===MODEL_SKILL_ROOT||e.startsWith(`${MODEL_SKILL_ROOT}/`)}function isUsableSandboxHome(e){return e.length>0&&e.startsWith(`/`)&&!e.includes(`\0`)&&!e.includes(`
2
+ `)&&!e.includes(`\r`)}function normalizeSandboxHome(e){return e===`/`?e:e.replace(/\/+$/,``)}export{FALLBACK_SKILL_ROOT,MODEL_SKILL_ROOT,formatFallbackSkillPath,formatSkillModelPath,resolveSandboxModelPath,resolveSandboxSkillReadPaths,resolveSandboxSkillRoot,resolveSandboxSkillWritePath};
@@ -1 +1 @@
1
- import{dirname,join}from"node:path";import{stat}from"node:fs/promises";async function fileExists(e){try{return(await stat(e)).isFile()}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}async function findClosestDirectoryWithFile(t){let n=t.start;for(;;){let r=join(n,t.directoryName);if(await fileExists(join(r,t.fileName)))return r;let i=dirname(n);if(i===n)return;n=i}}async function findClosestLinkedVercelDirectory(e){return findClosestDirectoryWithFile({start:e,directoryName:`.vercel`,fileName:`project.json`})}async function findClosestVercelOutputDirectory(e){return findClosestDirectoryWithFile({start:e,directoryName:`output`,fileName:`builds.json`})}export{findClosestLinkedVercelDirectory,findClosestVercelOutputDirectory};
1
+ import{stat}from"node:fs/promises";import{dirname,join}from"node:path";async function fileExists(t){try{return(await stat(t)).isFile()}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}async function findClosestDirectoryWithFile(e){let n=e.start;for(;;){let r=join(n,e.directoryName);if(await fileExists(join(r,e.fileName)))return r;let i=dirname(n);if(i===n)return;n=i}}async function findClosestLinkedVercelDirectory(e){return findClosestDirectoryWithFile({start:e,directoryName:`.vercel`,fileName:`project.json`})}async function findClosestVercelOutputDirectory(e){return findClosestDirectoryWithFile({start:e,directoryName:`output`,fileName:`builds.json`})}export{findClosestLinkedVercelDirectory,findClosestVercelOutputDirectory};
@@ -1 +1 @@
1
- import{join}from"node:path";import{readFile,rename,writeFile}from"node:fs/promises";import{checkAgentConfigSource}from"#source-change/agent-config-string-path.js";import{applyAgentModelSettingsToSource}from"#source-change/apply-agent-model-settings.js";import{applyModelNameToSource}from"#source-change/apply-model-name.js";function createStaticSourceChange(e){return{updateModelName:t=>updateAgentModelName(e,t),updateModelSettings:t=>updateAgentModelSettings(e,t)}}async function updateAgentModelSettings(n,r){let i=n.configModule;if(i===void 0)return{kind:`bail`,reason:`agent has no agent.ts config module to edit`,at:{logicalPath:`agent.ts`,line:1}};let o=join(n.agentRoot,i.logicalPath),s=await readFile(o,`utf8`),c=await applyAgentModelSettingsToSource(s,r);if(c.kind===`bail`)return{kind:`bail`,reason:c.reason,at:{logicalPath:i.logicalPath,line:c.line}};let l=await editedSourceBail(s,c.nextSource,i.logicalPath);return l===void 0?(await writeSourceIfChanged(o,s,c.nextSource),{kind:`applied`,changed:c.changed}):l}async function updateAgentModelName(n,r){let i=n.configModule;if(i===void 0)return{kind:`bail`,reason:`agent has no agent.ts config module to edit`,at:{logicalPath:`agent.ts`,line:1}};let a=join(n.agentRoot,i.logicalPath),s=await readFile(a,`utf8`),c=await applyModelNameToSource(s,r);if(c.kind===`bail`)return{kind:`bail`,reason:c.reason,at:{logicalPath:i.logicalPath,line:c.line}};let l=await editedSourceBail(s,c.nextSource,i.logicalPath);return l===void 0?(await writeSourceIfChanged(a,s,c.nextSource),{kind:`applied`,from:c.from,to:c.to}):l}async function writeSourceIfChanged(e,t,i){if(i===t)return;let a=`${e}.${process.pid}.eve-tmp`;await writeFile(a,i,`utf8`),await rename(a,e)}async function editedSourceBail(e,t,n){if(t===e)return;let r=await checkAgentConfigSource(t);if(r!==void 0)return{kind:`bail`,reason:`the edit produced source eve refuses to write (${r})`,at:{logicalPath:n,line:1}}}export{createStaticSourceChange};
1
+ import{readFile,rename,writeFile}from"node:fs/promises";import{join}from"node:path";import{checkAgentConfigSource}from"#source-change/agent-config-string-path.js";import{applyAgentModelSettingsToSource}from"#source-change/apply-agent-model-settings.js";import{applyModelNameToSource}from"#source-change/apply-model-name.js";function createStaticSourceChange(e){return{updateModelName:t=>updateAgentModelName(e,t),updateModelSettings:t=>updateAgentModelSettings(e,t)}}async function updateAgentModelSettings(t,n){let i=t.configModule;if(i===void 0)return{kind:`bail`,reason:`agent has no agent.ts config module to edit`,at:{logicalPath:`agent.ts`,line:1}};let o=join(t.agentRoot,i.logicalPath),s=await readFile(o,`utf8`),c=await applyAgentModelSettingsToSource(s,n);if(c.kind===`bail`)return{kind:`bail`,reason:c.reason,at:{logicalPath:i.logicalPath,line:c.line}};let l=await editedSourceBail(s,c.nextSource,i.logicalPath);return l===void 0?(await writeSourceIfChanged(o,s,c.nextSource),{kind:`applied`,changed:c.changed}):l}async function updateAgentModelName(t,n){let i=t.configModule;if(i===void 0)return{kind:`bail`,reason:`agent has no agent.ts config module to edit`,at:{logicalPath:`agent.ts`,line:1}};let a=join(t.agentRoot,i.logicalPath),s=await readFile(a,`utf8`),c=await applyModelNameToSource(s,n);if(c.kind===`bail`)return{kind:`bail`,reason:c.reason,at:{logicalPath:i.logicalPath,line:c.line}};let l=await editedSourceBail(s,c.nextSource,i.logicalPath);return l===void 0?(await writeSourceIfChanged(a,s,c.nextSource),{kind:`applied`,from:c.from,to:c.to}):l}async function writeSourceIfChanged(e,r,i){if(i===r)return;let a=`${e}.${process.pid}.eve-tmp`;await writeFile(a,i,`utf8`),await rename(a,e)}async function editedSourceBail(e,t,n){if(t===e)return;let r=await checkAgentConfigSource(t);if(r!==void 0)return{kind:`bail`,reason:`the edit produced source eve refuses to write (${r})`,at:{logicalPath:n,line:1}}}export{createStaticSourceChange};
@@ -1,3 +1,3 @@
1
- import { n as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-DaH3cf8K.js";
1
+ import { n as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-BXMIf5fR.js";
2
2
 
3
3
  export { defaultMessageReducer, useEveAgent };
@@ -1,3 +1,3 @@
1
- import { t as useEveAgent } from "../chunks/use-eve-agent-DaH3cf8K.js";
1
+ import { t as useEveAgent } from "../chunks/use-eve-agent-BXMIf5fR.js";
2
2
 
3
3
  export { useEveAgent };
@@ -1 +1 @@
1
- import{LocalTraceSpanProcessor}from"#tracing/local-trace-span-processor.js";import{ContextAgentTraceStateStore}from"#tracing/agent-trace-context-store.js";import{getInstrumentationRuntime,registerInstrumentationRuntime}from"#harness/instrumentation-runtime.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{registerOTel}from"#compiled/@vercel/otel/index.js";import{createAgentOtelInstrumentation}from"#tracing/agent-otel-provider.js";import{AgentTraceSpanProcessor}from"#tracing/agent-trace-span-processor.js";import{createInstrumentationHooks}from"#harness/instrumentation-lifecycle.js";import{requestLocalTraceStorePrune,resolveLocalTraceRetentionSettings}from"#tracing/local-trace-retention.js";function installLocalInstrumentationRuntime(t){let n=getInstrumentationRuntime();if(n!==void 0)return n;let r=resolveLocalTraceRetentionSettings(),i=new AgentTraceSpanProcessor(r.enabled?[new LocalTraceSpanProcessor(t.appRoot)]:[]);registerOTel({autoDetectResources:!1,instrumentations:[],propagators:[`none`],serviceName:t.serviceName,spanProcessors:[i]});let a=trace.getTracer(`eve.registration`).startSpan(`eve.otel.registration`),o=trace.setSpan(context.active(),a),s=context.with(o,()=>trace.getActiveSpan()===a);if(a.end(),!i.isAttached()||!s)throw Error(`eve could not register OpenTelemetry because another runtime already exists.`);let c=createAgentOtelInstrumentation({captureContent:process.env.EVE_TRACES_CONTENT!==`off`,frameworkVersion:t.frameworkVersion,stateStore:new ContextAgentTraceStateStore,tracer:trace.getTracer(`eve.agent`,t.frameworkVersion)}),l={events:{"session.completed":releaseSessionTrace,"session.failed":releaseSessionTrace}};return requestPrune(),registerInstrumentationRuntime({forceFlush:()=>i.forceFlush(),hooks:createInstrumentationHooks([c.hook,l]),runInContext:c.runInContext});async function releaseSessionTrace(e){await i.forceFlush(),i.releaseSession(e.sessionId)&&requestPrune()}function requestPrune(){r.enabled&&requestLocalTraceStorePrune({activeTraceIds:i.activeTraceIds(),appRoot:t.appRoot,maxAgeMs:r.maxAgeMs,maxTotalBytes:r.maxTotalBytes,retainCount:r.retainCount})}}export{installLocalInstrumentationRuntime};
1
+ import{ContextAgentTraceStateStore}from"#tracing/agent-trace-context-store.js";import{getInstrumentationRuntime,registerInstrumentationRuntime}from"#harness/instrumentation-runtime.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{registerOTel}from"#compiled/@vercel/otel/index.js";import{createAgentOtelInstrumentation}from"#tracing/agent-otel-provider.js";import{AgentTraceSpanProcessor}from"#tracing/agent-trace-span-processor.js";import{createInstrumentationHooks}from"#harness/instrumentation-lifecycle.js";import{requestLocalTraceStorePrune,resolveLocalTraceRetentionSettings}from"#tracing/local-trace-retention.js";import{LocalTraceSpanProcessor}from"#tracing/local-trace-span-processor.js";function installLocalInstrumentationRuntime(t){let n=getInstrumentationRuntime();if(n!==void 0)return n;let r=resolveLocalTraceRetentionSettings(),i=new AgentTraceSpanProcessor(r.enabled?[new LocalTraceSpanProcessor(t.appRoot)]:[]);registerOTel({autoDetectResources:!1,instrumentations:[],propagators:[`none`],serviceName:t.serviceName,spanProcessors:[i]});let a=trace.getTracer(`eve.registration`).startSpan(`eve.otel.registration`),o=trace.setSpan(context.active(),a),s=context.with(o,()=>trace.getActiveSpan()===a);if(a.end(),!i.isAttached()||!s)throw Error(`eve could not register OpenTelemetry because another runtime already exists.`);let c=createAgentOtelInstrumentation({captureContent:process.env.EVE_TRACES_CONTENT!==`off`,frameworkVersion:t.frameworkVersion,stateStore:new ContextAgentTraceStateStore,tracer:trace.getTracer(`eve.agent`,t.frameworkVersion)}),l={events:{"session.completed":releaseSessionTrace,"session.failed":releaseSessionTrace}};return requestPrune(),registerInstrumentationRuntime({forceFlush:()=>i.forceFlush(),hooks:createInstrumentationHooks([c.hook,l]),runInContext:c.runInContext});async function releaseSessionTrace(e){await i.forceFlush(),i.releaseSession(e.sessionId)&&requestPrune()}function requestPrune(){r.enabled&&requestLocalTraceStorePrune({activeTraceIds:i.activeTraceIds(),appRoot:t.appRoot,maxAgeMs:r.maxAgeMs,maxTotalBytes:r.maxTotalBytes,retainCount:r.retainCount})}}export{installLocalInstrumentationRuntime};
@@ -36,13 +36,30 @@ export interface LocalTrace {
36
36
  /** Zero-based session window this trace holds, when the spans record one. */
37
37
  readonly window?: number;
38
38
  }
39
- /** Reads valid local traces, newest first, while ignoring malformed segments. */
40
- export declare function listLocalTraces(appRoot: string): Promise<LocalTrace[]>;
41
39
  /**
42
- * Reads one trace from its segments directory, or `undefined` when the trace
43
- * has no valid spans. Spans come back ordered by start time.
40
+ * Trace ids held by the spool, unordered. Empty when nothing has been written
41
+ * yet; any other read fault propagates.
42
+ */
43
+ export declare function listLocalTraceIds(appRoot: string): Promise<string[]>;
44
+ /**
45
+ * Instant one trace last received a span, or `undefined` once retention has
46
+ * pruned it. Reads the segments directory's mtime, so it stays cheap enough to
47
+ * poll a large spool without parsing any span.
48
+ */
49
+ export declare function readLocalTraceActivityMs(appRoot: string, traceId: string): Promise<number | undefined>;
50
+ /**
51
+ * Segment file names of one trace in read order, or `undefined` when the trace
52
+ * is gone. Segments are immutable and named for their span, so the order is
53
+ * stable across reads and a caller can treat names it has seen as parsed.
54
+ */
55
+ export declare function listLocalTraceSegments(appRoot: string, traceId: string): Promise<string[] | undefined>;
56
+ /**
57
+ * Spans held by one segment file. An oversized, unreadable, or malformed
58
+ * segment yields none, so a partial write never breaks a view.
44
59
  */
45
- export declare function readLocalTrace(root: string, traceId: string): Promise<LocalTrace | undefined>;
60
+ export declare function readLocalTraceSegment(appRoot: string, traceId: string, fileName: string): Promise<LocalTraceSpan[]>;
61
+ /** Reads valid local traces, newest first, while ignoring malformed segments. */
62
+ export declare function listLocalTraces(appRoot: string): Promise<LocalTrace[]>;
46
63
  /** Sorts spans into timeline order: start, then end, then a stable tiebreak. */
47
64
  export declare function compareLocalTraceSpans(left: LocalTraceSpan, right: LocalTraceSpan): number;
48
65
  /** Builds a trace from already-parsed spans, deriving summary fields. */
@@ -1 +1 @@
1
- import{join}from"node:path";import{readFile,readdir,stat}from"node:fs/promises";import{resolveLocalTraceSchemaDirectory}from"#tracing/local-trace-span-processor.js";const TRACE_ID_PATTERN=/^[0-9a-f]{32}$/u,SPAN_FILE_PATTERN=/^([0-9a-f]{16})\.otlp\.json$/u;async function listLocalTraces(e){let t=resolveLocalTraceSchemaDirectory(e),r;try{r=await readdir(t,{withFileTypes:!0})}catch(e){if(isMissing(e))return[];throw e}let o=[];for(let e of r){if(!e.isDirectory()||!TRACE_ID_PATTERN.test(e.name))continue;let n=await readLocalTrace(t,e.name).catch(()=>void 0);n!==void 0&&o.push(n)}return o.sort((e,t)=>e.startTimeNs===t.startTimeNs?e.traceId.localeCompare(t.traceId):e.startTimeNs>t.startTimeNs?-1:1)}async function readLocalTrace(i,a){let s=join(i,a,`segments`),c;try{c=await readdir(s,{withFileTypes:!0})}catch(e){if(isMissing(e))return;throw e}let l=new Map;for(let n of c.sort((e,t)=>e.name.localeCompare(t.name))){if(!n.isFile()||!SPAN_FILE_PATTERN.test(n.name))continue;let i;try{let a=join(s,n.name);if((await stat(a)).size>8388608)continue;i=await readFile(a,`utf8`)}catch{continue}for(let e of parseLocalTraceSegment(i,a))l.has(e.spanId)||l.set(e.spanId,e)}if(l.size!==0)return assembleLocalTrace(a,[...l.values()])}function compareLocalTraceSpans(e,t){return e.startTimeNs===t.startTimeNs?e.endTimeNs===t.endTimeNs?e.name.localeCompare(t.name)||e.spanId.localeCompare(t.spanId):e.endTimeNs<t.endTimeNs?-1:1:e.startTimeNs<t.startTimeNs?-1:1}function assembleLocalTrace(e,t){let n=[...t].sort(compareLocalTraceSpans),r=n.map(e=>e.attributes),i=distinctAttributes(r,`agent.session.id`);return{agentName:firstAttribute(r,`agent.name`),endTimeNs:n.reduce((e,t)=>t.endTimeNs>e?t.endTimeNs:e,0n),sessionId:i[0],sessionIds:i,spans:n,startTimeNs:n.reduce((e,t)=>t.startTimeNs<e?t.startTimeNs:e,n[0].startTimeNs),traceId:e,window:firstNumberAttribute(r,`agent.session.window`)}}function describeLocalTraceSpan(e){let t=[],n=stringSpanAttribute(e,`agent.turn.id`),r=valueSpanAttribute(e,`agent.step.index`),i=valueSpanAttribute(e,`agent.step.attempt`),a=stringSpanAttribute(e,`agent.action.kind`),o=stringSpanAttribute(e,`agent.action.name`),s=stringSpanAttribute(e,`agent.model.id`)??stringSpanAttribute(e,`gen_ai.request.model`);return e.name===`agent.turn`&&n!==void 0&&t.push(n),e.name===`agent.step`&&r!==void 0&&t.push(`step ${String(r)}${i===void 0?``:`, attempt ${String(i)}`}`),e.name===`agent.action`&&o!==void 0&&t.push(`${a??`action`}: ${o}`),s!==void 0&&e.name.includes(`do`)&&t.push(`model ${s}`),t}function parseLocalTraceSegment(e,t){try{let n=JSON.parse(e);if(!isRecord(n)||!Array.isArray(n.resourceSpans))return[];let r=[];for(let e of n.resourceSpans)if(!(!isRecord(e)||!Array.isArray(e.scopeSpans)))for(let n of e.scopeSpans){if(!isRecord(n)||!Array.isArray(n.spans))continue;let e=isRecord(n.scope)&&typeof n.scope.name==`string`?n.scope.name:void 0;for(let i of n.spans){let n=parseLocalTraceSpan(i,t,e);n!==void 0&&r.push(n)}}return r}catch{return[]}}function parseLocalTraceSpan(e,t,n){if(!isRecord(e)||e.traceId!==t||typeof e.spanId!=`string`||!/^[0-9a-f]{16}$/u.test(e.spanId)||typeof e.name!=`string`)return;let r=parseNanos(e.startTimeUnixNano),i=parseNanos(e.endTimeUnixNano);if(!(r===void 0||i===void 0||i<r))return{attributes:parseAttributes(e.attributes),endTimeNs:i,name:e.name,parentSpanId:typeof e.parentSpanId==`string`&&/^[0-9a-f]{16}$/u.test(e.parentSpanId)?e.parentSpanId:void 0,scope:n,spanId:e.spanId,startTimeNs:r,statusCode:parseStatusCode(e.status),traceId:t}}function parseAttributes(e){if(!Array.isArray(e))return{};let t={};for(let n of e){if(!isRecord(n)||typeof n.key!=`string`||!isRecord(n.value))continue;let e=parseAnyValue(n.value);e!==void 0&&(t[n.key]=e)}return t}function parseAnyValue(e){for(let t of[`stringValue`,`boolValue`,`intValue`,`doubleValue`])if(t in e)return e[t];if(isRecord(e.arrayValue)&&Array.isArray(e.arrayValue.values))return e.arrayValue.values.filter(isRecord).map(e=>parseAnyValue(e))}function parseNanos(e){if(!(typeof e!=`string`&&typeof e!=`number`))try{let t=BigInt(e);return t>=0n&&t<=18446744073709551615n?t:void 0}catch{return}}function parseStatusCode(e){return isRecord(e)?typeof e.code==`number`?e.code:e.code===`STATUS_CODE_ERROR`?2:0:0}function firstAttribute(e,t){for(let n of e){let e=n[t];if(typeof e==`string`&&e.length>0)return e}}function firstNumberAttribute(e,t){for(let n of e){let e=n[t];if(typeof e==`number`)return e;if(typeof e==`bigint`)return Number(e)}}function distinctAttributes(e,t){let n=new Set;for(let r of e){let e=r[t];typeof e==`string`&&e.length>0&&n.add(e)}return[...n]}function stringSpanAttribute(e,t){let n=e.attributes[t];return typeof n==`string`?n:void 0}function valueSpanAttribute(e,t){let n=e.attributes[t];return typeof n==`string`||typeof n==`number`?n:void 0}function isMissing(e){return e.code===`ENOENT`}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{assembleLocalTrace,compareLocalTraceSpans,describeLocalTraceSpan,listLocalTraces,parseLocalTraceSegment,readLocalTrace};
1
+ import{readFile,readdir,stat}from"node:fs/promises";import{join}from"node:path";import{resolveLocalTraceSchemaDirectory,resolveLocalTraceSegmentsDirectory}from"#tracing/local-trace-span-processor.js";const TRACE_ID_PATTERN=/^[0-9a-f]{32}$/u,SPAN_FILE_PATTERN=/^[0-9a-f]{16}\.otlp\.json$/u;async function listLocalTraceIds(e){let n;try{n=await readdir(resolveLocalTraceSchemaDirectory(e),{withFileTypes:!0})}catch(e){if(isMissing(e))return[];throw e}return n.filter(e=>e.isDirectory()&&TRACE_ID_PATTERN.test(e.name)).map(e=>e.name)}async function readLocalTraceActivityMs(e,t){try{return(await stat(resolveLocalTraceSegmentsDirectory(e,t))).mtimeMs}catch(e){if(isMissing(e))return;throw e}}async function listLocalTraceSegments(e,n){let r;try{r=await readdir(resolveLocalTraceSegmentsDirectory(e,n),{withFileTypes:!0})}catch(e){if(isMissing(e))return;throw e}return r.filter(e=>e.isFile()&&SPAN_FILE_PATTERN.test(e.name)).map(e=>e.name).sort((e,t)=>e.localeCompare(t))}async function readLocalTraceSegment(t,i,o){let s=join(resolveLocalTraceSegmentsDirectory(t,i),o),c;try{if((await stat(s)).size>8388608)return[];c=await readFile(s,`utf8`)}catch{return[]}return parseLocalTraceSegment(c,i)}async function listLocalTraces(e){let t=[];for(let n of await listLocalTraceIds(e)){let r=await readLocalTrace(e,n).catch(()=>void 0);r!==void 0&&t.push(r)}return t.sort((e,t)=>e.startTimeNs===t.startTimeNs?e.traceId.localeCompare(t.traceId):e.startTimeNs>t.startTimeNs?-1:1)}async function readLocalTrace(e,t){let n=await listLocalTraceSegments(e,t);if(n===void 0)return;let r=new Map;for(let i of n)for(let n of await readLocalTraceSegment(e,t,i))r.has(n.spanId)||r.set(n.spanId,n);if(r.size!==0)return assembleLocalTrace(t,[...r.values()])}function compareLocalTraceSpans(e,t){return e.startTimeNs===t.startTimeNs?e.endTimeNs===t.endTimeNs?e.name.localeCompare(t.name)||e.spanId.localeCompare(t.spanId):e.endTimeNs<t.endTimeNs?-1:1:e.startTimeNs<t.startTimeNs?-1:1}function assembleLocalTrace(e,t){let n=[...t].sort(compareLocalTraceSpans),r=n.map(e=>e.attributes),i=distinctAttributes(r,`agent.session.id`);return{agentName:firstAttribute(r,`agent.name`),endTimeNs:n.reduce((e,t)=>t.endTimeNs>e?t.endTimeNs:e,0n),sessionId:i[0],sessionIds:i,spans:n,startTimeNs:n.reduce((e,t)=>t.startTimeNs<e?t.startTimeNs:e,n[0].startTimeNs),traceId:e,window:firstNumberAttribute(r,`agent.session.window`)}}function describeLocalTraceSpan(e){let t=[],n=stringSpanAttribute(e,`agent.turn.id`),r=valueSpanAttribute(e,`agent.step.index`),i=valueSpanAttribute(e,`agent.step.attempt`),a=stringSpanAttribute(e,`agent.action.kind`),o=stringSpanAttribute(e,`agent.action.name`),s=stringSpanAttribute(e,`agent.model.id`)??stringSpanAttribute(e,`gen_ai.request.model`);return e.name===`agent.turn`&&n!==void 0&&t.push(n),e.name===`agent.step`&&r!==void 0&&t.push(`step ${String(r)}${i===void 0?``:`, attempt ${String(i)}`}`),e.name===`agent.action`&&o!==void 0&&t.push(`${a??`action`}: ${o}`),s!==void 0&&e.name.includes(`do`)&&t.push(`model ${s}`),t}function parseLocalTraceSegment(e,t){try{let n=JSON.parse(e);if(!isRecord(n)||!Array.isArray(n.resourceSpans))return[];let r=[];for(let e of n.resourceSpans)if(!(!isRecord(e)||!Array.isArray(e.scopeSpans)))for(let n of e.scopeSpans){if(!isRecord(n)||!Array.isArray(n.spans))continue;let e=isRecord(n.scope)&&typeof n.scope.name==`string`?n.scope.name:void 0;for(let i of n.spans){let n=parseLocalTraceSpan(i,t,e);n!==void 0&&r.push(n)}}return r}catch{return[]}}function parseLocalTraceSpan(e,t,n){if(!isRecord(e)||e.traceId!==t||typeof e.spanId!=`string`||!/^[0-9a-f]{16}$/u.test(e.spanId)||typeof e.name!=`string`)return;let r=parseNanos(e.startTimeUnixNano),i=parseNanos(e.endTimeUnixNano);if(!(r===void 0||i===void 0||i<r))return{attributes:parseAttributes(e.attributes),endTimeNs:i,name:e.name,parentSpanId:typeof e.parentSpanId==`string`&&/^[0-9a-f]{16}$/u.test(e.parentSpanId)?e.parentSpanId:void 0,scope:n,spanId:e.spanId,startTimeNs:r,statusCode:parseStatusCode(e.status),traceId:t}}function parseAttributes(e){if(!Array.isArray(e))return{};let t={};for(let n of e){if(!isRecord(n)||typeof n.key!=`string`||!isRecord(n.value))continue;let e=parseAnyValue(n.value);e!==void 0&&(t[n.key]=e)}return t}function parseAnyValue(e){for(let t of[`stringValue`,`boolValue`,`intValue`,`doubleValue`])if(t in e)return e[t];if(isRecord(e.arrayValue)&&Array.isArray(e.arrayValue.values))return e.arrayValue.values.filter(isRecord).map(e=>parseAnyValue(e))}function parseNanos(e){if(!(typeof e!=`string`&&typeof e!=`number`))try{let t=BigInt(e);return t>=0n&&t<=18446744073709551615n?t:void 0}catch{return}}function parseStatusCode(e){return isRecord(e)?typeof e.code==`number`?e.code:e.code===`STATUS_CODE_ERROR`?2:0:0}function firstAttribute(e,t){for(let n of e){let e=n[t];if(typeof e==`string`&&e.length>0)return e}}function firstNumberAttribute(e,t){for(let n of e){let e=n[t];if(typeof e==`number`)return e;if(typeof e==`bigint`)return Number(e)}}function distinctAttributes(e,t){let n=new Set;for(let r of e){let e=r[t];typeof e==`string`&&e.length>0&&n.add(e)}return[...n]}function stringSpanAttribute(e,t){let n=e.attributes[t];return typeof n==`string`?n:void 0}function valueSpanAttribute(e,t){let n=e.attributes[t];return typeof n==`string`||typeof n==`number`?n:void 0}function isMissing(e){return e.code===`ENOENT`}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{assembleLocalTrace,compareLocalTraceSpans,describeLocalTraceSpan,listLocalTraceIds,listLocalTraceSegments,listLocalTraces,parseLocalTraceSegment,readLocalTraceActivityMs,readLocalTraceSegment};
@@ -1 +1 @@
1
- import{createLogger,formatError}from"#internal/logging.js";import{join}from"node:path";import{readdir,rm,stat}from"node:fs/promises";import{resolveLocalTraceSchemaDirectory,resolveLocalTraceSegmentsDirectory}from"#tracing/local-trace-span-processor.js";const log=createLogger(`harness.local-trace-retention`),LOCAL_TRACE_QUIESCENCE_MS=300*1e3,LOCAL_TRACE_MAX_AGE_MS=10080*60*1e3,LOCAL_TRACE_MAX_TOTAL_BYTES=512*1024*1024;function resolveLocalTraceRetentionSettings(e=process.env){return{enabled:!isDisabled(e.EVE_TRACES),maxAgeMs:readBound(e,`EVE_TRACES_MAX_AGE_MS`,LOCAL_TRACE_MAX_AGE_MS),maxTotalBytes:readBound(e,`EVE_TRACES_MAX_TOTAL_BYTES`,LOCAL_TRACE_MAX_TOTAL_BYTES),retainCount:readBound(e,`EVE_TRACES_RETAIN_COUNT`,20)}}async function pruneLocalTraceStore(e){let t=e.now??Date.now(),n=clampBound(e.maxAgeMs??LOCAL_TRACE_MAX_AGE_MS),r=clampBound(e.maxTotalBytes??LOCAL_TRACE_MAX_TOTAL_BYTES),a=clampCount(e.retainCount??20),o=await readStoredTraces(e.appRoot,t),s=[...o].sort((e,t)=>t.modifiedAtMs-e.modifiedAtMs),c=new Set(s.slice(0,a===!1?0:a)),l=new Set,u=o.reduce((e,t)=>e+t.byteSize,0),d=0,f=0,p=0;for(let a of s.toReversed()){let o=t-a.modifiedAtMs,s=e.activeTraceIds.has(a.traceId)||c.has(a)||o<=LOCAL_TRACE_QUIESCENCE_MS?void 0:n!==!1&&o>n?`maxAgeMs`:r!==!1&&u>r?`maxTotalBytes`:void 0;if(s===void 0){p+=1;continue}await rm(a.path,{force:!0,recursive:!0}),u-=a.byteSize,d+=a.byteSize,f+=1,l.add(s)}return{reasons:[...l],reclaimedBytes:d,removedTraces:f,retainedTraces:p}}const pruneRequest={input:{activeTraceIds:new Set,appRoot:``},requested:!1,running:void 0};function requestLocalTraceStorePrune(e){pruneRequest.input=e,pruneRequest.requested=!0,pruneRequest.running===void 0&&startPruning()}function startPruning(){pruneRequest.running=(async()=>{for(;pruneRequest.requested;)pruneRequest.requested=!1,report(await pruneLocalTraceStore(pruneRequest.input))})().catch(e=>{log.warn(`local trace retention failed`,{error:formatError(e)})}).finally(()=>{pruneRequest.running=void 0,pruneRequest.requested&&startPruning()})}function report(e){e.removedTraces!==0&&log.info(`pruned local traces`,{reasons:e.reasons.join(`,`),reclaimedBytes:e.reclaimedBytes,removedTraces:e.removedTraces,retainedTraces:e.retainedTraces})}async function readStoredTraces(e,t){let r=resolveLocalTraceSchemaDirectory(e),i=await readDirectoryEntries(r);return i===void 0?[]:(await Promise.all(i.filter(e=>e.isDirectory()).map(async i=>{let a=join(r,i.name),o=resolveLocalTraceSegmentsDirectory(e,i.name);await reapAbandonedTemporaryFiles(o,t);let c=await directoryMtime(o)??await directoryMtime(a);if(c!==void 0)return{byteSize:await directorySize(a),modifiedAtMs:c,path:a,traceId:i.name}}))).filter(e=>e!==void 0)}async function reapAbandonedTemporaryFiles(e,t){let r=await readDirectoryEntries(e);if(r!==void 0)for(let o of r){if(!o.isFile()||!o.name.includes(`.tmp-`))continue;let r=join(e,o.name);try{if(t-(await stat(r)).mtimeMs<=LOCAL_TRACE_QUIESCENCE_MS)continue;await rm(r,{force:!0})}catch{}}}async function directoryMtime(e){try{return(await stat(e)).mtimeMs}catch{return}}async function directorySize(e){let t=await readDirectoryEntries(e);if(t===void 0)return 0;let r=0;for(let i of t){let t=join(e,i.name);if(i.isDirectory()){r+=await directorySize(t);continue}try{r+=(await stat(t)).size}catch{}}return r}async function readDirectoryEntries(e){try{return await readdir(e,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`))return;throw e}}function isDisabled(e){if(e===void 0)return!1;let t=e.trim().toLowerCase();return t===`off`||t===`false`||t===`0`}function readBound(e,t,n){let r=e[t];if(r===void 0)return n;let i=r.trim().toLowerCase();if(i===`off`||i===`false`)return!1;let a=Number(i);return!Number.isFinite(a)||a<0?(log.warn(`ignoring invalid local trace retention value`,{fallback:n,name:t,value:r}),n):a}function clampBound(e){return e!==!1&&Math.max(0,e)}function clampCount(e){return e!==!1&&Math.max(0,Math.trunc(e))}export{pruneLocalTraceStore,requestLocalTraceStorePrune,resolveLocalTraceRetentionSettings};
1
+ import{readdir,rm,stat}from"node:fs/promises";import{createLogger,formatError}from"#internal/logging.js";import{join}from"node:path";import{resolveLocalTraceSchemaDirectory,resolveLocalTraceSegmentsDirectory}from"#tracing/local-trace-span-processor.js";const log=createLogger(`harness.local-trace-retention`),LOCAL_TRACE_QUIESCENCE_MS=300*1e3,LOCAL_TRACE_MAX_AGE_MS=10080*60*1e3,LOCAL_TRACE_MAX_TOTAL_BYTES=512*1024*1024;function resolveLocalTraceRetentionSettings(e=process.env){return{enabled:!isDisabled(e.EVE_TRACES),maxAgeMs:readBound(e,`EVE_TRACES_MAX_AGE_MS`,LOCAL_TRACE_MAX_AGE_MS),maxTotalBytes:readBound(e,`EVE_TRACES_MAX_TOTAL_BYTES`,LOCAL_TRACE_MAX_TOTAL_BYTES),retainCount:readBound(e,`EVE_TRACES_RETAIN_COUNT`,20)}}async function pruneLocalTraceStore(e){let n=e.now??Date.now(),r=clampBound(e.maxAgeMs??LOCAL_TRACE_MAX_AGE_MS),i=clampBound(e.maxTotalBytes??LOCAL_TRACE_MAX_TOTAL_BYTES),a=clampCount(e.retainCount??20),o=await readStoredTraces(e.appRoot,n),s=[...o].sort((e,t)=>t.modifiedAtMs-e.modifiedAtMs),c=new Set(s.slice(0,a===!1?0:a)),l=new Set,u=o.reduce((e,t)=>e+t.byteSize,0),d=0,f=0,p=0;for(let a of s.toReversed()){let o=n-a.modifiedAtMs,s=e.activeTraceIds.has(a.traceId)||c.has(a)||o<=LOCAL_TRACE_QUIESCENCE_MS?void 0:r!==!1&&o>r?`maxAgeMs`:i!==!1&&u>i?`maxTotalBytes`:void 0;if(s===void 0){p+=1;continue}await rm(a.path,{force:!0,recursive:!0}),u-=a.byteSize,d+=a.byteSize,f+=1,l.add(s)}return{reasons:[...l],reclaimedBytes:d,removedTraces:f,retainedTraces:p}}const pruneRequest={input:{activeTraceIds:new Set,appRoot:``},requested:!1,running:void 0};function requestLocalTraceStorePrune(e){pruneRequest.input=e,pruneRequest.requested=!0,pruneRequest.running===void 0&&startPruning()}function startPruning(){pruneRequest.running=(async()=>{for(;pruneRequest.requested;)pruneRequest.requested=!1,report(await pruneLocalTraceStore(pruneRequest.input))})().catch(e=>{log.warn(`local trace retention failed`,{error:formatError(e)})}).finally(()=>{pruneRequest.running=void 0,pruneRequest.requested&&startPruning()})}function report(e){e.removedTraces!==0&&log.info(`pruned local traces`,{reasons:e.reasons.join(`,`),reclaimedBytes:e.reclaimedBytes,removedTraces:e.removedTraces,retainedTraces:e.retainedTraces})}async function readStoredTraces(e,t){let n=resolveLocalTraceSchemaDirectory(e),r=await readDirectoryEntries(n);return r===void 0?[]:(await Promise.all(r.filter(e=>e.isDirectory()).map(async r=>{let i=join(n,r.name),o=resolveLocalTraceSegmentsDirectory(e,r.name);await reapAbandonedTemporaryFiles(o,t);let c=await directoryMtime(o)??await directoryMtime(i);if(c!==void 0)return{byteSize:await directorySize(i),modifiedAtMs:c,path:i,traceId:r.name}}))).filter(e=>e!==void 0)}async function reapAbandonedTemporaryFiles(e,r){let i=await readDirectoryEntries(e);if(i!==void 0)for(let o of i){if(!o.isFile()||!o.name.includes(`.tmp-`))continue;let i=join(e,o.name);try{if(r-(await stat(i)).mtimeMs<=LOCAL_TRACE_QUIESCENCE_MS)continue;await rm(i,{force:!0})}catch{}}}async function directoryMtime(e){try{return(await stat(e)).mtimeMs}catch{return}}async function directorySize(e){let t=await readDirectoryEntries(e);if(t===void 0)return 0;let r=0;for(let i of t){let t=join(e,i.name);if(i.isDirectory()){r+=await directorySize(t);continue}try{r+=(await stat(t)).size}catch{}}return r}async function readDirectoryEntries(t){try{return await readdir(t,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`))return;throw e}}function isDisabled(e){if(e===void 0)return!1;let t=e.trim().toLowerCase();return t===`off`||t===`false`||t===`0`}function readBound(e,t,n){let r=e[t];if(r===void 0)return n;let i=r.trim().toLowerCase();if(i===`off`||i===`false`)return!1;let a=Number(i);return!Number.isFinite(a)||a<0?(log.warn(`ignoring invalid local trace retention value`,{fallback:n,name:t,value:r}),n):a}function clampBound(e){return e!==!1&&Math.max(0,e)}function clampCount(e){return e!==!1&&Math.max(0,Math.trunc(e))}export{pruneLocalTraceStore,requestLocalTraceStorePrune,resolveLocalTraceRetentionSettings};
@@ -1 +1 @@
1
- import{createLogger,formatError}from"#internal/logging.js";import{join}from"node:path";import{mkdir}from"node:fs/promises";import{atomicWriteFile}from"#shared/atomic-write-file.js";import{JsonTraceSerializer}from"#compiled/@opentelemetry/otlp-transformer/index.js";const log=createLogger(`harness.local-trace-span-processor`);function resolveLocalTraceStoreDirectory(e){return join(e,`.eve`,`traces`)}function resolveLocalTraceSchemaDirectory(e){return join(resolveLocalTraceStoreDirectory(e),`v1`)}function resolveLocalTraceSegmentsDirectory(e,t){return join(resolveLocalTraceSchemaDirectory(e),t,`segments`)}var LocalTraceSpanProcessor=class{#e;#t=Promise.resolve();#n=!1;constructor(e){this.#e=e}forceFlush(){return this.#t}onStart(){}onEnd(e){if(!isReadableSpan(e))return;let{spanId:n,traceId:r}=e.spanContext();if(!isHexId(r,32)||!isHexId(n,16))return;let i=JsonTraceSerializer.serializeRequest([e]);i!==void 0&&(this.#t=this.#t.then(async()=>{let e=resolveLocalTraceSegmentsDirectory(this.#e,r);await mkdir(e,{recursive:!0}),await atomicWriteFile(join(e,`${n}.otlp.json`),i)}).catch(e=>{this.#n||(this.#n=!0,log.warn(`local trace persistence failed`,{error:formatError(e)}))}))}shutdown(){return this.forceFlush()}};function isReadableSpan(e){return typeof e==`object`&&!!e&&`attributes`in e&&`spanContext`in e&&typeof e.spanContext==`function`}function isHexId(e,t){return e.length===t&&/^[0-9a-f]+$/u.test(e)}export{LocalTraceSpanProcessor,resolveLocalTraceSchemaDirectory,resolveLocalTraceSegmentsDirectory};
1
+ import{mkdir}from"node:fs/promises";import{createLogger,formatError}from"#internal/logging.js";import{join}from"node:path";import{atomicWriteFile}from"#shared/atomic-write-file.js";import{JsonTraceSerializer}from"#compiled/@opentelemetry/otlp-transformer/index.js";const log=createLogger(`harness.local-trace-span-processor`);function resolveLocalTraceStoreDirectory(e){return join(e,`.eve`,`traces`)}function resolveLocalTraceSchemaDirectory(e){return join(resolveLocalTraceStoreDirectory(e),`v1`)}function resolveLocalTraceSegmentsDirectory(e,t){return join(resolveLocalTraceSchemaDirectory(e),t,`segments`)}var LocalTraceSpanProcessor=class{#e;#t=Promise.resolve();#n=!1;constructor(e){this.#e=e}forceFlush(){return this.#t}onStart(){}onEnd(t){if(!isReadableSpan(t))return;let{spanId:n,traceId:r}=t.spanContext();if(!isHexId(r,32)||!isHexId(n,16))return;let i=JsonTraceSerializer.serializeRequest([t]);i!==void 0&&(this.#t=this.#t.then(async()=>{let t=resolveLocalTraceSegmentsDirectory(this.#e,r);await mkdir(t,{recursive:!0}),await atomicWriteFile(join(t,`${n}.otlp.json`),i)}).catch(e=>{this.#n||(this.#n=!0,log.warn(`local trace persistence failed`,{error:formatError(e)}))}))}shutdown(){return this.forceFlush()}};function isReadableSpan(e){return typeof e==`object`&&!!e&&`attributes`in e&&`spanContext`in e&&typeof e.spanContext==`function`}function isHexId(e,t){return e.length===t&&/^[0-9a-f]+$/u.test(e)}export{LocalTraceSpanProcessor,resolveLocalTraceSchemaDirectory,resolveLocalTraceSegmentsDirectory};
@@ -1,3 +1,3 @@
1
- import { n as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-CyDt3Lny.js";
1
+ import { n as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-k-XHfrJT.js";
2
2
 
3
3
  export { defaultMessageReducer, useEveAgent };
@@ -1,3 +1,3 @@
1
- import { t as useEveAgent } from "../chunks/use-eve-agent-CyDt3Lny.js";
1
+ import { t as useEveAgent } from "../chunks/use-eve-agent-k-XHfrJT.js";
2
2
 
3
3
  export { useEveAgent };
@@ -48,6 +48,8 @@ Declare routes with the `POST()` and `GET()` helpers. Each route handler receive
48
48
 
49
49
  - `send(message, { auth, continuationToken, state?, title? })` starts or resumes a session. `title` overrides the new workflow session's display title without changing the model message. Returns a `Session`.
50
50
  - `cancel({ continuationToken, turnId? })` requests cancellation of the active turn on the session that owns the token. See [Cancel a turn](#cancel-a-turn).
51
+ - `clear({ continuationToken })` removes the model-message history while preserving the session and its durable resources. See [Clear session context](#clear-session-context).
52
+ - `compact({ continuationToken })` queues context compaction for the session that owns the token without sending model input. See [Compact a session](#compact-a-session).
51
53
  - `reset({ continuationToken, reason? })` retires the session that owns the token so the next `send()` starts a fresh session. See [Reset a session](#reset-a-session).
52
54
  - `getSession(sessionId)` looks up an existing session. The returned `Session` exposes `getEventStream({ startIndex? })` for streaming, `getStreamTailIndex()` for resolving the durable tail when a route wants to serve bounded reads, and `cancel({ turnId? })` for session-id-addressed cancellation.
53
55
  - `receive(channel, ...)` hands inbound work to a different channel for cross-channel hand-off.
@@ -86,6 +88,44 @@ Semantics:
86
88
 
87
89
  When you already hold a `Session` — returned by `send()` or `getSession(sessionId)` — call `session.cancel({ turnId? })` to request the same cancellation addressed by session id.
88
90
 
91
+ ## Clear session context
92
+
93
+ Call `clear` with the channel-local continuation token to remove a session's durable model-message history without replacing the session:
94
+
95
+ ```ts
96
+ import { defineChannel, POST } from "eve/channels";
97
+
98
+ export default defineChannel({
99
+ routes: [
100
+ POST("/threads/:threadId/clear", async (_req, { clear, params }) => {
101
+ const result = await clear({ continuationToken: params.threadId });
102
+ return Response.json(result);
103
+ }),
104
+ ],
105
+ });
106
+ ```
107
+
108
+ `"accepted"` means the clear was queued. The stream emits `context.cleared` followed by `session.waiting`, after which the next ordinary message resumes the same session with no prior model messages. The system prompt, configured tools and skills, durable state, limits, continuation-token ownership, and session-scoped sandbox remain. `"no_active_session"` means the token has no current owner.
109
+
110
+ ## Compact a session
111
+
112
+ Call `compact` with the channel-local continuation token to summarize durable conversation history without delivering a command to the model:
113
+
114
+ ```ts
115
+ import { defineChannel, POST } from "eve/channels";
116
+
117
+ export default defineChannel({
118
+ routes: [
119
+ POST("/threads/:threadId/compact", async (_req, { compact, params }) => {
120
+ const result = await compact({ continuationToken: params.threadId });
121
+ return Response.json(result);
122
+ }),
123
+ ],
124
+ });
125
+ ```
126
+
127
+ `"accepted"` means the durable session queued the operation. A successful compaction emits `compaction.requested` followed by `compaction.completed`, then the operation returns through `session.waiting`. If summarization fails, the stream returns through `session.waiting` without `compaction.completed` and preserves the previous history. If a turn is active, eve runs the compaction after that turn settles; it does not cancel the turn. `"no_active_session"` means the token has no current owner. Both outcomes are successful, and compaction never starts a session or appends a synthetic user message.
128
+
89
129
  ## Reset a session
90
130
 
91
131
  Identity-addressed channels can consume commands such as `/new` in their route, without sending the command to the model. Call `reset` with the same channel-local continuation token used by `send()`:
@@ -160,7 +200,7 @@ export default defineChannel({
160
200
  });
161
201
  ```
162
202
 
163
- `WS()` handlers receive the same helpers as HTTP route handlers: `send`, `cancel`, `reset`, `getSession`, `receive`, `params`, `waitUntil`, and `requestIp`. The returned hooks are eve-owned structural types compatible with Nitro/H3 websocket routing, including `upgrade`, `open`, `message`, `close`, and `error`.
203
+ `WS()` handlers receive the same helpers as HTTP route handlers: `send`, `cancel`, `clear`, `compact`, `reset`, `getSession`, `receive`, `params`, `waitUntil`, and `requestIp`. The returned hooks are eve-owned structural types compatible with Nitro/H3 websocket routing, including `upgrade`, `open`, `message`, `close`, and `error`.
164
204
 
165
205
  ### Node upgrade server escape hatch
166
206
 
@@ -4,27 +4,43 @@ description: "Reach your agent from Discord HTTP Interactions, including slash c
4
4
  type: integration
5
5
  ---
6
6
 
7
- The Discord channel wires your agent into Discord's HTTP Interactions, including slash and application commands, message components, and modal submissions. Discord enforces a three-second ACK deadline, so the channel verifies the Ed25519 signature headers, acknowledges the command right away, and runs the eve work in the background. See [Channels](./overview) for the contract this builds on.
7
+ The Discord channel wires your agent into Discord's HTTP Interactions, including slash and application commands, message components, and modal submissions. Discord enforces a three-second ACK deadline, so the channel acknowledges the command right away and runs the eve work in the background. Credentials and inbound request verification run through [Vercel Connect](../guides/auth-and-route-protection), so Discord's bot token stays out of your environment and Connect verifies Discord's signature before forwarding an interaction to eve. See [Channels](./overview) for the contract this builds on.
8
8
 
9
- ## Add the channel
9
+ ## Set up Discord
10
10
 
11
- ```ts title="agent/channels/discord.ts"
12
- import { discordChannel } from "eve/channels/discord";
11
+ Run the guided setup from your eve project:
13
12
 
14
- export default discordChannel();
13
+ ```bash
14
+ pnpm eve add channel/discord
15
15
  ```
16
16
 
17
- ```bash
18
- DISCORD_PUBLIC_KEY=... # verifies X-Signature-Ed25519 + X-Signature-Timestamp
19
- DISCORD_APPLICATION_ID=... # edits the deferred response and sends followups
20
- DISCORD_BOT_TOKEN=... # proactive messages + fallback + typing indicators
17
+ The setup guides you through creating a Discord application and bot, then:
18
+
19
+ - validates the bot token;
20
+ - creates a Vercel Connect client and attaches `/eve/v1/discord` as its trigger destination;
21
+ - registers an application command with a required `message` option;
22
+ - configures the Discord application's Interactions Endpoint URL;
23
+ - scaffolds the channel with Connect-managed credentials; and
24
+ - prints the bot installation URL.
25
+
26
+ The command defaults to `/ask` with the description **Ask the eve agent**. You can edit both during setup. Discord global commands can take up to an hour to appear after registration.
27
+
28
+ The generated channel looks like this:
29
+
30
+ ```ts title="agent/channels/discord.ts"
31
+ import { connectDiscordCredentials } from "@vercel/connect/eve";
32
+ import { discordChannel } from "eve/channels/discord";
33
+
34
+ export default discordChannel({
35
+ credentials: connectDiscordCredentials("discord/my-agent"),
36
+ });
21
37
  ```
22
38
 
23
- To skip env vars, pass the same values through `credentials: { applicationId, botToken, publicKey }`. The route is `POST /eve/v1/discord` by default. Paste that public URL into your Discord application's Interactions Endpoint URL.
39
+ The route is `POST /eve/v1/discord` by default. Connect resolves the application ID and bot token lazily and verifies forwarded interactions with same-project Vercel OIDC.
24
40
 
25
- ## Register a command
41
+ ### Configure Discord manually
26
42
 
27
- Registering commands is on you, not the channel. Use Discord's API or the Developer Portal. A string option named `message` lines up with eve's default prompt extraction:
43
+ If you do not use the guided Connect setup, register a command with Discord's API or the Developer Portal. A string option named `message` lines up with eve's default prompt extraction:
28
44
 
29
45
  ```bash
30
46
  curl -X PUT "https://discord.com/api/v10/applications/$DISCORD_APPLICATION_ID/commands" \
@@ -33,7 +49,7 @@ curl -X PUT "https://discord.com/api/v10/applications/$DISCORD_APPLICATION_ID/co
33
49
  "options":[{"name":"message","description":"What should the agent do?","type":3,"required":true}]}]'
34
50
  ```
35
51
 
36
- Use guild commands during development for faster propagation.
52
+ Then configure the public `https://…/eve/v1/discord` route as the application's Interactions Endpoint URL. Pass `credentials: { applicationId, botToken, publicKey }` to `discordChannel`, or set the corresponding `DISCORD_APPLICATION_ID`, `DISCORD_BOT_TOKEN`, and `DISCORD_PUBLIC_KEY` environment variables.
37
53
 
38
54
  ## How the channel handles messages
39
55
 
@@ -74,7 +90,7 @@ HITL renders as Discord components. Confirmations and options become buttons, `d
74
90
 
75
91
  ### Proactive sessions
76
92
 
77
- Start a session without an inbound interaction through `receive(discord, { message, target, auth })` from a schedule `run` handler, or `args.receive(discord, ...)` from another channel. The proactive target shape is `{ channelId, conversationId?, initialMessage? }`. Either path needs `DISCORD_BOT_TOKEN`.
93
+ Start a session without an inbound interaction through `receive(discord, { message, target, auth })` from a schedule `run` handler, or `args.receive(discord, ...)` from another channel. The proactive target shape is `{ channelId, conversationId?, initialMessage? }`. Either path needs a bot token, supplied by Connect or `DISCORD_BOT_TOKEN`.
78
94
 
79
95
  ### Attachments
80
96
 
@@ -18,13 +18,16 @@ export default eveChannel({
18
18
 
19
19
  ## Routes
20
20
 
21
- The application exposes a health route plus eve channel routes that inspect the agent, create sessions, send follow-ups, cancel turns, and stream events:
21
+ The application exposes a health route plus eve channel routes that inspect the agent, create sessions, send follow-ups, cancel turns, compact or reset sessions, and stream events:
22
22
 
23
23
  - `GET /eve/v1/health`
24
24
  - `GET /eve/v1/info`
25
25
  - `POST /eve/v1/session` (start a session)
26
26
  - `POST /eve/v1/session/:sessionId` (send a follow-up)
27
27
  - `POST /eve/v1/session/:sessionId/cancel` (cancel the in-flight turn)
28
+ - `POST /eve/v1/session/clear` (clear the continuation owner's model history)
29
+ - `POST /eve/v1/session/compact` (compact the continuation owner's context)
30
+ - `POST /eve/v1/session/reset` (retire the continuation owner)
28
31
  - `GET /eve/v1/session/:sessionId/stream` (stream events, NDJSON)
29
32
 
30
33
  Start a session with a minimal body. The response returns `sessionId` and the `continuationToken` you reuse for follow-ups:
@@ -54,6 +57,28 @@ curl -X POST https://<deployment>/eve/v1/session/ses_01h.../cancel
54
57
 
55
58
  Cancellation is asynchronous: `"accepted"` means a cancellation hook accepted the request. Confirm the effective outcome on the stream as `turn.cancelled` followed by `session.waiting` — never as a failure. Active local and remote subagents are cancelled recursively before the parent settles; their own streams carry their cancellation boundaries, and cancelled work does not emit `subagent.completed` on the parent. Content emitted before the cancel stays on the event stream, while durable model history keeps only content that had already settled. The session accepts the next message normally. When there is no resumable cancellation target (including an unknown session, a settled turn, or a duplicate cancel), the route responds with `"no_active_turn"` — also a success, so a stop button can fire and forget. A `turnId` naming any other turn is accepted and consumed as a no-op, so a guarded cancel racing a turn boundary cannot stop a turn the caller never saw.
56
59
 
60
+ Clear the model-message history of the session that owns a continuation token:
61
+
62
+ ```bash
63
+ curl -X POST https://<deployment>/eve/v1/session/clear \
64
+ -H "Content-Type: application/json" \
65
+ -d '{"continuationToken":"eve:7f3c..."}'
66
+ # {"ok":true,"sessionId":"ses_01h...","status":"accepted"}
67
+ ```
68
+
69
+ An accepted clear emits `context.cleared` followed by `session.waiting`. The next message resumes the same session without prior model messages; the system prompt, tools and skills, durable state, limits, and session-scoped sandbox remain.
70
+
71
+ Compact the session that owns a continuation token without sending a message:
72
+
73
+ ```bash
74
+ curl -X POST https://<deployment>/eve/v1/session/compact \
75
+ -H "Content-Type: application/json" \
76
+ -d '{"continuationToken":"eve:7f3c..."}'
77
+ # {"ok":true,"sessionId":"ses_01h...","status":"accepted"}
78
+ ```
79
+
80
+ Compaction is asynchronous. A successful operation emits `compaction.requested` and `compaction.completed`, then returns through `session.waiting`; when a turn is active, the operation waits for it to settle. If summarization fails, the session still returns to `session.waiting` with its previous history. `"no_active_session"` is the successful no-op response when the token has no owner.
81
+
57
82
  See [Sessions, runs & streaming](../concepts/sessions-runs-and-streaming) for the full request and stream flow, including the complete event set.
58
83
 
59
84
  ## CORS
@@ -20,6 +20,10 @@ export default defineAgent({
20
20
 
21
21
  Compaction also preserves the framework's own tool state automatically. It resets read-before-write tracking (so a write afterward re-reads the file whose read evidence was summarized away) and re-injects the active todo list, so the model keeps its task list across the summary. There is no per-tool hook to configure.
22
22
 
23
+ Clients and channels can also request compaction between turns. Call `ClientSession.compact()` or a custom route's `compact({ continuationToken })` helper. The request does not append a user message; if a turn is running, eve queues it until that turn settles. A successful manual compaction emits the same `compaction.requested` and `compaction.completed` events as automatic compaction, followed by `session.waiting`.
24
+
25
+ To discard model-message history instead of summarizing it, call `ClientSession.clear()` or a custom route's `clear({ continuationToken })` helper. Clearing preserves the session identity, system prompt, configured tools and skills, durable state, limits, and sandbox. Its stream boundary is `context.cleared` followed by `session.waiting`.
26
+
23
27
  ## Built-in tools
24
28
 
25
29
  Built-in tools require no imports. The exact set depends on the agent and session. `agent` is available only in the root session; `load_skill` and `connection_search` appear only when the agent declares the corresponding resources; `ask_question` requires a session that can request user input; and `web_search` requires a supported model provider. The harness advertises only the tools available to the current session.