eve 0.68.0 → 0.70.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 (1196) hide show
  1. package/CHANGELOG.md +132 -0
  2. package/bin/eve.js +15 -0
  3. package/dist/src/_virtual/_rolldown/runtime.js +1 -1
  4. package/dist/src/acp/adapter.js +1 -1
  5. package/dist/src/approval/definition.d.ts +19 -5
  6. package/dist/src/channel/adapter.d.ts +2 -0
  7. package/dist/src/channel/auth/oidc.js +1 -1
  8. package/dist/src/channel/channel-address.d.ts +1 -4
  9. package/dist/src/channel/channel-address.js +1 -1
  10. package/dist/src/channel/channel-operations.d.ts +4 -11
  11. package/dist/src/channel/channel-operations.js +1 -1
  12. package/dist/src/channel/compiled-channel.d.ts +0 -2
  13. package/dist/src/channel/compiled-channel.js +2 -2
  14. package/dist/src/channel/cross-channel-receive.d.ts +1 -3
  15. package/dist/src/channel/cross-channel-receive.js +1 -1
  16. package/dist/src/channel/forwarded-principal.js +1 -1
  17. package/dist/src/channel/schedule-auth.d.ts +16 -0
  18. package/dist/src/channel/schedule-auth.js +1 -1
  19. package/dist/src/channel/session-callback.js +1 -1
  20. package/dist/src/channel/session.d.ts +3 -8
  21. package/dist/src/channel/session.js +1 -1
  22. package/dist/src/channel/task-card.d.ts +121 -0
  23. package/dist/src/channel/task-card.js +1 -0
  24. package/dist/src/channel/types.d.ts +30 -57
  25. package/dist/src/chunks/{use-eve-agent-D4HVZBjn.js → use-eve-agent-CJQeE7-t.js} +2058 -1331
  26. package/dist/src/chunks/{use-eve-agent-DXcE_8Ja.js → use-eve-agent-DdemtY6C.js} +2061 -1331
  27. package/dist/src/cli/commands/info.d.ts +11 -0
  28. package/dist/src/cli/commands/info.js +1 -1
  29. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  30. package/dist/src/cli/commands/init.js +1 -1
  31. package/dist/src/cli/dev/command-options.d.ts +2 -2
  32. package/dist/src/cli/dev/command.js +1 -1
  33. package/dist/src/cli/dev/console-records-preload.d.ts +1 -0
  34. package/dist/src/cli/dev/console-records-preload.js +1 -0
  35. package/dist/src/cli/dev/console-records.d.ts +17 -0
  36. package/dist/src/cli/dev/console-records.js +3 -0
  37. package/dist/src/cli/dev/diagnostic-sink.d.ts +1 -0
  38. package/dist/src/cli/dev/local-server-process.js +1 -1
  39. package/dist/src/cli/dev/tui/blocks.d.ts +21 -19
  40. package/dist/src/cli/dev/tui/blocks.js +4 -4
  41. package/dist/src/cli/dev/tui/command-typeahead.d.ts +3 -6
  42. package/dist/src/cli/dev/tui/conversation-view.d.ts +54 -0
  43. package/dist/src/cli/dev/tui/conversation-view.js +1 -0
  44. package/dist/src/cli/dev/tui/diagnostic-presentation.d.ts +10 -0
  45. package/dist/src/cli/dev/tui/diagnostic-presentation.js +3 -2
  46. package/dist/src/cli/dev/tui/flow-drawer.d.ts +5 -2
  47. package/dist/src/cli/dev/tui/flow-drawer.js +1 -1
  48. package/dist/src/cli/dev/tui/log-display-mode.d.ts +4 -10
  49. package/dist/src/cli/dev/tui/log-display-mode.js +1 -1
  50. package/dist/src/cli/dev/tui/message-queue.d.ts +7 -63
  51. package/dist/src/cli/dev/tui/message-queue.js +3 -1
  52. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  53. package/dist/src/cli/dev/tui/prompt-placeholder.d.ts +2 -0
  54. package/dist/src/cli/dev/tui/prompt-placeholder.js +1 -0
  55. package/dist/src/cli/dev/tui/question-panel.d.ts +3 -1
  56. package/dist/src/cli/dev/tui/question-panel.js +1 -1
  57. package/dist/src/cli/dev/tui/rail.d.ts +1 -1
  58. package/dist/src/cli/dev/tui/runner.d.ts +60 -174
  59. package/dist/src/cli/dev/tui/runner.js +3 -3
  60. package/dist/src/cli/dev/tui/status-line.d.ts +4 -2
  61. package/dist/src/cli/dev/tui/status-line.js +1 -1
  62. package/dist/src/cli/dev/tui/task-activity.d.ts +59 -0
  63. package/dist/src/cli/dev/tui/task-activity.js +1 -0
  64. package/dist/src/cli/dev/tui/terminal-renderer.d.ts +18 -57
  65. package/dist/src/cli/dev/tui/terminal-renderer.js +10 -13
  66. package/dist/src/cli/dev/tui/terminal-tool-part.d.ts +2 -0
  67. package/dist/src/cli/dev/tui/terminal-tool-part.js +1 -0
  68. package/dist/src/cli/dev/tui/test/fake-eve-server.d.ts +34 -0
  69. package/dist/src/cli/dev/tui/test/fake-eve-server.js +1 -0
  70. package/dist/src/cli/dev/tui/test/index.d.ts +1 -0
  71. package/dist/src/cli/dev/tui/test/index.js +1 -1
  72. package/dist/src/cli/dev/tui/theme.d.ts +1 -1
  73. package/dist/src/cli/dev/tui/theme.js +1 -1
  74. package/dist/src/cli/dev/tui/tool-block-groups.d.ts +6 -9
  75. package/dist/src/cli/dev/tui/tool-block-groups.js +1 -1
  76. package/dist/src/cli/dev/tui/tool-presentation.d.ts +17 -3
  77. package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
  78. package/dist/src/cli/dev/tui/tool-rows.d.ts +1 -0
  79. package/dist/src/cli/dev/tui/tool-rows.js +2 -2
  80. package/dist/src/cli/dev/tui/traces/trace-conversation.js +3 -1
  81. package/dist/src/cli/dev/tui/traces/trace-view.js +1 -1
  82. package/dist/src/cli/dev/tui/transcript-parts.d.ts +73 -0
  83. package/dist/src/cli/dev/tui/transcript-parts.js +3 -0
  84. package/dist/src/cli/dev/tui/transcript.d.ts +47 -0
  85. package/dist/src/cli/dev/tui/transcript.js +1 -0
  86. package/dist/src/cli/dev/tui/tui.js +1 -1
  87. package/dist/src/cli/dev/tui/turn-clock.d.ts +11 -26
  88. package/dist/src/cli/dev/tui/turn-clock.js +1 -1
  89. package/dist/src/cli/dev/tui/types.d.ts +13 -9
  90. package/dist/src/cli/dev/ui-options.d.ts +2 -2
  91. package/dist/src/cli/dev/ui-options.js +1 -1
  92. package/dist/src/cli/option-parsers.d.ts +3 -1
  93. package/dist/src/cli/option-parsers.js +1 -1
  94. package/dist/src/cli/ui/terminal-text.js +1 -1
  95. package/dist/src/client/agent-info-schema.d.ts +150 -9
  96. package/dist/src/client/agent-info-schema.js +1 -1
  97. package/dist/src/client/agent-session.d.ts +28 -0
  98. package/dist/src/client/agent-session.js +1 -0
  99. package/dist/src/client/agent-stream-follower.d.ts +26 -0
  100. package/dist/src/client/agent-stream-follower.js +1 -0
  101. package/dist/src/client/authorization-message-parts.js +1 -1
  102. package/dist/src/client/conversation-client.d.ts +40 -0
  103. package/dist/src/client/conversation-client.js +1 -0
  104. package/dist/src/client/conversation-reducer.d.ts +29 -0
  105. package/dist/src/client/conversation-reducer.js +1 -0
  106. package/dist/src/client/conversation-state.d.ts +110 -0
  107. package/dist/src/client/conversation-state.js +1 -0
  108. package/dist/src/client/eve-agent-projection.d.ts +24 -7
  109. package/dist/src/client/eve-agent-projection.js +1 -1
  110. package/dist/src/client/eve-agent-store-helpers.d.ts +20 -1
  111. package/dist/src/client/eve-agent-store-helpers.js +2 -2
  112. package/dist/src/client/eve-agent-store-state.d.ts +15 -3
  113. package/dist/src/client/eve-agent-store.d.ts +10 -1
  114. package/dist/src/client/eve-agent-store.js +1 -1
  115. package/dist/src/client/index.d.ts +5 -1
  116. package/dist/src/client/index.js +1 -1
  117. package/dist/src/client/message-action-parts.js +1 -1
  118. package/dist/src/client/message-reducer-primitives.d.ts +1 -2
  119. package/dist/src/client/message-reducer-primitives.js +1 -1
  120. package/dist/src/client/message-reducer-types.d.ts +9 -2
  121. package/dist/src/client/message-reducer.js +1 -1
  122. package/dist/src/client/message-response.js +1 -1
  123. package/dist/src/client/message-run-parts.d.ts +10 -6
  124. package/dist/src/client/message-run-parts.js +1 -1
  125. package/dist/src/client/message-task-parts.d.ts +8 -0
  126. package/dist/src/client/message-task-parts.js +1 -0
  127. package/dist/src/client/optimistic-message-submissions.d.ts +6 -4
  128. package/dist/src/client/optimistic-message-submissions.js +1 -1
  129. package/dist/src/client/reducer.d.ts +5 -1
  130. package/dist/src/client/session-controls.d.ts +0 -1
  131. package/dist/src/client/session-turn-dispatch.d.ts +15 -0
  132. package/dist/src/client/session-turn-dispatch.js +1 -0
  133. package/dist/src/client/session-utils.d.ts +29 -2
  134. package/dist/src/client/session-utils.js +1 -1
  135. package/dist/src/client/session.d.ts +8 -16
  136. package/dist/src/client/session.js +1 -1
  137. package/dist/src/client/stream-version.js +1 -1
  138. package/dist/src/client/types.d.ts +4 -5
  139. package/dist/src/compiled/.vendor-stamp.json +3 -2
  140. package/dist/src/compiled/@eve/catalog/index.js +1 -1
  141. package/dist/src/compiled/@vercel/connect/LICENSE +202 -0
  142. package/dist/src/compiled/@vercel/connect/authorization-details.d.ts +11 -0
  143. package/dist/src/compiled/@vercel/connect/authorization.d.ts +47 -0
  144. package/dist/src/compiled/@vercel/connect/connector.d.ts +32 -0
  145. package/dist/src/compiled/@vercel/connect/index.d.ts +5 -0
  146. package/dist/src/compiled/@vercel/connect/index.js +26 -0
  147. package/dist/src/compiled/@vercel/connect/installation.d.ts +48 -0
  148. package/dist/src/compiled/@vercel/connect/token.d.ts +137 -0
  149. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  150. package/dist/src/compiler/bundled-extension.d.ts +7 -1
  151. package/dist/src/compiler/bundled-extension.js +1 -1
  152. package/dist/src/compiler/default-tool-policy.d.ts +2 -2
  153. package/dist/src/compiler/default-tool-policy.js +1 -1
  154. package/dist/src/compiler/development-extensions.js +1 -1
  155. package/dist/src/compiler/extension-compatibility.d.ts +54 -18
  156. package/dist/src/compiler/extension-compatibility.js +1 -1
  157. package/dist/src/compiler/extension-mount-bindings.d.ts +5 -0
  158. package/dist/src/compiler/extension-mount-bindings.js +1 -0
  159. package/dist/src/compiler/load-binding-namespace.d.ts +10 -2
  160. package/dist/src/compiler/load-binding-namespace.js +1 -1
  161. package/dist/src/compiler/manifest.d.ts +19 -17
  162. package/dist/src/compiler/manifest.js +1 -1
  163. package/dist/src/compiler/module-lifecycle.d.ts +2 -2
  164. package/dist/src/compiler/module-lifecycle.js +1 -1
  165. package/dist/src/compiler/module-map.d.ts +1 -1
  166. package/dist/src/compiler/module-map.js +3 -3
  167. package/dist/src/compiler/normalize-manifest-helpers.d.ts +18 -1
  168. package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
  169. package/dist/src/compiler/normalize-manifest-types.d.ts +2 -0
  170. package/dist/src/compiler/normalize-manifest.js +1 -1
  171. package/dist/src/compiler/normalize-subagent.js +1 -1
  172. package/dist/src/compiler/normalize-tool.js +1 -1
  173. package/dist/src/compiler/project-sources.d.ts +4 -0
  174. package/dist/src/compiler/project-sources.js +1 -1
  175. package/dist/src/compiler/remote-agent-node.js +1 -1
  176. package/dist/src/compiler/source-graph.d.ts +5 -0
  177. package/dist/src/compiler/source-graph.js +1 -1
  178. package/dist/src/computer-use/extension/lib/computer-use-sandbox.d.ts +8 -0
  179. package/dist/src/computer-use/extension/lib/computer-use-sandbox.js +3 -3
  180. package/dist/src/computer-use/extension/lib/computer-use.d.ts +2 -0
  181. package/dist/src/computer-use/extension/lib/computer-use.js +2 -1
  182. package/dist/src/computer-use/extension/tools/computer_use.js +1 -1
  183. package/dist/src/context/build-dynamic-tools.js +1 -1
  184. package/dist/src/context/dynamic-subagent-lifecycle.d.ts +5 -0
  185. package/dist/src/context/dynamic-subagent-lifecycle.js +1 -1
  186. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  187. package/dist/src/context/dynamic-tool-metadata.d.ts +1 -1
  188. package/dist/src/context/key-names.d.ts +0 -1
  189. package/dist/src/context/key-names.js +1 -1
  190. package/dist/src/context/keys.d.ts +12 -15
  191. package/dist/src/context/keys.js +1 -1
  192. package/dist/src/context/memory-lifecycle.js +1 -1
  193. package/dist/src/context/memory-tools.d.ts +0 -1
  194. package/dist/src/context/provider.d.ts +5 -11
  195. package/dist/src/context/run-step.d.ts +5 -6
  196. package/dist/src/context/run-step.js +1 -1
  197. package/dist/src/context/serialize.js +1 -1
  198. package/dist/src/discover/bundled-extension.js +1 -1
  199. package/dist/src/discover/discover-agent.js +1 -1
  200. package/dist/src/discover/extensions.d.ts +0 -7
  201. package/dist/src/discover/extensions.js +1 -1
  202. package/dist/src/discover/manifest.d.ts +4 -0
  203. package/dist/src/evals/assertions/run.d.ts +4 -3
  204. package/dist/src/evals/assertions/run.js +1 -1
  205. package/dist/src/evals/index.d.ts +1 -1
  206. package/dist/src/evals/match.d.ts +4 -4
  207. package/dist/src/evals/mock-model.js +1 -1
  208. package/dist/src/evals/runner/derive-run-facts.d.ts +3 -3
  209. package/dist/src/evals/runner/derive-run-facts.js +1 -1
  210. package/dist/src/evals/runner/execute-task.js +1 -1
  211. package/dist/src/evals/runner/reporters/assertion-scores.d.ts +19 -0
  212. package/dist/src/evals/runner/reporters/assertion-scores.js +1 -0
  213. package/dist/src/evals/runner/reporters/braintrust.js +1 -1
  214. package/dist/src/evals/runner/reporters/datadog-client.d.ts +123 -0
  215. package/dist/src/evals/runner/reporters/datadog-client.js +4 -0
  216. package/dist/src/evals/runner/reporters/datadog.d.ts +9 -98
  217. package/dist/src/evals/runner/reporters/datadog.js +2 -3
  218. package/dist/src/evals/session-content.js +1 -1
  219. package/dist/src/evals/session.d.ts +4 -4
  220. package/dist/src/evals/session.js +2 -2
  221. package/dist/src/evals/types.d.ts +34 -15
  222. package/dist/src/eve-channel/create-request.d.ts +5 -4
  223. package/dist/src/eve-channel/create-request.js +1 -1
  224. package/dist/src/eve-channel/index.d.ts +0 -9
  225. package/dist/src/eve-channel/index.js +1 -1
  226. package/dist/src/eve-channel/request.d.ts +3 -7
  227. package/dist/src/eve-channel/request.js +1 -1
  228. package/dist/src/eve-channel/support.d.ts +15 -5
  229. package/dist/src/eve-channel/support.js +1 -1
  230. package/dist/src/eve-channel/turn-policy-request.d.ts +2 -0
  231. package/dist/src/eve-channel/turn-policy-request.js +1 -0
  232. package/dist/src/eve-channel/types.d.ts +4 -0
  233. package/dist/src/execution/agent-sessions/context.d.ts +62 -0
  234. package/dist/src/execution/agent-sessions/context.js +1 -0
  235. package/dist/src/{subagents/remote-dispatch.d.ts → execution/agent-sessions/remote.d.ts} +17 -40
  236. package/dist/src/execution/agent-sessions/remote.js +1 -0
  237. package/dist/src/execution/agent-sessions/requests.d.ts +20 -0
  238. package/dist/src/execution/agent-sessions/requests.js +1 -0
  239. package/dist/src/execution/agent-sessions/session.d.ts +12 -0
  240. package/dist/src/execution/agent-sessions/session.js +1 -0
  241. package/dist/src/execution/agent-sessions/steps.d.ts +59 -0
  242. package/dist/src/execution/agent-sessions/steps.js +1 -0
  243. package/dist/src/execution/agent-sessions/target.d.ts +45 -0
  244. package/dist/src/execution/agent-sessions/target.js +1 -0
  245. package/dist/src/execution/agent-sessions/usage.d.ts +18 -0
  246. package/dist/src/execution/agent-sessions/usage.js +1 -0
  247. package/dist/src/execution/authorization-callback-match.d.ts +2 -4
  248. package/dist/src/execution/authorization-callback-match.js +1 -1
  249. package/dist/src/execution/cancel-descendant-turns-step.d.ts +1 -5
  250. package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
  251. package/dist/src/execution/cancelled-model-call-batch.js +1 -1
  252. package/dist/src/execution/connection-announcement.d.ts +7 -0
  253. package/dist/src/execution/connection-announcement.js +4 -0
  254. package/dist/src/execution/continuation-conflict-step.d.ts +2 -3
  255. package/dist/src/execution/continuation-conflict-step.js +1 -1
  256. package/dist/src/execution/coordination-dispatch-shared.d.ts +12 -28
  257. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  258. package/dist/src/execution/coordination-dispatch-step.d.ts +3 -2
  259. package/dist/src/execution/coordination-dispatch-step.js +1 -1
  260. package/dist/src/execution/create-session-step.d.ts +4 -3
  261. package/dist/src/execution/create-session-step.js +1 -1
  262. package/dist/src/execution/deliver-payloads.js +1 -1
  263. package/dist/src/execution/durable-session-store.d.ts +10 -5
  264. package/dist/src/execution/durable-session-store.js +1 -1
  265. package/dist/src/execution/dynamic-connections.js +1 -1
  266. package/dist/src/execution/dynamic-workflow/program-step.js +1 -1
  267. package/dist/src/execution/dynamic-workflow/schema.d.ts +1 -3
  268. package/dist/src/execution/dynamic-workflow/schema.js +1 -1
  269. package/dist/src/execution/dynamic-workflow/tool.d.ts +1 -1
  270. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  271. package/dist/src/execution/dynamic-workflow/workflow.js +1 -1
  272. package/dist/src/execution/forward-session-input.d.ts +4 -0
  273. package/dist/src/execution/forward-session-input.js +1 -0
  274. package/dist/src/execution/legacy-remote-agent/protocol.d.ts +41 -0
  275. package/dist/src/execution/legacy-remote-agent/protocol.js +1 -0
  276. package/dist/src/execution/legacy-session/authorization.js +1 -1
  277. package/dist/src/execution/legacy-session/completion-step.d.ts +2 -0
  278. package/dist/src/execution/legacy-session/completion-step.js +1 -1
  279. package/dist/src/execution/legacy-session/inbox.js +1 -1
  280. package/dist/src/execution/legacy-session/input.js +1 -1
  281. package/dist/src/execution/legacy-session/interrupt-step.js +1 -1
  282. package/dist/src/execution/legacy-session/prepare-step.d.ts +1 -0
  283. package/dist/src/execution/legacy-session/prepare-step.js +1 -1
  284. package/dist/src/execution/legacy-session/snapshot.d.ts +8 -4
  285. package/dist/src/execution/legacy-session/snapshot.js +1 -1
  286. package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
  287. package/dist/src/execution/model-call-batching.js +1 -1
  288. package/dist/src/execution/node-step.d.ts +1 -1
  289. package/dist/src/execution/node-step.js +1 -1
  290. package/dist/src/execution/proxied-deliver-step.d.ts +9 -6
  291. package/dist/src/execution/proxied-deliver-step.js +1 -1
  292. package/dist/src/execution/publish-session-events.d.ts +150 -0
  293. package/dist/src/execution/publish-session-events.js +1 -0
  294. package/dist/src/execution/reconcile-session-continuation-token.d.ts +2 -2
  295. package/dist/src/execution/route-child-delivery.d.ts +5 -4
  296. package/dist/src/execution/route-child-delivery.js +1 -3
  297. package/dist/src/execution/runtime-context.js +1 -1
  298. package/dist/src/execution/sandbox/prewarm.js +1 -1
  299. package/dist/src/execution/session/active-turn.d.ts +97 -0
  300. package/dist/src/execution/session/active-turn.js +1 -0
  301. package/dist/src/execution/session/admission.d.ts +1 -12
  302. package/dist/src/execution/session/admission.js +1 -1
  303. package/dist/src/execution/session/entry-input.d.ts +0 -2
  304. package/dist/src/execution/session/entry.js +1 -1
  305. package/dist/src/execution/session/finalization.js +1 -1
  306. package/dist/src/execution/session/handoff-steps.d.ts +13 -2
  307. package/dist/src/execution/session/handoff-steps.js +1 -1
  308. package/dist/src/execution/session/handoff.d.ts +21 -5
  309. package/dist/src/execution/session/handoff.js +1 -1
  310. package/dist/src/execution/session/input-queue.d.ts +44 -39
  311. package/dist/src/execution/session/input-queue.js +1 -1
  312. package/dist/src/execution/session/next-input.d.ts +7 -10
  313. package/dist/src/execution/session/next-input.js +1 -1
  314. package/dist/src/execution/session/pending-turn-state.d.ts +2 -0
  315. package/dist/src/execution/session/pending-turn-state.js +1 -1
  316. package/dist/src/execution/session/principal.d.ts +14 -0
  317. package/dist/src/execution/session/principal.js +1 -0
  318. package/dist/src/execution/session/program.d.ts +2 -0
  319. package/dist/src/execution/session/program.js +1 -1
  320. package/dist/src/execution/session/route-selected-delivery.js +1 -1
  321. package/dist/src/execution/session/state-cursor.d.ts +26 -18
  322. package/dist/src/execution/session/state-cursor.js +1 -1
  323. package/dist/src/execution/session/state-delta.d.ts +40 -0
  324. package/dist/src/execution/session/state-delta.js +1 -0
  325. package/dist/src/execution/session/timeout-steps.js +1 -1
  326. package/dist/src/execution/session/turn-event-handler.d.ts +2 -2
  327. package/dist/src/execution/session/turn-event-handler.js +1 -1
  328. package/dist/src/execution/session/turn-step-result.d.ts +1 -3
  329. package/dist/src/execution/session/turn-step-result.js +1 -1
  330. package/dist/src/execution/session/turn-step-types.d.ts +37 -19
  331. package/dist/src/execution/session/turn-step.d.ts +2 -2
  332. package/dist/src/execution/session/turn-step.js +1 -1
  333. package/dist/src/execution/session/turn-waiting-step.d.ts +4 -0
  334. package/dist/src/execution/session/turn-waiting-step.js +1 -0
  335. package/dist/src/execution/session/turn.d.ts +41 -3
  336. package/dist/src/execution/session/turn.js +1 -1
  337. package/dist/src/execution/session-callback-request.js +1 -1
  338. package/dist/src/execution/session-event-stream.d.ts +33 -0
  339. package/dist/src/execution/session-event-stream.js +1 -0
  340. package/dist/src/execution/session-inbox/inbox.d.ts +2 -0
  341. package/dist/src/execution/session-inbox/inbox.js +1 -1
  342. package/dist/src/execution/session-inbox/protocol.js +1 -1
  343. package/dist/src/execution/session-inbox/release-step.js +1 -1
  344. package/dist/src/execution/session-inbox/resume.js +1 -1
  345. package/dist/src/execution/session-workflow-tool-run.d.ts +11 -2
  346. package/dist/src/execution/session-workflow-tool-run.js +1 -1
  347. package/dist/src/execution/session.d.ts +5 -6
  348. package/dist/src/execution/session.js +2 -2
  349. package/dist/src/execution/settle-cancelled-turn-step.d.ts +23 -10
  350. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  351. package/dist/src/execution/stable-workflow-names.d.ts +0 -1
  352. package/dist/src/execution/stable-workflow-names.js +1 -1
  353. package/dist/src/execution/tasks/calls.d.ts +42 -0
  354. package/dist/src/execution/tasks/calls.js +1 -0
  355. package/dist/src/execution/tasks/model-step.d.ts +58 -0
  356. package/dist/src/execution/tasks/model-step.js +1 -0
  357. package/dist/src/execution/tasks/render.d.ts +66 -0
  358. package/dist/src/execution/tasks/render.js +8 -0
  359. package/dist/src/execution/tasks/session.d.ts +19 -0
  360. package/dist/src/execution/tasks/session.js +1 -0
  361. package/dist/src/execution/tasks/start.d.ts +34 -0
  362. package/dist/src/execution/tasks/start.js +1 -0
  363. package/dist/src/execution/tasks/steps.d.ts +31 -0
  364. package/dist/src/execution/tasks/steps.js +1 -0
  365. package/dist/src/execution/tasks/table.d.ts +192 -0
  366. package/dist/src/execution/tasks/table.js +1 -0
  367. package/dist/src/execution/tasks/task-id-input.d.ts +19 -0
  368. package/dist/src/execution/tasks/task-id-input.js +1 -0
  369. package/dist/src/execution/tasks/tool-entry-point.d.ts +11 -0
  370. package/dist/src/execution/tasks/tool-entry-point.js +1 -0
  371. package/dist/src/execution/tasks/workflow-target.d.ts +2 -0
  372. package/dist/src/execution/tasks/workflow-target.js +1 -1
  373. package/dist/src/execution/terminal-session-completion-step.d.ts +2 -0
  374. package/dist/src/execution/terminal-session-completion-step.js +1 -1
  375. package/dist/src/execution/terminal-session-failure-step.d.ts +2 -0
  376. package/dist/src/execution/terminal-session-failure-step.js +1 -1
  377. package/dist/src/execution/terminate-child-sessions-step.d.ts +2 -9
  378. package/dist/src/execution/terminate-child-sessions-step.js +1 -1
  379. package/dist/src/execution/tool-auth.js +1 -1
  380. package/dist/src/execution/tools/agent-router-workflow.d.ts +1 -1
  381. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  382. package/dist/src/execution/tools/agent-router.d.ts +1 -1
  383. package/dist/src/execution/tools/agent-router.js +1 -1
  384. package/dist/src/execution/tools/connection-approval.d.ts +25 -0
  385. package/dist/src/execution/tools/connection-approval.js +1 -0
  386. package/dist/src/execution/tools/connection-search-rank.d.ts +21 -0
  387. package/dist/src/execution/tools/connection-search-rank.js +1 -0
  388. package/dist/src/execution/tools/connection-target.d.ts +18 -0
  389. package/dist/src/execution/tools/connection-target.js +1 -0
  390. package/dist/src/execution/tools/connection-tools.d.ts +10 -0
  391. package/dist/src/execution/tools/connection-tools.js +2 -0
  392. package/dist/src/execution/tools/load-skill.js +1 -1
  393. package/dist/src/execution/tools/workflow/answer.d.ts +7 -4
  394. package/dist/src/execution/tools/workflow/answer.js +1 -1
  395. package/dist/src/execution/tools/workflow/ask.d.ts +73 -10
  396. package/dist/src/execution/tools/workflow/ask.js +1 -1
  397. package/dist/src/execution/tools/workflow/body.d.ts +60 -19
  398. package/dist/src/execution/tools/workflow/body.js +1 -1
  399. package/dist/src/execution/tools/workflow/cancel.d.ts +7 -2
  400. package/dist/src/execution/tools/workflow/cancel.js +1 -1
  401. package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +10 -4
  402. package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +1 -1
  403. package/dist/src/execution/tools/workflow/{background.d.ts → harness-definition.d.ts} +6 -6
  404. package/dist/src/execution/tools/workflow/harness-definition.js +1 -0
  405. package/dist/src/execution/tools/workflow/interrupt.d.ts +6 -0
  406. package/dist/src/execution/tools/workflow/interrupt.js +1 -0
  407. package/dist/src/execution/tools/workflow/messages.d.ts +135 -10
  408. package/dist/src/execution/tools/workflow/messages.js +1 -1
  409. package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
  410. package/dist/src/execution/tools/workflow/owner.d.ts +15 -4
  411. package/dist/src/execution/tools/workflow/owner.js +1 -1
  412. package/dist/src/execution/tools/workflow/serve.d.ts +3 -0
  413. package/dist/src/execution/tools/workflow/serve.js +1 -0
  414. package/dist/src/execution/tools/workflow/start.d.ts +18 -11
  415. package/dist/src/execution/tools/workflow/start.js +1 -1
  416. package/dist/src/execution/tools/workflow/step-execution.js +1 -1
  417. package/dist/src/execution/tools/workflow/step.js +1 -1
  418. package/dist/src/execution/tools/workflow/types.d.ts +0 -10
  419. package/dist/src/execution/tools/workflow/withdraw-step.d.ts +31 -0
  420. package/dist/src/execution/tools/workflow/withdraw-step.js +1 -0
  421. package/dist/src/execution/tools/workflow/workflow-owner-blocking.d.ts +3 -5
  422. package/dist/src/execution/tools/workflow/workflow-owner-blocking.js +1 -1
  423. package/dist/src/execution/tools/workflow/workflow.d.ts +3 -3
  424. package/dist/src/execution/tools/workflow/workflow.js +1 -1
  425. package/dist/src/execution/web-fetch/request.js +1 -1
  426. package/dist/src/execution/workflow-callback-url.d.ts +0 -5
  427. package/dist/src/execution/workflow-callback-url.js +1 -1
  428. package/dist/src/execution/workflow-runtime.d.ts +3 -5
  429. package/dist/src/execution/workflow-runtime.js +1 -1
  430. package/dist/src/execution/workflow-webhook-route.js +1 -1
  431. package/dist/src/extensions/code/extension/lib/connect-authentication.js +1 -1
  432. package/dist/src/extensions/code/extension/lib/github-shell.js +1 -1
  433. package/dist/src/extensions/code/extension/lib/prwatch-github.js +1 -1
  434. package/dist/src/framework/sources/modules/agent.d.ts +1 -0
  435. package/dist/src/framework/sources/modules/agent.js +1 -1
  436. package/dist/src/framework/sources/registry.js +1 -1
  437. package/dist/src/harness/action-presentation.js +1 -1
  438. package/dist/src/harness/action-result-helpers.d.ts +1 -0
  439. package/dist/src/harness/action-result-helpers.js +1 -1
  440. package/dist/src/harness/advertised-tools.d.ts +1 -1
  441. package/dist/src/harness/advertised-tools.js +1 -1
  442. package/dist/src/harness/announcements.d.ts +22 -0
  443. package/dist/src/harness/announcements.js +1 -0
  444. package/dist/src/harness/approval-candidates.d.ts +10 -2
  445. package/dist/src/harness/approval-candidates.js +1 -1
  446. package/dist/src/harness/approval-delivery-coordinator.d.ts +4 -5
  447. package/dist/src/harness/approval-delivery-coordinator.js +1 -1
  448. package/dist/src/harness/approval-recheck.d.ts +7 -0
  449. package/dist/src/harness/approval-recheck.js +1 -0
  450. package/dist/src/harness/authorization-event-fields.d.ts +13 -0
  451. package/dist/src/harness/authorization-event-fields.js +1 -0
  452. package/dist/src/harness/authorization.d.ts +17 -3
  453. package/dist/src/harness/authorization.js +1 -1
  454. package/dist/src/harness/cancelled-turn-emission.d.ts +2 -1
  455. package/dist/src/harness/cancelled-turn-emission.js +1 -1
  456. package/dist/src/harness/coordination.d.ts +36 -30
  457. package/dist/src/harness/coordination.js +1 -1
  458. package/dist/src/harness/current-messages.d.ts +6 -1
  459. package/dist/src/harness/current-messages.js +1 -1
  460. package/dist/src/harness/emission.d.ts +11 -2
  461. package/dist/src/harness/emission.js +1 -1
  462. package/dist/src/harness/execute-tool.d.ts +4 -15
  463. package/dist/src/harness/held-requests.d.ts +18 -0
  464. package/dist/src/harness/held-requests.js +1 -0
  465. package/dist/src/harness/hitl/approval-input-requests.d.ts +16 -0
  466. package/dist/src/harness/hitl/approval-input-requests.js +1 -1
  467. package/dist/src/harness/hitl/session-limit-input-requests.d.ts +2 -0
  468. package/dist/src/harness/hitl/session-limit-input-requests.js +1 -1
  469. package/dist/src/harness/input-extraction.js +1 -1
  470. package/dist/src/harness/input-request-resolution.d.ts +5 -2
  471. package/dist/src/harness/input-request-resolution.js +1 -1
  472. package/dist/src/harness/input-requests.d.ts +0 -4
  473. package/dist/src/harness/input-requests.js +1 -1
  474. package/dist/src/harness/messages.d.ts +11 -3
  475. package/dist/src/harness/messages.js +1 -1
  476. package/dist/src/harness/model-call-error.js +1 -1
  477. package/dist/src/harness/nested-actions.d.ts +23 -0
  478. package/dist/src/harness/nested-actions.js +1 -0
  479. package/dist/src/harness/pending-input-batches.d.ts +8 -6
  480. package/dist/src/harness/pending-input-batches.js +1 -1
  481. package/dist/src/harness/provider-tool-history.d.ts +7 -2
  482. package/dist/src/harness/provider-tool-history.js +1 -1
  483. package/dist/src/harness/proxy-input-requests.d.ts +45 -40
  484. package/dist/src/harness/proxy-input-requests.js +1 -1
  485. package/dist/src/harness/session-limit-enforcement.js +1 -1
  486. package/dist/src/harness/stale-input-responses.js +1 -1
  487. package/dist/src/harness/step-hooks.js +1 -1
  488. package/dist/src/harness/tool-loop.js +2 -2
  489. package/dist/src/harness/tool-model-output.js +1 -1
  490. package/dist/src/harness/tool-presentation.js +1 -1
  491. package/dist/src/harness/tools.d.ts +1 -5
  492. package/dist/src/harness/tools.js +1 -1
  493. package/dist/src/harness/turn-tag-state.d.ts +8 -5
  494. package/dist/src/harness/turn-tag-state.js +1 -1
  495. package/dist/src/harness/types.d.ts +25 -21
  496. package/dist/src/harness/workflow-dispatch.d.ts +30 -0
  497. package/dist/src/harness/workflow-dispatch.js +1 -0
  498. package/dist/src/harness/workflow-tool-runs.d.ts +5 -65
  499. package/dist/src/harness/workflow-tool-runs.js +1 -1
  500. package/dist/src/instrumentation/channel-delivery.d.ts +1 -0
  501. package/dist/src/instrumentation/channel-delivery.js +1 -1
  502. package/dist/src/instrumentation/lifecycle.d.ts +7 -0
  503. package/dist/src/instrumentation/memory.d.ts +2 -0
  504. package/dist/src/instrumentation/memory.js +1 -1
  505. package/dist/src/instrumentation/native-events.d.ts +1 -7
  506. package/dist/src/instrumentation/native-events.js +1 -1
  507. package/dist/src/instrumentation/runtime.d.ts +5 -7
  508. package/dist/src/instrumentation/runtime.js +1 -1
  509. package/dist/src/instrumentation/session-init.js +1 -1
  510. package/dist/src/instrumentation/state.d.ts +0 -6
  511. package/dist/src/instrumentation/state.js +1 -1
  512. package/dist/src/internal/application/package.js +1 -1
  513. package/dist/src/internal/authored-definition/schema-backed.d.ts +10 -0
  514. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  515. package/dist/src/internal/authored-module-loader.d.ts +20 -6
  516. package/dist/src/internal/authored-module-loader.js +2 -2
  517. package/dist/src/internal/authored-module-map-loader.js +1 -1
  518. package/dist/src/internal/authored-package-boundary.d.ts +3 -0
  519. package/dist/src/internal/authored-package-boundary.js +1 -1
  520. package/dist/src/internal/bundler/extension-mount-plugin.d.ts +14 -0
  521. package/dist/src/internal/bundler/extension-mount-plugin.js +1 -0
  522. package/dist/src/internal/bundler/extension-scope-plugin.d.ts +8 -11
  523. package/dist/src/internal/bundler/extension-scope-plugin.js +2 -3
  524. package/dist/src/internal/invocation/workflow-execution.d.ts +2 -2
  525. package/dist/src/internal/invocation/workflow-execution.js +1 -1
  526. package/dist/src/internal/mount-state.d.ts +1 -0
  527. package/dist/src/internal/mount-state.js +1 -0
  528. package/dist/src/internal/nitro/host/build-application.js +1 -1
  529. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  530. package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
  531. package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -1
  532. package/dist/src/internal/nitro/host/workspace-extensions.js +1 -1
  533. package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
  534. package/dist/src/internal/node-esm-compat-banner.js +1 -1
  535. package/dist/src/internal/workflow/development-world-client.js +1 -1
  536. package/dist/src/internal/workflow-bundle/authored-workflow-directives.d.ts +4 -3
  537. package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
  538. package/dist/src/internal/workflow-bundle/builder.js +1 -1
  539. package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.js +1 -1
  540. package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.js +1 -1
  541. package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.d.ts +27 -1
  542. package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.js +1 -1
  543. package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +2 -2
  544. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  545. package/dist/src/models/auto.d.ts +6 -0
  546. package/dist/src/models/auto.js +2 -2
  547. package/dist/src/protocol/message-version.d.ts +1 -0
  548. package/dist/src/protocol/message-version.js +1 -1
  549. package/dist/src/protocol/message.d.ts +166 -69
  550. package/dist/src/protocol/message.js +2 -2
  551. package/dist/src/protocol/remote-agent-protocol.d.ts +16 -0
  552. package/dist/src/protocol/remote-agent-protocol.js +1 -0
  553. package/dist/src/protocol/routes.d.ts +0 -6
  554. package/dist/src/protocol/routes.js +1 -1
  555. package/dist/src/protocol/task-tools.d.ts +21 -0
  556. package/dist/src/protocol/task-tools.js +1 -0
  557. package/dist/src/public/channels/auth.js +1 -1
  558. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +25 -16
  559. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
  560. package/dist/src/public/channels/chat-sdk/index.d.ts +1 -1
  561. package/dist/src/public/channels/chat-sdk/input-actions.d.ts +8 -0
  562. package/dist/src/public/channels/chat-sdk/input-actions.js +1 -0
  563. package/dist/src/public/channels/index.d.ts +1 -1
  564. package/dist/src/public/channels/linq/linqChannel.js +1 -1
  565. package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
  566. package/dist/src/public/channels/slack/action-status.d.ts +11 -12
  567. package/dist/src/public/channels/slack/action-status.js +1 -1
  568. package/dist/src/public/channels/slack/api.js +1 -1
  569. package/dist/src/public/channels/slack/approval-cards.d.ts +15 -0
  570. package/dist/src/public/channels/slack/approval-cards.js +2 -0
  571. package/dist/src/public/channels/slack/attachments.js +1 -1
  572. package/dist/src/public/channels/slack/auth.d.ts +5 -0
  573. package/dist/src/public/channels/slack/auth.js +1 -1
  574. package/dist/src/public/channels/slack/connections.d.ts +20 -16
  575. package/dist/src/public/channels/slack/connections.js +1 -1
  576. package/dist/src/public/channels/slack/defaults.d.ts +13 -33
  577. package/dist/src/public/channels/slack/defaults.js +3 -4
  578. package/dist/src/public/channels/slack/hitl.d.ts +22 -13
  579. package/dist/src/public/channels/slack/hitl.js +2 -2
  580. package/dist/src/public/channels/slack/inbound.d.ts +10 -2
  581. package/dist/src/public/channels/slack/inbound.js +1 -1
  582. package/dist/src/public/channels/slack/index.d.ts +6 -3
  583. package/dist/src/public/channels/slack/index.js +1 -1
  584. package/dist/src/public/channels/slack/input-response.d.ts +1 -5
  585. package/dist/src/public/channels/slack/input-response.js +1 -1
  586. package/dist/src/public/channels/slack/interaction-cards.js +1 -1
  587. package/dist/src/public/channels/slack/interactions.js +1 -1
  588. package/dist/src/public/channels/slack/limits.d.ts +5 -3
  589. package/dist/src/public/channels/slack/private-approval-delivery.js +1 -1
  590. package/dist/src/public/channels/slack/renderers.d.ts +76 -0
  591. package/dist/src/public/channels/slack/renderers.js +1 -0
  592. package/dist/src/public/channels/slack/reply-delivery.d.ts +72 -0
  593. package/dist/src/public/channels/slack/reply-delivery.js +1 -0
  594. package/dist/src/public/channels/slack/session-operations.d.ts +6 -0
  595. package/dist/src/public/channels/slack/session-operations.js +1 -1
  596. package/dist/src/public/channels/slack/sign-in-cancel.d.ts +20 -0
  597. package/dist/src/public/channels/slack/sign-in-cancel.js +1 -0
  598. package/dist/src/public/channels/slack/slackChannel.d.ts +62 -103
  599. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  600. package/dist/src/public/channels/slack/task-card.d.ts +24 -0
  601. package/dist/src/public/channels/slack/task-card.js +1 -0
  602. package/dist/src/public/channels/teams/defaults.d.ts +1 -1
  603. package/dist/src/public/channels/teams/defaults.js +2 -2
  604. package/dist/src/public/channels/telegram/hitl.d.ts +7 -1
  605. package/dist/src/public/channels/telegram/hitl.js +2 -1
  606. package/dist/src/public/channels/telegram/state.js +1 -1
  607. package/dist/src/public/channels/telegram/telegramChannel.d.ts +5 -0
  608. package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
  609. package/dist/src/public/definitions/channel.d.ts +7 -1
  610. package/dist/src/public/definitions/channel.js +1 -1
  611. package/dist/src/public/definitions/connections/mcp.d.ts +4 -6
  612. package/dist/src/public/definitions/connections/openapi.d.ts +7 -8
  613. package/dist/src/public/definitions/extension.d.ts +2 -2
  614. package/dist/src/public/definitions/extension.js +1 -1
  615. package/dist/src/public/definitions/hook.d.ts +4 -4
  616. package/dist/src/public/definitions/state.d.ts +4 -2
  617. package/dist/src/public/definitions/state.js +1 -1
  618. package/dist/src/public/memory/index.d.ts +0 -1
  619. package/dist/src/public/models/openai/index.d.ts +1 -1
  620. package/dist/src/public/models/openai/index.js +1 -1
  621. package/dist/src/public/next/index.js +1 -1
  622. package/dist/src/public/next/server.d.ts +2 -0
  623. package/dist/src/public/next/server.js +1 -2
  624. package/dist/src/public/nuxt/module.d.ts +6 -0
  625. package/dist/src/public/nuxt/module.js +1 -1
  626. package/dist/src/public/schedules/index.d.ts +1 -0
  627. package/dist/src/public/schedules/index.js +1 -1
  628. package/dist/src/public/server/index.d.ts +28 -0
  629. package/dist/src/public/server/index.js +1 -0
  630. package/dist/src/public/tools/index.d.ts +3 -2
  631. package/dist/src/public/tools/index.js +1 -1
  632. package/dist/src/public/tools/no-reply.d.ts +1 -0
  633. package/dist/src/public/tools/no-reply.js +1 -0
  634. package/dist/src/react/index.d.ts +3 -0
  635. package/dist/src/react/index.js +1 -1
  636. package/dist/src/react/use-eve-agent.d.ts +7 -5
  637. package/dist/src/react/use-eve-agent.js +1 -1
  638. package/dist/src/runtime/agent/bootstrap-model-utils.d.ts +6 -7
  639. package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -1
  640. package/dist/src/runtime/agent/bootstrap.d.ts +0 -1
  641. package/dist/src/runtime/agent/bootstrap.js +1 -1
  642. package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
  643. package/dist/src/runtime/agent/mock-model-fixtures.d.ts +1 -1
  644. package/dist/src/runtime/agent/mock-model-fixtures.js +2 -2
  645. package/dist/src/runtime/channels/registry.js +1 -1
  646. package/dist/src/runtime/connections/mcp-client.d.ts +1 -9
  647. package/dist/src/runtime/connections/mcp-client.js +1 -1
  648. package/dist/src/runtime/connections/openapi-client.js +1 -1
  649. package/dist/src/runtime/connections/scoped-authorization.d.ts +3 -1
  650. package/dist/src/runtime/connections/scoped-authorization.js +1 -1
  651. package/dist/src/runtime/connections/tool-result.d.ts +27 -0
  652. package/dist/src/runtime/connections/tool-result.js +2 -0
  653. package/dist/src/runtime/connections/tool-signature.d.ts +14 -0
  654. package/dist/src/runtime/connections/tool-signature.js +1 -0
  655. package/dist/src/runtime/local-dev-capability.js +1 -1
  656. package/dist/src/runtime/prompt/compose.d.ts +1 -3
  657. package/dist/src/runtime/prompt/compose.js +3 -3
  658. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  659. package/dist/src/runtime/resolve-tool.js +1 -1
  660. package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
  661. package/dist/src/runtime/sessions/runtime-context-keys.js +1 -1
  662. package/dist/src/runtime/sessions/turn.d.ts +1 -16
  663. package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -1
  664. package/dist/src/runtime/subagents/registry.js +1 -1
  665. package/dist/src/runtime/subagents/workflow-reference.d.ts +6 -3
  666. package/dist/src/runtime/subagents/workflow-reference.js +1 -1
  667. package/dist/src/runtime/subagents/workflow.d.ts +12 -6
  668. package/dist/src/runtime/subagents/workflow.js +1 -1
  669. package/dist/src/runtime/tools/registry.js +1 -1
  670. package/dist/src/self-modification/extension/classify-registry-item.d.ts +3 -0
  671. package/dist/src/self-modification/extension/classify-registry-item.js +1 -1
  672. package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +1 -1
  673. package/dist/src/self-modification/extension/subagents/agent/agent.js +1 -1
  674. package/dist/src/self-modification/extension/subagents/agent/instructions.js +7 -7
  675. package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.js +1 -1
  676. package/dist/src/self-modification/extension/subagents/agent/tools/search_registry.d.ts +2 -0
  677. package/dist/src/self-modification/extension/subagents/agent/tools/search_registry.js +1 -1
  678. package/dist/src/self-modification/scaffold.d.ts +2 -0
  679. package/dist/src/self-modification/scaffold.js +7 -0
  680. package/dist/src/self-modification/setup.js +1 -7
  681. package/dist/src/setup/boxes/deploy-project.js +1 -1
  682. package/dist/src/setup/boxes/select-model.js +1 -1
  683. package/dist/src/setup/integrations/shopify/templates.d.ts +1 -1
  684. package/dist/src/setup/integrations/shopify/templates.js +31 -19
  685. package/dist/src/setup/integrations/web/setup.js +6 -2
  686. package/dist/src/setup/scaffold/create/agent-paths.d.ts +5 -0
  687. package/dist/src/setup/scaffold/create/agent-paths.js +1 -0
  688. package/dist/src/setup/scaffold/create/instructions-template.d.ts +1 -0
  689. package/dist/src/setup/scaffold/create/instructions-template.js +8 -0
  690. package/dist/src/setup/scaffold/create/project.js +3 -10
  691. package/dist/src/setup/scaffold/create/web-template.d.ts +2 -2
  692. package/dist/src/setup/scaffold/create/web-template.js +28 -9
  693. package/dist/src/setup/vercel-project-framework.js +1 -1
  694. package/dist/src/shared/action-request-name.d.ts +3 -0
  695. package/dist/src/shared/action-request-name.js +1 -0
  696. package/dist/src/shared/action-types.d.ts +49 -21
  697. package/dist/src/shared/action-types.js +1 -1
  698. package/dist/src/shared/agent-definition.d.ts +0 -7
  699. package/dist/src/shared/chatgpt-model.d.ts +1 -1
  700. package/dist/src/shared/chatgpt-model.js +1 -1
  701. package/dist/src/shared/connection-types.d.ts +2 -8
  702. package/dist/src/shared/default-agent-model.d.ts +10 -1
  703. package/dist/src/shared/default-agent-model.js +1 -1
  704. package/dist/src/shared/display-name.d.ts +15 -0
  705. package/dist/src/shared/display-name.js +1 -0
  706. package/dist/src/shared/extension-mount.d.ts +2 -0
  707. package/dist/src/shared/extension-mount.js +1 -0
  708. package/dist/src/shared/format-duration.d.ts +2 -0
  709. package/dist/src/shared/format-duration.js +1 -0
  710. package/dist/src/shared/framework-eve-server.d.ts +43 -0
  711. package/dist/src/shared/framework-eve-server.js +2 -0
  712. package/dist/src/shared/input.d.ts +1 -0
  713. package/dist/src/shared/memory-state.d.ts +1 -0
  714. package/dist/src/shared/memory-state.js +1 -1
  715. package/dist/src/shared/model-helper.d.ts +2 -2
  716. package/dist/src/shared/model-helper.js +1 -1
  717. package/dist/src/shared/model-summary.d.ts +2 -6
  718. package/dist/src/shared/model-summary.js +1 -1
  719. package/dist/src/shared/presentation-text.d.ts +5 -0
  720. package/dist/src/shared/presentation-text.js +1 -1
  721. package/dist/src/shared/serialized-observability-state.d.ts +0 -4
  722. package/dist/src/shared/serialized-observability-state.js +1 -1
  723. package/dist/src/shared/token-usage.d.ts +2 -0
  724. package/dist/src/shared/token-usage.js +1 -1
  725. package/dist/src/shared/trace-root.d.ts +8 -0
  726. package/dist/src/shared/trace-root.js +1 -0
  727. package/dist/src/shared/value-delta.d.ts +39 -0
  728. package/dist/src/shared/value-delta.js +1 -0
  729. package/dist/src/subagents/adapter-state.d.ts +0 -2
  730. package/dist/src/subagents/adapter-state.js +1 -1
  731. package/dist/src/subagents/adapter.js +1 -1
  732. package/dist/src/subagents/callback-route.js +1 -1
  733. package/dist/src/subagents/event-proxy-step.d.ts +16 -29
  734. package/dist/src/subagents/event-proxy-step.js +1 -1
  735. package/dist/src/subagents/hitl-proxy.d.ts +38 -20
  736. package/dist/src/subagents/hitl-proxy.js +1 -1
  737. package/dist/src/subagents/invocation.d.ts +4 -3
  738. package/dist/src/subagents/parent-notification.d.ts +2 -1
  739. package/dist/src/subagents/parent-notification.js +1 -1
  740. package/dist/src/subagents/token-budget.d.ts +8 -9
  741. package/dist/src/subagents/token-budget.js +1 -1
  742. package/dist/src/subagents/tool.d.ts +6 -12
  743. package/dist/src/subagents/tool.js +1 -1
  744. package/dist/src/svelte/index.d.ts +3 -0
  745. package/dist/src/svelte/index.js +2 -2
  746. package/dist/src/svelte/use-eve-agent.d.ts +7 -4
  747. package/dist/src/svelte/use-eve-agent.js +1 -1
  748. package/dist/src/tools/behavior.d.ts +5 -5
  749. package/dist/src/tools/definition.d.ts +50 -14
  750. package/dist/src/tools/definition.js +1 -1
  751. package/dist/src/tools/durable-callbacks.d.ts +1 -1
  752. package/dist/src/tools/dynamic.d.ts +6 -0
  753. package/dist/src/tools/framework/agent-contract.d.ts +2 -5
  754. package/dist/src/tools/framework/agent-contract.js +1 -1
  755. package/dist/src/tools/framework/agent.d.ts +2 -5
  756. package/dist/src/tools/framework/agent.js +1 -1
  757. package/dist/src/tools/framework/connection-tools.d.ts +3 -0
  758. package/dist/src/tools/framework/connection-tools.js +1 -0
  759. package/dist/src/tools/provided/agent-router.d.ts +6 -3
  760. package/dist/src/tools/provided/agent-router.js +1 -1
  761. package/dist/src/{execution/tools → tools/provided}/ask-question-workflow.d.ts +3 -4
  762. package/dist/src/tools/provided/ask-question-workflow.js +1 -0
  763. package/dist/src/tools/provided/ask-question.d.ts +20 -5
  764. package/dist/src/tools/provided/ask-question.js +2 -1
  765. package/dist/src/tools/provided/interrupted.d.ts +18 -0
  766. package/dist/src/tools/provided/interrupted.js +1 -0
  767. package/dist/src/tools/provided/load-skill.js +1 -1
  768. package/dist/src/tools/provided/no-reply.d.ts +19 -0
  769. package/dist/src/tools/provided/no-reply.js +1 -0
  770. package/dist/src/tools/provided/sleep-workflow.d.ts +4 -0
  771. package/dist/src/tools/provided/sleep-workflow.js +1 -0
  772. package/dist/src/tools/provided/sleep.d.ts +11 -5
  773. package/dist/src/tools/provided/sleep.js +1 -1
  774. package/dist/src/tools/provided/task-cancel.d.ts +6 -0
  775. package/dist/src/tools/provided/task-cancel.js +1 -0
  776. package/dist/src/tools/provided/task-wait.d.ts +9 -0
  777. package/dist/src/tools/provided/task-wait.js +1 -0
  778. package/dist/src/tools/provided/workflow.d.ts +2 -2
  779. package/dist/src/tools/provided/workflow.js +1 -1
  780. package/dist/src/tools/schema-emission.d.ts +23 -0
  781. package/dist/src/tools/schema-emission.js +1 -0
  782. package/dist/src/tools/schema.d.ts +22 -8
  783. package/dist/src/tools/schema.js +1 -1
  784. package/dist/src/tools/workflow-definition.d.ts +187 -85
  785. package/dist/src/tools/workflow-definition.js +1 -1
  786. package/dist/src/tools/workflow-entry-point.d.ts +3 -0
  787. package/dist/src/tools/workflow-entry-point.js +1 -0
  788. package/dist/src/tracing/agent-action-instrumentation.d.ts +1 -3
  789. package/dist/src/tracing/agent-action-instrumentation.js +1 -1
  790. package/dist/src/tracing/agent-approval-instrumentation.js +1 -1
  791. package/dist/src/tracing/agent-invocation-coordinator.d.ts +9 -18
  792. package/dist/src/tracing/agent-invocation-coordinator.js +1 -1
  793. package/dist/src/tracing/agent-memory-instrumentation.js +1 -1
  794. package/dist/src/tracing/agent-otel-attributes.d.ts +6 -0
  795. package/dist/src/tracing/agent-otel-attributes.js +1 -1
  796. package/dist/src/tracing/agent-otel-content.d.ts +0 -2
  797. package/dist/src/tracing/agent-otel-content.js +3 -3
  798. package/dist/src/tracing/agent-otel-provider.js +2 -2
  799. package/dist/src/tracing/agent-otel-runtime-context.d.ts +20 -0
  800. package/dist/src/tracing/agent-otel-runtime-context.js +1 -1
  801. package/dist/src/tracing/agent-otel-session-context.js +1 -1
  802. package/dist/src/tracing/agent-otel-usage.js +1 -1
  803. package/dist/src/tracing/agent-span-contract.d.ts +1 -1
  804. package/dist/src/tracing/agent-span-contract.js +1 -1
  805. package/dist/src/tracing/agent-span-id-generator.d.ts +0 -1
  806. package/dist/src/tracing/agent-span-id-generator.js +1 -1
  807. package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
  808. package/dist/src/tracing/agent-trace-context-codec.d.ts +5 -2
  809. package/dist/src/tracing/agent-trace-context-codec.js +1 -1
  810. package/dist/src/tracing/agent-trace-context-store.d.ts +2 -27
  811. package/dist/src/tracing/agent-trace-context-store.js +1 -1
  812. package/dist/src/tracing/agent-trace-span-processor.js +1 -1
  813. package/dist/src/tracing/agent-trace-state.d.ts +4 -19
  814. package/dist/src/tracing/content-attributes.js +1 -1
  815. package/dist/src/tracing/conversation-context.d.ts +10 -0
  816. package/dist/src/tracing/conversation-context.js +1 -1
  817. package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
  818. package/dist/src/tracing/otel-registration.js +1 -1
  819. package/dist/src/vue/index.d.ts +3 -0
  820. package/dist/src/vue/index.js +2 -2
  821. package/dist/src/vue/use-eve-agent.d.ts +7 -3
  822. package/dist/src/vue/use-eve-agent.js +1 -1
  823. package/docs/agent-config.md +36 -13
  824. package/docs/channels/chat-sdk.mdx +15 -4
  825. package/docs/channels/custom.mdx +89 -17
  826. package/docs/channels/eve.mdx +1 -1
  827. package/docs/channels/mcp.mdx +1 -1
  828. package/docs/channels/overview.mdx +14 -56
  829. package/docs/channels/slack.mdx +287 -45
  830. package/docs/channels/telegram.mdx +2 -0
  831. package/docs/concepts/built-in-tools.md +37 -28
  832. package/docs/concepts/context-control.md +2 -2
  833. package/docs/concepts/execution-model-and-durability.mdx +10 -11
  834. package/docs/concepts/sessions-runs-and-streaming.md +69 -49
  835. package/docs/connections/mcp.mdx +4 -4
  836. package/docs/connections/openapi.mdx +2 -2
  837. package/docs/connections/overview.mdx +11 -5
  838. package/docs/evals/assertions.mdx +5 -5
  839. package/docs/evals/cases.mdx +1 -1
  840. package/docs/evals/reporters.mdx +10 -4
  841. package/docs/extensions.md +22 -2
  842. package/docs/guides/client/streaming.mdx +33 -12
  843. package/docs/guides/deployment/vercel.mdx +2 -1
  844. package/docs/guides/dev-tui.md +26 -16
  845. package/docs/guides/dynamic-capabilities.md +6 -4
  846. package/docs/guides/evaluate.md +29 -2
  847. package/docs/guides/frontend/nuxt.mdx +24 -4
  848. package/docs/guides/frontend/overview.mdx +45 -41
  849. package/docs/guides/frontend/use-eve-agent-svelte.mdx +4 -10
  850. package/docs/guides/frontend/use-eve-agent-vue.mdx +4 -10
  851. package/docs/guides/hooks.md +16 -12
  852. package/docs/guides/instrumentation/instrumentation.mdx +2 -0
  853. package/docs/guides/instrumentation/otel.mdx +24 -6
  854. package/docs/guides/remote-agents.md +38 -22
  855. package/docs/guides/self-modification.md +10 -0
  856. package/docs/instructions.mdx +1 -1
  857. package/docs/patterns/multi-tenant-approvals.md +1 -1
  858. package/docs/protocols/ucp.mdx +20 -16
  859. package/docs/reference/cli.md +64 -11
  860. package/docs/reference/typescript-api.md +43 -41
  861. package/docs/schedules.mdx +14 -34
  862. package/docs/subagents/index.mdx +24 -56
  863. package/docs/tools/human-in-the-loop.md +50 -15
  864. package/docs/tools/meta.json +1 -1
  865. package/docs/tools/overview.mdx +80 -60
  866. package/docs/tools/tasks-upgrade.md +201 -0
  867. package/docs/tools/tasks.md +315 -0
  868. package/docs/tools/workflows.mdx +368 -154
  869. package/package.json +18 -12
  870. package/dist/src/channel/activity-renderer.d.ts +0 -21
  871. package/dist/src/channel/activity-renderer.js +0 -1
  872. package/dist/src/channel/activity-sink.d.ts +0 -2
  873. package/dist/src/channel/activity-sink.js +0 -1
  874. package/dist/src/cli/dev/tui/steering-stream.d.ts +0 -15
  875. package/dist/src/cli/dev/tui/steering-stream.js +0 -1
  876. package/dist/src/cli/dev/tui/subagent-pump.d.ts +0 -142
  877. package/dist/src/cli/dev/tui/subagent-pump.js +0 -1
  878. package/dist/src/eve-channel/activity-observer-request.d.ts +0 -7
  879. package/dist/src/eve-channel/activity-observer-request.js +0 -1
  880. package/dist/src/eve-channel/delivery-policy-request.d.ts +0 -4
  881. package/dist/src/eve-channel/delivery-policy-request.js +0 -1
  882. package/dist/src/execution/activity-cohort.d.ts +0 -20
  883. package/dist/src/execution/activity-cohort.js +0 -1
  884. package/dist/src/execution/activity-collector.d.ts +0 -12
  885. package/dist/src/execution/activity-collector.js +0 -1
  886. package/dist/src/execution/activity-events.d.ts +0 -8
  887. package/dist/src/execution/activity-events.js +0 -1
  888. package/dist/src/execution/activity-route.d.ts +0 -2
  889. package/dist/src/execution/activity-route.js +0 -1
  890. package/dist/src/execution/activity-work-id.d.ts +0 -9
  891. package/dist/src/execution/activity-work-id.js +0 -1
  892. package/dist/src/execution/activity-work.d.ts +0 -30
  893. package/dist/src/execution/activity-work.js +0 -1
  894. package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +0 -7
  895. package/dist/src/execution/cancel-indexed-session-tasks-step.js +0 -1
  896. package/dist/src/execution/dispatch-action-failures.d.ts +0 -8
  897. package/dist/src/execution/dispatch-action-failures.js +0 -1
  898. package/dist/src/execution/dispatch-start-operation.d.ts +0 -15
  899. package/dist/src/execution/dispatch-start-operation.js +0 -1
  900. package/dist/src/execution/publish-channel-event.d.ts +0 -23
  901. package/dist/src/execution/publish-channel-event.js +0 -1
  902. package/dist/src/execution/scheduled-launch-delivery.d.ts +0 -7
  903. package/dist/src/execution/scheduled-launch-delivery.js +0 -1
  904. package/dist/src/execution/session/event-sink.d.ts +0 -26
  905. package/dist/src/execution/session/event-sink.js +0 -1
  906. package/dist/src/execution/session-activity-projection.d.ts +0 -16
  907. package/dist/src/execution/session-activity-projection.js +0 -1
  908. package/dist/src/execution/session-activity-renderer-step.d.ts +0 -15
  909. package/dist/src/execution/session-activity-renderer-step.js +0 -1
  910. package/dist/src/execution/session-activity.d.ts +0 -3
  911. package/dist/src/execution/session-activity.js +0 -1
  912. package/dist/src/execution/submit-activity.d.ts +0 -7
  913. package/dist/src/execution/submit-activity.js +0 -1
  914. package/dist/src/execution/task-event-callback.d.ts +0 -12
  915. package/dist/src/execution/task-event-callback.js +0 -1
  916. package/dist/src/execution/task-input-capability.d.ts +0 -4
  917. package/dist/src/execution/task-input-capability.js +0 -1
  918. package/dist/src/execution/task-input-response-route.d.ts +0 -2
  919. package/dist/src/execution/task-input-response-route.js +0 -1
  920. package/dist/src/execution/tasks/child/notify.d.ts +0 -44
  921. package/dist/src/execution/tasks/child/notify.js +0 -1
  922. package/dist/src/execution/tasks/parent/control-shared.d.ts +0 -23
  923. package/dist/src/execution/tasks/parent/control-shared.js +0 -1
  924. package/dist/src/execution/tasks/parent/delegate.d.ts +0 -35
  925. package/dist/src/execution/tasks/parent/delegate.js +0 -1
  926. package/dist/src/execution/tasks/parent/dispatch.d.ts +0 -22
  927. package/dist/src/execution/tasks/parent/dispatch.js +0 -1
  928. package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +0 -27
  929. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +0 -1
  930. package/dist/src/execution/tasks/parent/run-parent.d.ts +0 -58
  931. package/dist/src/execution/tasks/parent/run-parent.js +0 -1
  932. package/dist/src/execution/tasks/parent/subagent-task-projection.d.ts +0 -26
  933. package/dist/src/execution/tasks/parent/subagent-task-projection.js +0 -1
  934. package/dist/src/execution/tasks/parent/task-cancel.d.ts +0 -12
  935. package/dist/src/execution/tasks/parent/task-cancel.js +0 -1
  936. package/dist/src/execution/tasks/parent/tool-execution.d.ts +0 -45
  937. package/dist/src/execution/tasks/parent/tool-execution.js +0 -1
  938. package/dist/src/execution/terminal-session-event.d.ts +0 -13
  939. package/dist/src/execution/terminal-session-event.js +0 -1
  940. package/dist/src/execution/tools/ask-question-workflow.js +0 -1
  941. package/dist/src/execution/tools/ask-question.d.ts +0 -19
  942. package/dist/src/execution/tools/ask-question.js +0 -2
  943. package/dist/src/execution/tools/connection-search.d.ts +0 -2
  944. package/dist/src/execution/tools/connection-search.js +0 -2
  945. package/dist/src/execution/tools/sleep-workflow.d.ts +0 -3
  946. package/dist/src/execution/tools/sleep-workflow.js +0 -1
  947. package/dist/src/execution/tools/sleep.d.ts +0 -10
  948. package/dist/src/execution/tools/sleep.js +0 -1
  949. package/dist/src/execution/tools/subagent/accept-event-step.d.ts +0 -7
  950. package/dist/src/execution/tools/subagent/accept-event-step.js +0 -1
  951. package/dist/src/execution/tools/subagent/emit-event-step.d.ts +0 -12
  952. package/dist/src/execution/tools/subagent/emit-event-step.js +0 -1
  953. package/dist/src/execution/tools/subagent/invoke-agent.d.ts +0 -42
  954. package/dist/src/execution/tools/subagent/invoke-agent.js +0 -1
  955. package/dist/src/execution/tools/subagent/invoke-preparation.d.ts +0 -44
  956. package/dist/src/execution/tools/subagent/invoke-preparation.js +0 -1
  957. package/dist/src/execution/tools/subagent/invoke-step.d.ts +0 -64
  958. package/dist/src/execution/tools/subagent/invoke-step.js +0 -1
  959. package/dist/src/execution/tools/subagent/receipt-identity.d.ts +0 -11
  960. package/dist/src/execution/tools/subagent/receipt-identity.js +0 -1
  961. package/dist/src/execution/tools/subagent/start.d.ts +0 -51
  962. package/dist/src/execution/tools/subagent/start.js +0 -1
  963. package/dist/src/execution/tools/subagent/steer.d.ts +0 -13
  964. package/dist/src/execution/tools/subagent/steer.js +0 -1
  965. package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +0 -24
  966. package/dist/src/execution/tools/subagent/task-agent-requests.js +0 -1
  967. package/dist/src/execution/tools/subagent/task-cancel.d.ts +0 -10
  968. package/dist/src/execution/tools/subagent/task-cancel.js +0 -1
  969. package/dist/src/execution/tools/tasks.d.ts +0 -3
  970. package/dist/src/execution/tools/tasks.js +0 -1
  971. package/dist/src/execution/tools/workflow/background.js +0 -1
  972. package/dist/src/execution/tools/workflow/workflow-owner-background.d.ts +0 -14
  973. package/dist/src/execution/tools/workflow/workflow-owner-background.js +0 -1
  974. package/dist/src/harness/background-tools.d.ts +0 -45
  975. package/dist/src/harness/background-tools.js +0 -1
  976. package/dist/src/instrumentation/background-task-runtime.d.ts +0 -18
  977. package/dist/src/instrumentation/background-task-runtime.js +0 -1
  978. package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.3.0/node_modules/@vercel/cli-config/dist/index.js +0 -21
  979. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/envpath.js +0 -1
  980. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/errors.js +0 -2
  981. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/errutils.js +0 -1
  982. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/exec.js +0 -1
  983. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/fsutils.js +0 -1
  984. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/index.js +0 -1
  985. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/lookup.js +0 -1
  986. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/safety.js +0 -1
  987. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/authorization.js +0 -1
  988. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/connector.js +0 -1
  989. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/index.js +0 -1
  990. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/installation.js +0 -1
  991. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/internal/base-url.js +0 -1
  992. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/internal/default-scopes.js +0 -1
  993. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/internal/env.js +0 -1
  994. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/internal/url-validation.js +0 -1
  995. package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/token.js +0 -1
  996. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/auth-errors.js +0 -1
  997. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/exchange-vercel-oidc-token.js +0 -1
  998. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/get-context.js +0 -1
  999. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-sync.js +0 -1
  1000. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-with-refresh.js +0 -2
  1001. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/index.js +0 -1
  1002. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/oauth.js +0 -1
  1003. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token-error.js +0 -1
  1004. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token-io.js +0 -1
  1005. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token-util.js +0 -2
  1006. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token.js +0 -1
  1007. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/verify-vercel-oidc-token.js +0 -1
  1008. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/version.js +0 -1
  1009. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js +0 -1
  1010. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js +0 -1
  1011. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js +0 -1
  1012. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js +0 -1
  1013. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js +0 -1
  1014. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -1
  1015. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js +0 -1
  1016. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/command.js +0 -1
  1017. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js +0 -2
  1018. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/kill.js +0 -1
  1019. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/promise.js +0 -1
  1020. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stdio.js +0 -1
  1021. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stream.js +0 -1
  1022. package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/buffer-stream.js +0 -1
  1023. package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/index.js +0 -1
  1024. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/core.js +0 -1
  1025. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/main.js +0 -1
  1026. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/realtime.js +0 -1
  1027. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/signals.js +0 -1
  1028. package/dist/src/node_modules/.pnpm/is-stream@2.0.1/node_modules/is-stream/index.js +0 -1
  1029. package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js +0 -1
  1030. package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js +0 -1
  1031. package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js +0 -1
  1032. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/index.js +0 -1
  1033. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/decrypt.js +0 -1
  1034. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/encrypt.js +0 -1
  1035. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/decrypt.js +0 -1
  1036. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/encrypt.js +0 -1
  1037. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/decrypt.js +0 -1
  1038. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/encrypt.js +0 -1
  1039. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/embedded.js +0 -1
  1040. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/thumbprint.js +0 -1
  1041. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/local.js +0 -1
  1042. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/remote.js +0 -1
  1043. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/sign.js +0 -1
  1044. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/verify.js +0 -1
  1045. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/sign.js +0 -1
  1046. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/verify.js +0 -1
  1047. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/sign.js +0 -1
  1048. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/verify.js +0 -1
  1049. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/decrypt.js +0 -1
  1050. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/encrypt.js +0 -1
  1051. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/produce.js +0 -1
  1052. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/sign.js +0 -1
  1053. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/unsecured.js +0 -1
  1054. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/verify.js +0 -1
  1055. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/export.js +0 -1
  1056. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_key_pair.js +0 -1
  1057. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_secret.js +0 -1
  1058. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/import.js +0 -1
  1059. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/aesgcmkw.js +0 -1
  1060. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/buffer_utils.js +0 -1
  1061. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/cek.js +0 -1
  1062. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_iv_length.js +0 -1
  1063. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_key_type.js +0 -1
  1064. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_p2s.js +0 -1
  1065. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/crypto_key.js +0 -1
  1066. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/decrypt_key_management.js +0 -1
  1067. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/encrypt_key_management.js +0 -1
  1068. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/epoch.js +0 -1
  1069. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/invalid_key_input.js +0 -1
  1070. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_disjoint.js +0 -1
  1071. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_jwk.js +0 -1
  1072. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_object.js +0 -1
  1073. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/iv.js +0 -1
  1074. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/jwt_claims_set.js +0 -1
  1075. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/private_symbols.js +0 -1
  1076. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/secs.js +0 -1
  1077. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_algorithms.js +0 -1
  1078. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_crit.js +0 -1
  1079. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/aeskw.js +0 -1
  1080. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/asn1.js +0 -1
  1081. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/base64url.js +0 -1
  1082. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/cbc_tag.js +0 -1
  1083. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_cek_length.js +0 -1
  1084. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_key_length.js +0 -1
  1085. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ciphers.js +0 -1
  1086. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/decrypt.js +0 -1
  1087. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/digest.js +0 -1
  1088. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/dsa_digest.js +0 -1
  1089. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ecdhes.js +0 -1
  1090. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/encrypt.js +0 -1
  1091. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/fetch_jwks.js +0 -1
  1092. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/generate.js +0 -1
  1093. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_named_curve.js +0 -1
  1094. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_sign_verify_key.js +0 -1
  1095. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/hmac_digest.js +0 -1
  1096. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_like.js +0 -1
  1097. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_object.js +0 -1
  1098. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/jwk_to_key.js +0 -1
  1099. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/key_to_jwk.js +0 -1
  1100. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/node_key.js +0 -1
  1101. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/normalize_key.js +0 -1
  1102. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/pbes2kw.js +0 -1
  1103. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/random.js +0 -1
  1104. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/rsaes.js +0 -1
  1105. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/runtime.js +0 -1
  1106. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/sign.js +0 -1
  1107. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/timing_safe_equal.js +0 -1
  1108. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/verify.js +0 -1
  1109. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/webcrypto.js +0 -1
  1110. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/base64url.js +0 -1
  1111. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_jwt.js +0 -1
  1112. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_protected_header.js +0 -1
  1113. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/errors.js +0 -1
  1114. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/runtime.js +0 -1
  1115. package/dist/src/node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js +0 -1
  1116. package/dist/src/node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js +0 -1
  1117. package/dist/src/node_modules/.pnpm/npm-run-path@4.0.1/node_modules/npm-run-path/index.js +0 -1
  1118. package/dist/src/node_modules/.pnpm/onetime@5.1.2/node_modules/onetime/index.js +0 -1
  1119. package/dist/src/node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js +0 -1
  1120. package/dist/src/node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js +0 -1
  1121. package/dist/src/node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js +0 -1
  1122. package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js +0 -1
  1123. package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js +0 -1
  1124. package/dist/src/node_modules/.pnpm/strip-final-newline@2.0.0/node_modules/strip-final-newline/index.js +0 -2
  1125. package/dist/src/node_modules/.pnpm/which@2.0.2/node_modules/which/which.js +0 -1
  1126. package/dist/src/protocol/activity.d.ts +0 -112
  1127. package/dist/src/protocol/activity.js +0 -1
  1128. package/dist/src/protocol/agent-handle-error.d.ts +0 -13
  1129. package/dist/src/protocol/agent-handle-error.js +0 -1
  1130. package/dist/src/public/channels/slack/activity-plan.d.ts +0 -5
  1131. package/dist/src/public/channels/slack/activity-plan.js +0 -1
  1132. package/dist/src/public/channels/slack/activity.d.ts +0 -63
  1133. package/dist/src/public/channels/slack/activity.js +0 -2
  1134. package/dist/src/public/nuxt/dev-server.d.ts +0 -25
  1135. package/dist/src/public/nuxt/dev-server.js +0 -1
  1136. package/dist/src/public/tools/connection-search.d.ts +0 -1
  1137. package/dist/src/public/tools/connection-search.js +0 -1
  1138. package/dist/src/public/tools/task-cancel.d.ts +0 -1
  1139. package/dist/src/public/tools/task-cancel.js +0 -1
  1140. package/dist/src/runtime/prompt/connections.d.ts +0 -9
  1141. package/dist/src/runtime/prompt/connections.js +0 -2
  1142. package/dist/src/shared/empty-delivery.d.ts +0 -3
  1143. package/dist/src/shared/empty-delivery.js +0 -1
  1144. package/dist/src/subagents/agent-handle-errors.d.ts +0 -25
  1145. package/dist/src/subagents/agent-handle-errors.js +0 -1
  1146. package/dist/src/subagents/callback-step.d.ts +0 -11
  1147. package/dist/src/subagents/callback-step.js +0 -1
  1148. package/dist/src/subagents/continuation-bundle.d.ts +0 -13
  1149. package/dist/src/subagents/continuation-bundle.js +0 -1
  1150. package/dist/src/subagents/handle-dispatch.d.ts +0 -65
  1151. package/dist/src/subagents/handle-dispatch.js +0 -1
  1152. package/dist/src/subagents/handles/operation-id.d.ts +0 -15
  1153. package/dist/src/subagents/handles/operation-id.js +0 -1
  1154. package/dist/src/subagents/handles/prompt.d.ts +0 -52
  1155. package/dist/src/subagents/handles/prompt.js +0 -3
  1156. package/dist/src/subagents/handles/query.d.ts +0 -41
  1157. package/dist/src/subagents/handles/query.js +0 -1
  1158. package/dist/src/subagents/handles/state-key.d.ts +0 -8
  1159. package/dist/src/subagents/handles/state-key.js +0 -1
  1160. package/dist/src/subagents/handles/store.d.ts +0 -217
  1161. package/dist/src/subagents/handles/store.js +0 -1
  1162. package/dist/src/subagents/handles/transitions.d.ts +0 -103
  1163. package/dist/src/subagents/handles/transitions.js +0 -1
  1164. package/dist/src/subagents/remote-dispatch.js +0 -1
  1165. package/dist/src/subagents/start-local.d.ts +0 -29
  1166. package/dist/src/subagents/start-local.js +0 -1
  1167. package/dist/src/subagents/start-remote.d.ts +0 -21
  1168. package/dist/src/subagents/start-remote.js +0 -1
  1169. package/dist/src/tasks/delivery-context.d.ts +0 -32
  1170. package/dist/src/tasks/delivery-context.js +0 -4
  1171. package/dist/src/tasks/delivery-policy.d.ts +0 -14
  1172. package/dist/src/tasks/delivery-policy.js +0 -1
  1173. package/dist/src/tasks/json.d.ts +0 -88
  1174. package/dist/src/tasks/json.js +0 -1
  1175. package/dist/src/tasks/notification.d.ts +0 -10
  1176. package/dist/src/tasks/notification.js +0 -1
  1177. package/dist/src/tasks/task-id.d.ts +0 -31
  1178. package/dist/src/tasks/task-id.js +0 -1
  1179. package/dist/src/tasks/task-inbox-token.d.ts +0 -2
  1180. package/dist/src/tasks/task-inbox-token.js +0 -1
  1181. package/dist/src/tasks/transitions.d.ts +0 -17
  1182. package/dist/src/tasks/transitions.js +0 -1
  1183. package/dist/src/tasks/types.d.ts +0 -138
  1184. package/dist/src/tasks/types.js +0 -1
  1185. package/dist/src/tools/framework/connection-search.d.ts +0 -3
  1186. package/dist/src/tools/framework/connection-search.js +0 -1
  1187. package/dist/src/tools/framework/task-cancel.d.ts +0 -4
  1188. package/dist/src/tools/framework/task-cancel.js +0 -1
  1189. package/dist/src/tools/framework/task-contract.d.ts +0 -19
  1190. package/dist/src/tools/framework/task-contract.js +0 -1
  1191. package/dist/src/tools/native-definition.d.ts +0 -7
  1192. package/dist/src/tools/native-definition.js +0 -1
  1193. package/dist/src/tracing/agent-invocation-terminal.d.ts +0 -18
  1194. package/dist/src/tracing/agent-invocation-terminal.js +0 -1
  1195. /package/dist/src/execution/{tools/subagent → agent-sessions}/metadata.d.ts +0 -0
  1196. /package/dist/src/execution/{tools/subagent → agent-sessions}/metadata.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import { computed, onScopeDispose, shallowRef } from "vue";
2
2
  import { z } from "#compiled/zod/index.js";
3
- import { asSchema } from "ai";
3
+ import "ai";
4
4
  import { Validator } from "#compiled/@cfworker/json-schema/index.js";
5
5
 
6
6
  //#region src/protocol/routes.ts
@@ -23,8 +23,6 @@ const EVE_DEV_RUNTIME_ARTIFACTS_SUSPEND_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACT
23
23
  const EVE_DEV_RUNTIME_ARTIFACTS_RESUME_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}/resume`;
24
24
  const EVE_CONNECTION_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/connections/:name/callback/:attemptId/:token`;
25
25
  const EVE_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/callback/:token`;
26
- const EVE_TASK_INPUT_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/task-input/:token`;
27
- const EVE_ACTIVITY_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/activity/:token`;
28
26
  function createEveSessionRoutePath(sessionId) {
29
27
  return `${EVE_SESSION_ROUTE_PATH}/${encodeURIComponent(sessionId)}`;
30
28
  }
@@ -84,6 +82,10 @@ function encodeBasicCredentials(username, password) {
84
82
  return btoa(binaryString);
85
83
  }
86
84
 
85
+ //#endregion
86
+ //#region src/shared/extension-mount.ts
87
+ const mountIdSchema = z.string().min(1);
88
+
87
89
  //#endregion
88
90
  //#region src/client/agent-info-schema.ts
89
91
  const owner = z.discriminatedUnion("kind", [
@@ -94,6 +96,7 @@ const owner = z.discriminatedUnion("kind", [
94
96
  }).strict(),
95
97
  z.object({
96
98
  kind: z.literal("extension"),
99
+ mountId: mountIdSchema.optional(),
97
100
  namespace: z.string(),
98
101
  packageName: z.string()
99
102
  }).strict()
@@ -105,10 +108,12 @@ const moduleBacking = z.discriminatedUnion("kind", [z.object({
105
108
  sourceRoot: z.string()
106
109
  }).strict().optional(),
107
110
  kind: z.literal("filesystem"),
111
+ mountId: z.string().optional(),
108
112
  sourcePath: z.string()
109
113
  }).strict(), z.object({
110
114
  dependencies: z.record(z.string(), z.string()).optional(),
111
115
  kind: z.literal("programmatic"),
116
+ mountId: z.string().optional(),
112
117
  moduleId: z.string(),
113
118
  parameters: z.record(z.string(), z.unknown()).optional(),
114
119
  registryId: z.string(),
@@ -315,13 +320,9 @@ const remoteAgent = entry.extend({
315
320
  url: z.string().optional()
316
321
  }).strict();
317
322
  const kernelEffect = z.object({
318
- action: z.enum([
319
- "subagent-call",
320
- "task-cancel",
321
- "workflow-tool-call"
322
- ]).optional(),
323
- audience: z.array(z.enum(["root-session", "delegated-task-child"])),
324
- kind: z.enum(["dispatch", "provider-tool"]),
323
+ action: z.union([z.enum(["subagent-call", "workflow-tool-call"]), z.literal("unrecognized")]).catch("unrecognized").optional(),
324
+ audience: z.array(z.union([z.literal("root-session"), z.literal("unrecognized")]).catch("unrecognized")),
325
+ kind: z.union([z.enum(["dispatch", "provider-tool"]), z.literal("unrecognized")]).catch("unrecognized"),
325
326
  sourceId: z.string()
326
327
  }).strict();
327
328
  const compositionDiagnostic = z.object({
@@ -683,117 +684,74 @@ function isTurnFailureEvent(event) {
683
684
  //#endregion
684
685
  //#region src/client/session-utils.ts
685
686
  function summarizeTurnEvents(events) {
687
+ const segment = new TurnSegment();
686
688
  let boundary;
687
689
  let failure;
688
690
  let message;
689
- const inputRequests = [];
690
- const pendingAuthorizations = /* @__PURE__ */ new Map();
691
691
  for (const event of events) {
692
- if (isCurrentTurnBoundaryEvent(event)) boundary = event;
692
+ if (segment.observe(event)) boundary = event;
693
693
  if (isTurnFailureEvent(event)) failure = event;
694
694
  if (isFinalMessageCompleted(event)) message = event.data.message ?? void 0;
695
- if (event.type === "input.requested") inputRequests.push(...event.data.requests);
696
- if (event.type === "authorization.required") pendingAuthorizations.set(event.data.name, event.data);
697
- if (event.type === "authorization.completed") pendingAuthorizations.delete(event.data.name);
695
+ if (event.type === "turn.waiting") message = void 0;
698
696
  }
699
697
  return {
700
698
  boundary,
701
699
  failure,
702
- inputRequests,
700
+ inputRequests: segment.inputRequests,
703
701
  message,
704
- pendingAuthorizations: [...pendingAuthorizations.values()],
705
- status: boundary?.type === "session.waiting" ? "waiting" : boundary?.type === "session.failed" ? "failed" : "completed"
702
+ pendingAuthorizations: segment.pendingAuthorizations,
703
+ status: summarizeBoundaryStatus(boundary)
706
704
  };
707
705
  }
708
- function isFinalMessageCompleted(event) {
709
- return event.type === "message.completed" && event.data.finishReason !== "tool-calls";
710
- }
711
- function updatePendingAuthorizations(pending, event) {
712
- if (event.type === "authorization.required" && event.data.webhookUrl !== void 0) pending.add(event.data.name);
713
- else if (event.type === "authorization.completed") pending.delete(event.data.name);
714
- }
715
-
716
- //#endregion
717
- //#region src/client/output-schema.ts
718
- function extractCompletedResult(events) {
719
- let result;
720
- for (const event of events) if (isResultCompletedEvent(event)) result = event.data.result;
721
- return result;
706
+ function summarizeBoundaryStatus(boundary) {
707
+ if (boundary?.type === "session.waiting" || boundary?.type === "turn.waiting") return "waiting";
708
+ if (boundary?.type === "session.failed") return "failed";
709
+ return "completed";
722
710
  }
723
- function isResultCompletedEvent(event) {
724
- return event.type === "result.completed";
711
+ function endsTurnSegment(event, open) {
712
+ if (event.type === "turn.waiting") return open.requests || event.data.on === "input" && !open.callbacks;
713
+ return isCurrentTurnBoundaryEvent(event) && (event.type !== "session.waiting" || !open.callbacks);
725
714
  }
726
-
727
- //#endregion
728
- //#region src/client/message-response.ts
729
- const consumeResponse = Symbol("consumeMessageResponse");
730
- const acceptedDeliveryId = Symbol("acceptedDeliveryId");
731
- var MessageResponse = class {
732
- sessionId;
733
- [acceptedDeliveryId];
734
- #cancelTurn;
735
- #cancellation;
736
- #consumed = false;
737
- #createStream;
738
- #settled = false;
739
- #turnId = Promise.withResolvers();
740
- constructor(input) {
741
- this.#cancelTurn = input.cancelTurn;
742
- this.sessionId = input.sessionId;
743
- this[acceptedDeliveryId] = input.deliveryId;
744
- this.#createStream = input.createStream;
745
- }
746
- cancel() {
747
- if (this.#settled) return Promise.resolve({ status: "no_active_turn" });
748
- if (this.#cancellation !== void 0) return this.#cancellation;
749
- const cancellation = this.#turnId.promise.then((turnId) => turnId === void 0 ? { status: "no_active_turn" } : this.#cancelTurn(turnId));
750
- this.#cancellation = cancellation;
751
- cancellation.catch(() => {
752
- if (!this.#settled && this.#cancellation === cancellation) this.#cancellation = void 0;
753
- });
754
- return cancellation;
755
- }
756
- async result() {
757
- const events = [];
758
- for await (const event of this) events.push(event);
759
- const summary = summarizeTurnEvents(events);
760
- return {
761
- data: extractCompletedResult(events),
762
- events,
763
- inputRequests: summary.inputRequests,
764
- message: summary.message,
765
- sessionId: this.sessionId,
766
- status: summary.status
767
- };
715
+ var TurnSegment = class {
716
+ #authorizations = /* @__PURE__ */ new Map();
717
+ #followCallbacks;
718
+ #requests = /* @__PURE__ */ new Map();
719
+ constructor(options = {}) {
720
+ this.#followCallbacks = options.followCallbacks === true;
768
721
  }
769
- [Symbol.asyncIterator]() {
770
- return this[consumeResponse]();
722
+ get inputRequests() {
723
+ return [...this.#requests.values()];
771
724
  }
772
- [consumeResponse](source) {
773
- if (this.#consumed) throw new Error("MessageResponse has already been consumed.");
774
- this.#consumed = true;
775
- return this.#observeStream(source);
725
+ get pendingAuthorizations() {
726
+ return [...this.#authorizations.values()];
776
727
  }
777
- async *#observeStream(source) {
778
- try {
779
- for await (const event of this.#createStream(source)) {
780
- if (event.type === "turn.started") this.#turnId.resolve(event.data.turnId);
781
- else if (isCurrentTurnBoundaryEvent(event)) {
782
- this.#settled = true;
783
- this.#turnId.resolve(void 0);
784
- }
785
- yield event;
786
- }
787
- } finally {
788
- this.#turnId.resolve(void 0);
728
+ observe(event) {
729
+ switch (event.type) {
730
+ case "input.requested":
731
+ for (const request of event.data.requests) this.#requests.set(request.requestId, request);
732
+ break;
733
+ case "approval.settled":
734
+ this.#requests.delete(event.data.requestId);
735
+ break;
736
+ case "input.resolved":
737
+ for (const resolution of event.data.resolutions) this.#requests.delete(resolution.requestId);
738
+ break;
739
+ case "authorization.required":
740
+ this.#authorizations.set(authorizationKey(event.data), event.data);
741
+ break;
742
+ case "authorization.completed": this.#authorizations.delete(authorizationKey(event.data));
789
743
  }
744
+ return endsTurnSegment(event, {
745
+ callbacks: this.#followCallbacks && [...this.#authorizations.values()].some((authorization) => authorization.webhookUrl !== void 0),
746
+ requests: this.#requests.size > 0
747
+ });
790
748
  }
791
749
  };
792
- function getMessageResponseDeliveryId(response) {
793
- return response[acceptedDeliveryId];
750
+ function isFinalMessageCompleted(event) {
751
+ return event.type === "message.completed" && event.data.finishReason !== "tool-calls";
794
752
  }
795
- function consumeMessageResponse(response, source) {
796
- return response[consumeResponse](source);
753
+ function authorizationKey(data) {
754
+ return data.attemptId === void 0 ? `name:${data.name}` : `attempt:${data.attemptId}`;
797
755
  }
798
756
 
799
757
  //#endregion
@@ -804,7 +762,8 @@ function normalizeMessageStreamEvent(version, event) {
804
762
  case "22":
805
763
  case "23":
806
764
  case "24": return normalizeLegacyMessageStreamEvent(version, event);
807
- case "25": return validateCurrentMessageStreamEvent(event);
765
+ case "25":
766
+ case "26": return validateDeltaMessageStreamEvent(version, event);
808
767
  default: return assertNever(version);
809
768
  }
810
769
  }
@@ -853,26 +812,26 @@ function normalizeLegacyMessageStreamEvent(version, event) {
853
812
  }
854
813
  return event;
855
814
  }
856
- function validateCurrentMessageStreamEvent(event) {
815
+ function validateDeltaMessageStreamEvent(version, event) {
857
816
  if (event.type === "message.appended") {
858
- assertCurrentAppendDelta(event.data.messageDelta, "message");
859
- assertUnsupportedAppendField(event.data, "messageOffset", "message");
860
- assertUnsupportedAppendField(event.data, "messageSoFar", "message");
817
+ assertAppendDelta(event.data.messageDelta, "message", version);
818
+ assertUnsupportedAppendField(event.data, "messageOffset", "message", version);
819
+ assertUnsupportedAppendField(event.data, "messageSoFar", "message", version);
861
820
  } else if (event.type === "reasoning.appended") {
862
- assertCurrentAppendDelta(event.data.reasoningDelta, "reasoning");
863
- assertUnsupportedAppendField(event.data, "reasoningOffset", "reasoning");
864
- assertUnsupportedAppendField(event.data, "reasoningSoFar", "reasoning");
821
+ assertAppendDelta(event.data.reasoningDelta, "reasoning", version);
822
+ assertUnsupportedAppendField(event.data, "reasoningOffset", "reasoning", version);
823
+ assertUnsupportedAppendField(event.data, "reasoningSoFar", "reasoning", version);
865
824
  } else if (event.type === "action.input.appended") {
866
- assertCurrentAppendDelta(event.data.inputTextDelta, "action input");
867
- assertUnsupportedAppendField(event.data, "inputTextOffset", "action input");
825
+ assertAppendDelta(event.data.inputTextDelta, "action input", version);
826
+ assertUnsupportedAppendField(event.data, "inputTextOffset", "action input", version);
868
827
  }
869
828
  return event;
870
829
  }
871
- function assertCurrentAppendDelta(delta, stream) {
872
- if (typeof delta !== "string") throw new TypeError(`Invalid ${stream} append delta for stream version 25.`);
830
+ function assertAppendDelta(delta, stream, version) {
831
+ if (typeof delta !== "string") throw new TypeError(`Invalid ${stream} append delta for stream version ${version}.`);
873
832
  }
874
- function assertUnsupportedAppendField(data, field, stream) {
875
- if (field in data) throw new TypeError(`Invalid ${stream} append shape for stream version 25.`);
833
+ function assertUnsupportedAppendField(data, field, stream, version) {
834
+ if (field in data) throw new TypeError(`Invalid ${stream} append shape for stream version ${version}.`);
876
835
  }
877
836
  function assertNever(value) {
878
837
  throw new TypeError(`Unsupported message stream version: ${String(value)}.`);
@@ -973,7 +932,8 @@ const supportedMessageStreamVersions = {
973
932
  "22": true,
974
933
  "23": true,
975
934
  "24": true,
976
- "25": true
935
+ "25": true,
936
+ "26": true
977
937
  };
978
938
  function readMessageStreamVersion(headers) {
979
939
  const version = headers.get(EVE_STREAM_VERSION_HEADER);
@@ -1255,6 +1215,120 @@ async function sleep(ms, signal) {
1255
1215
  });
1256
1216
  }
1257
1217
 
1218
+ //#endregion
1219
+ //#region src/client/agent-session.ts
1220
+ var ClientAgentSession = class {
1221
+ name;
1222
+ sessionId;
1223
+ taskId;
1224
+ #context;
1225
+ #streamPath;
1226
+ constructor(context, started) {
1227
+ this.#context = context;
1228
+ this.#streamPath = started.data.streamPath;
1229
+ this.name = started.data.name;
1230
+ this.sessionId = started.data.sessionId;
1231
+ this.taskId = started.data.taskId;
1232
+ }
1233
+ stream(options) {
1234
+ const startIndex = options?.startIndex ?? 0;
1235
+ if (options?.follow === false && startIndex < 0) throw new Error("agent(started).stream({ follow: false }) requires a nonnegative startIndex; a tail-relative cursor cannot be bounded.");
1236
+ return followStreamIterable({
1237
+ follow: options?.follow,
1238
+ host: this.#context.host,
1239
+ path: this.#streamPath,
1240
+ redirect: this.#context.redirect,
1241
+ resolveHeaders: () => this.#context.resolveHeaders(),
1242
+ signal: options?.signal,
1243
+ startIndex,
1244
+ streamReconnectPolicy: options?.streamReconnectPolicy
1245
+ });
1246
+ }
1247
+ };
1248
+
1249
+ //#endregion
1250
+ //#region src/client/output-schema.ts
1251
+ function extractCompletedResult(events) {
1252
+ let result;
1253
+ for (const event of events) if (isResultCompletedEvent(event)) result = event.data.result;
1254
+ return result;
1255
+ }
1256
+ function isResultCompletedEvent(event) {
1257
+ return event.type === "result.completed";
1258
+ }
1259
+
1260
+ //#endregion
1261
+ //#region src/client/message-response.ts
1262
+ const consumeResponse = Symbol("consumeMessageResponse");
1263
+ const acceptedDeliveryId = Symbol("acceptedDeliveryId");
1264
+ var MessageResponse = class {
1265
+ sessionId;
1266
+ [acceptedDeliveryId];
1267
+ #cancelTurn;
1268
+ #cancellation;
1269
+ #consumed = false;
1270
+ #createStream;
1271
+ #settled = false;
1272
+ #turnId = Promise.withResolvers();
1273
+ constructor(input) {
1274
+ this.#cancelTurn = input.cancelTurn;
1275
+ this.sessionId = input.sessionId;
1276
+ this[acceptedDeliveryId] = input.deliveryId;
1277
+ this.#createStream = input.createStream;
1278
+ }
1279
+ cancel() {
1280
+ if (this.#settled) return Promise.resolve({ status: "no_active_turn" });
1281
+ if (this.#cancellation !== void 0) return this.#cancellation;
1282
+ const cancellation = this.#turnId.promise.then((turnId) => turnId === void 0 ? { status: "no_active_turn" } : this.#cancelTurn(turnId));
1283
+ this.#cancellation = cancellation;
1284
+ cancellation.catch(() => {
1285
+ if (!this.#settled && this.#cancellation === cancellation) this.#cancellation = void 0;
1286
+ });
1287
+ return cancellation;
1288
+ }
1289
+ async result() {
1290
+ const events = [];
1291
+ for await (const event of this) events.push(event);
1292
+ const summary = summarizeTurnEvents(events);
1293
+ return {
1294
+ data: extractCompletedResult(events),
1295
+ events,
1296
+ inputRequests: summary.inputRequests,
1297
+ message: summary.message,
1298
+ sessionId: this.sessionId,
1299
+ status: summary.status
1300
+ };
1301
+ }
1302
+ [Symbol.asyncIterator]() {
1303
+ return this[consumeResponse]();
1304
+ }
1305
+ [consumeResponse](source) {
1306
+ if (this.#consumed) throw new Error("MessageResponse has already been consumed.");
1307
+ this.#consumed = true;
1308
+ return this.#observeStream(source);
1309
+ }
1310
+ async *#observeStream(source) {
1311
+ try {
1312
+ for await (const event of this.#createStream(source)) {
1313
+ if (event.type === "turn.started") this.#turnId.resolve(event.data.turnId);
1314
+ else if (isCurrentTurnBoundaryEvent(event)) {
1315
+ this.#settled = true;
1316
+ this.#turnId.resolve(void 0);
1317
+ }
1318
+ yield event;
1319
+ }
1320
+ } finally {
1321
+ this.#turnId.resolve(void 0);
1322
+ }
1323
+ }
1324
+ };
1325
+ function getMessageResponseDeliveryId(response) {
1326
+ return response[acceptedDeliveryId];
1327
+ }
1328
+ function consumeMessageResponse(response, source) {
1329
+ return response[consumeResponse](source);
1330
+ }
1331
+
1258
1332
  //#endregion
1259
1333
  //#region src/protocol/cancel-turn.ts
1260
1334
  const CancelTurnResponseSchema = z.discriminatedUnion("status", [z.strictObject({
@@ -1436,11 +1510,42 @@ function isPlainObject(value) {
1436
1510
  }
1437
1511
 
1438
1512
  //#endregion
1439
- //#region src/tools/schema.ts
1513
+ //#region src/tools/schema-emission.ts
1440
1514
  const JSON_SCHEMA_TARGET = "draft-07";
1441
1515
  function serializeOutputSchema(source) {
1442
- return serializeSchema(source, "output");
1516
+ if (source === null || source === void 0) return source;
1517
+ return emitJsonSchema(source, "output");
1518
+ }
1519
+ function emitJsonSchema(source, direction) {
1520
+ const standard = getStandardSchemaProperties(source);
1521
+ if (standard === void 0) return withoutSchemaVersion(parseJsonObject(source));
1522
+ const emit = readJsonSchemaEmitter(standard, direction);
1523
+ if (emit === void 0) throw new Error(describeMissingEmitter(standard));
1524
+ return withoutSchemaVersion(parseJsonObject(emit({ target: JSON_SCHEMA_TARGET })));
1443
1525
  }
1526
+ function readJsonSchemaEmitter(standard, direction) {
1527
+ const jsonSchema = standard.jsonSchema;
1528
+ if (typeof jsonSchema !== "object" || jsonSchema === null) return void 0;
1529
+ const emit = jsonSchema[direction];
1530
+ return typeof emit === "function" ? emit : void 0;
1531
+ }
1532
+ function getStandardSchemaProperties(value) {
1533
+ if (typeof value !== "object" || value === null || !("~standard" in value)) return void 0;
1534
+ const standard = value["~standard"];
1535
+ return typeof standard === "object" && standard !== null ? standard : void 0;
1536
+ }
1537
+ function describeMissingEmitter(standard) {
1538
+ const vendor = typeof standard.vendor === "string" ? standard.vendor : "unknown";
1539
+ if (vendor === "zod") return "Zod 3 cannot emit an output JSON Schema. Upgrade to Zod 4 or provide a plain JSON Schema object.";
1540
+ return `Standard Schema vendor "${vendor}" does not support JSON Schema conversion. Provide a Standard Schema implementation with JSON Schema conversion or a plain JSON Schema object.`;
1541
+ }
1542
+ function withoutSchemaVersion(schema) {
1543
+ const { $schema: _schemaVersion, ...canonical } = schema;
1544
+ return canonical;
1545
+ }
1546
+
1547
+ //#endregion
1548
+ //#region src/tools/schema.ts
1444
1549
  function defineJsonSchema(schema, check) {
1445
1550
  const emit = () => structuredClone(schema);
1446
1551
  const toolSchema = { "~standard": {
@@ -1457,32 +1562,6 @@ function defineJsonSchema(schema, check) {
1457
1562
  }
1458
1563
  const plainJsonSchemas = /* @__PURE__ */ new WeakSet();
1459
1564
  const UNSPECIFIED_INPUT_SCHEMA = defineJsonSchema({});
1460
- function serializeSchema(source, direction) {
1461
- if (source === null || source === void 0) return source;
1462
- return toJsonObject(source, direction);
1463
- }
1464
- function toJsonObject(source, direction) {
1465
- const standard = getStandardSchemaProperties(source);
1466
- const jsonSchema = standard?.jsonSchema;
1467
- const emit = typeof jsonSchema === "object" && jsonSchema !== null ? jsonSchema[direction] : void 0;
1468
- const vendor = typeof standard?.vendor === "string" ? standard.vendor : "unknown";
1469
- if (standard !== void 0 && typeof emit !== "function" && vendor === "zod") {
1470
- if (direction === "input") {
1471
- const schema = asSchema(source);
1472
- const { $schema: _schemaVersion, ...canonical } = parseJsonObject(schema.jsonSchema);
1473
- return canonical;
1474
- }
1475
- throw new Error("Zod 3 cannot emit an output JSON Schema. Upgrade to Zod 4 or provide a plain JSON Schema object.");
1476
- }
1477
- if (standard !== void 0 && typeof emit !== "function") throw new Error(`Standard Schema vendor "${vendor}" does not support JSON Schema conversion. Provide a Standard Schema implementation with JSON Schema conversion or a plain JSON Schema object.`);
1478
- const { $schema: _schemaVersion, ...canonical } = standard === void 0 ? parseJsonObject(source) : parseJsonObject(emit({ target: JSON_SCHEMA_TARGET }));
1479
- return canonical;
1480
- }
1481
- function getStandardSchemaProperties(value) {
1482
- if (typeof value !== "object" || value === null || !("~standard" in value)) return void 0;
1483
- const standard = value["~standard"];
1484
- return typeof standard === "object" && standard !== null ? standard : void 0;
1485
- }
1486
1565
  function createJsonSchemaValidator(schema, check) {
1487
1566
  let validator;
1488
1567
  let warned = false;
@@ -1813,21 +1892,8 @@ var ClientSession = class ClientSession {
1813
1892
  if (options?.follow === false && (options.startIndex ?? this.#state.streamIndex) < 0) throw new Error("stream({ follow: false }) requires a nonnegative startIndex; a tail-relative cursor cannot be bounded.");
1814
1893
  return this.#streamAndAdvance(options);
1815
1894
  }
1816
- streamSubagent(called, options) {
1817
- if (called.data.sessionId !== this.#state.sessionId) throw new Error(`streamSubagent() requires a subagent.called event from session ${this.#state.sessionId}, but it came from session ${called.data.sessionId}.`);
1818
- if (typeof called.data.childStreamPath !== "string") throw new Error(`streamSubagent() requires a subagent.called event with childStreamPath, but call ${called.data.callId} has none. The event was recorded by an older eve version.`);
1819
- const startIndex = options?.startIndex ?? 0;
1820
- if (options?.follow === false && startIndex < 0) throw new Error("streamSubagent({ follow: false }) requires a nonnegative startIndex; a tail-relative cursor cannot be bounded.");
1821
- return followStreamIterable({
1822
- follow: options?.follow,
1823
- host: this.#context.host,
1824
- path: called.data.childStreamPath,
1825
- redirect: this.#context.redirect,
1826
- resolveHeaders: () => this.#context.resolveHeaders(),
1827
- signal: options?.signal,
1828
- startIndex,
1829
- streamReconnectPolicy: options?.streamReconnectPolicy
1830
- });
1895
+ agent(started) {
1896
+ return new ClientAgentSession(this.#context, started);
1831
1897
  }
1832
1898
  [followSession](options) {
1833
1899
  return this.#streamAndAdvance({
@@ -1848,7 +1914,7 @@ var ClientSession = class ClientSession {
1848
1914
  let eventCount = 0;
1849
1915
  let started = deliveryId === void 0;
1850
1916
  let reachedBoundary = false;
1851
- const pendingAuthorizations = /* @__PURE__ */ new Set();
1917
+ const segment = new TurnSegment({ followCallbacks: true });
1852
1918
  try {
1853
1919
  for await (const event of source ?? this.#readStream({
1854
1920
  headers: input.headers,
@@ -1866,8 +1932,7 @@ var ClientSession = class ClientSession {
1866
1932
  if (!terminal && event.meta?.deliveryIds !== void 0 && !matches) continue;
1867
1933
  started = true;
1868
1934
  }
1869
- updatePendingAuthorizations(pendingAuthorizations, event);
1870
- reachedBoundary = isCurrentTurnBoundaryEvent(event) && (event.type !== "session.waiting" || pendingAuthorizations.size === 0);
1935
+ reachedBoundary = segment.observe(event);
1871
1936
  yield event;
1872
1937
  if (reachedBoundary) break;
1873
1938
  }
@@ -1985,7 +2050,6 @@ function createMessageBody(input, requireMessage) {
1985
2050
  if (input.message !== void 0) body.message = input.message;
1986
2051
  if (input.inputResponses !== void 0 && input.inputResponses.length > 0) body.inputResponses = input.inputResponses;
1987
2052
  if (!requireMessage && input.message !== void 0 && input.turnPolicy !== void 0) body.turnPolicy = input.turnPolicy;
1988
- if (input.message !== void 0 && input.taskDeliveryPolicy !== void 0) body.taskDeliveryPolicy = input.taskDeliveryPolicy;
1989
2053
  if (input.clientContext !== void 0) body.clientContext = input.clientContext;
1990
2054
  const outputSchema = serializeOutputSchema(input.outputSchema);
1991
2055
  if (outputSchema !== void 0) body.outputSchema = outputSchema;
@@ -2133,117 +2197,6 @@ function withRedirectPolicy(init, redirect) {
2133
2197
  };
2134
2198
  }
2135
2199
 
2136
- //#endregion
2137
- //#region src/client/session-event-stream.ts
2138
- var SessionEventStream = class {
2139
- #controller = new AbortController();
2140
- #readers = /* @__PURE__ */ new Set();
2141
- #caughtUp = Promise.withResolvers();
2142
- caughtUp = this.#caughtUp.promise;
2143
- #ended = false;
2144
- #error;
2145
- #headers;
2146
- #reconnectPolicy;
2147
- constructor(session, options) {
2148
- this.setOptions(options);
2149
- this.caughtUp.catch(() => {});
2150
- if (!options.catchUp) this.#caughtUp.resolve();
2151
- (async () => {
2152
- try {
2153
- for await (const event of followClientSession(session, {
2154
- signal: this.#controller.signal,
2155
- resolveHeaders: () => this.#headers,
2156
- resolveReconnectPolicy: () => this.#reconnectPolicy,
2157
- startIndex: options.startIndex,
2158
- onCaughtUp: options.catchUp ? () => this.#caughtUp.resolve() : void 0
2159
- })) {
2160
- if (this.#controller.signal.aborted) return;
2161
- options.onEvent(event);
2162
- for (const reader of this.#readers) reader.push(event);
2163
- if (event.type === "session.completed" || event.type === "session.failed") break;
2164
- }
2165
- this.#caughtUp.resolve();
2166
- this.#finish();
2167
- } catch (error) {
2168
- this.#caughtUp.reject(error);
2169
- this.#finish(error);
2170
- if (!this.#controller.signal.aborted) options.onError(error);
2171
- }
2172
- })();
2173
- }
2174
- subscribe(signal) {
2175
- const reader = new SessionEventReader(() => this.#readers.delete(reader), signal);
2176
- if (this.#ended) reader.end(this.#error);
2177
- else this.#readers.add(reader);
2178
- return reader;
2179
- }
2180
- get ended() {
2181
- return this.#ended;
2182
- }
2183
- setOptions(options) {
2184
- if ("headers" in options) this.#headers = options.headers;
2185
- if ("streamReconnectPolicy" in options) this.#reconnectPolicy = options.streamReconnectPolicy;
2186
- }
2187
- close() {
2188
- const error = new DOMException("Session stream was detached.", "AbortError");
2189
- this.#controller.abort(error);
2190
- this.#caughtUp.reject(error);
2191
- this.#finish(error);
2192
- }
2193
- #finish(error) {
2194
- if (this.#ended) return;
2195
- this.#ended = true;
2196
- this.#error = error;
2197
- for (const reader of this.#readers) reader.end(error);
2198
- }
2199
- };
2200
- var SessionEventReader = class {
2201
- #events = [];
2202
- #wake = Promise.withResolvers();
2203
- #ended = false;
2204
- #error;
2205
- #dispose;
2206
- constructor(unsubscribe, signal) {
2207
- const abort = () => this.end(signal?.reason);
2208
- signal?.addEventListener("abort", abort, { once: true });
2209
- this.#dispose = () => {
2210
- signal?.removeEventListener("abort", abort);
2211
- unsubscribe();
2212
- };
2213
- if (signal?.aborted) abort();
2214
- }
2215
- push(event) {
2216
- if (this.#ended) return;
2217
- this.#events.push(event);
2218
- this.#wake.resolve();
2219
- }
2220
- end(error) {
2221
- if (this.#ended) return;
2222
- this.#ended = true;
2223
- this.#error = error;
2224
- this.#wake.resolve();
2225
- }
2226
- [Symbol.dispose]() {
2227
- this.end();
2228
- this.#events = [];
2229
- this.#dispose();
2230
- }
2231
- discard() {
2232
- this.#events = [];
2233
- }
2234
- async *[Symbol.asyncIterator]() {
2235
- for (;;) {
2236
- while (this.#events.length > 0) yield this.#events.shift();
2237
- if (this.#ended) {
2238
- if (this.#error !== void 0) throw this.#error;
2239
- return;
2240
- }
2241
- this.#wake = Promise.withResolvers();
2242
- await this.#wake.promise;
2243
- }
2244
- }
2245
- };
2246
-
2247
2200
  //#endregion
2248
2201
  //#region src/client/eve-agent-projection.ts
2249
2202
  var EveAgentProjection = class {
@@ -2252,18 +2205,21 @@ var EveAgentProjection = class {
2252
2205
  #data;
2253
2206
  constructor(reducer, events) {
2254
2207
  this.#reducer = reducer;
2255
- this.#events = events;
2208
+ this.#events = [...events];
2256
2209
  this.#data = this.#reduce();
2257
2210
  }
2258
2211
  get data() {
2259
2212
  return this.#data;
2260
2213
  }
2214
+ get reducer() {
2215
+ return this.#reducer;
2216
+ }
2261
2217
  reset() {
2262
2218
  this.#events = [];
2263
2219
  this.#data = this.#reducer.initial();
2264
2220
  }
2265
2221
  append(event) {
2266
- this.#events = [...this.#events, event];
2222
+ this.#events.push(event);
2267
2223
  this.#data = this.#reducer.reduce(this.#data, event);
2268
2224
  }
2269
2225
  remove(predicate) {
@@ -2272,7 +2228,8 @@ var EveAgentProjection = class {
2272
2228
  }
2273
2229
  replace(predicate, replacement) {
2274
2230
  const index = this.#events.findIndex(predicate);
2275
- this.#events = index === -1 ? [...this.#events, replacement] : this.#events.map((event, i) => i === index ? replacement : event);
2231
+ if (index === -1) this.#events.push(replacement);
2232
+ else this.#events[index] = replacement;
2276
2233
  this.#data = this.#reduce();
2277
2234
  }
2278
2235
  #reduce() {
@@ -2282,16 +2239,68 @@ var EveAgentProjection = class {
2282
2239
  }
2283
2240
  };
2284
2241
 
2242
+ //#endregion
2243
+ //#region src/client/conversation-state.ts
2244
+ function openConversationInputs(state) {
2245
+ return Object.values(state.inputs).filter((input) => input.status === "open");
2246
+ }
2247
+ function conversationAuthorizations(state) {
2248
+ return state.messages.flatMap((message) => message.role === "assistant" ? message.parts.filter((part) => part.type === "authorization") : []);
2249
+ }
2250
+ function hasPendingAuthorizations(state) {
2251
+ return conversationAuthorizations(state).some((part) => part.state === "required" && part.awaitsCallback === true);
2252
+ }
2253
+ function agentToolTask(state, agent) {
2254
+ const task = agent.taskId === void 0 ? void 0 : state.tasks[agent.taskId];
2255
+ return task?.kind === "agent" ? task : void 0;
2256
+ }
2257
+ function isAgentSessionCaughtUp(state, agent) {
2258
+ if (agent.observation.status !== "following" && agent.observation.status !== "idle") return false;
2259
+ const task = agentToolTask(state, agent);
2260
+ if (task === void 0) return false;
2261
+ const calls = Object.values(task.calls);
2262
+ if (calls.some((call) => call.status === "working")) return false;
2263
+ const child = agent.observation.conversation;
2264
+ if (child.activeTurnId !== void 0) return false;
2265
+ if (Object.values(child.inputs).some((input) => input.status !== "settled")) return false;
2266
+ if (hasPendingAuthorizations(child)) return false;
2267
+ return child.messages.filter((message) => message.role === "user").length >= calls.filter((call) => call.status === "completed").length;
2268
+ }
2269
+
2285
2270
  //#endregion
2286
2271
  //#region src/client/eve-agent-store-helpers.ts
2287
- function isSettledSessionTail(events) {
2272
+ function activeTurnForOptimisticFollowUp(events) {
2273
+ const lastTurn = events.findLast((event) => event.type === "turn.started" || event.type === "turn.completed" || event.type === "turn.failed" || event.type === "turn.cancelled" || isCurrentTurnBoundaryEvent(event));
2274
+ return lastTurn?.type === "turn.started" ? lastTurn.data.turnId : void 0;
2275
+ }
2276
+ function isResponseBoundary(event, conversation) {
2277
+ return endsTurnSegment(event, {
2278
+ callbacks: hasPendingAuthorizations(conversation),
2279
+ requests: Object.values(conversation.inputs).some((input) => input.status !== "settled")
2280
+ });
2281
+ }
2282
+ function settledStatus(error, conversation) {
2283
+ if (error !== void 0) return "error";
2284
+ return conversation.activeTurnId === void 0 ? "ready" : "streaming";
2285
+ }
2286
+ function isSettledSessionTail(events, conversation) {
2288
2287
  const tail = events.at(-1);
2289
- return tail !== void 0 && isCurrentTurnBoundaryEvent(tail) && (tail.type !== "session.waiting" || collectPendingAuthorizations(events).size === 0);
2288
+ return tail !== void 0 && isResponseBoundary(tail, conversation);
2289
+ }
2290
+ function assertAnswerable(input, conversation) {
2291
+ for (const { requestId } of input.inputResponses ?? []) {
2292
+ const status = conversation.inputs[requestId]?.status;
2293
+ if (status !== void 0 && status !== "open") throw new Error(`Input request ${requestId} was already answered.`);
2294
+ }
2295
+ }
2296
+ function assertInFlightFollowUp(input) {
2297
+ if (input.inputResponses !== void 0) return;
2298
+ if (input.message === void 0 || input.turnPolicy !== "steer") throw new Error("eve session is already processing a turn. Send a message with turnPolicy: \"steer\" to guide it at the next boundary, or answer an open input request.");
2290
2299
  }
2291
- function collectPendingAuthorizations(events) {
2292
- const pending = /* @__PURE__ */ new Set();
2293
- for (const event of events) updatePendingAuthorizations(pending, event);
2294
- return pending;
2300
+ function validateFollowUp(input) {
2301
+ assertExclusiveTurnInput(input);
2302
+ assertInFlightFollowUp(input);
2303
+ return input;
2295
2304
  }
2296
2305
  function assertExclusiveTurnInput(input) {
2297
2306
  if (input.message !== void 0 === (input.inputResponses !== void 0)) throw new Error("A turn requires exactly one of message or inputResponses.");
@@ -2340,14 +2349,25 @@ function createActiveTurn(cancel) {
2340
2349
  };
2341
2350
  return turn;
2342
2351
  }
2352
+ function countFollowUpDeliveries(turn, reconciliation) {
2353
+ let followed = 0;
2354
+ for (const id of reconciliation.ids) if (turn.followUpSubmissionIds.delete(id)) followed += 1;
2355
+ if (followed === 0) return;
2356
+ if (reconciliation.alreadyProjected) turn.receivedFollowUps += followed;
2357
+ else {
2358
+ const previous = turn.receivedFollowUpEvents.get(reconciliation.event) ?? 0;
2359
+ turn.receivedFollowUpEvents.set(reconciliation.event, previous + followed);
2360
+ }
2361
+ }
2343
2362
  async function followSteeredTurns(turn, events, isActive) {
2344
2363
  while (turn.followUpDispatches.size > 0) await Promise.allSettled(turn.followUpDispatches);
2345
2364
  if (turn.receivedFollowUps >= turn.acceptedFollowUps) return;
2365
+ const segment = new TurnSegment({ followCallbacks: true });
2346
2366
  for await (const event of events) {
2347
2367
  if (!isActive()) return;
2348
2368
  turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
2349
2369
  turn.receivedFollowUpEvents.delete(event);
2350
- if (isCurrentTurnBoundaryEvent(event)) {
2370
+ if (segment.observe(event)) {
2351
2371
  while (turn.followUpDispatches.size > 0) await Promise.allSettled(turn.followUpDispatches);
2352
2372
  if (turn.receivedFollowUps >= turn.acceptedFollowUps) return;
2353
2373
  }
@@ -2370,47 +2390,52 @@ async function waitWithSignal(promise, signal) {
2370
2390
  //#region src/client/optimistic-message-submissions.ts
2371
2391
  var OptimisticMessageSubmissions = class {
2372
2392
  #optimistic;
2373
- #projection;
2393
+ #projections;
2374
2394
  #pending = [];
2375
- constructor(projection, optimistic) {
2376
- this.#projection = projection;
2395
+ constructor(projections, optimistic) {
2396
+ this.#projections = projections;
2377
2397
  this.#optimistic = optimistic;
2378
2398
  }
2379
2399
  reset() {
2380
2400
  this.#pending = [];
2381
2401
  }
2382
- submit(input, eventStartIndex) {
2402
+ submit(input, eventStartIndex, turnId) {
2383
2403
  if (input.message === void 0) return void 0;
2384
2404
  const pending = {
2385
2405
  createdAt: Date.now(),
2386
2406
  eventStartIndex,
2387
2407
  id: createSubmissionId(),
2388
2408
  message: summarizeUserContent(input.message),
2409
+ turnId,
2389
2410
  requiresDeliveryId: true
2390
2411
  };
2391
2412
  this.#pending = [...this.#pending, pending];
2392
- if (this.#optimistic) this.#projection.append({
2413
+ if (this.#optimistic) for (const projection of this.#projections) projection.append({
2393
2414
  data: {
2394
2415
  createdAt: pending.createdAt,
2395
2416
  message: pending.message,
2396
- submissionId: pending.id
2417
+ submissionId: pending.id,
2418
+ turnId
2397
2419
  },
2398
2420
  type: "client.message.submitted"
2399
2421
  });
2400
2422
  return pending.id;
2401
2423
  }
2424
+ resubmit(submissionId, input) {
2425
+ const pending = this.#pending.find((candidate) => candidate.id === submissionId);
2426
+ const message = input.message === void 0 ? void 0 : summarizeUserContent(input.message);
2427
+ if (pending?.message === message) return submissionId;
2428
+ if (pending !== void 0) this.#withdraw([pending.id]);
2429
+ return this.submit(input, pending?.eventStartIndex ?? 0, pending?.turnId);
2430
+ }
2402
2431
  apply(event) {
2403
2432
  if (event.type !== "message.received") {
2404
- this.#projection.append(event);
2405
- return;
2406
- }
2407
- if (event.data.kind === "execution.background_task") {
2408
- this.#projection.append(event);
2433
+ for (const projection of this.#projections) projection.append(event);
2409
2434
  return;
2410
2435
  }
2411
2436
  const matching = this.#matching(event);
2412
2437
  if (matching.length === 0) {
2413
- this.#projection.append(event);
2438
+ for (const projection of this.#projections) projection.append(event);
2414
2439
  return;
2415
2440
  }
2416
2441
  return this.#reconcile(matching, event, false);
@@ -2425,7 +2450,7 @@ var OptimisticMessageSubmissions = class {
2425
2450
  const pending = this.#pending.find((candidate) => candidate.id === submissionId);
2426
2451
  if (pending === void 0) return void 0;
2427
2452
  for (const event of events.slice(pending.eventStartIndex)) {
2428
- if (event.type !== "message.received" || event.data.kind === "execution.background_task") continue;
2453
+ if (event.type !== "message.received") continue;
2429
2454
  const matching = this.#matching(event);
2430
2455
  if (matching.some((candidate) => candidate.id === submissionId)) return this.#reconcile(matching, event, true);
2431
2456
  }
@@ -2434,12 +2459,13 @@ var OptimisticMessageSubmissions = class {
2434
2459
  const pending = submissionId === void 0 ? this.#pending[0] : this.#pending.find((candidate) => candidate.id === submissionId);
2435
2460
  if (pending === void 0) return;
2436
2461
  this.#pending = this.#pending.filter((candidate) => candidate.id !== pending.id);
2437
- this.#projection.replace((event) => event.type === "client.message.submitted" && event.data.submissionId === pending.id, {
2462
+ for (const projection of this.#projections) projection.replace((event) => event.type === "client.message.submitted" && event.data.submissionId === pending.id, {
2438
2463
  data: {
2439
2464
  createdAt: pending.createdAt,
2440
2465
  error: { message: error.message },
2441
2466
  message: pending.message,
2442
- submissionId: pending.id
2467
+ submissionId: pending.id,
2468
+ turnId: pending.turnId
2443
2469
  },
2444
2470
  type: "client.message.failed"
2445
2471
  });
@@ -2452,1141 +2478,1840 @@ var OptimisticMessageSubmissions = class {
2452
2478
  }
2453
2479
  #reconcile(submissions, event, alreadyProjected) {
2454
2480
  const ids = submissions.map((pending) => pending.id);
2455
- const idSet = new Set(ids);
2456
- this.#pending = this.#pending.filter((pending) => !idSet.has(pending.id));
2457
- if (alreadyProjected) this.#projection.remove((candidate) => candidate.type === "client.message.submitted" && idSet.has(candidate.data.submissionId));
2458
- else {
2459
- this.#projection.replace((candidate) => candidate.type === "client.message.submitted" && candidate.data.submissionId === ids[0], event);
2460
- this.#projection.remove((candidate) => candidate.type === "client.message.submitted" && idSet.has(candidate.data.submissionId));
2461
- }
2481
+ this.#withdraw(ids);
2482
+ if (!alreadyProjected) for (const projection of this.#projections) projection.append(event);
2462
2483
  return {
2463
2484
  alreadyProjected,
2464
2485
  event,
2465
2486
  ids
2466
2487
  };
2467
2488
  }
2489
+ #withdraw(ids) {
2490
+ const idSet = new Set(ids);
2491
+ this.#pending = this.#pending.filter((pending) => !idSet.has(pending.id));
2492
+ for (const projection of this.#projections) projection.remove((candidate) => candidate.type === "client.message.submitted" && idSet.has(candidate.data.submissionId));
2493
+ }
2468
2494
  };
2469
2495
 
2470
2496
  //#endregion
2471
- //#region src/protocol/event-dedupe.ts
2472
- function createEventDeduper() {
2473
- const seen = /* @__PURE__ */ new Set();
2474
- return {
2475
- admit(event) {
2476
- const id = event.meta?.id;
2477
- if (id === void 0) return true;
2478
- if (seen.has(id)) return false;
2479
- seen.add(id);
2480
- return true;
2481
- },
2482
- get size() {
2483
- return seen.size;
2497
+ //#region src/client/agent-stream-follower.ts
2498
+ const agentStreamReconnectPolicy = {
2499
+ streamIdleReconnectPolicy: { maxAttempts: Infinity },
2500
+ streamOpenReconnectPolicy: { maxAttempts: Infinity }
2501
+ };
2502
+ var AgentStreamFollower = class {
2503
+ #options;
2504
+ #started = /* @__PURE__ */ new Map();
2505
+ #controllers = /* @__PURE__ */ new Map();
2506
+ #failed = /* @__PURE__ */ new Set();
2507
+ #disposed = false;
2508
+ constructor(options) {
2509
+ this.#options = options;
2510
+ }
2511
+ acceptParentEvent(event) {
2512
+ if (event.type === "agent.started") this.#started.set(event.data.sessionId, event);
2513
+ }
2514
+ reconcile() {
2515
+ if (this.#disposed) return;
2516
+ const state = this.#options.getState();
2517
+ for (const agent of Object.values(state.agents)) {
2518
+ if (agentToolTask(state, agent) === void 0) continue;
2519
+ const controller = this.#controllers.get(agent.sessionId);
2520
+ const caughtUp = isAgentSessionCaughtUp(state, agent);
2521
+ if (controller !== void 0 && caughtUp) {
2522
+ this.#controllers.delete(agent.sessionId);
2523
+ controller.abort();
2524
+ this.#options.onIdle(agent.sessionId);
2525
+ } else if (controller === void 0 && !caughtUp && !this.#failed.has(agent.sessionId)) this.#follow(agent.sessionId);
2484
2526
  }
2485
- };
2486
- }
2487
-
2488
- //#endregion
2489
- //#region src/client/eve-agent-store.ts
2490
- const detachStore = Symbol("detachEveAgentStore");
2491
- const attachStore = Symbol("attachEveAgentStore");
2492
- var EveAgentStore = class {
2493
- #client;
2494
- #autoPrewarm;
2495
- #attached = false;
2496
- #stream;
2497
- #pendingAuthorizations = /* @__PURE__ */ new Set();
2498
- #externalSession;
2499
- #optimistic;
2500
- #projection;
2501
- #subscribers = /* @__PURE__ */ new Set();
2502
- #seenEvents = createEventDeduper();
2503
- #activeTurn;
2504
- #callbacks = {};
2505
- #error;
2506
- #events;
2507
- #messageSubmissions;
2508
- #prewarmGeneration = 0;
2509
- #prewarmPromise;
2510
- #prewarmController;
2511
- #resumePromise;
2512
- #session;
2513
- #snapshot;
2514
- #status = "ready";
2515
- constructor(init) {
2516
- this.#autoPrewarm = init.prewarm ?? false;
2517
- this.#externalSession = init.session !== void 0;
2518
- this.#client = this.#externalSession ? void 0 : new Client({
2519
- auth: init.auth,
2520
- headers: init.headers,
2521
- host: init.host ?? ""
2522
- });
2523
- const initialEvents = [];
2524
- for (const event of init.initialEvents ?? []) {
2525
- if (this.#seenEvents.admit(event)) initialEvents.push(event);
2526
- updatePendingAuthorizations(this.#pendingAuthorizations, event);
2527
- }
2528
- this.#events = initialEvents;
2529
- this.#projection = new EveAgentProjection(init.reducer, this.#events);
2530
- this.#optimistic = init.optimistic ?? true;
2531
- this.#messageSubmissions = new OptimisticMessageSubmissions(this.#projection, this.#optimistic);
2532
- this.#session = init.session ?? (init.initialSession === void 0 ? void 0 : this.#client?.sessions.attach(init.initialSession.sessionId, { streamIndex: init.initialSession.streamIndex }));
2533
- this.#snapshot = this.#createSnapshot();
2534
- }
2535
- get snapshot() {
2536
- return this.#snapshot;
2537
- }
2538
- setCallbacks(callbacks) {
2539
- this.#callbacks = callbacks;
2540
2527
  }
2541
- subscribe(callback) {
2542
- this.#subscribers.add(callback);
2543
- return () => {
2544
- this.#subscribers.delete(callback);
2545
- };
2528
+ abortAll() {
2529
+ this.#disposed = true;
2530
+ for (const controller of this.#controllers.values()) controller.abort();
2531
+ this.#controllers.clear();
2546
2532
  }
2547
- prewarm() {
2548
- if (this.#prewarmPromise !== void 0) return this.#prewarmPromise;
2549
- if (this.#session !== void 0 || this.#externalSession) return Promise.resolve();
2550
- if (this.#activeTurn !== void 0) return this.#activeTurn.response.then((response) => {
2551
- if (response === void 0) throw this.#error ?? new DOMException("Session creation was aborted.", "AbortError");
2552
- });
2553
- const client = this.#client;
2554
- if (client === void 0) return Promise.reject(/* @__PURE__ */ new Error("This eve agent store does not own a session client."));
2555
- const generation = this.#prewarmGeneration;
2533
+ #follow(sessionId) {
2534
+ const started = this.#started.get(sessionId);
2535
+ if (started === void 0) return;
2556
2536
  const controller = new AbortController();
2557
- this.#prewarmController = controller;
2558
- const promise = (async () => {
2537
+ this.#controllers.set(sessionId, controller);
2538
+ this.#options.onFollowing(sessionId);
2539
+ const { cursors } = this.#options;
2540
+ (async () => {
2541
+ let cursor = cursors.get(sessionId) ?? 0;
2559
2542
  try {
2560
- const created = await client.sessions.create({ signal: controller.signal });
2561
- if (generation !== this.#prewarmGeneration) return;
2562
- this.#session = created.session;
2563
- this.#error = void 0;
2564
- if (this.#status === "error") this.#status = "ready";
2565
- this.#callbacks.onSessionChange?.(created.session.state);
2566
- this.#publish();
2567
- this.#ensureStream();
2568
- } catch (error) {
2569
- if (generation === this.#prewarmGeneration && this.#activeTurn === void 0 && this.#error === void 0) {
2570
- this.#error = toError(error);
2571
- this.#status = "error";
2572
- this.#callbacks.onError?.(this.#error);
2573
- this.#publish();
2543
+ for await (const event of this.#options.session.agent(started).stream({
2544
+ signal: controller.signal,
2545
+ startIndex: cursor,
2546
+ streamReconnectPolicy: agentStreamReconnectPolicy
2547
+ })) {
2548
+ if (controller.signal.aborted) return;
2549
+ cursors.set(sessionId, ++cursor);
2550
+ this.#options.onEvent(sessionId, event);
2551
+ this.reconcile();
2574
2552
  }
2575
- throw error;
2576
- }
2553
+ } catch {}
2554
+ if (controller.signal.aborted || this.#controllers.get(sessionId) !== controller) return;
2555
+ this.#controllers.delete(sessionId);
2556
+ this.#failed.add(sessionId);
2557
+ this.#options.onUnavailable(sessionId);
2577
2558
  })();
2578
- this.#prewarmPromise = promise;
2579
- const clear = () => {
2580
- if (this.#prewarmPromise === promise) {
2581
- this.#prewarmPromise = void 0;
2582
- this.#prewarmController = void 0;
2583
- }
2584
- };
2585
- promise.then(clear, clear);
2586
- return promise;
2587
2559
  }
2588
- async send(input) {
2589
- return await this.#submit(input, this.#callbacks.prepareSend);
2560
+ };
2561
+
2562
+ //#endregion
2563
+ //#region src/client/authorization-message-parts.ts
2564
+ function createAuthorizationRequiredPart(event) {
2565
+ const displayName = event.data.authorization?.displayName ?? formatAuthorizationDisplayName(event.data.name);
2566
+ const part = {
2567
+ authorization: event.data.authorization,
2568
+ description: normalizeAuthorizationDescription(event.data.description, event.data.name, displayName),
2569
+ displayName,
2570
+ name: event.data.name,
2571
+ state: "required",
2572
+ stepIndex: event.data.stepIndex,
2573
+ turnId: event.data.turnId,
2574
+ type: "authorization"
2575
+ };
2576
+ if (event.data.attemptId !== void 0) part.attemptId = event.data.attemptId;
2577
+ if (event.data.webhookUrl !== void 0) part.awaitsCallback = true;
2578
+ return part;
2579
+ }
2580
+ function createAuthorizationCompletedPart(event, existing) {
2581
+ const displayName = event.data.authorization?.displayName ?? existing?.displayName ?? formatAuthorizationDisplayName(event.data.name);
2582
+ const part = {
2583
+ authorization: existing?.authorization || event.data.authorization ? {
2584
+ ...existing?.authorization,
2585
+ ...event.data.authorization
2586
+ } : void 0,
2587
+ description: existing?.description ?? buildCompletedAuthorizationDescription(displayName, event.data.outcome, event.data.reason),
2588
+ displayName,
2589
+ name: event.data.name,
2590
+ outcome: event.data.outcome,
2591
+ state: "completed",
2592
+ stepIndex: existing?.stepIndex ?? event.data.stepIndex,
2593
+ turnId: existing?.turnId ?? event.data.turnId,
2594
+ type: "authorization"
2595
+ };
2596
+ const attemptId = event.data.attemptId ?? existing?.attemptId;
2597
+ if (attemptId !== void 0) part.attemptId = attemptId;
2598
+ if (existing?.awaitsCallback) part.awaitsCallback = true;
2599
+ if (event.data.reason !== void 0) part.reason = event.data.reason;
2600
+ return part;
2601
+ }
2602
+ function buildCompletedAuthorizationDescription(displayName, outcome, reason) {
2603
+ if (outcome === "authorized") return `${displayName} connected.`;
2604
+ return `${displayName} authorization ${outcome}${reason !== void 0 ? ` (${reason})` : ""}.`;
2605
+ }
2606
+ function normalizeAuthorizationDescription(description, name, displayName) {
2607
+ if (description === `Authorization required for ${name}`) return `Authorization required for ${displayName}`;
2608
+ return description;
2609
+ }
2610
+ function formatAuthorizationDisplayName(name) {
2611
+ if (name.length === 0) return name;
2612
+ return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
2613
+ }
2614
+
2615
+ //#endregion
2616
+ //#region src/shared/action-request-name.ts
2617
+ function actionRequestName(action) {
2618
+ switch (action.kind) {
2619
+ case "load-skill": return "load_skill";
2620
+ case "subagent-call": return action.subagentName;
2621
+ case "remote-agent-call": return action.remoteAgentName;
2622
+ case "tool-call":
2623
+ case "workflow-tool-call": return action.toolName;
2590
2624
  }
2591
- async #submit(input, prepareSend) {
2592
- if (this.#activeTurn !== void 0) {
2593
- if (this.#status === "resuming") throw new Error("eve session is resuming.");
2594
- return await this.#sendFollowUp(this.#activeTurn, input, prepareSend);
2595
- }
2596
- const turn = createActiveTurn((turn) => turn.acceptedFollowUps > 0 && this.#session !== void 0 ? this.#session.cancel() : turn.response.then((response) => response === void 0 ? { status: "no_active_turn" } : response.cancel()));
2597
- this.#activeTurn = turn;
2598
- this.#error = void 0;
2599
- this.#status = "submitted";
2600
- this.#publish();
2601
- let reader;
2602
- try {
2603
- const preparedInput = await (prepareSend === void 0 ? input : waitWithSignal(Promise.resolve(prepareSend(input)), createAbortSignal(input.signal, turn.abortController.signal)));
2604
- assertExclusiveTurnInput(preparedInput);
2605
- if (!this.#isActiveTurn(turn)) return;
2606
- const submissionId = this.#messageSubmissions.submit(preparedInput, this.#events.length);
2607
- this.#projectInputResponses(preparedInput);
2608
- this.#publish();
2609
- const turnInput = {
2610
- ...preparedInput,
2611
- signal: createAbortSignal(preparedInput.signal, turn.abortController.signal)
2612
- };
2613
- const dispatched = await this.#dispatchTurn(turnInput);
2614
- const response = dispatched.response;
2615
- reader = dispatched.reader;
2616
- if (!this.#isActiveTurn(turn)) return;
2617
- turn.resolveResponse(response);
2618
- if (this.#handleReconciliation(this.#messageSubmissions.correlate(submissionId, getMessageResponseDeliveryId(response), this.#events))) this.#publish();
2619
- for await (const event of consumeMessageResponse(response, reader)) {
2620
- if (!this.#isActiveTurn(turn)) return;
2621
- turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
2622
- turn.receivedFollowUpEvents.delete(event);
2623
- }
2624
- if (!this.#isActiveTurn(turn)) return;
2625
- await followSteeredTurns(turn, reader, () => this.#isActiveTurn(turn));
2626
- if (!this.#isActiveTurn(turn)) return;
2627
- this.#status = this.#error === void 0 ? "ready" : "error";
2628
- } catch (error) {
2629
- if (!this.#isActiveTurn(turn)) return;
2630
- if (isAbortError(error)) {
2631
- this.#status = "ready";
2632
- this.#messageSubmissions.fail(toError(error));
2633
- } else {
2634
- const reported = this.#error !== void 0;
2635
- this.#error ??= toError(error);
2636
- this.#status = "error";
2637
- this.#messageSubmissions.fail(this.#error);
2638
- if (!reported) this.#callbacks.onError?.(this.#error);
2639
- }
2640
- } finally {
2641
- reader?.[Symbol.dispose]();
2642
- this.#finishTurn(turn);
2643
- }
2644
- }
2645
- resume() {
2646
- if (this.#resumePromise !== void 0) return this.#resumePromise;
2647
- const promise = this.#resume();
2648
- this.#resumePromise = promise;
2649
- const clear = () => {
2650
- if (this.#resumePromise === promise) this.#resumePromise = void 0;
2625
+ }
2626
+
2627
+ //#endregion
2628
+ //#region src/client/message-action-parts.ts
2629
+ function toMessageInputRequest(request) {
2630
+ return {
2631
+ allowFreeform: request.allowFreeform,
2632
+ display: request.display,
2633
+ kind: request.kind,
2634
+ options: request.options,
2635
+ prompt: request.prompt,
2636
+ requestId: request.requestId
2637
+ };
2638
+ }
2639
+ function createToolMetadata(descriptor, extra) {
2640
+ return { eve: {
2641
+ inputRequest: extra?.inputRequest,
2642
+ kind: descriptor.kind,
2643
+ name: descriptor.name
2644
+ } };
2645
+ }
2646
+ function mergeToolMetadata(current, next) {
2647
+ const kind = next.eve?.kind ?? current?.eve?.kind ?? "unknown";
2648
+ const name = next.eve?.name ?? current?.eve?.name ?? "unknown";
2649
+ return { eve: {
2650
+ ...current?.eve,
2651
+ ...next.eve,
2652
+ inputRequest: next.eve?.inputRequest ?? current?.eve?.inputRequest,
2653
+ inputResponse: next.eve?.inputResponse ?? current?.eve?.inputResponse,
2654
+ kind,
2655
+ name
2656
+ } };
2657
+ }
2658
+ function approvedApproval(part) {
2659
+ if (!part?.approval?.id) return;
2660
+ return {
2661
+ approved: true,
2662
+ id: part.approval.id,
2663
+ isAutomatic: part.approval.isAutomatic,
2664
+ reason: part.approval.reason
2665
+ };
2666
+ }
2667
+ function normalizeActionRequest(action) {
2668
+ const name = actionRequestName(action);
2669
+ switch (action.kind) {
2670
+ case "load-skill": return {
2671
+ kind: "load-skill",
2672
+ name,
2673
+ toolName: "eve:load-skill"
2674
+ };
2675
+ case "tool-call":
2676
+ case "workflow-tool-call": return {
2677
+ kind: "tool-call",
2678
+ name,
2679
+ toolName: name
2680
+ };
2681
+ case "subagent-call":
2682
+ case "remote-agent-call": return {
2683
+ kind: "subagent-call",
2684
+ name,
2685
+ toolName: `eve:subagent:${name}`
2651
2686
  };
2652
- promise.then(clear, clear);
2653
- return promise;
2654
- }
2655
- async #resume() {
2656
- if (this.#status === "resuming" || this.#status === "streaming" || this.#status === "submitted") throw new Error("eve session is already processing a turn.");
2657
- if (this.#session === void 0) throw new Error("An eve session is required before resuming.");
2658
- const session = this.#session;
2659
- const turn = createActiveTurn(() => session.cancel());
2660
- this.#activeTurn = turn;
2661
- turn.resolveResponse(void 0);
2662
- this.#error = void 0;
2663
- this.#status = "resuming";
2664
- this.#publish();
2665
- let reader;
2666
- try {
2667
- const stream = this.#ensureStream({
2668
- catchUp: true,
2669
- startIndex: this.#events.length === session.state.streamIndex ? session.state.streamIndex : 0
2670
- });
2671
- reader = stream.subscribe(turn.abortController.signal);
2672
- await stream.caughtUp;
2673
- if (!this.#isActiveTurn(turn)) return;
2674
- reader.discard();
2675
- const tail = this.#events.at(-1);
2676
- if (tail !== void 0) this.#applyTerminalStreamFailure(tail);
2677
- if (tail !== void 0 && this.#error === void 0 && !isSettledSessionTail(this.#events)) {
2678
- this.#status = "streaming";
2679
- this.#publish();
2680
- for await (const event of reader) {
2681
- if (!this.#isActiveTurn(turn)) return;
2682
- turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
2683
- turn.receivedFollowUpEvents.delete(event);
2684
- if (isCurrentTurnBoundaryEvent(event) && this.#pendingAuthorizations.size === 0) break;
2685
- }
2686
- }
2687
- await followSteeredTurns(turn, reader, () => this.#isActiveTurn(turn));
2688
- if (this.#isActiveTurn(turn)) this.#status = this.#error === void 0 ? "ready" : "error";
2689
- } catch (error) {
2690
- if (!this.#isActiveTurn(turn)) return;
2691
- if (isAbortError(error)) this.#status = "ready";
2692
- else {
2693
- this.#error = toError(error);
2694
- this.#status = "error";
2695
- this.#callbacks.onError?.(this.#error);
2696
- }
2697
- } finally {
2698
- reader?.[Symbol.dispose]();
2699
- this.#finishTurn(turn);
2700
- }
2701
2687
  }
2702
- cancel() {
2703
- const turn = this.#activeTurn;
2704
- if (turn === void 0) return this.#status === "streaming" && this.#session !== void 0 ? this.#session.cancel() : Promise.resolve({ status: "no_active_turn" });
2705
- return turn.cancel();
2688
+ }
2689
+ function normalizeActionResult(result) {
2690
+ switch (result.kind) {
2691
+ case "load-skill-result": return {
2692
+ kind: "load-skill",
2693
+ name: result.name ?? "load_skill",
2694
+ toolName: "eve:load-skill"
2695
+ };
2696
+ case "tool-result": return {
2697
+ kind: "tool-call",
2698
+ name: result.toolName,
2699
+ toolName: result.toolName
2700
+ };
2701
+ case "subagent-result": return {
2702
+ kind: "subagent-call",
2703
+ name: result.subagentName,
2704
+ toolName: `eve:subagent:${result.subagentName}`
2705
+ };
2706
2706
  }
2707
- [attachStore]() {
2708
- this.#attached = true;
2709
- if (this.#autoPrewarm && this.#session === void 0) this.prewarm().catch(() => {});
2707
+ }
2708
+ function stringifyUnknown(value) {
2709
+ if (typeof value === "string") return value;
2710
+ try {
2711
+ return JSON.stringify(value);
2712
+ } catch {
2713
+ return "Action failed.";
2710
2714
  }
2711
- [detachStore]() {
2712
- this.#attached = false;
2713
- this.#stream?.close();
2714
- this.#stream = void 0;
2715
- this.#activeTurn?.abortController.abort();
2716
- this.#resetPrewarm();
2717
- this.#resumePromise = void 0;
2715
+ }
2716
+
2717
+ //#endregion
2718
+ //#region src/client/message-reducer-primitives.ts
2719
+ function projectReceivedParts(parts, message) {
2720
+ return parts?.map((part) => part.type === "text" ? {
2721
+ state: "done",
2722
+ text: part.text,
2723
+ type: "text"
2724
+ } : {
2725
+ filename: part.filename,
2726
+ mediaType: part.mediaType,
2727
+ size: part.size,
2728
+ type: "file",
2729
+ url: part.url
2730
+ }) ?? [{
2731
+ state: "done",
2732
+ text: message,
2733
+ type: "text"
2734
+ }];
2735
+ }
2736
+ function partKey(part) {
2737
+ switch (part.type) {
2738
+ case "text": return `text:${part.stepIndex ?? 0}`;
2739
+ case "reasoning": return `reasoning:${part.stepIndex ?? 0}`;
2740
+ case "file": return `file:${part.stepIndex ?? 0}:${part.filename ?? part.url ?? part.mediaType}`;
2741
+ case "step-start": return "step-start";
2742
+ case "authorization": return part.attemptId === void 0 ? `authorization:${part.turnId}:${part.stepIndex}:${part.name}` : `authorization:${part.attemptId}`;
2743
+ case "dynamic-tool": return `dynamic-tool:${part.toolCallId}`;
2718
2744
  }
2719
- reset() {
2720
- this.#stream?.close();
2721
- this.#stream = void 0;
2722
- this.#pendingAuthorizations.clear();
2723
- const turn = this.#activeTurn;
2724
- this.#activeTurn = void 0;
2725
- turn?.resolveResponse(void 0);
2726
- turn?.resolveCompletion();
2727
- turn?.abortController.abort();
2728
- this.#resetPrewarm();
2729
- this.#resumePromise = void 0;
2730
- if (!this.#externalSession) this.#session = void 0;
2731
- this.#events = [];
2732
- this.#seenEvents = createEventDeduper();
2733
- this.#messageSubmissions.reset();
2734
- this.#projection.reset();
2735
- this.#error = void 0;
2736
- this.#status = "ready";
2737
- this.#callbacks.onSessionChange?.(this.#session?.state);
2738
- this.#publish();
2739
- if (this.#autoPrewarm && this.#attached) this.prewarm().catch(() => {});
2745
+ }
2746
+ function upsertMessage(data, next, beforeAssistantTurnId) {
2747
+ const index = data.messages.findIndex((message) => message.id === next.id);
2748
+ if (index !== -1) return {
2749
+ ...data,
2750
+ messages: [
2751
+ ...data.messages.slice(0, index),
2752
+ next,
2753
+ ...data.messages.slice(index + 1)
2754
+ ]
2755
+ };
2756
+ const before = beforeAssistantTurnId === void 0 ? -1 : data.messages.findIndex((message) => message.role === "assistant" && message.metadata?.turnId === beforeAssistantTurnId);
2757
+ if (before === -1) return {
2758
+ ...data,
2759
+ messages: [...data.messages, next]
2760
+ };
2761
+ return {
2762
+ ...data,
2763
+ messages: [
2764
+ ...data.messages.slice(0, before),
2765
+ next,
2766
+ ...data.messages.slice(before)
2767
+ ]
2768
+ };
2769
+ }
2770
+ function optimisticUserMessageId(submissionId) {
2771
+ return `optimistic:${submissionId}:user`;
2772
+ }
2773
+
2774
+ //#endregion
2775
+ //#region src/client/message-run-parts.ts
2776
+ function transition(message, input) {
2777
+ const index = message.parts.findLastIndex((part) => part.type === input.type && part.stepIndex === input.stepIndex);
2778
+ const previous = index === -1 ? void 0 : message.parts[index];
2779
+ if (input.kind === "append" && !input.delta) return message;
2780
+ const current = previous?.state === "streaming" ? previous : void 0;
2781
+ const part = {
2782
+ id: current?.id ?? input.id ?? `${message.id}:${input.type}:${message.parts.length}`,
2783
+ state: input.kind === "append" ? "streaming" : "done",
2784
+ stepIndex: input.stepIndex,
2785
+ text: input.kind === "append" ? (current?.text ?? "") + input.delta : input.text,
2786
+ type: input.type
2787
+ };
2788
+ const parts = current ? [
2789
+ ...message.parts.slice(0, index),
2790
+ part,
2791
+ ...message.parts.slice(index + 1)
2792
+ ] : [...message.parts, part];
2793
+ return {
2794
+ ...message,
2795
+ metadata: {
2796
+ ...message.metadata,
2797
+ status: input.type === "text" && part.state === "done" ? "complete" : "streaming"
2798
+ },
2799
+ parts
2800
+ };
2801
+ }
2802
+ const messageRun = { transition };
2803
+
2804
+ //#endregion
2805
+ //#region src/client/message-task-parts.ts
2806
+ function createSettledTaskPart(existing, event) {
2807
+ const settledPartBase = {
2808
+ approval: approvedApproval(existing),
2809
+ input: existing.input,
2810
+ stepIndex: existing.stepIndex,
2811
+ toolCallId: existing.toolCallId,
2812
+ toolMetadata: existing.toolMetadata,
2813
+ toolName: existing.toolName,
2814
+ type: "dynamic-tool"
2815
+ };
2816
+ switch (event.data.status) {
2817
+ case "completed": return {
2818
+ ...settledPartBase,
2819
+ output: event.data.output,
2820
+ state: "output-available"
2821
+ };
2822
+ case "failed": return {
2823
+ ...settledPartBase,
2824
+ errorText: event.data.error?.message ?? "Task failed.",
2825
+ state: "output-error"
2826
+ };
2827
+ case "cancelled": return {
2828
+ ...settledPartBase,
2829
+ errorText: "Task was cancelled.",
2830
+ state: "output-error"
2831
+ };
2740
2832
  }
2741
- async #sendFollowUp(turn, input, prepareSend) {
2742
- if (input.message === void 0 || input.turnPolicy !== "steer") throw new Error("eve session is already processing a turn. Send a message with turnPolicy: \"steer\" to guide it at the next boundary.");
2743
- const generation = this.#prewarmGeneration;
2744
- const signal = createAbortSignal(input.signal, turn.abortController.signal);
2745
- const preparedInput = await waitWithSignal(Promise.resolve(prepareSend?.(input)), signal) ?? input;
2746
- if (generation !== this.#prewarmGeneration) return;
2747
- assertExclusiveTurnInput(preparedInput);
2748
- if (preparedInput.message === void 0 || preparedInput.turnPolicy !== "steer") throw new Error("An in-flight follow-up requires a message with turnPolicy: \"steer\".");
2749
- if (!this.#isActiveTurn(turn)) return await this.#submit(preparedInput);
2750
- const submissionId = this.#messageSubmissions.submit(preparedInput, this.#events.length);
2751
- if (submissionId !== void 0) turn.followUpSubmissionIds.add(submissionId);
2752
- this.#publish();
2753
- this.#ensureStream({
2754
- headers: preparedInput.headers,
2755
- streamReconnectPolicy: preparedInput.streamReconnectPolicy
2756
- });
2757
- let dispatch;
2758
- dispatch = (async () => {
2759
- try {
2760
- const signal = createAbortSignal(preparedInput.signal, turn.abortController.signal);
2761
- await waitWithSignal(turn.response, signal);
2762
- if (!this.#isActiveTurn(turn) || this.#session === void 0) throw new Error("The active eve turn ended before the follow-up could be sent.");
2763
- const { message, ...options } = preparedInput;
2764
- const response = await this.#session.send(message, {
2765
- ...options,
2766
- signal
2767
- });
2768
- turn.acceptedFollowUps += 1;
2769
- if (this.#handleReconciliation(this.#messageSubmissions.correlate(submissionId, getMessageResponseDeliveryId(response), this.#events))) this.#publish();
2770
- } catch (error) {
2771
- if (this.#isActiveTurn(turn)) {
2772
- this.#messageSubmissions.fail(toError(error), submissionId);
2773
- this.#publish();
2774
- }
2775
- throw error;
2776
- } finally {
2777
- turn.followUpDispatches.delete(dispatch);
2833
+ }
2834
+
2835
+ //#endregion
2836
+ //#region src/client/message-reducer.ts
2837
+ function receivedMessageEventId(event) {
2838
+ return event.meta.id ?? `${event.data.turnId}:${event.data.sequence}`;
2839
+ }
2840
+ function defaultMessageReducer() {
2841
+ return {
2842
+ initial() {
2843
+ return { messages: [] };
2844
+ },
2845
+ reduce(data, event) {
2846
+ return reduceMessageData(data, event);
2847
+ }
2848
+ };
2849
+ }
2850
+ function reduceMessageData(data, event) {
2851
+ switch (event.type) {
2852
+ case "client.message.submitted":
2853
+ case "client.message.failed": return upsertMessage(data, {
2854
+ id: optimisticUserMessageId(event.data.submissionId),
2855
+ metadata: {
2856
+ optimistic: true,
2857
+ status: event.type === "client.message.failed" ? "failed" : "submitted"
2858
+ },
2859
+ parts: [{
2860
+ type: "text",
2861
+ text: event.data.message
2862
+ }],
2863
+ role: "user"
2864
+ }, event.data.turnId);
2865
+ case "input.resolved": {
2866
+ let next = data;
2867
+ for (const resolution of event.data.resolutions) next = resolveInputRequest(next, resolution);
2868
+ return next;
2869
+ }
2870
+ case "message.received": return upsertMessage(data, {
2871
+ id: `${receivedMessageEventId(event)}:user`,
2872
+ metadata: {
2873
+ status: "complete",
2874
+ turnId: event.data.turnId
2875
+ },
2876
+ parts: projectReceivedParts(event.data.parts, event.data.message),
2877
+ role: "user"
2878
+ }, event.data.turnId);
2879
+ case "step.started": return updateAssistantMessage(data, event.data.turnId, (message) => ensureStepStartPart(message, event.data.stepIndex));
2880
+ case "step.completed":
2881
+ if (data.messages.find((message) => message.role === "assistant" && message.metadata?.turnId === event.data.turnId) === void 0) return data;
2882
+ return updateAssistantMessage(data, event.data.turnId, (message) => ({
2883
+ ...message,
2884
+ parts: closeStreamingRuns(message.parts, event.data.stepIndex)
2885
+ }));
2886
+ case "reasoning.appended": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.transition(ensureStepStartPart(message, event.data.stepIndex), {
2887
+ kind: "append",
2888
+ delta: event.data.reasoningDelta,
2889
+ id: event.meta?.id,
2890
+ stepIndex: event.data.stepIndex,
2891
+ type: "reasoning"
2892
+ }));
2893
+ case "reasoning.completed": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.transition(ensureStepStartPart(message, event.data.stepIndex), {
2894
+ kind: "complete",
2895
+ stepIndex: event.data.stepIndex,
2896
+ text: event.data.reasoning,
2897
+ id: event.meta?.id,
2898
+ type: "reasoning"
2899
+ }));
2900
+ case "action.input.appended": {
2901
+ const existing = findToolPart(data, event.data.callId);
2902
+ if (existing !== void 0 && existing.state !== "input-streaming") return data;
2903
+ const nextPart = {
2904
+ input: void 0,
2905
+ inputText: (existing?.state === "input-streaming" ? existing.inputText : "") + event.data.inputTextDelta,
2906
+ state: "input-streaming",
2907
+ stepIndex: event.data.stepIndex,
2908
+ toolCallId: event.data.callId,
2909
+ toolMetadata: existing?.toolMetadata ?? { eve: {
2910
+ kind: "unknown",
2911
+ name: event.data.toolName
2912
+ } },
2913
+ toolName: event.data.toolName,
2914
+ type: "dynamic-tool"
2915
+ };
2916
+ return upsertToolPart(data, event.data.turnId, event.data.stepIndex, nextPart);
2917
+ }
2918
+ case "actions.requested": {
2919
+ let next = data;
2920
+ for (const action of event.data.actions) {
2921
+ const existing = findToolPart(next, action.callId);
2922
+ if (existing !== void 0 && existing.state !== "input-streaming") continue;
2923
+ const descriptor = normalizeActionRequest(action);
2924
+ next = updateAssistantMessage(next, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
2925
+ input: "input" in action ? action.input : void 0,
2926
+ state: "input-available",
2927
+ stepIndex: event.data.stepIndex,
2928
+ toolCallId: action.callId,
2929
+ toolMetadata: createToolMetadata(descriptor),
2930
+ toolName: descriptor.toolName,
2931
+ type: "dynamic-tool"
2932
+ }));
2778
2933
  }
2779
- })();
2780
- turn.followUpDispatches.add(dispatch);
2781
- await dispatch;
2782
- await turn.completion;
2783
- }
2784
- async #dispatchTurn(input) {
2785
- const streamOptions = {
2786
- headers: input.headers,
2787
- streamReconnectPolicy: input.streamReconnectPolicy
2788
- };
2789
- if (this.#prewarmPromise !== void 0) {
2790
- await waitWithSignal(this.#prewarmPromise.catch((error) => {
2791
- if (this.#session !== void 0) throw error;
2792
- }), input.signal);
2793
- input.signal?.throwIfAborted();
2934
+ return next;
2794
2935
  }
2795
- if (this.#session === void 0) {
2796
- if (this.#client === void 0) throw new Error("An external eve session is required before sending.");
2797
- if (input.message === void 0) throw new Error("Cannot answer an input request before the session starts.");
2798
- const created = await this.#client.sessions.create({
2799
- ...input,
2800
- message: input.message
2936
+ case "input.requested": {
2937
+ let next = data;
2938
+ for (const request of event.data.requests) {
2939
+ const existing = findToolPart(next, request.action.callId);
2940
+ if (existing?.approval?.id === request.requestId || existing !== void 0 && isSettledToolPart(existing)) continue;
2941
+ const descriptor = normalizeActionRequest(request.action);
2942
+ next = updateAssistantMessage(next, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
2943
+ approval: { id: request.requestId },
2944
+ input: request.action.input,
2945
+ state: "approval-requested",
2946
+ stepIndex: event.data.stepIndex,
2947
+ toolCallId: request.action.callId,
2948
+ toolMetadata: createToolMetadata(descriptor, { inputRequest: toMessageInputRequest(request) }),
2949
+ toolName: descriptor.toolName,
2950
+ type: "dynamic-tool"
2951
+ }));
2952
+ }
2953
+ return next;
2954
+ }
2955
+ case "approval.candidate": return data;
2956
+ case "approval.settled": {
2957
+ const existing = findToolPartByApprovalId(data, event.data.requestId);
2958
+ if (existing === void 0) return data;
2959
+ if (event.data.outcome === "approved") {
2960
+ const approval = {
2961
+ approved: true,
2962
+ id: event.data.requestId,
2963
+ reason: void 0
2964
+ };
2965
+ return updateToolPart(data, existing.toolCallId, existing.state === "output-available" ? {
2966
+ ...existing,
2967
+ approval
2968
+ } : {
2969
+ ...toolPartIdentity(existing),
2970
+ approval,
2971
+ state: "approval-responded"
2972
+ });
2973
+ }
2974
+ if (existing.state === "output-available") return data;
2975
+ return updateToolPart(data, existing.toolCallId, {
2976
+ ...toolPartIdentity(existing),
2977
+ approval: {
2978
+ approved: false,
2979
+ id: event.data.requestId,
2980
+ reason: "Tool execution was cancelled."
2981
+ },
2982
+ state: "output-denied"
2801
2983
  });
2802
- input.signal?.throwIfAborted();
2803
- this.#session = created.session;
2804
- this.#callbacks.onSessionChange?.(created.session.state);
2805
- this.#publish();
2806
- return {
2807
- response: created.response,
2808
- reader: this.#ensureStream(streamOptions).subscribe(input.signal)
2984
+ }
2985
+ case "action.result": {
2986
+ const descriptor = normalizeActionResult(event.data.result);
2987
+ const existing = findToolPart(data, event.data.result.callId);
2988
+ const denied = event.data.status === "rejected" || event.data.error?.code === "TOOL_EXECUTION_DENIED";
2989
+ const failed = event.data.status === "failed" && !denied;
2990
+ const approvalId = existing?.approval?.id ?? event.data.result.callId;
2991
+ const toolMetadata = mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor));
2992
+ const resultPartBase = {
2993
+ input: existing?.input,
2994
+ stepIndex: event.data.stepIndex,
2995
+ toolCallId: event.data.result.callId,
2996
+ toolMetadata,
2997
+ toolName: existing?.toolName ?? descriptor.toolName,
2998
+ type: "dynamic-tool"
2999
+ };
3000
+ let nextPart;
3001
+ if (denied) nextPart = {
3002
+ ...resultPartBase,
3003
+ approval: {
3004
+ approved: false,
3005
+ id: approvalId,
3006
+ reason: event.data.error?.message
3007
+ },
3008
+ state: "output-denied"
3009
+ };
3010
+ else if (failed) nextPart = {
3011
+ ...resultPartBase,
3012
+ approval: approvedApproval(existing),
3013
+ errorText: event.data.error?.message ?? stringifyUnknown(event.data.result.output),
3014
+ state: "output-error"
3015
+ };
3016
+ else nextPart = {
3017
+ ...resultPartBase,
3018
+ approval: approvedApproval(existing),
3019
+ output: event.data.result.output,
3020
+ state: "output-available"
2809
3021
  };
3022
+ return upsertToolPart(data, event.data.turnId, event.data.stepIndex, nextPart);
2810
3023
  }
2811
- const reader = this.#ensureStream(streamOptions).subscribe(input.signal);
2812
- try {
2813
- if (input.inputResponses === void 0) {
2814
- const { message, ...options } = input;
2815
- return {
2816
- response: await this.#session.send(message, options),
2817
- reader
2818
- };
2819
- }
2820
- const { inputResponses, ...options } = input;
2821
- return {
2822
- response: await this.#session.respond(inputResponses, options),
2823
- reader
3024
+ case "action.partial": {
3025
+ const existing = findToolPart(data, event.data.result.callId);
3026
+ if (existing !== void 0 && isSettledToolPart(existing)) return data;
3027
+ const descriptor = normalizeActionResult(event.data.result);
3028
+ const nextPart = {
3029
+ approval: approvedApproval(existing),
3030
+ input: existing?.input,
3031
+ output: event.data.result.output,
3032
+ partial: true,
3033
+ state: "output-available",
3034
+ stepIndex: event.data.stepIndex,
3035
+ toolCallId: event.data.result.callId,
3036
+ toolMetadata: mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor)),
3037
+ toolName: existing?.toolName ?? descriptor.toolName,
3038
+ type: "dynamic-tool"
2824
3039
  };
2825
- } catch (error) {
2826
- reader[Symbol.dispose]();
2827
- throw error;
3040
+ return upsertToolPart(data, event.data.turnId, event.data.stepIndex, nextPart);
2828
3041
  }
2829
- }
2830
- #ensureStream(options = {}) {
2831
- if (this.#stream !== void 0 && !this.#stream.ended) {
2832
- this.#stream.setOptions(options);
2833
- return this.#stream;
3042
+ case "task.settled": {
3043
+ const existing = findToolPart(data, event.data.callId);
3044
+ if (existing === void 0) return data;
3045
+ return replaceToolPart(data, createSettledTaskPart(existing, event));
2834
3046
  }
2835
- if (this.#session === void 0) throw new Error("A session is required before opening its stream.");
2836
- const session = this.#session;
2837
- const generation = this.#prewarmGeneration;
2838
- this.#stream = new SessionEventStream(session, {
2839
- ...options,
2840
- onEvent: (event) => {
2841
- if (generation === this.#prewarmGeneration) this.#acceptServerEvent(event);
2842
- },
2843
- onError: (error) => {
2844
- if (generation !== this.#prewarmGeneration) return;
2845
- this.#stream = void 0;
2846
- if (this.#activeTurn !== void 0) return;
2847
- this.#error = toError(error);
2848
- this.#status = "error";
2849
- this.#callbacks.onError?.(this.#error);
2850
- this.#publish();
3047
+ case "authorization.required": return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), createAuthorizationRequiredPart(event)));
3048
+ case "authorization.completed": return completeAuthorization(data, event);
3049
+ case "message.appended": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.transition(ensureStepStartPart(message, event.data.stepIndex), {
3050
+ kind: "append",
3051
+ delta: event.data.messageDelta,
3052
+ id: event.meta?.id,
3053
+ stepIndex: event.data.stepIndex,
3054
+ type: "text"
3055
+ }));
3056
+ case "message.completed": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.transition(ensureStepStartPart(message, event.data.stepIndex), {
3057
+ kind: "complete",
3058
+ stepIndex: event.data.stepIndex,
3059
+ text: event.data.message,
3060
+ id: event.meta?.id,
3061
+ type: "text"
3062
+ }));
3063
+ case "result.completed": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3064
+ ...message,
3065
+ metadata: {
3066
+ ...message.metadata,
3067
+ result: event.data.result
2851
3068
  }
2852
- });
2853
- return this.#stream;
2854
- }
2855
- #resetPrewarm() {
2856
- this.#prewarmGeneration += 1;
2857
- this.#prewarmController?.abort();
2858
- this.#prewarmController = void 0;
2859
- this.#prewarmPromise = void 0;
2860
- }
2861
- #finishTurn(turn) {
2862
- if (!this.#isActiveTurn(turn)) return;
2863
- turn.resolveResponse(void 0);
2864
- this.#activeTurn = void 0;
2865
- try {
2866
- this.#callbacks.onSessionChange?.(this.#session?.state);
2867
- this.#publish();
2868
- this.#callbacks.onFinish?.(this.#snapshot);
2869
- } finally {
2870
- turn.resolveCompletion();
2871
- }
2872
- }
2873
- #isActiveTurn(turn) {
2874
- return this.#activeTurn === turn;
2875
- }
2876
- #projectInputResponses(input) {
2877
- if (input.inputResponses === void 0 || input.inputResponses.length === 0) return;
2878
- this.#projection.append({
2879
- data: {
2880
- createdAt: Date.now(),
2881
- responses: input.inputResponses
3069
+ }));
3070
+ case "turn.completed": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3071
+ ...message,
3072
+ metadata: {
3073
+ ...message.metadata,
3074
+ status: "complete"
2882
3075
  },
2883
- type: "client.input.responded"
2884
- });
2885
- }
2886
- #acceptServerEvent(event) {
2887
- if (!this.#seenEvents.admit(event)) return;
2888
- const wasStreaming = this.#status === "streaming";
2889
- updatePendingAuthorizations(this.#pendingAuthorizations, event);
2890
- this.#events = [...this.#events, event];
2891
- this.#handleReconciliation(this.#messageSubmissions.apply(event));
2892
- this.#callbacks.onEvent?.(event);
2893
- this.#applyTerminalStreamFailure(event);
2894
- const settled = isCurrentTurnBoundaryEvent(event) && this.#pendingAuthorizations.size === 0;
2895
- if (this.#status !== "resuming" && this.#error === void 0) {
2896
- if ("data" in event && "turnId" in event.data) this.#status = "streaming";
2897
- if (this.#activeTurn === void 0 && settled) this.#status = "ready";
2898
- }
2899
- this.#callbacks.onSessionChange?.(this.#session?.state);
2900
- if (this.#status !== "resuming") this.#publish();
2901
- if (this.#activeTurn === void 0 && wasStreaming && settled) this.#callbacks.onFinish?.(this.#snapshot);
2902
- }
2903
- #handleReconciliation(reconciliation) {
2904
- if (reconciliation === void 0) return false;
2905
- let followed = 0;
2906
- for (const id of reconciliation.ids) if (this.#activeTurn?.followUpSubmissionIds.delete(id)) followed += 1;
2907
- if (followed > 0 && this.#activeTurn !== void 0) {
2908
- if (reconciliation.alreadyProjected) this.#activeTurn.receivedFollowUps += followed;
2909
- else {
2910
- const previous = this.#activeTurn.receivedFollowUpEvents.get(reconciliation.event) ?? 0;
2911
- this.#activeTurn.receivedFollowUpEvents.set(reconciliation.event, previous + followed);
2912
- }
2913
- }
2914
- return true;
2915
- }
2916
- #applyTerminalStreamFailure(event) {
2917
- const error = toTerminalStreamFailureError(event);
2918
- if (error === void 0) return;
2919
- this.#status = "error";
2920
- this.#messageSubmissions.failAll(error);
2921
- if (this.#error === void 0) {
2922
- this.#error = error;
2923
- this.#callbacks.onError?.(error);
2924
- }
2925
- }
2926
- #createSnapshot() {
2927
- return {
2928
- data: this.#projection.data,
2929
- error: this.#error,
2930
- events: this.#events,
2931
- session: this.#session?.state,
2932
- status: this.#status
2933
- };
2934
- }
2935
- #publish() {
2936
- this.#snapshot = this.#createSnapshot();
2937
- for (const subscriber of this.#subscribers) subscriber();
3076
+ parts: removeStreamingToolParts(closeStreamingRuns(message.parts))
3077
+ }));
3078
+ case "turn.cancelled": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3079
+ ...message,
3080
+ metadata: {
3081
+ ...message.metadata,
3082
+ status: "complete"
3083
+ },
3084
+ parts: removeStreamingToolParts(closeStreamingRuns(message.parts))
3085
+ }));
3086
+ case "turn.failed":
3087
+ if (data.messages.find((message) => message.role === "assistant" && message.metadata?.turnId === event.data.turnId) === void 0) return data;
3088
+ return updateAssistantMessage(data, event.data.turnId, (message) => ({
3089
+ ...message,
3090
+ metadata: {
3091
+ ...message.metadata,
3092
+ status: "complete"
3093
+ },
3094
+ parts: removeStreamingToolParts(closeStreamingRuns(message.parts))
3095
+ }));
3096
+ case "session.failed": return data;
3097
+ default: return data;
2938
3098
  }
2939
- };
2940
- function detachEveAgentStore(store) {
2941
- store[detachStore]();
2942
3099
  }
2943
- function attachEveAgentStore(store) {
2944
- store[attachStore]();
3100
+ function closeStreamingRuns(parts, stepIndex) {
3101
+ return parts.map((part) => (part.type === "text" || part.type === "reasoning") && part.state === "streaming" && (stepIndex === void 0 || part.stepIndex === stepIndex) ? {
3102
+ ...part,
3103
+ state: "done"
3104
+ } : part);
2945
3105
  }
2946
-
2947
- //#endregion
2948
- //#region src/client/agent-host.ts
2949
- const AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
2950
- const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve";
2951
- function resolveEveAgentHost(input) {
2952
- if (input.agent === void 0) return input.host ?? "";
2953
- if (input.host !== void 0) throw new Error("useEveAgent cannot combine agent and host. Use one target option.");
2954
- assertValidAgentName(input.agent);
2955
- return `${EVE_NAMED_AGENT_ROUTE_PREFIX}/${input.agent}`;
3106
+ function removeStreamingToolParts(parts) {
3107
+ return parts.filter((part) => part.type !== "dynamic-tool" || part.state !== "input-streaming");
2956
3108
  }
2957
- function assertValidAgentName(name) {
2958
- if (!AGENT_NAME_PATTERN.test(name)) throw new Error(`eve agent name ${JSON.stringify(name)} is invalid. Use lowercase letters, numbers, underscores, or hyphens, starting with a letter or number.`);
3109
+ function respondToInputRequest(data, response) {
3110
+ const existing = findToolPartByApprovalId(data, response.requestId);
3111
+ if (!existing) return data;
3112
+ const approval = { id: response.requestId };
3113
+ if (response.text !== void 0) approval.reason = response.text;
3114
+ const toolMetadata = mergeToolMetadata(existing.toolMetadata, { eve: {
3115
+ inputResponse: response,
3116
+ kind: existing.toolMetadata?.eve?.kind ?? "unknown",
3117
+ name: existing.toolMetadata?.eve?.name ?? existing.toolName
3118
+ } });
3119
+ return updateToolPart(data, existing.toolCallId, existing.state === "output-available" ? {
3120
+ ...existing,
3121
+ approval: {
3122
+ ...approval,
3123
+ approved: true
3124
+ },
3125
+ toolMetadata
3126
+ } : {
3127
+ ...toolPartIdentity(existing),
3128
+ approval,
3129
+ state: "approval-responded",
3130
+ toolMetadata
3131
+ });
2959
3132
  }
2960
-
2961
- //#endregion
2962
- //#region src/client/authorization-message-parts.ts
2963
- function createAuthorizationRequiredPart(event) {
2964
- const displayName = event.data.authorization?.displayName ?? formatAuthorizationDisplayName(event.data.name);
3133
+ function resolveInputRequest(data, resolution) {
3134
+ if (resolution.response !== void 0) return findToolPartByApprovalId(data, resolution.requestId)?.approval?.approved === void 0 ? respondToInputRequest(data, resolution.response) : data;
3135
+ const existing = findToolPartByApprovalId(data, resolution.requestId);
3136
+ if (!existing) return data;
3137
+ return updateToolPart(data, existing.toolCallId, {
3138
+ ...toolPartIdentity(existing),
3139
+ output: { status: resolution.outcome },
3140
+ state: "output-available"
3141
+ });
3142
+ }
3143
+ function toolPartIdentity(part) {
2965
3144
  return {
2966
- authorization: event.data.authorization,
2967
- description: normalizeAuthorizationDescription(event.data.description, event.data.name, displayName),
2968
- displayName,
2969
- name: event.data.name,
2970
- state: "required",
2971
- stepIndex: event.data.stepIndex,
2972
- turnId: event.data.turnId,
2973
- type: "authorization"
3145
+ input: part.input,
3146
+ stepIndex: part.stepIndex,
3147
+ toolCallId: part.toolCallId,
3148
+ toolMetadata: part.toolMetadata,
3149
+ toolName: part.toolName,
3150
+ type: part.type
2974
3151
  };
2975
3152
  }
2976
- function createAuthorizationCompletedPart(event, existing) {
2977
- const displayName = event.data.authorization?.displayName ?? existing?.displayName ?? formatAuthorizationDisplayName(event.data.name);
3153
+ function updateAssistantMessage(data, turnId, update) {
3154
+ const message = data.messages.find((message) => message.role === "assistant" && message.metadata?.turnId === turnId) ?? createAssistantMessage(turnId);
3155
+ return upsertMessage(data, update(message));
3156
+ }
3157
+ function createAssistantMessage(turnId) {
2978
3158
  return {
2979
- authorization: existing?.authorization || event.data.authorization ? {
2980
- ...existing?.authorization,
2981
- ...event.data.authorization
2982
- } : void 0,
2983
- description: existing?.description ?? buildCompletedAuthorizationDescription(displayName, event.data.outcome, event.data.reason),
2984
- displayName,
2985
- name: event.data.name,
2986
- outcome: event.data.outcome,
2987
- reason: event.data.reason,
2988
- state: "completed",
2989
- stepIndex: existing?.stepIndex ?? event.data.stepIndex,
2990
- turnId: existing?.turnId ?? event.data.turnId,
2991
- type: "authorization"
3159
+ id: `${turnId}:assistant`,
3160
+ metadata: {
3161
+ status: "streaming",
3162
+ turnId
3163
+ },
3164
+ parts: [],
3165
+ role: "assistant"
3166
+ };
3167
+ }
3168
+ function ensureStepStartPart(message, stepIndex) {
3169
+ const stepStartCount = message.parts.filter((part) => part.type === "step-start").length;
3170
+ if (stepStartCount > stepIndex) return message;
3171
+ const missingCount = stepIndex - stepStartCount + 1;
3172
+ return {
3173
+ ...message,
3174
+ parts: [...message.parts, ...Array.from({ length: missingCount }, () => ({ type: "step-start" }))]
3175
+ };
3176
+ }
3177
+ function upsertPart(message, next) {
3178
+ const index = message.parts.findIndex((part) => partKey(part) === partKey(next));
3179
+ const parts = index === -1 ? [...message.parts, next] : [
3180
+ ...message.parts.slice(0, index),
3181
+ next,
3182
+ ...message.parts.slice(index + 1)
3183
+ ];
3184
+ return {
3185
+ ...message,
3186
+ metadata: {
3187
+ ...message.metadata,
3188
+ status: next.type === "text" && next.state === "done" ? "complete" : "streaming"
3189
+ },
3190
+ parts
2992
3191
  };
2993
3192
  }
2994
- function buildCompletedAuthorizationDescription(displayName, outcome, reason) {
2995
- if (outcome === "authorized") return `${displayName} connected.`;
2996
- return `${displayName} authorization ${outcome}${reason !== void 0 ? ` (${reason})` : ""}.`;
3193
+ function upsertToolPart(data, turnId, stepIndex, part) {
3194
+ const updated = updateToolPart(data, part.toolCallId, part);
3195
+ return updated !== data ? updated : updateAssistantMessage(data, turnId, (message) => upsertPart(ensureStepStartPart(message, stepIndex), part));
3196
+ }
3197
+ function updateToolPart(data, toolCallId, next) {
3198
+ const message = data.messages.find((candidate) => candidate.role === "assistant" && candidate.parts.some((part) => part.type === "dynamic-tool" && part.toolCallId === toolCallId));
3199
+ if (!message) return data;
3200
+ return upsertMessage(data, upsertPart(message, next));
3201
+ }
3202
+ function replaceToolPart(data, next) {
3203
+ const message = data.messages.find((candidate) => candidate.parts.some((part) => part.type === "dynamic-tool" && part.toolCallId === next.toolCallId));
3204
+ if (message === void 0) return data;
3205
+ return upsertMessage(data, {
3206
+ ...message,
3207
+ parts: message.parts.map((part) => partKey(part) === partKey(next) ? next : part)
3208
+ });
3209
+ }
3210
+ function completeAuthorization(data, event) {
3211
+ const existing = findPendingAuthorizationPart(data, event.data.name, event.data.attemptId);
3212
+ const next = createAuthorizationCompletedPart(event, existing);
3213
+ return updateAssistantMessage(data, existing?.turnId ?? event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, next.stepIndex), next));
2997
3214
  }
2998
- function normalizeAuthorizationDescription(description, name, displayName) {
2999
- if (description === `Authorization required for ${name}`) return `Authorization required for ${displayName}`;
3000
- return description;
3215
+ function findToolPart(data, toolCallId) {
3216
+ for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.toolCallId === toolCallId) return part;
3001
3217
  }
3002
- function formatAuthorizationDisplayName(name) {
3003
- if (name.length === 0) return name;
3004
- return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
3218
+ function isSettledToolPart(part) {
3219
+ return part.state === "output-denied" || part.state === "output-error" || part.state === "output-available" && part.partial !== true;
3220
+ }
3221
+ function findPendingAuthorizationPart(data, name, attemptId) {
3222
+ for (let messageIndex = data.messages.length - 1; messageIndex >= 0; messageIndex -= 1) {
3223
+ const message = data.messages[messageIndex];
3224
+ if (message?.role !== "assistant") continue;
3225
+ for (let partIndex = message.parts.length - 1; partIndex >= 0; partIndex -= 1) {
3226
+ const part = message.parts[partIndex];
3227
+ if (part?.type === "authorization" && part.state === "required" && (attemptId === void 0 ? part.attemptId === void 0 && part.name === name : part.attemptId === attemptId)) return part;
3228
+ }
3229
+ }
3230
+ }
3231
+ function findToolPartByApprovalId(data, approvalId) {
3232
+ for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.approval?.id === approvalId) return part;
3005
3233
  }
3006
3234
 
3007
3235
  //#endregion
3008
- //#region src/client/message-action-parts.ts
3009
- function toMessageInputRequest(request) {
3236
+ //#region src/client/conversation-reducer.ts
3237
+ function initialConversationState() {
3010
3238
  return {
3011
- allowFreeform: request.allowFreeform,
3012
- display: request.display,
3013
- kind: request.kind,
3014
- options: request.options,
3015
- prompt: request.prompt,
3016
- requestId: request.requestId
3239
+ messages: [],
3240
+ turns: {},
3241
+ inputs: {},
3242
+ tasks: {},
3243
+ agents: {}
3017
3244
  };
3018
3245
  }
3019
- function createToolMetadata(descriptor, extra) {
3020
- return { eve: {
3021
- inputRequest: extra?.inputRequest,
3022
- kind: descriptor.kind,
3023
- name: descriptor.name
3024
- } };
3246
+ function updateTurn(state, turnId, update) {
3247
+ const turn = state.turns[turnId];
3248
+ if (turn === void 0) return state;
3249
+ const next = update(turn);
3250
+ return next === turn ? state : {
3251
+ ...state,
3252
+ turns: {
3253
+ ...state.turns,
3254
+ [turnId]: next
3255
+ }
3256
+ };
3025
3257
  }
3026
- function mergeToolMetadata(current, next) {
3027
- const kind = next.eve?.kind ?? current?.eve?.kind ?? "unknown";
3028
- const name = next.eve?.name ?? current?.eve?.name ?? "unknown";
3029
- return { eve: {
3030
- ...current?.eve,
3031
- ...next.eve,
3032
- inputRequest: next.eve?.inputRequest ?? current?.eve?.inputRequest,
3033
- inputResponse: next.eve?.inputResponse ?? current?.eve?.inputResponse,
3034
- kind,
3035
- name
3036
- } };
3258
+ function updateTask(state, taskId, update) {
3259
+ const task = state.tasks[taskId];
3260
+ if (task === void 0) return state;
3261
+ const next = update(task);
3262
+ return next === task ? state : {
3263
+ ...state,
3264
+ tasks: {
3265
+ ...state.tasks,
3266
+ [taskId]: next
3267
+ }
3268
+ };
3037
3269
  }
3038
- function approvedApproval(part) {
3039
- if (!part?.approval?.id) return;
3270
+ function updateObservation(state, sessionId, update) {
3271
+ const agent = state.agents[sessionId];
3272
+ if (agent === void 0) return state;
3273
+ const observation = update(agent.observation);
3274
+ if (observation === agent.observation) return state;
3040
3275
  return {
3041
- approved: true,
3042
- id: part.approval.id,
3043
- isAutomatic: part.approval.isAutomatic,
3044
- reason: part.approval.reason
3276
+ ...state,
3277
+ agents: {
3278
+ ...state.agents,
3279
+ [sessionId]: {
3280
+ ...agent,
3281
+ observation
3282
+ }
3283
+ }
3045
3284
  };
3046
3285
  }
3047
- function normalizeActionRequest(action) {
3048
- switch (action.kind) {
3049
- case "load-skill": return {
3050
- kind: "load-skill",
3051
- name: "load_skill",
3052
- toolName: "eve:load-skill"
3053
- };
3054
- case "tool-call":
3055
- case "workflow-tool-call": return {
3056
- kind: "tool-call",
3057
- name: action.toolName,
3058
- toolName: action.toolName
3059
- };
3060
- case "subagent-call": return {
3061
- kind: "subagent-call",
3062
- name: action.subagentName,
3063
- toolName: `eve:subagent:${action.subagentName}`
3286
+ function observedConversation(observation) {
3287
+ return observation.status === "not-followed" ? void 0 : observation.conversation;
3288
+ }
3289
+ function reduceConversationLifecycle(state, event) {
3290
+ switch (event.type) {
3291
+ case "turn.started": return {
3292
+ ...state,
3293
+ activeTurnId: event.data.turnId,
3294
+ turns: {
3295
+ ...state.turns,
3296
+ [event.data.turnId]: {
3297
+ turnId: event.data.turnId,
3298
+ status: "active"
3299
+ }
3300
+ }
3064
3301
  };
3065
- case "remote-agent-call": return {
3066
- kind: "subagent-call",
3067
- name: action.remoteAgentName,
3068
- toolName: `eve:subagent:${action.remoteAgentName}`
3302
+ case "turn.waiting": return updateTurn(state, event.data.turnId, (turn) => turn.status === "active" && !turn.waiting ? {
3303
+ ...turn,
3304
+ waiting: true
3305
+ } : turn);
3306
+ case "step.started": return updateTurn(state, event.data.turnId, (turn) => turn.waiting ? {
3307
+ turnId: turn.turnId,
3308
+ status: turn.status
3309
+ } : turn);
3310
+ case "turn.completed":
3311
+ case "turn.cancelled":
3312
+ case "turn.failed": {
3313
+ const { turnId } = event.data;
3314
+ return {
3315
+ ...state,
3316
+ activeTurnId: state.activeTurnId === turnId ? void 0 : state.activeTurnId,
3317
+ turns: {
3318
+ ...state.turns,
3319
+ [turnId]: {
3320
+ turnId,
3321
+ status: event.type === "turn.completed" ? "completed" : event.type === "turn.failed" ? "failed" : "cancelled"
3322
+ }
3323
+ }
3324
+ };
3325
+ }
3326
+ case "session.waiting":
3327
+ case "session.completed":
3328
+ case "session.failed": return state.activeTurnId === void 0 ? state : {
3329
+ ...state,
3330
+ activeTurnId: void 0
3069
3331
  };
3332
+ case "task.started": {
3333
+ const { callId, kind, name, taskId, turnId } = event.data;
3334
+ const task = state.tasks[taskId] ?? {
3335
+ taskId,
3336
+ name,
3337
+ kind,
3338
+ calls: {}
3339
+ };
3340
+ if (task.calls[callId] !== void 0) return state;
3341
+ return {
3342
+ ...state,
3343
+ tasks: {
3344
+ ...state.tasks,
3345
+ [taskId]: {
3346
+ ...task,
3347
+ calls: {
3348
+ ...task.calls,
3349
+ [callId]: {
3350
+ callId,
3351
+ turnId,
3352
+ status: "working"
3353
+ }
3354
+ }
3355
+ }
3356
+ }
3357
+ };
3358
+ }
3359
+ case "task.settled": {
3360
+ const { callId, error, output, status, taskId } = event.data;
3361
+ return updateTask(state, taskId, (task) => {
3362
+ const call = task.calls[callId];
3363
+ if (call === void 0 || call.status !== "working") return task;
3364
+ const settled = {
3365
+ callId,
3366
+ turnId: call.turnId,
3367
+ status
3368
+ };
3369
+ return {
3370
+ ...task,
3371
+ calls: {
3372
+ ...task.calls,
3373
+ [callId]: status === "completed" && output !== void 0 ? {
3374
+ ...settled,
3375
+ output
3376
+ } : status === "failed" && error !== void 0 ? {
3377
+ ...settled,
3378
+ error
3379
+ } : settled
3380
+ }
3381
+ };
3382
+ });
3383
+ }
3384
+ case "agent.started": {
3385
+ const { callId, name, sessionId, taskId, turnId } = event.data;
3386
+ if (state.agents[sessionId] !== void 0) return state;
3387
+ const agent = {
3388
+ sessionId,
3389
+ name,
3390
+ callId,
3391
+ turnId,
3392
+ observation: { status: "not-followed" }
3393
+ };
3394
+ if (taskId !== void 0) agent.taskId = taskId;
3395
+ return {
3396
+ ...state,
3397
+ agents: {
3398
+ ...state.agents,
3399
+ [sessionId]: agent
3400
+ }
3401
+ };
3402
+ }
3403
+ case "input.requested": {
3404
+ const inputs = { ...state.inputs };
3405
+ for (const request of event.data.requests) {
3406
+ if (inputs[request.requestId] !== void 0) continue;
3407
+ const input = {
3408
+ request,
3409
+ turnId: event.data.turnId,
3410
+ stepIndex: event.data.stepIndex,
3411
+ status: "open"
3412
+ };
3413
+ if (event.data.taskId !== void 0) input.taskId = event.data.taskId;
3414
+ inputs[request.requestId] = input;
3415
+ }
3416
+ return {
3417
+ ...state,
3418
+ inputs
3419
+ };
3420
+ }
3421
+ case "client.input.responded": {
3422
+ const inputs = { ...state.inputs };
3423
+ for (const response of event.data.responses) {
3424
+ const current = inputs[response.requestId];
3425
+ if (current?.status !== "open") continue;
3426
+ inputs[response.requestId] = {
3427
+ ...current,
3428
+ response,
3429
+ status: "responded"
3430
+ };
3431
+ }
3432
+ return {
3433
+ ...state,
3434
+ inputs
3435
+ };
3436
+ }
3437
+ case "approval.candidate": {
3438
+ const current = state.inputs[event.data.requestId];
3439
+ if (current === void 0 || current.status === "settled") return state;
3440
+ if (event.data.outcome === "pending") return state;
3441
+ return {
3442
+ ...state,
3443
+ inputs: {
3444
+ ...state.inputs,
3445
+ [event.data.requestId]: {
3446
+ ...current,
3447
+ status: "open",
3448
+ response: void 0
3449
+ }
3450
+ }
3451
+ };
3452
+ }
3453
+ case "approval.settled": {
3454
+ const current = state.inputs[event.data.requestId];
3455
+ if (current === void 0 || current.status === "settled") return state;
3456
+ return {
3457
+ ...state,
3458
+ inputs: {
3459
+ ...state.inputs,
3460
+ [event.data.requestId]: {
3461
+ ...current,
3462
+ status: "settled",
3463
+ outcome: event.data.outcome
3464
+ }
3465
+ }
3466
+ };
3467
+ }
3468
+ case "input.resolved": {
3469
+ const inputs = { ...state.inputs };
3470
+ for (const resolution of event.data.resolutions) {
3471
+ const current = inputs[resolution.requestId];
3472
+ if (current === void 0 || current.status === "settled") continue;
3473
+ inputs[resolution.requestId] = {
3474
+ ...current,
3475
+ status: "settled",
3476
+ outcome: resolution.outcome,
3477
+ response: resolution.response ?? current.response
3478
+ };
3479
+ }
3480
+ return {
3481
+ ...state,
3482
+ inputs
3483
+ };
3484
+ }
3485
+ default: return state;
3070
3486
  }
3071
3487
  }
3072
- function normalizeActionResult(result) {
3073
- switch (result.kind) {
3074
- case "load-skill-result": return {
3075
- kind: "load-skill",
3076
- name: result.name ?? "load_skill",
3077
- toolName: "eve:load-skill"
3078
- };
3079
- case "tool-result": return {
3080
- kind: "tool-call",
3081
- name: result.toolName,
3082
- toolName: result.toolName
3083
- };
3084
- case "subagent-result": return {
3085
- kind: "subagent-call",
3086
- name: result.subagentName,
3087
- toolName: `eve:subagent:${result.subagentName}`
3488
+ const messageReducer = defaultMessageReducer();
3489
+ function reduceConversation(state, event) {
3490
+ switch (event.type) {
3491
+ case "client.agent.following": return updateObservation(state, event.data.sessionId, (observation) => observation.status === "following" ? observation : {
3492
+ status: "following",
3493
+ conversation: observedConversation(observation) ?? initialConversationState()
3494
+ });
3495
+ case "client.agent.observed": return updateObservation(state, event.data.sessionId, (observation) => observation.status === "following" ? {
3496
+ status: "following",
3497
+ conversation: reduceConversation(observation.conversation, event.data.event)
3498
+ } : observation);
3499
+ case "client.agent.idle": return updateObservation(state, event.data.sessionId, (observation) => observation.status === "following" ? {
3500
+ status: "idle",
3501
+ conversation: observation.conversation
3502
+ } : observation);
3503
+ case "client.agent.unavailable": return updateObservation(state, event.data.sessionId, (observation) => {
3504
+ const conversation = observedConversation(observation);
3505
+ return conversation === void 0 ? { status: "unavailable" } : {
3506
+ status: "unavailable",
3507
+ conversation
3508
+ };
3509
+ });
3510
+ default: {
3511
+ const projected = messageReducer.reduce(state, event);
3512
+ return reduceConversationLifecycle({
3513
+ ...state,
3514
+ ...projected
3515
+ }, event);
3516
+ }
3517
+ }
3518
+ }
3519
+ const canonicalConversationReducer = {
3520
+ initial: initialConversationState,
3521
+ reduce: reduceConversation
3522
+ };
3523
+ const conversationReducer = canonicalConversationReducer;
3524
+
3525
+ //#endregion
3526
+ //#region src/protocol/event-dedupe.ts
3527
+ function createEventDeduper() {
3528
+ const seen = /* @__PURE__ */ new Set();
3529
+ return {
3530
+ admit(event) {
3531
+ const id = event.meta?.id;
3532
+ if (id === void 0) return true;
3533
+ if (seen.has(id)) return false;
3534
+ seen.add(id);
3535
+ return true;
3536
+ },
3537
+ get size() {
3538
+ return seen.size;
3539
+ }
3540
+ };
3541
+ }
3542
+
3543
+ //#endregion
3544
+ //#region src/client/session-event-stream.ts
3545
+ var SessionEventStream = class {
3546
+ #controller = new AbortController();
3547
+ #readers = /* @__PURE__ */ new Set();
3548
+ #caughtUp = Promise.withResolvers();
3549
+ caughtUp = this.#caughtUp.promise;
3550
+ #ended = false;
3551
+ #error;
3552
+ #headers;
3553
+ #reconnectPolicy;
3554
+ constructor(session, options) {
3555
+ this.setOptions(options);
3556
+ this.caughtUp.catch(() => {});
3557
+ if (!options.catchUp) this.#caughtUp.resolve();
3558
+ (async () => {
3559
+ try {
3560
+ for await (const event of followClientSession(session, {
3561
+ signal: this.#controller.signal,
3562
+ resolveHeaders: () => this.#headers,
3563
+ resolveReconnectPolicy: () => this.#reconnectPolicy,
3564
+ startIndex: options.startIndex,
3565
+ onCaughtUp: options.catchUp ? () => this.#caughtUp.resolve() : void 0
3566
+ })) {
3567
+ if (this.#controller.signal.aborted) return;
3568
+ options.onEvent(event);
3569
+ for (const reader of this.#readers) reader.push(event);
3570
+ if (event.type === "session.completed" || event.type === "session.failed") break;
3571
+ }
3572
+ this.#caughtUp.resolve();
3573
+ this.#finish();
3574
+ } catch (error) {
3575
+ this.#caughtUp.reject(error);
3576
+ this.#finish(error);
3577
+ if (!this.#controller.signal.aborted) options.onError(error);
3578
+ }
3579
+ })();
3580
+ }
3581
+ subscribe(signal) {
3582
+ const reader = new SessionEventReader(() => this.#readers.delete(reader), signal);
3583
+ if (this.#ended) reader.end(this.#error);
3584
+ else this.#readers.add(reader);
3585
+ return reader;
3586
+ }
3587
+ get ended() {
3588
+ return this.#ended;
3589
+ }
3590
+ setOptions(options) {
3591
+ if ("headers" in options) this.#headers = options.headers;
3592
+ if ("streamReconnectPolicy" in options) this.#reconnectPolicy = options.streamReconnectPolicy;
3593
+ }
3594
+ close() {
3595
+ const error = new DOMException("Session stream was detached.", "AbortError");
3596
+ this.#controller.abort(error);
3597
+ this.#caughtUp.reject(error);
3598
+ this.#finish(error);
3599
+ }
3600
+ #finish(error) {
3601
+ if (this.#ended) return;
3602
+ this.#ended = true;
3603
+ this.#error = error;
3604
+ for (const reader of this.#readers) reader.end(error);
3605
+ }
3606
+ };
3607
+ var SessionEventReader = class {
3608
+ #events = [];
3609
+ #wake = Promise.withResolvers();
3610
+ #ended = false;
3611
+ #error;
3612
+ #dispose;
3613
+ constructor(unsubscribe, signal) {
3614
+ const abort = () => this.end(signal?.reason);
3615
+ signal?.addEventListener("abort", abort, { once: true });
3616
+ this.#dispose = () => {
3617
+ signal?.removeEventListener("abort", abort);
3618
+ unsubscribe();
3088
3619
  };
3620
+ if (signal?.aborted) abort();
3621
+ }
3622
+ push(event) {
3623
+ if (this.#ended) return;
3624
+ this.#events.push(event);
3625
+ this.#wake.resolve();
3626
+ }
3627
+ end(error) {
3628
+ if (this.#ended) return;
3629
+ this.#ended = true;
3630
+ this.#error = error;
3631
+ this.#wake.resolve();
3089
3632
  }
3090
- }
3091
- function stringifyUnknown(value) {
3092
- if (typeof value === "string") return value;
3093
- try {
3094
- return JSON.stringify(value);
3095
- } catch {
3096
- return "Action failed.";
3633
+ [Symbol.dispose]() {
3634
+ this.end();
3635
+ this.#events = [];
3636
+ this.#dispose();
3097
3637
  }
3098
- }
3099
-
3100
- //#endregion
3101
- //#region src/client/message-reducer-primitives.ts
3102
- function projectReceivedParts(parts, message) {
3103
- return parts?.map((part) => part.type === "text" ? {
3104
- state: "done",
3105
- text: part.text,
3106
- type: "text"
3107
- } : {
3108
- filename: part.filename,
3109
- mediaType: part.mediaType,
3110
- size: part.size,
3111
- type: "file",
3112
- url: part.url
3113
- }) ?? [{
3114
- state: "done",
3115
- text: message,
3116
- type: "text"
3117
- }];
3118
- }
3119
- function partKey(part) {
3120
- switch (part.type) {
3121
- case "text": return `text:${part.stepIndex ?? 0}`;
3122
- case "reasoning": return `reasoning:${part.stepIndex ?? 0}`;
3123
- case "file": return `file:${part.stepIndex ?? 0}:${part.filename ?? part.url ?? part.mediaType}`;
3124
- case "step-start": return "step-start";
3125
- case "authorization": return `authorization:${part.turnId}:${part.stepIndex}:${part.name}`;
3126
- case "dynamic-tool": return `dynamic-tool:${part.toolCallId}`;
3638
+ discard() {
3639
+ this.#events = [];
3127
3640
  }
3128
- }
3129
- function upsertMessage(data, next) {
3130
- const index = data.messages.findIndex((message) => message.id === next.id);
3131
- if (index === -1) return { messages: [...data.messages, next] };
3132
- return { messages: [
3133
- ...data.messages.slice(0, index),
3134
- next,
3135
- ...data.messages.slice(index + 1)
3136
- ] };
3137
- }
3138
- function removeStreamingToolPartsForTurn(data, turnId) {
3139
- const index = data.messages.findIndex((message) => message.role === "assistant" && message.metadata?.turnId === turnId);
3140
- const message = data.messages[index];
3141
- if (message === void 0) return data;
3142
- return upsertMessage(data, {
3143
- ...message,
3144
- parts: message.parts.filter((part) => part.type !== "dynamic-tool" || part.state !== "input-streaming")
3145
- });
3146
- }
3147
- function optimisticUserMessageId(submissionId) {
3148
- return `optimistic:${submissionId}:user`;
3149
- }
3641
+ async *[Symbol.asyncIterator]() {
3642
+ for (;;) {
3643
+ while (this.#events.length > 0) yield this.#events.shift();
3644
+ if (this.#ended) {
3645
+ if (this.#error !== void 0) throw this.#error;
3646
+ return;
3647
+ }
3648
+ this.#wake = Promise.withResolvers();
3649
+ await this.#wake.promise;
3650
+ }
3651
+ }
3652
+ };
3150
3653
 
3151
3654
  //#endregion
3152
- //#region src/client/message-run-parts.ts
3153
- function append(message, append) {
3154
- const current = latestStreamingRun(message, append.type, append.stepIndex);
3155
- return upsert(message, {
3156
- state: "streaming",
3157
- stepIndex: append.stepIndex,
3158
- text: (current?.text ?? "") + append.delta,
3159
- type: append.type
3160
- });
3161
- }
3162
- function latestStreamingRun(message, type, stepIndex) {
3163
- for (let index = message.parts.length - 1; index >= 0; index -= 1) {
3164
- const part = message.parts[index];
3165
- if (part?.type === type && part.stepIndex === stepIndex) return part.state === "streaming" ? part : void 0;
3655
+ //#region src/client/conversation-client.ts
3656
+ var ConversationClient = class {
3657
+ projection;
3658
+ #conversation;
3659
+ #cursors = /* @__PURE__ */ new Map();
3660
+ #seenEvents = createEventDeduper();
3661
+ #follower;
3662
+ #stream;
3663
+ #onChange;
3664
+ #onConversationChange;
3665
+ constructor(projection, onChange, onConversationChange) {
3666
+ this.projection = projection;
3667
+ this.#conversation = projection.reducer === conversationReducer ? projection : new EveAgentProjection(canonicalConversationReducer, []);
3668
+ this.#onChange = onChange;
3669
+ this.#onConversationChange = onConversationChange;
3166
3670
  }
3167
- }
3168
- function upsert(message, next) {
3169
- let lastIndex = -1;
3170
- for (let index = message.parts.length - 1; index >= 0; index -= 1) {
3171
- const part = message.parts[index];
3172
- if (part?.type === next.type && part.stepIndex === next.stepIndex) {
3173
- lastIndex = index;
3174
- break;
3671
+ get data() {
3672
+ return this.projection.data;
3673
+ }
3674
+ get conversation() {
3675
+ return this.#conversation.data;
3676
+ }
3677
+ get projections() {
3678
+ return this.#conversation === this.projection ? [this.projection] : [this.#conversation, this.projection];
3679
+ }
3680
+ get following() {
3681
+ return this.#follower !== void 0;
3682
+ }
3683
+ append(event) {
3684
+ const previous = this.data;
3685
+ const previousConversation = this.conversation;
3686
+ this.#appendRoot(event);
3687
+ if (previous !== this.data) this.#onChange(this.data, previous);
3688
+ else if (previousConversation !== this.conversation) this.#onConversationChange?.(this.conversation, previousConversation);
3689
+ }
3690
+ projectResponses(responses) {
3691
+ if (!responses?.length) return void 0;
3692
+ const event = {
3693
+ data: {
3694
+ createdAt: Date.now(),
3695
+ responses
3696
+ },
3697
+ type: "client.input.responded"
3698
+ };
3699
+ this.append(event);
3700
+ return () => this.#retract(event);
3701
+ }
3702
+ replaceResponses(retract, input) {
3703
+ retract?.();
3704
+ assertAnswerable(input, this.conversation);
3705
+ return this.projectResponses(input.inputResponses);
3706
+ }
3707
+ #retract(event) {
3708
+ const previous = this.data;
3709
+ const previousConversation = this.conversation;
3710
+ for (const projection of this.projections) projection.remove((entry) => entry === event);
3711
+ if (previous !== this.data) this.#onChange(this.data, previous);
3712
+ else if (previousConversation !== this.conversation) this.#onConversationChange?.(this.conversation, previousConversation);
3713
+ }
3714
+ observe(event, options = {}) {
3715
+ if (!this.#seenEvents.admit(event)) return false;
3716
+ options.onAccepted?.(event);
3717
+ const previous = this.data;
3718
+ const previousConversation = this.conversation;
3719
+ if (options.project) options.project(event);
3720
+ else this.#appendRoot(event);
3721
+ if (options.notify !== false) {
3722
+ if (previous !== this.data) this.#onChange(this.data, previous);
3723
+ else if (previousConversation !== this.conversation) this.#onConversationChange?.(this.conversation, previousConversation);
3175
3724
  }
3725
+ this.#follower?.acceptParentEvent(event);
3726
+ this.#follower?.reconcile();
3727
+ return true;
3728
+ }
3729
+ hydrate(event) {
3730
+ if (!this.#seenEvents.admit(event)) return false;
3731
+ this.#appendRoot(event);
3732
+ return true;
3733
+ }
3734
+ follow(session, events = []) {
3735
+ this.#follower?.abortAll();
3736
+ const follower = new AgentStreamFollower({
3737
+ session,
3738
+ cursors: this.#cursors,
3739
+ getState: () => this.conversation,
3740
+ onFollowing: (sessionId) => this.#appendChild({
3741
+ type: "client.agent.following",
3742
+ data: { sessionId }
3743
+ }),
3744
+ onEvent: (sessionId, event) => this.#appendChild({
3745
+ type: "client.agent.observed",
3746
+ data: {
3747
+ sessionId,
3748
+ event
3749
+ }
3750
+ }),
3751
+ onIdle: (sessionId) => this.#appendChild({
3752
+ type: "client.agent.idle",
3753
+ data: { sessionId }
3754
+ }),
3755
+ onUnavailable: (sessionId) => this.#appendChild({
3756
+ type: "client.agent.unavailable",
3757
+ data: { sessionId }
3758
+ })
3759
+ });
3760
+ this.#follower = follower;
3761
+ for (const event of events) follower.acceptParentEvent(event);
3762
+ follower.reconcile();
3763
+ }
3764
+ #appendRoot(event) {
3765
+ for (const projection of this.projections) projection.append(event);
3766
+ }
3767
+ #appendChild(event) {
3768
+ const previous = this.data;
3769
+ const previousConversation = this.conversation;
3770
+ this.#conversation.append(event);
3771
+ if (previous !== this.data) this.#onChange(this.data, previous);
3772
+ else if (previousConversation !== this.conversation) this.#onConversationChange?.(this.conversation, previousConversation);
3773
+ }
3774
+ stream(session, options) {
3775
+ if (this.#stream !== void 0 && !this.#stream.ended) {
3776
+ this.#stream.setOptions(options);
3777
+ return this.#stream;
3778
+ }
3779
+ this.#stream = new SessionEventStream(session, options);
3780
+ return this.#stream;
3781
+ }
3782
+ stop() {
3783
+ this.#follower?.abortAll();
3784
+ this.#follower = void 0;
3785
+ this.#stream?.close();
3786
+ this.#stream = void 0;
3787
+ }
3788
+ reset() {
3789
+ this.stop();
3790
+ this.#cursors.clear();
3791
+ this.#seenEvents = createEventDeduper();
3792
+ for (const projection of this.projections) projection.reset();
3176
3793
  }
3177
- const parts = lastIndex !== -1 && message.parts[lastIndex].state === "streaming" ? [
3178
- ...message.parts.slice(0, lastIndex),
3179
- next,
3180
- ...message.parts.slice(lastIndex + 1)
3181
- ] : [...message.parts, next];
3182
- return {
3183
- ...message,
3184
- metadata: {
3185
- ...message.metadata,
3186
- status: next.type === "text" && next.state === "done" ? "complete" : "streaming"
3187
- },
3188
- parts
3189
- };
3190
- }
3191
- const messageRun = {
3192
- append,
3193
- upsert
3194
3794
  };
3195
3795
 
3196
3796
  //#endregion
3197
- //#region src/client/message-reducer.ts
3198
- function receivedMessageEventId(event) {
3199
- return event.meta.id ?? `${event.data.turnId}:${event.data.sequence}`;
3200
- }
3201
- function defaultMessageReducer() {
3797
+ //#region src/client/session-turn-dispatch.ts
3798
+ async function dispatchSessionTurn(input) {
3799
+ const { client, session, turn, beforeSend } = input;
3800
+ if (session === void 0) {
3801
+ if (client === void 0) throw new Error("An external eve session is required before sending.");
3802
+ if (turn.message === void 0) throw new Error("Cannot answer an input request before the session starts.");
3803
+ const created = await client.sessions.create({
3804
+ ...turn,
3805
+ message: turn.message
3806
+ });
3807
+ turn.signal?.throwIfAborted();
3808
+ return {
3809
+ ...created,
3810
+ created: true
3811
+ };
3812
+ }
3813
+ beforeSend?.();
3814
+ if (turn.inputResponses === void 0) {
3815
+ const { message, ...options } = turn;
3816
+ return {
3817
+ session,
3818
+ response: await session.send(message, options),
3819
+ created: false
3820
+ };
3821
+ }
3822
+ const { inputResponses, ...options } = turn;
3202
3823
  return {
3203
- initial() {
3204
- return { messages: [] };
3205
- },
3206
- reduce(data, event) {
3207
- return reduceMessageData(data, event);
3208
- }
3824
+ session,
3825
+ response: await session.respond(inputResponses, options),
3826
+ created: false
3209
3827
  };
3210
3828
  }
3211
- function reduceMessageData(data, event) {
3212
- switch (event.type) {
3213
- case "client.message.submitted": return upsertMessage(data, {
3214
- id: optimisticUserMessageId(event.data.submissionId),
3215
- metadata: {
3216
- optimistic: true,
3217
- status: "submitted"
3218
- },
3219
- parts: [{
3220
- type: "text",
3221
- text: event.data.message
3222
- }],
3223
- role: "user"
3829
+
3830
+ //#endregion
3831
+ //#region src/client/eve-agent-store.ts
3832
+ const detachStore = Symbol("detachEveAgentStore");
3833
+ const attachStore = Symbol("attachEveAgentStore");
3834
+ var EveAgentStore = class {
3835
+ #client;
3836
+ #autoPrewarm;
3837
+ #attached = false;
3838
+ #conversationClient;
3839
+ #followChildStreams;
3840
+ #externalSession;
3841
+ #subscribers = /* @__PURE__ */ new Set();
3842
+ #activeTurn;
3843
+ #callbacks = {};
3844
+ #error;
3845
+ #events;
3846
+ #messageSubmissions;
3847
+ #prewarmGeneration = 0;
3848
+ #prewarmPromise;
3849
+ #prewarmController;
3850
+ #resumePromise;
3851
+ #session;
3852
+ #snapshot;
3853
+ #status = "ready";
3854
+ constructor(init) {
3855
+ this.#autoPrewarm = init.prewarm ?? false;
3856
+ this.#followChildStreams = init.followSubagents ?? false;
3857
+ this.#externalSession = init.session !== void 0;
3858
+ this.#client = this.#externalSession ? void 0 : init.client ?? new Client({
3859
+ auth: init.auth,
3860
+ headers: init.headers,
3861
+ host: init.host ?? ""
3224
3862
  });
3225
- case "client.message.failed": return upsertMessage(data, {
3226
- id: optimisticUserMessageId(event.data.submissionId),
3227
- metadata: {
3228
- optimistic: true,
3229
- status: "failed"
3230
- },
3231
- parts: [{
3232
- type: "text",
3233
- text: event.data.message
3234
- }],
3235
- role: "user"
3863
+ this.#conversationClient = new ConversationClient(new EveAgentProjection(init.reducer, []), () => this.#publish(), () => this.#publish());
3864
+ this.#events = (init.initialEvents ?? []).filter((event) => this.#conversationClient.hydrate(event));
3865
+ this.#messageSubmissions = new OptimisticMessageSubmissions(this.#conversationClient.projections, init.optimistic ?? true);
3866
+ this.#session = init.session ?? (init.initialSession === void 0 ? void 0 : this.#client?.sessions.attach(init.initialSession.sessionId, { streamIndex: init.initialSession.streamIndex }));
3867
+ this.#snapshot = this.#createSnapshot();
3868
+ }
3869
+ get snapshot() {
3870
+ return this.#snapshot;
3871
+ }
3872
+ setCallbacks(callbacks) {
3873
+ this.#callbacks = callbacks;
3874
+ }
3875
+ subscribe(callback) {
3876
+ this.#subscribers.add(callback);
3877
+ return () => void this.#subscribers.delete(callback);
3878
+ }
3879
+ prewarm() {
3880
+ if (this.#prewarmPromise !== void 0) return this.#prewarmPromise;
3881
+ if (this.#session !== void 0 || this.#externalSession) return Promise.resolve();
3882
+ if (this.#activeTurn !== void 0) return this.#activeTurn.response.then((response) => {
3883
+ if (response === void 0) throw this.#error ?? new DOMException("Session creation was aborted.", "AbortError");
3236
3884
  });
3237
- case "input.resolved": {
3238
- let next = data;
3239
- for (const resolution of event.data.resolutions) next = resolveInputRequest(next, resolution);
3240
- return next;
3241
- }
3242
- case "message.received":
3243
- if (event.data.kind === "execution.background_task") return data;
3244
- return upsertMessage(data, {
3245
- id: `${receivedMessageEventId(event)}:user`,
3246
- metadata: {
3247
- status: "complete",
3248
- turnId: event.data.turnId
3249
- },
3250
- parts: projectReceivedParts(event.data.parts, event.data.message),
3251
- role: "user"
3252
- });
3253
- case "step.started": return updateAssistantMessage(data, event.data.turnId, (message) => ensureStepStartPart(message, event.data.stepIndex));
3254
- case "reasoning.appended": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.append(ensureStepStartPart(message, event.data.stepIndex), {
3255
- delta: event.data.reasoningDelta,
3256
- stepIndex: event.data.stepIndex,
3257
- type: "reasoning"
3258
- }));
3259
- case "reasoning.completed": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.upsert(ensureStepStartPart(message, event.data.stepIndex), {
3260
- state: "done",
3261
- stepIndex: event.data.stepIndex,
3262
- text: event.data.reasoning,
3263
- type: "reasoning"
3264
- }));
3265
- case "action.input.appended": {
3266
- const existing = findToolPart(data, event.data.callId);
3267
- if (existing !== void 0 && existing.state !== "input-streaming") return data;
3268
- const nextPart = {
3269
- input: void 0,
3270
- inputText: (existing?.state === "input-streaming" ? existing.inputText : "") + event.data.inputTextDelta,
3271
- state: "input-streaming",
3272
- stepIndex: event.data.stepIndex,
3273
- toolCallId: event.data.callId,
3274
- toolMetadata: existing?.toolMetadata ?? { eve: {
3275
- kind: "unknown",
3276
- name: event.data.toolName
3277
- } },
3278
- toolName: event.data.toolName,
3279
- type: "dynamic-tool"
3280
- };
3281
- if (existing !== void 0) return updateToolPart(data, event.data.callId, nextPart);
3282
- return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), nextPart));
3283
- }
3284
- case "actions.requested": {
3285
- let next = data;
3286
- for (const action of event.data.actions) {
3287
- const descriptor = normalizeActionRequest(action);
3288
- next = updateAssistantMessage(next, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
3289
- input: "input" in action ? action.input : void 0,
3290
- state: "input-available",
3291
- stepIndex: event.data.stepIndex,
3292
- toolCallId: action.callId,
3293
- toolMetadata: createToolMetadata(descriptor),
3294
- toolName: descriptor.toolName,
3295
- type: "dynamic-tool"
3296
- }));
3885
+ const client = this.#client;
3886
+ if (client === void 0) return Promise.reject(/* @__PURE__ */ new Error("This eve agent store does not own a session client."));
3887
+ const generation = this.#prewarmGeneration;
3888
+ const controller = new AbortController();
3889
+ this.#prewarmController = controller;
3890
+ const promise = (async () => {
3891
+ try {
3892
+ const created = await client.sessions.create({ signal: controller.signal });
3893
+ if (generation !== this.#prewarmGeneration) return;
3894
+ this.#error = void 0;
3895
+ if (this.#status === "error") this.#status = "ready";
3896
+ this.#adoptSession(created.session);
3897
+ this.#ensureStream();
3898
+ } catch (error) {
3899
+ if (generation === this.#prewarmGeneration && this.#activeTurn === void 0 && this.#error === void 0) this.#fail(error);
3900
+ throw error;
3297
3901
  }
3298
- return next;
3902
+ })();
3903
+ this.#prewarmPromise = promise;
3904
+ const clear = () => {
3905
+ if (this.#prewarmPromise === promise) {
3906
+ this.#prewarmPromise = void 0;
3907
+ this.#prewarmController = void 0;
3908
+ }
3909
+ };
3910
+ promise.then(clear, clear);
3911
+ return promise;
3912
+ }
3913
+ async send(input) {
3914
+ return await this.#submit(input, this.#callbacks.prepareSend);
3915
+ }
3916
+ async #submit(input, prepareSend) {
3917
+ assertAnswerable(input, this.#conversationClient.conversation);
3918
+ if (this.#activeTurn !== void 0) {
3919
+ if (this.#status === "resuming") throw new Error("eve session is resuming.");
3920
+ return await this.#sendFollowUp(this.#activeTurn, input, prepareSend);
3299
3921
  }
3300
- case "input.requested": {
3301
- let next = data;
3302
- for (const request of event.data.requests) {
3303
- const descriptor = normalizeActionRequest(request.action);
3304
- next = updateAssistantMessage(next, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
3305
- approval: { id: request.requestId },
3306
- input: request.action.input,
3307
- state: "approval-requested",
3308
- stepIndex: event.data.stepIndex,
3309
- toolCallId: request.action.callId,
3310
- toolMetadata: createToolMetadata(descriptor, { inputRequest: toMessageInputRequest(request) }),
3311
- toolName: descriptor.toolName,
3312
- type: "dynamic-tool"
3313
- }));
3922
+ const turn = createActiveTurn((turn) => turn.acceptedFollowUps > 0 && this.#session !== void 0 ? this.#session.cancel() : turn.response.then((response) => response === void 0 ? { status: "no_active_turn" } : response.cancel()));
3923
+ this.#activeTurn = turn;
3924
+ this.#error = void 0;
3925
+ this.#status = "submitted";
3926
+ let reader;
3927
+ let submissionId;
3928
+ let retractResponses;
3929
+ try {
3930
+ assertExclusiveTurnInput(input);
3931
+ submissionId = this.#messageSubmissions.submit(input, this.#events.length);
3932
+ retractResponses = this.#conversationClient.projectResponses(input.inputResponses);
3933
+ this.#publish();
3934
+ const preparedInput = await (prepareSend === void 0 ? input : waitWithSignal(Promise.resolve(prepareSend(input)), createAbortSignal(input.signal, turn.abortController.signal)));
3935
+ assertExclusiveTurnInput(preparedInput);
3936
+ if (!this.#isActiveTurn(turn)) return;
3937
+ if (preparedInput !== input) {
3938
+ submissionId = this.#messageSubmissions.resubmit(submissionId, preparedInput);
3939
+ retractResponses = this.#conversationClient.replaceResponses(retractResponses, preparedInput);
3940
+ this.#publish();
3314
3941
  }
3315
- return next;
3942
+ const turnInput = {
3943
+ ...preparedInput,
3944
+ signal: createAbortSignal(preparedInput.signal, turn.abortController.signal)
3945
+ };
3946
+ const dispatched = await this.#dispatchTurn(turnInput);
3947
+ retractResponses = void 0;
3948
+ const response = dispatched.response;
3949
+ reader = dispatched.reader;
3950
+ if (!this.#isActiveTurn(turn)) return;
3951
+ turn.resolveResponse(response);
3952
+ this.#correlate(submissionId, response);
3953
+ for await (const event of consumeMessageResponse(response, reader)) {
3954
+ if (!this.#isActiveTurn(turn)) return;
3955
+ turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
3956
+ turn.receivedFollowUpEvents.delete(event);
3957
+ }
3958
+ if (!this.#isActiveTurn(turn)) return;
3959
+ await followSteeredTurns(turn, reader, () => this.#isActiveTurn(turn));
3960
+ if (!this.#isActiveTurn(turn)) return;
3961
+ this.#status = settledStatus(this.#error, this.#conversationClient.conversation);
3962
+ } catch (error) {
3963
+ if (!this.#isActiveTurn(turn)) return;
3964
+ retractResponses?.();
3965
+ if (isAbortError(error)) {
3966
+ this.#status = "ready";
3967
+ this.#messageSubmissions.fail(toError(error), submissionId);
3968
+ } else {
3969
+ const reported = this.#error !== void 0;
3970
+ this.#error ??= toError(error);
3971
+ this.#status = "error";
3972
+ this.#messageSubmissions.fail(this.#error, submissionId);
3973
+ if (!reported) this.#callbacks.onError?.(this.#error);
3974
+ }
3975
+ } finally {
3976
+ reader?.[Symbol.dispose]();
3977
+ this.#finishTurn(turn);
3316
3978
  }
3317
- case "approval.candidate": return data;
3318
- case "approval.settled": {
3319
- const existing = findToolPartByApprovalId(data, event.data.requestId);
3320
- if (existing === void 0) return data;
3321
- if (event.data.outcome === "approved") return updateToolPart(data, existing.toolCallId, {
3322
- approval: {
3323
- approved: true,
3324
- id: event.data.requestId,
3325
- reason: void 0
3326
- },
3327
- input: existing.input,
3328
- state: "approval-responded",
3329
- stepIndex: existing.stepIndex,
3330
- toolCallId: existing.toolCallId,
3331
- toolMetadata: existing.toolMetadata,
3332
- toolName: existing.toolName,
3333
- type: "dynamic-tool"
3334
- });
3335
- return updateToolPart(data, existing.toolCallId, {
3336
- approval: {
3337
- approved: false,
3338
- id: event.data.requestId,
3339
- reason: "Tool execution was cancelled."
3340
- },
3341
- input: existing.input,
3342
- state: "output-denied",
3343
- stepIndex: existing.stepIndex,
3344
- toolCallId: existing.toolCallId,
3345
- toolMetadata: existing.toolMetadata,
3346
- toolName: existing.toolName,
3347
- type: "dynamic-tool"
3979
+ }
3980
+ resume() {
3981
+ if (this.#resumePromise !== void 0) return this.#resumePromise;
3982
+ const promise = this.#resume();
3983
+ this.#resumePromise = promise;
3984
+ const clear = () => {
3985
+ if (this.#resumePromise === promise) this.#resumePromise = void 0;
3986
+ };
3987
+ promise.then(clear, clear);
3988
+ return promise;
3989
+ }
3990
+ async #resume() {
3991
+ if (this.#status !== "ready" && this.#status !== "error") throw new Error("eve session is already processing a turn.");
3992
+ if (this.#session === void 0) throw new Error("An eve session is required before resuming.");
3993
+ const session = this.#session;
3994
+ const turn = createActiveTurn(() => session.cancel());
3995
+ this.#activeTurn = turn;
3996
+ turn.resolveResponse(void 0);
3997
+ this.#error = void 0;
3998
+ this.#status = "resuming";
3999
+ this.#publish();
4000
+ let reader;
4001
+ try {
4002
+ const stream = this.#ensureStream({
4003
+ catchUp: true,
4004
+ startIndex: this.#events.length === session.state.streamIndex ? session.state.streamIndex : 0
3348
4005
  });
4006
+ reader = stream.subscribe(turn.abortController.signal);
4007
+ await stream.caughtUp;
4008
+ if (!this.#isActiveTurn(turn)) return;
4009
+ reader.discard();
4010
+ const tail = this.#events.at(-1);
4011
+ if (tail !== void 0) this.#applyTerminalStreamFailure(tail);
4012
+ if (tail && !this.#error && !isSettledSessionTail(this.#events, this.#conversationClient.conversation)) {
4013
+ this.#status = "streaming";
4014
+ this.#publish();
4015
+ for await (const event of reader) {
4016
+ if (!this.#isActiveTurn(turn)) return;
4017
+ turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
4018
+ turn.receivedFollowUpEvents.delete(event);
4019
+ if (isResponseBoundary(event, this.#conversationClient.conversation)) break;
4020
+ }
4021
+ }
4022
+ await followSteeredTurns(turn, reader, () => this.#isActiveTurn(turn));
4023
+ if (this.#isActiveTurn(turn)) this.#status = settledStatus(this.#error, this.#conversationClient.conversation);
4024
+ } catch (error) {
4025
+ if (!this.#isActiveTurn(turn)) return;
4026
+ if (isAbortError(error)) this.#status = "ready";
4027
+ else {
4028
+ this.#error = toError(error);
4029
+ this.#status = "error";
4030
+ this.#callbacks.onError?.(this.#error);
4031
+ }
4032
+ } finally {
4033
+ reader?.[Symbol.dispose]();
4034
+ this.#finishTurn(turn);
3349
4035
  }
3350
- case "action.result": {
3351
- const descriptor = normalizeActionResult(event.data.result);
3352
- const existing = findToolPart(data, event.data.result.callId);
3353
- const denied = event.data.error?.code === "TOOL_EXECUTION_DENIED";
3354
- const failed = event.data.status === "failed" && !denied;
3355
- const approvalId = existing?.approval?.id ?? event.data.result.callId;
3356
- const toolMetadata = mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor));
3357
- const resultPartBase = {
3358
- input: existing?.input,
3359
- stepIndex: event.data.stepIndex,
3360
- toolCallId: event.data.result.callId,
3361
- toolMetadata,
3362
- toolName: existing?.toolName ?? descriptor.toolName,
3363
- type: "dynamic-tool"
3364
- };
3365
- let nextPart;
3366
- if (denied) nextPart = {
3367
- ...resultPartBase,
3368
- approval: {
3369
- approved: false,
3370
- id: approvalId,
3371
- reason: event.data.error?.message
3372
- },
3373
- state: "output-denied"
3374
- };
3375
- else if (failed) nextPart = {
3376
- ...resultPartBase,
3377
- approval: approvedApproval(existing),
3378
- errorText: event.data.error?.message ?? stringifyUnknown(event.data.result.output),
3379
- state: "output-error"
3380
- };
3381
- else nextPart = {
3382
- ...resultPartBase,
3383
- approval: approvedApproval(existing),
3384
- output: event.data.result.output,
3385
- state: "output-available"
3386
- };
3387
- if (existing !== void 0) return updateToolPart(data, event.data.result.callId, nextPart);
3388
- return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), nextPart));
4036
+ }
4037
+ cancel() {
4038
+ const turn = this.#activeTurn;
4039
+ if (turn === void 0) return this.#status === "streaming" && this.#session !== void 0 ? this.#session.cancel() : Promise.resolve({ status: "no_active_turn" });
4040
+ return turn.cancel();
4041
+ }
4042
+ async compact() {
4043
+ return await this.#session?.compact() ?? { status: "no_active_session" };
4044
+ }
4045
+ async clear() {
4046
+ return await this.#session?.clear() ?? { status: "no_active_session" };
4047
+ }
4048
+ async retire() {
4049
+ if (this.#externalSession) throw new Error("retire() needs a store-owned session. Call reset() on the session you supplied, then create a new store for the next session.");
4050
+ const result = await this.#session?.reset() ?? { status: "no_active_session" };
4051
+ this.reset();
4052
+ return result;
4053
+ }
4054
+ [attachStore]() {
4055
+ this.#attached = true;
4056
+ if (this.#followChildStreams && !this.#conversationClient.following) this.#followSubagents();
4057
+ if (this.#autoPrewarm && this.#session === void 0) this.prewarm().catch(() => {});
4058
+ }
4059
+ [detachStore]() {
4060
+ this.#attached = false;
4061
+ this.#conversationClient.stop();
4062
+ this.#activeTurn?.abortController.abort();
4063
+ this.#resetPrewarm();
4064
+ this.#resumePromise = void 0;
4065
+ }
4066
+ reset() {
4067
+ this.#conversationClient.stop();
4068
+ const turn = this.#activeTurn;
4069
+ this.#activeTurn = void 0;
4070
+ turn?.resolveResponse(void 0);
4071
+ turn?.resolveCompletion();
4072
+ turn?.abortController.abort();
4073
+ this.#resetPrewarm();
4074
+ this.#resumePromise = void 0;
4075
+ if (!this.#externalSession) this.#session = void 0;
4076
+ this.#events = [];
4077
+ this.#conversationClient.reset();
4078
+ this.#messageSubmissions.reset();
4079
+ if (this.#followChildStreams && this.#attached) this.#followSubagents();
4080
+ this.#error = void 0;
4081
+ this.#status = "ready";
4082
+ this.#callbacks.onSessionChange?.(this.#session?.state);
4083
+ this.#publish();
4084
+ if (this.#autoPrewarm && this.#attached) this.prewarm().catch(() => {});
4085
+ }
4086
+ async #sendFollowUp(turn, input, prepareSend) {
4087
+ assertInFlightFollowUp(input);
4088
+ const generation = this.#prewarmGeneration;
4089
+ const signal = createAbortSignal(input.signal, turn.abortController.signal);
4090
+ let retractResponses = this.#conversationClient.projectResponses(input.inputResponses);
4091
+ const preparedInput = await waitWithSignal(Promise.resolve(prepareSend?.(input)), signal).then((prepared) => {
4092
+ const next = validateFollowUp(prepared ?? input);
4093
+ if (next === input) return next;
4094
+ retractResponses = this.#conversationClient.replaceResponses(retractResponses, next);
4095
+ return next;
4096
+ }).catch((error) => {
4097
+ retractResponses?.();
4098
+ throw error;
4099
+ });
4100
+ if (generation !== this.#prewarmGeneration) return;
4101
+ if (!this.#isActiveTurn(turn)) {
4102
+ retractResponses?.();
4103
+ return await this.#submit(preparedInput);
4104
+ }
4105
+ const submissionId = this.#messageSubmissions.submit(preparedInput, this.#events.length, activeTurnForOptimisticFollowUp(this.#events));
4106
+ if (submissionId !== void 0) turn.followUpSubmissionIds.add(submissionId);
4107
+ this.#publish();
4108
+ let dispatch;
4109
+ dispatch = (async () => {
4110
+ try {
4111
+ const signal = createAbortSignal(preparedInput.signal, turn.abortController.signal);
4112
+ await waitWithSignal(turn.response, signal);
4113
+ if (!this.#isActiveTurn(turn) || this.#session === void 0) throw new Error("The active eve turn ended before the follow-up could be sent.");
4114
+ this.#ensureStream({
4115
+ headers: preparedInput.headers,
4116
+ streamReconnectPolicy: preparedInput.streamReconnectPolicy
4117
+ });
4118
+ const response = (await dispatchSessionTurn({
4119
+ session: this.#session,
4120
+ turn: {
4121
+ ...preparedInput,
4122
+ signal
4123
+ }
4124
+ })).response;
4125
+ retractResponses = void 0;
4126
+ if (preparedInput.message === void 0) return;
4127
+ turn.acceptedFollowUps += 1;
4128
+ this.#correlate(submissionId, response);
4129
+ } catch (error) {
4130
+ if (this.#isActiveTurn(turn)) {
4131
+ this.#messageSubmissions.fail(toError(error), submissionId);
4132
+ retractResponses?.();
4133
+ this.#publish();
4134
+ }
4135
+ throw error;
4136
+ } finally {
4137
+ turn.followUpDispatches.delete(dispatch);
4138
+ }
4139
+ })();
4140
+ turn.followUpDispatches.add(dispatch);
4141
+ await dispatch;
4142
+ await turn.completion;
4143
+ }
4144
+ async #dispatchTurn(input) {
4145
+ const streamOptions = {
4146
+ headers: input.headers,
4147
+ streamReconnectPolicy: input.streamReconnectPolicy
4148
+ };
4149
+ if (this.#prewarmPromise !== void 0) {
4150
+ await waitWithSignal(this.#prewarmPromise.catch((error) => {
4151
+ if (this.#session !== void 0) throw error;
4152
+ }), input.signal);
4153
+ input.signal?.throwIfAborted();
3389
4154
  }
3390
- case "action.partial": {
3391
- const existing = findToolPart(data, event.data.result.callId);
3392
- if (existing !== void 0 && isSettledToolPart(existing)) return data;
3393
- const descriptor = normalizeActionResult(event.data.result);
3394
- const nextPart = {
3395
- approval: approvedApproval(existing),
3396
- input: existing?.input,
3397
- output: event.data.result.output,
3398
- partial: true,
3399
- state: "output-available",
3400
- stepIndex: event.data.stepIndex,
3401
- toolCallId: event.data.result.callId,
3402
- toolMetadata: mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor)),
3403
- toolName: existing?.toolName ?? descriptor.toolName,
3404
- type: "dynamic-tool"
4155
+ const session = this.#session;
4156
+ let reader;
4157
+ try {
4158
+ const dispatched = await dispatchSessionTurn({
4159
+ client: this.#client,
4160
+ session,
4161
+ turn: input,
4162
+ beforeSend: () => {
4163
+ reader = this.#ensureStream(streamOptions).subscribe(input.signal);
4164
+ }
4165
+ });
4166
+ if (dispatched.created) {
4167
+ this.#adoptSession(dispatched.session);
4168
+ reader = this.#ensureStream(streamOptions).subscribe(input.signal);
4169
+ }
4170
+ return {
4171
+ response: dispatched.response,
4172
+ reader
3405
4173
  };
3406
- if (existing !== void 0) return updateToolPart(data, event.data.result.callId, nextPart);
3407
- return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), nextPart));
4174
+ } catch (error) {
4175
+ reader?.[Symbol.dispose]();
4176
+ throw error;
3408
4177
  }
3409
- case "authorization.required": return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), createAuthorizationRequiredPart(event)));
3410
- case "authorization.completed": return completeAuthorization(data, event);
3411
- case "message.appended": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.append(ensureStepStartPart(message, event.data.stepIndex), {
3412
- delta: event.data.messageDelta,
3413
- stepIndex: event.data.stepIndex,
3414
- type: "text"
3415
- }));
3416
- case "message.completed": return updateAssistantMessage(data, event.data.turnId, (message) => {
3417
- if (event.data.message === null) return removeTextPart(message, event.data.stepIndex);
3418
- return messageRun.upsert(ensureStepStartPart(message, event.data.stepIndex), {
3419
- state: "done",
3420
- stepIndex: event.data.stepIndex,
3421
- text: event.data.message,
3422
- type: "text"
3423
- });
4178
+ }
4179
+ #ensureStream(options = {}) {
4180
+ if (this.#session === void 0) throw new Error("A session is required before opening its stream.");
4181
+ const generation = this.#prewarmGeneration;
4182
+ if (this.#followChildStreams && !this.#conversationClient.following) this.#followSubagents();
4183
+ return this.#conversationClient.stream(this.#session, {
4184
+ ...options,
4185
+ onEvent: (event) => {
4186
+ if (generation === this.#prewarmGeneration) this.#acceptServerEvent(event);
4187
+ },
4188
+ onError: (error) => {
4189
+ if (generation !== this.#prewarmGeneration || this.#activeTurn !== void 0) return;
4190
+ this.#fail(error);
4191
+ }
3424
4192
  });
3425
- case "result.completed": return updateAssistantMetadata(data, event.data.turnId, { result: event.data.result });
3426
- case "turn.completed": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3427
- ...message,
3428
- metadata: {
3429
- ...message.metadata,
3430
- status: "complete"
4193
+ }
4194
+ #adoptSession(session) {
4195
+ this.#session = session;
4196
+ if (this.#followChildStreams && this.#attached) this.#followSubagents();
4197
+ this.#callbacks.onSessionChange?.(session.state);
4198
+ this.#publish();
4199
+ }
4200
+ #fail(error) {
4201
+ this.#error = toError(error);
4202
+ this.#status = "error";
4203
+ this.#callbacks.onError?.(this.#error);
4204
+ this.#publish();
4205
+ }
4206
+ #followSubagents() {
4207
+ if (this.#session) this.#conversationClient.follow(this.#session, this.#events);
4208
+ }
4209
+ #resetPrewarm() {
4210
+ this.#prewarmGeneration += 1;
4211
+ this.#prewarmController?.abort();
4212
+ this.#prewarmController = void 0;
4213
+ this.#prewarmPromise = void 0;
4214
+ }
4215
+ #finishTurn(turn) {
4216
+ if (!this.#isActiveTurn(turn)) return;
4217
+ turn.resolveResponse(void 0);
4218
+ this.#activeTurn = void 0;
4219
+ try {
4220
+ this.#callbacks.onSessionChange?.(this.#session?.state);
4221
+ this.#publish();
4222
+ this.#callbacks.onFinish?.(this.#snapshot);
4223
+ } finally {
4224
+ turn.resolveCompletion();
4225
+ }
4226
+ }
4227
+ #isActiveTurn(turn) {
4228
+ return this.#activeTurn === turn;
4229
+ }
4230
+ #acceptServerEvent(event) {
4231
+ const wasStreaming = this.#status === "streaming";
4232
+ if (!this.#conversationClient.observe(event, {
4233
+ onAccepted: () => {
4234
+ this.#events = [...this.#events, event];
3431
4235
  },
3432
- parts: removeStreamingToolParts(message.parts)
3433
- }));
3434
- case "turn.cancelled": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3435
- ...message,
3436
- metadata: {
3437
- ...message.metadata,
3438
- status: "complete"
4236
+ project: (accepted) => {
4237
+ this.#handleReconciliation(this.#messageSubmissions.apply(accepted));
3439
4238
  },
3440
- parts: removeStreamingToolParts(message.parts.map((part) => (part.type === "text" || part.type === "reasoning") && part.state === "streaming" ? {
3441
- ...part,
3442
- state: "done"
3443
- } : part))
3444
- }));
3445
- case "turn.failed": return removeStreamingToolPartsForTurn(data, event.data.turnId);
3446
- case "session.failed": return data;
3447
- default: return data;
4239
+ notify: false
4240
+ })) return false;
4241
+ this.#callbacks.onEvent?.(event);
4242
+ this.#applyTerminalStreamFailure(event);
4243
+ const { conversation } = this.#conversationClient;
4244
+ const settled = isSettledSessionTail(this.#events, conversation) && conversation.activeTurnId === void 0;
4245
+ if (this.#status !== "resuming" && this.#error === void 0) {
4246
+ if ("data" in event && event.data !== void 0 && "turnId" in event.data) this.#status = "streaming";
4247
+ if (this.#activeTurn === void 0 && settled) this.#status = "ready";
4248
+ }
4249
+ this.#callbacks.onSessionChange?.(this.#session?.state);
4250
+ if (this.#status !== "resuming") this.#publish();
4251
+ if (this.#activeTurn === void 0 && wasStreaming && settled) this.#callbacks.onFinish?.(this.#snapshot);
4252
+ return true;
3448
4253
  }
3449
- }
3450
- function removeStreamingToolParts(parts) {
3451
- return parts.filter((part) => part.type !== "dynamic-tool" || part.state !== "input-streaming");
3452
- }
3453
- function respondToInputRequest(data, response) {
3454
- const existing = findToolPartByApprovalId(data, response.requestId);
3455
- if (!existing) return data;
3456
- const approval = { id: response.requestId };
3457
- if (response.text !== void 0) approval.reason = response.text;
3458
- return updateToolPart(data, existing.toolCallId, {
3459
- approval,
3460
- input: existing.input,
3461
- state: "approval-responded",
3462
- stepIndex: existing.stepIndex,
3463
- toolCallId: existing.toolCallId,
3464
- toolMetadata: mergeToolMetadata(existing.toolMetadata, { eve: {
3465
- inputResponse: response,
3466
- kind: existing.toolMetadata?.eve?.kind ?? "unknown",
3467
- name: existing.toolMetadata?.eve?.name ?? existing.toolName
3468
- } }),
3469
- toolName: existing.toolName,
3470
- type: "dynamic-tool"
3471
- });
3472
- }
3473
- function resolveInputRequest(data, resolution) {
3474
- if (resolution.response !== void 0) return respondToInputRequest(data, resolution.response);
3475
- const existing = findToolPartByApprovalId(data, resolution.requestId);
3476
- if (!existing) return data;
3477
- return updateToolPart(data, existing.toolCallId, {
3478
- input: existing.input,
3479
- output: { status: resolution.outcome },
3480
- state: "output-available",
3481
- stepIndex: existing.stepIndex,
3482
- toolCallId: existing.toolCallId,
3483
- toolMetadata: existing.toolMetadata,
3484
- toolName: existing.toolName,
3485
- type: "dynamic-tool"
3486
- });
3487
- }
3488
- function updateAssistantMessage(data, turnId, update) {
3489
- const message = data.messages.find((message) => message.role === "assistant" && message.metadata?.turnId === turnId) ?? createAssistantMessage(turnId);
3490
- return upsertMessage(data, update(message));
3491
- }
3492
- function updateAssistantMetadata(data, turnId, metadata) {
3493
- return updateAssistantMessage(data, turnId, (message) => ({
3494
- ...message,
3495
- metadata: {
3496
- ...message.metadata,
3497
- ...metadata
4254
+ #correlate(submissionId, response) {
4255
+ const deliveryId = getMessageResponseDeliveryId(response);
4256
+ const reconciled = this.#messageSubmissions.correlate(submissionId, deliveryId, this.#events);
4257
+ if (this.#handleReconciliation(reconciled)) this.#publish();
4258
+ }
4259
+ #handleReconciliation(reconciliation) {
4260
+ if (reconciliation === void 0) return false;
4261
+ if (this.#activeTurn !== void 0) countFollowUpDeliveries(this.#activeTurn, reconciliation);
4262
+ return true;
4263
+ }
4264
+ #applyTerminalStreamFailure(event) {
4265
+ const error = toTerminalStreamFailureError(event);
4266
+ if (error === void 0) return;
4267
+ this.#status = "error";
4268
+ this.#messageSubmissions.failAll(error);
4269
+ if (this.#error === void 0) {
4270
+ this.#error = error;
4271
+ this.#callbacks.onError?.(error);
3498
4272
  }
3499
- }));
3500
- }
3501
- function createAssistantMessage(turnId) {
3502
- return {
3503
- id: `${turnId}:assistant`,
3504
- metadata: {
3505
- status: "streaming",
3506
- turnId
3507
- },
3508
- parts: [],
3509
- role: "assistant"
3510
- };
3511
- }
3512
- function ensureStepStartPart(message, stepIndex) {
3513
- const stepStartCount = message.parts.filter((part) => part.type === "step-start").length;
3514
- if (stepStartCount > stepIndex) return message;
3515
- const missingCount = stepIndex - stepStartCount + 1;
3516
- return {
3517
- ...message,
3518
- parts: [...message.parts, ...Array.from({ length: missingCount }, () => ({ type: "step-start" }))]
3519
- };
3520
- }
3521
- function upsertPart(message, next) {
3522
- const index = message.parts.findIndex((part) => partKey(part) === partKey(next));
3523
- const parts = index === -1 ? [...message.parts, next] : [
3524
- ...message.parts.slice(0, index),
3525
- next,
3526
- ...message.parts.slice(index + 1)
3527
- ];
3528
- return {
3529
- ...message,
3530
- metadata: {
3531
- ...message.metadata,
3532
- status: next.type === "text" && next.state === "done" ? "complete" : "streaming"
3533
- },
3534
- parts
3535
- };
3536
- }
3537
- function removeTextPart(message, stepIndex) {
3538
- const parts = message.parts.filter((part) => part.type !== "text" || part.stepIndex !== stepIndex);
3539
- if (parts.length === message.parts.length) return message;
3540
- return {
3541
- ...message,
3542
- metadata: {
3543
- ...message.metadata,
3544
- status: "complete"
3545
- },
3546
- parts
3547
- };
3548
- }
3549
- function updateToolPart(data, toolCallId, next) {
3550
- const message = data.messages.find((candidate) => candidate.role === "assistant" && candidate.parts.some((part) => part.type === "dynamic-tool" && part.toolCallId === toolCallId));
3551
- if (!message) return data;
3552
- return upsertMessage(data, upsertPart(message, next));
3553
- }
3554
- function completeAuthorization(data, event) {
3555
- const existing = findLatestPendingAuthorizationPart(data, event.data.name);
3556
- const next = createAuthorizationCompletedPart(event, existing);
3557
- if (existing !== void 0) return updateAuthorizationPart(data, existing, next);
3558
- return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), next));
3559
- }
3560
- function updateAuthorizationPart(data, existing, next) {
3561
- const message = data.messages.find((candidate) => candidate.role === "assistant" && candidate.parts.some((part) => part === existing));
3562
- if (!message) return data;
3563
- return upsertMessage(data, upsertPart(message, next));
3564
- }
3565
- function findToolPart(data, toolCallId) {
3566
- for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.toolCallId === toolCallId) return part;
4273
+ }
4274
+ #createSnapshot() {
4275
+ return {
4276
+ data: this.#conversationClient.data,
4277
+ conversation: this.#conversationClient.conversation,
4278
+ error: this.#error,
4279
+ events: this.#events,
4280
+ session: this.#session?.state,
4281
+ status: this.#status
4282
+ };
4283
+ }
4284
+ #publish() {
4285
+ this.#snapshot = this.#createSnapshot();
4286
+ for (const subscriber of this.#subscribers) subscriber();
4287
+ }
4288
+ };
4289
+ function detachEveAgentStore(store) {
4290
+ store[detachStore]();
3567
4291
  }
3568
- function isSettledToolPart(part) {
3569
- return part.state === "output-denied" || part.state === "output-error" || part.state === "output-available" && part.partial !== true;
4292
+ function attachEveAgentStore(store) {
4293
+ store[attachStore]();
3570
4294
  }
3571
- function findLatestPendingAuthorizationPart(data, name) {
3572
- for (let messageIndex = data.messages.length - 1; messageIndex >= 0; messageIndex -= 1) {
3573
- const message = data.messages[messageIndex];
3574
- if (message?.role !== "assistant") continue;
3575
- for (let partIndex = message.parts.length - 1; partIndex >= 0; partIndex -= 1) {
3576
- const part = message.parts[partIndex];
3577
- if (part?.type === "authorization" && part.state === "required" && part.name === name) return part;
3578
- }
3579
- }
4295
+
4296
+ //#endregion
4297
+ //#region src/client/agent-host.ts
4298
+ const AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
4299
+ const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve";
4300
+ function resolveEveAgentHost(input) {
4301
+ if (input.agent === void 0) return input.host ?? "";
4302
+ if (input.host !== void 0) throw new Error("useEveAgent cannot combine agent and host. Use one target option.");
4303
+ assertValidAgentName(input.agent);
4304
+ return `${EVE_NAMED_AGENT_ROUTE_PREFIX}/${input.agent}`;
3580
4305
  }
3581
- function findToolPartByApprovalId(data, approvalId) {
3582
- for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.approval?.id === approvalId) return part;
4306
+ function assertValidAgentName(name) {
4307
+ if (!AGENT_NAME_PATTERN.test(name)) throw new Error(`eve agent name ${JSON.stringify(name)} is invalid. Use lowercase letters, numbers, underscores, or hyphens, starting with a letter or number.`);
3583
4308
  }
3584
4309
 
3585
4310
  //#endregion
3586
4311
  //#region src/vue/use-eve-agent.ts
3587
4312
  function useEveAgent(options = {}) {
3588
4313
  if (options.resume && options.initialSession === void 0 && options.session === void 0) throw new Error("useEveAgent({ resume: true }) requires initialSession or session.");
3589
- const reducer = options.reducer ?? defaultMessageReducer();
4314
+ const reducer = options.reducer ?? conversationReducer;
3590
4315
  const store = new EveAgentStore({
3591
4316
  auth: options.auth,
3592
4317
  headers: options.headers,
@@ -3597,6 +4322,7 @@ function useEveAgent(options = {}) {
3597
4322
  initialEvents: options.initialEvents,
3598
4323
  initialSession: options.initialSession,
3599
4324
  optimistic: options.optimistic,
4325
+ followSubagents: options.followSubagents,
3600
4326
  prewarm: options.prewarm,
3601
4327
  reducer,
3602
4328
  session: options.session
@@ -3623,6 +4349,7 @@ function useEveAgent(options = {}) {
3623
4349
  return {
3624
4350
  cancel: () => store.cancel(),
3625
4351
  data: computed(() => snapshot.value.data),
4352
+ conversation: computed(() => snapshot.value.conversation),
3626
4353
  error: computed(() => snapshot.value.error),
3627
4354
  events: computed(() => snapshot.value.events),
3628
4355
  prewarm: () => store.prewarm(),
@@ -3642,4 +4369,4 @@ function useEveAgent(options = {}) {
3642
4369
  }
3643
4370
 
3644
4371
  //#endregion
3645
- export { defaultMessageReducer as n, useEveAgent as t };
4372
+ export { openConversationInputs as i, conversationReducer as n, defaultMessageReducer as r, useEveAgent as t };