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,7 +1,7 @@
1
1
  import { onMount } from "svelte";
2
2
  import { createSubscriber } from "svelte/reactivity";
3
3
  import { z } from "#compiled/zod/index.js";
4
- import { asSchema } from "ai";
4
+ import "ai";
5
5
  import { Validator } from "#compiled/@cfworker/json-schema/index.js";
6
6
 
7
7
  //#region src/protocol/routes.ts
@@ -24,8 +24,6 @@ const EVE_DEV_RUNTIME_ARTIFACTS_SUSPEND_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACT
24
24
  const EVE_DEV_RUNTIME_ARTIFACTS_RESUME_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}/resume`;
25
25
  const EVE_CONNECTION_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/connections/:name/callback/:attemptId/:token`;
26
26
  const EVE_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/callback/:token`;
27
- const EVE_TASK_INPUT_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/task-input/:token`;
28
- const EVE_ACTIVITY_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/activity/:token`;
29
27
  function createEveSessionRoutePath(sessionId) {
30
28
  return `${EVE_SESSION_ROUTE_PATH}/${encodeURIComponent(sessionId)}`;
31
29
  }
@@ -85,6 +83,10 @@ function encodeBasicCredentials(username, password) {
85
83
  return btoa(binaryString);
86
84
  }
87
85
 
86
+ //#endregion
87
+ //#region src/shared/extension-mount.ts
88
+ const mountIdSchema = z.string().min(1);
89
+
88
90
  //#endregion
89
91
  //#region src/client/agent-info-schema.ts
90
92
  const owner = z.discriminatedUnion("kind", [
@@ -95,6 +97,7 @@ const owner = z.discriminatedUnion("kind", [
95
97
  }).strict(),
96
98
  z.object({
97
99
  kind: z.literal("extension"),
100
+ mountId: mountIdSchema.optional(),
98
101
  namespace: z.string(),
99
102
  packageName: z.string()
100
103
  }).strict()
@@ -106,10 +109,12 @@ const moduleBacking = z.discriminatedUnion("kind", [z.object({
106
109
  sourceRoot: z.string()
107
110
  }).strict().optional(),
108
111
  kind: z.literal("filesystem"),
112
+ mountId: z.string().optional(),
109
113
  sourcePath: z.string()
110
114
  }).strict(), z.object({
111
115
  dependencies: z.record(z.string(), z.string()).optional(),
112
116
  kind: z.literal("programmatic"),
117
+ mountId: z.string().optional(),
113
118
  moduleId: z.string(),
114
119
  parameters: z.record(z.string(), z.unknown()).optional(),
115
120
  registryId: z.string(),
@@ -316,13 +321,9 @@ const remoteAgent = entry.extend({
316
321
  url: z.string().optional()
317
322
  }).strict();
318
323
  const kernelEffect = z.object({
319
- action: z.enum([
320
- "subagent-call",
321
- "task-cancel",
322
- "workflow-tool-call"
323
- ]).optional(),
324
- audience: z.array(z.enum(["root-session", "delegated-task-child"])),
325
- kind: z.enum(["dispatch", "provider-tool"]),
324
+ action: z.union([z.enum(["subagent-call", "workflow-tool-call"]), z.literal("unrecognized")]).catch("unrecognized").optional(),
325
+ audience: z.array(z.union([z.literal("root-session"), z.literal("unrecognized")]).catch("unrecognized")),
326
+ kind: z.union([z.enum(["dispatch", "provider-tool"]), z.literal("unrecognized")]).catch("unrecognized"),
326
327
  sourceId: z.string()
327
328
  }).strict();
328
329
  const compositionDiagnostic = z.object({
@@ -684,117 +685,74 @@ function isTurnFailureEvent(event) {
684
685
  //#endregion
685
686
  //#region src/client/session-utils.ts
686
687
  function summarizeTurnEvents(events) {
688
+ const segment = new TurnSegment();
687
689
  let boundary;
688
690
  let failure;
689
691
  let message;
690
- const inputRequests = [];
691
- const pendingAuthorizations = /* @__PURE__ */ new Map();
692
692
  for (const event of events) {
693
- if (isCurrentTurnBoundaryEvent(event)) boundary = event;
693
+ if (segment.observe(event)) boundary = event;
694
694
  if (isTurnFailureEvent(event)) failure = event;
695
695
  if (isFinalMessageCompleted(event)) message = event.data.message ?? void 0;
696
- if (event.type === "input.requested") inputRequests.push(...event.data.requests);
697
- if (event.type === "authorization.required") pendingAuthorizations.set(event.data.name, event.data);
698
- if (event.type === "authorization.completed") pendingAuthorizations.delete(event.data.name);
696
+ if (event.type === "turn.waiting") message = void 0;
699
697
  }
700
698
  return {
701
699
  boundary,
702
700
  failure,
703
- inputRequests,
701
+ inputRequests: segment.inputRequests,
704
702
  message,
705
- pendingAuthorizations: [...pendingAuthorizations.values()],
706
- status: boundary?.type === "session.waiting" ? "waiting" : boundary?.type === "session.failed" ? "failed" : "completed"
703
+ pendingAuthorizations: segment.pendingAuthorizations,
704
+ status: summarizeBoundaryStatus(boundary)
707
705
  };
708
706
  }
709
- function isFinalMessageCompleted(event) {
710
- return event.type === "message.completed" && event.data.finishReason !== "tool-calls";
711
- }
712
- function updatePendingAuthorizations(pending, event) {
713
- if (event.type === "authorization.required" && event.data.webhookUrl !== void 0) pending.add(event.data.name);
714
- else if (event.type === "authorization.completed") pending.delete(event.data.name);
715
- }
716
-
717
- //#endregion
718
- //#region src/client/output-schema.ts
719
- function extractCompletedResult(events) {
720
- let result;
721
- for (const event of events) if (isResultCompletedEvent(event)) result = event.data.result;
722
- return result;
707
+ function summarizeBoundaryStatus(boundary) {
708
+ if (boundary?.type === "session.waiting" || boundary?.type === "turn.waiting") return "waiting";
709
+ if (boundary?.type === "session.failed") return "failed";
710
+ return "completed";
723
711
  }
724
- function isResultCompletedEvent(event) {
725
- return event.type === "result.completed";
712
+ function endsTurnSegment(event, open) {
713
+ if (event.type === "turn.waiting") return open.requests || event.data.on === "input" && !open.callbacks;
714
+ return isCurrentTurnBoundaryEvent(event) && (event.type !== "session.waiting" || !open.callbacks);
726
715
  }
727
-
728
- //#endregion
729
- //#region src/client/message-response.ts
730
- const consumeResponse = Symbol("consumeMessageResponse");
731
- const acceptedDeliveryId = Symbol("acceptedDeliveryId");
732
- var MessageResponse = class {
733
- sessionId;
734
- [acceptedDeliveryId];
735
- #cancelTurn;
736
- #cancellation;
737
- #consumed = false;
738
- #createStream;
739
- #settled = false;
740
- #turnId = Promise.withResolvers();
741
- constructor(input) {
742
- this.#cancelTurn = input.cancelTurn;
743
- this.sessionId = input.sessionId;
744
- this[acceptedDeliveryId] = input.deliveryId;
745
- this.#createStream = input.createStream;
746
- }
747
- cancel() {
748
- if (this.#settled) return Promise.resolve({ status: "no_active_turn" });
749
- if (this.#cancellation !== void 0) return this.#cancellation;
750
- const cancellation = this.#turnId.promise.then((turnId) => turnId === void 0 ? { status: "no_active_turn" } : this.#cancelTurn(turnId));
751
- this.#cancellation = cancellation;
752
- cancellation.catch(() => {
753
- if (!this.#settled && this.#cancellation === cancellation) this.#cancellation = void 0;
754
- });
755
- return cancellation;
756
- }
757
- async result() {
758
- const events = [];
759
- for await (const event of this) events.push(event);
760
- const summary = summarizeTurnEvents(events);
761
- return {
762
- data: extractCompletedResult(events),
763
- events,
764
- inputRequests: summary.inputRequests,
765
- message: summary.message,
766
- sessionId: this.sessionId,
767
- status: summary.status
768
- };
716
+ var TurnSegment = class {
717
+ #authorizations = /* @__PURE__ */ new Map();
718
+ #followCallbacks;
719
+ #requests = /* @__PURE__ */ new Map();
720
+ constructor(options = {}) {
721
+ this.#followCallbacks = options.followCallbacks === true;
769
722
  }
770
- [Symbol.asyncIterator]() {
771
- return this[consumeResponse]();
723
+ get inputRequests() {
724
+ return [...this.#requests.values()];
772
725
  }
773
- [consumeResponse](source) {
774
- if (this.#consumed) throw new Error("MessageResponse has already been consumed.");
775
- this.#consumed = true;
776
- return this.#observeStream(source);
726
+ get pendingAuthorizations() {
727
+ return [...this.#authorizations.values()];
777
728
  }
778
- async *#observeStream(source) {
779
- try {
780
- for await (const event of this.#createStream(source)) {
781
- if (event.type === "turn.started") this.#turnId.resolve(event.data.turnId);
782
- else if (isCurrentTurnBoundaryEvent(event)) {
783
- this.#settled = true;
784
- this.#turnId.resolve(void 0);
785
- }
786
- yield event;
787
- }
788
- } finally {
789
- this.#turnId.resolve(void 0);
729
+ observe(event) {
730
+ switch (event.type) {
731
+ case "input.requested":
732
+ for (const request of event.data.requests) this.#requests.set(request.requestId, request);
733
+ break;
734
+ case "approval.settled":
735
+ this.#requests.delete(event.data.requestId);
736
+ break;
737
+ case "input.resolved":
738
+ for (const resolution of event.data.resolutions) this.#requests.delete(resolution.requestId);
739
+ break;
740
+ case "authorization.required":
741
+ this.#authorizations.set(authorizationKey(event.data), event.data);
742
+ break;
743
+ case "authorization.completed": this.#authorizations.delete(authorizationKey(event.data));
790
744
  }
745
+ return endsTurnSegment(event, {
746
+ callbacks: this.#followCallbacks && [...this.#authorizations.values()].some((authorization) => authorization.webhookUrl !== void 0),
747
+ requests: this.#requests.size > 0
748
+ });
791
749
  }
792
750
  };
793
- function getMessageResponseDeliveryId(response) {
794
- return response[acceptedDeliveryId];
751
+ function isFinalMessageCompleted(event) {
752
+ return event.type === "message.completed" && event.data.finishReason !== "tool-calls";
795
753
  }
796
- function consumeMessageResponse(response, source) {
797
- return response[consumeResponse](source);
754
+ function authorizationKey(data) {
755
+ return data.attemptId === void 0 ? `name:${data.name}` : `attempt:${data.attemptId}`;
798
756
  }
799
757
 
800
758
  //#endregion
@@ -805,7 +763,8 @@ function normalizeMessageStreamEvent(version, event) {
805
763
  case "22":
806
764
  case "23":
807
765
  case "24": return normalizeLegacyMessageStreamEvent(version, event);
808
- case "25": return validateCurrentMessageStreamEvent(event);
766
+ case "25":
767
+ case "26": return validateDeltaMessageStreamEvent(version, event);
809
768
  default: return assertNever(version);
810
769
  }
811
770
  }
@@ -854,26 +813,26 @@ function normalizeLegacyMessageStreamEvent(version, event) {
854
813
  }
855
814
  return event;
856
815
  }
857
- function validateCurrentMessageStreamEvent(event) {
816
+ function validateDeltaMessageStreamEvent(version, event) {
858
817
  if (event.type === "message.appended") {
859
- assertCurrentAppendDelta(event.data.messageDelta, "message");
860
- assertUnsupportedAppendField(event.data, "messageOffset", "message");
861
- assertUnsupportedAppendField(event.data, "messageSoFar", "message");
818
+ assertAppendDelta(event.data.messageDelta, "message", version);
819
+ assertUnsupportedAppendField(event.data, "messageOffset", "message", version);
820
+ assertUnsupportedAppendField(event.data, "messageSoFar", "message", version);
862
821
  } else if (event.type === "reasoning.appended") {
863
- assertCurrentAppendDelta(event.data.reasoningDelta, "reasoning");
864
- assertUnsupportedAppendField(event.data, "reasoningOffset", "reasoning");
865
- assertUnsupportedAppendField(event.data, "reasoningSoFar", "reasoning");
822
+ assertAppendDelta(event.data.reasoningDelta, "reasoning", version);
823
+ assertUnsupportedAppendField(event.data, "reasoningOffset", "reasoning", version);
824
+ assertUnsupportedAppendField(event.data, "reasoningSoFar", "reasoning", version);
866
825
  } else if (event.type === "action.input.appended") {
867
- assertCurrentAppendDelta(event.data.inputTextDelta, "action input");
868
- assertUnsupportedAppendField(event.data, "inputTextOffset", "action input");
826
+ assertAppendDelta(event.data.inputTextDelta, "action input", version);
827
+ assertUnsupportedAppendField(event.data, "inputTextOffset", "action input", version);
869
828
  }
870
829
  return event;
871
830
  }
872
- function assertCurrentAppendDelta(delta, stream) {
873
- if (typeof delta !== "string") throw new TypeError(`Invalid ${stream} append delta for stream version 25.`);
831
+ function assertAppendDelta(delta, stream, version) {
832
+ if (typeof delta !== "string") throw new TypeError(`Invalid ${stream} append delta for stream version ${version}.`);
874
833
  }
875
- function assertUnsupportedAppendField(data, field, stream) {
876
- if (field in data) throw new TypeError(`Invalid ${stream} append shape for stream version 25.`);
834
+ function assertUnsupportedAppendField(data, field, stream, version) {
835
+ if (field in data) throw new TypeError(`Invalid ${stream} append shape for stream version ${version}.`);
877
836
  }
878
837
  function assertNever(value) {
879
838
  throw new TypeError(`Unsupported message stream version: ${String(value)}.`);
@@ -974,7 +933,8 @@ const supportedMessageStreamVersions = {
974
933
  "22": true,
975
934
  "23": true,
976
935
  "24": true,
977
- "25": true
936
+ "25": true,
937
+ "26": true
978
938
  };
979
939
  function readMessageStreamVersion(headers) {
980
940
  const version = headers.get(EVE_STREAM_VERSION_HEADER);
@@ -1256,6 +1216,120 @@ async function sleep(ms, signal) {
1256
1216
  });
1257
1217
  }
1258
1218
 
1219
+ //#endregion
1220
+ //#region src/client/agent-session.ts
1221
+ var ClientAgentSession = class {
1222
+ name;
1223
+ sessionId;
1224
+ taskId;
1225
+ #context;
1226
+ #streamPath;
1227
+ constructor(context, started) {
1228
+ this.#context = context;
1229
+ this.#streamPath = started.data.streamPath;
1230
+ this.name = started.data.name;
1231
+ this.sessionId = started.data.sessionId;
1232
+ this.taskId = started.data.taskId;
1233
+ }
1234
+ stream(options) {
1235
+ const startIndex = options?.startIndex ?? 0;
1236
+ 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.");
1237
+ return followStreamIterable({
1238
+ follow: options?.follow,
1239
+ host: this.#context.host,
1240
+ path: this.#streamPath,
1241
+ redirect: this.#context.redirect,
1242
+ resolveHeaders: () => this.#context.resolveHeaders(),
1243
+ signal: options?.signal,
1244
+ startIndex,
1245
+ streamReconnectPolicy: options?.streamReconnectPolicy
1246
+ });
1247
+ }
1248
+ };
1249
+
1250
+ //#endregion
1251
+ //#region src/client/output-schema.ts
1252
+ function extractCompletedResult(events) {
1253
+ let result;
1254
+ for (const event of events) if (isResultCompletedEvent(event)) result = event.data.result;
1255
+ return result;
1256
+ }
1257
+ function isResultCompletedEvent(event) {
1258
+ return event.type === "result.completed";
1259
+ }
1260
+
1261
+ //#endregion
1262
+ //#region src/client/message-response.ts
1263
+ const consumeResponse = Symbol("consumeMessageResponse");
1264
+ const acceptedDeliveryId = Symbol("acceptedDeliveryId");
1265
+ var MessageResponse = class {
1266
+ sessionId;
1267
+ [acceptedDeliveryId];
1268
+ #cancelTurn;
1269
+ #cancellation;
1270
+ #consumed = false;
1271
+ #createStream;
1272
+ #settled = false;
1273
+ #turnId = Promise.withResolvers();
1274
+ constructor(input) {
1275
+ this.#cancelTurn = input.cancelTurn;
1276
+ this.sessionId = input.sessionId;
1277
+ this[acceptedDeliveryId] = input.deliveryId;
1278
+ this.#createStream = input.createStream;
1279
+ }
1280
+ cancel() {
1281
+ if (this.#settled) return Promise.resolve({ status: "no_active_turn" });
1282
+ if (this.#cancellation !== void 0) return this.#cancellation;
1283
+ const cancellation = this.#turnId.promise.then((turnId) => turnId === void 0 ? { status: "no_active_turn" } : this.#cancelTurn(turnId));
1284
+ this.#cancellation = cancellation;
1285
+ cancellation.catch(() => {
1286
+ if (!this.#settled && this.#cancellation === cancellation) this.#cancellation = void 0;
1287
+ });
1288
+ return cancellation;
1289
+ }
1290
+ async result() {
1291
+ const events = [];
1292
+ for await (const event of this) events.push(event);
1293
+ const summary = summarizeTurnEvents(events);
1294
+ return {
1295
+ data: extractCompletedResult(events),
1296
+ events,
1297
+ inputRequests: summary.inputRequests,
1298
+ message: summary.message,
1299
+ sessionId: this.sessionId,
1300
+ status: summary.status
1301
+ };
1302
+ }
1303
+ [Symbol.asyncIterator]() {
1304
+ return this[consumeResponse]();
1305
+ }
1306
+ [consumeResponse](source) {
1307
+ if (this.#consumed) throw new Error("MessageResponse has already been consumed.");
1308
+ this.#consumed = true;
1309
+ return this.#observeStream(source);
1310
+ }
1311
+ async *#observeStream(source) {
1312
+ try {
1313
+ for await (const event of this.#createStream(source)) {
1314
+ if (event.type === "turn.started") this.#turnId.resolve(event.data.turnId);
1315
+ else if (isCurrentTurnBoundaryEvent(event)) {
1316
+ this.#settled = true;
1317
+ this.#turnId.resolve(void 0);
1318
+ }
1319
+ yield event;
1320
+ }
1321
+ } finally {
1322
+ this.#turnId.resolve(void 0);
1323
+ }
1324
+ }
1325
+ };
1326
+ function getMessageResponseDeliveryId(response) {
1327
+ return response[acceptedDeliveryId];
1328
+ }
1329
+ function consumeMessageResponse(response, source) {
1330
+ return response[consumeResponse](source);
1331
+ }
1332
+
1259
1333
  //#endregion
1260
1334
  //#region src/protocol/cancel-turn.ts
1261
1335
  const CancelTurnResponseSchema = z.discriminatedUnion("status", [z.strictObject({
@@ -1437,11 +1511,42 @@ function isPlainObject(value) {
1437
1511
  }
1438
1512
 
1439
1513
  //#endregion
1440
- //#region src/tools/schema.ts
1514
+ //#region src/tools/schema-emission.ts
1441
1515
  const JSON_SCHEMA_TARGET = "draft-07";
1442
1516
  function serializeOutputSchema(source) {
1443
- return serializeSchema(source, "output");
1517
+ if (source === null || source === void 0) return source;
1518
+ return emitJsonSchema(source, "output");
1519
+ }
1520
+ function emitJsonSchema(source, direction) {
1521
+ const standard = getStandardSchemaProperties(source);
1522
+ if (standard === void 0) return withoutSchemaVersion(parseJsonObject(source));
1523
+ const emit = readJsonSchemaEmitter(standard, direction);
1524
+ if (emit === void 0) throw new Error(describeMissingEmitter(standard));
1525
+ return withoutSchemaVersion(parseJsonObject(emit({ target: JSON_SCHEMA_TARGET })));
1444
1526
  }
1527
+ function readJsonSchemaEmitter(standard, direction) {
1528
+ const jsonSchema = standard.jsonSchema;
1529
+ if (typeof jsonSchema !== "object" || jsonSchema === null) return void 0;
1530
+ const emit = jsonSchema[direction];
1531
+ return typeof emit === "function" ? emit : void 0;
1532
+ }
1533
+ function getStandardSchemaProperties(value) {
1534
+ if (typeof value !== "object" || value === null || !("~standard" in value)) return void 0;
1535
+ const standard = value["~standard"];
1536
+ return typeof standard === "object" && standard !== null ? standard : void 0;
1537
+ }
1538
+ function describeMissingEmitter(standard) {
1539
+ const vendor = typeof standard.vendor === "string" ? standard.vendor : "unknown";
1540
+ if (vendor === "zod") return "Zod 3 cannot emit an output JSON Schema. Upgrade to Zod 4 or provide a plain JSON Schema object.";
1541
+ 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.`;
1542
+ }
1543
+ function withoutSchemaVersion(schema) {
1544
+ const { $schema: _schemaVersion, ...canonical } = schema;
1545
+ return canonical;
1546
+ }
1547
+
1548
+ //#endregion
1549
+ //#region src/tools/schema.ts
1445
1550
  function defineJsonSchema(schema, check) {
1446
1551
  const emit = () => structuredClone(schema);
1447
1552
  const toolSchema = { "~standard": {
@@ -1458,32 +1563,6 @@ function defineJsonSchema(schema, check) {
1458
1563
  }
1459
1564
  const plainJsonSchemas = /* @__PURE__ */ new WeakSet();
1460
1565
  const UNSPECIFIED_INPUT_SCHEMA = defineJsonSchema({});
1461
- function serializeSchema(source, direction) {
1462
- if (source === null || source === void 0) return source;
1463
- return toJsonObject(source, direction);
1464
- }
1465
- function toJsonObject(source, direction) {
1466
- const standard = getStandardSchemaProperties(source);
1467
- const jsonSchema = standard?.jsonSchema;
1468
- const emit = typeof jsonSchema === "object" && jsonSchema !== null ? jsonSchema[direction] : void 0;
1469
- const vendor = typeof standard?.vendor === "string" ? standard.vendor : "unknown";
1470
- if (standard !== void 0 && typeof emit !== "function" && vendor === "zod") {
1471
- if (direction === "input") {
1472
- const schema = asSchema(source);
1473
- const { $schema: _schemaVersion, ...canonical } = parseJsonObject(schema.jsonSchema);
1474
- return canonical;
1475
- }
1476
- throw new Error("Zod 3 cannot emit an output JSON Schema. Upgrade to Zod 4 or provide a plain JSON Schema object.");
1477
- }
1478
- 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.`);
1479
- const { $schema: _schemaVersion, ...canonical } = standard === void 0 ? parseJsonObject(source) : parseJsonObject(emit({ target: JSON_SCHEMA_TARGET }));
1480
- return canonical;
1481
- }
1482
- function getStandardSchemaProperties(value) {
1483
- if (typeof value !== "object" || value === null || !("~standard" in value)) return void 0;
1484
- const standard = value["~standard"];
1485
- return typeof standard === "object" && standard !== null ? standard : void 0;
1486
- }
1487
1566
  function createJsonSchemaValidator(schema, check) {
1488
1567
  let validator;
1489
1568
  let warned = false;
@@ -1814,21 +1893,8 @@ var ClientSession = class ClientSession {
1814
1893
  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.");
1815
1894
  return this.#streamAndAdvance(options);
1816
1895
  }
1817
- streamSubagent(called, options) {
1818
- 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}.`);
1819
- 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.`);
1820
- const startIndex = options?.startIndex ?? 0;
1821
- if (options?.follow === false && startIndex < 0) throw new Error("streamSubagent({ follow: false }) requires a nonnegative startIndex; a tail-relative cursor cannot be bounded.");
1822
- return followStreamIterable({
1823
- follow: options?.follow,
1824
- host: this.#context.host,
1825
- path: called.data.childStreamPath,
1826
- redirect: this.#context.redirect,
1827
- resolveHeaders: () => this.#context.resolveHeaders(),
1828
- signal: options?.signal,
1829
- startIndex,
1830
- streamReconnectPolicy: options?.streamReconnectPolicy
1831
- });
1896
+ agent(started) {
1897
+ return new ClientAgentSession(this.#context, started);
1832
1898
  }
1833
1899
  [followSession](options) {
1834
1900
  return this.#streamAndAdvance({
@@ -1849,7 +1915,7 @@ var ClientSession = class ClientSession {
1849
1915
  let eventCount = 0;
1850
1916
  let started = deliveryId === void 0;
1851
1917
  let reachedBoundary = false;
1852
- const pendingAuthorizations = /* @__PURE__ */ new Set();
1918
+ const segment = new TurnSegment({ followCallbacks: true });
1853
1919
  try {
1854
1920
  for await (const event of source ?? this.#readStream({
1855
1921
  headers: input.headers,
@@ -1867,8 +1933,7 @@ var ClientSession = class ClientSession {
1867
1933
  if (!terminal && event.meta?.deliveryIds !== void 0 && !matches) continue;
1868
1934
  started = true;
1869
1935
  }
1870
- updatePendingAuthorizations(pendingAuthorizations, event);
1871
- reachedBoundary = isCurrentTurnBoundaryEvent(event) && (event.type !== "session.waiting" || pendingAuthorizations.size === 0);
1936
+ reachedBoundary = segment.observe(event);
1872
1937
  yield event;
1873
1938
  if (reachedBoundary) break;
1874
1939
  }
@@ -1986,7 +2051,6 @@ function createMessageBody(input, requireMessage) {
1986
2051
  if (input.message !== void 0) body.message = input.message;
1987
2052
  if (input.inputResponses !== void 0 && input.inputResponses.length > 0) body.inputResponses = input.inputResponses;
1988
2053
  if (!requireMessage && input.message !== void 0 && input.turnPolicy !== void 0) body.turnPolicy = input.turnPolicy;
1989
- if (input.message !== void 0 && input.taskDeliveryPolicy !== void 0) body.taskDeliveryPolicy = input.taskDeliveryPolicy;
1990
2054
  if (input.clientContext !== void 0) body.clientContext = input.clientContext;
1991
2055
  const outputSchema = serializeOutputSchema(input.outputSchema);
1992
2056
  if (outputSchema !== void 0) body.outputSchema = outputSchema;
@@ -2134,117 +2198,6 @@ function withRedirectPolicy(init, redirect) {
2134
2198
  };
2135
2199
  }
2136
2200
 
2137
- //#endregion
2138
- //#region src/client/session-event-stream.ts
2139
- var SessionEventStream = class {
2140
- #controller = new AbortController();
2141
- #readers = /* @__PURE__ */ new Set();
2142
- #caughtUp = Promise.withResolvers();
2143
- caughtUp = this.#caughtUp.promise;
2144
- #ended = false;
2145
- #error;
2146
- #headers;
2147
- #reconnectPolicy;
2148
- constructor(session, options) {
2149
- this.setOptions(options);
2150
- this.caughtUp.catch(() => {});
2151
- if (!options.catchUp) this.#caughtUp.resolve();
2152
- (async () => {
2153
- try {
2154
- for await (const event of followClientSession(session, {
2155
- signal: this.#controller.signal,
2156
- resolveHeaders: () => this.#headers,
2157
- resolveReconnectPolicy: () => this.#reconnectPolicy,
2158
- startIndex: options.startIndex,
2159
- onCaughtUp: options.catchUp ? () => this.#caughtUp.resolve() : void 0
2160
- })) {
2161
- if (this.#controller.signal.aborted) return;
2162
- options.onEvent(event);
2163
- for (const reader of this.#readers) reader.push(event);
2164
- if (event.type === "session.completed" || event.type === "session.failed") break;
2165
- }
2166
- this.#caughtUp.resolve();
2167
- this.#finish();
2168
- } catch (error) {
2169
- this.#caughtUp.reject(error);
2170
- this.#finish(error);
2171
- if (!this.#controller.signal.aborted) options.onError(error);
2172
- }
2173
- })();
2174
- }
2175
- subscribe(signal) {
2176
- const reader = new SessionEventReader(() => this.#readers.delete(reader), signal);
2177
- if (this.#ended) reader.end(this.#error);
2178
- else this.#readers.add(reader);
2179
- return reader;
2180
- }
2181
- get ended() {
2182
- return this.#ended;
2183
- }
2184
- setOptions(options) {
2185
- if ("headers" in options) this.#headers = options.headers;
2186
- if ("streamReconnectPolicy" in options) this.#reconnectPolicy = options.streamReconnectPolicy;
2187
- }
2188
- close() {
2189
- const error = new DOMException("Session stream was detached.", "AbortError");
2190
- this.#controller.abort(error);
2191
- this.#caughtUp.reject(error);
2192
- this.#finish(error);
2193
- }
2194
- #finish(error) {
2195
- if (this.#ended) return;
2196
- this.#ended = true;
2197
- this.#error = error;
2198
- for (const reader of this.#readers) reader.end(error);
2199
- }
2200
- };
2201
- var SessionEventReader = class {
2202
- #events = [];
2203
- #wake = Promise.withResolvers();
2204
- #ended = false;
2205
- #error;
2206
- #dispose;
2207
- constructor(unsubscribe, signal) {
2208
- const abort = () => this.end(signal?.reason);
2209
- signal?.addEventListener("abort", abort, { once: true });
2210
- this.#dispose = () => {
2211
- signal?.removeEventListener("abort", abort);
2212
- unsubscribe();
2213
- };
2214
- if (signal?.aborted) abort();
2215
- }
2216
- push(event) {
2217
- if (this.#ended) return;
2218
- this.#events.push(event);
2219
- this.#wake.resolve();
2220
- }
2221
- end(error) {
2222
- if (this.#ended) return;
2223
- this.#ended = true;
2224
- this.#error = error;
2225
- this.#wake.resolve();
2226
- }
2227
- [Symbol.dispose]() {
2228
- this.end();
2229
- this.#events = [];
2230
- this.#dispose();
2231
- }
2232
- discard() {
2233
- this.#events = [];
2234
- }
2235
- async *[Symbol.asyncIterator]() {
2236
- for (;;) {
2237
- while (this.#events.length > 0) yield this.#events.shift();
2238
- if (this.#ended) {
2239
- if (this.#error !== void 0) throw this.#error;
2240
- return;
2241
- }
2242
- this.#wake = Promise.withResolvers();
2243
- await this.#wake.promise;
2244
- }
2245
- }
2246
- };
2247
-
2248
2201
  //#endregion
2249
2202
  //#region src/client/eve-agent-projection.ts
2250
2203
  var EveAgentProjection = class {
@@ -2253,18 +2206,21 @@ var EveAgentProjection = class {
2253
2206
  #data;
2254
2207
  constructor(reducer, events) {
2255
2208
  this.#reducer = reducer;
2256
- this.#events = events;
2209
+ this.#events = [...events];
2257
2210
  this.#data = this.#reduce();
2258
2211
  }
2259
2212
  get data() {
2260
2213
  return this.#data;
2261
2214
  }
2215
+ get reducer() {
2216
+ return this.#reducer;
2217
+ }
2262
2218
  reset() {
2263
2219
  this.#events = [];
2264
2220
  this.#data = this.#reducer.initial();
2265
2221
  }
2266
2222
  append(event) {
2267
- this.#events = [...this.#events, event];
2223
+ this.#events.push(event);
2268
2224
  this.#data = this.#reducer.reduce(this.#data, event);
2269
2225
  }
2270
2226
  remove(predicate) {
@@ -2273,7 +2229,8 @@ var EveAgentProjection = class {
2273
2229
  }
2274
2230
  replace(predicate, replacement) {
2275
2231
  const index = this.#events.findIndex(predicate);
2276
- this.#events = index === -1 ? [...this.#events, replacement] : this.#events.map((event, i) => i === index ? replacement : event);
2232
+ if (index === -1) this.#events.push(replacement);
2233
+ else this.#events[index] = replacement;
2277
2234
  this.#data = this.#reduce();
2278
2235
  }
2279
2236
  #reduce() {
@@ -2283,16 +2240,68 @@ var EveAgentProjection = class {
2283
2240
  }
2284
2241
  };
2285
2242
 
2243
+ //#endregion
2244
+ //#region src/client/conversation-state.ts
2245
+ function openConversationInputs(state) {
2246
+ return Object.values(state.inputs).filter((input) => input.status === "open");
2247
+ }
2248
+ function conversationAuthorizations(state) {
2249
+ return state.messages.flatMap((message) => message.role === "assistant" ? message.parts.filter((part) => part.type === "authorization") : []);
2250
+ }
2251
+ function hasPendingAuthorizations(state) {
2252
+ return conversationAuthorizations(state).some((part) => part.state === "required" && part.awaitsCallback === true);
2253
+ }
2254
+ function agentToolTask(state, agent) {
2255
+ const task = agent.taskId === void 0 ? void 0 : state.tasks[agent.taskId];
2256
+ return task?.kind === "agent" ? task : void 0;
2257
+ }
2258
+ function isAgentSessionCaughtUp(state, agent) {
2259
+ if (agent.observation.status !== "following" && agent.observation.status !== "idle") return false;
2260
+ const task = agentToolTask(state, agent);
2261
+ if (task === void 0) return false;
2262
+ const calls = Object.values(task.calls);
2263
+ if (calls.some((call) => call.status === "working")) return false;
2264
+ const child = agent.observation.conversation;
2265
+ if (child.activeTurnId !== void 0) return false;
2266
+ if (Object.values(child.inputs).some((input) => input.status !== "settled")) return false;
2267
+ if (hasPendingAuthorizations(child)) return false;
2268
+ return child.messages.filter((message) => message.role === "user").length >= calls.filter((call) => call.status === "completed").length;
2269
+ }
2270
+
2286
2271
  //#endregion
2287
2272
  //#region src/client/eve-agent-store-helpers.ts
2288
- function isSettledSessionTail(events) {
2273
+ function activeTurnForOptimisticFollowUp(events) {
2274
+ const lastTurn = events.findLast((event) => event.type === "turn.started" || event.type === "turn.completed" || event.type === "turn.failed" || event.type === "turn.cancelled" || isCurrentTurnBoundaryEvent(event));
2275
+ return lastTurn?.type === "turn.started" ? lastTurn.data.turnId : void 0;
2276
+ }
2277
+ function isResponseBoundary(event, conversation) {
2278
+ return endsTurnSegment(event, {
2279
+ callbacks: hasPendingAuthorizations(conversation),
2280
+ requests: Object.values(conversation.inputs).some((input) => input.status !== "settled")
2281
+ });
2282
+ }
2283
+ function settledStatus(error, conversation) {
2284
+ if (error !== void 0) return "error";
2285
+ return conversation.activeTurnId === void 0 ? "ready" : "streaming";
2286
+ }
2287
+ function isSettledSessionTail(events, conversation) {
2289
2288
  const tail = events.at(-1);
2290
- return tail !== void 0 && isCurrentTurnBoundaryEvent(tail) && (tail.type !== "session.waiting" || collectPendingAuthorizations(events).size === 0);
2289
+ return tail !== void 0 && isResponseBoundary(tail, conversation);
2290
+ }
2291
+ function assertAnswerable(input, conversation) {
2292
+ for (const { requestId } of input.inputResponses ?? []) {
2293
+ const status = conversation.inputs[requestId]?.status;
2294
+ if (status !== void 0 && status !== "open") throw new Error(`Input request ${requestId} was already answered.`);
2295
+ }
2296
+ }
2297
+ function assertInFlightFollowUp(input) {
2298
+ if (input.inputResponses !== void 0) return;
2299
+ 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.");
2291
2300
  }
2292
- function collectPendingAuthorizations(events) {
2293
- const pending = /* @__PURE__ */ new Set();
2294
- for (const event of events) updatePendingAuthorizations(pending, event);
2295
- return pending;
2301
+ function validateFollowUp(input) {
2302
+ assertExclusiveTurnInput(input);
2303
+ assertInFlightFollowUp(input);
2304
+ return input;
2296
2305
  }
2297
2306
  function assertExclusiveTurnInput(input) {
2298
2307
  if (input.message !== void 0 === (input.inputResponses !== void 0)) throw new Error("A turn requires exactly one of message or inputResponses.");
@@ -2341,14 +2350,25 @@ function createActiveTurn(cancel) {
2341
2350
  };
2342
2351
  return turn;
2343
2352
  }
2353
+ function countFollowUpDeliveries(turn, reconciliation) {
2354
+ let followed = 0;
2355
+ for (const id of reconciliation.ids) if (turn.followUpSubmissionIds.delete(id)) followed += 1;
2356
+ if (followed === 0) return;
2357
+ if (reconciliation.alreadyProjected) turn.receivedFollowUps += followed;
2358
+ else {
2359
+ const previous = turn.receivedFollowUpEvents.get(reconciliation.event) ?? 0;
2360
+ turn.receivedFollowUpEvents.set(reconciliation.event, previous + followed);
2361
+ }
2362
+ }
2344
2363
  async function followSteeredTurns(turn, events, isActive) {
2345
2364
  while (turn.followUpDispatches.size > 0) await Promise.allSettled(turn.followUpDispatches);
2346
2365
  if (turn.receivedFollowUps >= turn.acceptedFollowUps) return;
2366
+ const segment = new TurnSegment({ followCallbacks: true });
2347
2367
  for await (const event of events) {
2348
2368
  if (!isActive()) return;
2349
2369
  turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
2350
2370
  turn.receivedFollowUpEvents.delete(event);
2351
- if (isCurrentTurnBoundaryEvent(event)) {
2371
+ if (segment.observe(event)) {
2352
2372
  while (turn.followUpDispatches.size > 0) await Promise.allSettled(turn.followUpDispatches);
2353
2373
  if (turn.receivedFollowUps >= turn.acceptedFollowUps) return;
2354
2374
  }
@@ -2371,47 +2391,52 @@ async function waitWithSignal(promise, signal) {
2371
2391
  //#region src/client/optimistic-message-submissions.ts
2372
2392
  var OptimisticMessageSubmissions = class {
2373
2393
  #optimistic;
2374
- #projection;
2394
+ #projections;
2375
2395
  #pending = [];
2376
- constructor(projection, optimistic) {
2377
- this.#projection = projection;
2396
+ constructor(projections, optimistic) {
2397
+ this.#projections = projections;
2378
2398
  this.#optimistic = optimistic;
2379
2399
  }
2380
2400
  reset() {
2381
2401
  this.#pending = [];
2382
2402
  }
2383
- submit(input, eventStartIndex) {
2403
+ submit(input, eventStartIndex, turnId) {
2384
2404
  if (input.message === void 0) return void 0;
2385
2405
  const pending = {
2386
2406
  createdAt: Date.now(),
2387
2407
  eventStartIndex,
2388
2408
  id: createSubmissionId(),
2389
2409
  message: summarizeUserContent(input.message),
2410
+ turnId,
2390
2411
  requiresDeliveryId: true
2391
2412
  };
2392
2413
  this.#pending = [...this.#pending, pending];
2393
- if (this.#optimistic) this.#projection.append({
2414
+ if (this.#optimistic) for (const projection of this.#projections) projection.append({
2394
2415
  data: {
2395
2416
  createdAt: pending.createdAt,
2396
2417
  message: pending.message,
2397
- submissionId: pending.id
2418
+ submissionId: pending.id,
2419
+ turnId
2398
2420
  },
2399
2421
  type: "client.message.submitted"
2400
2422
  });
2401
2423
  return pending.id;
2402
2424
  }
2425
+ resubmit(submissionId, input) {
2426
+ const pending = this.#pending.find((candidate) => candidate.id === submissionId);
2427
+ const message = input.message === void 0 ? void 0 : summarizeUserContent(input.message);
2428
+ if (pending?.message === message) return submissionId;
2429
+ if (pending !== void 0) this.#withdraw([pending.id]);
2430
+ return this.submit(input, pending?.eventStartIndex ?? 0, pending?.turnId);
2431
+ }
2403
2432
  apply(event) {
2404
2433
  if (event.type !== "message.received") {
2405
- this.#projection.append(event);
2406
- return;
2407
- }
2408
- if (event.data.kind === "execution.background_task") {
2409
- this.#projection.append(event);
2434
+ for (const projection of this.#projections) projection.append(event);
2410
2435
  return;
2411
2436
  }
2412
2437
  const matching = this.#matching(event);
2413
2438
  if (matching.length === 0) {
2414
- this.#projection.append(event);
2439
+ for (const projection of this.#projections) projection.append(event);
2415
2440
  return;
2416
2441
  }
2417
2442
  return this.#reconcile(matching, event, false);
@@ -2426,7 +2451,7 @@ var OptimisticMessageSubmissions = class {
2426
2451
  const pending = this.#pending.find((candidate) => candidate.id === submissionId);
2427
2452
  if (pending === void 0) return void 0;
2428
2453
  for (const event of events.slice(pending.eventStartIndex)) {
2429
- if (event.type !== "message.received" || event.data.kind === "execution.background_task") continue;
2454
+ if (event.type !== "message.received") continue;
2430
2455
  const matching = this.#matching(event);
2431
2456
  if (matching.some((candidate) => candidate.id === submissionId)) return this.#reconcile(matching, event, true);
2432
2457
  }
@@ -2435,12 +2460,13 @@ var OptimisticMessageSubmissions = class {
2435
2460
  const pending = submissionId === void 0 ? this.#pending[0] : this.#pending.find((candidate) => candidate.id === submissionId);
2436
2461
  if (pending === void 0) return;
2437
2462
  this.#pending = this.#pending.filter((candidate) => candidate.id !== pending.id);
2438
- this.#projection.replace((event) => event.type === "client.message.submitted" && event.data.submissionId === pending.id, {
2463
+ for (const projection of this.#projections) projection.replace((event) => event.type === "client.message.submitted" && event.data.submissionId === pending.id, {
2439
2464
  data: {
2440
2465
  createdAt: pending.createdAt,
2441
2466
  error: { message: error.message },
2442
2467
  message: pending.message,
2443
- submissionId: pending.id
2468
+ submissionId: pending.id,
2469
+ turnId: pending.turnId
2444
2470
  },
2445
2471
  type: "client.message.failed"
2446
2472
  });
@@ -2453,1134 +2479,1833 @@ var OptimisticMessageSubmissions = class {
2453
2479
  }
2454
2480
  #reconcile(submissions, event, alreadyProjected) {
2455
2481
  const ids = submissions.map((pending) => pending.id);
2456
- const idSet = new Set(ids);
2457
- this.#pending = this.#pending.filter((pending) => !idSet.has(pending.id));
2458
- if (alreadyProjected) this.#projection.remove((candidate) => candidate.type === "client.message.submitted" && idSet.has(candidate.data.submissionId));
2459
- else {
2460
- this.#projection.replace((candidate) => candidate.type === "client.message.submitted" && candidate.data.submissionId === ids[0], event);
2461
- this.#projection.remove((candidate) => candidate.type === "client.message.submitted" && idSet.has(candidate.data.submissionId));
2462
- }
2482
+ this.#withdraw(ids);
2483
+ if (!alreadyProjected) for (const projection of this.#projections) projection.append(event);
2463
2484
  return {
2464
2485
  alreadyProjected,
2465
2486
  event,
2466
2487
  ids
2467
2488
  };
2468
2489
  }
2490
+ #withdraw(ids) {
2491
+ const idSet = new Set(ids);
2492
+ this.#pending = this.#pending.filter((pending) => !idSet.has(pending.id));
2493
+ for (const projection of this.#projections) projection.remove((candidate) => candidate.type === "client.message.submitted" && idSet.has(candidate.data.submissionId));
2494
+ }
2469
2495
  };
2470
2496
 
2471
2497
  //#endregion
2472
- //#region src/protocol/event-dedupe.ts
2473
- function createEventDeduper() {
2474
- const seen = /* @__PURE__ */ new Set();
2475
- return {
2476
- admit(event) {
2477
- const id = event.meta?.id;
2478
- if (id === void 0) return true;
2479
- if (seen.has(id)) return false;
2480
- seen.add(id);
2481
- return true;
2482
- },
2483
- get size() {
2484
- return seen.size;
2498
+ //#region src/client/agent-stream-follower.ts
2499
+ const agentStreamReconnectPolicy = {
2500
+ streamIdleReconnectPolicy: { maxAttempts: Infinity },
2501
+ streamOpenReconnectPolicy: { maxAttempts: Infinity }
2502
+ };
2503
+ var AgentStreamFollower = class {
2504
+ #options;
2505
+ #started = /* @__PURE__ */ new Map();
2506
+ #controllers = /* @__PURE__ */ new Map();
2507
+ #failed = /* @__PURE__ */ new Set();
2508
+ #disposed = false;
2509
+ constructor(options) {
2510
+ this.#options = options;
2511
+ }
2512
+ acceptParentEvent(event) {
2513
+ if (event.type === "agent.started") this.#started.set(event.data.sessionId, event);
2514
+ }
2515
+ reconcile() {
2516
+ if (this.#disposed) return;
2517
+ const state = this.#options.getState();
2518
+ for (const agent of Object.values(state.agents)) {
2519
+ if (agentToolTask(state, agent) === void 0) continue;
2520
+ const controller = this.#controllers.get(agent.sessionId);
2521
+ const caughtUp = isAgentSessionCaughtUp(state, agent);
2522
+ if (controller !== void 0 && caughtUp) {
2523
+ this.#controllers.delete(agent.sessionId);
2524
+ controller.abort();
2525
+ this.#options.onIdle(agent.sessionId);
2526
+ } else if (controller === void 0 && !caughtUp && !this.#failed.has(agent.sessionId)) this.#follow(agent.sessionId);
2485
2527
  }
2486
- };
2487
- }
2488
-
2489
- //#endregion
2490
- //#region src/client/eve-agent-store.ts
2491
- const detachStore = Symbol("detachEveAgentStore");
2492
- const attachStore = Symbol("attachEveAgentStore");
2493
- var EveAgentStore = class {
2494
- #client;
2495
- #autoPrewarm;
2496
- #attached = false;
2497
- #stream;
2498
- #pendingAuthorizations = /* @__PURE__ */ new Set();
2499
- #externalSession;
2500
- #optimistic;
2501
- #projection;
2502
- #subscribers = /* @__PURE__ */ new Set();
2503
- #seenEvents = createEventDeduper();
2504
- #activeTurn;
2505
- #callbacks = {};
2506
- #error;
2507
- #events;
2508
- #messageSubmissions;
2509
- #prewarmGeneration = 0;
2510
- #prewarmPromise;
2511
- #prewarmController;
2512
- #resumePromise;
2513
- #session;
2514
- #snapshot;
2515
- #status = "ready";
2516
- constructor(init) {
2517
- this.#autoPrewarm = init.prewarm ?? false;
2518
- this.#externalSession = init.session !== void 0;
2519
- this.#client = this.#externalSession ? void 0 : new Client({
2520
- auth: init.auth,
2521
- headers: init.headers,
2522
- host: init.host ?? ""
2523
- });
2524
- const initialEvents = [];
2525
- for (const event of init.initialEvents ?? []) {
2526
- if (this.#seenEvents.admit(event)) initialEvents.push(event);
2527
- updatePendingAuthorizations(this.#pendingAuthorizations, event);
2528
- }
2529
- this.#events = initialEvents;
2530
- this.#projection = new EveAgentProjection(init.reducer, this.#events);
2531
- this.#optimistic = init.optimistic ?? true;
2532
- this.#messageSubmissions = new OptimisticMessageSubmissions(this.#projection, this.#optimistic);
2533
- this.#session = init.session ?? (init.initialSession === void 0 ? void 0 : this.#client?.sessions.attach(init.initialSession.sessionId, { streamIndex: init.initialSession.streamIndex }));
2534
- this.#snapshot = this.#createSnapshot();
2535
- }
2536
- get snapshot() {
2537
- return this.#snapshot;
2538
- }
2539
- setCallbacks(callbacks) {
2540
- this.#callbacks = callbacks;
2541
2528
  }
2542
- subscribe(callback) {
2543
- this.#subscribers.add(callback);
2544
- return () => {
2545
- this.#subscribers.delete(callback);
2546
- };
2529
+ abortAll() {
2530
+ this.#disposed = true;
2531
+ for (const controller of this.#controllers.values()) controller.abort();
2532
+ this.#controllers.clear();
2547
2533
  }
2548
- prewarm() {
2549
- if (this.#prewarmPromise !== void 0) return this.#prewarmPromise;
2550
- if (this.#session !== void 0 || this.#externalSession) return Promise.resolve();
2551
- if (this.#activeTurn !== void 0) return this.#activeTurn.response.then((response) => {
2552
- if (response === void 0) throw this.#error ?? new DOMException("Session creation was aborted.", "AbortError");
2553
- });
2554
- const client = this.#client;
2555
- if (client === void 0) return Promise.reject(/* @__PURE__ */ new Error("This eve agent store does not own a session client."));
2556
- const generation = this.#prewarmGeneration;
2534
+ #follow(sessionId) {
2535
+ const started = this.#started.get(sessionId);
2536
+ if (started === void 0) return;
2557
2537
  const controller = new AbortController();
2558
- this.#prewarmController = controller;
2559
- const promise = (async () => {
2538
+ this.#controllers.set(sessionId, controller);
2539
+ this.#options.onFollowing(sessionId);
2540
+ const { cursors } = this.#options;
2541
+ (async () => {
2542
+ let cursor = cursors.get(sessionId) ?? 0;
2560
2543
  try {
2561
- const created = await client.sessions.create({ signal: controller.signal });
2562
- if (generation !== this.#prewarmGeneration) return;
2563
- this.#session = created.session;
2564
- this.#error = void 0;
2565
- if (this.#status === "error") this.#status = "ready";
2566
- this.#callbacks.onSessionChange?.(created.session.state);
2567
- this.#publish();
2568
- this.#ensureStream();
2569
- } catch (error) {
2570
- if (generation === this.#prewarmGeneration && this.#activeTurn === void 0 && this.#error === void 0) {
2571
- this.#error = toError(error);
2572
- this.#status = "error";
2573
- this.#callbacks.onError?.(this.#error);
2574
- this.#publish();
2544
+ for await (const event of this.#options.session.agent(started).stream({
2545
+ signal: controller.signal,
2546
+ startIndex: cursor,
2547
+ streamReconnectPolicy: agentStreamReconnectPolicy
2548
+ })) {
2549
+ if (controller.signal.aborted) return;
2550
+ cursors.set(sessionId, ++cursor);
2551
+ this.#options.onEvent(sessionId, event);
2552
+ this.reconcile();
2575
2553
  }
2576
- throw error;
2577
- }
2554
+ } catch {}
2555
+ if (controller.signal.aborted || this.#controllers.get(sessionId) !== controller) return;
2556
+ this.#controllers.delete(sessionId);
2557
+ this.#failed.add(sessionId);
2558
+ this.#options.onUnavailable(sessionId);
2578
2559
  })();
2579
- this.#prewarmPromise = promise;
2580
- const clear = () => {
2581
- if (this.#prewarmPromise === promise) {
2582
- this.#prewarmPromise = void 0;
2583
- this.#prewarmController = void 0;
2584
- }
2585
- };
2586
- promise.then(clear, clear);
2587
- return promise;
2588
2560
  }
2589
- async send(input) {
2590
- return await this.#submit(input, this.#callbacks.prepareSend);
2561
+ };
2562
+
2563
+ //#endregion
2564
+ //#region src/client/authorization-message-parts.ts
2565
+ function createAuthorizationRequiredPart(event) {
2566
+ const displayName = event.data.authorization?.displayName ?? formatAuthorizationDisplayName(event.data.name);
2567
+ const part = {
2568
+ authorization: event.data.authorization,
2569
+ description: normalizeAuthorizationDescription(event.data.description, event.data.name, displayName),
2570
+ displayName,
2571
+ name: event.data.name,
2572
+ state: "required",
2573
+ stepIndex: event.data.stepIndex,
2574
+ turnId: event.data.turnId,
2575
+ type: "authorization"
2576
+ };
2577
+ if (event.data.attemptId !== void 0) part.attemptId = event.data.attemptId;
2578
+ if (event.data.webhookUrl !== void 0) part.awaitsCallback = true;
2579
+ return part;
2580
+ }
2581
+ function createAuthorizationCompletedPart(event, existing) {
2582
+ const displayName = event.data.authorization?.displayName ?? existing?.displayName ?? formatAuthorizationDisplayName(event.data.name);
2583
+ const part = {
2584
+ authorization: existing?.authorization || event.data.authorization ? {
2585
+ ...existing?.authorization,
2586
+ ...event.data.authorization
2587
+ } : void 0,
2588
+ description: existing?.description ?? buildCompletedAuthorizationDescription(displayName, event.data.outcome, event.data.reason),
2589
+ displayName,
2590
+ name: event.data.name,
2591
+ outcome: event.data.outcome,
2592
+ state: "completed",
2593
+ stepIndex: existing?.stepIndex ?? event.data.stepIndex,
2594
+ turnId: existing?.turnId ?? event.data.turnId,
2595
+ type: "authorization"
2596
+ };
2597
+ const attemptId = event.data.attemptId ?? existing?.attemptId;
2598
+ if (attemptId !== void 0) part.attemptId = attemptId;
2599
+ if (existing?.awaitsCallback) part.awaitsCallback = true;
2600
+ if (event.data.reason !== void 0) part.reason = event.data.reason;
2601
+ return part;
2602
+ }
2603
+ function buildCompletedAuthorizationDescription(displayName, outcome, reason) {
2604
+ if (outcome === "authorized") return `${displayName} connected.`;
2605
+ return `${displayName} authorization ${outcome}${reason !== void 0 ? ` (${reason})` : ""}.`;
2606
+ }
2607
+ function normalizeAuthorizationDescription(description, name, displayName) {
2608
+ if (description === `Authorization required for ${name}`) return `Authorization required for ${displayName}`;
2609
+ return description;
2610
+ }
2611
+ function formatAuthorizationDisplayName(name) {
2612
+ if (name.length === 0) return name;
2613
+ return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
2614
+ }
2615
+
2616
+ //#endregion
2617
+ //#region src/shared/action-request-name.ts
2618
+ function actionRequestName(action) {
2619
+ switch (action.kind) {
2620
+ case "load-skill": return "load_skill";
2621
+ case "subagent-call": return action.subagentName;
2622
+ case "remote-agent-call": return action.remoteAgentName;
2623
+ case "tool-call":
2624
+ case "workflow-tool-call": return action.toolName;
2591
2625
  }
2592
- async #submit(input, prepareSend) {
2593
- if (this.#activeTurn !== void 0) {
2594
- if (this.#status === "resuming") throw new Error("eve session is resuming.");
2595
- return await this.#sendFollowUp(this.#activeTurn, input, prepareSend);
2596
- }
2597
- 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()));
2598
- this.#activeTurn = turn;
2599
- this.#error = void 0;
2600
- this.#status = "submitted";
2601
- this.#publish();
2602
- let reader;
2603
- try {
2604
- const preparedInput = await (prepareSend === void 0 ? input : waitWithSignal(Promise.resolve(prepareSend(input)), createAbortSignal(input.signal, turn.abortController.signal)));
2605
- assertExclusiveTurnInput(preparedInput);
2606
- if (!this.#isActiveTurn(turn)) return;
2607
- const submissionId = this.#messageSubmissions.submit(preparedInput, this.#events.length);
2608
- this.#projectInputResponses(preparedInput);
2609
- this.#publish();
2610
- const turnInput = {
2611
- ...preparedInput,
2612
- signal: createAbortSignal(preparedInput.signal, turn.abortController.signal)
2613
- };
2614
- const dispatched = await this.#dispatchTurn(turnInput);
2615
- const response = dispatched.response;
2616
- reader = dispatched.reader;
2617
- if (!this.#isActiveTurn(turn)) return;
2618
- turn.resolveResponse(response);
2619
- if (this.#handleReconciliation(this.#messageSubmissions.correlate(submissionId, getMessageResponseDeliveryId(response), this.#events))) this.#publish();
2620
- for await (const event of consumeMessageResponse(response, reader)) {
2621
- if (!this.#isActiveTurn(turn)) return;
2622
- turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
2623
- turn.receivedFollowUpEvents.delete(event);
2624
- }
2625
- if (!this.#isActiveTurn(turn)) return;
2626
- await followSteeredTurns(turn, reader, () => this.#isActiveTurn(turn));
2627
- if (!this.#isActiveTurn(turn)) return;
2628
- this.#status = this.#error === void 0 ? "ready" : "error";
2629
- } catch (error) {
2630
- if (!this.#isActiveTurn(turn)) return;
2631
- if (isAbortError(error)) {
2632
- this.#status = "ready";
2633
- this.#messageSubmissions.fail(toError(error));
2634
- } else {
2635
- const reported = this.#error !== void 0;
2636
- this.#error ??= toError(error);
2637
- this.#status = "error";
2638
- this.#messageSubmissions.fail(this.#error);
2639
- if (!reported) this.#callbacks.onError?.(this.#error);
2640
- }
2641
- } finally {
2642
- reader?.[Symbol.dispose]();
2643
- this.#finishTurn(turn);
2644
- }
2645
- }
2646
- resume() {
2647
- if (this.#resumePromise !== void 0) return this.#resumePromise;
2648
- const promise = this.#resume();
2649
- this.#resumePromise = promise;
2650
- const clear = () => {
2651
- if (this.#resumePromise === promise) this.#resumePromise = void 0;
2626
+ }
2627
+
2628
+ //#endregion
2629
+ //#region src/client/message-action-parts.ts
2630
+ function toMessageInputRequest(request) {
2631
+ return {
2632
+ allowFreeform: request.allowFreeform,
2633
+ display: request.display,
2634
+ kind: request.kind,
2635
+ options: request.options,
2636
+ prompt: request.prompt,
2637
+ requestId: request.requestId
2638
+ };
2639
+ }
2640
+ function createToolMetadata(descriptor, extra) {
2641
+ return { eve: {
2642
+ inputRequest: extra?.inputRequest,
2643
+ kind: descriptor.kind,
2644
+ name: descriptor.name
2645
+ } };
2646
+ }
2647
+ function mergeToolMetadata(current, next) {
2648
+ const kind = next.eve?.kind ?? current?.eve?.kind ?? "unknown";
2649
+ const name = next.eve?.name ?? current?.eve?.name ?? "unknown";
2650
+ return { eve: {
2651
+ ...current?.eve,
2652
+ ...next.eve,
2653
+ inputRequest: next.eve?.inputRequest ?? current?.eve?.inputRequest,
2654
+ inputResponse: next.eve?.inputResponse ?? current?.eve?.inputResponse,
2655
+ kind,
2656
+ name
2657
+ } };
2658
+ }
2659
+ function approvedApproval(part) {
2660
+ if (!part?.approval?.id) return;
2661
+ return {
2662
+ approved: true,
2663
+ id: part.approval.id,
2664
+ isAutomatic: part.approval.isAutomatic,
2665
+ reason: part.approval.reason
2666
+ };
2667
+ }
2668
+ function normalizeActionRequest(action) {
2669
+ const name = actionRequestName(action);
2670
+ switch (action.kind) {
2671
+ case "load-skill": return {
2672
+ kind: "load-skill",
2673
+ name,
2674
+ toolName: "eve:load-skill"
2675
+ };
2676
+ case "tool-call":
2677
+ case "workflow-tool-call": return {
2678
+ kind: "tool-call",
2679
+ name,
2680
+ toolName: name
2681
+ };
2682
+ case "subagent-call":
2683
+ case "remote-agent-call": return {
2684
+ kind: "subagent-call",
2685
+ name,
2686
+ toolName: `eve:subagent:${name}`
2652
2687
  };
2653
- promise.then(clear, clear);
2654
- return promise;
2655
- }
2656
- async #resume() {
2657
- if (this.#status === "resuming" || this.#status === "streaming" || this.#status === "submitted") throw new Error("eve session is already processing a turn.");
2658
- if (this.#session === void 0) throw new Error("An eve session is required before resuming.");
2659
- const session = this.#session;
2660
- const turn = createActiveTurn(() => session.cancel());
2661
- this.#activeTurn = turn;
2662
- turn.resolveResponse(void 0);
2663
- this.#error = void 0;
2664
- this.#status = "resuming";
2665
- this.#publish();
2666
- let reader;
2667
- try {
2668
- const stream = this.#ensureStream({
2669
- catchUp: true,
2670
- startIndex: this.#events.length === session.state.streamIndex ? session.state.streamIndex : 0
2671
- });
2672
- reader = stream.subscribe(turn.abortController.signal);
2673
- await stream.caughtUp;
2674
- if (!this.#isActiveTurn(turn)) return;
2675
- reader.discard();
2676
- const tail = this.#events.at(-1);
2677
- if (tail !== void 0) this.#applyTerminalStreamFailure(tail);
2678
- if (tail !== void 0 && this.#error === void 0 && !isSettledSessionTail(this.#events)) {
2679
- this.#status = "streaming";
2680
- this.#publish();
2681
- for await (const event of reader) {
2682
- if (!this.#isActiveTurn(turn)) return;
2683
- turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
2684
- turn.receivedFollowUpEvents.delete(event);
2685
- if (isCurrentTurnBoundaryEvent(event) && this.#pendingAuthorizations.size === 0) break;
2686
- }
2687
- }
2688
- await followSteeredTurns(turn, reader, () => this.#isActiveTurn(turn));
2689
- if (this.#isActiveTurn(turn)) this.#status = this.#error === void 0 ? "ready" : "error";
2690
- } catch (error) {
2691
- if (!this.#isActiveTurn(turn)) return;
2692
- if (isAbortError(error)) this.#status = "ready";
2693
- else {
2694
- this.#error = toError(error);
2695
- this.#status = "error";
2696
- this.#callbacks.onError?.(this.#error);
2697
- }
2698
- } finally {
2699
- reader?.[Symbol.dispose]();
2700
- this.#finishTurn(turn);
2701
- }
2702
2688
  }
2703
- cancel() {
2704
- const turn = this.#activeTurn;
2705
- if (turn === void 0) return this.#status === "streaming" && this.#session !== void 0 ? this.#session.cancel() : Promise.resolve({ status: "no_active_turn" });
2706
- return turn.cancel();
2689
+ }
2690
+ function normalizeActionResult(result) {
2691
+ switch (result.kind) {
2692
+ case "load-skill-result": return {
2693
+ kind: "load-skill",
2694
+ name: result.name ?? "load_skill",
2695
+ toolName: "eve:load-skill"
2696
+ };
2697
+ case "tool-result": return {
2698
+ kind: "tool-call",
2699
+ name: result.toolName,
2700
+ toolName: result.toolName
2701
+ };
2702
+ case "subagent-result": return {
2703
+ kind: "subagent-call",
2704
+ name: result.subagentName,
2705
+ toolName: `eve:subagent:${result.subagentName}`
2706
+ };
2707
2707
  }
2708
- [attachStore]() {
2709
- this.#attached = true;
2710
- if (this.#autoPrewarm && this.#session === void 0) this.prewarm().catch(() => {});
2708
+ }
2709
+ function stringifyUnknown(value) {
2710
+ if (typeof value === "string") return value;
2711
+ try {
2712
+ return JSON.stringify(value);
2713
+ } catch {
2714
+ return "Action failed.";
2711
2715
  }
2712
- [detachStore]() {
2713
- this.#attached = false;
2714
- this.#stream?.close();
2715
- this.#stream = void 0;
2716
- this.#activeTurn?.abortController.abort();
2717
- this.#resetPrewarm();
2718
- this.#resumePromise = void 0;
2716
+ }
2717
+
2718
+ //#endregion
2719
+ //#region src/client/message-reducer-primitives.ts
2720
+ function projectReceivedParts(parts, message) {
2721
+ return parts?.map((part) => part.type === "text" ? {
2722
+ state: "done",
2723
+ text: part.text,
2724
+ type: "text"
2725
+ } : {
2726
+ filename: part.filename,
2727
+ mediaType: part.mediaType,
2728
+ size: part.size,
2729
+ type: "file",
2730
+ url: part.url
2731
+ }) ?? [{
2732
+ state: "done",
2733
+ text: message,
2734
+ type: "text"
2735
+ }];
2736
+ }
2737
+ function partKey(part) {
2738
+ switch (part.type) {
2739
+ case "text": return `text:${part.stepIndex ?? 0}`;
2740
+ case "reasoning": return `reasoning:${part.stepIndex ?? 0}`;
2741
+ case "file": return `file:${part.stepIndex ?? 0}:${part.filename ?? part.url ?? part.mediaType}`;
2742
+ case "step-start": return "step-start";
2743
+ case "authorization": return part.attemptId === void 0 ? `authorization:${part.turnId}:${part.stepIndex}:${part.name}` : `authorization:${part.attemptId}`;
2744
+ case "dynamic-tool": return `dynamic-tool:${part.toolCallId}`;
2719
2745
  }
2720
- reset() {
2721
- this.#stream?.close();
2722
- this.#stream = void 0;
2723
- this.#pendingAuthorizations.clear();
2724
- const turn = this.#activeTurn;
2725
- this.#activeTurn = void 0;
2726
- turn?.resolveResponse(void 0);
2727
- turn?.resolveCompletion();
2728
- turn?.abortController.abort();
2729
- this.#resetPrewarm();
2730
- this.#resumePromise = void 0;
2731
- if (!this.#externalSession) this.#session = void 0;
2732
- this.#events = [];
2733
- this.#seenEvents = createEventDeduper();
2734
- this.#messageSubmissions.reset();
2735
- this.#projection.reset();
2736
- this.#error = void 0;
2737
- this.#status = "ready";
2738
- this.#callbacks.onSessionChange?.(this.#session?.state);
2739
- this.#publish();
2740
- if (this.#autoPrewarm && this.#attached) this.prewarm().catch(() => {});
2746
+ }
2747
+ function upsertMessage(data, next, beforeAssistantTurnId) {
2748
+ const index = data.messages.findIndex((message) => message.id === next.id);
2749
+ if (index !== -1) return {
2750
+ ...data,
2751
+ messages: [
2752
+ ...data.messages.slice(0, index),
2753
+ next,
2754
+ ...data.messages.slice(index + 1)
2755
+ ]
2756
+ };
2757
+ const before = beforeAssistantTurnId === void 0 ? -1 : data.messages.findIndex((message) => message.role === "assistant" && message.metadata?.turnId === beforeAssistantTurnId);
2758
+ if (before === -1) return {
2759
+ ...data,
2760
+ messages: [...data.messages, next]
2761
+ };
2762
+ return {
2763
+ ...data,
2764
+ messages: [
2765
+ ...data.messages.slice(0, before),
2766
+ next,
2767
+ ...data.messages.slice(before)
2768
+ ]
2769
+ };
2770
+ }
2771
+ function optimisticUserMessageId(submissionId) {
2772
+ return `optimistic:${submissionId}:user`;
2773
+ }
2774
+
2775
+ //#endregion
2776
+ //#region src/client/message-run-parts.ts
2777
+ function transition(message, input) {
2778
+ const index = message.parts.findLastIndex((part) => part.type === input.type && part.stepIndex === input.stepIndex);
2779
+ const previous = index === -1 ? void 0 : message.parts[index];
2780
+ if (input.kind === "append" && !input.delta) return message;
2781
+ const current = previous?.state === "streaming" ? previous : void 0;
2782
+ const part = {
2783
+ id: current?.id ?? input.id ?? `${message.id}:${input.type}:${message.parts.length}`,
2784
+ state: input.kind === "append" ? "streaming" : "done",
2785
+ stepIndex: input.stepIndex,
2786
+ text: input.kind === "append" ? (current?.text ?? "") + input.delta : input.text,
2787
+ type: input.type
2788
+ };
2789
+ const parts = current ? [
2790
+ ...message.parts.slice(0, index),
2791
+ part,
2792
+ ...message.parts.slice(index + 1)
2793
+ ] : [...message.parts, part];
2794
+ return {
2795
+ ...message,
2796
+ metadata: {
2797
+ ...message.metadata,
2798
+ status: input.type === "text" && part.state === "done" ? "complete" : "streaming"
2799
+ },
2800
+ parts
2801
+ };
2802
+ }
2803
+ const messageRun = { transition };
2804
+
2805
+ //#endregion
2806
+ //#region src/client/message-task-parts.ts
2807
+ function createSettledTaskPart(existing, event) {
2808
+ const settledPartBase = {
2809
+ approval: approvedApproval(existing),
2810
+ input: existing.input,
2811
+ stepIndex: existing.stepIndex,
2812
+ toolCallId: existing.toolCallId,
2813
+ toolMetadata: existing.toolMetadata,
2814
+ toolName: existing.toolName,
2815
+ type: "dynamic-tool"
2816
+ };
2817
+ switch (event.data.status) {
2818
+ case "completed": return {
2819
+ ...settledPartBase,
2820
+ output: event.data.output,
2821
+ state: "output-available"
2822
+ };
2823
+ case "failed": return {
2824
+ ...settledPartBase,
2825
+ errorText: event.data.error?.message ?? "Task failed.",
2826
+ state: "output-error"
2827
+ };
2828
+ case "cancelled": return {
2829
+ ...settledPartBase,
2830
+ errorText: "Task was cancelled.",
2831
+ state: "output-error"
2832
+ };
2741
2833
  }
2742
- async #sendFollowUp(turn, input, prepareSend) {
2743
- 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.");
2744
- const generation = this.#prewarmGeneration;
2745
- const signal = createAbortSignal(input.signal, turn.abortController.signal);
2746
- const preparedInput = await waitWithSignal(Promise.resolve(prepareSend?.(input)), signal) ?? input;
2747
- if (generation !== this.#prewarmGeneration) return;
2748
- assertExclusiveTurnInput(preparedInput);
2749
- if (preparedInput.message === void 0 || preparedInput.turnPolicy !== "steer") throw new Error("An in-flight follow-up requires a message with turnPolicy: \"steer\".");
2750
- if (!this.#isActiveTurn(turn)) return await this.#submit(preparedInput);
2751
- const submissionId = this.#messageSubmissions.submit(preparedInput, this.#events.length);
2752
- if (submissionId !== void 0) turn.followUpSubmissionIds.add(submissionId);
2753
- this.#publish();
2754
- this.#ensureStream({
2755
- headers: preparedInput.headers,
2756
- streamReconnectPolicy: preparedInput.streamReconnectPolicy
2757
- });
2758
- let dispatch;
2759
- dispatch = (async () => {
2760
- try {
2761
- const signal = createAbortSignal(preparedInput.signal, turn.abortController.signal);
2762
- await waitWithSignal(turn.response, signal);
2763
- if (!this.#isActiveTurn(turn) || this.#session === void 0) throw new Error("The active eve turn ended before the follow-up could be sent.");
2764
- const { message, ...options } = preparedInput;
2765
- const response = await this.#session.send(message, {
2766
- ...options,
2767
- signal
2768
- });
2769
- turn.acceptedFollowUps += 1;
2770
- if (this.#handleReconciliation(this.#messageSubmissions.correlate(submissionId, getMessageResponseDeliveryId(response), this.#events))) this.#publish();
2771
- } catch (error) {
2772
- if (this.#isActiveTurn(turn)) {
2773
- this.#messageSubmissions.fail(toError(error), submissionId);
2774
- this.#publish();
2775
- }
2776
- throw error;
2777
- } finally {
2778
- turn.followUpDispatches.delete(dispatch);
2834
+ }
2835
+
2836
+ //#endregion
2837
+ //#region src/client/message-reducer.ts
2838
+ function receivedMessageEventId(event) {
2839
+ return event.meta.id ?? `${event.data.turnId}:${event.data.sequence}`;
2840
+ }
2841
+ function defaultMessageReducer() {
2842
+ return {
2843
+ initial() {
2844
+ return { messages: [] };
2845
+ },
2846
+ reduce(data, event) {
2847
+ return reduceMessageData(data, event);
2848
+ }
2849
+ };
2850
+ }
2851
+ function reduceMessageData(data, event) {
2852
+ switch (event.type) {
2853
+ case "client.message.submitted":
2854
+ case "client.message.failed": return upsertMessage(data, {
2855
+ id: optimisticUserMessageId(event.data.submissionId),
2856
+ metadata: {
2857
+ optimistic: true,
2858
+ status: event.type === "client.message.failed" ? "failed" : "submitted"
2859
+ },
2860
+ parts: [{
2861
+ type: "text",
2862
+ text: event.data.message
2863
+ }],
2864
+ role: "user"
2865
+ }, event.data.turnId);
2866
+ case "input.resolved": {
2867
+ let next = data;
2868
+ for (const resolution of event.data.resolutions) next = resolveInputRequest(next, resolution);
2869
+ return next;
2870
+ }
2871
+ case "message.received": return upsertMessage(data, {
2872
+ id: `${receivedMessageEventId(event)}:user`,
2873
+ metadata: {
2874
+ status: "complete",
2875
+ turnId: event.data.turnId
2876
+ },
2877
+ parts: projectReceivedParts(event.data.parts, event.data.message),
2878
+ role: "user"
2879
+ }, event.data.turnId);
2880
+ case "step.started": return updateAssistantMessage(data, event.data.turnId, (message) => ensureStepStartPart(message, event.data.stepIndex));
2881
+ case "step.completed":
2882
+ if (data.messages.find((message) => message.role === "assistant" && message.metadata?.turnId === event.data.turnId) === void 0) return data;
2883
+ return updateAssistantMessage(data, event.data.turnId, (message) => ({
2884
+ ...message,
2885
+ parts: closeStreamingRuns(message.parts, event.data.stepIndex)
2886
+ }));
2887
+ case "reasoning.appended": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.transition(ensureStepStartPart(message, event.data.stepIndex), {
2888
+ kind: "append",
2889
+ delta: event.data.reasoningDelta,
2890
+ id: event.meta?.id,
2891
+ stepIndex: event.data.stepIndex,
2892
+ type: "reasoning"
2893
+ }));
2894
+ case "reasoning.completed": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.transition(ensureStepStartPart(message, event.data.stepIndex), {
2895
+ kind: "complete",
2896
+ stepIndex: event.data.stepIndex,
2897
+ text: event.data.reasoning,
2898
+ id: event.meta?.id,
2899
+ type: "reasoning"
2900
+ }));
2901
+ case "action.input.appended": {
2902
+ const existing = findToolPart(data, event.data.callId);
2903
+ if (existing !== void 0 && existing.state !== "input-streaming") return data;
2904
+ const nextPart = {
2905
+ input: void 0,
2906
+ inputText: (existing?.state === "input-streaming" ? existing.inputText : "") + event.data.inputTextDelta,
2907
+ state: "input-streaming",
2908
+ stepIndex: event.data.stepIndex,
2909
+ toolCallId: event.data.callId,
2910
+ toolMetadata: existing?.toolMetadata ?? { eve: {
2911
+ kind: "unknown",
2912
+ name: event.data.toolName
2913
+ } },
2914
+ toolName: event.data.toolName,
2915
+ type: "dynamic-tool"
2916
+ };
2917
+ return upsertToolPart(data, event.data.turnId, event.data.stepIndex, nextPart);
2918
+ }
2919
+ case "actions.requested": {
2920
+ let next = data;
2921
+ for (const action of event.data.actions) {
2922
+ const existing = findToolPart(next, action.callId);
2923
+ if (existing !== void 0 && existing.state !== "input-streaming") continue;
2924
+ const descriptor = normalizeActionRequest(action);
2925
+ next = updateAssistantMessage(next, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
2926
+ input: "input" in action ? action.input : void 0,
2927
+ state: "input-available",
2928
+ stepIndex: event.data.stepIndex,
2929
+ toolCallId: action.callId,
2930
+ toolMetadata: createToolMetadata(descriptor),
2931
+ toolName: descriptor.toolName,
2932
+ type: "dynamic-tool"
2933
+ }));
2779
2934
  }
2780
- })();
2781
- turn.followUpDispatches.add(dispatch);
2782
- await dispatch;
2783
- await turn.completion;
2784
- }
2785
- async #dispatchTurn(input) {
2786
- const streamOptions = {
2787
- headers: input.headers,
2788
- streamReconnectPolicy: input.streamReconnectPolicy
2789
- };
2790
- if (this.#prewarmPromise !== void 0) {
2791
- await waitWithSignal(this.#prewarmPromise.catch((error) => {
2792
- if (this.#session !== void 0) throw error;
2793
- }), input.signal);
2794
- input.signal?.throwIfAborted();
2935
+ return next;
2795
2936
  }
2796
- if (this.#session === void 0) {
2797
- if (this.#client === void 0) throw new Error("An external eve session is required before sending.");
2798
- if (input.message === void 0) throw new Error("Cannot answer an input request before the session starts.");
2799
- const created = await this.#client.sessions.create({
2800
- ...input,
2801
- message: input.message
2937
+ case "input.requested": {
2938
+ let next = data;
2939
+ for (const request of event.data.requests) {
2940
+ const existing = findToolPart(next, request.action.callId);
2941
+ if (existing?.approval?.id === request.requestId || existing !== void 0 && isSettledToolPart(existing)) continue;
2942
+ const descriptor = normalizeActionRequest(request.action);
2943
+ next = updateAssistantMessage(next, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
2944
+ approval: { id: request.requestId },
2945
+ input: request.action.input,
2946
+ state: "approval-requested",
2947
+ stepIndex: event.data.stepIndex,
2948
+ toolCallId: request.action.callId,
2949
+ toolMetadata: createToolMetadata(descriptor, { inputRequest: toMessageInputRequest(request) }),
2950
+ toolName: descriptor.toolName,
2951
+ type: "dynamic-tool"
2952
+ }));
2953
+ }
2954
+ return next;
2955
+ }
2956
+ case "approval.candidate": return data;
2957
+ case "approval.settled": {
2958
+ const existing = findToolPartByApprovalId(data, event.data.requestId);
2959
+ if (existing === void 0) return data;
2960
+ if (event.data.outcome === "approved") {
2961
+ const approval = {
2962
+ approved: true,
2963
+ id: event.data.requestId,
2964
+ reason: void 0
2965
+ };
2966
+ return updateToolPart(data, existing.toolCallId, existing.state === "output-available" ? {
2967
+ ...existing,
2968
+ approval
2969
+ } : {
2970
+ ...toolPartIdentity(existing),
2971
+ approval,
2972
+ state: "approval-responded"
2973
+ });
2974
+ }
2975
+ if (existing.state === "output-available") return data;
2976
+ return updateToolPart(data, existing.toolCallId, {
2977
+ ...toolPartIdentity(existing),
2978
+ approval: {
2979
+ approved: false,
2980
+ id: event.data.requestId,
2981
+ reason: "Tool execution was cancelled."
2982
+ },
2983
+ state: "output-denied"
2802
2984
  });
2803
- input.signal?.throwIfAborted();
2804
- this.#session = created.session;
2805
- this.#callbacks.onSessionChange?.(created.session.state);
2806
- this.#publish();
2807
- return {
2808
- response: created.response,
2809
- reader: this.#ensureStream(streamOptions).subscribe(input.signal)
2985
+ }
2986
+ case "action.result": {
2987
+ const descriptor = normalizeActionResult(event.data.result);
2988
+ const existing = findToolPart(data, event.data.result.callId);
2989
+ const denied = event.data.status === "rejected" || event.data.error?.code === "TOOL_EXECUTION_DENIED";
2990
+ const failed = event.data.status === "failed" && !denied;
2991
+ const approvalId = existing?.approval?.id ?? event.data.result.callId;
2992
+ const toolMetadata = mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor));
2993
+ const resultPartBase = {
2994
+ input: existing?.input,
2995
+ stepIndex: event.data.stepIndex,
2996
+ toolCallId: event.data.result.callId,
2997
+ toolMetadata,
2998
+ toolName: existing?.toolName ?? descriptor.toolName,
2999
+ type: "dynamic-tool"
3000
+ };
3001
+ let nextPart;
3002
+ if (denied) nextPart = {
3003
+ ...resultPartBase,
3004
+ approval: {
3005
+ approved: false,
3006
+ id: approvalId,
3007
+ reason: event.data.error?.message
3008
+ },
3009
+ state: "output-denied"
3010
+ };
3011
+ else if (failed) nextPart = {
3012
+ ...resultPartBase,
3013
+ approval: approvedApproval(existing),
3014
+ errorText: event.data.error?.message ?? stringifyUnknown(event.data.result.output),
3015
+ state: "output-error"
3016
+ };
3017
+ else nextPart = {
3018
+ ...resultPartBase,
3019
+ approval: approvedApproval(existing),
3020
+ output: event.data.result.output,
3021
+ state: "output-available"
2810
3022
  };
3023
+ return upsertToolPart(data, event.data.turnId, event.data.stepIndex, nextPart);
2811
3024
  }
2812
- const reader = this.#ensureStream(streamOptions).subscribe(input.signal);
2813
- try {
2814
- if (input.inputResponses === void 0) {
2815
- const { message, ...options } = input;
2816
- return {
2817
- response: await this.#session.send(message, options),
2818
- reader
2819
- };
2820
- }
2821
- const { inputResponses, ...options } = input;
2822
- return {
2823
- response: await this.#session.respond(inputResponses, options),
2824
- reader
3025
+ case "action.partial": {
3026
+ const existing = findToolPart(data, event.data.result.callId);
3027
+ if (existing !== void 0 && isSettledToolPart(existing)) return data;
3028
+ const descriptor = normalizeActionResult(event.data.result);
3029
+ const nextPart = {
3030
+ approval: approvedApproval(existing),
3031
+ input: existing?.input,
3032
+ output: event.data.result.output,
3033
+ partial: true,
3034
+ state: "output-available",
3035
+ stepIndex: event.data.stepIndex,
3036
+ toolCallId: event.data.result.callId,
3037
+ toolMetadata: mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor)),
3038
+ toolName: existing?.toolName ?? descriptor.toolName,
3039
+ type: "dynamic-tool"
2825
3040
  };
2826
- } catch (error) {
2827
- reader[Symbol.dispose]();
2828
- throw error;
3041
+ return upsertToolPart(data, event.data.turnId, event.data.stepIndex, nextPart);
2829
3042
  }
2830
- }
2831
- #ensureStream(options = {}) {
2832
- if (this.#stream !== void 0 && !this.#stream.ended) {
2833
- this.#stream.setOptions(options);
2834
- return this.#stream;
3043
+ case "task.settled": {
3044
+ const existing = findToolPart(data, event.data.callId);
3045
+ if (existing === void 0) return data;
3046
+ return replaceToolPart(data, createSettledTaskPart(existing, event));
2835
3047
  }
2836
- if (this.#session === void 0) throw new Error("A session is required before opening its stream.");
2837
- const session = this.#session;
2838
- const generation = this.#prewarmGeneration;
2839
- this.#stream = new SessionEventStream(session, {
2840
- ...options,
2841
- onEvent: (event) => {
2842
- if (generation === this.#prewarmGeneration) this.#acceptServerEvent(event);
2843
- },
2844
- onError: (error) => {
2845
- if (generation !== this.#prewarmGeneration) return;
2846
- this.#stream = void 0;
2847
- if (this.#activeTurn !== void 0) return;
2848
- this.#error = toError(error);
2849
- this.#status = "error";
2850
- this.#callbacks.onError?.(this.#error);
2851
- this.#publish();
3048
+ case "authorization.required": return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), createAuthorizationRequiredPart(event)));
3049
+ case "authorization.completed": return completeAuthorization(data, event);
3050
+ case "message.appended": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.transition(ensureStepStartPart(message, event.data.stepIndex), {
3051
+ kind: "append",
3052
+ delta: event.data.messageDelta,
3053
+ id: event.meta?.id,
3054
+ stepIndex: event.data.stepIndex,
3055
+ type: "text"
3056
+ }));
3057
+ case "message.completed": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.transition(ensureStepStartPart(message, event.data.stepIndex), {
3058
+ kind: "complete",
3059
+ stepIndex: event.data.stepIndex,
3060
+ text: event.data.message,
3061
+ id: event.meta?.id,
3062
+ type: "text"
3063
+ }));
3064
+ case "result.completed": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3065
+ ...message,
3066
+ metadata: {
3067
+ ...message.metadata,
3068
+ result: event.data.result
2852
3069
  }
2853
- });
2854
- return this.#stream;
2855
- }
2856
- #resetPrewarm() {
2857
- this.#prewarmGeneration += 1;
2858
- this.#prewarmController?.abort();
2859
- this.#prewarmController = void 0;
2860
- this.#prewarmPromise = void 0;
2861
- }
2862
- #finishTurn(turn) {
2863
- if (!this.#isActiveTurn(turn)) return;
2864
- turn.resolveResponse(void 0);
2865
- this.#activeTurn = void 0;
2866
- try {
2867
- this.#callbacks.onSessionChange?.(this.#session?.state);
2868
- this.#publish();
2869
- this.#callbacks.onFinish?.(this.#snapshot);
2870
- } finally {
2871
- turn.resolveCompletion();
2872
- }
2873
- }
2874
- #isActiveTurn(turn) {
2875
- return this.#activeTurn === turn;
2876
- }
2877
- #projectInputResponses(input) {
2878
- if (input.inputResponses === void 0 || input.inputResponses.length === 0) return;
2879
- this.#projection.append({
2880
- data: {
2881
- createdAt: Date.now(),
2882
- responses: input.inputResponses
3070
+ }));
3071
+ case "turn.completed": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3072
+ ...message,
3073
+ metadata: {
3074
+ ...message.metadata,
3075
+ status: "complete"
2883
3076
  },
2884
- type: "client.input.responded"
2885
- });
2886
- }
2887
- #acceptServerEvent(event) {
2888
- if (!this.#seenEvents.admit(event)) return;
2889
- const wasStreaming = this.#status === "streaming";
2890
- updatePendingAuthorizations(this.#pendingAuthorizations, event);
2891
- this.#events = [...this.#events, event];
2892
- this.#handleReconciliation(this.#messageSubmissions.apply(event));
2893
- this.#callbacks.onEvent?.(event);
2894
- this.#applyTerminalStreamFailure(event);
2895
- const settled = isCurrentTurnBoundaryEvent(event) && this.#pendingAuthorizations.size === 0;
2896
- if (this.#status !== "resuming" && this.#error === void 0) {
2897
- if ("data" in event && "turnId" in event.data) this.#status = "streaming";
2898
- if (this.#activeTurn === void 0 && settled) this.#status = "ready";
2899
- }
2900
- this.#callbacks.onSessionChange?.(this.#session?.state);
2901
- if (this.#status !== "resuming") this.#publish();
2902
- if (this.#activeTurn === void 0 && wasStreaming && settled) this.#callbacks.onFinish?.(this.#snapshot);
2903
- }
2904
- #handleReconciliation(reconciliation) {
2905
- if (reconciliation === void 0) return false;
2906
- let followed = 0;
2907
- for (const id of reconciliation.ids) if (this.#activeTurn?.followUpSubmissionIds.delete(id)) followed += 1;
2908
- if (followed > 0 && this.#activeTurn !== void 0) {
2909
- if (reconciliation.alreadyProjected) this.#activeTurn.receivedFollowUps += followed;
2910
- else {
2911
- const previous = this.#activeTurn.receivedFollowUpEvents.get(reconciliation.event) ?? 0;
2912
- this.#activeTurn.receivedFollowUpEvents.set(reconciliation.event, previous + followed);
2913
- }
2914
- }
2915
- return true;
2916
- }
2917
- #applyTerminalStreamFailure(event) {
2918
- const error = toTerminalStreamFailureError(event);
2919
- if (error === void 0) return;
2920
- this.#status = "error";
2921
- this.#messageSubmissions.failAll(error);
2922
- if (this.#error === void 0) {
2923
- this.#error = error;
2924
- this.#callbacks.onError?.(error);
2925
- }
2926
- }
2927
- #createSnapshot() {
2928
- return {
2929
- data: this.#projection.data,
2930
- error: this.#error,
2931
- events: this.#events,
2932
- session: this.#session?.state,
2933
- status: this.#status
2934
- };
2935
- }
2936
- #publish() {
2937
- this.#snapshot = this.#createSnapshot();
2938
- for (const subscriber of this.#subscribers) subscriber();
3077
+ parts: removeStreamingToolParts(closeStreamingRuns(message.parts))
3078
+ }));
3079
+ case "turn.cancelled": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3080
+ ...message,
3081
+ metadata: {
3082
+ ...message.metadata,
3083
+ status: "complete"
3084
+ },
3085
+ parts: removeStreamingToolParts(closeStreamingRuns(message.parts))
3086
+ }));
3087
+ case "turn.failed":
3088
+ if (data.messages.find((message) => message.role === "assistant" && message.metadata?.turnId === event.data.turnId) === void 0) return data;
3089
+ return updateAssistantMessage(data, event.data.turnId, (message) => ({
3090
+ ...message,
3091
+ metadata: {
3092
+ ...message.metadata,
3093
+ status: "complete"
3094
+ },
3095
+ parts: removeStreamingToolParts(closeStreamingRuns(message.parts))
3096
+ }));
3097
+ case "session.failed": return data;
3098
+ default: return data;
2939
3099
  }
2940
- };
2941
- function detachEveAgentStore(store) {
2942
- store[detachStore]();
2943
3100
  }
2944
- function attachEveAgentStore(store) {
2945
- store[attachStore]();
3101
+ function closeStreamingRuns(parts, stepIndex) {
3102
+ return parts.map((part) => (part.type === "text" || part.type === "reasoning") && part.state === "streaming" && (stepIndex === void 0 || part.stepIndex === stepIndex) ? {
3103
+ ...part,
3104
+ state: "done"
3105
+ } : part);
2946
3106
  }
2947
-
2948
- //#endregion
2949
- //#region src/client/agent-host.ts
2950
- const AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
2951
- const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve";
2952
- function resolveEveAgentHost(input) {
2953
- if (input.agent === void 0) return input.host ?? "";
2954
- if (input.host !== void 0) throw new Error("useEveAgent cannot combine agent and host. Use one target option.");
2955
- assertValidAgentName(input.agent);
2956
- return `${EVE_NAMED_AGENT_ROUTE_PREFIX}/${input.agent}`;
3107
+ function removeStreamingToolParts(parts) {
3108
+ return parts.filter((part) => part.type !== "dynamic-tool" || part.state !== "input-streaming");
2957
3109
  }
2958
- function assertValidAgentName(name) {
2959
- 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.`);
3110
+ function respondToInputRequest(data, response) {
3111
+ const existing = findToolPartByApprovalId(data, response.requestId);
3112
+ if (!existing) return data;
3113
+ const approval = { id: response.requestId };
3114
+ if (response.text !== void 0) approval.reason = response.text;
3115
+ const toolMetadata = mergeToolMetadata(existing.toolMetadata, { eve: {
3116
+ inputResponse: response,
3117
+ kind: existing.toolMetadata?.eve?.kind ?? "unknown",
3118
+ name: existing.toolMetadata?.eve?.name ?? existing.toolName
3119
+ } });
3120
+ return updateToolPart(data, existing.toolCallId, existing.state === "output-available" ? {
3121
+ ...existing,
3122
+ approval: {
3123
+ ...approval,
3124
+ approved: true
3125
+ },
3126
+ toolMetadata
3127
+ } : {
3128
+ ...toolPartIdentity(existing),
3129
+ approval,
3130
+ state: "approval-responded",
3131
+ toolMetadata
3132
+ });
2960
3133
  }
2961
-
2962
- //#endregion
2963
- //#region src/client/authorization-message-parts.ts
2964
- function createAuthorizationRequiredPart(event) {
2965
- const displayName = event.data.authorization?.displayName ?? formatAuthorizationDisplayName(event.data.name);
3134
+ function resolveInputRequest(data, resolution) {
3135
+ if (resolution.response !== void 0) return findToolPartByApprovalId(data, resolution.requestId)?.approval?.approved === void 0 ? respondToInputRequest(data, resolution.response) : data;
3136
+ const existing = findToolPartByApprovalId(data, resolution.requestId);
3137
+ if (!existing) return data;
3138
+ return updateToolPart(data, existing.toolCallId, {
3139
+ ...toolPartIdentity(existing),
3140
+ output: { status: resolution.outcome },
3141
+ state: "output-available"
3142
+ });
3143
+ }
3144
+ function toolPartIdentity(part) {
2966
3145
  return {
2967
- authorization: event.data.authorization,
2968
- description: normalizeAuthorizationDescription(event.data.description, event.data.name, displayName),
2969
- displayName,
2970
- name: event.data.name,
2971
- state: "required",
2972
- stepIndex: event.data.stepIndex,
2973
- turnId: event.data.turnId,
2974
- type: "authorization"
3146
+ input: part.input,
3147
+ stepIndex: part.stepIndex,
3148
+ toolCallId: part.toolCallId,
3149
+ toolMetadata: part.toolMetadata,
3150
+ toolName: part.toolName,
3151
+ type: part.type
2975
3152
  };
2976
3153
  }
2977
- function createAuthorizationCompletedPart(event, existing) {
2978
- const displayName = event.data.authorization?.displayName ?? existing?.displayName ?? formatAuthorizationDisplayName(event.data.name);
3154
+ function updateAssistantMessage(data, turnId, update) {
3155
+ const message = data.messages.find((message) => message.role === "assistant" && message.metadata?.turnId === turnId) ?? createAssistantMessage(turnId);
3156
+ return upsertMessage(data, update(message));
3157
+ }
3158
+ function createAssistantMessage(turnId) {
2979
3159
  return {
2980
- authorization: existing?.authorization || event.data.authorization ? {
2981
- ...existing?.authorization,
2982
- ...event.data.authorization
2983
- } : void 0,
2984
- description: existing?.description ?? buildCompletedAuthorizationDescription(displayName, event.data.outcome, event.data.reason),
2985
- displayName,
2986
- name: event.data.name,
2987
- outcome: event.data.outcome,
2988
- reason: event.data.reason,
2989
- state: "completed",
2990
- stepIndex: existing?.stepIndex ?? event.data.stepIndex,
2991
- turnId: existing?.turnId ?? event.data.turnId,
2992
- type: "authorization"
3160
+ id: `${turnId}:assistant`,
3161
+ metadata: {
3162
+ status: "streaming",
3163
+ turnId
3164
+ },
3165
+ parts: [],
3166
+ role: "assistant"
3167
+ };
3168
+ }
3169
+ function ensureStepStartPart(message, stepIndex) {
3170
+ const stepStartCount = message.parts.filter((part) => part.type === "step-start").length;
3171
+ if (stepStartCount > stepIndex) return message;
3172
+ const missingCount = stepIndex - stepStartCount + 1;
3173
+ return {
3174
+ ...message,
3175
+ parts: [...message.parts, ...Array.from({ length: missingCount }, () => ({ type: "step-start" }))]
3176
+ };
3177
+ }
3178
+ function upsertPart(message, next) {
3179
+ const index = message.parts.findIndex((part) => partKey(part) === partKey(next));
3180
+ const parts = index === -1 ? [...message.parts, next] : [
3181
+ ...message.parts.slice(0, index),
3182
+ next,
3183
+ ...message.parts.slice(index + 1)
3184
+ ];
3185
+ return {
3186
+ ...message,
3187
+ metadata: {
3188
+ ...message.metadata,
3189
+ status: next.type === "text" && next.state === "done" ? "complete" : "streaming"
3190
+ },
3191
+ parts
2993
3192
  };
2994
3193
  }
2995
- function buildCompletedAuthorizationDescription(displayName, outcome, reason) {
2996
- if (outcome === "authorized") return `${displayName} connected.`;
2997
- return `${displayName} authorization ${outcome}${reason !== void 0 ? ` (${reason})` : ""}.`;
3194
+ function upsertToolPart(data, turnId, stepIndex, part) {
3195
+ const updated = updateToolPart(data, part.toolCallId, part);
3196
+ return updated !== data ? updated : updateAssistantMessage(data, turnId, (message) => upsertPart(ensureStepStartPart(message, stepIndex), part));
3197
+ }
3198
+ function updateToolPart(data, toolCallId, next) {
3199
+ const message = data.messages.find((candidate) => candidate.role === "assistant" && candidate.parts.some((part) => part.type === "dynamic-tool" && part.toolCallId === toolCallId));
3200
+ if (!message) return data;
3201
+ return upsertMessage(data, upsertPart(message, next));
3202
+ }
3203
+ function replaceToolPart(data, next) {
3204
+ const message = data.messages.find((candidate) => candidate.parts.some((part) => part.type === "dynamic-tool" && part.toolCallId === next.toolCallId));
3205
+ if (message === void 0) return data;
3206
+ return upsertMessage(data, {
3207
+ ...message,
3208
+ parts: message.parts.map((part) => partKey(part) === partKey(next) ? next : part)
3209
+ });
3210
+ }
3211
+ function completeAuthorization(data, event) {
3212
+ const existing = findPendingAuthorizationPart(data, event.data.name, event.data.attemptId);
3213
+ const next = createAuthorizationCompletedPart(event, existing);
3214
+ return updateAssistantMessage(data, existing?.turnId ?? event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, next.stepIndex), next));
3215
+ }
3216
+ function findToolPart(data, toolCallId) {
3217
+ for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.toolCallId === toolCallId) return part;
2998
3218
  }
2999
- function normalizeAuthorizationDescription(description, name, displayName) {
3000
- if (description === `Authorization required for ${name}`) return `Authorization required for ${displayName}`;
3001
- return description;
3219
+ function isSettledToolPart(part) {
3220
+ return part.state === "output-denied" || part.state === "output-error" || part.state === "output-available" && part.partial !== true;
3002
3221
  }
3003
- function formatAuthorizationDisplayName(name) {
3004
- if (name.length === 0) return name;
3005
- return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
3222
+ function findPendingAuthorizationPart(data, name, attemptId) {
3223
+ for (let messageIndex = data.messages.length - 1; messageIndex >= 0; messageIndex -= 1) {
3224
+ const message = data.messages[messageIndex];
3225
+ if (message?.role !== "assistant") continue;
3226
+ for (let partIndex = message.parts.length - 1; partIndex >= 0; partIndex -= 1) {
3227
+ const part = message.parts[partIndex];
3228
+ if (part?.type === "authorization" && part.state === "required" && (attemptId === void 0 ? part.attemptId === void 0 && part.name === name : part.attemptId === attemptId)) return part;
3229
+ }
3230
+ }
3231
+ }
3232
+ function findToolPartByApprovalId(data, approvalId) {
3233
+ for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.approval?.id === approvalId) return part;
3006
3234
  }
3007
3235
 
3008
3236
  //#endregion
3009
- //#region src/client/message-action-parts.ts
3010
- function toMessageInputRequest(request) {
3237
+ //#region src/client/conversation-reducer.ts
3238
+ function initialConversationState() {
3011
3239
  return {
3012
- allowFreeform: request.allowFreeform,
3013
- display: request.display,
3014
- kind: request.kind,
3015
- options: request.options,
3016
- prompt: request.prompt,
3017
- requestId: request.requestId
3240
+ messages: [],
3241
+ turns: {},
3242
+ inputs: {},
3243
+ tasks: {},
3244
+ agents: {}
3018
3245
  };
3019
3246
  }
3020
- function createToolMetadata(descriptor, extra) {
3021
- return { eve: {
3022
- inputRequest: extra?.inputRequest,
3023
- kind: descriptor.kind,
3024
- name: descriptor.name
3025
- } };
3247
+ function updateTurn(state, turnId, update) {
3248
+ const turn = state.turns[turnId];
3249
+ if (turn === void 0) return state;
3250
+ const next = update(turn);
3251
+ return next === turn ? state : {
3252
+ ...state,
3253
+ turns: {
3254
+ ...state.turns,
3255
+ [turnId]: next
3256
+ }
3257
+ };
3026
3258
  }
3027
- function mergeToolMetadata(current, next) {
3028
- const kind = next.eve?.kind ?? current?.eve?.kind ?? "unknown";
3029
- const name = next.eve?.name ?? current?.eve?.name ?? "unknown";
3030
- return { eve: {
3031
- ...current?.eve,
3032
- ...next.eve,
3033
- inputRequest: next.eve?.inputRequest ?? current?.eve?.inputRequest,
3034
- inputResponse: next.eve?.inputResponse ?? current?.eve?.inputResponse,
3035
- kind,
3036
- name
3037
- } };
3259
+ function updateTask(state, taskId, update) {
3260
+ const task = state.tasks[taskId];
3261
+ if (task === void 0) return state;
3262
+ const next = update(task);
3263
+ return next === task ? state : {
3264
+ ...state,
3265
+ tasks: {
3266
+ ...state.tasks,
3267
+ [taskId]: next
3268
+ }
3269
+ };
3038
3270
  }
3039
- function approvedApproval(part) {
3040
- if (!part?.approval?.id) return;
3271
+ function updateObservation(state, sessionId, update) {
3272
+ const agent = state.agents[sessionId];
3273
+ if (agent === void 0) return state;
3274
+ const observation = update(agent.observation);
3275
+ if (observation === agent.observation) return state;
3041
3276
  return {
3042
- approved: true,
3043
- id: part.approval.id,
3044
- isAutomatic: part.approval.isAutomatic,
3045
- reason: part.approval.reason
3277
+ ...state,
3278
+ agents: {
3279
+ ...state.agents,
3280
+ [sessionId]: {
3281
+ ...agent,
3282
+ observation
3283
+ }
3284
+ }
3046
3285
  };
3047
3286
  }
3048
- function normalizeActionRequest(action) {
3049
- switch (action.kind) {
3050
- case "load-skill": return {
3051
- kind: "load-skill",
3052
- name: "load_skill",
3053
- toolName: "eve:load-skill"
3054
- };
3055
- case "tool-call":
3056
- case "workflow-tool-call": return {
3057
- kind: "tool-call",
3058
- name: action.toolName,
3059
- toolName: action.toolName
3060
- };
3061
- case "subagent-call": return {
3062
- kind: "subagent-call",
3063
- name: action.subagentName,
3064
- toolName: `eve:subagent:${action.subagentName}`
3287
+ function observedConversation(observation) {
3288
+ return observation.status === "not-followed" ? void 0 : observation.conversation;
3289
+ }
3290
+ function reduceConversationLifecycle(state, event) {
3291
+ switch (event.type) {
3292
+ case "turn.started": return {
3293
+ ...state,
3294
+ activeTurnId: event.data.turnId,
3295
+ turns: {
3296
+ ...state.turns,
3297
+ [event.data.turnId]: {
3298
+ turnId: event.data.turnId,
3299
+ status: "active"
3300
+ }
3301
+ }
3065
3302
  };
3066
- case "remote-agent-call": return {
3067
- kind: "subagent-call",
3068
- name: action.remoteAgentName,
3069
- toolName: `eve:subagent:${action.remoteAgentName}`
3303
+ case "turn.waiting": return updateTurn(state, event.data.turnId, (turn) => turn.status === "active" && !turn.waiting ? {
3304
+ ...turn,
3305
+ waiting: true
3306
+ } : turn);
3307
+ case "step.started": return updateTurn(state, event.data.turnId, (turn) => turn.waiting ? {
3308
+ turnId: turn.turnId,
3309
+ status: turn.status
3310
+ } : turn);
3311
+ case "turn.completed":
3312
+ case "turn.cancelled":
3313
+ case "turn.failed": {
3314
+ const { turnId } = event.data;
3315
+ return {
3316
+ ...state,
3317
+ activeTurnId: state.activeTurnId === turnId ? void 0 : state.activeTurnId,
3318
+ turns: {
3319
+ ...state.turns,
3320
+ [turnId]: {
3321
+ turnId,
3322
+ status: event.type === "turn.completed" ? "completed" : event.type === "turn.failed" ? "failed" : "cancelled"
3323
+ }
3324
+ }
3325
+ };
3326
+ }
3327
+ case "session.waiting":
3328
+ case "session.completed":
3329
+ case "session.failed": return state.activeTurnId === void 0 ? state : {
3330
+ ...state,
3331
+ activeTurnId: void 0
3070
3332
  };
3333
+ case "task.started": {
3334
+ const { callId, kind, name, taskId, turnId } = event.data;
3335
+ const task = state.tasks[taskId] ?? {
3336
+ taskId,
3337
+ name,
3338
+ kind,
3339
+ calls: {}
3340
+ };
3341
+ if (task.calls[callId] !== void 0) return state;
3342
+ return {
3343
+ ...state,
3344
+ tasks: {
3345
+ ...state.tasks,
3346
+ [taskId]: {
3347
+ ...task,
3348
+ calls: {
3349
+ ...task.calls,
3350
+ [callId]: {
3351
+ callId,
3352
+ turnId,
3353
+ status: "working"
3354
+ }
3355
+ }
3356
+ }
3357
+ }
3358
+ };
3359
+ }
3360
+ case "task.settled": {
3361
+ const { callId, error, output, status, taskId } = event.data;
3362
+ return updateTask(state, taskId, (task) => {
3363
+ const call = task.calls[callId];
3364
+ if (call === void 0 || call.status !== "working") return task;
3365
+ const settled = {
3366
+ callId,
3367
+ turnId: call.turnId,
3368
+ status
3369
+ };
3370
+ return {
3371
+ ...task,
3372
+ calls: {
3373
+ ...task.calls,
3374
+ [callId]: status === "completed" && output !== void 0 ? {
3375
+ ...settled,
3376
+ output
3377
+ } : status === "failed" && error !== void 0 ? {
3378
+ ...settled,
3379
+ error
3380
+ } : settled
3381
+ }
3382
+ };
3383
+ });
3384
+ }
3385
+ case "agent.started": {
3386
+ const { callId, name, sessionId, taskId, turnId } = event.data;
3387
+ if (state.agents[sessionId] !== void 0) return state;
3388
+ const agent = {
3389
+ sessionId,
3390
+ name,
3391
+ callId,
3392
+ turnId,
3393
+ observation: { status: "not-followed" }
3394
+ };
3395
+ if (taskId !== void 0) agent.taskId = taskId;
3396
+ return {
3397
+ ...state,
3398
+ agents: {
3399
+ ...state.agents,
3400
+ [sessionId]: agent
3401
+ }
3402
+ };
3403
+ }
3404
+ case "input.requested": {
3405
+ const inputs = { ...state.inputs };
3406
+ for (const request of event.data.requests) {
3407
+ if (inputs[request.requestId] !== void 0) continue;
3408
+ const input = {
3409
+ request,
3410
+ turnId: event.data.turnId,
3411
+ stepIndex: event.data.stepIndex,
3412
+ status: "open"
3413
+ };
3414
+ if (event.data.taskId !== void 0) input.taskId = event.data.taskId;
3415
+ inputs[request.requestId] = input;
3416
+ }
3417
+ return {
3418
+ ...state,
3419
+ inputs
3420
+ };
3421
+ }
3422
+ case "client.input.responded": {
3423
+ const inputs = { ...state.inputs };
3424
+ for (const response of event.data.responses) {
3425
+ const current = inputs[response.requestId];
3426
+ if (current?.status !== "open") continue;
3427
+ inputs[response.requestId] = {
3428
+ ...current,
3429
+ response,
3430
+ status: "responded"
3431
+ };
3432
+ }
3433
+ return {
3434
+ ...state,
3435
+ inputs
3436
+ };
3437
+ }
3438
+ case "approval.candidate": {
3439
+ const current = state.inputs[event.data.requestId];
3440
+ if (current === void 0 || current.status === "settled") return state;
3441
+ if (event.data.outcome === "pending") return state;
3442
+ return {
3443
+ ...state,
3444
+ inputs: {
3445
+ ...state.inputs,
3446
+ [event.data.requestId]: {
3447
+ ...current,
3448
+ status: "open",
3449
+ response: void 0
3450
+ }
3451
+ }
3452
+ };
3453
+ }
3454
+ case "approval.settled": {
3455
+ const current = state.inputs[event.data.requestId];
3456
+ if (current === void 0 || current.status === "settled") return state;
3457
+ return {
3458
+ ...state,
3459
+ inputs: {
3460
+ ...state.inputs,
3461
+ [event.data.requestId]: {
3462
+ ...current,
3463
+ status: "settled",
3464
+ outcome: event.data.outcome
3465
+ }
3466
+ }
3467
+ };
3468
+ }
3469
+ case "input.resolved": {
3470
+ const inputs = { ...state.inputs };
3471
+ for (const resolution of event.data.resolutions) {
3472
+ const current = inputs[resolution.requestId];
3473
+ if (current === void 0 || current.status === "settled") continue;
3474
+ inputs[resolution.requestId] = {
3475
+ ...current,
3476
+ status: "settled",
3477
+ outcome: resolution.outcome,
3478
+ response: resolution.response ?? current.response
3479
+ };
3480
+ }
3481
+ return {
3482
+ ...state,
3483
+ inputs
3484
+ };
3485
+ }
3486
+ default: return state;
3071
3487
  }
3072
3488
  }
3073
- function normalizeActionResult(result) {
3074
- switch (result.kind) {
3075
- case "load-skill-result": return {
3076
- kind: "load-skill",
3077
- name: result.name ?? "load_skill",
3078
- toolName: "eve:load-skill"
3079
- };
3080
- case "tool-result": return {
3081
- kind: "tool-call",
3082
- name: result.toolName,
3083
- toolName: result.toolName
3084
- };
3085
- case "subagent-result": return {
3086
- kind: "subagent-call",
3087
- name: result.subagentName,
3088
- toolName: `eve:subagent:${result.subagentName}`
3489
+ const messageReducer = defaultMessageReducer();
3490
+ function reduceConversation(state, event) {
3491
+ switch (event.type) {
3492
+ case "client.agent.following": return updateObservation(state, event.data.sessionId, (observation) => observation.status === "following" ? observation : {
3493
+ status: "following",
3494
+ conversation: observedConversation(observation) ?? initialConversationState()
3495
+ });
3496
+ case "client.agent.observed": return updateObservation(state, event.data.sessionId, (observation) => observation.status === "following" ? {
3497
+ status: "following",
3498
+ conversation: reduceConversation(observation.conversation, event.data.event)
3499
+ } : observation);
3500
+ case "client.agent.idle": return updateObservation(state, event.data.sessionId, (observation) => observation.status === "following" ? {
3501
+ status: "idle",
3502
+ conversation: observation.conversation
3503
+ } : observation);
3504
+ case "client.agent.unavailable": return updateObservation(state, event.data.sessionId, (observation) => {
3505
+ const conversation = observedConversation(observation);
3506
+ return conversation === void 0 ? { status: "unavailable" } : {
3507
+ status: "unavailable",
3508
+ conversation
3509
+ };
3510
+ });
3511
+ default: {
3512
+ const projected = messageReducer.reduce(state, event);
3513
+ return reduceConversationLifecycle({
3514
+ ...state,
3515
+ ...projected
3516
+ }, event);
3517
+ }
3518
+ }
3519
+ }
3520
+ const canonicalConversationReducer = {
3521
+ initial: initialConversationState,
3522
+ reduce: reduceConversation
3523
+ };
3524
+ const conversationReducer = canonicalConversationReducer;
3525
+
3526
+ //#endregion
3527
+ //#region src/protocol/event-dedupe.ts
3528
+ function createEventDeduper() {
3529
+ const seen = /* @__PURE__ */ new Set();
3530
+ return {
3531
+ admit(event) {
3532
+ const id = event.meta?.id;
3533
+ if (id === void 0) return true;
3534
+ if (seen.has(id)) return false;
3535
+ seen.add(id);
3536
+ return true;
3537
+ },
3538
+ get size() {
3539
+ return seen.size;
3540
+ }
3541
+ };
3542
+ }
3543
+
3544
+ //#endregion
3545
+ //#region src/client/session-event-stream.ts
3546
+ var SessionEventStream = class {
3547
+ #controller = new AbortController();
3548
+ #readers = /* @__PURE__ */ new Set();
3549
+ #caughtUp = Promise.withResolvers();
3550
+ caughtUp = this.#caughtUp.promise;
3551
+ #ended = false;
3552
+ #error;
3553
+ #headers;
3554
+ #reconnectPolicy;
3555
+ constructor(session, options) {
3556
+ this.setOptions(options);
3557
+ this.caughtUp.catch(() => {});
3558
+ if (!options.catchUp) this.#caughtUp.resolve();
3559
+ (async () => {
3560
+ try {
3561
+ for await (const event of followClientSession(session, {
3562
+ signal: this.#controller.signal,
3563
+ resolveHeaders: () => this.#headers,
3564
+ resolveReconnectPolicy: () => this.#reconnectPolicy,
3565
+ startIndex: options.startIndex,
3566
+ onCaughtUp: options.catchUp ? () => this.#caughtUp.resolve() : void 0
3567
+ })) {
3568
+ if (this.#controller.signal.aborted) return;
3569
+ options.onEvent(event);
3570
+ for (const reader of this.#readers) reader.push(event);
3571
+ if (event.type === "session.completed" || event.type === "session.failed") break;
3572
+ }
3573
+ this.#caughtUp.resolve();
3574
+ this.#finish();
3575
+ } catch (error) {
3576
+ this.#caughtUp.reject(error);
3577
+ this.#finish(error);
3578
+ if (!this.#controller.signal.aborted) options.onError(error);
3579
+ }
3580
+ })();
3581
+ }
3582
+ subscribe(signal) {
3583
+ const reader = new SessionEventReader(() => this.#readers.delete(reader), signal);
3584
+ if (this.#ended) reader.end(this.#error);
3585
+ else this.#readers.add(reader);
3586
+ return reader;
3587
+ }
3588
+ get ended() {
3589
+ return this.#ended;
3590
+ }
3591
+ setOptions(options) {
3592
+ if ("headers" in options) this.#headers = options.headers;
3593
+ if ("streamReconnectPolicy" in options) this.#reconnectPolicy = options.streamReconnectPolicy;
3594
+ }
3595
+ close() {
3596
+ const error = new DOMException("Session stream was detached.", "AbortError");
3597
+ this.#controller.abort(error);
3598
+ this.#caughtUp.reject(error);
3599
+ this.#finish(error);
3600
+ }
3601
+ #finish(error) {
3602
+ if (this.#ended) return;
3603
+ this.#ended = true;
3604
+ this.#error = error;
3605
+ for (const reader of this.#readers) reader.end(error);
3606
+ }
3607
+ };
3608
+ var SessionEventReader = class {
3609
+ #events = [];
3610
+ #wake = Promise.withResolvers();
3611
+ #ended = false;
3612
+ #error;
3613
+ #dispose;
3614
+ constructor(unsubscribe, signal) {
3615
+ const abort = () => this.end(signal?.reason);
3616
+ signal?.addEventListener("abort", abort, { once: true });
3617
+ this.#dispose = () => {
3618
+ signal?.removeEventListener("abort", abort);
3619
+ unsubscribe();
3089
3620
  };
3621
+ if (signal?.aborted) abort();
3622
+ }
3623
+ push(event) {
3624
+ if (this.#ended) return;
3625
+ this.#events.push(event);
3626
+ this.#wake.resolve();
3627
+ }
3628
+ end(error) {
3629
+ if (this.#ended) return;
3630
+ this.#ended = true;
3631
+ this.#error = error;
3632
+ this.#wake.resolve();
3090
3633
  }
3091
- }
3092
- function stringifyUnknown(value) {
3093
- if (typeof value === "string") return value;
3094
- try {
3095
- return JSON.stringify(value);
3096
- } catch {
3097
- return "Action failed.";
3634
+ [Symbol.dispose]() {
3635
+ this.end();
3636
+ this.#events = [];
3637
+ this.#dispose();
3098
3638
  }
3099
- }
3100
-
3101
- //#endregion
3102
- //#region src/client/message-reducer-primitives.ts
3103
- function projectReceivedParts(parts, message) {
3104
- return parts?.map((part) => part.type === "text" ? {
3105
- state: "done",
3106
- text: part.text,
3107
- type: "text"
3108
- } : {
3109
- filename: part.filename,
3110
- mediaType: part.mediaType,
3111
- size: part.size,
3112
- type: "file",
3113
- url: part.url
3114
- }) ?? [{
3115
- state: "done",
3116
- text: message,
3117
- type: "text"
3118
- }];
3119
- }
3120
- function partKey(part) {
3121
- switch (part.type) {
3122
- case "text": return `text:${part.stepIndex ?? 0}`;
3123
- case "reasoning": return `reasoning:${part.stepIndex ?? 0}`;
3124
- case "file": return `file:${part.stepIndex ?? 0}:${part.filename ?? part.url ?? part.mediaType}`;
3125
- case "step-start": return "step-start";
3126
- case "authorization": return `authorization:${part.turnId}:${part.stepIndex}:${part.name}`;
3127
- case "dynamic-tool": return `dynamic-tool:${part.toolCallId}`;
3639
+ discard() {
3640
+ this.#events = [];
3128
3641
  }
3129
- }
3130
- function upsertMessage(data, next) {
3131
- const index = data.messages.findIndex((message) => message.id === next.id);
3132
- if (index === -1) return { messages: [...data.messages, next] };
3133
- return { messages: [
3134
- ...data.messages.slice(0, index),
3135
- next,
3136
- ...data.messages.slice(index + 1)
3137
- ] };
3138
- }
3139
- function removeStreamingToolPartsForTurn(data, turnId) {
3140
- const index = data.messages.findIndex((message) => message.role === "assistant" && message.metadata?.turnId === turnId);
3141
- const message = data.messages[index];
3142
- if (message === void 0) return data;
3143
- return upsertMessage(data, {
3144
- ...message,
3145
- parts: message.parts.filter((part) => part.type !== "dynamic-tool" || part.state !== "input-streaming")
3146
- });
3147
- }
3148
- function optimisticUserMessageId(submissionId) {
3149
- return `optimistic:${submissionId}:user`;
3150
- }
3642
+ async *[Symbol.asyncIterator]() {
3643
+ for (;;) {
3644
+ while (this.#events.length > 0) yield this.#events.shift();
3645
+ if (this.#ended) {
3646
+ if (this.#error !== void 0) throw this.#error;
3647
+ return;
3648
+ }
3649
+ this.#wake = Promise.withResolvers();
3650
+ await this.#wake.promise;
3651
+ }
3652
+ }
3653
+ };
3151
3654
 
3152
3655
  //#endregion
3153
- //#region src/client/message-run-parts.ts
3154
- function append(message, append) {
3155
- const current = latestStreamingRun(message, append.type, append.stepIndex);
3156
- return upsert(message, {
3157
- state: "streaming",
3158
- stepIndex: append.stepIndex,
3159
- text: (current?.text ?? "") + append.delta,
3160
- type: append.type
3161
- });
3162
- }
3163
- function latestStreamingRun(message, type, stepIndex) {
3164
- for (let index = message.parts.length - 1; index >= 0; index -= 1) {
3165
- const part = message.parts[index];
3166
- if (part?.type === type && part.stepIndex === stepIndex) return part.state === "streaming" ? part : void 0;
3656
+ //#region src/client/conversation-client.ts
3657
+ var ConversationClient = class {
3658
+ projection;
3659
+ #conversation;
3660
+ #cursors = /* @__PURE__ */ new Map();
3661
+ #seenEvents = createEventDeduper();
3662
+ #follower;
3663
+ #stream;
3664
+ #onChange;
3665
+ #onConversationChange;
3666
+ constructor(projection, onChange, onConversationChange) {
3667
+ this.projection = projection;
3668
+ this.#conversation = projection.reducer === conversationReducer ? projection : new EveAgentProjection(canonicalConversationReducer, []);
3669
+ this.#onChange = onChange;
3670
+ this.#onConversationChange = onConversationChange;
3167
3671
  }
3168
- }
3169
- function upsert(message, next) {
3170
- let lastIndex = -1;
3171
- for (let index = message.parts.length - 1; index >= 0; index -= 1) {
3172
- const part = message.parts[index];
3173
- if (part?.type === next.type && part.stepIndex === next.stepIndex) {
3174
- lastIndex = index;
3175
- break;
3672
+ get data() {
3673
+ return this.projection.data;
3674
+ }
3675
+ get conversation() {
3676
+ return this.#conversation.data;
3677
+ }
3678
+ get projections() {
3679
+ return this.#conversation === this.projection ? [this.projection] : [this.#conversation, this.projection];
3680
+ }
3681
+ get following() {
3682
+ return this.#follower !== void 0;
3683
+ }
3684
+ append(event) {
3685
+ const previous = this.data;
3686
+ const previousConversation = this.conversation;
3687
+ this.#appendRoot(event);
3688
+ if (previous !== this.data) this.#onChange(this.data, previous);
3689
+ else if (previousConversation !== this.conversation) this.#onConversationChange?.(this.conversation, previousConversation);
3690
+ }
3691
+ projectResponses(responses) {
3692
+ if (!responses?.length) return void 0;
3693
+ const event = {
3694
+ data: {
3695
+ createdAt: Date.now(),
3696
+ responses
3697
+ },
3698
+ type: "client.input.responded"
3699
+ };
3700
+ this.append(event);
3701
+ return () => this.#retract(event);
3702
+ }
3703
+ replaceResponses(retract, input) {
3704
+ retract?.();
3705
+ assertAnswerable(input, this.conversation);
3706
+ return this.projectResponses(input.inputResponses);
3707
+ }
3708
+ #retract(event) {
3709
+ const previous = this.data;
3710
+ const previousConversation = this.conversation;
3711
+ for (const projection of this.projections) projection.remove((entry) => entry === event);
3712
+ if (previous !== this.data) this.#onChange(this.data, previous);
3713
+ else if (previousConversation !== this.conversation) this.#onConversationChange?.(this.conversation, previousConversation);
3714
+ }
3715
+ observe(event, options = {}) {
3716
+ if (!this.#seenEvents.admit(event)) return false;
3717
+ options.onAccepted?.(event);
3718
+ const previous = this.data;
3719
+ const previousConversation = this.conversation;
3720
+ if (options.project) options.project(event);
3721
+ else this.#appendRoot(event);
3722
+ if (options.notify !== false) {
3723
+ if (previous !== this.data) this.#onChange(this.data, previous);
3724
+ else if (previousConversation !== this.conversation) this.#onConversationChange?.(this.conversation, previousConversation);
3176
3725
  }
3726
+ this.#follower?.acceptParentEvent(event);
3727
+ this.#follower?.reconcile();
3728
+ return true;
3729
+ }
3730
+ hydrate(event) {
3731
+ if (!this.#seenEvents.admit(event)) return false;
3732
+ this.#appendRoot(event);
3733
+ return true;
3734
+ }
3735
+ follow(session, events = []) {
3736
+ this.#follower?.abortAll();
3737
+ const follower = new AgentStreamFollower({
3738
+ session,
3739
+ cursors: this.#cursors,
3740
+ getState: () => this.conversation,
3741
+ onFollowing: (sessionId) => this.#appendChild({
3742
+ type: "client.agent.following",
3743
+ data: { sessionId }
3744
+ }),
3745
+ onEvent: (sessionId, event) => this.#appendChild({
3746
+ type: "client.agent.observed",
3747
+ data: {
3748
+ sessionId,
3749
+ event
3750
+ }
3751
+ }),
3752
+ onIdle: (sessionId) => this.#appendChild({
3753
+ type: "client.agent.idle",
3754
+ data: { sessionId }
3755
+ }),
3756
+ onUnavailable: (sessionId) => this.#appendChild({
3757
+ type: "client.agent.unavailable",
3758
+ data: { sessionId }
3759
+ })
3760
+ });
3761
+ this.#follower = follower;
3762
+ for (const event of events) follower.acceptParentEvent(event);
3763
+ follower.reconcile();
3764
+ }
3765
+ #appendRoot(event) {
3766
+ for (const projection of this.projections) projection.append(event);
3767
+ }
3768
+ #appendChild(event) {
3769
+ const previous = this.data;
3770
+ const previousConversation = this.conversation;
3771
+ this.#conversation.append(event);
3772
+ if (previous !== this.data) this.#onChange(this.data, previous);
3773
+ else if (previousConversation !== this.conversation) this.#onConversationChange?.(this.conversation, previousConversation);
3774
+ }
3775
+ stream(session, options) {
3776
+ if (this.#stream !== void 0 && !this.#stream.ended) {
3777
+ this.#stream.setOptions(options);
3778
+ return this.#stream;
3779
+ }
3780
+ this.#stream = new SessionEventStream(session, options);
3781
+ return this.#stream;
3782
+ }
3783
+ stop() {
3784
+ this.#follower?.abortAll();
3785
+ this.#follower = void 0;
3786
+ this.#stream?.close();
3787
+ this.#stream = void 0;
3788
+ }
3789
+ reset() {
3790
+ this.stop();
3791
+ this.#cursors.clear();
3792
+ this.#seenEvents = createEventDeduper();
3793
+ for (const projection of this.projections) projection.reset();
3177
3794
  }
3178
- const parts = lastIndex !== -1 && message.parts[lastIndex].state === "streaming" ? [
3179
- ...message.parts.slice(0, lastIndex),
3180
- next,
3181
- ...message.parts.slice(lastIndex + 1)
3182
- ] : [...message.parts, next];
3183
- return {
3184
- ...message,
3185
- metadata: {
3186
- ...message.metadata,
3187
- status: next.type === "text" && next.state === "done" ? "complete" : "streaming"
3188
- },
3189
- parts
3190
- };
3191
- }
3192
- const messageRun = {
3193
- append,
3194
- upsert
3195
3795
  };
3196
3796
 
3197
3797
  //#endregion
3198
- //#region src/client/message-reducer.ts
3199
- function receivedMessageEventId(event) {
3200
- return event.meta.id ?? `${event.data.turnId}:${event.data.sequence}`;
3201
- }
3202
- function defaultMessageReducer() {
3798
+ //#region src/client/session-turn-dispatch.ts
3799
+ async function dispatchSessionTurn(input) {
3800
+ const { client, session, turn, beforeSend } = input;
3801
+ if (session === void 0) {
3802
+ if (client === void 0) throw new Error("An external eve session is required before sending.");
3803
+ if (turn.message === void 0) throw new Error("Cannot answer an input request before the session starts.");
3804
+ const created = await client.sessions.create({
3805
+ ...turn,
3806
+ message: turn.message
3807
+ });
3808
+ turn.signal?.throwIfAborted();
3809
+ return {
3810
+ ...created,
3811
+ created: true
3812
+ };
3813
+ }
3814
+ beforeSend?.();
3815
+ if (turn.inputResponses === void 0) {
3816
+ const { message, ...options } = turn;
3817
+ return {
3818
+ session,
3819
+ response: await session.send(message, options),
3820
+ created: false
3821
+ };
3822
+ }
3823
+ const { inputResponses, ...options } = turn;
3203
3824
  return {
3204
- initial() {
3205
- return { messages: [] };
3206
- },
3207
- reduce(data, event) {
3208
- return reduceMessageData(data, event);
3209
- }
3825
+ session,
3826
+ response: await session.respond(inputResponses, options),
3827
+ created: false
3210
3828
  };
3211
3829
  }
3212
- function reduceMessageData(data, event) {
3213
- switch (event.type) {
3214
- case "client.message.submitted": return upsertMessage(data, {
3215
- id: optimisticUserMessageId(event.data.submissionId),
3216
- metadata: {
3217
- optimistic: true,
3218
- status: "submitted"
3219
- },
3220
- parts: [{
3221
- type: "text",
3222
- text: event.data.message
3223
- }],
3224
- role: "user"
3830
+
3831
+ //#endregion
3832
+ //#region src/client/eve-agent-store.ts
3833
+ const detachStore = Symbol("detachEveAgentStore");
3834
+ const attachStore = Symbol("attachEveAgentStore");
3835
+ var EveAgentStore = class {
3836
+ #client;
3837
+ #autoPrewarm;
3838
+ #attached = false;
3839
+ #conversationClient;
3840
+ #followChildStreams;
3841
+ #externalSession;
3842
+ #subscribers = /* @__PURE__ */ new Set();
3843
+ #activeTurn;
3844
+ #callbacks = {};
3845
+ #error;
3846
+ #events;
3847
+ #messageSubmissions;
3848
+ #prewarmGeneration = 0;
3849
+ #prewarmPromise;
3850
+ #prewarmController;
3851
+ #resumePromise;
3852
+ #session;
3853
+ #snapshot;
3854
+ #status = "ready";
3855
+ constructor(init) {
3856
+ this.#autoPrewarm = init.prewarm ?? false;
3857
+ this.#followChildStreams = init.followSubagents ?? false;
3858
+ this.#externalSession = init.session !== void 0;
3859
+ this.#client = this.#externalSession ? void 0 : init.client ?? new Client({
3860
+ auth: init.auth,
3861
+ headers: init.headers,
3862
+ host: init.host ?? ""
3225
3863
  });
3226
- case "client.message.failed": return upsertMessage(data, {
3227
- id: optimisticUserMessageId(event.data.submissionId),
3228
- metadata: {
3229
- optimistic: true,
3230
- status: "failed"
3231
- },
3232
- parts: [{
3233
- type: "text",
3234
- text: event.data.message
3235
- }],
3236
- role: "user"
3864
+ this.#conversationClient = new ConversationClient(new EveAgentProjection(init.reducer, []), () => this.#publish(), () => this.#publish());
3865
+ this.#events = (init.initialEvents ?? []).filter((event) => this.#conversationClient.hydrate(event));
3866
+ this.#messageSubmissions = new OptimisticMessageSubmissions(this.#conversationClient.projections, init.optimistic ?? true);
3867
+ this.#session = init.session ?? (init.initialSession === void 0 ? void 0 : this.#client?.sessions.attach(init.initialSession.sessionId, { streamIndex: init.initialSession.streamIndex }));
3868
+ this.#snapshot = this.#createSnapshot();
3869
+ }
3870
+ get snapshot() {
3871
+ return this.#snapshot;
3872
+ }
3873
+ setCallbacks(callbacks) {
3874
+ this.#callbacks = callbacks;
3875
+ }
3876
+ subscribe(callback) {
3877
+ this.#subscribers.add(callback);
3878
+ return () => void this.#subscribers.delete(callback);
3879
+ }
3880
+ prewarm() {
3881
+ if (this.#prewarmPromise !== void 0) return this.#prewarmPromise;
3882
+ if (this.#session !== void 0 || this.#externalSession) return Promise.resolve();
3883
+ if (this.#activeTurn !== void 0) return this.#activeTurn.response.then((response) => {
3884
+ if (response === void 0) throw this.#error ?? new DOMException("Session creation was aborted.", "AbortError");
3237
3885
  });
3238
- case "input.resolved": {
3239
- let next = data;
3240
- for (const resolution of event.data.resolutions) next = resolveInputRequest(next, resolution);
3241
- return next;
3242
- }
3243
- case "message.received":
3244
- if (event.data.kind === "execution.background_task") return data;
3245
- return upsertMessage(data, {
3246
- id: `${receivedMessageEventId(event)}:user`,
3247
- metadata: {
3248
- status: "complete",
3249
- turnId: event.data.turnId
3250
- },
3251
- parts: projectReceivedParts(event.data.parts, event.data.message),
3252
- role: "user"
3253
- });
3254
- case "step.started": return updateAssistantMessage(data, event.data.turnId, (message) => ensureStepStartPart(message, event.data.stepIndex));
3255
- case "reasoning.appended": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.append(ensureStepStartPart(message, event.data.stepIndex), {
3256
- delta: event.data.reasoningDelta,
3257
- stepIndex: event.data.stepIndex,
3258
- type: "reasoning"
3259
- }));
3260
- case "reasoning.completed": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.upsert(ensureStepStartPart(message, event.data.stepIndex), {
3261
- state: "done",
3262
- stepIndex: event.data.stepIndex,
3263
- text: event.data.reasoning,
3264
- type: "reasoning"
3265
- }));
3266
- case "action.input.appended": {
3267
- const existing = findToolPart(data, event.data.callId);
3268
- if (existing !== void 0 && existing.state !== "input-streaming") return data;
3269
- const nextPart = {
3270
- input: void 0,
3271
- inputText: (existing?.state === "input-streaming" ? existing.inputText : "") + event.data.inputTextDelta,
3272
- state: "input-streaming",
3273
- stepIndex: event.data.stepIndex,
3274
- toolCallId: event.data.callId,
3275
- toolMetadata: existing?.toolMetadata ?? { eve: {
3276
- kind: "unknown",
3277
- name: event.data.toolName
3278
- } },
3279
- toolName: event.data.toolName,
3280
- type: "dynamic-tool"
3281
- };
3282
- if (existing !== void 0) return updateToolPart(data, event.data.callId, nextPart);
3283
- return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), nextPart));
3284
- }
3285
- case "actions.requested": {
3286
- let next = data;
3287
- for (const action of event.data.actions) {
3288
- const descriptor = normalizeActionRequest(action);
3289
- next = updateAssistantMessage(next, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
3290
- input: "input" in action ? action.input : void 0,
3291
- state: "input-available",
3292
- stepIndex: event.data.stepIndex,
3293
- toolCallId: action.callId,
3294
- toolMetadata: createToolMetadata(descriptor),
3295
- toolName: descriptor.toolName,
3296
- type: "dynamic-tool"
3297
- }));
3886
+ const client = this.#client;
3887
+ if (client === void 0) return Promise.reject(/* @__PURE__ */ new Error("This eve agent store does not own a session client."));
3888
+ const generation = this.#prewarmGeneration;
3889
+ const controller = new AbortController();
3890
+ this.#prewarmController = controller;
3891
+ const promise = (async () => {
3892
+ try {
3893
+ const created = await client.sessions.create({ signal: controller.signal });
3894
+ if (generation !== this.#prewarmGeneration) return;
3895
+ this.#error = void 0;
3896
+ if (this.#status === "error") this.#status = "ready";
3897
+ this.#adoptSession(created.session);
3898
+ this.#ensureStream();
3899
+ } catch (error) {
3900
+ if (generation === this.#prewarmGeneration && this.#activeTurn === void 0 && this.#error === void 0) this.#fail(error);
3901
+ throw error;
3298
3902
  }
3299
- return next;
3903
+ })();
3904
+ this.#prewarmPromise = promise;
3905
+ const clear = () => {
3906
+ if (this.#prewarmPromise === promise) {
3907
+ this.#prewarmPromise = void 0;
3908
+ this.#prewarmController = void 0;
3909
+ }
3910
+ };
3911
+ promise.then(clear, clear);
3912
+ return promise;
3913
+ }
3914
+ async send(input) {
3915
+ return await this.#submit(input, this.#callbacks.prepareSend);
3916
+ }
3917
+ async #submit(input, prepareSend) {
3918
+ assertAnswerable(input, this.#conversationClient.conversation);
3919
+ if (this.#activeTurn !== void 0) {
3920
+ if (this.#status === "resuming") throw new Error("eve session is resuming.");
3921
+ return await this.#sendFollowUp(this.#activeTurn, input, prepareSend);
3300
3922
  }
3301
- case "input.requested": {
3302
- let next = data;
3303
- for (const request of event.data.requests) {
3304
- const descriptor = normalizeActionRequest(request.action);
3305
- next = updateAssistantMessage(next, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
3306
- approval: { id: request.requestId },
3307
- input: request.action.input,
3308
- state: "approval-requested",
3309
- stepIndex: event.data.stepIndex,
3310
- toolCallId: request.action.callId,
3311
- toolMetadata: createToolMetadata(descriptor, { inputRequest: toMessageInputRequest(request) }),
3312
- toolName: descriptor.toolName,
3313
- type: "dynamic-tool"
3314
- }));
3923
+ 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()));
3924
+ this.#activeTurn = turn;
3925
+ this.#error = void 0;
3926
+ this.#status = "submitted";
3927
+ let reader;
3928
+ let submissionId;
3929
+ let retractResponses;
3930
+ try {
3931
+ assertExclusiveTurnInput(input);
3932
+ submissionId = this.#messageSubmissions.submit(input, this.#events.length);
3933
+ retractResponses = this.#conversationClient.projectResponses(input.inputResponses);
3934
+ this.#publish();
3935
+ const preparedInput = await (prepareSend === void 0 ? input : waitWithSignal(Promise.resolve(prepareSend(input)), createAbortSignal(input.signal, turn.abortController.signal)));
3936
+ assertExclusiveTurnInput(preparedInput);
3937
+ if (!this.#isActiveTurn(turn)) return;
3938
+ if (preparedInput !== input) {
3939
+ submissionId = this.#messageSubmissions.resubmit(submissionId, preparedInput);
3940
+ retractResponses = this.#conversationClient.replaceResponses(retractResponses, preparedInput);
3941
+ this.#publish();
3315
3942
  }
3316
- return next;
3943
+ const turnInput = {
3944
+ ...preparedInput,
3945
+ signal: createAbortSignal(preparedInput.signal, turn.abortController.signal)
3946
+ };
3947
+ const dispatched = await this.#dispatchTurn(turnInput);
3948
+ retractResponses = void 0;
3949
+ const response = dispatched.response;
3950
+ reader = dispatched.reader;
3951
+ if (!this.#isActiveTurn(turn)) return;
3952
+ turn.resolveResponse(response);
3953
+ this.#correlate(submissionId, response);
3954
+ for await (const event of consumeMessageResponse(response, reader)) {
3955
+ if (!this.#isActiveTurn(turn)) return;
3956
+ turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
3957
+ turn.receivedFollowUpEvents.delete(event);
3958
+ }
3959
+ if (!this.#isActiveTurn(turn)) return;
3960
+ await followSteeredTurns(turn, reader, () => this.#isActiveTurn(turn));
3961
+ if (!this.#isActiveTurn(turn)) return;
3962
+ this.#status = settledStatus(this.#error, this.#conversationClient.conversation);
3963
+ } catch (error) {
3964
+ if (!this.#isActiveTurn(turn)) return;
3965
+ retractResponses?.();
3966
+ if (isAbortError(error)) {
3967
+ this.#status = "ready";
3968
+ this.#messageSubmissions.fail(toError(error), submissionId);
3969
+ } else {
3970
+ const reported = this.#error !== void 0;
3971
+ this.#error ??= toError(error);
3972
+ this.#status = "error";
3973
+ this.#messageSubmissions.fail(this.#error, submissionId);
3974
+ if (!reported) this.#callbacks.onError?.(this.#error);
3975
+ }
3976
+ } finally {
3977
+ reader?.[Symbol.dispose]();
3978
+ this.#finishTurn(turn);
3317
3979
  }
3318
- case "approval.candidate": return data;
3319
- case "approval.settled": {
3320
- const existing = findToolPartByApprovalId(data, event.data.requestId);
3321
- if (existing === void 0) return data;
3322
- if (event.data.outcome === "approved") return updateToolPart(data, existing.toolCallId, {
3323
- approval: {
3324
- approved: true,
3325
- id: event.data.requestId,
3326
- reason: void 0
3327
- },
3328
- input: existing.input,
3329
- state: "approval-responded",
3330
- stepIndex: existing.stepIndex,
3331
- toolCallId: existing.toolCallId,
3332
- toolMetadata: existing.toolMetadata,
3333
- toolName: existing.toolName,
3334
- type: "dynamic-tool"
3335
- });
3336
- return updateToolPart(data, existing.toolCallId, {
3337
- approval: {
3338
- approved: false,
3339
- id: event.data.requestId,
3340
- reason: "Tool execution was cancelled."
3341
- },
3342
- input: existing.input,
3343
- state: "output-denied",
3344
- stepIndex: existing.stepIndex,
3345
- toolCallId: existing.toolCallId,
3346
- toolMetadata: existing.toolMetadata,
3347
- toolName: existing.toolName,
3348
- type: "dynamic-tool"
3980
+ }
3981
+ resume() {
3982
+ if (this.#resumePromise !== void 0) return this.#resumePromise;
3983
+ const promise = this.#resume();
3984
+ this.#resumePromise = promise;
3985
+ const clear = () => {
3986
+ if (this.#resumePromise === promise) this.#resumePromise = void 0;
3987
+ };
3988
+ promise.then(clear, clear);
3989
+ return promise;
3990
+ }
3991
+ async #resume() {
3992
+ if (this.#status !== "ready" && this.#status !== "error") throw new Error("eve session is already processing a turn.");
3993
+ if (this.#session === void 0) throw new Error("An eve session is required before resuming.");
3994
+ const session = this.#session;
3995
+ const turn = createActiveTurn(() => session.cancel());
3996
+ this.#activeTurn = turn;
3997
+ turn.resolveResponse(void 0);
3998
+ this.#error = void 0;
3999
+ this.#status = "resuming";
4000
+ this.#publish();
4001
+ let reader;
4002
+ try {
4003
+ const stream = this.#ensureStream({
4004
+ catchUp: true,
4005
+ startIndex: this.#events.length === session.state.streamIndex ? session.state.streamIndex : 0
3349
4006
  });
4007
+ reader = stream.subscribe(turn.abortController.signal);
4008
+ await stream.caughtUp;
4009
+ if (!this.#isActiveTurn(turn)) return;
4010
+ reader.discard();
4011
+ const tail = this.#events.at(-1);
4012
+ if (tail !== void 0) this.#applyTerminalStreamFailure(tail);
4013
+ if (tail && !this.#error && !isSettledSessionTail(this.#events, this.#conversationClient.conversation)) {
4014
+ this.#status = "streaming";
4015
+ this.#publish();
4016
+ for await (const event of reader) {
4017
+ if (!this.#isActiveTurn(turn)) return;
4018
+ turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
4019
+ turn.receivedFollowUpEvents.delete(event);
4020
+ if (isResponseBoundary(event, this.#conversationClient.conversation)) break;
4021
+ }
4022
+ }
4023
+ await followSteeredTurns(turn, reader, () => this.#isActiveTurn(turn));
4024
+ if (this.#isActiveTurn(turn)) this.#status = settledStatus(this.#error, this.#conversationClient.conversation);
4025
+ } catch (error) {
4026
+ if (!this.#isActiveTurn(turn)) return;
4027
+ if (isAbortError(error)) this.#status = "ready";
4028
+ else {
4029
+ this.#error = toError(error);
4030
+ this.#status = "error";
4031
+ this.#callbacks.onError?.(this.#error);
4032
+ }
4033
+ } finally {
4034
+ reader?.[Symbol.dispose]();
4035
+ this.#finishTurn(turn);
3350
4036
  }
3351
- case "action.result": {
3352
- const descriptor = normalizeActionResult(event.data.result);
3353
- const existing = findToolPart(data, event.data.result.callId);
3354
- const denied = event.data.error?.code === "TOOL_EXECUTION_DENIED";
3355
- const failed = event.data.status === "failed" && !denied;
3356
- const approvalId = existing?.approval?.id ?? event.data.result.callId;
3357
- const toolMetadata = mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor));
3358
- const resultPartBase = {
3359
- input: existing?.input,
3360
- stepIndex: event.data.stepIndex,
3361
- toolCallId: event.data.result.callId,
3362
- toolMetadata,
3363
- toolName: existing?.toolName ?? descriptor.toolName,
3364
- type: "dynamic-tool"
3365
- };
3366
- let nextPart;
3367
- if (denied) nextPart = {
3368
- ...resultPartBase,
3369
- approval: {
3370
- approved: false,
3371
- id: approvalId,
3372
- reason: event.data.error?.message
3373
- },
3374
- state: "output-denied"
3375
- };
3376
- else if (failed) nextPart = {
3377
- ...resultPartBase,
3378
- approval: approvedApproval(existing),
3379
- errorText: event.data.error?.message ?? stringifyUnknown(event.data.result.output),
3380
- state: "output-error"
3381
- };
3382
- else nextPart = {
3383
- ...resultPartBase,
3384
- approval: approvedApproval(existing),
3385
- output: event.data.result.output,
3386
- state: "output-available"
3387
- };
3388
- if (existing !== void 0) return updateToolPart(data, event.data.result.callId, nextPart);
3389
- return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), nextPart));
4037
+ }
4038
+ cancel() {
4039
+ const turn = this.#activeTurn;
4040
+ if (turn === void 0) return this.#status === "streaming" && this.#session !== void 0 ? this.#session.cancel() : Promise.resolve({ status: "no_active_turn" });
4041
+ return turn.cancel();
4042
+ }
4043
+ async compact() {
4044
+ return await this.#session?.compact() ?? { status: "no_active_session" };
4045
+ }
4046
+ async clear() {
4047
+ return await this.#session?.clear() ?? { status: "no_active_session" };
4048
+ }
4049
+ async retire() {
4050
+ 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.");
4051
+ const result = await this.#session?.reset() ?? { status: "no_active_session" };
4052
+ this.reset();
4053
+ return result;
4054
+ }
4055
+ [attachStore]() {
4056
+ this.#attached = true;
4057
+ if (this.#followChildStreams && !this.#conversationClient.following) this.#followSubagents();
4058
+ if (this.#autoPrewarm && this.#session === void 0) this.prewarm().catch(() => {});
4059
+ }
4060
+ [detachStore]() {
4061
+ this.#attached = false;
4062
+ this.#conversationClient.stop();
4063
+ this.#activeTurn?.abortController.abort();
4064
+ this.#resetPrewarm();
4065
+ this.#resumePromise = void 0;
4066
+ }
4067
+ reset() {
4068
+ this.#conversationClient.stop();
4069
+ const turn = this.#activeTurn;
4070
+ this.#activeTurn = void 0;
4071
+ turn?.resolveResponse(void 0);
4072
+ turn?.resolveCompletion();
4073
+ turn?.abortController.abort();
4074
+ this.#resetPrewarm();
4075
+ this.#resumePromise = void 0;
4076
+ if (!this.#externalSession) this.#session = void 0;
4077
+ this.#events = [];
4078
+ this.#conversationClient.reset();
4079
+ this.#messageSubmissions.reset();
4080
+ if (this.#followChildStreams && this.#attached) this.#followSubagents();
4081
+ this.#error = void 0;
4082
+ this.#status = "ready";
4083
+ this.#callbacks.onSessionChange?.(this.#session?.state);
4084
+ this.#publish();
4085
+ if (this.#autoPrewarm && this.#attached) this.prewarm().catch(() => {});
4086
+ }
4087
+ async #sendFollowUp(turn, input, prepareSend) {
4088
+ assertInFlightFollowUp(input);
4089
+ const generation = this.#prewarmGeneration;
4090
+ const signal = createAbortSignal(input.signal, turn.abortController.signal);
4091
+ let retractResponses = this.#conversationClient.projectResponses(input.inputResponses);
4092
+ const preparedInput = await waitWithSignal(Promise.resolve(prepareSend?.(input)), signal).then((prepared) => {
4093
+ const next = validateFollowUp(prepared ?? input);
4094
+ if (next === input) return next;
4095
+ retractResponses = this.#conversationClient.replaceResponses(retractResponses, next);
4096
+ return next;
4097
+ }).catch((error) => {
4098
+ retractResponses?.();
4099
+ throw error;
4100
+ });
4101
+ if (generation !== this.#prewarmGeneration) return;
4102
+ if (!this.#isActiveTurn(turn)) {
4103
+ retractResponses?.();
4104
+ return await this.#submit(preparedInput);
4105
+ }
4106
+ const submissionId = this.#messageSubmissions.submit(preparedInput, this.#events.length, activeTurnForOptimisticFollowUp(this.#events));
4107
+ if (submissionId !== void 0) turn.followUpSubmissionIds.add(submissionId);
4108
+ this.#publish();
4109
+ let dispatch;
4110
+ dispatch = (async () => {
4111
+ try {
4112
+ const signal = createAbortSignal(preparedInput.signal, turn.abortController.signal);
4113
+ await waitWithSignal(turn.response, signal);
4114
+ if (!this.#isActiveTurn(turn) || this.#session === void 0) throw new Error("The active eve turn ended before the follow-up could be sent.");
4115
+ this.#ensureStream({
4116
+ headers: preparedInput.headers,
4117
+ streamReconnectPolicy: preparedInput.streamReconnectPolicy
4118
+ });
4119
+ const response = (await dispatchSessionTurn({
4120
+ session: this.#session,
4121
+ turn: {
4122
+ ...preparedInput,
4123
+ signal
4124
+ }
4125
+ })).response;
4126
+ retractResponses = void 0;
4127
+ if (preparedInput.message === void 0) return;
4128
+ turn.acceptedFollowUps += 1;
4129
+ this.#correlate(submissionId, response);
4130
+ } catch (error) {
4131
+ if (this.#isActiveTurn(turn)) {
4132
+ this.#messageSubmissions.fail(toError(error), submissionId);
4133
+ retractResponses?.();
4134
+ this.#publish();
4135
+ }
4136
+ throw error;
4137
+ } finally {
4138
+ turn.followUpDispatches.delete(dispatch);
4139
+ }
4140
+ })();
4141
+ turn.followUpDispatches.add(dispatch);
4142
+ await dispatch;
4143
+ await turn.completion;
4144
+ }
4145
+ async #dispatchTurn(input) {
4146
+ const streamOptions = {
4147
+ headers: input.headers,
4148
+ streamReconnectPolicy: input.streamReconnectPolicy
4149
+ };
4150
+ if (this.#prewarmPromise !== void 0) {
4151
+ await waitWithSignal(this.#prewarmPromise.catch((error) => {
4152
+ if (this.#session !== void 0) throw error;
4153
+ }), input.signal);
4154
+ input.signal?.throwIfAborted();
3390
4155
  }
3391
- case "action.partial": {
3392
- const existing = findToolPart(data, event.data.result.callId);
3393
- if (existing !== void 0 && isSettledToolPart(existing)) return data;
3394
- const descriptor = normalizeActionResult(event.data.result);
3395
- const nextPart = {
3396
- approval: approvedApproval(existing),
3397
- input: existing?.input,
3398
- output: event.data.result.output,
3399
- partial: true,
3400
- state: "output-available",
3401
- stepIndex: event.data.stepIndex,
3402
- toolCallId: event.data.result.callId,
3403
- toolMetadata: mergeToolMetadata(existing?.toolMetadata, createToolMetadata(descriptor)),
3404
- toolName: existing?.toolName ?? descriptor.toolName,
3405
- type: "dynamic-tool"
4156
+ const session = this.#session;
4157
+ let reader;
4158
+ try {
4159
+ const dispatched = await dispatchSessionTurn({
4160
+ client: this.#client,
4161
+ session,
4162
+ turn: input,
4163
+ beforeSend: () => {
4164
+ reader = this.#ensureStream(streamOptions).subscribe(input.signal);
4165
+ }
4166
+ });
4167
+ if (dispatched.created) {
4168
+ this.#adoptSession(dispatched.session);
4169
+ reader = this.#ensureStream(streamOptions).subscribe(input.signal);
4170
+ }
4171
+ return {
4172
+ response: dispatched.response,
4173
+ reader
3406
4174
  };
3407
- if (existing !== void 0) return updateToolPart(data, event.data.result.callId, nextPart);
3408
- return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), nextPart));
4175
+ } catch (error) {
4176
+ reader?.[Symbol.dispose]();
4177
+ throw error;
3409
4178
  }
3410
- case "authorization.required": return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), createAuthorizationRequiredPart(event)));
3411
- case "authorization.completed": return completeAuthorization(data, event);
3412
- case "message.appended": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.append(ensureStepStartPart(message, event.data.stepIndex), {
3413
- delta: event.data.messageDelta,
3414
- stepIndex: event.data.stepIndex,
3415
- type: "text"
3416
- }));
3417
- case "message.completed": return updateAssistantMessage(data, event.data.turnId, (message) => {
3418
- if (event.data.message === null) return removeTextPart(message, event.data.stepIndex);
3419
- return messageRun.upsert(ensureStepStartPart(message, event.data.stepIndex), {
3420
- state: "done",
3421
- stepIndex: event.data.stepIndex,
3422
- text: event.data.message,
3423
- type: "text"
3424
- });
4179
+ }
4180
+ #ensureStream(options = {}) {
4181
+ if (this.#session === void 0) throw new Error("A session is required before opening its stream.");
4182
+ const generation = this.#prewarmGeneration;
4183
+ if (this.#followChildStreams && !this.#conversationClient.following) this.#followSubagents();
4184
+ return this.#conversationClient.stream(this.#session, {
4185
+ ...options,
4186
+ onEvent: (event) => {
4187
+ if (generation === this.#prewarmGeneration) this.#acceptServerEvent(event);
4188
+ },
4189
+ onError: (error) => {
4190
+ if (generation !== this.#prewarmGeneration || this.#activeTurn !== void 0) return;
4191
+ this.#fail(error);
4192
+ }
3425
4193
  });
3426
- case "result.completed": return updateAssistantMetadata(data, event.data.turnId, { result: event.data.result });
3427
- case "turn.completed": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3428
- ...message,
3429
- metadata: {
3430
- ...message.metadata,
3431
- status: "complete"
4194
+ }
4195
+ #adoptSession(session) {
4196
+ this.#session = session;
4197
+ if (this.#followChildStreams && this.#attached) this.#followSubagents();
4198
+ this.#callbacks.onSessionChange?.(session.state);
4199
+ this.#publish();
4200
+ }
4201
+ #fail(error) {
4202
+ this.#error = toError(error);
4203
+ this.#status = "error";
4204
+ this.#callbacks.onError?.(this.#error);
4205
+ this.#publish();
4206
+ }
4207
+ #followSubagents() {
4208
+ if (this.#session) this.#conversationClient.follow(this.#session, this.#events);
4209
+ }
4210
+ #resetPrewarm() {
4211
+ this.#prewarmGeneration += 1;
4212
+ this.#prewarmController?.abort();
4213
+ this.#prewarmController = void 0;
4214
+ this.#prewarmPromise = void 0;
4215
+ }
4216
+ #finishTurn(turn) {
4217
+ if (!this.#isActiveTurn(turn)) return;
4218
+ turn.resolveResponse(void 0);
4219
+ this.#activeTurn = void 0;
4220
+ try {
4221
+ this.#callbacks.onSessionChange?.(this.#session?.state);
4222
+ this.#publish();
4223
+ this.#callbacks.onFinish?.(this.#snapshot);
4224
+ } finally {
4225
+ turn.resolveCompletion();
4226
+ }
4227
+ }
4228
+ #isActiveTurn(turn) {
4229
+ return this.#activeTurn === turn;
4230
+ }
4231
+ #acceptServerEvent(event) {
4232
+ const wasStreaming = this.#status === "streaming";
4233
+ if (!this.#conversationClient.observe(event, {
4234
+ onAccepted: () => {
4235
+ this.#events = [...this.#events, event];
3432
4236
  },
3433
- parts: removeStreamingToolParts(message.parts)
3434
- }));
3435
- case "turn.cancelled": return updateAssistantMessage(data, event.data.turnId, (message) => ({
3436
- ...message,
3437
- metadata: {
3438
- ...message.metadata,
3439
- status: "complete"
4237
+ project: (accepted) => {
4238
+ this.#handleReconciliation(this.#messageSubmissions.apply(accepted));
3440
4239
  },
3441
- parts: removeStreamingToolParts(message.parts.map((part) => (part.type === "text" || part.type === "reasoning") && part.state === "streaming" ? {
3442
- ...part,
3443
- state: "done"
3444
- } : part))
3445
- }));
3446
- case "turn.failed": return removeStreamingToolPartsForTurn(data, event.data.turnId);
3447
- case "session.failed": return data;
3448
- default: return data;
4240
+ notify: false
4241
+ })) return false;
4242
+ this.#callbacks.onEvent?.(event);
4243
+ this.#applyTerminalStreamFailure(event);
4244
+ const { conversation } = this.#conversationClient;
4245
+ const settled = isSettledSessionTail(this.#events, conversation) && conversation.activeTurnId === void 0;
4246
+ if (this.#status !== "resuming" && this.#error === void 0) {
4247
+ if ("data" in event && event.data !== void 0 && "turnId" in event.data) this.#status = "streaming";
4248
+ if (this.#activeTurn === void 0 && settled) this.#status = "ready";
4249
+ }
4250
+ this.#callbacks.onSessionChange?.(this.#session?.state);
4251
+ if (this.#status !== "resuming") this.#publish();
4252
+ if (this.#activeTurn === void 0 && wasStreaming && settled) this.#callbacks.onFinish?.(this.#snapshot);
4253
+ return true;
3449
4254
  }
3450
- }
3451
- function removeStreamingToolParts(parts) {
3452
- return parts.filter((part) => part.type !== "dynamic-tool" || part.state !== "input-streaming");
3453
- }
3454
- function respondToInputRequest(data, response) {
3455
- const existing = findToolPartByApprovalId(data, response.requestId);
3456
- if (!existing) return data;
3457
- const approval = { id: response.requestId };
3458
- if (response.text !== void 0) approval.reason = response.text;
3459
- return updateToolPart(data, existing.toolCallId, {
3460
- approval,
3461
- input: existing.input,
3462
- state: "approval-responded",
3463
- stepIndex: existing.stepIndex,
3464
- toolCallId: existing.toolCallId,
3465
- toolMetadata: mergeToolMetadata(existing.toolMetadata, { eve: {
3466
- inputResponse: response,
3467
- kind: existing.toolMetadata?.eve?.kind ?? "unknown",
3468
- name: existing.toolMetadata?.eve?.name ?? existing.toolName
3469
- } }),
3470
- toolName: existing.toolName,
3471
- type: "dynamic-tool"
3472
- });
3473
- }
3474
- function resolveInputRequest(data, resolution) {
3475
- if (resolution.response !== void 0) return respondToInputRequest(data, resolution.response);
3476
- const existing = findToolPartByApprovalId(data, resolution.requestId);
3477
- if (!existing) return data;
3478
- return updateToolPart(data, existing.toolCallId, {
3479
- input: existing.input,
3480
- output: { status: resolution.outcome },
3481
- state: "output-available",
3482
- stepIndex: existing.stepIndex,
3483
- toolCallId: existing.toolCallId,
3484
- toolMetadata: existing.toolMetadata,
3485
- toolName: existing.toolName,
3486
- type: "dynamic-tool"
3487
- });
3488
- }
3489
- function updateAssistantMessage(data, turnId, update) {
3490
- const message = data.messages.find((message) => message.role === "assistant" && message.metadata?.turnId === turnId) ?? createAssistantMessage(turnId);
3491
- return upsertMessage(data, update(message));
3492
- }
3493
- function updateAssistantMetadata(data, turnId, metadata) {
3494
- return updateAssistantMessage(data, turnId, (message) => ({
3495
- ...message,
3496
- metadata: {
3497
- ...message.metadata,
3498
- ...metadata
4255
+ #correlate(submissionId, response) {
4256
+ const deliveryId = getMessageResponseDeliveryId(response);
4257
+ const reconciled = this.#messageSubmissions.correlate(submissionId, deliveryId, this.#events);
4258
+ if (this.#handleReconciliation(reconciled)) this.#publish();
4259
+ }
4260
+ #handleReconciliation(reconciliation) {
4261
+ if (reconciliation === void 0) return false;
4262
+ if (this.#activeTurn !== void 0) countFollowUpDeliveries(this.#activeTurn, reconciliation);
4263
+ return true;
4264
+ }
4265
+ #applyTerminalStreamFailure(event) {
4266
+ const error = toTerminalStreamFailureError(event);
4267
+ if (error === void 0) return;
4268
+ this.#status = "error";
4269
+ this.#messageSubmissions.failAll(error);
4270
+ if (this.#error === void 0) {
4271
+ this.#error = error;
4272
+ this.#callbacks.onError?.(error);
3499
4273
  }
3500
- }));
3501
- }
3502
- function createAssistantMessage(turnId) {
3503
- return {
3504
- id: `${turnId}:assistant`,
3505
- metadata: {
3506
- status: "streaming",
3507
- turnId
3508
- },
3509
- parts: [],
3510
- role: "assistant"
3511
- };
3512
- }
3513
- function ensureStepStartPart(message, stepIndex) {
3514
- const stepStartCount = message.parts.filter((part) => part.type === "step-start").length;
3515
- if (stepStartCount > stepIndex) return message;
3516
- const missingCount = stepIndex - stepStartCount + 1;
3517
- return {
3518
- ...message,
3519
- parts: [...message.parts, ...Array.from({ length: missingCount }, () => ({ type: "step-start" }))]
3520
- };
3521
- }
3522
- function upsertPart(message, next) {
3523
- const index = message.parts.findIndex((part) => partKey(part) === partKey(next));
3524
- const parts = index === -1 ? [...message.parts, next] : [
3525
- ...message.parts.slice(0, index),
3526
- next,
3527
- ...message.parts.slice(index + 1)
3528
- ];
3529
- return {
3530
- ...message,
3531
- metadata: {
3532
- ...message.metadata,
3533
- status: next.type === "text" && next.state === "done" ? "complete" : "streaming"
3534
- },
3535
- parts
3536
- };
3537
- }
3538
- function removeTextPart(message, stepIndex) {
3539
- const parts = message.parts.filter((part) => part.type !== "text" || part.stepIndex !== stepIndex);
3540
- if (parts.length === message.parts.length) return message;
3541
- return {
3542
- ...message,
3543
- metadata: {
3544
- ...message.metadata,
3545
- status: "complete"
3546
- },
3547
- parts
3548
- };
3549
- }
3550
- function updateToolPart(data, toolCallId, next) {
3551
- const message = data.messages.find((candidate) => candidate.role === "assistant" && candidate.parts.some((part) => part.type === "dynamic-tool" && part.toolCallId === toolCallId));
3552
- if (!message) return data;
3553
- return upsertMessage(data, upsertPart(message, next));
3554
- }
3555
- function completeAuthorization(data, event) {
3556
- const existing = findLatestPendingAuthorizationPart(data, event.data.name);
3557
- const next = createAuthorizationCompletedPart(event, existing);
3558
- if (existing !== void 0) return updateAuthorizationPart(data, existing, next);
3559
- return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), next));
3560
- }
3561
- function updateAuthorizationPart(data, existing, next) {
3562
- const message = data.messages.find((candidate) => candidate.role === "assistant" && candidate.parts.some((part) => part === existing));
3563
- if (!message) return data;
3564
- return upsertMessage(data, upsertPart(message, next));
3565
- }
3566
- function findToolPart(data, toolCallId) {
3567
- for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.toolCallId === toolCallId) return part;
4274
+ }
4275
+ #createSnapshot() {
4276
+ return {
4277
+ data: this.#conversationClient.data,
4278
+ conversation: this.#conversationClient.conversation,
4279
+ error: this.#error,
4280
+ events: this.#events,
4281
+ session: this.#session?.state,
4282
+ status: this.#status
4283
+ };
4284
+ }
4285
+ #publish() {
4286
+ this.#snapshot = this.#createSnapshot();
4287
+ for (const subscriber of this.#subscribers) subscriber();
4288
+ }
4289
+ };
4290
+ function detachEveAgentStore(store) {
4291
+ store[detachStore]();
3568
4292
  }
3569
- function isSettledToolPart(part) {
3570
- return part.state === "output-denied" || part.state === "output-error" || part.state === "output-available" && part.partial !== true;
4293
+ function attachEveAgentStore(store) {
4294
+ store[attachStore]();
3571
4295
  }
3572
- function findLatestPendingAuthorizationPart(data, name) {
3573
- for (let messageIndex = data.messages.length - 1; messageIndex >= 0; messageIndex -= 1) {
3574
- const message = data.messages[messageIndex];
3575
- if (message?.role !== "assistant") continue;
3576
- for (let partIndex = message.parts.length - 1; partIndex >= 0; partIndex -= 1) {
3577
- const part = message.parts[partIndex];
3578
- if (part?.type === "authorization" && part.state === "required" && part.name === name) return part;
3579
- }
3580
- }
4296
+
4297
+ //#endregion
4298
+ //#region src/client/agent-host.ts
4299
+ const AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
4300
+ const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve";
4301
+ function resolveEveAgentHost(input) {
4302
+ if (input.agent === void 0) return input.host ?? "";
4303
+ if (input.host !== void 0) throw new Error("useEveAgent cannot combine agent and host. Use one target option.");
4304
+ assertValidAgentName(input.agent);
4305
+ return `${EVE_NAMED_AGENT_ROUTE_PREFIX}/${input.agent}`;
3581
4306
  }
3582
- function findToolPartByApprovalId(data, approvalId) {
3583
- for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.approval?.id === approvalId) return part;
4307
+ function assertValidAgentName(name) {
4308
+ 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.`);
3584
4309
  }
3585
4310
 
3586
4311
  //#endregion
@@ -3607,6 +4332,10 @@ var SvelteEveAgent = class {
3607
4332
  this.#subscribe();
3608
4333
  return this.#snapshot.data;
3609
4334
  }
4335
+ get conversation() {
4336
+ this.#subscribe();
4337
+ return this.#snapshot.conversation;
4338
+ }
3610
4339
  get error() {
3611
4340
  this.#subscribe();
3612
4341
  return this.#snapshot.error;
@@ -3650,7 +4379,7 @@ var SvelteEveAgent = class {
3650
4379
  };
3651
4380
  function useEveAgent(options = {}) {
3652
4381
  if (options.resume && options.initialSession === void 0 && options.session === void 0) throw new Error("useEveAgent({ resume: true }) requires initialSession or session.");
3653
- const reducer = options.reducer ?? defaultMessageReducer();
4382
+ const reducer = options.reducer ?? conversationReducer;
3654
4383
  const store = new EveAgentStore({
3655
4384
  auth: options.auth,
3656
4385
  headers: options.headers,
@@ -3661,6 +4390,7 @@ function useEveAgent(options = {}) {
3661
4390
  initialEvents: options.initialEvents,
3662
4391
  initialSession: options.initialSession,
3663
4392
  optimistic: options.optimistic,
4393
+ followSubagents: options.followSubagents,
3664
4394
  prewarm: options.prewarm,
3665
4395
  reducer,
3666
4396
  session: options.session
@@ -3681,4 +4411,4 @@ function useEveAgent(options = {}) {
3681
4411
  }
3682
4412
 
3683
4413
  //#endregion
3684
- export { defaultMessageReducer as n, useEveAgent as t };
4414
+ export { openConversationInputs as i, conversationReducer as n, defaultMessageReducer as r, useEveAgent as t };