eve 0.85.0 → 0.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/CHANGELOG.md +34 -3073
  2. package/README.md +7 -4
  3. package/dist/src/acp/adapter.d.ts +2 -26
  4. package/dist/src/acp/adapter.js +1 -1
  5. package/dist/src/acp/server.d.ts +0 -3
  6. package/dist/src/ai/decision-adapter.d.ts +5 -3
  7. package/dist/src/ai/decision-adapter.js +1 -1
  8. package/dist/src/ai/decision-types.d.ts +4 -3
  9. package/dist/src/channel/adapter.d.ts +0 -14
  10. package/dist/src/channel/auth/definitions.d.ts +0 -4
  11. package/dist/src/channel/channel-address.d.ts +1 -1
  12. package/dist/src/channel/channel-address.js +1 -1
  13. package/dist/src/channel/channel-operations.d.ts +2 -2
  14. package/dist/src/channel/channel-operations.js +1 -1
  15. package/dist/src/channel/prompt-queue.d.ts +0 -2
  16. package/dist/src/channel/session-not-active-error.d.ts +10 -5
  17. package/dist/src/channel/session-not-active-error.js +1 -1
  18. package/dist/src/channel/session-stranded-error.d.ts +1 -1
  19. package/dist/src/channel/session.d.ts +3 -4
  20. package/dist/src/channel/session.js +1 -1
  21. package/dist/src/channel/types.d.ts +5 -14
  22. package/dist/src/chunks/{use-eve-agent-B2jCfcnG.js → use-eve-agent-BExXjBv6.js} +82 -72
  23. package/dist/src/chunks/{use-eve-agent-DCLFi26P.js → use-eve-agent-C0KHCyb9.js} +82 -72
  24. package/dist/src/cli/commands/agent-prompt/collect-intent.md +2 -1
  25. package/dist/src/cli/commands/agent-prompt/scaffold.md +1 -2
  26. package/dist/src/cli/dev/command-options.d.ts +4 -4
  27. package/dist/src/cli/dev/command.js +1 -1
  28. package/dist/src/cli/dev/tui/runner.d.ts +1 -1
  29. package/dist/src/cli/dev/tui/runner.js +2 -2
  30. package/dist/src/cli/dev/tui/test/fake-eve-server.js +1 -1
  31. package/dist/src/cli/dev/tui/tool-format.d.ts +2 -2
  32. package/dist/src/cli/dev/ui-options.d.ts +4 -4
  33. package/dist/src/cli/dev/ui-options.js +1 -1
  34. package/dist/src/cli/run.js +1 -1
  35. package/dist/src/client/agent-info-error.d.ts +4 -1
  36. package/dist/src/client/agent-info-error.js +1 -1
  37. package/dist/src/client/agent-session.d.ts +1 -4
  38. package/dist/src/client/agent-session.js +1 -1
  39. package/dist/src/client/agent-stream-follower.js +1 -1
  40. package/dist/src/client/client-error.d.ts +13 -4
  41. package/dist/src/client/client-error.js +1 -1
  42. package/dist/src/client/delivery.d.ts +2 -17
  43. package/dist/src/client/health-response-error.d.ts +4 -1
  44. package/dist/src/client/health-response-error.js +1 -1
  45. package/dist/src/client/index.d.ts +5 -3
  46. package/dist/src/client/index.js +1 -1
  47. package/dist/src/client/open-stream.d.ts +7 -12
  48. package/dist/src/client/open-stream.js +1 -1
  49. package/dist/src/client/session-controls.d.ts +2 -2
  50. package/dist/src/client/session-controls.js +1 -1
  51. package/dist/src/client/session-event-stream.d.ts +2 -2
  52. package/dist/src/client/session-event-stream.js +1 -1
  53. package/dist/src/client/session-store.d.ts +2 -6
  54. package/dist/src/client/session-store.js +1 -1
  55. package/dist/src/client/session.d.ts +4 -13
  56. package/dist/src/client/session.js +1 -1
  57. package/dist/src/client/sessions.d.ts +3 -6
  58. package/dist/src/client/types.d.ts +23 -32
  59. package/dist/src/compiled/.vendor-stamp.json +4 -4
  60. package/dist/src/compiled/@vercel/agent-runs/LICENSE +202 -0
  61. package/dist/src/compiled/@vercel/schedules/index.d.ts +45 -6
  62. package/dist/src/compiled/@vercel/schedules/index.js +2 -2
  63. package/dist/src/compiler/manifest.js +1 -1
  64. package/dist/src/compiler/normalize-agent-config.js +1 -1
  65. package/dist/src/compiler/normalize-connection.d.ts +1 -1
  66. package/dist/src/compiler/normalize-connection.js +1 -1
  67. package/dist/src/compiler/normalize-instructions.js +1 -1
  68. package/dist/src/compiler/normalize-skill.js +1 -1
  69. package/dist/src/compiler/resolve-workspace-subagent.js +1 -1
  70. package/dist/src/context/memory-tools.d.ts +9 -5
  71. package/dist/src/discover/sandbox.js +1 -1
  72. package/dist/src/dynamic/definition.d.ts +11 -5
  73. package/dist/src/dynamic/definition.js +1 -1
  74. package/dist/src/evals/mock-model.d.ts +1 -1
  75. package/dist/src/evals/session-manager.d.ts +0 -2
  76. package/dist/src/evals/session.d.ts +1 -11
  77. package/dist/src/evals/session.js +1 -1
  78. package/dist/src/eve-channel/index.js +1 -1
  79. package/dist/src/eve-channel/support.js +1 -1
  80. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  81. package/dist/src/execution/effective-agent-config.js +1 -1
  82. package/dist/src/execution/proxied-deliver-step.js +1 -1
  83. package/dist/src/execution/sandbox/bindings/just-bash-runtime.d.ts +1 -2
  84. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  85. package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
  86. package/dist/src/execution/session/active-turn.js +1 -1
  87. package/dist/src/execution/session/answer-caller.d.ts +9 -5
  88. package/dist/src/execution/session/answer-caller.js +1 -1
  89. package/dist/src/execution/session/principal.d.ts +8 -0
  90. package/dist/src/execution/session/principal.js +1 -1
  91. package/dist/src/execution/session/program.js +1 -1
  92. package/dist/src/execution/session/turn-step.js +1 -1
  93. package/dist/src/execution/session/turn.js +1 -1
  94. package/dist/src/execution/session-callback-request.js +1 -1
  95. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  96. package/dist/src/harness/attachment-staging.d.ts +2 -2
  97. package/dist/src/harness/attachment-staging.js +1 -1
  98. package/dist/src/instrumentation/ai-sdk-telemetry.d.ts +0 -2
  99. package/dist/src/instrumentation/providers.d.ts +1 -38
  100. package/dist/src/instrumentation/providers.js +1 -1
  101. package/dist/src/instrumentation/setup-context.d.ts +1 -7
  102. package/dist/src/internal/application/package.d.ts +1 -0
  103. package/dist/src/internal/application/package.js +1 -1
  104. package/dist/src/internal/application/stamped-package-version.js +1 -1
  105. package/dist/src/internal/authored-definition/core.js +1 -1
  106. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  107. package/dist/src/internal/classify-model-routing.d.ts +2 -3
  108. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  109. package/dist/src/internal/nitro/routes/schedule-collection-consumer.js +1 -1
  110. package/dist/src/internal/runtime-model.d.ts +9 -4
  111. package/dist/src/internal/runtime-model.js +1 -1
  112. package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
  113. package/dist/src/internal/workflow-bundle/builder-support.d.ts +1 -1
  114. package/dist/src/internal/workflow-bundle/builder-support.js +1 -1
  115. package/dist/src/internal/workflow-bundle/workflow-transformer.js +1 -1
  116. package/dist/src/models/auto.js +1 -1
  117. package/dist/src/protocol/delivery.d.ts +1 -0
  118. package/dist/src/protocol/reset-session.d.ts +0 -2
  119. package/dist/src/protocol/routes.d.ts +9 -2
  120. package/dist/src/protocol/routes.js +1 -1
  121. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +1 -22
  122. package/dist/src/public/channels/discord/discordChannel.d.ts +3 -12
  123. package/dist/src/public/channels/discord/gateway/{index.d.ts → relay.d.ts} +2 -2
  124. package/dist/src/public/channels/discord/gateway/relay.js +1 -0
  125. package/dist/src/public/channels/discord/messages.d.ts +4 -4
  126. package/dist/src/public/channels/github/state.d.ts +0 -2
  127. package/dist/src/public/channels/index.d.ts +1 -2
  128. package/dist/src/public/channels/index.js +1 -1
  129. package/dist/src/public/channels/linear/index.d.ts +1 -1
  130. package/dist/src/public/channels/linear/index.js +1 -1
  131. package/dist/src/public/channels/linear/linearChannel.d.ts +0 -5
  132. package/dist/src/public/channels/linq/index.d.ts +1 -1
  133. package/dist/src/public/channels/linq/linqChannel.d.ts +7 -5
  134. package/dist/src/public/channels/photon/index.d.ts +1 -1
  135. package/dist/src/public/channels/photon/photonIMessageChannel.d.ts +15 -4
  136. package/dist/src/public/channels/slack/api.d.ts +1 -1
  137. package/dist/src/public/channels/slack/api.js +1 -1
  138. package/dist/src/public/channels/slack/blocks.d.ts +1 -1
  139. package/dist/src/public/channels/slack/blocks.js +2 -2
  140. package/dist/src/public/channels/slack/cards.d.ts +2 -297
  141. package/dist/src/public/channels/slack/cards.js +1 -1
  142. package/dist/src/public/channels/slack/index.d.ts +2 -2
  143. package/dist/src/public/channels/slack/index.js +1 -1
  144. package/dist/src/public/channels/slack/session-operations.d.ts +2 -2
  145. package/dist/src/public/channels/slack/session-operations.js +1 -1
  146. package/dist/src/public/channels/slack/slackChannel.d.ts +11 -72
  147. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  148. package/dist/src/public/channels/teams/teamsChannel.d.ts +4 -3
  149. package/dist/src/public/channels/telegram/hitl.d.ts +2 -9
  150. package/dist/src/public/channels/telegram/index.d.ts +1 -1
  151. package/dist/src/public/channels/telegram/telegramChannel.d.ts +0 -2
  152. package/dist/src/public/channels/twilio/twilioChannel.d.ts +0 -2
  153. package/dist/src/public/channels/undelivered-reply.d.ts +0 -5
  154. package/dist/src/public/definitions/agent.d.ts +15 -7
  155. package/dist/src/public/definitions/agent.js +1 -1
  156. package/dist/src/public/definitions/channel.d.ts +7 -5
  157. package/dist/src/public/definitions/channel.js +1 -1
  158. package/dist/src/public/definitions/connections/protocol.d.ts +1 -7
  159. package/dist/src/public/definitions/connections/protocol.js +1 -1
  160. package/dist/src/public/experimental/channels/discord/gateway.d.ts +1 -0
  161. package/dist/src/public/experimental/channels/discord/gateway.js +1 -0
  162. package/dist/src/public/experimental/sandbox/just-bash.d.ts +1 -0
  163. package/dist/src/public/experimental/sandbox/just-bash.js +1 -0
  164. package/dist/src/public/experimental/workspace/index.d.ts +1 -0
  165. package/dist/src/public/experimental/workspace/index.js +1 -0
  166. package/dist/src/public/index.d.ts +2 -2
  167. package/dist/src/public/index.js +1 -1
  168. package/dist/src/public/instrumentation/otel.d.ts +1 -1
  169. package/dist/src/public/instrumentation/provider.d.ts +1 -1
  170. package/dist/src/public/instrumentation/provider.js +1 -1
  171. package/dist/src/public/memory/file/backend.d.ts +1 -1
  172. package/dist/src/public/memory/file/backends/in-memory.js +1 -1
  173. package/dist/src/public/memory/file/backends/vercel-blob.js +1 -1
  174. package/dist/src/public/memory/file/provider.js +1 -1
  175. package/dist/src/public/memory/index.d.ts +3 -11
  176. package/dist/src/public/models/anthropic/index.d.ts +1 -1
  177. package/dist/src/public/models/index.d.ts +1 -0
  178. package/dist/src/public/models/openai/index.d.ts +2 -2
  179. package/dist/src/public/next/index.d.ts +2 -2
  180. package/dist/src/public/sandbox/just-bash-sandbox.d.ts +27 -20
  181. package/dist/src/public/sandbox/just-bash.d.ts +0 -1
  182. package/dist/src/public/schedules/providers/vercel.d.ts +2 -0
  183. package/dist/src/public/schedules/providers/vercel.js +1 -1
  184. package/dist/src/public/sessions/index.d.ts +1 -0
  185. package/dist/src/public/sessions/index.js +1 -1
  186. package/dist/src/public/tools/index.d.ts +1 -1
  187. package/dist/src/public/tools/index.js +1 -1
  188. package/dist/src/public/workflow/api.d.ts +25 -0
  189. package/dist/src/public/workflow/api.js +1 -0
  190. package/dist/src/public/workflow/index.d.ts +76 -0
  191. package/dist/src/public/workflow/index.js +1 -0
  192. package/dist/src/public/workflow-modules.d.ts +2 -17
  193. package/dist/src/react/use-eve-agent.d.ts +3 -2
  194. package/dist/src/react/use-eve-agent.js +1 -1
  195. package/dist/src/reactions/kinds/model.js +1 -1
  196. package/dist/src/runtime/agent/resolve-model.js +1 -1
  197. package/dist/src/runtime/resolve-agent.js +1 -1
  198. package/dist/src/runtime/resolve-dynamic.js +1 -1
  199. package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -1
  200. package/dist/src/runtime/subagents/workflow.js +1 -1
  201. package/dist/src/sandbox/providers/default.js +1 -1
  202. package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +2 -2
  203. package/dist/src/self-modification/sandbox.js +1 -1
  204. package/dist/src/setup/integrations/discord/daemon.js +2 -2
  205. package/dist/src/setup/scaffold/create/project.js +2 -2
  206. package/dist/src/setup/scaffold/create/web-template.d.ts +2 -2
  207. package/dist/src/setup/scaffold/create/web-template.js +2 -2
  208. package/dist/src/setup/verified-remote-agent.d.ts +1 -3
  209. package/dist/src/shared/agent-definition.d.ts +18 -9
  210. package/dist/src/shared/eve-error.d.ts +22 -0
  211. package/dist/src/shared/eve-error.js +1 -0
  212. package/dist/src/shared/session.d.ts +2 -2
  213. package/dist/src/shared/token-usage.d.ts +7 -1
  214. package/dist/src/svelte/index.js +1 -1
  215. package/dist/src/svelte/use-eve-agent.d.ts +2 -1
  216. package/dist/src/svelte/use-eve-agent.js +1 -1
  217. package/dist/src/tools/definition.d.ts +7 -5
  218. package/dist/src/tools/definition.js +1 -1
  219. package/dist/src/tools/provided/ask-question-workflow.js +1 -1
  220. package/dist/src/tools/provided/sleep-workflow.js +1 -1
  221. package/dist/src/tracing/eve/batch-span-processor.d.ts +1 -1
  222. package/dist/src/tracing/eve/content-span-processor.d.ts +1 -19
  223. package/dist/src/tracing/eve/otel-configuration.d.ts +6 -0
  224. package/dist/src/tracing/eve/otel-declaration.d.ts +6 -19
  225. package/dist/src/tracing/eve/span-export-policy.d.ts +0 -2
  226. package/dist/src/tracing/local/instrumentation-runtime.d.ts +0 -3
  227. package/dist/src/tracing/local/traces.d.ts +0 -13
  228. package/dist/src/vue/index.js +1 -1
  229. package/dist/src/vue/use-eve-agent.d.ts +3 -2
  230. package/dist/src/vue/use-eve-agent.js +1 -1
  231. package/docs/agent-config.md +15 -11
  232. package/docs/channels/custom.mdx +26 -10
  233. package/docs/channels/discord.mdx +10 -10
  234. package/docs/channels/eve.mdx +15 -13
  235. package/docs/channels/linear.mdx +11 -0
  236. package/docs/channels/linq.mdx +5 -1
  237. package/docs/channels/photon.mdx +6 -1
  238. package/docs/channels/slack.mdx +73 -14
  239. package/docs/channels/telegram.mdx +6 -0
  240. package/docs/code-extension.mdx +25 -0
  241. package/docs/concepts/default-harness.md +2 -2
  242. package/docs/concepts/execution-model-and-durability.mdx +11 -11
  243. package/docs/concepts/project-structure.mdx +1 -1
  244. package/docs/concepts/security-model.md +6 -2
  245. package/docs/concepts/sessions-runs-and-streaming.md +23 -10
  246. package/docs/concepts/upgrade-to-v27-events.md +70 -1
  247. package/docs/connections/overview.mdx +4 -0
  248. package/docs/evals/reporters.mdx +21 -0
  249. package/docs/extensions.md +12 -0
  250. package/docs/getting-started.mdx +6 -0
  251. package/docs/guides/auth-and-route-protection.md +2 -1
  252. package/docs/guides/client/continuations.mdx +12 -10
  253. package/docs/guides/client/messages.mdx +24 -1
  254. package/docs/guides/client/overview.mdx +8 -6
  255. package/docs/guides/client/streaming.mdx +25 -7
  256. package/docs/guides/decide.md +3 -3
  257. package/docs/guides/deployment/self-hosting.md +1 -1
  258. package/docs/guides/deployment/vercel.mdx +1 -1
  259. package/docs/guides/dev-tui.md +2 -2
  260. package/docs/guides/frontend/meta.json +1 -0
  261. package/docs/guides/frontend/nextjs.mdx +329 -121
  262. package/docs/guides/frontend/overview.mdx +115 -335
  263. package/docs/guides/frontend/tanstack.mdx +1 -1
  264. package/docs/guides/frontend/use-eve-agent-svelte.mdx +18 -16
  265. package/docs/guides/frontend/use-eve-agent-vue.mdx +18 -16
  266. package/docs/guides/frontend/use-eve-agent.mdx +385 -0
  267. package/docs/guides/hooks.md +1 -1
  268. package/docs/guides/instrumentation/otel.mdx +3 -1
  269. package/docs/guides/prepare-for-1-0.md +255 -0
  270. package/docs/guides/remote-agents.md +26 -22
  271. package/docs/guides/self-modification.md +6 -0
  272. package/docs/instructions.mdx +1 -1
  273. package/docs/memory/custom-provider.md +1 -1
  274. package/docs/memory/file.md +11 -2
  275. package/docs/meta.json +1 -0
  276. package/docs/reference/agent-files.md +17 -17
  277. package/docs/reference/cli.md +15 -11
  278. package/docs/reference/typescript-api.md +46 -20
  279. package/docs/sandbox/custom-providers.mdx +2 -0
  280. package/docs/sandbox/default.mdx +6 -6
  281. package/docs/sandbox/index.mdx +6 -6
  282. package/docs/sandbox/just-bash.mdx +30 -21
  283. package/docs/subagents/index.mdx +4 -4
  284. package/docs/tools/human-in-the-loop.md +1 -1
  285. package/docs/tools/workflows.mdx +52 -8
  286. package/docs/tutorial/first-agent.mdx +1 -1
  287. package/package.json +46 -27
  288. package/dist/src/public/channels/discord/gateway/index.js +0 -1
  289. package/dist/src/self-modification/agent.d.ts +0 -12
  290. package/dist/src/self-modification/agent.js +0 -1
package/README.md CHANGED
@@ -6,6 +6,10 @@ You author an agent as a directory on disk. The directory is the contract — ma
6
6
 
7
7
  The framework is called eve. The published npm package is `eve`. The CLI binary is `eve`.
8
8
 
9
+ ## Release notes
10
+
11
+ The installed package contains its release notes in `CHANGELOG.md`, with a link to the full changelog through that version. For an upgrade across releases, review the target version's history at `https://raw.githubusercontent.com/vercel/eve/refs/tags/eve%40<version>/packages/eve/CHANGELOG.md`.
12
+
9
13
  ## Preview Terms and Safeguards
10
14
 
11
15
  eve is currently a preview and subject to the Vercel beta terms; the framework, APIs, documentation, and behavior may change before general availability.
@@ -119,9 +123,8 @@ npx eve@latest init my-agent
119
123
  ```
120
124
 
121
125
  `eve init` writes a new agent with eve's default model. Pass `--model
122
- openai/gpt-5.5` to choose another AI Gateway model, `--reasoning high` to set a
123
- reasoning effort, or `--channel-web-nextjs` to add the Web Chat application. It
124
- installs dependencies, initializes Git, and opens the terminal UI in an interactive
126
+ openai/gpt-5.5` to choose another AI Gateway model, or `--reasoning high` to set a
127
+ reasoning effort. It installs dependencies, initializes Git, and opens the terminal UI in an interactive
125
128
  human terminal. Coding-agent invocations return setup instructions instead.
126
129
  Targeting an existing project directory (`eve init .`) adds the agent files and
127
130
  missing dependencies instead. Initialization does not create a Vercel project,
@@ -191,4 +194,4 @@ and inspection. Channel-local addresses remain behind authored channel APIs.
191
194
 
192
195
  ## Changelog
193
196
 
194
- See [`./CHANGELOG.md`](./CHANGELOG.md) for the release history. The changelog ships inside the published package so agents can read it directly from `node_modules/eve/CHANGELOG.md` to evaluate upgrades.
197
+ The repository's `CHANGELOG.md` contains the full release history. For the installed package, see [Release notes](#release-notes).
@@ -1,26 +1,5 @@
1
- import type { SessionStreamEvent } from "#protocol/session-event.js";
2
1
  import { type AgentContext, type InitializeRequest, type InitializeResponse, type NewSessionRequest, type NewSessionResponse, type PromptRequest, type PromptResponse } from "#compiled/@agentclientprotocol/sdk/index.js";
3
- import type { ClientOptions, SendTurnInput } from "#client/types.js";
4
- import type { Answer } from "#shared/input.js";
5
- interface AdapterDelivery {
6
- stream(): AsyncIterable<SessionStreamEvent>;
7
- }
8
- interface AdapterClientSession {
9
- send(message: SendTurnInput["message"]): Promise<AdapterDelivery>;
10
- respond(answers: readonly Answer[]): Promise<AdapterDelivery>;
11
- cancel(options?: {
12
- turnId?: string;
13
- }): Promise<unknown>;
14
- reset(): Promise<unknown>;
15
- }
16
- interface AdapterClient {
17
- readonly sessions: {
18
- create(input: SendTurnInput): Promise<{
19
- readonly delivery: AdapterDelivery;
20
- readonly session: AdapterClientSession;
21
- }>;
22
- };
23
- }
2
+ import type { ClientOptions } from "#client/types.js";
24
3
  /** Configuration for translating one ACP client connection to an eve server. */
25
4
  export interface EveAcpAdapterOptions {
26
5
  readonly eveVersion: string;
@@ -29,14 +8,12 @@ export interface EveAcpAdapterOptions {
29
8
  readonly serverUrl: string;
30
9
  /** Local workspace root to enforce; omit when connecting to a remote deployment. */
31
10
  readonly workspaceRoot?: string;
32
- /** @internal Test seam for the public eve client boundary. */
33
- readonly client?: AdapterClient;
34
11
  }
35
12
  /**
36
13
  * Translates stable ACP v1 sessions onto the public eve HTTP client.
37
14
  *
38
15
  * The adapter owns only process-local ACP identities. Conversation durability,
39
- * event cursors, cancellation, and reset behavior remain owned by
16
+ * event cursors, cancellation, and session retirement remain owned by
40
17
  * {@link ClientSession}.
41
18
  */
42
19
  export declare class EveAcpAdapter {
@@ -49,4 +26,3 @@ export declare class EveAcpAdapter {
49
26
  closeSession(sessionId: string): Promise<void>;
50
27
  close(): Promise<void>;
51
28
  }
52
- export {};
@@ -1 +1 @@
1
- import{randomUUID}from"node:crypto";import{realpath}from"node:fs/promises";import{PROTOCOL_VERSION,RequestError,methods}from"#compiled/@agentclientprotocol/sdk/index.js";import{Client,ClientError}from"#client/index.js";import{isFactType}from"#protocol/session-events/catalog.js";import{emptySessionView,foldReceivedEvent}from"#protocol/session-projection/fold.js";import{interaction}from"#protocol/session-projection/reader.js";import{callLabel,callOutputSource,callState}from"#protocol/session-projection/selectors.js";import{actionLabel}from"#shared/action-label.js";import{failureOf}from"#client/session-utils.js";const ANSWER_FIELD=`answer`,ERROR_CODE_EVE=-32002;function acpStatus(e,t){switch(callState(e,t)){case void 0:return;case`requested`:case`approval`:return`pending`;case`running`:case`blocked`:return`in_progress`;case`completed`:return`completed`;default:return`failed`}}var EveAcpAdapter=class{#e;#t;#n;#r=!1;#i=new Map;constructor(e){this.#t=e.eveVersion,this.#n=e.workspaceRoot,this.#e=e.client??new Client({auth:e.auth,headers:e.headers,baseUrl:e.serverUrl,redirect:`manual`})}initialize(e){return this.#r=e.clientCapabilities?.elicitation?.form!==void 0,{protocolVersion:PROTOCOL_VERSION,agentCapabilities:{loadSession:!1,promptCapabilities:{},sessionCapabilities:{close:{}}},agentInfo:{name:`eve`,title:`eve`,version:this.#t},authMethods:[]}}async newSession(e){if(e.mcpServers.length>0)throw unsupported(`Client-provided MCP servers are not supported by eve ACP mode.`);if((e.additionalDirectories?.length??0)>0)throw unsupported(`Additional workspace directories are not supported by eve ACP mode.`);if(this.#n!==void 0){let t=await normalizedRealpath(e.cwd,`session/new.cwd`),n=await normalizedRealpath(this.#n,`the eve application root`);if(t!==n)throw RequestError.invalidParams({cwd:e.cwd,workspaceRoot:n},`ACP cwd must be the eve application root`)}let t=randomUUID();return this.#i.set(t,{view:emptySessionView(),tools:new Map,parts:new Map}),{sessionId:t}}async prompt(e,t,n){let r=this.#s(e.sessionId);if(r.active!==void 0)throw new RequestError(-32001,`ACP session ${e.sessionId} already has an active prompt.`);let i=promptContent(e);r.tools.clear(),r.parts.clear();let a=Promise.withResolvers(),o={cancelRequested:!1,protocolCancelled:!1,outboundController:new AbortController,settled:a.promise,resolveSettled:a.resolve};r.active=o;let onProtocolCancel=()=>{o.protocolCancelled=!0,this.#o(r).catch(()=>void 0)};n.aborted?onProtocolCancel():n.addEventListener(`abort`,onProtocolCancel,{once:!0});try{if(o.protocolCancelled)throw RequestError.requestCancelled({sessionId:e.sessionId});let a={message:i};for(;;){let i;if(r.client===void 0){if(a.message===void 0)throw Error(`ACP session has not started.`);let e=await this.#e.sessions.create({...a,message:a.message});r.client=e.session,i=e.delivery}else i=a.answers===void 0?await r.client.send(a.message):await r.client.respond(a.answers);(o.cancelRequested||o.protocolCancelled)&&await this.#o(r);let s=[],c=!1,l,u;for await(let n of i.stream()){let i=`data`in n?n.data:void 0,a=i!==void 0&&`turnId`in i?i.turnId:void 0;if(typeof a==`string`&&(o.turnId=a),n.type===`interaction.opened`&&n.data.request.kind===`sign-in`&&(u=unsupported(`Connection authorization cannot be completed through eve ACP mode.`)),n.type===`turn.settled`&&n.data.outcome===`cancelled`&&(c=!0),l=failureOf(n)??l,await this.#c(e.sessionId,r,n,t),n.type===`interaction.opened`){let e=interaction(r.view,n.data.interactionId);e!==void 0&&e.request.kind!==`sign-in`&&s.push(e)}}if(o.protocolCancelled)throw RequestError.requestCancelled({sessionId:e.sessionId});if(o.cancelRequested||c&&l===void 0)return{stopReason:`cancelled`};if(l!==void 0)throw await this.#l(e.sessionId,r,t),eveFailure(l);if(u!==void 0)throw u;if(s.length===0)return{stopReason:`end_turn`};let d;try{d=await Promise.all(s.map(i=>this.#d(e.sessionId,r,i,t,n)))}catch(t){if(o.protocolCancelled)throw RequestError.requestCancelled({sessionId:e.sessionId});if(o.cancelRequested)return{stopReason:`cancelled`};throw t}if(o.protocolCancelled)throw RequestError.requestCancelled({sessionId:e.sessionId});if(o.cancelRequested)return{stopReason:`cancelled`};a={answers:d}}}catch(e){throw acpRequestError(e)}finally{n.removeEventListener(`abort`,onProtocolCancel),r.tools.clear(),o.resolveSettled(),r.active===o&&(r.active=void 0)}}async cancel(e){let t=this.#i.get(e);t!==void 0&&t.active!==void 0&&(t.active.cancelRequested=!0,await this.#o(t))}async closeSession(e){let t=this.#s(e);this.#i.delete(e),await this.#a(t)}async close(){let e=[...this.#i.values()];this.#i.clear(),await Promise.allSettled(e.map(e=>this.#a(e)))}async#a(e){let t;if(e.active!==void 0){let n=e.active;n.cancelRequested=!0;try{await this.#o(e)}catch(e){t=e}await n.settled}try{await e.client?.reset()}catch(e){throw t===void 0?e:AggregateError([t,e],`Could not cancel or reset the eve session`)}if(t!==void 0)throw t}async#o(e){e.active?.outboundController.abort(),e.client!==void 0&&await e.client.cancel(e.active?.turnId===void 0?void 0:{turnId:e.active.turnId})}#s(e){let t=this.#i.get(e);if(t===void 0)throw RequestError.invalidParams({sessionId:e},`Unknown or closed ACP session`);return t}async#c(e,t,n,r){if(!isFactType(n.type)){await this.#u(e,t,n,r);return}if(foldReceivedEvent(t.view,n),await this.#u(e,t,n,r),n.type===`call.requested`)return;let i=n.type===`call.settled`?n.data.callId:void 0;for(let[a,o]of t.tools){let s=acpStatus(t.view,a);if(s===void 0)continue;let c=callOutput(n,a,t.view);(s!==o.status||a===i&&`content`in c)&&(t.tools.set(a,{...o,status:s}),await notifyUpdate(r,e,{sessionUpdate:`tool_call_update`,toolCallId:a,status:s,...c,...resultTitle(n,a)}))}}async#l(e,t,n){for(let r of t.tools.keys())acpStatus(t.view,r)===`in_progress`&&await notifyUpdate(n,e,{sessionUpdate:`tool_call_update`,toolCallId:r,status:`failed`})}async#u(e,t,n,r){switch(n.type){case`content.delta`:{let{partId:i,kind:a,delta:o}=n.data;a===`text`?t.parts.set(i,`text`):a===`reasoning`&&t.parts.set(i,`reasoning`);let s=t.parts.get(i);if(s===void 0||o===void 0)return;await notifyUpdate(r,e,{sessionUpdate:s===`text`?`agent_message_chunk`:`agent_thought_chunk`,content:{type:`text`,text:o},messageId:i});return}case`content.completed`:{let{partId:i,kind:a,value:o}=n.data;if(t.parts.has(i)||typeof o!=`string`||a!==`text`&&a!==`reasoning`)return;t.parts.set(i,a===`text`?`text`:`reasoning`),await notifyUpdate(r,e,{sessionUpdate:a===`text`?`agent_message_chunk`:`agent_thought_chunk`,content:{type:`text`,text:o},messageId:i});return}case`call.requested`:{let{callId:i,capability:a,input:o}=n.data,s=t.view.calls[i];if(a.kind===`control`||s===void 0)return;let c={toolCallId:i,title:callLabel(s),kind:`other`,status:`pending`,rawInput:o};t.tools.set(i,c),await notifyUpdate(r,e,{sessionUpdate:`tool_call`,...c});return}default:return}}async#d(e,t,n,r,i){let a=AbortSignal.any([i,t.active.outboundController.signal]);if(n.request.display===`confirmation`){let i=`${n.interactionId}:approve`,o=`${n.interactionId}:deny`,s=(n.call===void 0?void 0:t.tools.get(n.call.callId))??toolCallForAsked(n),c=await r.request(methods.client.session.requestPermission,{sessionId:e,toolCall:s,options:[{kind:`allow_once`,name:`Approve`,optionId:i},{kind:`reject_once`,name:`Deny`,optionId:o}]},{cancellationSignal:a});if(c.outcome.outcome===`cancelled`)return this.#f(t),{interactionId:n.interactionId};if(c.outcome.optionId===i)return{interactionId:n.interactionId,optionId:`approve`};if(c.outcome.optionId===o)return{interactionId:n.interactionId,optionId:`deny`};throw RequestError.invalidParams({optionId:c.outcome.optionId},`Unknown ACP permission option`)}if(!this.#r)throw unsupported(`The ACP client does not support form elicitation required by this eve question.`);let o=elicitationProperty(n),s=await r.request(methods.client.elicitation.create,{mode:`form`,sessionId:e,message:n.request.prompt,requestedSchema:{type:`object`,properties:{[ANSWER_FIELD]:o},required:[ANSWER_FIELD]}},{cancellationSignal:a});if(s.action!==`accept`)return this.#f(t),{interactionId:n.interactionId};let c=s.content?.[ANSWER_FIELD];if(typeof c!=`string`)throw RequestError.invalidParams(s.content,`ACP elicitation response must contain a string answer`);if(n.request.display===`select`){if(!n.request.options?.some(e=>e.id===c))throw RequestError.invalidParams({answer:c},`Unknown eve question option`);return{interactionId:n.interactionId,optionId:c}}return{interactionId:n.interactionId,text:c}}#f(e){let t=e.active;t.cancelRequested=!0,t.outboundController.abort()}};async function normalizedRealpath(e,t){try{return await realpath(e)}catch(n){throw RequestError.invalidParams({path:e},`Could not resolve ${t}: ${errorMessage(n)}`)}}function promptContent(e){let t=e.prompt.map(e=>{if(e.type!==`text`)throw unsupported(`ACP prompt content type ${JSON.stringify(e.type)} is not supported.`);return{type:`text`,text:e.text}});if(t.every(e=>e.text.length===0))throw RequestError.invalidParams(e.prompt,`ACP prompt must contain at least one non-empty text block`);return t}function toolCallForAsked(e){let t=e.call?.name??e.request.kind;return{toolCallId:e.call?.callId??e.interactionId,title:actionLabel({callId:e.call?.callId??``,input:{},kind:`tool-call`,toolName:t},void 0),kind:`other`,status:`pending`,rawInput:e.call?.input??{}}}function elicitationProperty(e){if(e.request.display===`select`&&e.request.allowFreeform!==!0&&e.request.options?.length)return{type:`string`,title:e.request.prompt,oneOf:e.request.options.map(e=>({const:e.id,title:e.label,description:e.description}))};if(e.request.display===`text`&&e.request.allowFreeform!==!1)return{type:`string`,title:e.request.prompt,minLength:1};throw unsupported(`This eve question shape cannot be represented by ACP form elicitation.`)}async function notifyUpdate(e,t,n){await e.notify(methods.client.session.update,{sessionId:t,update:n})}function stringifyOutput(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function unsupported(e){return new RequestError(-32003,e)}function eveFailure(e){return new RequestError(ERROR_CODE_EVE,e.message,{code:e.code,id:e.id,hint:e.hint})}function acpRequestError(e){return e instanceof RequestError?e:e instanceof ClientError?new RequestError(ERROR_CODE_EVE,e.message,{httpStatus:e.status}):new RequestError(ERROR_CODE_EVE,errorMessage(e))}function errorMessage(e){return e instanceof Error?e.message:String(e)}function resultTitle(e,t){let n=e.type===`call.settled`&&e.data.callId===t?e.data.label:void 0;return n===void 0?{}:{title:n}}function callOutput(e,t,n){if(e.type!==`call.settled`||e.data.callId!==t)return{};let r=e.data.outputOf,i=r===void 0?void 0:callOutputSource(n,r.callId)?.output,a=e.data.output===void 0?i===void 0?e.data.error?.message:i:e.data.output;return a===void 0?{}:{content:[{type:`content`,content:{type:`text`,text:stringifyOutput(a)}}],rawOutput:a}}export{EveAcpAdapter};
1
+ import{randomUUID}from"node:crypto";import{realpath}from"node:fs/promises";import{PROTOCOL_VERSION,RequestError,methods}from"#compiled/@agentclientprotocol/sdk/index.js";import{Client,ClientError}from"#client/index.js";import{isFactType}from"#protocol/session-events/catalog.js";import{emptySessionView,foldReceivedEvent}from"#protocol/session-projection/fold.js";import{interaction}from"#protocol/session-projection/reader.js";import{callLabel,callOutputSource,callState}from"#protocol/session-projection/selectors.js";import{actionLabel}from"#shared/action-label.js";import{failureOf}from"#client/session-utils.js";const ANSWER_FIELD=`answer`,ERROR_CODE_EVE=-32002;function acpStatus(e,t){switch(callState(e,t)){case void 0:return;case`requested`:case`approval`:return`pending`;case`running`:case`blocked`:return`in_progress`;case`completed`:return`completed`;default:return`failed`}}var EveAcpAdapter=class{#e;#t;#n;#r=!1;#i=new Map;constructor(e){this.#t=e.eveVersion,this.#n=e.workspaceRoot,this.#e=e.client??new Client({auth:e.auth,headers:e.headers,baseUrl:e.serverUrl,redirect:`manual`})}initialize(e){return this.#r=e.clientCapabilities?.elicitation?.form!==void 0,{protocolVersion:PROTOCOL_VERSION,agentCapabilities:{loadSession:!1,promptCapabilities:{},sessionCapabilities:{close:{}}},agentInfo:{name:`eve`,title:`eve`,version:this.#t},authMethods:[]}}async newSession(e){if(e.mcpServers.length>0)throw unsupported(`Client-provided MCP servers are not supported by eve ACP mode.`);if((e.additionalDirectories?.length??0)>0)throw unsupported(`Additional workspace directories are not supported by eve ACP mode.`);if(this.#n!==void 0){let t=await normalizedRealpath(e.cwd,`session/new.cwd`),n=await normalizedRealpath(this.#n,`the eve application root`);if(t!==n)throw RequestError.invalidParams({cwd:e.cwd,workspaceRoot:n},`ACP cwd must be the eve application root`)}let t=randomUUID();return this.#i.set(t,{view:emptySessionView(),tools:new Map,parts:new Map}),{sessionId:t}}async prompt(e,t,n){let r=this.#s(e.sessionId);if(r.active!==void 0)throw new RequestError(-32001,`ACP session ${e.sessionId} already has an active prompt.`);let i=promptContent(e);r.tools.clear(),r.parts.clear();let a=Promise.withResolvers(),o={cancelRequested:!1,protocolCancelled:!1,outboundController:new AbortController,settled:a.promise,resolveSettled:a.resolve};r.active=o;let onProtocolCancel=()=>{o.protocolCancelled=!0,this.#o(r).catch(()=>void 0)};n.aborted?onProtocolCancel():n.addEventListener(`abort`,onProtocolCancel,{once:!0});try{if(o.protocolCancelled)throw RequestError.requestCancelled({sessionId:e.sessionId});let a={message:i};for(;;){let i;if(r.client===void 0){if(a.message===void 0)throw Error(`ACP session has not started.`);let e=await this.#e.sessions.create({...a,message:a.message});r.client=e.session,i=e.delivery}else i=a.answers===void 0?await r.client.send(a.message):await r.client.respond(a.answers);(o.cancelRequested||o.protocolCancelled)&&await this.#o(r);let s=[],c=!1,l,u;for await(let n of i.stream()){let i=`data`in n?n.data:void 0,a=i!==void 0&&`turnId`in i?i.turnId:void 0;if(typeof a==`string`&&(o.turnId=a),n.type===`interaction.opened`&&n.data.request.kind===`sign-in`&&(u=unsupported(`Connection authorization cannot be completed through eve ACP mode.`)),n.type===`turn.settled`&&n.data.outcome===`cancelled`&&(c=!0),l=failureOf(n)??l,await this.#c(e.sessionId,r,n,t),n.type===`interaction.opened`){let e=interaction(r.view,n.data.interactionId);e!==void 0&&e.request.kind!==`sign-in`&&s.push(e)}}if(o.protocolCancelled)throw RequestError.requestCancelled({sessionId:e.sessionId});if(o.cancelRequested||c&&l===void 0)return{stopReason:`cancelled`};if(l!==void 0)throw await this.#l(e.sessionId,r,t),eveFailure(l);if(u!==void 0)throw u;if(s.length===0)return{stopReason:`end_turn`};let d;try{d=await Promise.all(s.map(i=>this.#d(e.sessionId,r,i,t,n)))}catch(t){if(o.protocolCancelled)throw RequestError.requestCancelled({sessionId:e.sessionId});if(o.cancelRequested)return{stopReason:`cancelled`};throw t}if(o.protocolCancelled)throw RequestError.requestCancelled({sessionId:e.sessionId});if(o.cancelRequested)return{stopReason:`cancelled`};a={answers:d}}}catch(e){throw acpRequestError(e)}finally{n.removeEventListener(`abort`,onProtocolCancel),r.tools.clear(),o.resolveSettled(),r.active===o&&(r.active=void 0)}}async cancel(e){let t=this.#i.get(e);t!==void 0&&t.active!==void 0&&(t.active.cancelRequested=!0,await this.#o(t))}async closeSession(e){let t=this.#s(e);this.#i.delete(e),await this.#a(t)}async close(){let e=[...this.#i.values()];this.#i.clear(),await Promise.allSettled(e.map(e=>this.#a(e)))}async#a(e){let t;if(e.active!==void 0){let n=e.active;n.cancelRequested=!0;try{await this.#o(e)}catch(e){t=e}await n.settled}try{await e.client?.end()}catch(e){throw t===void 0?e:AggregateError([t,e],`Could not cancel or end the eve session`)}if(t!==void 0)throw t}async#o(e){e.active?.outboundController.abort(),e.client!==void 0&&await e.client.cancel(e.active?.turnId===void 0?void 0:{turnId:e.active.turnId})}#s(e){let t=this.#i.get(e);if(t===void 0)throw RequestError.invalidParams({sessionId:e},`Unknown or closed ACP session`);return t}async#c(e,t,n,r){if(!isFactType(n.type)){await this.#u(e,t,n,r);return}if(foldReceivedEvent(t.view,n),await this.#u(e,t,n,r),n.type===`call.requested`)return;let i=n.type===`call.settled`?n.data.callId:void 0;for(let[a,o]of t.tools){let s=acpStatus(t.view,a);if(s===void 0)continue;let c=callOutput(n,a,t.view);(s!==o.status||a===i&&`content`in c)&&(t.tools.set(a,{...o,status:s}),await notifyUpdate(r,e,{sessionUpdate:`tool_call_update`,toolCallId:a,status:s,...c,...resultTitle(n,a)}))}}async#l(e,t,n){for(let r of t.tools.keys())acpStatus(t.view,r)===`in_progress`&&await notifyUpdate(n,e,{sessionUpdate:`tool_call_update`,toolCallId:r,status:`failed`})}async#u(e,t,n,r){switch(n.type){case`content.delta`:{let{partId:i,kind:a,delta:o}=n.data;a===`text`?t.parts.set(i,`text`):a===`reasoning`&&t.parts.set(i,`reasoning`);let s=t.parts.get(i);if(s===void 0||o===void 0)return;await notifyUpdate(r,e,{sessionUpdate:s===`text`?`agent_message_chunk`:`agent_thought_chunk`,content:{type:`text`,text:o},messageId:i});return}case`content.completed`:{let{partId:i,kind:a,value:o}=n.data;if(t.parts.has(i)||typeof o!=`string`||a!==`text`&&a!==`reasoning`)return;t.parts.set(i,a===`text`?`text`:`reasoning`),await notifyUpdate(r,e,{sessionUpdate:a===`text`?`agent_message_chunk`:`agent_thought_chunk`,content:{type:`text`,text:o},messageId:i});return}case`call.requested`:{let{callId:i,capability:a,input:o}=n.data,s=t.view.calls[i];if(a.kind===`control`||s===void 0)return;let c={toolCallId:i,title:callLabel(s),kind:`other`,status:`pending`,rawInput:o};t.tools.set(i,c),await notifyUpdate(r,e,{sessionUpdate:`tool_call`,...c});return}default:return}}async#d(e,t,n,r,i){let a=AbortSignal.any([i,t.active.outboundController.signal]);if(n.request.display===`confirmation`){let i=`${n.interactionId}:approve`,o=`${n.interactionId}:deny`,s=(n.call===void 0?void 0:t.tools.get(n.call.callId))??toolCallForAsked(n),c=await r.request(methods.client.session.requestPermission,{sessionId:e,toolCall:s,options:[{kind:`allow_once`,name:`Approve`,optionId:i},{kind:`reject_once`,name:`Deny`,optionId:o}]},{cancellationSignal:a});if(c.outcome.outcome===`cancelled`)return this.#f(t),{interactionId:n.interactionId};if(c.outcome.optionId===i)return{interactionId:n.interactionId,optionId:`approve`};if(c.outcome.optionId===o)return{interactionId:n.interactionId,optionId:`deny`};throw RequestError.invalidParams({optionId:c.outcome.optionId},`Unknown ACP permission option`)}if(!this.#r)throw unsupported(`The ACP client does not support form elicitation required by this eve question.`);let o=elicitationProperty(n),s=await r.request(methods.client.elicitation.create,{mode:`form`,sessionId:e,message:n.request.prompt,requestedSchema:{type:`object`,properties:{[ANSWER_FIELD]:o},required:[ANSWER_FIELD]}},{cancellationSignal:a});if(s.action!==`accept`)return this.#f(t),{interactionId:n.interactionId};let c=s.content?.[ANSWER_FIELD];if(typeof c!=`string`)throw RequestError.invalidParams(s.content,`ACP elicitation response must contain a string answer`);if(n.request.display===`select`){if(!n.request.options?.some(e=>e.id===c))throw RequestError.invalidParams({answer:c},`Unknown eve question option`);return{interactionId:n.interactionId,optionId:c}}return{interactionId:n.interactionId,text:c}}#f(e){let t=e.active;t.cancelRequested=!0,t.outboundController.abort()}};async function normalizedRealpath(e,t){try{return await realpath(e)}catch(n){throw RequestError.invalidParams({path:e},`Could not resolve ${t}: ${errorMessage(n)}`)}}function promptContent(e){let t=e.prompt.map(e=>{if(e.type!==`text`)throw unsupported(`ACP prompt content type ${JSON.stringify(e.type)} is not supported.`);return{type:`text`,text:e.text}});if(t.every(e=>e.text.length===0))throw RequestError.invalidParams(e.prompt,`ACP prompt must contain at least one non-empty text block`);return t}function toolCallForAsked(e){let t=e.call?.name??e.request.kind;return{toolCallId:e.call?.callId??e.interactionId,title:actionLabel({callId:e.call?.callId??``,input:{},kind:`tool-call`,toolName:t},void 0),kind:`other`,status:`pending`,rawInput:e.call?.input??{}}}function elicitationProperty(e){if(e.request.display===`select`&&e.request.allowFreeform!==!0&&e.request.options?.length)return{type:`string`,title:e.request.prompt,oneOf:e.request.options.map(e=>({const:e.id,title:e.label,description:e.description}))};if(e.request.display===`text`&&e.request.allowFreeform!==!1)return{type:`string`,title:e.request.prompt,minLength:1};throw unsupported(`This eve question shape cannot be represented by ACP form elicitation.`)}async function notifyUpdate(e,t,n){await e.notify(methods.client.session.update,{sessionId:t,update:n})}function stringifyOutput(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function unsupported(e){return new RequestError(-32003,e)}function eveFailure(e){return new RequestError(ERROR_CODE_EVE,e.message,{code:e.code,id:e.id,hint:e.hint})}function acpRequestError(e){return e instanceof RequestError?e:e instanceof ClientError?new RequestError(ERROR_CODE_EVE,e.message,{httpStatus:e.status}):new RequestError(ERROR_CODE_EVE,errorMessage(e))}function errorMessage(e){return e instanceof Error?e.message:String(e)}function resultTitle(e,t){let n=e.type===`call.settled`&&e.data.callId===t?e.data.label:void 0;return n===void 0?{}:{title:n}}function callOutput(e,t,n){if(e.type!==`call.settled`||e.data.callId!==t)return{};let r=e.data.outputOf,i=r===void 0?void 0:callOutputSource(n,r.callId)?.output,a=e.data.output===void 0?i===void 0?e.data.error?.message:i:e.data.output;return a===void 0?{}:{content:[{type:`content`,content:{type:`text`,text:stringifyOutput(a)}}],rawOutput:a}}export{EveAcpAdapter};
@@ -1,5 +1,4 @@
1
1
  import { Readable, Writable } from "node:stream";
2
- import { type EveAcpAdapterOptions } from "#acp/adapter.js";
3
2
  import type { ClientOptions } from "#client/types.js";
4
3
  /** Configuration for one ACP stdio connection backed by an eve server. */
5
4
  export interface RunAcpServerOptions {
@@ -10,8 +9,6 @@ export interface RunAcpServerOptions {
10
9
  readonly signal?: AbortSignal;
11
10
  /** Local workspace root to enforce; omit when connecting to a remote deployment. */
12
11
  readonly workspaceRoot?: string;
13
- /** @internal Test seam for the public eve client boundary. */
14
- readonly client?: EveAcpAdapterOptions["client"];
15
12
  }
16
13
  /** Node streams for one ACP stdio connection. */
17
14
  export interface AcpServerStreams {
@@ -1,7 +1,9 @@
1
- import { experimental_decide as decideWithAiSdk } from "ai";
1
+ import * as aiSdk from "ai";
2
2
  import type { DecisionOptions, DecisionQuestion } from "#ai/decision-types.js";
3
3
  export declare const DEFAULT_DECISION_MODEL = "typesafe-ai/jev";
4
+ type AiSdkDecide = typeof aiSdk.experimental_decide;
4
5
  /** Internal eval diagnostics retain SDK metadata without promising it to applications. */
5
6
  export declare function decideWithMetadata<const Questions extends Readonly<Record<string, DecisionQuestion>>>({ model, state, questions, maxRetries, signal, providerOptions, }: DecisionOptions<Questions> & {
6
- readonly providerOptions?: Parameters<typeof decideWithAiSdk>[0]["providerOptions"];
7
- }): Promise<import("ai").Experimental_DecisionResult<Questions>>;
7
+ readonly providerOptions?: Parameters<AiSdkDecide>[0]["providerOptions"];
8
+ }): Promise<aiSdk.Experimental_DecisionResult<Questions>>;
9
+ export {};
@@ -1 +1 @@
1
- import{experimental_decide}from"ai";import{ensureAiSdkWarningLogger}from"#instrumentation/ai-sdk-warnings.js";import{localGatewayDecisionModel}from"#internal/model-auth/transport.js";const DEFAULT_DECISION_MODEL=`typesafe-ai/jev`;function decideWithMetadata({model:e=DEFAULT_DECISION_MODEL,state:t,questions:n,maxRetries:r,signal:i,providerOptions:a}){if(ensureAiSdkWarningLogger(),typeof e!=`string`&&typeof Reflect.get(e,`doDecide`)!=`function`&&typeof Reflect.get(e,`doEvaluate`)!=`function`)throw TypeError(`decide requires a provider decision model implementation, not just its identity.`);return experimental_decide({model:typeof e==`string`&&Reflect.get(globalThis,`AI_SDK_DEFAULT_PROVIDER`)==null?localGatewayDecisionModel(e)??e:e,state:t,questions:n,maxRetries:r,abortSignal:i,providerOptions:a})}export{DEFAULT_DECISION_MODEL,decideWithMetadata};
1
+ import*as aiSdk from"ai";import{ensureAiSdkWarningLogger}from"#instrumentation/ai-sdk-warnings.js";import{localGatewayDecisionModel}from"#internal/model-auth/transport.js";const DEFAULT_DECISION_MODEL=`typesafe-ai/jev`;function resolveAiSdkDecide(){let e=Reflect.get(aiSdk,`decide`)??Reflect.get(aiSdk,`experimental_decide`);if(typeof e!=`function`)throw Error(`decide requires an installed "ai" package that exports decide or experimental_decide. Install a version of "ai" supported by eve, such as ai@^7.0.137.`);return e}function decideWithMetadata({model:e=DEFAULT_DECISION_MODEL,state:t,questions:n,maxRetries:r,signal:i,providerOptions:a}){let o=resolveAiSdkDecide();if(ensureAiSdkWarningLogger(),typeof e!=`string`&&typeof Reflect.get(e,`doDecide`)!=`function`&&typeof Reflect.get(e,`doEvaluate`)!=`function`)throw TypeError(`decide requires a provider decision model implementation, not just its identity.`);return o({model:typeof e==`string`&&Reflect.get(globalThis,`AI_SDK_DEFAULT_PROVIDER`)==null?localGatewayDecisionModel(e)??e:e,state:t,questions:n,maxRetries:r,abortSignal:i,providerOptions:a})}export{DEFAULT_DECISION_MODEL,decideWithMetadata};
@@ -1,13 +1,14 @@
1
1
  import type { HistoryMessage } from "#shared/history-message.js";
2
2
  import type { JsonObject, JsonValue } from "#shared/json.js";
3
3
  /** A model ID or an installed provider's decision model instance.
4
- * The installed AI SDK validates the model specification at runtime.
5
- * An identity object without a decision implementation is not a model.
4
+ * AI SDK 7 decision models implement specification `v4`; the installed AI SDK
5
+ * validates the full model contract at runtime. An identity object without a
6
+ * decision implementation is not a model.
6
7
  */
7
8
  export type DecisionModel = string | ({
8
9
  readonly provider: string;
9
10
  readonly modelId: string;
10
- readonly specificationVersion: string;
11
+ readonly specificationVersion: "v4";
11
12
  } & ({
12
13
  readonly doDecide: (...args: never[]) => unknown;
13
14
  } | {
@@ -32,8 +32,6 @@ export interface ChannelAdapterContext<TState = Record<string, unknown>> extends
32
32
  * to read during the turn.
33
33
  */
34
34
  readonly ctx: ContextAccessor;
35
- /** @internal Independent source of a relayed child input batch. */
36
- readonly inputSource?: string;
37
35
  /** Where the event a handler observes sits on the stream: its line, and its index there. */
38
36
  readonly position?: FactPosition;
39
37
  /** The event's owners: its turn, task, model run, or context change. */
@@ -41,12 +39,6 @@ export interface ChannelAdapterContext<TState = Record<string, unknown>> extends
41
39
  /** The immutable snapshot of the event's line, supplied by its publisher. */
42
40
  readonly view?: SessionView;
43
41
  }
44
- /**
45
- * Extracts the state type from a {@link ChannelAdapterContext} generic.
46
- * Used internally so adapter-level types can declare their state shape
47
- * once (via `TCtx`) and have helpers narrow consistently.
48
- */
49
- type StateOf<TCtx> = TCtx extends ChannelAdapterContext<infer S> ? S : Record<string, unknown>;
50
42
  /**
51
43
  * A single outbound event handler. Receives the written event and the adapter context. Void
52
44
  * return: side effects only.
@@ -111,12 +103,6 @@ export type ChannelAdapter<TCtx extends ChannelAdapterContext<any> = ChannelAdap
111
103
  * return void to use the default payload projection.
112
104
  */
113
105
  deliver?(payload: DeliverPayload, ctx: TCtx): StepInput | void | Promise<StepInput | void>;
114
- /**
115
- * Optional factory that builds the adapter context for this adapter.
116
- *
117
- * @internal
118
- */
119
- createAdapterContext?(base: ChannelAdapterContext<StateOf<TCtx>>): TCtx;
120
106
  /**
121
107
  * Fetches bytes for a URL encountered in `FilePart.data`.
122
108
  *
@@ -196,8 +196,6 @@ export interface UnauthorizedResponseOptions {
196
196
  * challenge, and a `{ ok: false, code, error }` body.
197
197
  */
198
198
  export declare function createUnauthorizedResponse(opts?: UnauthorizedResponseOptions): Response;
199
- /** @internal Escapes a value for an HTTP auth challenge quoted string. */
200
- export declare function escapeAuthChallengeParameter(value: string): string;
201
199
  /**
202
200
  * Options accepted by auth error classes. The class chooses the HTTP status.
203
201
  */
@@ -270,8 +268,6 @@ export type OAuthResourceAuth = AuthFn<Request> & {
270
268
  * `mcpChannel` may additionally publish the metadata and discovery challenge.
271
269
  */
272
270
  export declare function oauthResource(auth: AuthFn<Request> | readonly AuthFn<Request>[], options: OAuthResourceOptions): OAuthResourceAuth;
273
- /** @internal Reads OAuth resource metadata without widening `AuthFn`. */
274
- export declare function readOAuthResourceOptions(auth: AuthFn<Request> | readonly AuthFn<Request>[]): OAuthResourceOptions | undefined;
275
271
  /**
276
272
  * Attaches declared `www-authenticate` challenges to an {@link AuthFn}
277
273
  * without changing its call signature or behavior. {@link routeAuth} reads
@@ -53,7 +53,7 @@ interface ChannelAddress<TState = undefined> {
53
53
  } & SessionControlOptions): Promise<Delivery>;
54
54
  compact(options?: SessionControlOptions): Promise<Delivery>;
55
55
  clear(options?: SessionControlOptions): Promise<Delivery>;
56
- reset(options?: {
56
+ end(options?: {
57
57
  readonly reason?: string;
58
58
  } & SessionControlOptions): Promise<Delivery>;
59
59
  resolveSession(): Promise<Session | undefined>;
@@ -1 +1 @@
1
- import{createSession,sessionCallbackToTurnCaller}from"#channel/session.js";import{commandDelivery}from"#channel/delivery.js";import{validateDeliveryIdempotencyKey}from"#channel/delivery-idempotency.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{normalizeSendInput,serializeFilePartsInMessage}from"#channel/send-input.js";import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{SessionStrandedError,describeStrandedSession}from"#channel/session-stranded-error.js";import{DEFAULT_TURN_POLICY,controlCommand}from"#channel/types.js";import{isReservedSessionCommandToken}from"#execution/session-inbox/address.js";import{validateSessionHistory}from"#shared/session-history.js";function createChannelAddress(e){let t=e.metadata??{},n=`${e.channelName}:${e.continuationToken}`;if(isReservedSessionCommandToken(n))throw Error(`Channel address "${n}" uses eve's reserved session namespace.`);return{continuationToken:e.continuationToken,async deliver(r,i){validateDeliveryIdempotencyKey(i.idempotencyKey);let a=createChannelDeliveryMetadata({channelKind:`channel:${e.channelName}`,channelName:e.channelName,...t}),o=withValidatedHistory(normalizeSendInput(r)),s=sessionCallbackToTurnCaller(i.callback),c={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:a,kind:`send`,payload:{...o,message:serializeFilePartsInMessage(o.message)},requestId:t.requestId,turnPolicy:o.message===void 0?void 0:i.turnPolicy??e.turnPolicy??DEFAULT_TURN_POLICY},l=s===void 0?c:{...c,caller:s},u=i.state,d=u===void 0?e.adapter:{...e.adapter,state:{...e.adapter.state,...u}},f={idempotencyKey:i.idempotencyKey,adapter:d,auth:i.auth,capabilities:{requestInput:!0},callback:i.callback,channelName:e.channelName,continuationConflictCommand:l,continuationToken:n,delivery:a,initiatorAuth:i.initiatorAuth,input:{context:o.context,history:o.history,message:serializeFilePartsInMessage(o.message)??``,outputSchema:o.outputSchema,state:o.state},requestId:t.requestId,title:i.title},p=await e.runtime.dispatchContinuation({command:l,continuationToken:n,successor:f});if(p.status===`accepted`)return commandDelivery(e.runtime,p,a.deliveryId);if(p.retryable===!0)throw new SessionNotActiveError({retryable:!0});if(o.answers&&o.answers.length>0)throw new SessionNotActiveError;let m=await e.runtime.createSession(f);return commandDelivery(e.runtime,{status:`accepted`,sessionId:m.sessionId},a.deliveryId)},async create(r){let i=validateSessionHistory(r.history),toSession=n=>createSession(n,e.runtime,{...t,turnPolicy:e.turnPolicy}),a;try{a=await e.runtime.resolveContinuation(n,{runnable:!0})}catch(e){throw SessionStrandedError.is(e)?new SessionStrandedError(e.owner,describeStrandedSession(e.owner,`Call reset() on the address, then create() again to start a session from your history.`)):e}if(a!==void 0)return{created:!1,session:toSession(a.sessionId)};let o=r.state,s=await e.runtime.createSession({adapter:o===void 0?e.adapter:{...e.adapter,state:{...e.adapter.state,...o}},auth:r.auth,capabilities:{requestInput:!0},channelName:e.channelName,continuationToken:n,initiatorAuth:r.initiatorAuth,input:i===void 0?{}:{history:i},requestId:t.requestId,title:r.title}),c=await waitForContinuationOwner(e.runtime,n,s.sessionId);return{created:c.sessionId===s.sessionId,session:toSession(c.sessionId)}},async send(e,t){return await this.deliver({message:e},t)},async respond(e,t){if(e===void 0||e.length===0)throw Error(`respond() requires at least one answer.`);return await this.deliver({answers:e},t)},async cancel(t){let r=controlCommand({kind:`cancel`,turnId:t?.turnId},t),i=await e.runtime.dispatchContinuation({command:r,continuationToken:n});return commandDelivery(e.runtime,i,r.deliveryId)},async compact(t){let r=controlCommand({kind:`compact`},t),i=await e.runtime.dispatchContinuation({command:r,continuationToken:n});return commandDelivery(e.runtime,i,r.deliveryId)},async clear(t){let r=controlCommand({kind:`clear`},t),i=await e.runtime.dispatchContinuation({command:r,continuationToken:n});return commandDelivery(e.runtime,i,r.deliveryId)},async reset(t){let r=controlCommand({kind:`reset`,reason:t?.reason},t),i=await e.runtime.dispatchContinuation({command:r,continuationToken:n});return commandDelivery(e.runtime,i,r.deliveryId,{follow:!1})},async resolveSession(){let r=await e.runtime.resolveContinuation(n);return r===void 0?void 0:createSession(r.sessionId,e.runtime,{...t,turnPolicy:e.turnPolicy})}}}function createChannelAddressFn(e){return t=>createChannelAddress({...e,continuationToken:t})}function withValidatedHistory(e){let{history:t,...n}=e,r=validateSessionHistory(t);return r===void 0?n:{...n,history:r}}const CREATE_CLAIM_TIMEOUT_MS=15e3;async function waitForContinuationOwner(e,t,n){let r=Date.now()+CREATE_CLAIM_TIMEOUT_MS;for(let i=25;;i=Math.min(i*2,500)){let a=await e.resolveContinuation(t);if(a!==void 0)return a;if(Date.now()+i>r)throw Error(`create() started session "${n}" for "${t}", but no session claimed the address within ${CREATE_CLAIM_TIMEOUT_MS/1e3}s. Call resolveSession() on the address to find its owner once one does.`);await new Promise(e=>setTimeout(e,i))}}export{createChannelAddress,createChannelAddressFn};
1
+ import{createSession,sessionCallbackToTurnCaller}from"#channel/session.js";import{commandDelivery}from"#channel/delivery.js";import{validateDeliveryIdempotencyKey}from"#channel/delivery-idempotency.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{normalizeSendInput,serializeFilePartsInMessage}from"#channel/send-input.js";import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{SessionStrandedError,describeStrandedSession}from"#channel/session-stranded-error.js";import{DEFAULT_TURN_POLICY,controlCommand}from"#channel/types.js";import{isReservedSessionCommandToken}from"#execution/session-inbox/address.js";import{validateSessionHistory}from"#shared/session-history.js";function createChannelAddress(e){let t=e.metadata??{},n=`${e.channelName}:${e.continuationToken}`;if(isReservedSessionCommandToken(n))throw Error(`Channel address "${n}" uses eve's reserved session namespace.`);return{continuationToken:e.continuationToken,async deliver(r,i){validateDeliveryIdempotencyKey(i.idempotencyKey);let a=createChannelDeliveryMetadata({channelKind:`channel:${e.channelName}`,channelName:e.channelName,...t}),o=withValidatedHistory(normalizeSendInput(r)),s=sessionCallbackToTurnCaller(i.callback),c={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:a,kind:`send`,payload:{...o,message:serializeFilePartsInMessage(o.message)},requestId:t.requestId,turnPolicy:o.message===void 0?void 0:i.turnPolicy??e.turnPolicy??DEFAULT_TURN_POLICY},l=s===void 0?c:{...c,caller:s},u=i.state,d=u===void 0?e.adapter:{...e.adapter,state:{...e.adapter.state,...u}},f={idempotencyKey:i.idempotencyKey,adapter:d,auth:i.auth,capabilities:{requestInput:!0},callback:i.callback,channelName:e.channelName,continuationConflictCommand:l,continuationToken:n,delivery:a,initiatorAuth:i.initiatorAuth,input:{context:o.context,history:o.history,message:serializeFilePartsInMessage(o.message)??``,outputSchema:o.outputSchema,state:o.state},requestId:t.requestId,title:i.title},p=await e.runtime.dispatchContinuation({command:l,continuationToken:n,successor:f});if(p.status===`accepted`)return commandDelivery(e.runtime,p,a.deliveryId);if(p.retryable===!0)throw new SessionNotActiveError({retryable:!0});if(o.answers&&o.answers.length>0)throw new SessionNotActiveError;let m=await e.runtime.createSession(f);return commandDelivery(e.runtime,{status:`accepted`,sessionId:m.sessionId},a.deliveryId)},async create(r){let i=validateSessionHistory(r.history),toSession=n=>createSession(n,e.runtime,{...t,turnPolicy:e.turnPolicy}),a;try{a=await e.runtime.resolveContinuation(n,{runnable:!0})}catch(e){throw SessionStrandedError.is(e)?new SessionStrandedError(e.owner,describeStrandedSession(e.owner,`Call end() on the address, then create() again to start a session from your history.`)):e}if(a!==void 0)return{created:!1,session:toSession(a.sessionId)};let o=r.state,s=await e.runtime.createSession({adapter:o===void 0?e.adapter:{...e.adapter,state:{...e.adapter.state,...o}},auth:r.auth,capabilities:{requestInput:!0},channelName:e.channelName,continuationToken:n,initiatorAuth:r.initiatorAuth,input:i===void 0?{}:{history:i},requestId:t.requestId,title:r.title}),c=await waitForContinuationOwner(e.runtime,n,s.sessionId);return{created:c.sessionId===s.sessionId,session:toSession(c.sessionId)}},async send(e,t){return await this.deliver({message:e},t)},async respond(e,t){if(e===void 0||e.length===0)throw Error(`respond() requires at least one answer.`);return await this.deliver({answers:e},t)},async cancel(t){let r=controlCommand({kind:`cancel`,turnId:t?.turnId},t),i=await e.runtime.dispatchContinuation({command:r,continuationToken:n});return commandDelivery(e.runtime,i,r.deliveryId)},async compact(t){let r=controlCommand({kind:`compact`},t),i=await e.runtime.dispatchContinuation({command:r,continuationToken:n});return commandDelivery(e.runtime,i,r.deliveryId)},async clear(t){let r=controlCommand({kind:`clear`},t),i=await e.runtime.dispatchContinuation({command:r,continuationToken:n});return commandDelivery(e.runtime,i,r.deliveryId)},async end(t){let r=controlCommand({kind:`reset`,reason:t?.reason},t),i=await e.runtime.dispatchContinuation({command:r,continuationToken:n});return commandDelivery(e.runtime,i,r.deliveryId,{follow:!1})},async resolveSession(){let r=await e.runtime.resolveContinuation(n);return r===void 0?void 0:createSession(r.sessionId,e.runtime,{...t,turnPolicy:e.turnPolicy})}}}function createChannelAddressFn(e){return t=>createChannelAddress({...e,continuationToken:t})}function withValidatedHistory(e){let{history:t,...n}=e,r=validateSessionHistory(t);return r===void 0?n:{...n,history:r}}const CREATE_CLAIM_TIMEOUT_MS=15e3;async function waitForContinuationOwner(e,t,n){let r=Date.now()+CREATE_CLAIM_TIMEOUT_MS;for(let i=25;;i=Math.min(i*2,500)){let a=await e.resolveContinuation(t);if(a!==void 0)return a;if(Date.now()+i>r)throw Error(`create() started session "${n}" for "${t}", but no session claimed the address within ${CREATE_CLAIM_TIMEOUT_MS/1e3}s. Call resolveSession() on the address to find its owner once one does.`);await new Promise(e=>setTimeout(e,i))}}export{createChannelAddress,createChannelAddressFn};
@@ -39,7 +39,7 @@ export interface ChannelSource<TState = undefined> {
39
39
  * Creates a session that waits for its first message, without running a
40
40
  * turn. When another session owns the address, or claims it concurrently,
41
41
  * returns that session unchanged with `created: false`; its `history` was not
42
- * added. Throws `SessionStrandedError` when the owner is stranded; reset the
42
+ * added. Throws `SessionStrandedError` when the owner is stranded; end the session at the
43
43
  * address, then create again.
44
44
  */
45
45
  create(options: ChannelCreateOptions<TState>): Promise<ChannelCreateResult>;
@@ -56,7 +56,7 @@ export interface ChannelSource<TState = undefined> {
56
56
  /** Clears model-message history without creating a session. */
57
57
  clear(options?: SessionControlOptions): Promise<Delivery>;
58
58
  /** Retires the current owner without creating a replacement. */
59
- reset(options?: {
59
+ end(options?: {
60
60
  readonly reason?: string;
61
61
  } & SessionControlOptions): Promise<Delivery>;
62
62
  }
@@ -1 +1 @@
1
- import{attachInputText,readInputText}from"#internal/input-text.js";import{createChannelAddressFn}from"#channel/channel-address.js";import{parseAnswers}from"#shared/input.js";function createChannelOperations(e){let t=createChannelAddressFn(e);return{from(e){let n=t(e);return{async send(e,t){return await n.deliver(attachInputText({context:t.context,history:t.history,message:e,outputSchema:t.outputSchema,state:t.state},readInputText(t)),t)},async create(e){return await n.create(e)},async respond(e,t){if(e.length===0)throw Error(`respond() requires at least one answer.`);let r=parseAnswers(e);return await n.deliver({context:t.context,outputSchema:t.outputSchema,answers:r,state:t.state},t)},async cancel(e){return await n.cancel(e)},async compact(e){return await n.compact(e)},async clear(e){return await n.clear(e)},async reset(e){return await n.reset(e)}}},async resolveSession(e){return await t(e).resolveSession()}}}export{createChannelOperations};
1
+ import{attachInputText,readInputText}from"#internal/input-text.js";import{createChannelAddressFn}from"#channel/channel-address.js";import{parseAnswers}from"#shared/input.js";function createChannelOperations(e){let t=createChannelAddressFn(e);return{from(e){let n=t(e);return{async send(e,t){return await n.deliver(attachInputText({context:t.context,history:t.history,message:e,outputSchema:t.outputSchema,state:t.state},readInputText(t)),t)},async create(e){return await n.create(e)},async respond(e,t){if(e.length===0)throw Error(`respond() requires at least one answer.`);let r=parseAnswers(e);return await n.deliver({context:t.context,outputSchema:t.outputSchema,answers:r,state:t.state},t)},async cancel(e){return await n.cancel(e)},async compact(e){return await n.compact(e)},async clear(e){return await n.clear(e)},async end(e){return await n.end(e)}}},async resolveSession(e){return await t(e).resolveSession()}}}export{createChannelOperations};
@@ -6,8 +6,6 @@ import type { Interaction } from "#channel/interaction-prompts.js";
6
6
  * shows that one and holds the rest until it is answered.
7
7
  */
8
8
  export interface PromptQueueState {
9
- /** The request the channel last showed, which a typed reply answers. */
10
- shownPromptId?: string;
11
9
  }
12
10
  /**
13
11
  * A `committed` handler that calls `show` with the request a typed reply answers now, each time
@@ -1,12 +1,17 @@
1
- /** A session could not accept a command. No delivery was accepted. */
2
- export declare class SessionNotActiveError extends Error {
3
- readonly code = "EVE_SESSION_NOT_ACTIVE";
1
+ import { EveError } from "#shared/eve-error.js";
2
+ /**
3
+ * A session could not accept a command. No delivery was accepted.
4
+ *
5
+ * `code` is the HTTP channel's `409` code: `session_not_ready` (with `retryable: true`) while an
6
+ * accepted session is still starting, otherwise `session_not_active`.
7
+ */
8
+ export declare class SessionNotActiveError extends EveError {
9
+ static readonly errorName = "SessionNotActiveError";
10
+ readonly code: "session_not_active" | "session_not_ready";
4
11
  readonly retryable: boolean;
5
12
  constructor(options?: {
6
13
  readonly retryable?: boolean;
7
14
  });
8
- /** Recognizes errors across bundles without depending on constructor identity. */
9
- static is(error: unknown): error is SessionNotActiveError;
10
15
  }
11
16
  /** Whether an answer targets a session that cannot run or no longer exists. */
12
17
  export declare function isUnanswerableResponseError(error: unknown): boolean;
@@ -1 +1 @@
1
- import{SessionStrandedError}from"#channel/session-stranded-error.js";const CODE=`EVE_SESSION_NOT_ACTIVE`;var SessionNotActiveError=class extends Error{code=CODE;retryable;constructor(e={}){super(e.retryable===!0?`The session is not ready to accept commands. Retry shortly.`:`The session is no longer active. Start a new session.`),this.name=`SessionNotActiveError`,this.retryable=e.retryable===!0}static is(e){return typeof e==`object`&&!!e&&Reflect.get(e,`code`)===CODE&&typeof Reflect.get(e,`retryable`)==`boolean`}};function isUnanswerableResponseError(e){return SessionNotActiveError.is(e)||SessionStrandedError.is(e)}export{SessionNotActiveError,isUnanswerableResponseError};
1
+ import{SessionStrandedError}from"#channel/session-stranded-error.js";import{EveError}from"#shared/eve-error.js";var SessionNotActiveError=class extends EveError{static errorName=`SessionNotActiveError`;retryable;constructor(e={}){let t=e.retryable===!0;super(t?`session_not_ready`:`session_not_active`,t?`The session is not ready to accept commands. Retry shortly.`:`The session is no longer active. Start a new session.`),this.retryable=t}};function isUnanswerableResponseError(e){return SessionNotActiveError.is(e)||SessionStrandedError.is(e)}export{SessionNotActiveError,isUnanswerableResponseError};
@@ -8,7 +8,7 @@ interface StrandedSessionOwner {
8
8
  * a session whose owner another eve version built, on a World that only runs
9
9
  * this build, so the owner can never execute again. Nothing is delivered and
10
10
  * nothing is mutated. Historical reads with `follow: false` still succeed.
11
- * Call `reset()` to end the session, then start a new one. Narrow with
11
+ * Call `end()` to retire the session, then start a new one. Narrow with
12
12
  * {@link SessionStrandedError.is}.
13
13
  */
14
14
  export declare class SessionStrandedError extends Error {
@@ -6,7 +6,7 @@ import type { PrewarmSessionResult } from "#protocol/prewarm-session.js";
6
6
  import type { ContextAccessor } from "#context/key.js";
7
7
  import { type ChannelDeliverySource } from "#channel/delivery-metadata.js";
8
8
  import type { MessageContent } from "#shared/message-content.js";
9
- import type { SessionStreamOptions, SessionControlOptions, Runtime, SessionAuthContext, SessionCallback, TurnPolicy, TurnCaller } from "#channel/types.js";
9
+ import type { SessionStreamOptions, SessionControlOptions, Runtime, SessionAuthContext, TurnPolicy } from "#channel/types.js";
10
10
  import type { ChannelContext } from "#shared/channel-context.js";
11
11
  import { type Answer, type StrictAnswers } from "#shared/input.js";
12
12
  import type { JsonObject } from "#shared/json.js";
@@ -22,7 +22,8 @@ export interface Session extends SessionReader {
22
22
  prewarm(): Promise<PrewarmSessionResult>;
23
23
  clear(options?: SessionControlOptions): Promise<Delivery>;
24
24
  compact(options?: SessionControlOptions): Promise<Delivery>;
25
- reset(options?: SessionControlOptions & {
25
+ /** Retires this session without creating a replacement or changing this handle's ID. */
26
+ end(options?: SessionControlOptions & {
26
27
  readonly reason?: string;
27
28
  }): Promise<Delivery>;
28
29
  /**
@@ -89,6 +90,4 @@ export declare function createAttachSessionFn(runtime: Runtime, metadata?: Parti
89
90
  }): (sessionId: string) => Session;
90
91
  /** Live metadata and routing authority stay separate, including when auth changes mid-step. */
91
92
  export declare function buildChannelContext(accessor: ContextAccessor): ChannelContext;
92
- /** @internal Converts validated public callback metadata into runtime turn routing. */
93
- export declare function sessionCallbackToTurnCaller(callback: SessionCallback | undefined): TurnCaller | undefined;
94
93
  export {};
@@ -1 +1 @@
1
- import{attachClientContext,readClientContext}from"#internal/client-context.js";import{commandDelivery}from"#channel/delivery.js";import{validateDeliveryIdempotencyKey}from"#channel/delivery-idempotency.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{serializeFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY,controlCommand}from"#channel/types.js";import{validateSessionHistory}from"#shared/session-history.js";import{parseAnswers}from"#shared/input.js";import{AuthKey,ContinuationHookTokensKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";function internalSession(e){return e}const SESSION_SEND_OPTION_KEYS=Object.keys({auth:!0,context:!0,history:!0,idempotencyKey:!0,outputSchema:!0,title:!0,turnPolicy:!0});function toSessionSendOptions(e){validateDeliveryIdempotencyKey(e.idempotencyKey);let t={};for(let n of SESSION_SEND_OPTION_KEYS)e[n]!==void 0&&(t[n]=e[n]);return t}function createSession(e,t,n={}){return{id:e,async send(r,i){validateDeliveryIdempotencyKey(i.idempotencyKey);let a=createDelivery(n,i.deliveryId),o=sessionCallbackToTurnCaller(i.callback),s=validateSessionHistory(i.history),c=attachClientContext({message:serializeFilePartsInMessage(r)},readClientContext(i));i.context!==void 0&&(c.context=i.context),s!==void 0&&(c.history=s),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:a,kind:`send`,payload:c,requestId:n.requestId,turnPolicy:i.turnPolicy??n.turnPolicy??DEFAULT_TURN_POLICY,title:i.title},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,a.deliveryId)},async respond(r,i){if(validateDeliveryIdempotencyKey(i.idempotencyKey),r.length===0)throw Error(`respond() requires at least one answer.`);let a=parseAnswers(r),o=sessionCallbackToTurnCaller(i.callback),s=createDelivery(n,i.deliveryId),c=attachClientContext({answers:a},readClientContext(i));i.context!==void 0&&(c.context=i.context),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:s,kind:`send`,payload:c,requestId:n.requestId},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,s.deliveryId)},async cancel(n){let r=controlCommand({kind:`cancel`,turnId:n?.turnId},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async prewarm(){return await t.dispatchSession({command:{kind:`prewarm`,targetDeploymentId:n.acceptedDeploymentId},sessionId:e})},async compact(n){let r=controlCommand({kind:`compact`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async clear(n){let r=controlCommand({kind:`clear`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async reset(n){let r=controlCommand({kind:`reset`,reason:n?.reason},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId,{follow:!1})},async*stream(n){yield*await t.getEventStream(e,n)},async getLineStream(n){return t.getLineStream(e,n)},async getStreamTailIndex(){return t.getStreamTailIndex(e)},async hasRunnableOwner(){return await t.hasRunnableOwner?.(e)??!0},async getChildBinding(n){return await t.readChildBinding?.(e,n)}}}function createAttachSessionFn(e,t={}){return n=>createSession(n,e,t)}function createDelivery(e,t){let n=createChannelDeliveryMetadata({channelKind:`http`,channelName:`http`,...e});return t===void 0?n:{...n,deliveryId:t}}function buildChannelContext(e){return{session:{get id(){return e.get(SessionIdKey)??``},get auth(){return{current:e.get(AuthKey)??null,initiator:e.get(InitiatorAuthKey)??null}}},get continuation(){let t=e.get(ContinuationTokenKey);if(t!==void 0&&t.length!==0)return{token:toChannelLocalContinuationToken(t),alias(n){if(n.length===0)throw Error(`A session alias requires a nonempty token.`);let r=namespaceContinuationToken(t,n);t!==r&&(e.set(ContinuationHookTokensKey,e=>{let n=e??[t];return n.includes(r)?n:[...n,r]}),e.set(ContinuationTokenKey,r))}}}}}function namespaceContinuationToken(e,t){let n=e.indexOf(`:`);if(n<=0)throw Error(`Cannot set session continuation token without an existing namespaced continuation token. Start the session with a placeholder continuationToken.`);return`${e.slice(0,n+1)}${t}`}function sessionCallbackToTurnCaller(e){return e===void 0?void 0:{callId:e.callId,replyTo:{kind:`callback`,token:e.token,url:e.url},subagentName:e.subagentName}}export{buildChannelContext,createAttachSessionFn,createSession,internalSession,sessionCallbackToTurnCaller,toSessionSendOptions};
1
+ import{attachClientContext,readClientContext}from"#internal/client-context.js";import{commandDelivery}from"#channel/delivery.js";import{validateDeliveryIdempotencyKey}from"#channel/delivery-idempotency.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{serializeFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY,controlCommand}from"#channel/types.js";import{validateSessionHistory}from"#shared/session-history.js";import{parseAnswers}from"#shared/input.js";import{AuthKey,ContinuationHookTokensKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";function internalSession(e){return e}const SESSION_SEND_OPTION_KEYS=Object.keys({auth:!0,context:!0,history:!0,idempotencyKey:!0,outputSchema:!0,title:!0,turnPolicy:!0});function toSessionSendOptions(e){validateDeliveryIdempotencyKey(e.idempotencyKey);let t={};for(let n of SESSION_SEND_OPTION_KEYS)e[n]!==void 0&&(t[n]=e[n]);return t}function createSession(e,t,n={}){return{id:e,async send(r,i){validateDeliveryIdempotencyKey(i.idempotencyKey);let a=createDelivery(n,i.deliveryId),o=sessionCallbackToTurnCaller(i.callback),s=validateSessionHistory(i.history),c=attachClientContext({message:serializeFilePartsInMessage(r)},readClientContext(i));i.context!==void 0&&(c.context=i.context),s!==void 0&&(c.history=s),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:a,kind:`send`,payload:c,requestId:n.requestId,turnPolicy:i.turnPolicy??n.turnPolicy??DEFAULT_TURN_POLICY,title:i.title},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,a.deliveryId)},async respond(r,i){if(validateDeliveryIdempotencyKey(i.idempotencyKey),r.length===0)throw Error(`respond() requires at least one answer.`);let a=parseAnswers(r),o=sessionCallbackToTurnCaller(i.callback),s=createDelivery(n,i.deliveryId),c=attachClientContext({answers:a},readClientContext(i));i.context!==void 0&&(c.context=i.context),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:s,kind:`send`,payload:c,requestId:n.requestId},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,s.deliveryId)},async cancel(n){let r=controlCommand({kind:`cancel`,turnId:n?.turnId},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async prewarm(){return await t.dispatchSession({command:{kind:`prewarm`,targetDeploymentId:n.acceptedDeploymentId},sessionId:e})},async compact(n){let r=controlCommand({kind:`compact`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async clear(n){let r=controlCommand({kind:`clear`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async end(n){let r=controlCommand({kind:`reset`,reason:n?.reason},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId,{follow:!1})},async*stream(n){yield*await t.getEventStream(e,n)},async getLineStream(n){return t.getLineStream(e,n)},async getStreamTailIndex(){return t.getStreamTailIndex(e)},async hasRunnableOwner(){return await t.hasRunnableOwner?.(e)??!0},async getChildBinding(n){return await t.readChildBinding?.(e,n)}}}function createAttachSessionFn(e,t={}){return n=>createSession(n,e,t)}function createDelivery(e,t){let n=createChannelDeliveryMetadata({channelKind:`http`,channelName:`http`,...e});return t===void 0?n:{...n,deliveryId:t}}function buildChannelContext(e){return{session:{get id(){return e.get(SessionIdKey)??``},get auth(){return{current:e.get(AuthKey)??null,initiator:e.get(InitiatorAuthKey)??null}}},get continuation(){let t=e.get(ContinuationTokenKey);if(t!==void 0&&t.length!==0)return{token:toChannelLocalContinuationToken(t),alias(n){if(n.length===0)throw Error(`A session alias requires a nonempty token.`);let r=namespaceContinuationToken(t,n);t!==r&&(e.set(ContinuationHookTokensKey,e=>{let n=e??[t];return n.includes(r)?n:[...n,r]}),e.set(ContinuationTokenKey,r))}}}}}function namespaceContinuationToken(e,t){let n=e.indexOf(`:`);if(n<=0)throw Error(`Cannot set session continuation token without an existing namespaced continuation token. Start the session with a placeholder continuationToken.`);return`${e.slice(0,n+1)}${t}`}function sessionCallbackToTurnCaller(e){return e===void 0?void 0:{callId:e.callId,replyTo:{kind:`callback`,token:e.token,url:e.url},subagentName:e.subagentName}}export{buildChannelContext,createAttachSessionFn,createSession,internalSession,sessionCallbackToTurnCaller,toSessionSendOptions};
@@ -13,7 +13,6 @@ import type { SessionHistoryMessage } from "#shared/session-history.js";
13
13
  import type { InstrumentationDecision } from "#shared/instrumentation-decision.js";
14
14
  import type { ForwardedTraceAssertion } from "#shared/forwarded-trace-policy.js";
15
15
  import type { ConversationContext } from "#shared/conversation-context.js";
16
- import type { StubScope } from "#tool-stubs/types.js";
17
16
  export type { ContextAccessor } from "#context/key.js";
18
17
  export type { ChannelInstrumentationProjection } from "#channel/instrumentation.js";
19
18
  import type { ChannelInstrumentationProjection } from "#channel/instrumentation.js";
@@ -205,8 +204,8 @@ export type SessionSendCommandResult = {
205
204
  /** The workflow exists but its inbox is not yet available; no delivery was accepted. */
206
205
  readonly retryable?: boolean;
207
206
  };
208
- /** Result of terminally resetting a session. */
209
- export type ResetSessionResult = {
207
+ /** Result of ending a session. The `"reset"` status is kept for wire compatibility. */
208
+ export type EndSessionResult = {
210
209
  readonly status: "reset";
211
210
  readonly previousSessionId: string;
212
211
  } | {
@@ -222,7 +221,7 @@ export type SessionCommandResult<TCommand extends SessionCommand = SessionComman
222
221
  readonly kind: "compact";
223
222
  } ? CompactSessionResult : TCommand extends {
224
223
  readonly kind: "clear";
225
- } ? ClearSessionResult : ResetSessionResult;
224
+ } ? ClearSessionResult : EndSessionResult;
226
225
  export interface DispatchContinuationInput<TCommand extends SessionCommand = SessionCommand> {
227
226
  readonly command: TCommand;
228
227
  readonly continuationToken: string;
@@ -394,14 +393,6 @@ export interface SessionCapabilities {
394
393
  export interface RunInput {
395
394
  /** Optional stable identity of the initial delivery, scoped to this logical session. */
396
395
  readonly idempotencyKey?: string;
397
- /**
398
- * @internal Set by the server after it authorizes tool stubs.
399
- * Local subagents match rules qualified by their full path, such as researcher/list_tasks.
400
- * The root session tracks positions per rule; subagent sessions at the same path
401
- * share those positions. Unprefixed rules apply only to root tools.
402
- * Remote agents do not receive these stubs.
403
- */
404
- readonly toolStubs?: StubScope;
405
396
  /** Server-supplied provenance inherited by locally delegated scheduled work. */
406
397
  readonly schedule?: import("#context/session-schedule.js").SessionSchedule;
407
398
  readonly adapter: ChannelAdapter<any>;
@@ -551,12 +542,12 @@ export interface Runtime {
551
542
  * Sends a command to whichever session owns a continuation address. When
552
543
  * that owner is stranded, a send with a `successor` ends it and is accepted
553
544
  * by the successor; a send without one, or a `clear`, throws
554
- * `SessionStrandedError`, and a `reset` ends it.
545
+ * `SessionStrandedError`, and an `end()` call retires it.
555
546
  */
556
547
  dispatchContinuation<TCommand extends SessionCommand>(input: DispatchContinuationInput<TCommand>): Promise<SessionCommandResult<TCommand>>;
557
548
  /**
558
549
  * Sends a command to one exact session. A send or `clear` to a stranded
559
- * session throws `SessionStrandedError`; a `reset` ends it.
550
+ * session throws `SessionStrandedError`; an `end()` call retires it.
560
551
  */
561
552
  dispatchSession<TCommand extends SessionCommand>(input: DispatchSessionInput<TCommand>): Promise<SessionCommandResult<TCommand>>;
562
553
  /**