eve 0.68.0 → 0.69.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 (1048) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/bin/eve.js +15 -0
  3. package/dist/src/_virtual/_rolldown/runtime.js +1 -1
  4. package/dist/src/approval/definition.d.ts +19 -5
  5. package/dist/src/channel/adapter.d.ts +2 -0
  6. package/dist/src/channel/auth/oidc.js +1 -1
  7. package/dist/src/channel/channel-address.d.ts +1 -4
  8. package/dist/src/channel/channel-address.js +1 -1
  9. package/dist/src/channel/channel-operations.d.ts +4 -11
  10. package/dist/src/channel/channel-operations.js +1 -1
  11. package/dist/src/channel/compiled-channel.d.ts +0 -2
  12. package/dist/src/channel/compiled-channel.js +2 -2
  13. package/dist/src/channel/cross-channel-receive.d.ts +1 -3
  14. package/dist/src/channel/cross-channel-receive.js +1 -1
  15. package/dist/src/channel/forwarded-principal.js +1 -1
  16. package/dist/src/channel/schedule-auth.d.ts +16 -0
  17. package/dist/src/channel/schedule-auth.js +1 -1
  18. package/dist/src/channel/session-callback.js +1 -1
  19. package/dist/src/channel/session.d.ts +3 -8
  20. package/dist/src/channel/session.js +1 -1
  21. package/dist/src/channel/task-card.d.ts +121 -0
  22. package/dist/src/channel/task-card.js +1 -0
  23. package/dist/src/channel/types.d.ts +12 -57
  24. package/dist/src/chunks/{use-eve-agent-DXcE_8Ja.js → use-eve-agent-D_5129A9.js} +295 -205
  25. package/dist/src/chunks/{use-eve-agent-D4HVZBjn.js → use-eve-agent-Dab2MnT2.js} +295 -205
  26. package/dist/src/cli/commands/info.d.ts +11 -0
  27. package/dist/src/cli/commands/info.js +1 -1
  28. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  29. package/dist/src/cli/commands/init.js +1 -1
  30. package/dist/src/cli/dev/command-options.d.ts +2 -2
  31. package/dist/src/cli/dev/command.js +1 -1
  32. package/dist/src/cli/dev/tui/blocks.d.ts +19 -18
  33. package/dist/src/cli/dev/tui/blocks.js +3 -3
  34. package/dist/src/cli/dev/tui/command-typeahead.d.ts +3 -6
  35. package/dist/src/cli/dev/tui/diagnostic-presentation.d.ts +10 -0
  36. package/dist/src/cli/dev/tui/diagnostic-presentation.js +3 -2
  37. package/dist/src/cli/dev/tui/prompt-placeholder.d.ts +2 -0
  38. package/dist/src/cli/dev/tui/prompt-placeholder.js +1 -0
  39. package/dist/src/cli/dev/tui/rail.d.ts +1 -1
  40. package/dist/src/cli/dev/tui/runner.d.ts +25 -2
  41. package/dist/src/cli/dev/tui/runner.js +3 -3
  42. package/dist/src/cli/dev/tui/status-line.d.ts +4 -2
  43. package/dist/src/cli/dev/tui/status-line.js +1 -1
  44. package/dist/src/cli/dev/tui/subagent-pump.d.ts +44 -52
  45. package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
  46. package/dist/src/cli/dev/tui/task-activity.d.ts +55 -0
  47. package/dist/src/cli/dev/tui/task-activity.js +1 -0
  48. package/dist/src/cli/dev/tui/terminal-renderer.d.ts +13 -30
  49. package/dist/src/cli/dev/tui/terminal-renderer.js +11 -11
  50. package/dist/src/cli/dev/tui/theme.d.ts +1 -1
  51. package/dist/src/cli/dev/tui/theme.js +1 -1
  52. package/dist/src/cli/dev/tui/tool-block-groups.d.ts +6 -9
  53. package/dist/src/cli/dev/tui/tool-block-groups.js +1 -1
  54. package/dist/src/cli/dev/tui/tool-presentation.d.ts +16 -3
  55. package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
  56. package/dist/src/cli/dev/tui/traces/trace-conversation.js +3 -1
  57. package/dist/src/cli/dev/tui/traces/trace-view.js +1 -1
  58. package/dist/src/cli/dev/tui/types.d.ts +11 -5
  59. package/dist/src/cli/dev/ui-options.d.ts +2 -2
  60. package/dist/src/cli/option-parsers.d.ts +3 -1
  61. package/dist/src/cli/option-parsers.js +1 -1
  62. package/dist/src/cli/ui/terminal-text.js +1 -1
  63. package/dist/src/client/agent-info-schema.d.ts +150 -9
  64. package/dist/src/client/agent-info-schema.js +1 -1
  65. package/dist/src/client/agent-session.d.ts +28 -0
  66. package/dist/src/client/agent-session.js +1 -0
  67. package/dist/src/client/eve-agent-store-helpers.d.ts +1 -1
  68. package/dist/src/client/eve-agent-store-helpers.js +2 -2
  69. package/dist/src/client/eve-agent-store.js +1 -1
  70. package/dist/src/client/index.d.ts +2 -1
  71. package/dist/src/client/index.js +1 -1
  72. package/dist/src/client/message-action-parts.js +1 -1
  73. package/dist/src/client/message-reducer.js +1 -1
  74. package/dist/src/client/message-task-parts.d.ts +8 -0
  75. package/dist/src/client/message-task-parts.js +1 -0
  76. package/dist/src/client/optimistic-message-submissions.js +1 -1
  77. package/dist/src/client/session-controls.d.ts +0 -1
  78. package/dist/src/client/session-utils.d.ts +10 -0
  79. package/dist/src/client/session-utils.js +1 -1
  80. package/dist/src/client/session.d.ts +8 -16
  81. package/dist/src/client/session.js +1 -1
  82. package/dist/src/client/stream-version.js +1 -1
  83. package/dist/src/client/types.d.ts +2 -4
  84. package/dist/src/compiled/.vendor-stamp.json +3 -2
  85. package/dist/src/compiled/@eve/catalog/index.js +1 -1
  86. package/dist/src/compiled/@vercel/connect/LICENSE +202 -0
  87. package/dist/src/compiled/@vercel/connect/authorization-details.d.ts +11 -0
  88. package/dist/src/compiled/@vercel/connect/authorization.d.ts +47 -0
  89. package/dist/src/compiled/@vercel/connect/connector.d.ts +32 -0
  90. package/dist/src/compiled/@vercel/connect/index.d.ts +5 -0
  91. package/dist/src/compiled/@vercel/connect/index.js +26 -0
  92. package/dist/src/compiled/@vercel/connect/installation.d.ts +48 -0
  93. package/dist/src/compiled/@vercel/connect/token.d.ts +137 -0
  94. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  95. package/dist/src/compiler/bundled-extension.d.ts +7 -1
  96. package/dist/src/compiler/bundled-extension.js +1 -1
  97. package/dist/src/compiler/default-tool-policy.d.ts +2 -2
  98. package/dist/src/compiler/default-tool-policy.js +1 -1
  99. package/dist/src/compiler/development-extensions.js +1 -1
  100. package/dist/src/compiler/extension-compatibility.d.ts +54 -18
  101. package/dist/src/compiler/extension-compatibility.js +1 -1
  102. package/dist/src/compiler/extension-mount-bindings.d.ts +5 -0
  103. package/dist/src/compiler/extension-mount-bindings.js +1 -0
  104. package/dist/src/compiler/load-binding-namespace.d.ts +10 -2
  105. package/dist/src/compiler/load-binding-namespace.js +1 -1
  106. package/dist/src/compiler/manifest.d.ts +19 -17
  107. package/dist/src/compiler/manifest.js +1 -1
  108. package/dist/src/compiler/module-lifecycle.d.ts +2 -2
  109. package/dist/src/compiler/module-lifecycle.js +1 -1
  110. package/dist/src/compiler/module-map.d.ts +1 -1
  111. package/dist/src/compiler/module-map.js +3 -3
  112. package/dist/src/compiler/normalize-manifest-helpers.d.ts +18 -1
  113. package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
  114. package/dist/src/compiler/normalize-manifest-types.d.ts +2 -0
  115. package/dist/src/compiler/normalize-manifest.js +1 -1
  116. package/dist/src/compiler/normalize-subagent.js +1 -1
  117. package/dist/src/compiler/normalize-tool.js +1 -1
  118. package/dist/src/compiler/project-sources.d.ts +4 -0
  119. package/dist/src/compiler/project-sources.js +1 -1
  120. package/dist/src/compiler/remote-agent-node.js +1 -1
  121. package/dist/src/compiler/source-graph.d.ts +5 -0
  122. package/dist/src/compiler/source-graph.js +1 -1
  123. package/dist/src/computer-use/extension/lib/computer-use-sandbox.d.ts +8 -0
  124. package/dist/src/computer-use/extension/lib/computer-use-sandbox.js +3 -3
  125. package/dist/src/computer-use/extension/lib/computer-use.d.ts +2 -0
  126. package/dist/src/computer-use/extension/lib/computer-use.js +2 -1
  127. package/dist/src/computer-use/extension/tools/computer_use.js +1 -1
  128. package/dist/src/context/build-dynamic-tools.js +1 -1
  129. package/dist/src/context/dynamic-subagent-lifecycle.d.ts +5 -0
  130. package/dist/src/context/dynamic-subagent-lifecycle.js +1 -1
  131. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  132. package/dist/src/context/dynamic-tool-metadata.d.ts +1 -1
  133. package/dist/src/context/key-names.d.ts +0 -1
  134. package/dist/src/context/key-names.js +1 -1
  135. package/dist/src/context/keys.d.ts +8 -14
  136. package/dist/src/context/keys.js +1 -1
  137. package/dist/src/context/memory-lifecycle.js +1 -1
  138. package/dist/src/context/memory-tools.d.ts +0 -1
  139. package/dist/src/context/provider.d.ts +1 -3
  140. package/dist/src/context/run-step.d.ts +2 -3
  141. package/dist/src/context/run-step.js +1 -1
  142. package/dist/src/context/serialize.js +1 -1
  143. package/dist/src/discover/bundled-extension.js +1 -1
  144. package/dist/src/discover/discover-agent.js +1 -1
  145. package/dist/src/discover/extensions.d.ts +0 -7
  146. package/dist/src/discover/extensions.js +1 -1
  147. package/dist/src/discover/manifest.d.ts +4 -0
  148. package/dist/src/evals/assertions/run.d.ts +4 -3
  149. package/dist/src/evals/assertions/run.js +1 -1
  150. package/dist/src/evals/index.d.ts +1 -1
  151. package/dist/src/evals/match.d.ts +4 -4
  152. package/dist/src/evals/mock-model.js +1 -1
  153. package/dist/src/evals/runner/derive-run-facts.d.ts +3 -3
  154. package/dist/src/evals/runner/derive-run-facts.js +1 -1
  155. package/dist/src/evals/runner/reporters/assertion-scores.d.ts +19 -0
  156. package/dist/src/evals/runner/reporters/assertion-scores.js +1 -0
  157. package/dist/src/evals/runner/reporters/braintrust.js +1 -1
  158. package/dist/src/evals/runner/reporters/datadog-client.d.ts +123 -0
  159. package/dist/src/evals/runner/reporters/datadog-client.js +4 -0
  160. package/dist/src/evals/runner/reporters/datadog.d.ts +9 -98
  161. package/dist/src/evals/runner/reporters/datadog.js +2 -3
  162. package/dist/src/evals/session-content.js +1 -1
  163. package/dist/src/evals/session.d.ts +4 -4
  164. package/dist/src/evals/session.js +2 -2
  165. package/dist/src/evals/types.d.ts +18 -15
  166. package/dist/src/eve-channel/create-request.d.ts +5 -4
  167. package/dist/src/eve-channel/create-request.js +1 -1
  168. package/dist/src/eve-channel/index.d.ts +0 -9
  169. package/dist/src/eve-channel/index.js +1 -1
  170. package/dist/src/eve-channel/request.d.ts +3 -7
  171. package/dist/src/eve-channel/request.js +1 -1
  172. package/dist/src/eve-channel/support.d.ts +15 -5
  173. package/dist/src/eve-channel/support.js +1 -1
  174. package/dist/src/eve-channel/turn-policy-request.d.ts +2 -0
  175. package/dist/src/eve-channel/turn-policy-request.js +1 -0
  176. package/dist/src/eve-channel/types.d.ts +4 -0
  177. package/dist/src/execution/agent-sessions/context.d.ts +60 -0
  178. package/dist/src/execution/agent-sessions/context.js +1 -0
  179. package/dist/src/{subagents/remote-dispatch.d.ts → execution/agent-sessions/remote.d.ts} +17 -40
  180. package/dist/src/execution/agent-sessions/remote.js +1 -0
  181. package/dist/src/execution/agent-sessions/requests.d.ts +20 -0
  182. package/dist/src/execution/agent-sessions/requests.js +1 -0
  183. package/dist/src/execution/agent-sessions/session.d.ts +12 -0
  184. package/dist/src/execution/agent-sessions/session.js +1 -0
  185. package/dist/src/execution/agent-sessions/steps.d.ts +59 -0
  186. package/dist/src/execution/agent-sessions/steps.js +1 -0
  187. package/dist/src/execution/agent-sessions/target.d.ts +45 -0
  188. package/dist/src/execution/agent-sessions/target.js +1 -0
  189. package/dist/src/execution/agent-sessions/usage.d.ts +18 -0
  190. package/dist/src/execution/agent-sessions/usage.js +1 -0
  191. package/dist/src/execution/authorization-callback-match.d.ts +2 -4
  192. package/dist/src/execution/authorization-callback-match.js +1 -1
  193. package/dist/src/execution/cancel-descendant-turns-step.d.ts +1 -5
  194. package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
  195. package/dist/src/execution/cancelled-model-call-batch.js +1 -1
  196. package/dist/src/execution/connection-announcement.d.ts +7 -0
  197. package/dist/src/execution/connection-announcement.js +4 -0
  198. package/dist/src/execution/continuation-conflict-step.d.ts +2 -3
  199. package/dist/src/execution/continuation-conflict-step.js +1 -1
  200. package/dist/src/execution/coordination-dispatch-shared.d.ts +9 -27
  201. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  202. package/dist/src/execution/coordination-dispatch-step.d.ts +3 -2
  203. package/dist/src/execution/coordination-dispatch-step.js +1 -1
  204. package/dist/src/execution/create-session-step.d.ts +0 -1
  205. package/dist/src/execution/create-session-step.js +1 -1
  206. package/dist/src/execution/deliver-payloads.js +1 -1
  207. package/dist/src/execution/durable-session-store.d.ts +0 -1
  208. package/dist/src/execution/dynamic-connections.js +1 -1
  209. package/dist/src/execution/dynamic-workflow/program-step.js +1 -1
  210. package/dist/src/execution/dynamic-workflow/schema.d.ts +1 -3
  211. package/dist/src/execution/dynamic-workflow/schema.js +1 -1
  212. package/dist/src/execution/dynamic-workflow/tool.d.ts +1 -1
  213. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  214. package/dist/src/execution/dynamic-workflow/workflow.js +1 -1
  215. package/dist/src/execution/forward-session-input.d.ts +4 -0
  216. package/dist/src/execution/forward-session-input.js +1 -0
  217. package/dist/src/execution/legacy-remote-agent/protocol.d.ts +41 -0
  218. package/dist/src/execution/legacy-remote-agent/protocol.js +1 -0
  219. package/dist/src/execution/legacy-session/authorization.js +1 -1
  220. package/dist/src/execution/legacy-session/completion-step.js +1 -1
  221. package/dist/src/execution/legacy-session/inbox.js +1 -1
  222. package/dist/src/execution/legacy-session/input.js +1 -1
  223. package/dist/src/execution/legacy-session/interrupt-step.js +1 -1
  224. package/dist/src/execution/model-call-batching.js +1 -1
  225. package/dist/src/execution/node-step.d.ts +1 -1
  226. package/dist/src/execution/node-step.js +1 -1
  227. package/dist/src/execution/proxied-deliver-step.d.ts +9 -6
  228. package/dist/src/execution/proxied-deliver-step.js +1 -1
  229. package/dist/src/execution/publish-session-events.d.ts +130 -0
  230. package/dist/src/execution/publish-session-events.js +1 -0
  231. package/dist/src/execution/route-child-delivery.d.ts +5 -4
  232. package/dist/src/execution/route-child-delivery.js +1 -3
  233. package/dist/src/execution/runtime-context.js +1 -1
  234. package/dist/src/execution/sandbox/prewarm.js +1 -1
  235. package/dist/src/execution/session/admission.d.ts +1 -12
  236. package/dist/src/execution/session/admission.js +1 -1
  237. package/dist/src/execution/session/entry-input.d.ts +0 -2
  238. package/dist/src/execution/session/entry.js +1 -1
  239. package/dist/src/execution/session/finalization.js +1 -1
  240. package/dist/src/execution/session/handoff-steps.d.ts +13 -2
  241. package/dist/src/execution/session/handoff-steps.js +1 -1
  242. package/dist/src/execution/session/handoff.d.ts +17 -3
  243. package/dist/src/execution/session/handoff.js +1 -1
  244. package/dist/src/execution/session/input-queue.d.ts +27 -28
  245. package/dist/src/execution/session/input-queue.js +1 -1
  246. package/dist/src/execution/session/next-input.d.ts +5 -0
  247. package/dist/src/execution/session/next-input.js +1 -1
  248. package/dist/src/execution/session/pending-turn-state.d.ts +2 -0
  249. package/dist/src/execution/session/pending-turn-state.js +1 -1
  250. package/dist/src/execution/session/principal.d.ts +14 -0
  251. package/dist/src/execution/session/principal.js +1 -0
  252. package/dist/src/execution/session/program.js +1 -1
  253. package/dist/src/execution/session/route-selected-delivery.js +1 -1
  254. package/dist/src/execution/session/state-cursor.d.ts +17 -15
  255. package/dist/src/execution/session/state-cursor.js +1 -1
  256. package/dist/src/execution/session/state-delta.d.ts +33 -0
  257. package/dist/src/execution/session/state-delta.js +1 -0
  258. package/dist/src/execution/session/timeout-steps.js +1 -1
  259. package/dist/src/execution/session/turn-event-handler.d.ts +2 -2
  260. package/dist/src/execution/session/turn-event-handler.js +1 -1
  261. package/dist/src/execution/session/turn-step-result.d.ts +1 -3
  262. package/dist/src/execution/session/turn-step-result.js +1 -1
  263. package/dist/src/execution/session/turn-step-types.d.ts +24 -15
  264. package/dist/src/execution/session/turn-step.d.ts +2 -2
  265. package/dist/src/execution/session/turn-step.js +1 -1
  266. package/dist/src/execution/session/turn-waiting-step.d.ts +4 -0
  267. package/dist/src/execution/session/turn-waiting-step.js +1 -0
  268. package/dist/src/execution/session/turn.d.ts +33 -2
  269. package/dist/src/execution/session/turn.js +1 -1
  270. package/dist/src/execution/session-callback-request.js +1 -1
  271. package/dist/src/execution/session-event-stream.d.ts +33 -0
  272. package/dist/src/execution/session-event-stream.js +1 -0
  273. package/dist/src/execution/session-inbox/inbox.d.ts +2 -0
  274. package/dist/src/execution/session-inbox/inbox.js +1 -1
  275. package/dist/src/execution/session-inbox/protocol.js +1 -1
  276. package/dist/src/execution/session-inbox/release-step.js +1 -1
  277. package/dist/src/execution/session-inbox/resume.js +1 -1
  278. package/dist/src/execution/session-workflow-tool-run.d.ts +11 -2
  279. package/dist/src/execution/session-workflow-tool-run.js +1 -1
  280. package/dist/src/execution/session.d.ts +0 -1
  281. package/dist/src/execution/session.js +2 -2
  282. package/dist/src/execution/settle-cancelled-turn-step.d.ts +21 -9
  283. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  284. package/dist/src/execution/stable-workflow-names.d.ts +0 -1
  285. package/dist/src/execution/stable-workflow-names.js +1 -1
  286. package/dist/src/execution/tasks/calls.d.ts +42 -0
  287. package/dist/src/execution/tasks/calls.js +1 -0
  288. package/dist/src/execution/tasks/model-step.d.ts +58 -0
  289. package/dist/src/execution/tasks/model-step.js +1 -0
  290. package/dist/src/execution/tasks/render.d.ts +66 -0
  291. package/dist/src/execution/tasks/render.js +8 -0
  292. package/dist/src/execution/tasks/session.d.ts +19 -0
  293. package/dist/src/execution/tasks/session.js +1 -0
  294. package/dist/src/execution/tasks/start.d.ts +34 -0
  295. package/dist/src/execution/tasks/start.js +1 -0
  296. package/dist/src/execution/tasks/steps.d.ts +31 -0
  297. package/dist/src/execution/tasks/steps.js +1 -0
  298. package/dist/src/execution/tasks/table.d.ts +192 -0
  299. package/dist/src/execution/tasks/table.js +1 -0
  300. package/dist/src/execution/tasks/task-id-input.d.ts +19 -0
  301. package/dist/src/execution/tasks/task-id-input.js +1 -0
  302. package/dist/src/execution/tasks/tool-entry-point.d.ts +11 -0
  303. package/dist/src/execution/tasks/tool-entry-point.js +1 -0
  304. package/dist/src/execution/tasks/workflow-target.d.ts +2 -0
  305. package/dist/src/execution/tasks/workflow-target.js +1 -1
  306. package/dist/src/execution/terminal-session-completion-step.js +1 -1
  307. package/dist/src/execution/terminal-session-failure-step.js +1 -1
  308. package/dist/src/execution/terminate-child-sessions-step.d.ts +2 -9
  309. package/dist/src/execution/terminate-child-sessions-step.js +1 -1
  310. package/dist/src/execution/tool-auth.js +1 -1
  311. package/dist/src/execution/tools/agent-router-workflow.d.ts +1 -1
  312. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  313. package/dist/src/execution/tools/agent-router.d.ts +1 -1
  314. package/dist/src/execution/tools/agent-router.js +1 -1
  315. package/dist/src/execution/tools/connection-approval.d.ts +25 -0
  316. package/dist/src/execution/tools/connection-approval.js +1 -0
  317. package/dist/src/execution/tools/connection-search-rank.d.ts +21 -0
  318. package/dist/src/execution/tools/connection-search-rank.js +1 -0
  319. package/dist/src/execution/tools/connection-target.d.ts +13 -0
  320. package/dist/src/execution/tools/connection-target.js +1 -0
  321. package/dist/src/execution/tools/connection-tools.d.ts +10 -0
  322. package/dist/src/execution/tools/connection-tools.js +2 -0
  323. package/dist/src/execution/tools/load-skill.js +1 -1
  324. package/dist/src/execution/tools/workflow/answer.d.ts +7 -4
  325. package/dist/src/execution/tools/workflow/answer.js +1 -1
  326. package/dist/src/execution/tools/workflow/ask.d.ts +73 -10
  327. package/dist/src/execution/tools/workflow/ask.js +1 -1
  328. package/dist/src/execution/tools/workflow/body.d.ts +60 -19
  329. package/dist/src/execution/tools/workflow/body.js +1 -1
  330. package/dist/src/execution/tools/workflow/cancel.d.ts +7 -2
  331. package/dist/src/execution/tools/workflow/cancel.js +1 -1
  332. package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +10 -4
  333. package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +1 -1
  334. package/dist/src/execution/tools/workflow/{background.d.ts → harness-definition.d.ts} +6 -6
  335. package/dist/src/execution/tools/workflow/harness-definition.js +1 -0
  336. package/dist/src/execution/tools/workflow/interrupt.d.ts +6 -0
  337. package/dist/src/execution/tools/workflow/interrupt.js +1 -0
  338. package/dist/src/execution/tools/workflow/messages.d.ts +135 -10
  339. package/dist/src/execution/tools/workflow/messages.js +1 -1
  340. package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
  341. package/dist/src/execution/tools/workflow/owner.d.ts +15 -4
  342. package/dist/src/execution/tools/workflow/owner.js +1 -1
  343. package/dist/src/execution/tools/workflow/serve.d.ts +3 -0
  344. package/dist/src/execution/tools/workflow/serve.js +1 -0
  345. package/dist/src/execution/tools/workflow/start.d.ts +18 -11
  346. package/dist/src/execution/tools/workflow/start.js +1 -1
  347. package/dist/src/execution/tools/workflow/step-execution.js +1 -1
  348. package/dist/src/execution/tools/workflow/step.js +1 -1
  349. package/dist/src/execution/tools/workflow/types.d.ts +0 -10
  350. package/dist/src/execution/tools/workflow/withdraw-step.d.ts +31 -0
  351. package/dist/src/execution/tools/workflow/withdraw-step.js +1 -0
  352. package/dist/src/execution/tools/workflow/workflow-owner-blocking.d.ts +3 -5
  353. package/dist/src/execution/tools/workflow/workflow-owner-blocking.js +1 -1
  354. package/dist/src/execution/tools/workflow/workflow.d.ts +3 -3
  355. package/dist/src/execution/tools/workflow/workflow.js +1 -1
  356. package/dist/src/execution/web-fetch/request.js +1 -1
  357. package/dist/src/execution/workflow-callback-url.d.ts +0 -5
  358. package/dist/src/execution/workflow-callback-url.js +1 -1
  359. package/dist/src/execution/workflow-runtime.d.ts +3 -5
  360. package/dist/src/execution/workflow-runtime.js +1 -1
  361. package/dist/src/execution/workflow-webhook-route.js +1 -1
  362. package/dist/src/extensions/code/extension/lib/connect-authentication.js +1 -1
  363. package/dist/src/extensions/code/extension/lib/github-shell.js +1 -1
  364. package/dist/src/extensions/code/extension/lib/prwatch-github.js +1 -1
  365. package/dist/src/framework/sources/modules/agent.d.ts +1 -0
  366. package/dist/src/framework/sources/modules/agent.js +1 -1
  367. package/dist/src/framework/sources/registry.js +1 -1
  368. package/dist/src/harness/action-presentation.js +1 -1
  369. package/dist/src/harness/action-result-helpers.d.ts +1 -0
  370. package/dist/src/harness/action-result-helpers.js +1 -1
  371. package/dist/src/harness/advertised-tools.d.ts +1 -1
  372. package/dist/src/harness/advertised-tools.js +1 -1
  373. package/dist/src/harness/announcements.d.ts +22 -0
  374. package/dist/src/harness/announcements.js +1 -0
  375. package/dist/src/harness/approval-candidates.d.ts +10 -2
  376. package/dist/src/harness/approval-candidates.js +1 -1
  377. package/dist/src/harness/approval-delivery-coordinator.d.ts +4 -5
  378. package/dist/src/harness/approval-delivery-coordinator.js +1 -1
  379. package/dist/src/harness/approval-recheck.d.ts +7 -0
  380. package/dist/src/harness/approval-recheck.js +1 -0
  381. package/dist/src/harness/authorization-event-fields.d.ts +13 -0
  382. package/dist/src/harness/authorization-event-fields.js +1 -0
  383. package/dist/src/harness/authorization.d.ts +2 -1
  384. package/dist/src/harness/authorization.js +1 -1
  385. package/dist/src/harness/coordination.d.ts +31 -27
  386. package/dist/src/harness/coordination.js +1 -1
  387. package/dist/src/harness/current-messages.d.ts +6 -1
  388. package/dist/src/harness/current-messages.js +1 -1
  389. package/dist/src/harness/emission.d.ts +7 -1
  390. package/dist/src/harness/emission.js +1 -1
  391. package/dist/src/harness/execute-tool.d.ts +4 -15
  392. package/dist/src/harness/hitl/session-limit-input-requests.d.ts +2 -0
  393. package/dist/src/harness/hitl/session-limit-input-requests.js +1 -1
  394. package/dist/src/harness/input-request-resolution.d.ts +5 -2
  395. package/dist/src/harness/input-request-resolution.js +1 -1
  396. package/dist/src/harness/input-requests.js +1 -1
  397. package/dist/src/harness/messages.d.ts +11 -3
  398. package/dist/src/harness/messages.js +1 -1
  399. package/dist/src/harness/nested-actions.d.ts +23 -0
  400. package/dist/src/harness/nested-actions.js +1 -0
  401. package/dist/src/harness/pending-input-batches.d.ts +8 -6
  402. package/dist/src/harness/pending-input-batches.js +1 -1
  403. package/dist/src/harness/provider-tool-history.d.ts +7 -2
  404. package/dist/src/harness/provider-tool-history.js +1 -1
  405. package/dist/src/harness/proxy-input-requests.d.ts +41 -36
  406. package/dist/src/harness/proxy-input-requests.js +1 -1
  407. package/dist/src/harness/session-limit-enforcement.js +1 -1
  408. package/dist/src/harness/stale-input-responses.js +1 -1
  409. package/dist/src/harness/step-hooks.js +1 -1
  410. package/dist/src/harness/tool-loop.js +2 -2
  411. package/dist/src/harness/tool-model-output.js +1 -1
  412. package/dist/src/harness/tool-presentation.js +1 -1
  413. package/dist/src/harness/tools.d.ts +1 -5
  414. package/dist/src/harness/tools.js +1 -1
  415. package/dist/src/harness/turn-tag-state.d.ts +6 -5
  416. package/dist/src/harness/types.d.ts +7 -15
  417. package/dist/src/harness/workflow-dispatch.d.ts +30 -0
  418. package/dist/src/harness/workflow-dispatch.js +1 -0
  419. package/dist/src/harness/workflow-tool-runs.d.ts +5 -65
  420. package/dist/src/harness/workflow-tool-runs.js +1 -1
  421. package/dist/src/instrumentation/lifecycle.d.ts +3 -0
  422. package/dist/src/instrumentation/native-events.d.ts +0 -7
  423. package/dist/src/instrumentation/native-events.js +1 -1
  424. package/dist/src/instrumentation/runtime.d.ts +1 -4
  425. package/dist/src/instrumentation/runtime.js +1 -1
  426. package/dist/src/instrumentation/state.d.ts +0 -6
  427. package/dist/src/instrumentation/state.js +1 -1
  428. package/dist/src/internal/application/package.js +1 -1
  429. package/dist/src/internal/authored-definition/schema-backed.d.ts +10 -0
  430. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  431. package/dist/src/internal/authored-module-loader.d.ts +12 -6
  432. package/dist/src/internal/authored-module-loader.js +2 -2
  433. package/dist/src/internal/authored-module-map-loader.js +1 -1
  434. package/dist/src/internal/authored-package-boundary.d.ts +3 -0
  435. package/dist/src/internal/authored-package-boundary.js +1 -1
  436. package/dist/src/internal/bundler/extension-mount-plugin.d.ts +14 -0
  437. package/dist/src/internal/bundler/extension-mount-plugin.js +1 -0
  438. package/dist/src/internal/bundler/extension-scope-plugin.d.ts +8 -11
  439. package/dist/src/internal/bundler/extension-scope-plugin.js +2 -3
  440. package/dist/src/internal/invocation/workflow-execution.d.ts +2 -2
  441. package/dist/src/internal/invocation/workflow-execution.js +1 -1
  442. package/dist/src/internal/mount-state.d.ts +1 -0
  443. package/dist/src/internal/mount-state.js +1 -0
  444. package/dist/src/internal/nitro/host/build-application.js +1 -1
  445. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  446. package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
  447. package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -1
  448. package/dist/src/internal/nitro/host/workspace-extensions.js +1 -1
  449. package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
  450. package/dist/src/internal/node-esm-compat-banner.js +1 -1
  451. package/dist/src/internal/workflow/development-world-client.js +1 -1
  452. package/dist/src/internal/workflow-bundle/authored-workflow-directives.d.ts +4 -3
  453. package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
  454. package/dist/src/internal/workflow-bundle/builder.js +1 -1
  455. package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.js +1 -1
  456. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  457. package/dist/src/models/auto.d.ts +6 -0
  458. package/dist/src/models/auto.js +2 -2
  459. package/dist/src/protocol/message-version.d.ts +1 -0
  460. package/dist/src/protocol/message-version.js +1 -1
  461. package/dist/src/protocol/message.d.ts +126 -67
  462. package/dist/src/protocol/message.js +2 -2
  463. package/dist/src/protocol/remote-agent-protocol.d.ts +16 -0
  464. package/dist/src/protocol/remote-agent-protocol.js +1 -0
  465. package/dist/src/protocol/routes.d.ts +0 -6
  466. package/dist/src/protocol/routes.js +1 -1
  467. package/dist/src/protocol/task-tools.d.ts +21 -0
  468. package/dist/src/protocol/task-tools.js +1 -0
  469. package/dist/src/public/channels/auth.js +1 -1
  470. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +25 -16
  471. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
  472. package/dist/src/public/channels/chat-sdk/index.d.ts +1 -1
  473. package/dist/src/public/channels/chat-sdk/input-actions.d.ts +8 -0
  474. package/dist/src/public/channels/chat-sdk/input-actions.js +1 -0
  475. package/dist/src/public/channels/index.d.ts +1 -1
  476. package/dist/src/public/channels/linq/linqChannel.js +1 -1
  477. package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
  478. package/dist/src/public/channels/slack/action-status.d.ts +11 -12
  479. package/dist/src/public/channels/slack/action-status.js +1 -1
  480. package/dist/src/public/channels/slack/api.js +1 -1
  481. package/dist/src/public/channels/slack/attachments.js +1 -1
  482. package/dist/src/public/channels/slack/auth.d.ts +3 -0
  483. package/dist/src/public/channels/slack/auth.js +1 -1
  484. package/dist/src/public/channels/slack/connections.d.ts +6 -6
  485. package/dist/src/public/channels/slack/connections.js +1 -1
  486. package/dist/src/public/channels/slack/defaults.d.ts +13 -19
  487. package/dist/src/public/channels/slack/defaults.js +4 -4
  488. package/dist/src/public/channels/slack/hitl.d.ts +22 -13
  489. package/dist/src/public/channels/slack/hitl.js +2 -2
  490. package/dist/src/public/channels/slack/index.d.ts +4 -3
  491. package/dist/src/public/channels/slack/index.js +1 -1
  492. package/dist/src/public/channels/slack/input-response.d.ts +1 -5
  493. package/dist/src/public/channels/slack/input-response.js +1 -1
  494. package/dist/src/public/channels/slack/interaction-cards.js +1 -1
  495. package/dist/src/public/channels/slack/interactions.js +1 -1
  496. package/dist/src/public/channels/slack/renderers.d.ts +76 -0
  497. package/dist/src/public/channels/slack/renderers.js +1 -0
  498. package/dist/src/public/channels/slack/session-operations.d.ts +6 -0
  499. package/dist/src/public/channels/slack/session-operations.js +1 -1
  500. package/dist/src/public/channels/slack/slackChannel.d.ts +47 -103
  501. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  502. package/dist/src/public/channels/slack/task-card.d.ts +24 -0
  503. package/dist/src/public/channels/slack/task-card.js +1 -0
  504. package/dist/src/public/channels/telegram/hitl.d.ts +7 -1
  505. package/dist/src/public/channels/telegram/hitl.js +2 -1
  506. package/dist/src/public/channels/telegram/state.js +1 -1
  507. package/dist/src/public/channels/telegram/telegramChannel.d.ts +5 -0
  508. package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
  509. package/dist/src/public/definitions/channel.d.ts +6 -1
  510. package/dist/src/public/definitions/channel.js +1 -1
  511. package/dist/src/public/definitions/connections/mcp.d.ts +4 -6
  512. package/dist/src/public/definitions/connections/openapi.d.ts +7 -8
  513. package/dist/src/public/definitions/extension.d.ts +2 -2
  514. package/dist/src/public/definitions/extension.js +1 -1
  515. package/dist/src/public/definitions/hook.d.ts +4 -4
  516. package/dist/src/public/definitions/state.d.ts +4 -2
  517. package/dist/src/public/definitions/state.js +1 -1
  518. package/dist/src/public/memory/index.d.ts +0 -1
  519. package/dist/src/public/models/openai/index.d.ts +1 -1
  520. package/dist/src/public/models/openai/index.js +1 -1
  521. package/dist/src/public/schedules/index.d.ts +1 -0
  522. package/dist/src/public/schedules/index.js +1 -1
  523. package/dist/src/public/server/index.d.ts +28 -0
  524. package/dist/src/public/server/index.js +1 -0
  525. package/dist/src/public/tools/index.d.ts +3 -2
  526. package/dist/src/public/tools/index.js +1 -1
  527. package/dist/src/public/tools/no-reply.d.ts +1 -0
  528. package/dist/src/public/tools/no-reply.js +1 -0
  529. package/dist/src/runtime/agent/bootstrap-model-utils.d.ts +6 -7
  530. package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -1
  531. package/dist/src/runtime/agent/bootstrap.d.ts +0 -1
  532. package/dist/src/runtime/agent/bootstrap.js +1 -1
  533. package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
  534. package/dist/src/runtime/agent/mock-model-fixtures.d.ts +1 -1
  535. package/dist/src/runtime/agent/mock-model-fixtures.js +2 -2
  536. package/dist/src/runtime/channels/registry.js +1 -1
  537. package/dist/src/runtime/connections/mcp-client.d.ts +1 -9
  538. package/dist/src/runtime/connections/mcp-client.js +1 -1
  539. package/dist/src/runtime/connections/openapi-client.js +1 -1
  540. package/dist/src/runtime/connections/scoped-authorization.d.ts +1 -1
  541. package/dist/src/runtime/connections/scoped-authorization.js +1 -1
  542. package/dist/src/runtime/connections/tool-result.d.ts +27 -0
  543. package/dist/src/runtime/connections/tool-result.js +2 -0
  544. package/dist/src/runtime/connections/tool-signature.d.ts +14 -0
  545. package/dist/src/runtime/connections/tool-signature.js +1 -0
  546. package/dist/src/runtime/local-dev-capability.js +1 -1
  547. package/dist/src/runtime/prompt/compose.d.ts +1 -3
  548. package/dist/src/runtime/prompt/compose.js +3 -3
  549. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  550. package/dist/src/runtime/resolve-tool.js +1 -1
  551. package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
  552. package/dist/src/runtime/sessions/runtime-context-keys.js +1 -1
  553. package/dist/src/runtime/sessions/turn.d.ts +1 -16
  554. package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -1
  555. package/dist/src/runtime/subagents/registry.js +1 -1
  556. package/dist/src/runtime/subagents/workflow-reference.d.ts +6 -3
  557. package/dist/src/runtime/subagents/workflow-reference.js +1 -1
  558. package/dist/src/runtime/subagents/workflow.d.ts +12 -6
  559. package/dist/src/runtime/subagents/workflow.js +1 -1
  560. package/dist/src/runtime/tools/registry.js +1 -1
  561. package/dist/src/self-modification/extension/classify-registry-item.d.ts +3 -0
  562. package/dist/src/self-modification/extension/classify-registry-item.js +1 -1
  563. package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +1 -1
  564. package/dist/src/self-modification/extension/subagents/agent/agent.js +1 -1
  565. package/dist/src/self-modification/extension/subagents/agent/instructions.js +7 -7
  566. package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.js +1 -1
  567. package/dist/src/self-modification/extension/subagents/agent/tools/search_registry.d.ts +2 -0
  568. package/dist/src/self-modification/extension/subagents/agent/tools/search_registry.js +1 -1
  569. package/dist/src/self-modification/scaffold.d.ts +2 -0
  570. package/dist/src/self-modification/scaffold.js +7 -0
  571. package/dist/src/self-modification/setup.js +1 -7
  572. package/dist/src/setup/boxes/select-model.js +1 -1
  573. package/dist/src/setup/integrations/shopify/templates.d.ts +1 -1
  574. package/dist/src/setup/integrations/shopify/templates.js +31 -19
  575. package/dist/src/setup/scaffold/create/agent-paths.d.ts +5 -0
  576. package/dist/src/setup/scaffold/create/agent-paths.js +1 -0
  577. package/dist/src/setup/scaffold/create/instructions-template.d.ts +1 -0
  578. package/dist/src/setup/scaffold/create/instructions-template.js +8 -0
  579. package/dist/src/setup/scaffold/create/project.js +3 -10
  580. package/dist/src/shared/action-request-name.d.ts +3 -0
  581. package/dist/src/shared/action-request-name.js +1 -0
  582. package/dist/src/shared/action-types.d.ts +49 -21
  583. package/dist/src/shared/action-types.js +1 -1
  584. package/dist/src/shared/agent-definition.d.ts +0 -7
  585. package/dist/src/shared/chatgpt-model.d.ts +1 -1
  586. package/dist/src/shared/chatgpt-model.js +1 -1
  587. package/dist/src/shared/connection-types.d.ts +2 -8
  588. package/dist/src/shared/default-agent-model.d.ts +10 -1
  589. package/dist/src/shared/default-agent-model.js +1 -1
  590. package/dist/src/shared/extension-mount.d.ts +2 -0
  591. package/dist/src/shared/extension-mount.js +1 -0
  592. package/dist/src/shared/format-duration.d.ts +2 -0
  593. package/dist/src/shared/format-duration.js +1 -0
  594. package/dist/src/shared/input.d.ts +1 -0
  595. package/dist/src/shared/memory-state.d.ts +1 -0
  596. package/dist/src/shared/memory-state.js +1 -1
  597. package/dist/src/shared/model-helper.d.ts +2 -2
  598. package/dist/src/shared/model-helper.js +1 -1
  599. package/dist/src/shared/model-summary.d.ts +2 -6
  600. package/dist/src/shared/model-summary.js +1 -1
  601. package/dist/src/shared/presentation-text.d.ts +5 -0
  602. package/dist/src/shared/presentation-text.js +1 -1
  603. package/dist/src/shared/serialized-observability-state.d.ts +0 -4
  604. package/dist/src/shared/serialized-observability-state.js +1 -1
  605. package/dist/src/shared/value-delta.d.ts +39 -0
  606. package/dist/src/shared/value-delta.js +1 -0
  607. package/dist/src/subagents/adapter-state.d.ts +0 -2
  608. package/dist/src/subagents/adapter-state.js +1 -1
  609. package/dist/src/subagents/adapter.js +1 -1
  610. package/dist/src/subagents/callback-route.js +1 -1
  611. package/dist/src/subagents/event-proxy-step.d.ts +16 -29
  612. package/dist/src/subagents/event-proxy-step.js +1 -1
  613. package/dist/src/subagents/hitl-proxy.d.ts +35 -17
  614. package/dist/src/subagents/hitl-proxy.js +1 -1
  615. package/dist/src/subagents/invocation.d.ts +1 -2
  616. package/dist/src/subagents/parent-notification.d.ts +2 -1
  617. package/dist/src/subagents/parent-notification.js +1 -1
  618. package/dist/src/subagents/token-budget.d.ts +8 -9
  619. package/dist/src/subagents/token-budget.js +1 -1
  620. package/dist/src/subagents/tool.d.ts +6 -12
  621. package/dist/src/subagents/tool.js +1 -1
  622. package/dist/src/svelte/index.js +1 -1
  623. package/dist/src/svelte/use-eve-agent.js +1 -1
  624. package/dist/src/tools/behavior.d.ts +5 -5
  625. package/dist/src/tools/definition.d.ts +50 -14
  626. package/dist/src/tools/definition.js +1 -1
  627. package/dist/src/tools/durable-callbacks.d.ts +1 -1
  628. package/dist/src/tools/dynamic.d.ts +6 -0
  629. package/dist/src/tools/framework/agent-contract.d.ts +2 -5
  630. package/dist/src/tools/framework/agent-contract.js +1 -1
  631. package/dist/src/tools/framework/agent.d.ts +2 -5
  632. package/dist/src/tools/framework/agent.js +1 -1
  633. package/dist/src/tools/framework/connection-tools.d.ts +3 -0
  634. package/dist/src/tools/framework/connection-tools.js +1 -0
  635. package/dist/src/tools/provided/agent-router.d.ts +6 -3
  636. package/dist/src/tools/provided/agent-router.js +1 -1
  637. package/dist/src/{execution/tools → tools/provided}/ask-question-workflow.d.ts +3 -4
  638. package/dist/src/tools/provided/ask-question-workflow.js +1 -0
  639. package/dist/src/tools/provided/ask-question.d.ts +20 -5
  640. package/dist/src/tools/provided/ask-question.js +2 -1
  641. package/dist/src/tools/provided/interrupted.d.ts +18 -0
  642. package/dist/src/tools/provided/interrupted.js +1 -0
  643. package/dist/src/tools/provided/no-reply.d.ts +19 -0
  644. package/dist/src/tools/provided/no-reply.js +1 -0
  645. package/dist/src/tools/provided/sleep-workflow.d.ts +4 -0
  646. package/dist/src/tools/provided/sleep-workflow.js +1 -0
  647. package/dist/src/tools/provided/sleep.d.ts +11 -5
  648. package/dist/src/tools/provided/sleep.js +1 -1
  649. package/dist/src/tools/provided/task-cancel.d.ts +6 -0
  650. package/dist/src/tools/provided/task-cancel.js +1 -0
  651. package/dist/src/tools/provided/task-wait.d.ts +9 -0
  652. package/dist/src/tools/provided/task-wait.js +1 -0
  653. package/dist/src/tools/provided/workflow.d.ts +2 -2
  654. package/dist/src/tools/provided/workflow.js +1 -1
  655. package/dist/src/tools/schema-emission.d.ts +23 -0
  656. package/dist/src/tools/schema-emission.js +1 -0
  657. package/dist/src/tools/schema.d.ts +22 -8
  658. package/dist/src/tools/schema.js +1 -1
  659. package/dist/src/tools/workflow-definition.d.ts +187 -85
  660. package/dist/src/tools/workflow-definition.js +1 -1
  661. package/dist/src/tools/workflow-entry-point.d.ts +3 -0
  662. package/dist/src/tools/workflow-entry-point.js +1 -0
  663. package/dist/src/tracing/agent-action-instrumentation.d.ts +1 -3
  664. package/dist/src/tracing/agent-action-instrumentation.js +1 -1
  665. package/dist/src/tracing/agent-invocation-coordinator.d.ts +9 -18
  666. package/dist/src/tracing/agent-invocation-coordinator.js +1 -1
  667. package/dist/src/tracing/agent-otel-content.d.ts +0 -2
  668. package/dist/src/tracing/agent-otel-content.js +3 -3
  669. package/dist/src/tracing/agent-otel-provider.js +2 -2
  670. package/dist/src/tracing/agent-otel-runtime-context.d.ts +20 -0
  671. package/dist/src/tracing/agent-otel-runtime-context.js +1 -1
  672. package/dist/src/tracing/agent-otel-usage.js +1 -1
  673. package/dist/src/tracing/agent-span-contract.d.ts +1 -1
  674. package/dist/src/tracing/agent-span-contract.js +1 -1
  675. package/dist/src/tracing/agent-span-id-generator.d.ts +0 -1
  676. package/dist/src/tracing/agent-span-id-generator.js +1 -1
  677. package/dist/src/tracing/agent-trace-context-codec.d.ts +1 -2
  678. package/dist/src/tracing/agent-trace-context-codec.js +1 -1
  679. package/dist/src/tracing/agent-trace-context-store.d.ts +2 -27
  680. package/dist/src/tracing/agent-trace-context-store.js +1 -1
  681. package/dist/src/tracing/agent-trace-state.d.ts +1 -19
  682. package/dist/src/tracing/content-attributes.js +1 -1
  683. package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
  684. package/dist/src/vue/index.js +1 -1
  685. package/dist/src/vue/use-eve-agent.js +1 -1
  686. package/docs/agent-config.md +36 -13
  687. package/docs/channels/chat-sdk.mdx +15 -4
  688. package/docs/channels/custom.mdx +89 -17
  689. package/docs/channels/eve.mdx +1 -1
  690. package/docs/channels/mcp.mdx +1 -1
  691. package/docs/channels/overview.mdx +14 -56
  692. package/docs/channels/slack.mdx +230 -35
  693. package/docs/channels/telegram.mdx +2 -0
  694. package/docs/concepts/built-in-tools.md +36 -28
  695. package/docs/concepts/context-control.md +2 -2
  696. package/docs/concepts/execution-model-and-durability.mdx +10 -11
  697. package/docs/concepts/sessions-runs-and-streaming.md +67 -47
  698. package/docs/connections/mcp.mdx +4 -4
  699. package/docs/connections/openapi.mdx +2 -2
  700. package/docs/connections/overview.mdx +2 -2
  701. package/docs/evals/assertions.mdx +5 -5
  702. package/docs/evals/cases.mdx +1 -1
  703. package/docs/evals/reporters.mdx +6 -4
  704. package/docs/extensions.md +11 -2
  705. package/docs/guides/client/streaming.mdx +31 -11
  706. package/docs/guides/dev-tui.md +13 -3
  707. package/docs/guides/dynamic-capabilities.md +5 -3
  708. package/docs/guides/evaluate.md +29 -2
  709. package/docs/guides/frontend/overview.mdx +5 -7
  710. package/docs/guides/hooks.md +16 -12
  711. package/docs/guides/instrumentation/instrumentation.mdx +2 -0
  712. package/docs/guides/remote-agents.md +12 -14
  713. package/docs/guides/self-modification.md +10 -0
  714. package/docs/instructions.mdx +1 -1
  715. package/docs/patterns/multi-tenant-approvals.md +1 -1
  716. package/docs/protocols/ucp.mdx +20 -16
  717. package/docs/reference/cli.md +61 -8
  718. package/docs/reference/typescript-api.md +43 -41
  719. package/docs/schedules.mdx +14 -34
  720. package/docs/subagents/index.mdx +24 -56
  721. package/docs/tools/human-in-the-loop.md +48 -13
  722. package/docs/tools/meta.json +1 -1
  723. package/docs/tools/overview.mdx +79 -59
  724. package/docs/tools/tasks-upgrade.md +201 -0
  725. package/docs/tools/tasks.md +315 -0
  726. package/docs/tools/workflows.mdx +368 -154
  727. package/package.json +18 -12
  728. package/dist/src/channel/activity-renderer.d.ts +0 -21
  729. package/dist/src/channel/activity-renderer.js +0 -1
  730. package/dist/src/channel/activity-sink.d.ts +0 -2
  731. package/dist/src/channel/activity-sink.js +0 -1
  732. package/dist/src/eve-channel/activity-observer-request.d.ts +0 -7
  733. package/dist/src/eve-channel/activity-observer-request.js +0 -1
  734. package/dist/src/eve-channel/delivery-policy-request.d.ts +0 -4
  735. package/dist/src/eve-channel/delivery-policy-request.js +0 -1
  736. package/dist/src/execution/activity-cohort.d.ts +0 -20
  737. package/dist/src/execution/activity-cohort.js +0 -1
  738. package/dist/src/execution/activity-collector.d.ts +0 -12
  739. package/dist/src/execution/activity-collector.js +0 -1
  740. package/dist/src/execution/activity-events.d.ts +0 -8
  741. package/dist/src/execution/activity-events.js +0 -1
  742. package/dist/src/execution/activity-route.d.ts +0 -2
  743. package/dist/src/execution/activity-route.js +0 -1
  744. package/dist/src/execution/activity-work-id.d.ts +0 -9
  745. package/dist/src/execution/activity-work-id.js +0 -1
  746. package/dist/src/execution/activity-work.d.ts +0 -30
  747. package/dist/src/execution/activity-work.js +0 -1
  748. package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +0 -7
  749. package/dist/src/execution/cancel-indexed-session-tasks-step.js +0 -1
  750. package/dist/src/execution/dispatch-action-failures.d.ts +0 -8
  751. package/dist/src/execution/dispatch-action-failures.js +0 -1
  752. package/dist/src/execution/dispatch-start-operation.d.ts +0 -15
  753. package/dist/src/execution/dispatch-start-operation.js +0 -1
  754. package/dist/src/execution/publish-channel-event.d.ts +0 -23
  755. package/dist/src/execution/publish-channel-event.js +0 -1
  756. package/dist/src/execution/scheduled-launch-delivery.d.ts +0 -7
  757. package/dist/src/execution/scheduled-launch-delivery.js +0 -1
  758. package/dist/src/execution/session/event-sink.d.ts +0 -26
  759. package/dist/src/execution/session/event-sink.js +0 -1
  760. package/dist/src/execution/session-activity-projection.d.ts +0 -16
  761. package/dist/src/execution/session-activity-projection.js +0 -1
  762. package/dist/src/execution/session-activity-renderer-step.d.ts +0 -15
  763. package/dist/src/execution/session-activity-renderer-step.js +0 -1
  764. package/dist/src/execution/session-activity.d.ts +0 -3
  765. package/dist/src/execution/session-activity.js +0 -1
  766. package/dist/src/execution/submit-activity.d.ts +0 -7
  767. package/dist/src/execution/submit-activity.js +0 -1
  768. package/dist/src/execution/task-event-callback.d.ts +0 -12
  769. package/dist/src/execution/task-event-callback.js +0 -1
  770. package/dist/src/execution/task-input-capability.d.ts +0 -4
  771. package/dist/src/execution/task-input-capability.js +0 -1
  772. package/dist/src/execution/task-input-response-route.d.ts +0 -2
  773. package/dist/src/execution/task-input-response-route.js +0 -1
  774. package/dist/src/execution/tasks/child/notify.d.ts +0 -44
  775. package/dist/src/execution/tasks/child/notify.js +0 -1
  776. package/dist/src/execution/tasks/parent/control-shared.d.ts +0 -23
  777. package/dist/src/execution/tasks/parent/control-shared.js +0 -1
  778. package/dist/src/execution/tasks/parent/delegate.d.ts +0 -35
  779. package/dist/src/execution/tasks/parent/delegate.js +0 -1
  780. package/dist/src/execution/tasks/parent/dispatch.d.ts +0 -22
  781. package/dist/src/execution/tasks/parent/dispatch.js +0 -1
  782. package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +0 -27
  783. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +0 -1
  784. package/dist/src/execution/tasks/parent/run-parent.d.ts +0 -58
  785. package/dist/src/execution/tasks/parent/run-parent.js +0 -1
  786. package/dist/src/execution/tasks/parent/subagent-task-projection.d.ts +0 -26
  787. package/dist/src/execution/tasks/parent/subagent-task-projection.js +0 -1
  788. package/dist/src/execution/tasks/parent/task-cancel.d.ts +0 -12
  789. package/dist/src/execution/tasks/parent/task-cancel.js +0 -1
  790. package/dist/src/execution/tasks/parent/tool-execution.d.ts +0 -45
  791. package/dist/src/execution/tasks/parent/tool-execution.js +0 -1
  792. package/dist/src/execution/terminal-session-event.d.ts +0 -13
  793. package/dist/src/execution/terminal-session-event.js +0 -1
  794. package/dist/src/execution/tools/ask-question-workflow.js +0 -1
  795. package/dist/src/execution/tools/ask-question.d.ts +0 -19
  796. package/dist/src/execution/tools/ask-question.js +0 -2
  797. package/dist/src/execution/tools/connection-search.d.ts +0 -2
  798. package/dist/src/execution/tools/connection-search.js +0 -2
  799. package/dist/src/execution/tools/sleep-workflow.d.ts +0 -3
  800. package/dist/src/execution/tools/sleep-workflow.js +0 -1
  801. package/dist/src/execution/tools/sleep.d.ts +0 -10
  802. package/dist/src/execution/tools/sleep.js +0 -1
  803. package/dist/src/execution/tools/subagent/accept-event-step.d.ts +0 -7
  804. package/dist/src/execution/tools/subagent/accept-event-step.js +0 -1
  805. package/dist/src/execution/tools/subagent/emit-event-step.d.ts +0 -12
  806. package/dist/src/execution/tools/subagent/emit-event-step.js +0 -1
  807. package/dist/src/execution/tools/subagent/invoke-agent.d.ts +0 -42
  808. package/dist/src/execution/tools/subagent/invoke-agent.js +0 -1
  809. package/dist/src/execution/tools/subagent/invoke-preparation.d.ts +0 -44
  810. package/dist/src/execution/tools/subagent/invoke-preparation.js +0 -1
  811. package/dist/src/execution/tools/subagent/invoke-step.d.ts +0 -64
  812. package/dist/src/execution/tools/subagent/invoke-step.js +0 -1
  813. package/dist/src/execution/tools/subagent/receipt-identity.d.ts +0 -11
  814. package/dist/src/execution/tools/subagent/receipt-identity.js +0 -1
  815. package/dist/src/execution/tools/subagent/start.d.ts +0 -51
  816. package/dist/src/execution/tools/subagent/start.js +0 -1
  817. package/dist/src/execution/tools/subagent/steer.d.ts +0 -13
  818. package/dist/src/execution/tools/subagent/steer.js +0 -1
  819. package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +0 -24
  820. package/dist/src/execution/tools/subagent/task-agent-requests.js +0 -1
  821. package/dist/src/execution/tools/subagent/task-cancel.d.ts +0 -10
  822. package/dist/src/execution/tools/subagent/task-cancel.js +0 -1
  823. package/dist/src/execution/tools/tasks.d.ts +0 -3
  824. package/dist/src/execution/tools/tasks.js +0 -1
  825. package/dist/src/execution/tools/workflow/background.js +0 -1
  826. package/dist/src/execution/tools/workflow/workflow-owner-background.d.ts +0 -14
  827. package/dist/src/execution/tools/workflow/workflow-owner-background.js +0 -1
  828. package/dist/src/harness/background-tools.d.ts +0 -45
  829. package/dist/src/harness/background-tools.js +0 -1
  830. package/dist/src/instrumentation/background-task-runtime.d.ts +0 -18
  831. package/dist/src/instrumentation/background-task-runtime.js +0 -1
  832. package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.3.0/node_modules/@vercel/cli-config/dist/index.js +0 -21
  833. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/envpath.js +0 -1
  834. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/errors.js +0 -2
  835. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/errutils.js +0 -1
  836. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/exec.js +0 -1
  837. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/fsutils.js +0 -1
  838. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/index.js +0 -1
  839. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/lookup.js +0 -1
  840. package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/safety.js +0 -1
  841. 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
  842. 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
  843. 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
  844. 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
  845. 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
  846. 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
  847. 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
  848. 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
  849. 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
  850. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/auth-errors.js +0 -1
  851. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/exchange-vercel-oidc-token.js +0 -1
  852. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/get-context.js +0 -1
  853. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-sync.js +0 -1
  854. 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
  855. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/index.js +0 -1
  856. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/oauth.js +0 -1
  857. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token-error.js +0 -1
  858. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token-io.js +0 -1
  859. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token-util.js +0 -2
  860. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token.js +0 -1
  861. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/verify-vercel-oidc-token.js +0 -1
  862. package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/version.js +0 -1
  863. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js +0 -1
  864. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js +0 -1
  865. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js +0 -1
  866. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js +0 -1
  867. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js +0 -1
  868. package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -1
  869. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js +0 -1
  870. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/command.js +0 -1
  871. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js +0 -2
  872. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/kill.js +0 -1
  873. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/promise.js +0 -1
  874. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stdio.js +0 -1
  875. package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stream.js +0 -1
  876. package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/buffer-stream.js +0 -1
  877. package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/index.js +0 -1
  878. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/core.js +0 -1
  879. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/main.js +0 -1
  880. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/realtime.js +0 -1
  881. package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/signals.js +0 -1
  882. package/dist/src/node_modules/.pnpm/is-stream@2.0.1/node_modules/is-stream/index.js +0 -1
  883. package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js +0 -1
  884. package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js +0 -1
  885. package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js +0 -1
  886. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/index.js +0 -1
  887. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/decrypt.js +0 -1
  888. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/encrypt.js +0 -1
  889. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/decrypt.js +0 -1
  890. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/encrypt.js +0 -1
  891. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/decrypt.js +0 -1
  892. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/encrypt.js +0 -1
  893. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/embedded.js +0 -1
  894. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/thumbprint.js +0 -1
  895. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/local.js +0 -1
  896. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/remote.js +0 -1
  897. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/sign.js +0 -1
  898. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/verify.js +0 -1
  899. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/sign.js +0 -1
  900. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/verify.js +0 -1
  901. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/sign.js +0 -1
  902. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/verify.js +0 -1
  903. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/decrypt.js +0 -1
  904. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/encrypt.js +0 -1
  905. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/produce.js +0 -1
  906. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/sign.js +0 -1
  907. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/unsecured.js +0 -1
  908. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/verify.js +0 -1
  909. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/export.js +0 -1
  910. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_key_pair.js +0 -1
  911. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_secret.js +0 -1
  912. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/import.js +0 -1
  913. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/aesgcmkw.js +0 -1
  914. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/buffer_utils.js +0 -1
  915. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/cek.js +0 -1
  916. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_iv_length.js +0 -1
  917. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_key_type.js +0 -1
  918. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_p2s.js +0 -1
  919. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/crypto_key.js +0 -1
  920. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/decrypt_key_management.js +0 -1
  921. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/encrypt_key_management.js +0 -1
  922. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/epoch.js +0 -1
  923. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/invalid_key_input.js +0 -1
  924. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_disjoint.js +0 -1
  925. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_jwk.js +0 -1
  926. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_object.js +0 -1
  927. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/iv.js +0 -1
  928. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/jwt_claims_set.js +0 -1
  929. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/private_symbols.js +0 -1
  930. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/secs.js +0 -1
  931. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_algorithms.js +0 -1
  932. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_crit.js +0 -1
  933. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/aeskw.js +0 -1
  934. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/asn1.js +0 -1
  935. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/base64url.js +0 -1
  936. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/cbc_tag.js +0 -1
  937. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_cek_length.js +0 -1
  938. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_key_length.js +0 -1
  939. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ciphers.js +0 -1
  940. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/decrypt.js +0 -1
  941. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/digest.js +0 -1
  942. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/dsa_digest.js +0 -1
  943. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ecdhes.js +0 -1
  944. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/encrypt.js +0 -1
  945. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/fetch_jwks.js +0 -1
  946. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/generate.js +0 -1
  947. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_named_curve.js +0 -1
  948. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_sign_verify_key.js +0 -1
  949. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/hmac_digest.js +0 -1
  950. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_like.js +0 -1
  951. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_object.js +0 -1
  952. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/jwk_to_key.js +0 -1
  953. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/key_to_jwk.js +0 -1
  954. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/node_key.js +0 -1
  955. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/normalize_key.js +0 -1
  956. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/pbes2kw.js +0 -1
  957. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/random.js +0 -1
  958. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/rsaes.js +0 -1
  959. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/runtime.js +0 -1
  960. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/sign.js +0 -1
  961. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/timing_safe_equal.js +0 -1
  962. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/verify.js +0 -1
  963. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/webcrypto.js +0 -1
  964. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/base64url.js +0 -1
  965. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_jwt.js +0 -1
  966. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_protected_header.js +0 -1
  967. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/errors.js +0 -1
  968. package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/runtime.js +0 -1
  969. package/dist/src/node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js +0 -1
  970. package/dist/src/node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js +0 -1
  971. package/dist/src/node_modules/.pnpm/npm-run-path@4.0.1/node_modules/npm-run-path/index.js +0 -1
  972. package/dist/src/node_modules/.pnpm/onetime@5.1.2/node_modules/onetime/index.js +0 -1
  973. package/dist/src/node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js +0 -1
  974. package/dist/src/node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js +0 -1
  975. package/dist/src/node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js +0 -1
  976. package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js +0 -1
  977. package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js +0 -1
  978. package/dist/src/node_modules/.pnpm/strip-final-newline@2.0.0/node_modules/strip-final-newline/index.js +0 -2
  979. package/dist/src/node_modules/.pnpm/which@2.0.2/node_modules/which/which.js +0 -1
  980. package/dist/src/protocol/activity.d.ts +0 -112
  981. package/dist/src/protocol/activity.js +0 -1
  982. package/dist/src/protocol/agent-handle-error.d.ts +0 -13
  983. package/dist/src/protocol/agent-handle-error.js +0 -1
  984. package/dist/src/public/channels/slack/activity-plan.d.ts +0 -5
  985. package/dist/src/public/channels/slack/activity-plan.js +0 -1
  986. package/dist/src/public/channels/slack/activity.d.ts +0 -63
  987. package/dist/src/public/channels/slack/activity.js +0 -2
  988. package/dist/src/public/tools/connection-search.d.ts +0 -1
  989. package/dist/src/public/tools/connection-search.js +0 -1
  990. package/dist/src/public/tools/task-cancel.d.ts +0 -1
  991. package/dist/src/public/tools/task-cancel.js +0 -1
  992. package/dist/src/runtime/prompt/connections.d.ts +0 -9
  993. package/dist/src/runtime/prompt/connections.js +0 -2
  994. package/dist/src/shared/empty-delivery.d.ts +0 -3
  995. package/dist/src/shared/empty-delivery.js +0 -1
  996. package/dist/src/subagents/agent-handle-errors.d.ts +0 -25
  997. package/dist/src/subagents/agent-handle-errors.js +0 -1
  998. package/dist/src/subagents/callback-step.d.ts +0 -11
  999. package/dist/src/subagents/callback-step.js +0 -1
  1000. package/dist/src/subagents/continuation-bundle.d.ts +0 -13
  1001. package/dist/src/subagents/continuation-bundle.js +0 -1
  1002. package/dist/src/subagents/handle-dispatch.d.ts +0 -65
  1003. package/dist/src/subagents/handle-dispatch.js +0 -1
  1004. package/dist/src/subagents/handles/operation-id.d.ts +0 -15
  1005. package/dist/src/subagents/handles/operation-id.js +0 -1
  1006. package/dist/src/subagents/handles/prompt.d.ts +0 -52
  1007. package/dist/src/subagents/handles/prompt.js +0 -3
  1008. package/dist/src/subagents/handles/query.d.ts +0 -41
  1009. package/dist/src/subagents/handles/query.js +0 -1
  1010. package/dist/src/subagents/handles/state-key.d.ts +0 -8
  1011. package/dist/src/subagents/handles/state-key.js +0 -1
  1012. package/dist/src/subagents/handles/store.d.ts +0 -217
  1013. package/dist/src/subagents/handles/store.js +0 -1
  1014. package/dist/src/subagents/handles/transitions.d.ts +0 -103
  1015. package/dist/src/subagents/handles/transitions.js +0 -1
  1016. package/dist/src/subagents/remote-dispatch.js +0 -1
  1017. package/dist/src/subagents/start-local.d.ts +0 -29
  1018. package/dist/src/subagents/start-local.js +0 -1
  1019. package/dist/src/subagents/start-remote.d.ts +0 -21
  1020. package/dist/src/subagents/start-remote.js +0 -1
  1021. package/dist/src/tasks/delivery-context.d.ts +0 -32
  1022. package/dist/src/tasks/delivery-context.js +0 -4
  1023. package/dist/src/tasks/delivery-policy.d.ts +0 -14
  1024. package/dist/src/tasks/delivery-policy.js +0 -1
  1025. package/dist/src/tasks/json.d.ts +0 -88
  1026. package/dist/src/tasks/json.js +0 -1
  1027. package/dist/src/tasks/notification.d.ts +0 -10
  1028. package/dist/src/tasks/notification.js +0 -1
  1029. package/dist/src/tasks/task-id.d.ts +0 -31
  1030. package/dist/src/tasks/task-id.js +0 -1
  1031. package/dist/src/tasks/task-inbox-token.d.ts +0 -2
  1032. package/dist/src/tasks/task-inbox-token.js +0 -1
  1033. package/dist/src/tasks/transitions.d.ts +0 -17
  1034. package/dist/src/tasks/transitions.js +0 -1
  1035. package/dist/src/tasks/types.d.ts +0 -138
  1036. package/dist/src/tasks/types.js +0 -1
  1037. package/dist/src/tools/framework/connection-search.d.ts +0 -3
  1038. package/dist/src/tools/framework/connection-search.js +0 -1
  1039. package/dist/src/tools/framework/task-cancel.d.ts +0 -4
  1040. package/dist/src/tools/framework/task-cancel.js +0 -1
  1041. package/dist/src/tools/framework/task-contract.d.ts +0 -19
  1042. package/dist/src/tools/framework/task-contract.js +0 -1
  1043. package/dist/src/tools/native-definition.d.ts +0 -7
  1044. package/dist/src/tools/native-definition.js +0 -1
  1045. package/dist/src/tracing/agent-invocation-terminal.d.ts +0 -18
  1046. package/dist/src/tracing/agent-invocation-terminal.js +0 -1
  1047. /package/dist/src/execution/{tools/subagent → agent-sessions}/metadata.d.ts +0 -0
  1048. /package/dist/src/execution/{tools/subagent → agent-sessions}/metadata.js +0 -0
@@ -1,115 +1,217 @@
1
1
  import type { StandardJSONSchemaV1, StandardSchemaV1 } from "#compiled/@standard-schema/spec/index.js";
2
2
  import type { Approval } from "#approval/definition.js";
3
- import type { JsonObject, JsonValue } from "#shared/json.js";
4
- import { type PublicToolDefinition, type ToolContext, type ToolInputRequest, type ToolInputResponse } from "#tools/definition.js";
3
+ import type { MessageResult, SendTurnOptions } from "#client/types.js";
4
+ import type { JsonObject } from "#shared/json.js";
5
+ import { type PublicToolDefinition, type ToolContext, type ToolInputRequest, type ToolInputRequestOptions, type ToolInputResponse } from "#tools/definition.js";
5
6
  import type { ToolModelOutput } from "#tools/model-output.js";
6
- /** Fixed acknowledgement returned when a background task is admitted. */
7
- export interface TaskReceipt {
8
- readonly status: "working";
9
- readonly taskId: string;
10
- }
11
- export interface AgentInput {
12
- readonly agentId?: string;
13
- readonly message: string;
14
- readonly outputSchema?: JsonObject;
15
- }
16
- type JsonSchemaProperties = Readonly<Record<string, JsonObject>>;
17
- type JsonSchemaRequiredKeys<TProperties extends JsonSchemaProperties, TRequired> = TRequired extends readonly string[] ? Extract<TRequired[number], keyof TProperties> : never;
18
- type Simplify<TValue> = {
19
- [TKey in keyof TValue]: TValue[TKey];
20
- };
21
- type JsonSchemaObjectOutput<TProperties extends JsonSchemaProperties, TRequired> = Simplify<{
22
- -readonly [TKey in JsonSchemaRequiredKeys<TProperties, TRequired>]-?: JsonSchemaOutput<TProperties[TKey]>;
23
- } & {
24
- -readonly [TKey in Exclude<keyof TProperties, JsonSchemaRequiredKeys<TProperties, TRequired>>]?: JsonSchemaOutput<TProperties[TKey]>;
25
- }>;
26
- type JsonSchemaOutput<TSchema> = TSchema extends {
27
- readonly const: infer TValue;
28
- } ? Extract<TValue, JsonValue> : TSchema extends {
29
- readonly enum: readonly (infer TValue)[];
30
- } ? Extract<TValue, JsonValue> : TSchema extends {
31
- readonly type: "object";
32
- readonly properties: infer TProperties extends JsonSchemaProperties;
33
- readonly required?: infer TRequired;
34
- } ? JsonSchemaObjectOutput<TProperties, TRequired> : TSchema extends {
35
- readonly type: "array";
36
- readonly items: infer TItems extends JsonObject;
37
- } ? JsonSchemaOutput<TItems>[] : TSchema extends {
38
- readonly type: "string";
39
- } ? string : TSchema extends {
40
- readonly type: "integer" | "number";
41
- } ? number : TSchema extends {
42
- readonly type: "boolean";
43
- } ? boolean : TSchema extends {
44
- readonly type: "null";
45
- } ? null : JsonValue;
7
+ import { type WorkflowToolEntryPoint } from "#tools/workflow-entry-point.js";
8
+ export type { WorkflowToolEntryPoint };
46
9
  export interface WorkflowAgentMetadata {
47
10
  readonly description: string;
48
11
  }
49
12
  /** Context capabilities available inside an authored `"use step"` helper. */
50
13
  export type WorkflowStepToolContext = Pick<ToolContext, "abortSignal" | "callId" | "session" | "toolName" | "getToken" | "requireAuth">;
51
- interface WorkflowAgent {
52
- <const TOutputSchema extends JsonObject>(target: string, input: AgentInput & {
53
- readonly outputSchema: TOutputSchema;
54
- }): Promise<JsonSchemaOutput<TOutputSchema>>;
55
- (target: string, input: AgentInput): Promise<JsonValue>;
14
+ /** Options for one message to a `ctx.agent` session. */
15
+ export interface AgentSendOptions<TOutput = unknown> {
16
+ /** Structured output for the turn, as on the client's `send`. */
17
+ readonly outputSchema?: SendTurnOptions<TOutput>["outputSchema"];
18
+ /** Aborting cancels the turn this message started or joined; the turn still reports. */
19
+ readonly signal?: AbortSignal;
56
20
  }
57
21
  /**
58
- * Context supplied to a workflow tool body. When passed directly to a step,
59
- * eve replaces it with {@link WorkflowStepToolContext}.
22
+ * How one agent turn ended, as the client's `MessageResult` reports it:
23
+ * `"waiting"` when the session waits for its next message, including after a
24
+ * cancelled turn, which carries neither `data` nor `message`; `"completed"`
25
+ * when the session ended with the turn; and `"failed"` when the turn failed,
26
+ * with the reason in `error`.
60
27
  */
61
- export type WorkflowToolContext = Pick<ToolContext, "abortSignal" | "callId" | "session" | "toolName" | "getToken" | "requireAuth"> & {
62
- /** Invoke an agent by its invocation name. */
63
- agent: WorkflowAgent;
28
+ export type AgentMessageResult<TOutput = unknown> = Pick<MessageResult<TOutput>, "data" | "message" | "status"> & {
29
+ /** Why the turn failed, present only when `status` is `"failed"`. */
30
+ readonly error?: {
31
+ readonly message: string;
32
+ };
33
+ };
34
+ /** The response to one message sent to a `ctx.agent` session. */
35
+ export interface AgentResponse<TOutput = unknown> {
36
+ /** Resolves when the turn the message started or joined ends. */
37
+ result(): Promise<AgentMessageResult<TOutput>>;
38
+ }
39
+ /**
40
+ * A session the workflow run owns, opened by its first `send` and ended when
41
+ * the run finishes. Only the run can address it.
42
+ */
43
+ export interface AgentSession {
44
+ /**
45
+ * Delivers a message. It joins the session's running turn, whose result the
46
+ * response resolves, or starts the next turn when the session is idle or the
47
+ * running turn ends before the agent reads it.
48
+ */
49
+ send<TOutput = unknown>(message: string, options?: AgentSendOptions<TOutput>): Promise<AgentResponse<TOutput>>;
50
+ }
51
+ /** Members the context of every workflow tool entry point shares. */
52
+ export type WorkflowSharedContext = Pick<ToolContext, "session" | "toolName" | "getToken" | "requireAuth"> & {
53
+ /**
54
+ * Returns a new session with the agent of this invocation name. Nothing
55
+ * starts until the first `send`.
56
+ */
57
+ agent(name: string): AgentSession;
64
58
  /** Metadata for agents callable by this workflow, including hidden agents. */
65
59
  agents: Readonly<Record<string, WorkflowAgentMetadata>>;
66
- /** Ask the human on the session's channel; awaiting the answer suspends the run. */
67
- ask(request: ToolInputRequest): PromiseLike<ToolInputResponse>;
60
+ /**
61
+ * Ask the human on the session's channel; awaiting the answer suspends the
62
+ * run. The request is withdrawn, resolving as `cancelled`, when
63
+ * `options.signal` or the call's `abortSignal` aborts.
64
+ */
65
+ ask(request: ToolInputRequest, options?: ToolInputRequestOptions): PromiseLike<ToolInputResponse>;
66
+ };
67
+ /**
68
+ * Context of an `execute(input, ctx)` or `task(input, ctx)` call. When passed
69
+ * directly to a step, eve replaces it with {@link WorkflowStepToolContext}.
70
+ */
71
+ export type WorkflowToolContext = WorkflowSharedContext & Pick<ToolContext, "callId"> & {
72
+ /**
73
+ * Aborts when the call's work should stop: the call is cancelled, by
74
+ * `task_cancel`, `session.cancel()`, a failed turn, or the end of the
75
+ * session, or, for an `execute` call, a steering message arrives while the
76
+ * turn waits on it. Stop and return what you have. After a steering
77
+ * message the call settles with what the body returns, or with
78
+ * `{ interrupted: true }` if it rejects; a cancelled call's result is
79
+ * discarded. A task never sees a steering message.
80
+ */
81
+ readonly abortSignal: AbortSignal;
82
+ };
83
+ /**
84
+ * One call a `serve` body receives: the call that started the task, or a
85
+ * later call the model made with the task's `taskId`.
86
+ */
87
+ export interface WorkflowServeCall<TInput = unknown> {
88
+ readonly callId: string;
89
+ /** The call's input, validated by the tool's `inputSchema`. */
90
+ readonly input: TInput;
91
+ /**
92
+ * Aborts when the task's current stretch of work is cancelled or the
93
+ * session ends. A stretch starts when a call reaches an idle task and ends
94
+ * when a reply or a cancel settles its calls; calls that arrive during it
95
+ * share its signal, and the next stretch gets a new one.
96
+ */
97
+ readonly abortSignal: AbortSignal;
98
+ }
99
+ /**
100
+ * Resolves with the task's next call. The first `receive()` resolves at once
101
+ * with the call that started the task; each later one with the next call made
102
+ * with the task's `taskId`, in arrival order. A pending `receive()` is shared:
103
+ * calling it again returns the same promise. A call counts as received once its
104
+ * promise resolves, even if that promise lost a `Promise.race`, and the next
105
+ * `ctx.reply()` settles it, so keep a raced promise until you read its call.
106
+ * It rejects when the session ends.
107
+ */
108
+ export type WorkflowServeReceive<TInput = unknown> = () => Promise<WorkflowServeCall<TInput>>;
109
+ /**
110
+ * Context of a `serve(receive, ctx)` task. Each call brings its own `callId`
111
+ * and `abortSignal` from `receive()`, and steering never interrupts a task, so
112
+ * the context has neither. `session` (its turn and auth) and `agents`
113
+ * describe the latest call received, the call the body serves now. A session
114
+ * opened with `agent()` is the child of the call served when it opens, and
115
+ * each message sent to it carries the auth of the call served when it is sent.
116
+ * `ctx.ask` throws while no call is
117
+ * waiting for a result. When passed directly to a step, eve replaces it with
118
+ * {@link WorkflowStepToolContext} for the latest call waiting for a result.
119
+ */
120
+ export type WorkflowServeContext<TOutput = unknown> = WorkflowSharedContext & {
121
+ /**
122
+ * Settles every call received so far with `output`, and the task goes idle
123
+ * until its next call. A reply with no call left to settle, including one
124
+ * after a cancel, is dropped.
125
+ */
126
+ reply(output: TOutput): void;
68
127
  };
69
128
  declare const WORKFLOW_TOOL_BRAND: unique symbol;
70
- /** A static tool whose executor runs as a durable workflow. Its executor must start with "use workflow". */
71
- export interface BlockingWorkflowToolDefinition<TInput = unknown, TOutput = unknown> extends PublicToolDefinition<TInput, TOutput> {
129
+ interface WorkflowToolDefinitionBase<TInput, TOutput> extends PublicToolDefinition<TInput, TOutput> {
72
130
  readonly [WORKFLOW_TOOL_BRAND]: true;
73
- readonly execution?: never;
74
- execute(input: TInput, ctx: WorkflowToolContext): Promise<TOutput> | AsyncIterable<TOutput>;
75
131
  approval?: Approval<unknown extends TInput ? Record<string, unknown> : TInput>;
76
132
  toModelOutput?: (output: TOutput) => ToolModelOutput | Promise<ToolModelOutput>;
77
133
  }
78
- export type BackgroundWorkflowToolDefinition<TInput, TOutput> = PublicToolDefinition<TInput, TaskReceipt> & {
79
- readonly [WORKFLOW_TOOL_BRAND]: true;
80
- readonly execution: "background";
81
- execute(input: TInput, ctx: WorkflowToolContext): Promise<TOutput> | AsyncIterable<unknown>;
82
- approval?: Approval<unknown extends TInput ? Record<string, unknown> : TInput>;
83
- toModelOutput?: (output: TaskReceipt) => ToolModelOutput | Promise<ToolModelOutput>;
84
- };
85
- /** A static tool whose executor runs as a durable workflow. */
86
- export type WorkflowToolDefinition<TInput = unknown, TOutput = unknown> = BlockingWorkflowToolDefinition<TInput, TOutput> | BackgroundWorkflowToolDefinition<TInput, TOutput>;
134
+ /** A workflow tool whose calls are ordinary tool calls: the turn waits until each settles. */
135
+ export interface WorkflowExecuteToolDefinition<TInput = unknown, TOutput = unknown> extends WorkflowToolDefinitionBase<TInput, TOutput> {
136
+ execute(input: TInput, ctx: WorkflowToolContext): Promise<TOutput> | AsyncIterable<TOutput>;
137
+ task?: never;
138
+ serve?: never;
139
+ }
140
+ /**
141
+ * A workflow tool whose every call runs as a task: the model gets a receipt at
142
+ * once and the conversation continues, and the result arrives later in a
143
+ * `task.result` message.
144
+ */
145
+ export interface WorkflowTaskToolDefinition<TInput = unknown, TOutput = unknown> extends WorkflowToolDefinitionBase<TInput, TOutput> {
146
+ task(input: TInput, ctx: WorkflowToolContext): Promise<TOutput> | AsyncIterable<TOutput>;
147
+ execute?: never;
148
+ serve?: never;
149
+ }
150
+ /**
151
+ * A workflow tool whose calls reach resumable tasks. A call without `taskId`
152
+ * starts a task, whose body runs once and gets that call and every later call
153
+ * made with its `taskId` from `receive()`; each `ctx.reply()` delivers a
154
+ * result. eve adds the optional `taskId` to the tool's model input, so
155
+ * `inputSchema` must not declare its own. Returning settles the calls still
156
+ * waiting and ends the task; throwing fails them.
157
+ */
158
+ export interface WorkflowServeToolDefinition<TInput = unknown, TOutput = unknown> extends WorkflowToolDefinitionBase<TInput, TOutput> {
159
+ serve(receive: WorkflowServeReceive<TInput>, ctx: WorkflowServeContext<TOutput>): Promise<TOutput>;
160
+ execute?: never;
161
+ task?: never;
162
+ }
163
+ /**
164
+ * A static tool whose entry point runs as a durable workflow and must start
165
+ * with "use workflow". It defines exactly one entry point.
166
+ */
167
+ export type WorkflowToolDefinition<TInput = unknown, TOutput = unknown> = WorkflowExecuteToolDefinition<TInput, TOutput> | WorkflowTaskToolDefinition<TInput, TOutput> | WorkflowServeToolDefinition<TInput, TOutput>;
87
168
  type Unbranded<T> = T extends unknown ? Omit<T, typeof WORKFLOW_TOOL_BRAND> : never;
88
- type BackgroundReturn<T> = T extends AsyncGenerator<unknown, infer Output> ? Output : T extends AsyncIterable<unknown> ? null : Awaited<T>;
89
- type BackgroundDefinition<TInput, TReturn> = Omit<BackgroundWorkflowToolDefinition<TInput, BackgroundReturn<TReturn>>, typeof WORKFLOW_TOOL_BRAND | "execute"> & {
90
- execute(input: TInput, ctx: WorkflowToolContext): TReturn;
91
- };
92
169
  type WorkflowReturn<T> = T extends AsyncIterable<infer Output> ? Output : Awaited<T>;
93
170
  type Schema = StandardSchemaV1<unknown, unknown> | StandardJSONSchemaV1<unknown, unknown>;
94
- type Definition<TInput, TReturn> = Omit<BlockingWorkflowToolDefinition<TInput, WorkflowReturn<TReturn>>, typeof WORKFLOW_TOOL_BRAND | "execute"> & {
171
+ type EntryPointReturn<TOutput> = Promise<TOutput> | AsyncIterable<TOutput>;
172
+ type InferOutput<TSchema extends StandardJSONSchemaV1<unknown, unknown>> = StandardJSONSchemaV1.InferOutput<TSchema>;
173
+ type InferInput<TSchema extends Schema> = StandardSchemaV1.InferOutput<TSchema>;
174
+ type DefinitionFields<TInput, TOutput> = Omit<WorkflowToolDefinitionBase<TInput, TOutput>, typeof WORKFLOW_TOOL_BRAND>;
175
+ type ExecuteDefinition<TInput, TReturn> = DefinitionFields<TInput, WorkflowReturn<TReturn>> & {
95
176
  execute(input: TInput, ctx: WorkflowToolContext): TReturn;
177
+ task?: never;
178
+ serve?: never;
179
+ };
180
+ type TaskDefinition<TInput, TReturn> = DefinitionFields<TInput, WorkflowReturn<TReturn>> & {
181
+ task(input: TInput, ctx: WorkflowToolContext): TReturn;
182
+ execute?: never;
183
+ serve?: never;
96
184
  };
97
- export declare function defineWorkflowTool<TInputSchema extends Schema, TOutputSchema extends StandardJSONSchemaV1<unknown, unknown>, TReturn extends Promise<StandardJSONSchemaV1.InferOutput<TOutputSchema>> | AsyncIterable<StandardJSONSchemaV1.InferOutput<TOutputSchema>>>(definition: Omit<Definition<StandardSchemaV1.InferOutput<TInputSchema>, TReturn>, "inputSchema" | "outputSchema"> & {
185
+ type ServeDefinition<TInput, TOutput> = DefinitionFields<TInput, TOutput> & {
186
+ serve(receive: WorkflowServeReceive<TInput>, ctx: WorkflowServeContext<TOutput>): Promise<TOutput>;
187
+ execute?: never;
188
+ task?: never;
189
+ };
190
+ type WithSchemas<TDefinition, TInputSchema, TOutputSchema> = Omit<TDefinition, "inputSchema" | "outputSchema"> & {
98
191
  inputSchema: TInputSchema;
99
192
  outputSchema: TOutputSchema;
100
- }): BlockingWorkflowToolDefinition<StandardSchemaV1.InferOutput<TInputSchema>, StandardJSONSchemaV1.InferOutput<TOutputSchema>>;
101
- export declare function defineWorkflowTool<TSchema extends Schema, TReturn extends Promise<unknown> | AsyncIterable<unknown>>(definition: Omit<BackgroundDefinition<StandardSchemaV1.InferOutput<TSchema>, TReturn>, "inputSchema"> & {
193
+ };
194
+ type WithInputSchema<TDefinition, TSchema> = Omit<TDefinition, "inputSchema"> & {
102
195
  inputSchema: TSchema;
103
- }): BackgroundWorkflowToolDefinition<StandardSchemaV1.InferOutput<TSchema>, BackgroundReturn<TReturn>>;
104
- export declare function defineWorkflowTool<TReturn extends Promise<unknown> | AsyncIterable<unknown>>(definition: BackgroundDefinition<Record<string, unknown>, TReturn> & {
196
+ };
197
+ export declare function defineWorkflowTool<TInputSchema extends Schema, TOutputSchema extends StandardJSONSchemaV1<unknown, unknown>, TReturn extends EntryPointReturn<InferOutput<TOutputSchema>>>(definition: WithSchemas<ExecuteDefinition<InferInput<TInputSchema>, TReturn>, TInputSchema, TOutputSchema>): WorkflowExecuteToolDefinition<InferInput<TInputSchema>, InferOutput<TOutputSchema>>;
198
+ export declare function defineWorkflowTool<TInputSchema extends Schema, TOutputSchema extends StandardJSONSchemaV1<unknown, unknown>, TReturn extends EntryPointReturn<InferOutput<TOutputSchema>>>(definition: WithSchemas<TaskDefinition<InferInput<TInputSchema>, TReturn>, TInputSchema, TOutputSchema>): WorkflowTaskToolDefinition<InferInput<TInputSchema>, InferOutput<TOutputSchema>>;
199
+ export declare function defineWorkflowTool<TInputSchema extends Schema, TOutputSchema extends StandardJSONSchemaV1<unknown, unknown>>(definition: WithSchemas<ServeDefinition<InferInput<TInputSchema>, InferOutput<TOutputSchema>>, TInputSchema, TOutputSchema>): WorkflowServeToolDefinition<InferInput<TInputSchema>, InferOutput<TOutputSchema>>;
200
+ export declare function defineWorkflowTool<TSchema extends Schema, TReturn extends EntryPointReturn<unknown>>(definition: WithInputSchema<ExecuteDefinition<InferInput<TSchema>, TReturn>, TSchema>): WorkflowExecuteToolDefinition<InferInput<TSchema>, WorkflowReturn<TReturn>>;
201
+ export declare function defineWorkflowTool<TSchema extends Schema, TReturn extends EntryPointReturn<unknown>>(definition: WithInputSchema<TaskDefinition<InferInput<TSchema>, TReturn>, TSchema>): WorkflowTaskToolDefinition<InferInput<TSchema>, WorkflowReturn<TReturn>>;
202
+ export declare function defineWorkflowTool<TSchema extends Schema>(definition: WithInputSchema<ServeDefinition<InferInput<TSchema>, unknown>, TSchema>): WorkflowServeToolDefinition<InferInput<TSchema>>;
203
+ export declare function defineWorkflowTool<TReturn extends EntryPointReturn<unknown>>(definition: ExecuteDefinition<Record<string, unknown>, TReturn> & {
105
204
  inputSchema: JsonObject;
106
- }): BackgroundWorkflowToolDefinition<Record<string, unknown>, BackgroundReturn<TReturn>>;
107
- export declare function defineWorkflowTool<TSchema extends Schema, TReturn extends Promise<unknown> | AsyncIterable<unknown>>(definition: Omit<Definition<StandardSchemaV1.InferOutput<TSchema>, TReturn>, "inputSchema"> & {
108
- inputSchema: TSchema;
109
- }): BlockingWorkflowToolDefinition<StandardSchemaV1.InferOutput<TSchema>, WorkflowReturn<TReturn>>;
110
- export declare function defineWorkflowTool<TReturn extends Promise<unknown> | AsyncIterable<unknown>>(definition: Definition<Record<string, unknown>, TReturn> & {
205
+ }): WorkflowExecuteToolDefinition<Record<string, unknown>, WorkflowReturn<TReturn>>;
206
+ export declare function defineWorkflowTool<TReturn extends EntryPointReturn<unknown>>(definition: TaskDefinition<Record<string, unknown>, TReturn> & {
207
+ inputSchema: JsonObject;
208
+ }): WorkflowTaskToolDefinition<Record<string, unknown>, WorkflowReturn<TReturn>>;
209
+ export declare function defineWorkflowTool(definition: ServeDefinition<Record<string, unknown>, unknown> & {
111
210
  inputSchema: JsonObject;
112
- }): BlockingWorkflowToolDefinition<Record<string, unknown>, WorkflowReturn<TReturn>>;
113
- export declare function defineWorkflowTool<TInput = unknown, TOutput = unknown>(definition: Unbranded<WorkflowToolDefinition<TInput, TOutput>>): WorkflowToolDefinition<TInput, TOutput>;
211
+ }): WorkflowServeToolDefinition<Record<string, unknown>>;
212
+ export declare function defineWorkflowTool<TInput = unknown, TOutput = unknown>(definition: Unbranded<WorkflowExecuteToolDefinition<TInput, TOutput>>): WorkflowExecuteToolDefinition<TInput, TOutput>;
213
+ export declare function defineWorkflowTool<TInput = unknown, TOutput = unknown>(definition: Unbranded<WorkflowTaskToolDefinition<TInput, TOutput>>): WorkflowTaskToolDefinition<TInput, TOutput>;
214
+ export declare function defineWorkflowTool<TInput = unknown, TOutput = unknown>(definition: Unbranded<WorkflowServeToolDefinition<TInput, TOutput>>): WorkflowServeToolDefinition<TInput, TOutput>;
114
215
  export declare function isWorkflowToolDefinition(value: unknown): boolean;
115
- export {};
216
+ /** The entry points a definition defines; a workflow tool defines exactly one. */
217
+ export declare function readWorkflowToolEntryPoints(definition: object): WorkflowToolEntryPoint[];
@@ -1 +1 @@
1
- import{stampToolDefinition}from"#tools/definition.js";const WORKFLOW_TOOL_BRAND=Symbol.for(`eve:workflow-tool-brand`);function defineWorkflowTool(e){return stampToolDefinition(e,`defineWorkflowTool`),Object.assign(e,{[WORKFLOW_TOOL_BRAND]:!0})}function isWorkflowToolDefinition(e){return typeof e==`object`&&!!e&&Reflect.get(e,WORKFLOW_TOOL_BRAND)===!0}export{defineWorkflowTool,isWorkflowToolDefinition};
1
+ import{stampToolDefinition}from"#tools/definition.js";import{WORKFLOW_TOOL_ENTRY_POINTS}from"#tools/workflow-entry-point.js";const WORKFLOW_TOOL_BRAND=Symbol.for(`eve:workflow-tool-brand`);function defineWorkflowTool(e){if(`execution`in e)throw Error(`"execution" was replaced by task(). Define task(input, ctx) to run each call as a task.`);return assertOneEntryPoint(e),stampToolDefinition(e,`defineWorkflowTool`),Object.assign(e,{[WORKFLOW_TOOL_BRAND]:!0})}function isWorkflowToolDefinition(e){return typeof e==`object`&&!!e&&Reflect.get(e,WORKFLOW_TOOL_BRAND)===!0}function readWorkflowToolEntryPoints(e){return WORKFLOW_TOOL_ENTRY_POINTS.filter(t=>Reflect.get(e,t)!==void 0)}const ENTRY_POINT_LIST=new Intl.ListFormat(`en`,{type:`conjunction`});function assertOneEntryPoint(e){let t=readWorkflowToolEntryPoints(e);if(t.length===1)return;let n=t.length===0?`none`:ENTRY_POINT_LIST.format(t);throw Error(`Define exactly one of execute(input, ctx), task(input, ctx), or serve(receive, ctx); this tool defines ${n}.`)}export{defineWorkflowTool,isWorkflowToolDefinition,readWorkflowToolEntryPoints};
@@ -0,0 +1,3 @@
1
+ /** The method a workflow tool defines, which decides how its calls run. */
2
+ export type WorkflowToolEntryPoint = "execute" | "task" | "serve";
3
+ export declare const WORKFLOW_TOOL_ENTRY_POINTS: readonly WorkflowToolEntryPoint[];
@@ -0,0 +1 @@
1
+ const WORKFLOW_TOOL_ENTRY_POINTS=[`execute`,`task`,`serve`];export{WORKFLOW_TOOL_ENTRY_POINTS};
@@ -1,13 +1,11 @@
1
1
  import { type Context, type SpanContext, type Tracer } from "#compiled/@opentelemetry/api/index.js";
2
- import type { InstrumentationActionStartedEvent, InstrumentationAttemptScope, InstrumentationProviderDefinition, InstrumentationSessionTransitionEvent } from "#instrumentation/lifecycle.js";
2
+ import type { InstrumentationActionStartedEvent, InstrumentationAttemptScope, InstrumentationProviderDefinition } from "#instrumentation/lifecycle.js";
3
3
  import type { AgentSpanIdGenerator } from "#tracing/agent-span-id-generator.js";
4
4
  import type { AgentTraceStateStore } from "#tracing/agent-trace-state.js";
5
5
  interface AgentActionInstrumentation {
6
6
  readonly events: Pick<NonNullable<InstrumentationProviderDefinition["events"]>, "action.completed" | "action.failed" | "action.started">;
7
7
  deleteForSession(sessionId: string): void | PromiseLike<void>;
8
8
  failForAttempt(scope: InstrumentationAttemptScope, error: unknown): Promise<void>;
9
- flushSettledInvocations(): Promise<void>;
10
- flushForSessionTransition(event: InstrumentationSessionTransitionEvent): Promise<void>;
11
9
  contextFor(sessionId: string, turnId: string, callId: string): Promise<AgentActionContext | undefined>;
12
10
  }
13
11
  export interface AgentActionContext {
@@ -1 +1 @@
1
- import{normalizeChannelAudience}from"#shared/channel-audience.js";import{AGENT_SPAN_NAMES,workflowInvocationSpanName}from"#tracing/agent-span-contract.js";import{isSampledTrace}from"#tracing/sampled-trace.js";import{ROOT_CONTEXT,SpanKind,trace}from"#compiled/@opentelemetry/api/index.js";import{actionIdempotencyKey,attemptIdempotencyKey}from"#instrumentation/lifecycle.js";import{agentSpanNamingAttributes}from"#tracing/agent-span-naming.js";import{contentAttribute,textContentAttribute}from"#tracing/agent-otel-content.js";import{recordAgentSpanError}from"#tracing/agent-span-error.js";import{agentTraceIdentityAttributes}from"#tracing/agent-otel-attributes.js";import{setAgentUsage}from"#tracing/agent-otel-usage.js";import{withChannelAudience}from"#tracing/channel-audience-context.js";function createAgentActionInstrumentation(e){let t=new Map,onStarted=async n=>{let r=await e.resolveTraceContext(n);if(r===void 0||!isSampledTrace(r))return;let i=await e.stateStore.getAction(n.idempotencyKey)??{attemptIndex:n.scope.attemptIndex,callId:n.callId,channelAudience:normalizeChannelAudience(n.scope.channelAudience),inputAttribute:e.recordInputs?contentAttribute(n.input):void 0,isWorkflowTool:n.isWorkflowTool===!0,kind:n.kind,name:n.name,parent:{spanId:e.idGenerator.deriveSpanId(attemptIdempotencyKey(n.scope)),traceFlags:r.traceFlags,traceId:r.traceId},rootSessionId:n.scope.rootSessionId??n.scope.sessionId,sessionId:n.scope.sessionId,spanId:e.idGenerator.deriveSpanId(`action:${n.idempotencyKey}`),startTimeMs:Date.now(),stepIndex:n.scope.stepIndex,turnId:n.scope.turnId};await e.stateStore.setAction(n.idempotencyKey,i),n.isWorkflowTool===!0&&await e.stateStore.setActionAnchor(n.idempotencyKey,i);let a=t.get(n.scope.attemptId)??new Set;a.add(n.idempotencyKey),t.set(n.scope.attemptId,a)},onTerminal=async t=>{let n=await e.stateStore.getAction(t.idempotencyKey);if(n!==void 0)try{finishActionSpan(n,t)}finally{await e.stateStore.deleteAction(t.idempotencyKey),forget(t.idempotencyKey)}},startSpan=t=>{let n=isAgentInvocation(t.kind),r=t.kind===`tool-call`?t.workflowName:void 0,i=r===void 0?AGENT_SPAN_NAMES.action:workflowInvocationSpanName(r),a=e.idGenerator.withSpanId(t.spanId,()=>e.tracer.startSpan(AGENT_SPAN_NAMES.action,{attributes:{"agent.action.call_id":t.callId,"agent.action.kind":t.kind,"agent.action.name":t.name,"agent.framework.name":`eve`,"agent.framework.version":e.frameworkVersion,"agent.step.attempt":t.attemptIndex,"agent.step.index":t.stepIndex,"agent.turn.id":t.turnId,...agentSpanNamingAttributes(i,r===void 0?void 0:`invoke_workflow`),...agentTraceIdentityAttributes({rootSessionId:t.rootSessionId,sessionId:t.sessionId}),...r===void 0?void 0:{"gen_ai.operation.name":`invoke_workflow`,"gen_ai.workflow.name":r},...n?{"gen_ai.agent.name":t.name,"agent.invocation.role":`caller`}:void 0},kind:t.kind===`remote-agent-call`?SpanKind.CLIENT:SpanKind.INTERNAL,startTime:t.startTimeMs},contextFromActionState(t)));return r!==void 0&&updateSpanName(a,i),!n&&t.inputAttribute!==void 0&&a.setAttribute(`gen_ai.tool.call.arguments`,t.inputAttribute),a};return{async contextFor(t,n,r){let i=actionIdempotencyKey(t,n,r),a=await e.stateStore.getAction(i);if(a!==void 0)return actionContext(a);let o=await e.stateStore.findAction(t,r);return o===void 0?void 0:actionContext(o)},async deleteForSession(t){await e.stateStore.deleteActions(t),await e.stateStore.deleteActionAnchors(t),await e.stateStore.deleteInvocations(t)},async failForAttempt(n,r){let i=t.get(n.attemptId);if(i!==void 0){t.delete(n.attemptId);for(let t of i){let n=await e.stateStore.getAction(t);if(n===void 0)continue;let i=startSpan(n);recordAgentSpanError(i,r),i.end(),await e.stateStore.deleteAction(t)}}},flushSettledInvocations:()=>flushInvocations(),async flushForSessionTransition(e){let t=e.type===`session.completed`?{outcome:`abandoned`}:e.type===`session.failed`?{error:e.error,outcome:`failed`}:void 0;await flushInvocations(e.sessionId,t)},events:{"action.completed":onTerminal,"action.failed":onTerminal,"action.started":onStarted}};async function flushInvocations(t,n){for(let r of await e.stateStore.findInvocations(t)){let t=r.terminal??n;t!==void 0&&(finishInvocationSpan(r,t),await e.stateStore.deleteInvocation(actionIdempotencyKey(r.sessionId,r.turnId,r.callId)))}}function forget(e){for(let[n,r]of t)r.delete(e),r.size===0&&t.delete(n)}function finishActionSpan(t,n){let r=startSpan(t);if(r.setAttribute(`agent.action.outcome`,n.outcome),n.type===`action.failed`)n.errorCode!==void 0&&r.setAttribute(`agent.action.error.code`,n.errorCode),recordActionError(r,n.error,n.errorCode);else if(n.output.type===`error`)recordActionError(r,n.output.error);else if(n.usage!==void 0&&setAgentUsage(r,n.usage),e.recordOutputs&&!isAgentInvocation(t.kind)){let e=contentAttribute(n.output.output);e!==void 0&&r.setAttribute(`gen_ai.tool.call.result`,e)}r.end(n.acceptedAtMs)}function finishInvocationSpan(t,n){let r=startSpan(t);r.setAttribute(`agent.action.outcome`,n.outcome),n.usage!==void 0&&setAgentUsage(r,n.usage),n.outcome===`failed`&&recordAgentSpanError(r,e.recordOutputs&&t.recordOutputs===!0?n.error:void 0),r.end(n.acceptedAtMs)}}function actionContext(e){let t={isRemote:!1,spanId:e.spanId,traceFlags:e.parent.traceFlags,traceId:e.parent.traceId};return{context:withChannelAudience(trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext(t)),e.channelAudience),spanContext:t}}function contextFromActionState(e){return withChannelAudience(trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext({...e.parent,isRemote:!1})),e.channelAudience)}function isAgentInvocation(e){return e===`subagent-call`||e===`remote-agent-call`}function updateSpanName(e,t){let n=Reflect.get(e,`updateName`);typeof n==`function`&&Reflect.apply(n,e,[t])}function recordActionError(e,t,n){if(t instanceof Error||t===void 0){recordAgentSpanError(e,t,n);return}let r=serializedErrorDetail(t);if(r===void 0){recordAgentSpanError(e,void 0,n);return}let i=Error(r);n!==void 0&&(i.name=n),recordAgentSpanError(e,i,n)}function serializedErrorDetail(e){if(typeof e==`string`)return textContentAttribute(e);let t=contentAttribute(e);if(typeof e!=`object`||!e||Array.isArray(e))return t;let n=Reflect.get(e,`message`);return typeof n==`string`?textContentAttribute(t===void 0?n:`${n}\n${t}`):t}export{createAgentActionInstrumentation};
1
+ import{normalizeChannelAudience}from"#shared/channel-audience.js";import{AGENT_SPAN_NAMES}from"#tracing/agent-span-contract.js";import{isSampledTrace}from"#tracing/sampled-trace.js";import{ROOT_CONTEXT,SpanKind,trace}from"#compiled/@opentelemetry/api/index.js";import{actionIdempotencyKey,attemptIdempotencyKey}from"#instrumentation/lifecycle.js";import{agentSpanNamingAttributes}from"#tracing/agent-span-naming.js";import{contentAttribute,textContentAttribute}from"#tracing/agent-otel-content.js";import{recordAgentSpanError}from"#tracing/agent-span-error.js";import{agentTraceIdentityAttributes}from"#tracing/agent-otel-attributes.js";import{setAgentUsage}from"#tracing/agent-otel-usage.js";import{withChannelAudience}from"#tracing/channel-audience-context.js";function createAgentActionInstrumentation(e){let t=new Map,onStarted=async n=>{let r=await e.resolveTraceContext(n);if(r===void 0||!isSampledTrace(r))return;let i=await e.stateStore.getAction(n.idempotencyKey)??{attemptIndex:n.scope.attemptIndex,callId:n.callId,channelAudience:normalizeChannelAudience(n.scope.channelAudience),inputAttribute:e.recordInputs?contentAttribute(n.input):void 0,kind:n.kind,name:n.name,parent:{spanId:e.idGenerator.deriveSpanId(attemptIdempotencyKey(n.scope)),traceFlags:r.traceFlags,traceId:r.traceId},rootSessionId:n.scope.rootSessionId??n.scope.sessionId,sessionId:n.scope.sessionId,spanId:e.idGenerator.deriveSpanId(`action:${n.idempotencyKey}`),startTimeMs:Date.now(),stepIndex:n.scope.stepIndex,turnId:n.scope.turnId};await e.stateStore.setAction(n.idempotencyKey,i),n.isWorkflowTool===!0&&await e.stateStore.setActionAnchor(n.idempotencyKey,i);let a=t.get(n.scope.attemptId)??new Set;a.add(n.idempotencyKey),t.set(n.scope.attemptId,a)},onTerminal=async t=>{let n=await e.stateStore.getAction(t.idempotencyKey);if(n!==void 0)try{finishActionSpan(n,t)}finally{await e.stateStore.deleteAction(t.idempotencyKey),forget(t.idempotencyKey)}},startSpan=t=>{let n=isAgentInvocation(t.kind),r=e.idGenerator.withSpanId(t.spanId,()=>e.tracer.startSpan(AGENT_SPAN_NAMES.action,{attributes:{"agent.action.call_id":t.callId,"agent.action.kind":t.kind,"agent.action.name":t.name,"agent.framework.name":`eve`,"agent.framework.version":e.frameworkVersion,"agent.step.attempt":t.attemptIndex,"agent.step.index":t.stepIndex,"agent.turn.id":t.turnId,...agentSpanNamingAttributes(AGENT_SPAN_NAMES.action),...agentTraceIdentityAttributes({rootSessionId:t.rootSessionId,sessionId:t.sessionId}),...n?{"gen_ai.agent.name":t.name,"agent.invocation.role":`caller`}:void 0},kind:t.kind===`remote-agent-call`?SpanKind.CLIENT:SpanKind.INTERNAL,startTime:t.startTimeMs},contextFromActionState(t)));return!n&&t.inputAttribute!==void 0&&r.setAttribute(`gen_ai.tool.call.arguments`,t.inputAttribute),r};return{async contextFor(t,n,r){let i=actionIdempotencyKey(t,n,r),a=await e.stateStore.getAction(i);if(a!==void 0)return actionContext(a);let o=await e.stateStore.findAction(t,r);return o===void 0?void 0:actionContext(o)},async deleteForSession(t){await e.stateStore.deleteActions(t),await e.stateStore.deleteActionAnchors(t)},async failForAttempt(n,r){let i=t.get(n.attemptId);if(i!==void 0){t.delete(n.attemptId);for(let t of i){let n=await e.stateStore.getAction(t);if(n===void 0)continue;let i=startSpan(n);recordAgentSpanError(i,r),i.end(),await e.stateStore.deleteAction(t)}}},events:{"action.completed":onTerminal,"action.failed":onTerminal,"action.started":onStarted}};function forget(e){for(let[n,r]of t)r.delete(e),r.size===0&&t.delete(n)}function finishActionSpan(t,n){let r=startSpan(t);if(r.setAttribute(`agent.action.outcome`,n.outcome),n.usage!==void 0&&setAgentUsage(r,n.usage),n.type===`action.failed`)n.errorCode!==void 0&&r.setAttribute(`agent.action.error.code`,n.errorCode),recordActionError(r,n.error,n.errorCode);else if(n.output.type===`error`)recordActionError(r,n.output.error);else if(e.recordOutputs&&!isAgentInvocation(t.kind)){let e=contentAttribute(n.output.output);e!==void 0&&r.setAttribute(`gen_ai.tool.call.result`,e)}r.end(n.acceptedAtMs)}}function actionContext(e){let t={isRemote:!1,spanId:e.spanId,traceFlags:e.parent.traceFlags,traceId:e.parent.traceId};return{context:withChannelAudience(trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext(t)),e.channelAudience),spanContext:t}}function contextFromActionState(e){return withChannelAudience(trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext({...e.parent,isRemote:!1})),e.channelAudience)}function isAgentInvocation(e){return e===`subagent-call`||e===`remote-agent-call`}function recordActionError(e,t,n){if(t instanceof Error||t===void 0){recordAgentSpanError(e,t,n);return}let r=serializedErrorDetail(t);if(r===void 0){recordAgentSpanError(e,void 0,n);return}let i=Error(r);n!==void 0&&(i.name=n),recordAgentSpanError(e,i,n)}function serializedErrorDetail(e){if(typeof e==`string`)return textContentAttribute(e);let t=contentAttribute(e);if(typeof e!=`object`||!e||Array.isArray(e))return t;let n=Reflect.get(e,`message`);return typeof n==`string`?textContentAttribute(t===void 0?n:`${n}\n${t}`):t}export{createAgentActionInstrumentation};
@@ -1,29 +1,20 @@
1
1
  import type { SessionTraceContext } from "#channel/types.js";
2
- import type { RuntimeSubagentResult } from "#shared/action-types.js";
3
- import type { SessionStateMap } from "#harness/types.js";
4
- import { type ChannelAudience } from "#shared/channel-audience.js";
2
+ import type { ChannelAudience } from "#shared/channel-audience.js";
5
3
  import type { ConversationContext } from "#shared/conversation-context.js";
6
4
  export interface AgentChildTraceDispatch {
7
5
  readonly conversationId?: string;
8
6
  readonly originAudience: ChannelAudience;
9
7
  readonly parentTraceContext?: SessionTraceContext;
10
8
  }
11
- export declare function prepareAgentInvocationTrace(input: {
9
+ /**
10
+ * The trace dispatch for sessions opened with `ctx.agent` while a run serves
11
+ * one workflow tool call: the call's tool span in the calling turn, read from
12
+ * the calling session when it admits the call.
13
+ */
14
+ export declare function resolveToolCallAgentTrace(input: {
15
+ readonly callId: string;
12
16
  readonly conversation?: ConversationContext;
13
- readonly invocation: {
14
- readonly callId: string;
15
- readonly kind: "remote-agent-call" | "subagent-call";
16
- readonly name: string;
17
- };
18
- readonly ownerId: string;
19
17
  readonly serializedContext: Record<string, unknown>;
20
18
  readonly sessionId: string;
21
- readonly sessionState?: SessionStateMap;
22
- readonly startTimeMs: number;
23
- readonly taskId?: string;
24
19
  readonly turnId: string;
25
- }): {
26
- readonly dispatch: AgentChildTraceDispatch;
27
- fail(result: RuntimeSubagentResult): Record<string, unknown>;
28
- readonly serializedContext: Record<string, unknown>;
29
- };
20
+ }): AgentChildTraceDispatch;
@@ -1 +1 @@
1
- import"#shared/channel-audience.js";import{applyLiveDeliveryAudienceCeiling,readForwardedTraceAssertion}from"#shared/forwarded-trace-policy.js";import{ConversationIdKey}from"#context/keys.js";import{getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{readActionTraceContext,readTaskActionTrace,readTurnTraceContext,recordActionInvocationKind,recordNestedAgentInvocation}from"#tracing/agent-trace-context-store.js";import{readConversationId}from"#shared/conversation-identity.js";import{invocationError,recordNestedAgentInvocationTerminal}from"#tracing/agent-invocation-terminal.js";import{deriveAgentActionSpanId}from"#tracing/agent-span-id-generator.js";function prepareAgentInvocationTrace(e){let t=readConversationId(e.serializedContext[ConversationIdKey.name]),n=e.taskId===void 0?void 0:readTaskActionTrace(e.serializedContext,e.sessionId,e.taskId),r=e.taskId===void 0?getBlockingWorkflowToolRuns(e.sessionState).find(t=>t.address.runId===e.ownerId)?.callId:n?.callId,i=n?.turnId??e.turnId,a=readTurnTraceContext(e.serializedContext,e.sessionId,i),o=e.conversation,s=o?.audience??`unknown`,c=o?.environment??`production`,l=(r===void 0?void 0:readActionTraceContext(e.serializedContext,e.sessionId,i,r))??a,u=l?.decision===void 0?void 0:applyLiveDeliveryAudienceCeiling(l.decision,s,l.forwardedTracePolicy,c),d=r===void 0?e.serializedContext:r===e.invocation.callId?recordActionInvocationKind({callId:e.invocation.callId,kind:e.invocation.kind,serializedContext:e.serializedContext,sessionId:e.sessionId,turnId:i}):recordNestedAgentInvocation({callId:e.invocation.callId,kind:e.invocation.kind,name:e.invocation.name,outerCallId:r,recordOutputs:u?.action===`record`&&u.recordOutputs,serializedContext:e.serializedContext,sessionId:e.sessionId,spanId:deriveAgentActionSpanId(e.sessionId,i,e.invocation.callId),startTimeMs:e.startTimeMs,turnId:i}),f=readActionTraceContext(d,e.sessionId,i,e.invocation.callId)??l,p=readForwardedTraceAssertion(f?.forwardedTracePolicy),m=f?.decision===void 0?f:{...f,decision:applyLiveDeliveryAudienceCeiling(f.decision,s,p,c)};return{dispatch:{conversationId:t,originAudience:p?.originAudience??s,parentTraceContext:m},fail:t=>recordNestedAgentInvocationTerminal({callId:e.invocation.callId,serializedContext:d,sessionId:e.sessionId,terminal:{acceptedAtMs:Date.now(),error:invocationError(t.output),outcome:`failed`},turnId:i}),serializedContext:d}}export{prepareAgentInvocationTrace};
1
+ import{applyLiveDeliveryAudienceCeiling,readForwardedTraceAssertion}from"#shared/forwarded-trace-policy.js";import{ConversationIdKey}from"#context/keys.js";import{readConversationId}from"#shared/conversation-identity.js";import{readActionTraceContext,readTurnTraceContext}from"#tracing/agent-trace-context-store.js";function resolveToolCallAgentTrace(e){let{serializedContext:t,sessionId:n,turnId:r}=e;return toChildTraceDispatch({conversation:e.conversation,conversationId:readConversationId(t[ConversationIdKey.name]),stored:readActionTraceContext(t,n,r,e.callId)??readTurnTraceContext(t,n,r)})}function toChildTraceDispatch(e){let{stored:t}=e,n=e.conversation?.audience??`unknown`,r=e.conversation?.environment??`production`,i=readForwardedTraceAssertion(t?.forwardedTracePolicy),a=t?.decision===void 0?t:{...t,decision:applyLiveDeliveryAudienceCeiling(t.decision,n,i,r)};return{conversationId:e.conversationId,originAudience:i?.originAudience??n,parentTraceContext:a}}export{resolveToolCallAgentTrace};
@@ -24,7 +24,5 @@ export declare function genAiMemoryRecordsAttribute(records: readonly unknown[])
24
24
  * instead of cutting the JSON mid-string.
25
25
  */
26
26
  export declare function toolResultsContentAttribute(results: readonly Record<string, unknown>[]): string | undefined;
27
- /** Normalizes the AI SDK's `instructions` prompt to plain text for `ai.prompt.system`. */
28
- export declare function systemPromptAttribute(instructions: unknown): string | undefined;
29
27
  /** Caps plain text, marking the cut. */
30
28
  export declare function textContentAttribute(text: string): string | undefined;
@@ -1,4 +1,4 @@
1
- import{isUserMessageKind}from"#harness/messages.js";const CONTENT_ATTRIBUTE_LIMIT=32768;function contentAttribute(e){if(e===void 0)return;let t;try{t=JSON.stringify(e)}catch{return}if(t!==void 0)return textContentAttribute(t)}function genAiInputMessagesAttribute(e){if(!Array.isArray(e))return;let t=e.flatMap(e=>{if(!isRecord(e)||e.role===`system`||typeof e.role!=`string`)return[];let t=semanticParts(e.content);if(t.length===0)return[];let n=e.role===`user`&&isUserMessageKind(e.kind)?e.kind:void 0;return[n===void 0?{parts:t,role:e.role}:{kind:n,parts:t,role:e.role}]});for(let e=0;e<t.length;e+=1){let n=semanticJsonAttribute(t.slice(e));if(n!==void 0)return n}return truncateSingleSemanticMessage(t)??semanticJsonAttribute([])}function genAiSystemInstructionsAttribute(e){let t=systemPromptAttribute(e);return t===void 0?void 0:semanticJsonAttribute([{content:t,type:`text`}])}function genAiOutputMessagesAttribute(e,t){let n=semanticParts(e);return semanticJsonAttribute([{finish_reason:t===`tool-calls`?`tool_call`:t,parts:n,role:`assistant`}])}function genAiMemoryRecordsAttribute(e){return semanticJsonAttribute(e)}function toolResultsContentAttribute(e){if(e.length===0)return;let t=stringifyContent(e);if(t!==void 0&&t.length<=32768)return t;for(let t=CONTENT_ATTRIBUTE_LIMIT;t>=0;t=t>=256?Math.floor(t/2):-1){let n=stringifyContent(e.map(e=>cappedToolResult(e,t)));if(n!==void 0&&n.length<=32768)return n}}function cappedToolResult(e,t){let n={toolName:e.toolName};for(let r of[`input`,`output`,`error`]){if(!(r in e))continue;let i=e[r],a=typeof i==`string`?i:stringifyContent(i)??``;n[r]=a.length<=t?a:`${a.slice(0,t)}… [truncated]`}return n}function systemPromptAttribute(e){if(typeof e==`string`)return textContentAttribute(e);if(!isRecord(e)&&!Array.isArray(e))return;let t=Array.isArray(e)?e:[e],n=[];for(let e of t)if(isRecord(e)){if(typeof e.content==`string`)n.push(e.content);else if(Array.isArray(e.content))for(let t of e.content)isRecord(t)&&t.type===`text`&&typeof t.text==`string`&&n.push(t.text)}let r=n.join(`
1
+ import{isUserMessageKind}from"#harness/messages.js";const CONTENT_ATTRIBUTE_LIMIT=32768;function contentAttribute(e){if(e===void 0)return;let t;try{t=JSON.stringify(e)}catch{return}if(t!==void 0)return textContentAttribute(t)}function genAiInputMessagesAttribute(e){if(!Array.isArray(e))return;let t=e.flatMap(e=>{if(!isRecord(e)||e.role===`system`||typeof e.role!=`string`)return[];let t=semanticParts(e.content);if(t.length===0)return[];let n=e.role===`user`&&isUserMessageKind(e.kind)?e.kind:void 0;return[n===void 0?{parts:t,role:e.role}:{kind:n,parts:t,role:e.role}]});for(let e=0;e<t.length;e+=1){let n=semanticJsonAttribute(t.slice(e));if(n!==void 0)return n}return truncateSingleSemanticMessage(t)??semanticJsonAttribute([])}function genAiSystemInstructionsAttribute(e){let t=systemPromptText(e);if(t!==void 0)return fitSemanticText(t,e=>[{content:e,type:`text`}])}function genAiOutputMessagesAttribute(e,t){let n=semanticParts(e);return semanticJsonAttribute([{finish_reason:t===`tool-calls`?`tool_call`:t,parts:n,role:`assistant`}])}function genAiMemoryRecordsAttribute(e){return semanticJsonAttribute(e)}function toolResultsContentAttribute(e){if(e.length===0)return;let t=stringifyContent(e);if(t!==void 0&&t.length<=32768)return t;for(let t=CONTENT_ATTRIBUTE_LIMIT;t>=0;t=t>=256?Math.floor(t/2):-1){let n=stringifyContent(e.map(e=>cappedToolResult(e,t)));if(n!==void 0&&n.length<=32768)return n}}function cappedToolResult(e,t){let n={toolName:e.toolName};for(let r of[`input`,`output`,`error`]){if(!(r in e))continue;let i=e[r],a=typeof i==`string`?i:stringifyContent(i)??``;n[r]=a.length<=t?a:`${a.slice(0,t)}… [truncated]`}return n}function systemPromptText(e){if(typeof e==`string`)return e.length===0?void 0:e;if(!isRecord(e)&&!Array.isArray(e))return;let t=Array.isArray(e)?e:[e],n=[];for(let e of t)if(isRecord(e)){if(typeof e.content==`string`)n.push(e.content);else if(Array.isArray(e.content))for(let t of e.content)isRecord(t)&&t.type===`text`&&typeof t.text==`string`&&n.push(t.text)}let r=n.join(`
2
2
 
3
- `).trim();return r.length===0?void 0:textContentAttribute(r)}function textContentAttribute(e){if(e.length!==0)return e.length<=32768?e:`${e.slice(0,CONTENT_ATTRIBUTE_LIMIT)}… [truncated]`}function stringifyContent(e){try{return JSON.stringify(e)}catch{return}}function semanticJsonAttribute(e){let t=stringifyContent(e);return t!==void 0&&t.length<=32768?t:void 0}function truncateSingleSemanticMessage(e){let t=e.at(-1);if(t===void 0||typeof t.role!=`string`)return;let n=semanticMessageText(t.parts),r=typeof t.kind==`string`?{kind:t.kind,role:t.role}:{role:t.role};for(let e=Math.min(n.length,CONTENT_ATTRIBUTE_LIMIT);e>0;e-=256){let t=semanticJsonAttribute([{...r,parts:[{content:`${n.slice(0,e)}… [truncated]`,type:`text`}]}]);if(t!==void 0)return t}return semanticJsonAttribute([{...r,parts:[{content:`… [truncated]`,type:`text`}]}])}function semanticMessageText(e){if(!Array.isArray(e))return``;let t=``;for(let n of e){if(!isRecord(n)||n.type!==`text`||typeof n.content!=`string`)continue;let e=t.length===0?``:`
4
- `,r=32769-t.length-e.length;if(r<=0)break;t+=e+n.content.slice(0,r)}return t}function semanticParts(e){if(typeof e==`string`)return[{content:e,type:`text`}];if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=semanticPart(n);e!==void 0&&t.push(e)}return t}function semanticPart(e){if(isRecord(e)&&typeof e.type==`string`)switch(e.type){case`text`:case`reasoning`:{let t=typeof e.text==`string`?e.text:e.content;return typeof t==`string`?{content:t,type:e.type}:void 0}case`tool-call`:return{arguments:e.input,id:stringValue(e.toolCallId)??stringValue(e.callId)??null,name:e.toolName,type:`tool_call`};case`tool-result`:return{id:stringValue(e.toolCallId)??stringValue(e.callId)??null,response:toolResponse(e.output),type:`tool_call_response`};case`tool-error`:return{id:stringValue(e.toolCallId)??stringValue(e.callId)??null,response:e.error instanceof Error?e.error.message:e.error,type:`tool_call_response`};default:return{type:e.type}}}function toolResponse(e){return isRecord(e)?(e.type===`text`||e.type===`error-text`||e.type===`json`||e.type===`error-json`)&&`value`in e?e.value:e.type===`execution-denied`?{denied:!0,reason:e.reason}:e:e}function stringValue(e){return typeof e==`string`?e:void 0}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{CONTENT_ATTRIBUTE_LIMIT,contentAttribute,genAiInputMessagesAttribute,genAiMemoryRecordsAttribute,genAiOutputMessagesAttribute,genAiSystemInstructionsAttribute,systemPromptAttribute,textContentAttribute,toolResultsContentAttribute};
3
+ `).trim();return r.length===0?void 0:r}function textContentAttribute(e){if(e.length!==0)return e.length<=32768?e:`${e.slice(0,CONTENT_ATTRIBUTE_LIMIT)}… [truncated]`}function stringifyContent(e){try{return JSON.stringify(e)}catch{return}}function semanticJsonAttribute(e){let t=stringifyContent(e);return t!==void 0&&t.length<=32768?t:void 0}function truncateSingleSemanticMessage(e){let t=e.at(-1);if(t===void 0||typeof t.role!=`string`)return;let n=semanticMessageText(t.parts),r=typeof t.kind==`string`?{kind:t.kind,role:t.role}:{role:t.role};return fitSemanticText(n,e=>[{...r,parts:[{content:e,type:`text`}]}],!0)}function fitSemanticText(e,t,n=!1){if(!n&&e.length<=32768){let n=semanticJsonAttribute(t(e));if(n!==void 0)return n}for(let n=Math.min(e.length,CONTENT_ATTRIBUTE_LIMIT);n>0;n-=256){let r=semanticJsonAttribute(t(`${e.slice(0,n)}… [truncated]`));if(r!==void 0)return r}return semanticJsonAttribute(t(`… [truncated]`))}function semanticMessageText(e){if(!Array.isArray(e))return``;let t=``;for(let n of e){if(!isRecord(n)||n.type!==`text`||typeof n.content!=`string`)continue;let e=t.length===0?``:`
4
+ `,r=32769-t.length-e.length;if(r<=0)break;t+=e+n.content.slice(0,r)}return t}function semanticParts(e){if(typeof e==`string`)return[{content:e,type:`text`}];if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=semanticPart(n);e!==void 0&&t.push(e)}return t}function semanticPart(e){if(isRecord(e)&&typeof e.type==`string`)switch(e.type){case`text`:case`reasoning`:{let t=typeof e.text==`string`?e.text:e.content;return typeof t==`string`?{content:t,type:e.type}:void 0}case`tool-call`:return{arguments:e.input,id:stringValue(e.toolCallId)??stringValue(e.callId)??null,name:e.toolName,type:`tool_call`};case`tool-result`:return{id:stringValue(e.toolCallId)??stringValue(e.callId)??null,response:toolResponse(e.output),type:`tool_call_response`};case`tool-error`:return{id:stringValue(e.toolCallId)??stringValue(e.callId)??null,response:e.error instanceof Error?e.error.message:e.error,type:`tool_call_response`};default:return{type:e.type}}}function toolResponse(e){return isRecord(e)?(e.type===`text`||e.type===`error-text`||e.type===`json`||e.type===`error-json`)&&`value`in e?e.value:e.type===`execution-denied`?{denied:!0,reason:e.reason}:e:e}function stringValue(e){return typeof e==`string`?e:void 0}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{CONTENT_ATTRIBUTE_LIMIT,contentAttribute,genAiInputMessagesAttribute,genAiMemoryRecordsAttribute,genAiOutputMessagesAttribute,genAiSystemInstructionsAttribute,textContentAttribute,toolResultsContentAttribute};
@@ -1,2 +1,2 @@
1
- import{normalizeChannelAudience}from"#shared/channel-audience.js";import{applyLiveDeliveryAudienceCeiling,resolveForwardedTraceSeed}from"#shared/forwarded-trace-policy.js";import{contextStorage}from"#context/container.js";import{SessionTraceSeedKey}from"#context/keys.js";import{AGENT_SPAN_NAMES,agentInvocationSpanName,modelSpanName}from"#tracing/agent-span-contract.js";import{resolveInstrumentationEnvironment}from"#internal/application/dev-environment.js";import{isSampledTrace,resolveTracePolicyDecision}from"#tracing/sampled-trace.js";import{ROOT_CONTEXT,SpanKind,context,trace}from"#compiled/@opentelemetry/api/index.js";import{markAgentTraceContext}from"#tracing/agent-trace-context.js";import{attemptIdempotencyKey}from"#instrumentation/lifecycle.js";import{withoutInstrumentationContent}from"#instrumentation/content.js";import{withErrorContent}from"#tracing/error-content-context.js";import{readInstrumentationDecision}from"#shared/instrumentation-decision.js";import{agentSpanNamingAttributes}from"#tracing/agent-span-naming.js";import{contentAttribute,genAiInputMessagesAttribute,genAiOutputMessagesAttribute,genAiSystemInstructionsAttribute,systemPromptAttribute,textContentAttribute,toolResultsContentAttribute}from"#tracing/agent-otel-content.js";import{recordAgentSpanError}from"#tracing/agent-span-error.js";import{withAgentToolContentPolicy}from"#tracing/agent-tool-span-context.js";import{agentTraceIdentityAttributes}from"#tracing/agent-otel-attributes.js";import{readGatewayCost,setAgentInvocationUsage,setAgentUsage,setGenAiUsage}from"#tracing/agent-otel-usage.js";import{withChannelAudience}from"#tracing/channel-audience-context.js";import{suppressTracing}from"#tracing/suppress-tracing.js";import{instrumentationEventForTraceDecision}from"#instrumentation/content-policy.js";import{createAgentActionInstrumentation}from"#tracing/agent-action-instrumentation.js";import{createAgentApprovalInstrumentation}from"#tracing/agent-approval-instrumentation.js";import{createAgentChannelDeliveryInstrumentation}from"#tracing/agent-channel-delivery-instrumentation.js";import{createAgentToolInstrumentation}from"#tracing/agent-tool-instrumentation.js";import*as runtimeAttributes from"#tracing/agent-otel-runtime-context.js";import{createAgentMemoryInstrumentation}from"#tracing/agent-memory-instrumentation.js";import{createAgentOtelSessionContext}from"#tracing/agent-otel-session-context.js";function createAgentOtelInstrumentation(e){let t=e.environment??resolveInstrumentationEnvironment(),n=e.recordInputs??!1,r=e.recordOutputs??!1,i=new WeakMap,a=new Map,o=new WeakMap,s=new WeakMap,c=createAgentActionInstrumentation({frameworkVersion:e.frameworkVersion,idGenerator:e.idGenerator,recordInputs:n,recordOutputs:r,resolveTraceContext:async t=>(await e.stateStore.getTurn(t.scope.sessionId,t.scope.turnId))?.context,stateStore:e.stateStore,tracer:e.tracer}),l=createAgentApprovalInstrumentation({actionContextFor:c.contextFor,frameworkVersion:e.frameworkVersion,idGenerator:e.idGenerator,tracer:e.tracer}),u=createAgentToolInstrumentation({actionContextFor:c.contextFor,idGenerator:e.idGenerator,recordInputs:n,recordOutputs:r,resolveFallback:e=>{let t=a.get(e.scope.attemptId)??e.scope,n=o.get(t);return n===void 0?void 0:{context:n.context,spanContext:n.span.spanContext()}},tracer:e.tracer}),d=createAgentMemoryInstrumentation({...e,environment:t}),{prepareSessionTrace:f,prepareTurnTrace:p}=createAgentOtelSessionContext({...e,environment:t}),projectEvent=async i=>{let a=await e.stateStore.getSession(sessionIdForEvent(i)),o=audienceForEvent(i,a?.channelAudience),s=`traceSeed`in i?i.traceSeed:void 0,c=contextStorage.getStore()?.get(SessionTraceSeedKey),l=resolveForwardedTraceSeed(c),u=resolveForwardedTraceSeed(s,l?.forwardedTracePolicy),decisionForTrace=e=>e===void 0?void 0:resolveTracePolicyDecision(isSampledTrace(e),{audience:o,environment:t}),d=u?.decision??l?.decision??readInstrumentationDecision(a?.decision)??decisionForTrace(s)??decisionForTrace(c)??decisionForTrace(a?.context);if(d===void 0)return withoutInstrumentationContent(i);let f=u===void 0||!(`traceSeed`in i)||i.traceSeed===void 0?i:{...i,traceSeed:{...i.traceSeed,decision:u.decision,traceFlags:u.traceFlags}};return instrumentationEventForTraceDecision(f,applyLiveDeliveryAudienceCeiling(d.action===`drop`?d:{action:`record`,recordInputs:n&&d.recordInputs,recordOutputs:r&&d.recordOutputs},o,u?.forwardedTracePolicy??l?.forwardedTracePolicy,t),{audience:o,environment:t},{applyAudienceCeiling:!1})},onSessionStarted=async e=>{await f(e)},onTurnStarted=async e=>{await p(e)},onStepStarted=async t=>{let n=await e.stateStore.getTurn(t.scope.sessionId,t.scope.turnId);if(n===void 0||!isSampledTrace(n.context))return;let r=withChannelAudience(contextFromSpanContext(n.context),t.scope.channelAudience),i=trace.getSpan(context.active())?.spanContext(),s=e.idGenerator.withSpanId(e.idGenerator.deriveSpanId(attemptIdempotencyKey(t.scope)),()=>e.tracer.startSpan(AGENT_SPAN_NAMES.step,{attributes:{"agent.framework.name":`eve`,"agent.framework.version":e.frameworkVersion,"agent.step.attempt":t.scope.attemptIndex,"agent.step.index":t.scope.stepIndex,"agent.turn.id":t.scope.turnId,"agent.name":t.scope.functionId,...agentSpanNamingAttributes(`agent.step`),...agentTraceIdentityAttributes({rootSessionId:t.scope.rootSessionId??t.scope.sessionId,sessionId:t.scope.sessionId}),...runtimeAttributes.runtimeContextAttributes(t.runtimeContext)},links:i===void 0||i.traceId===n.context.traceId?void 0:[{attributes:{"eve.link.type":`workflow.delivery`},context:i}]},r));s.addEvent(`step.started`);let c=trace.setSpan(r,s);o.set(t.scope,{context:c,span:s}),a.set(t.scope.attemptId,t.scope)},onStepTerminal=async e=>{let t=a.get(e.scope.attemptId)??e.scope;i.delete(t),drainOpenSpans({...e,scope:t}),u.drain(e.scope.attemptId,e.type===`step.attempt.failed`?{error:e.error}:void 0),e.type===`step.attempt.failed`&&await c.failForAttempt(t,e.error),a.delete(e.scope.attemptId);let n=o.get(t);n!==void 0&&(n.span.addEvent(e.type===`step.attempt.completed`?`step.completed`:`step.failed`),e.type===`step.attempt.failed`&&recordAgentSpanError(n.span,e.error),n.span.end(),o.delete(t))},onTurnTerminal=async t=>{await e.stateStore.updateTurn(t.sessionId,t.turnId,e=>({...e,terminal:t.type===`turn.failed`?{error:t.error,type:t.type}:{type:t.type}}))},onSessionTransition=async t=>{if(await c.flushForSessionTransition(t),t.type===`session.failed`&&t.turnId!==void 0&&await e.stateStore.updateTurn(t.sessionId,t.turnId,e=>({...e,terminal:e.terminal??{error:t.error,type:`turn.failed`}})),t.turnId!==void 0){let n=await e.stateStore.getTurn(t.sessionId,t.turnId);if(n!==void 0){let r=await e.stateStore.getSession(t.sessionId);if(isSampledTrace(n.context)){let i=r?.agentName??n.subagentName,a=withChannelAudience(ROOT_CONTEXT,r?.channelAudience),startSpan=()=>e.tracer.startSpan(agentInvocationSpanName(i),{attributes:runtimeAttributes.agentActivationAttributes({agentName:i,frameworkVersion:e.frameworkVersion,session:r,sessionId:t.sessionId,turnId:t.turnId,turn:n}),kind:SpanKind.INTERNAL,links:agentActivationLinks(n),root:!0,startTime:n.startTimeMs},a),o=e.idGenerator.withSpanId(n.context.spanId,()=>e.idGenerator.withTraceId(n.context.traceId,startSpan));setAgentInvocationUsage(o,n.modelUsage),o.addEvent(`turn.started`,void 0,n.startTimeMs),n.terminal!==void 0&&(o.setAttribute(`agent.turn.outcome`,n.terminal.type===`turn.completed`?`completed`:n.terminal.type===`turn.cancelled`?`cancelled`:`failed`),o.addEvent(n.terminal.type),n.terminal.type===`turn.failed`&&recordAgentSpanError(o,n.terminal.error)),o.end()}await e.stateStore.deleteTurn(t.sessionId,t.turnId)}}(t.type===`session.completed`||t.type===`session.failed`)&&(await c.deleteForSession(t.sessionId),await e.stateStore.deleteSession(t.sessionId))},onModelCallStarted=t=>{let r=o.get(t.scope);if(r===void 0)return;r.span.setAttribute(`agent.model.id`,t.model.modelId),r.span.setAttribute(`agent.model.provider`,t.model.provider);let i=e.tracer.startSpan(modelSpanName(t.model.modelId),{attributes:{"gen_ai.agent.name":t.scope.functionId,"gen_ai.operation.name":`chat`,"gen_ai.provider.name":t.model.provider,"gen_ai.request.model":t.model.modelId,...agentSpanNamingAttributes(modelSpanName(t.model.modelId),`chat`),...agentTraceIdentityAttributes({rootSessionId:t.scope.rootSessionId??t.scope.sessionId,sessionId:t.scope.sessionId}),...runtimeAttributes.runtimeContextAttributes(t.runtimeContext)},kind:SpanKind.CLIENT},r.context);if(n&&t.input!==void 0){let e=genAiInputMessagesAttribute(t.input.messages);e!==void 0&&i.setAttribute(`gen_ai.input.messages`,e);let n=systemPromptAttribute(t.input.instructions);n!==void 0&&i.setAttribute(`ai.prompt.system`,n);let r=genAiSystemInstructionsAttribute(t.input.instructions);r!==void 0&&i.setAttribute(`gen_ai.system_instructions`,r)}let a={context:trace.setSpan(r.context,i),span:i};getExecutionContexts(t.scope).set(t.idempotencyKey,a.context),getSpanStates(s,t.scope).set(t.idempotencyKey,a)},onModelCallTerminal=async e=>{i.get(e.scope)?.delete(e.idempotencyKey);let t=takeSpanState(s,e.scope,e.idempotencyKey);if(t!==void 0){if(e.type===`model.call.failed`)recordAgentSpanError(t.span,e.error);else{await recordTurnUsage(e),setGenAiUsage(t.span,e.usage),e.responseId!==void 0&&t.span.setAttribute(`gen_ai.response.id`,e.responseId),e.responseModelId!==void 0&&t.span.setAttribute(`gen_ai.response.model`,e.responseModelId),t.span.setAttribute(`gen_ai.response.finish_reasons`,[e.finishReason]);let n=o.get(e.scope);if(n!==void 0&&setAgentUsage(n.span,e.usage),r){t.span.setAttribute(`ai.response.finish_reason`,e.finishReason);let n=e.content;if(n===void 0){t.span.end();return}let r=genAiOutputMessagesAttribute(n,e.finishReason);r!==void 0&&t.span.setAttribute(`gen_ai.output.messages`,r);let i=textContentAttribute(n.filter(e=>e.type===`reasoning`).map(e=>e.text).filter(e=>e.trim().length>0).join(`
2
- `));i!==void 0&&t.span.setAttribute(`ai.response.reasoning`,i);let a=textContentAttribute(n.filter(e=>e.type===`text`).map(e=>e.text).join(``));a!==void 0&&t.span.setAttribute(`ai.response.text`,a);let o=n.filter(e=>e.type===`tool-call`).map(e=>({callId:e.callId,input:e.input,toolName:e.toolName}));if(o.length>0){let e=contentAttribute(o);e!==void 0&&t.span.setAttribute(`ai.response.tool_calls`,e)}let s=n.filter(e=>e.type===`tool-result`||e.type===`tool-error`).map(e=>e.type===`tool-result`?{callId:e.callId,input:e.input,output:e.output,toolName:e.toolName}:{callId:e.callId,error:errorText(e.error),input:e.input,toolName:e.toolName});if(s.length>0){let e=toolResultsContentAttribute(s);e!==void 0&&t.span.setAttribute(`ai.response.tool_results`,e)}}}t.span.end()}},recordTurnUsage=async t=>{(t.usage.inputTokens!==void 0||t.usage.outputTokens!==void 0)&&await e.stateStore.updateTurn(t.scope.sessionId,t.scope.turnId,e=>({...e,modelUsage:{inputTokens:t.usage.inputTokens===void 0?e.modelUsage?.inputTokens:(e.modelUsage?.inputTokens??0)+t.usage.inputTokens,outputTokens:t.usage.outputTokens===void 0?e.modelUsage?.outputTokens:(e.modelUsage?.outputTokens??0)+t.usage.outputTokens}}))},m=createAgentChannelDeliveryInstrumentation({recordInputs:n,stateStore:e.stateStore}),onStepMetadata=e=>{let t=o.get(e.scope);if(t===void 0)return;let n=readGatewayCost(e.providerMetadata);if(n!==void 0)for(let[e,r]of Object.entries(n))t.span.setAttribute(e,r)};return{hook:{flush:c.flushSettledInvocations,events:{...m,"action.completed":c.events[`action.completed`],"action.failed":c.events[`action.failed`],async"action.started"(e,t){await c.events[`action.started`](e,t),await u.actionStarted(e)},...l,...d.events,"step.attempt.completed":onStepTerminal,"step.attempt.failed":onStepTerminal,"step.attempt.metadata":onStepMetadata,"step.attempt.started":onStepStarted,"model.call.completed":onModelCallTerminal,"model.call.failed":onModelCallTerminal,"model.call.started":onModelCallStarted,"session.completed":onSessionTransition,"session.failed":onSessionTransition,"session.started":onSessionStarted,"session.waiting":onSessionTransition,...u.events,"turn.cancelled":onTurnTerminal,"turn.completed":onTurnTerminal,"turn.failed":onTurnTerminal,"turn.started":onTurnStarted},name:`eve.otel`,projectEvent,tracePolicy:()=>({emit:!0,recordInputs:n,recordOutputs:r})},prepareSessionTrace:f,prepareTurnTrace:p,async runInContext(o,s){if(o.type===`memory.operation`)return d.runInContext(o,s);let c=a.get(o.scope.attemptId)??o.scope,l=i.get(c),f=o.type===`model.call`?l?.get(o.idempotencyKey):u.contextFor(o.scope.attemptId,o.idempotencyKey);if(f===void 0){let t=await e.stateStore.getTurn(o.scope.sessionId,o.scope.turnId);t!==void 0&&(f=withChannelAudience(contextFromSpanContext(t.context),o.scope.channelAudience),isSampledTrace(t.context)||(f=suppressTracing(f)))}let p=await e.stateStore.getSession(o.scope.sessionId),m=resolveForwardedTraceSeed(contextStorage.getStore()?.get(SessionTraceSeedKey)),h=m?.decision??p?.decision,g=h===void 0?void 0:applyLiveDeliveryAudienceCeiling(h,normalizeChannelAudience(o.scope.channelAudience),m?.forwardedTracePolicy,t),_={recordInputs:n&&g?.action===`record`&&g.recordInputs,recordOutputs:r&&g?.action===`record`&&g.recordOutputs};if(f===void 0)return s();let v=withErrorContent(f,_.recordOutputs),y=o.type===`tool.call`?withAgentToolContentPolicy(v,_):v;return context.with(markAgentTraceContext(y),s)}};function getExecutionContexts(e){let t=i.get(e);return t===void 0&&(t=new Map,i.set(e,t)),t}function drainOpenSpans(e){for(let t of s.get(e.scope)?.values()??[])e.type===`step.attempt.failed`&&recordAgentSpanError(t.span,e.error),t.span.end();s.delete(e.scope)}}function agentActivationLinks(e){let t=[];return e.caller!==void 0&&t.push({context:e.caller,attributes:{"eve.link.type":`agent.dispatch`}}),e.channelDelivery?.requestTraceContext!==void 0&&t.push({context:e.channelDelivery.requestTraceContext,attributes:{"eve.link.type":`channel.request`}}),t.length===0?void 0:t}function sessionIdForEvent(e){return`scope`in e?e.scope.sessionId:e.sessionId}function audienceForEvent(e,t){return`delivery`in e?normalizeChannelAudience(e.delivery.channelAudience):`scope`in e&&e.scope.channelAudience!==void 0?normalizeChannelAudience(e.scope.channelAudience):e.type===`session.started`?normalizeChannelAudience(e.channelAudience):normalizeChannelAudience(t)}function getSpanStates(e,t){let n=e.get(t);return n===void 0&&(n=new Map,e.set(t,n)),n}function takeSpanState(e,t,n){let r=e.get(t),i=r?.get(n);if(r!==void 0)return r.delete(n),r.size===0&&e.delete(t),i}function contextFromSpanContext(e){return trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext(e))}const errorText=e=>e instanceof Error?e.message:e;export{createAgentOtelInstrumentation};
1
+ import{normalizeChannelAudience}from"#shared/channel-audience.js";import{applyLiveDeliveryAudienceCeiling,resolveForwardedTraceSeed}from"#shared/forwarded-trace-policy.js";import{contextStorage}from"#context/container.js";import{SessionTraceSeedKey}from"#context/keys.js";import{AGENT_SPAN_NAMES,agentInvocationSpanName,modelSpanName}from"#tracing/agent-span-contract.js";import{resolveInstrumentationEnvironment}from"#internal/application/dev-environment.js";import{isSampledTrace,resolveTracePolicyDecision}from"#tracing/sampled-trace.js";import{ROOT_CONTEXT,SpanKind,context,trace}from"#compiled/@opentelemetry/api/index.js";import{markAgentTraceContext}from"#tracing/agent-trace-context.js";import{attemptIdempotencyKey}from"#instrumentation/lifecycle.js";import{withoutInstrumentationContent}from"#instrumentation/content.js";import{withErrorContent}from"#tracing/error-content-context.js";import{readInstrumentationDecision}from"#shared/instrumentation-decision.js";import{agentSpanNamingAttributes}from"#tracing/agent-span-naming.js";import{contentAttribute,genAiInputMessagesAttribute,genAiOutputMessagesAttribute,genAiSystemInstructionsAttribute,textContentAttribute,toolResultsContentAttribute}from"#tracing/agent-otel-content.js";import{recordAgentSpanError}from"#tracing/agent-span-error.js";import{withAgentToolContentPolicy}from"#tracing/agent-tool-span-context.js";import{agentTraceIdentityAttributes}from"#tracing/agent-otel-attributes.js";import{readGatewayCost,setAgentInvocationUsage,setAgentUsage,setGenAiUsage}from"#tracing/agent-otel-usage.js";import{withChannelAudience}from"#tracing/channel-audience-context.js";import{suppressTracing}from"#tracing/suppress-tracing.js";import{instrumentationEventForTraceDecision}from"#instrumentation/content-policy.js";import{createAgentActionInstrumentation}from"#tracing/agent-action-instrumentation.js";import{createAgentApprovalInstrumentation}from"#tracing/agent-approval-instrumentation.js";import{createAgentChannelDeliveryInstrumentation}from"#tracing/agent-channel-delivery-instrumentation.js";import{createAgentToolInstrumentation}from"#tracing/agent-tool-instrumentation.js";import*as runtimeAttributes from"#tracing/agent-otel-runtime-context.js";import{createAgentMemoryInstrumentation}from"#tracing/agent-memory-instrumentation.js";import{createAgentOtelSessionContext}from"#tracing/agent-otel-session-context.js";function createAgentOtelInstrumentation(e){let t=e.environment??resolveInstrumentationEnvironment(),n=e.recordInputs??!1,r=e.recordOutputs??!1,i=new WeakMap,a=new Map,o=new WeakMap,s=new WeakMap,c=createAgentActionInstrumentation({frameworkVersion:e.frameworkVersion,idGenerator:e.idGenerator,recordInputs:n,recordOutputs:r,resolveTraceContext:async t=>(await e.stateStore.getTurn(t.scope.sessionId,t.scope.turnId))?.context,stateStore:e.stateStore,tracer:e.tracer}),l=createAgentApprovalInstrumentation({actionContextFor:c.contextFor,frameworkVersion:e.frameworkVersion,idGenerator:e.idGenerator,tracer:e.tracer}),u=createAgentToolInstrumentation({actionContextFor:c.contextFor,idGenerator:e.idGenerator,recordInputs:n,recordOutputs:r,resolveFallback:e=>{let t=a.get(e.scope.attemptId)??e.scope,n=o.get(t);return n===void 0?void 0:{context:n.context,spanContext:n.span.spanContext()}},tracer:e.tracer}),d=createAgentMemoryInstrumentation({...e,environment:t}),{prepareSessionTrace:f,prepareTurnTrace:p}=createAgentOtelSessionContext({...e,environment:t}),projectEvent=async i=>{let a=await e.stateStore.getSession(sessionIdForEvent(i)),o=audienceForEvent(i,a?.channelAudience),s=`traceSeed`in i?i.traceSeed:void 0,c=contextStorage.getStore()?.get(SessionTraceSeedKey),l=resolveForwardedTraceSeed(c),u=resolveForwardedTraceSeed(s,l?.forwardedTracePolicy),decisionForTrace=e=>e===void 0?void 0:resolveTracePolicyDecision(isSampledTrace(e),{audience:o,environment:t}),d=u?.decision??l?.decision??readInstrumentationDecision(a?.decision)??decisionForTrace(s)??decisionForTrace(c)??decisionForTrace(a?.context);if(d===void 0)return withoutInstrumentationContent(i);let f=u===void 0||!(`traceSeed`in i)||i.traceSeed===void 0?i:{...i,traceSeed:{...i.traceSeed,decision:u.decision,traceFlags:u.traceFlags}};return instrumentationEventForTraceDecision(f,applyLiveDeliveryAudienceCeiling(d.action===`drop`?d:{action:`record`,recordInputs:n&&d.recordInputs,recordOutputs:r&&d.recordOutputs},o,u?.forwardedTracePolicy??l?.forwardedTracePolicy,t),{audience:o,environment:t},{applyAudienceCeiling:!1})},onSessionStarted=async e=>{await f(e)},onTurnStarted=async e=>{await p(e)},onStepStarted=async t=>{let n=await e.stateStore.getTurn(t.scope.sessionId,t.scope.turnId);if(n===void 0||!isSampledTrace(n.context))return;let r=await e.stateStore.getSession(t.scope.sessionId),i=withChannelAudience(contextFromSpanContext(n.context),t.scope.channelAudience),s=trace.getSpan(context.active())?.spanContext(),c=e.idGenerator.withSpanId(e.idGenerator.deriveSpanId(attemptIdempotencyKey(t.scope)),()=>e.tracer.startSpan(AGENT_SPAN_NAMES.step,{attributes:runtimeAttributes.agentStepAttributes({event:t,frameworkVersion:e.frameworkVersion,session:r,turn:n}),links:s===void 0||s.traceId===n.context.traceId?void 0:[{attributes:{"eve.link.type":`workflow.delivery`},context:s}]},i));c.addEvent(`step.started`);let l=trace.setSpan(i,c);o.set(t.scope,{context:l,span:c}),a.set(t.scope.attemptId,t.scope)},onStepTerminal=async e=>{let t=a.get(e.scope.attemptId)??e.scope;i.delete(t),drainOpenSpans({...e,scope:t}),u.drain(e.scope.attemptId,e.type===`step.attempt.failed`?{error:e.error}:void 0),e.type===`step.attempt.failed`&&await c.failForAttempt(t,e.error),a.delete(e.scope.attemptId);let n=o.get(t);n!==void 0&&(n.span.addEvent(e.type===`step.attempt.completed`?`step.completed`:`step.failed`),e.type===`step.attempt.failed`&&recordAgentSpanError(n.span,e.error),n.span.end(),o.delete(t))},onTurnTerminal=async t=>{await e.stateStore.updateTurn(t.sessionId,t.turnId,e=>({...e,terminal:t.type===`turn.failed`?{error:t.error,type:t.type}:{type:t.type}}))},onSessionTransition=async t=>{if(t.type===`session.failed`&&t.turnId!==void 0&&await e.stateStore.updateTurn(t.sessionId,t.turnId,e=>({...e,terminal:e.terminal??{error:t.error,type:`turn.failed`}})),t.turnId!==void 0){let n=await e.stateStore.getTurn(t.sessionId,t.turnId);if(n!==void 0){let r=await e.stateStore.getSession(t.sessionId);if(isSampledTrace(n.context)){let i=r?.agentName??n.subagentName,a=withChannelAudience(ROOT_CONTEXT,r?.channelAudience),startSpan=()=>e.tracer.startSpan(agentInvocationSpanName(i),{attributes:runtimeAttributes.agentActivationAttributes({agentName:i,frameworkVersion:e.frameworkVersion,session:r,sessionId:t.sessionId,turnId:t.turnId,turn:n}),kind:SpanKind.INTERNAL,links:agentActivationLinks(n),root:!0,startTime:n.startTimeMs},a),o=e.idGenerator.withSpanId(n.context.spanId,()=>e.idGenerator.withTraceId(n.context.traceId,startSpan));setAgentInvocationUsage(o,n.modelUsage),o.addEvent(`turn.started`,void 0,n.startTimeMs),n.terminal!==void 0&&(o.setAttribute(`agent.turn.outcome`,n.terminal.type===`turn.completed`?`completed`:n.terminal.type===`turn.cancelled`?`cancelled`:`failed`),o.addEvent(n.terminal.type),n.terminal.type===`turn.failed`&&recordAgentSpanError(o,n.terminal.error)),o.end()}await e.stateStore.deleteTurn(t.sessionId,t.turnId)}}(t.type===`session.completed`||t.type===`session.failed`)&&(await c.deleteForSession(t.sessionId),await e.stateStore.deleteSession(t.sessionId))},onModelCallStarted=t=>{let r=o.get(t.scope);if(r===void 0)return;r.span.setAttribute(`agent.model.id`,t.model.modelId),r.span.setAttribute(`agent.model.provider`,t.model.provider);let i=e.tracer.startSpan(modelSpanName(t.model.modelId),{attributes:{"gen_ai.agent.name":t.scope.functionId,"gen_ai.operation.name":`chat`,"gen_ai.provider.name":t.model.provider,"gen_ai.request.model":t.model.modelId,...agentSpanNamingAttributes(modelSpanName(t.model.modelId),`chat`),...agentTraceIdentityAttributes({rootSessionId:t.scope.rootSessionId??t.scope.sessionId,sessionId:t.scope.sessionId}),...runtimeAttributes.runtimeContextAttributes(t.runtimeContext)},kind:SpanKind.CLIENT},r.context);if(n&&t.input!==void 0){let e=genAiInputMessagesAttribute(t.input.messages);e!==void 0&&i.setAttribute(`gen_ai.input.messages`,e);let n=genAiSystemInstructionsAttribute(t.input.instructions);n!==void 0&&i.setAttribute(`gen_ai.system_instructions`,n)}let a={context:trace.setSpan(r.context,i),span:i};getExecutionContexts(t.scope).set(t.idempotencyKey,a.context),getSpanStates(s,t.scope).set(t.idempotencyKey,a)},onModelCallTerminal=async e=>{i.get(e.scope)?.delete(e.idempotencyKey);let t=takeSpanState(s,e.scope,e.idempotencyKey);if(t!==void 0){if(e.type===`model.call.failed`)recordAgentSpanError(t.span,e.error);else{await recordTurnUsage(e),setGenAiUsage(t.span,e.usage),e.responseId!==void 0&&t.span.setAttribute(`gen_ai.response.id`,e.responseId),e.responseModelId!==void 0&&t.span.setAttribute(`gen_ai.response.model`,e.responseModelId),t.span.setAttribute(`gen_ai.response.finish_reasons`,[e.finishReason]);let n=o.get(e.scope);if(n!==void 0&&setAgentUsage(n.span,e.usage),r){t.span.setAttribute(`ai.response.finish_reason`,e.finishReason);let n=e.content;if(n===void 0){t.span.end();return}let r=genAiOutputMessagesAttribute(n,e.finishReason);r!==void 0&&t.span.setAttribute(`gen_ai.output.messages`,r);let i=textContentAttribute(n.filter(e=>e.type===`reasoning`).map(e=>e.text).filter(e=>e.trim().length>0).join(`
2
+ `));i!==void 0&&t.span.setAttribute(`ai.response.reasoning`,i);let a=textContentAttribute(n.filter(e=>e.type===`text`).map(e=>e.text).join(``));a!==void 0&&t.span.setAttribute(`ai.response.text`,a);let o=n.filter(e=>e.type===`tool-call`).map(e=>({callId:e.callId,input:e.input,toolName:e.toolName}));if(o.length>0){let e=contentAttribute(o);e!==void 0&&t.span.setAttribute(`ai.response.tool_calls`,e)}let s=n.filter(e=>e.type===`tool-result`||e.type===`tool-error`).map(e=>e.type===`tool-result`?{callId:e.callId,input:e.input,output:e.output,toolName:e.toolName}:{callId:e.callId,error:errorText(e.error),input:e.input,toolName:e.toolName});if(s.length>0){let e=toolResultsContentAttribute(s);e!==void 0&&t.span.setAttribute(`ai.response.tool_results`,e)}}}t.span.end()}},recordTurnUsage=async t=>{(t.usage.inputTokens!==void 0||t.usage.outputTokens!==void 0)&&await e.stateStore.updateTurn(t.scope.sessionId,t.scope.turnId,e=>({...e,modelUsage:{inputTokens:t.usage.inputTokens===void 0?e.modelUsage?.inputTokens:(e.modelUsage?.inputTokens??0)+t.usage.inputTokens,outputTokens:t.usage.outputTokens===void 0?e.modelUsage?.outputTokens:(e.modelUsage?.outputTokens??0)+t.usage.outputTokens}}))},m=createAgentChannelDeliveryInstrumentation({recordInputs:n,stateStore:e.stateStore}),onStepMetadata=e=>{let t=o.get(e.scope);if(t===void 0)return;let n=readGatewayCost(e.providerMetadata);if(n!==void 0)for(let[e,r]of Object.entries(n))t.span.setAttribute(e,r)};return{hook:{events:{...m,"action.completed":c.events[`action.completed`],"action.failed":c.events[`action.failed`],async"action.started"(e,t){await c.events[`action.started`](e,t),await u.actionStarted(e)},...l,...d.events,"step.attempt.completed":onStepTerminal,"step.attempt.failed":onStepTerminal,"step.attempt.metadata":onStepMetadata,"step.attempt.started":onStepStarted,"model.call.completed":onModelCallTerminal,"model.call.failed":onModelCallTerminal,"model.call.started":onModelCallStarted,"session.completed":onSessionTransition,"session.failed":onSessionTransition,"session.started":onSessionStarted,"session.waiting":onSessionTransition,...u.events,"turn.cancelled":onTurnTerminal,"turn.completed":onTurnTerminal,"turn.failed":onTurnTerminal,"turn.started":onTurnStarted},name:`eve.otel`,projectEvent,tracePolicy:()=>({emit:!0,recordInputs:n,recordOutputs:r})},prepareSessionTrace:f,prepareTurnTrace:p,async runInContext(o,s){if(o.type===`memory.operation`)return d.runInContext(o,s);let c=a.get(o.scope.attemptId)??o.scope,l=i.get(c),f=o.type===`model.call`?l?.get(o.idempotencyKey):u.contextFor(o.scope.attemptId,o.idempotencyKey);if(f===void 0){let t=await e.stateStore.getTurn(o.scope.sessionId,o.scope.turnId);t!==void 0&&(f=withChannelAudience(contextFromSpanContext(t.context),o.scope.channelAudience),isSampledTrace(t.context)||(f=suppressTracing(f)))}let p=await e.stateStore.getSession(o.scope.sessionId),m=resolveForwardedTraceSeed(contextStorage.getStore()?.get(SessionTraceSeedKey)),h=m?.decision??p?.decision,g=h===void 0?void 0:applyLiveDeliveryAudienceCeiling(h,normalizeChannelAudience(o.scope.channelAudience),m?.forwardedTracePolicy,t),_={recordInputs:n&&g?.action===`record`&&g.recordInputs,recordOutputs:r&&g?.action===`record`&&g.recordOutputs};if(f===void 0)return s();let v=withErrorContent(f,_.recordOutputs),y=o.type===`tool.call`?withAgentToolContentPolicy(v,_):v;return context.with(markAgentTraceContext(y),s)}};function getExecutionContexts(e){let t=i.get(e);return t===void 0&&(t=new Map,i.set(e,t)),t}function drainOpenSpans(e){for(let t of s.get(e.scope)?.values()??[])e.type===`step.attempt.failed`&&recordAgentSpanError(t.span,e.error),t.span.end();s.delete(e.scope)}}function agentActivationLinks(e){let t=[];return e.caller!==void 0&&t.push({context:e.caller,attributes:{"eve.link.type":`agent.dispatch`}}),e.channelDelivery?.requestTraceContext!==void 0&&t.push({context:e.channelDelivery.requestTraceContext,attributes:{"eve.link.type":`channel.request`}}),t.length===0?void 0:t}function sessionIdForEvent(e){return`scope`in e?e.scope.sessionId:e.sessionId}function audienceForEvent(e,t){return`delivery`in e?normalizeChannelAudience(e.delivery.channelAudience):`scope`in e&&e.scope.channelAudience!==void 0?normalizeChannelAudience(e.scope.channelAudience):e.type===`session.started`?normalizeChannelAudience(e.channelAudience):normalizeChannelAudience(t)}function getSpanStates(e,t){let n=e.get(t);return n===void 0&&(n=new Map,e.set(t,n)),n}function takeSpanState(e,t,n){let r=e.get(t),i=r?.get(n);if(r!==void 0)return r.delete(n),r.size===0&&e.delete(t),i}function contextFromSpanContext(e){return trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext(e))}const errorText=e=>e instanceof Error?e.message:e;export{createAgentOtelInstrumentation};
@@ -1,4 +1,5 @@
1
1
  import type { AgentSessionTraceState, AgentTurnTraceState } from "#tracing/agent-trace-state.js";
2
+ import type { InstrumentationStepAttemptStartedEvent } from "#instrumentation/lifecycle.js";
2
3
  type SpanAttributePrimitive = string | number | boolean;
3
4
  type SpanAttributeValue = SpanAttributePrimitive | SpanAttributePrimitive[];
4
5
  export declare function agentActivationAttributes(input: {
@@ -9,6 +10,25 @@ export declare function agentActivationAttributes(input: {
9
10
  readonly turnId: string;
10
11
  readonly turn: AgentTurnTraceState;
11
12
  }): Record<string, string | number | boolean | undefined>;
13
+ export declare function agentChannelClassificationAttributes(session: AgentSessionTraceState | undefined, turn: AgentTurnTraceState): {
14
+ readonly "agent.channel.kind": string | undefined;
15
+ readonly "agent.session.origin": string | undefined;
16
+ };
17
+ export declare function agentStepAttributes(input: {
18
+ readonly event: InstrumentationStepAttemptStartedEvent;
19
+ readonly frameworkVersion: string;
20
+ readonly session?: AgentSessionTraceState;
21
+ readonly turn: AgentTurnTraceState;
22
+ }): {
23
+ "agent.channel.kind"?: string | undefined;
24
+ "agent.session.origin"?: string | undefined;
25
+ "agent.framework.name": string;
26
+ "agent.framework.version": string;
27
+ "agent.step.attempt": number;
28
+ "agent.step.index": number;
29
+ "agent.turn.id": string;
30
+ "agent.name": string | undefined;
31
+ };
12
32
  export declare function agentPrincipalAttributes(turn: AgentTurnTraceState): Record<string, string>;
13
33
  /** Flattens merged runtime context into AI SDK-compatible span attributes. */
14
34
  export declare function runtimeContextAttributes(runtimeContext: Readonly<Record<string, unknown>> | undefined): Record<string, SpanAttributeValue>;
@@ -1 +1 @@
1
- import{normalizeInstrumentationChannelKind}from"#internal/instrumentation.js";import{agentInvocationSpanName}from"#tracing/agent-span-contract.js";import{agentSpanNamingAttributes}from"#tracing/agent-span-naming.js";import{agentTraceIdentityAttributes}from"#tracing/agent-otel-attributes.js";function agentActivationAttributes(e){let t=e.session?.decision?.action===`record`,n=t&&e.session?.decision?.recordInputs===!0,r=t&&e.session?.decision?.recordOutputs===!0,i=e.turn.parentLineage??e.session?.parentLineage,a=i!==void 0,o=e.turn.channelDelivery?.channelKind??(a?void 0:e.session?.channelKind??(e.session?.channelType===void 0?void 0:normalizeInstrumentationChannelKind(e.session.channelType))),s=a?void 0:e.session?.scheduleId,c=a||o===void 0?void 0:s===void 0?`channel`:`schedule`;return{"agent.framework.name":`eve`,"agent.framework.version":e.frameworkVersion,"agent.name":e.agentName,"agent.channel.audience":e.session?.channelAudience,...agentPrincipalAttributes(e.turn),"agent.channel.delivery.id":e.turn.channelDelivery?.deliveryId,"agent.channel.delivery.input":e.turn.channelDelivery?.inputAttribute,"agent.channel.kind":o,"agent.channel.name":e.turn.channelDelivery?.channelName,"agent.channel.request.id":e.turn.channelDelivery?.requestId,"agent.parent_call.id":i?.callId,"agent.parent_run.id":i?.sessionId,"agent.run.type":a?`subagent`:`session`,"agent.schedule.id":s,"agent.session.origin":c,"agent.session.title":!a&&n?e.session?.title:void 0,"agent.subagent.name":e.turn.subagentName,"agent.trace.content.input":n,"agent.trace.content.output":r,"agent.turn.id":e.turnId,"agent.turn.sequence":e.turn.sequence,"gen_ai.agent.name":e.agentName,"gen_ai.operation.name":`invoke_agent`,...agentSpanNamingAttributes(agentInvocationSpanName(e.agentName),`invoke_agent`),...agentTraceIdentityAttributes({rootSessionId:e.turn.rootSessionId,sessionId:e.sessionId})}}function agentPrincipalAttributes(e){let t={};return setOptionalAttribute(t,`agent.principal.current.id`,e.currentPrincipal?.id),setOptionalAttribute(t,`agent.principal.current.type`,e.currentPrincipal?.type),setOptionalAttribute(t,`agent.principal.initiator.id`,e.initiatorPrincipal?.id),setOptionalAttribute(t,`agent.principal.initiator.type`,e.initiatorPrincipal?.type),t}function runtimeContextAttributes(e){let t={};if(e===void 0)return t;for(let[n,r]of Object.entries(e))flattenContextAttribute(t,`ai.settings.context.${n}`,r);return t}function flattenContextAttribute(e,t,n){if(n!=null){if(typeof n==`string`||typeof n==`number`||typeof n==`boolean`){e[t]=n;return}if(Array.isArray(n)){let r=n.filter(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`);if(r.length!==n.length||new Set(r.map(e=>typeof e)).size!==1)return;e[t]=r;return}if(typeof n==`object`)for(let[r,i]of Object.entries(n))flattenContextAttribute(e,`${t}.${r}`,i)}}function setOptionalAttribute(e,t,n){n!==void 0&&(e[t]=n)}export{agentActivationAttributes,agentPrincipalAttributes,runtimeContextAttributes};
1
+ import{normalizeInstrumentationChannelKind}from"#internal/instrumentation.js";import{agentInvocationSpanName}from"#tracing/agent-span-contract.js";import{agentSpanNamingAttributes}from"#tracing/agent-span-naming.js";import{agentTraceIdentityAttributes}from"#tracing/agent-otel-attributes.js";function agentActivationAttributes(e){let t=e.session?.decision?.action===`record`,n=t&&e.session?.decision?.recordInputs===!0,r=t&&e.session?.decision?.recordOutputs===!0,i=e.turn.parentLineage??e.session?.parentLineage,a=i!==void 0,o=agentChannelClassificationAttributes(e.session,e.turn),s=a?void 0:e.session?.scheduleId;return{"agent.framework.name":`eve`,"agent.framework.version":e.frameworkVersion,"agent.name":e.agentName,"agent.channel.audience":e.session?.channelAudience,...agentPrincipalAttributes(e.turn),"agent.channel.delivery.id":e.turn.channelDelivery?.deliveryId,"agent.channel.delivery.input":e.turn.channelDelivery?.inputAttribute,...o,"agent.channel.name":e.turn.channelDelivery?.channelName,"agent.channel.request.id":e.turn.channelDelivery?.requestId,"agent.parent_call.id":i?.callId,"agent.parent_run.id":i?.sessionId,"agent.run.type":a?`subagent`:`session`,"agent.schedule.id":s,"agent.session.title":!a&&n?e.session?.title:void 0,"agent.subagent.name":e.turn.subagentName,"agent.trace.content.input":n,"agent.trace.content.output":r,"agent.turn.id":e.turnId,"agent.turn.sequence":e.turn.sequence,"gen_ai.agent.name":e.agentName,"gen_ai.operation.name":`invoke_agent`,...agentSpanNamingAttributes(agentInvocationSpanName(e.agentName),`invoke_agent`),...agentTraceIdentityAttributes({rootSessionId:e.turn.rootSessionId,sessionId:e.sessionId})}}function agentChannelClassificationAttributes(e,t){let n=(t.parentLineage??e?.parentLineage)!==void 0,r=t.channelDelivery?.channelKind??(n?void 0:e?.channelKind??(e?.channelType===void 0?void 0:normalizeInstrumentationChannelKind(e.channelType)));return{"agent.channel.kind":r,"agent.session.origin":n||r===void 0?void 0:e?.scheduleId===void 0?`channel`:`schedule`}}function agentStepAttributes(e){let{event:t,session:n,turn:r}=e,i=agentChannelClassificationAttributes(n,r);return{"agent.framework.name":`eve`,"agent.framework.version":e.frameworkVersion,"agent.step.attempt":t.scope.attemptIndex,"agent.step.index":t.scope.stepIndex,"agent.turn.id":t.scope.turnId,"agent.name":t.scope.functionId,...i[`agent.channel.kind`]===`unknown`?void 0:i,...agentSpanNamingAttributes(`agent.step`),...agentTraceIdentityAttributes({rootSessionId:t.scope.rootSessionId??t.scope.sessionId,sessionId:t.scope.sessionId}),...runtimeContextAttributes(t.runtimeContext)}}function agentPrincipalAttributes(e){let t={};return setOptionalAttribute(t,`agent.principal.current.id`,e.currentPrincipal?.id),setOptionalAttribute(t,`agent.principal.current.type`,e.currentPrincipal?.type),setOptionalAttribute(t,`agent.principal.initiator.id`,e.initiatorPrincipal?.id),setOptionalAttribute(t,`agent.principal.initiator.type`,e.initiatorPrincipal?.type),t}function runtimeContextAttributes(e){let t={};if(e===void 0)return t;for(let[n,r]of Object.entries(e))flattenContextAttribute(t,`ai.settings.context.${n}`,r);return t}function flattenContextAttribute(e,t,n){if(n!=null){if(typeof n==`string`||typeof n==`number`||typeof n==`boolean`){e[t]=n;return}if(Array.isArray(n)){let r=n.filter(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`);if(r.length!==n.length||new Set(r.map(e=>typeof e)).size!==1)return;e[t]=r;return}if(typeof n==`object`)for(let[r,i]of Object.entries(n))flattenContextAttribute(e,`${t}.${r}`,i)}}function setOptionalAttribute(e,t,n){n!==void 0&&(e[t]=n)}export{agentActivationAttributes,agentChannelClassificationAttributes,agentPrincipalAttributes,agentStepAttributes,runtimeContextAttributes};
@@ -1 +1 @@
1
- import{AGENT_USAGE_ATTRIBUTES}from"#tracing/agent-span-contract.js";function setAgentUsage(e,t){t.inputTokens!==void 0&&e.setAttribute(AGENT_USAGE_ATTRIBUTES.inputTokens,t.inputTokens),t.outputTokens!==void 0&&e.setAttribute(AGENT_USAGE_ATTRIBUTES.outputTokens,t.outputTokens);let n=t.inputTokenDetails;n?.cacheReadTokens!==void 0&&e.setAttribute(AGENT_USAGE_ATTRIBUTES.cacheReadTokens,n.cacheReadTokens),n?.cacheWriteTokens!==void 0&&e.setAttribute(AGENT_USAGE_ATTRIBUTES.cacheWriteTokens,n.cacheWriteTokens)}function setGenAiUsage(e,t){setAgentUsage(e,t),t.inputTokens!==void 0&&e.setAttribute(`gen_ai.usage.input_tokens`,t.inputTokens),t.outputTokens!==void 0&&e.setAttribute(`gen_ai.usage.output_tokens`,t.outputTokens);let n=t.inputTokenDetails;n?.cacheReadTokens!==void 0&&e.setAttribute(`gen_ai.usage.cache_read.input_tokens`,n.cacheReadTokens),n?.cacheWriteTokens!==void 0&&e.setAttribute(`gen_ai.usage.cache_write.input_tokens`,n.cacheWriteTokens)}function setAgentInvocationUsage(e,t){t!==void 0&&setGenAiUsage(e,t)}function readGatewayCost(e){let t=e.gateway;if(!isRecord(t))return;let n={},r=readUsd(t.cost);r!==void 0&&(n[`gen_ai.usage.cost`]=r);let i=readUsd(t.gatewayCost);i!==void 0&&(n[`gen_ai.usage.gateway_cost`]=i);let a=readUsd(t.inputInferenceCost);a!==void 0&&(n[`gen_ai.usage.input_cost`]=a);let o=readUsd(t.outputInferenceCost);return o!==void 0&&(n[`gen_ai.usage.output_cost`]=o),typeof t.generationId==`string`&&t.generationId.length>0&&(n[`gen_ai.generation.id`]=t.generationId),Object.keys(n).length===0?void 0:n}function readUsd(e){if(typeof e!=`string`)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{readGatewayCost,setAgentInvocationUsage,setAgentUsage,setGenAiUsage};
1
+ import{AGENT_USAGE_ATTRIBUTES}from"#tracing/agent-span-contract.js";function setAgentUsage(e,t){t.costUsd!==void 0&&e.setAttribute(AGENT_USAGE_ATTRIBUTES.costUsd,t.costUsd),t.inputTokens!==void 0&&e.setAttribute(AGENT_USAGE_ATTRIBUTES.inputTokens,t.inputTokens),t.outputTokens!==void 0&&e.setAttribute(AGENT_USAGE_ATTRIBUTES.outputTokens,t.outputTokens);let n=t.inputTokenDetails;n?.cacheReadTokens!==void 0&&e.setAttribute(AGENT_USAGE_ATTRIBUTES.cacheReadTokens,n.cacheReadTokens),n?.cacheWriteTokens!==void 0&&e.setAttribute(AGENT_USAGE_ATTRIBUTES.cacheWriteTokens,n.cacheWriteTokens)}function setGenAiUsage(e,t){setAgentUsage(e,t),t.inputTokens!==void 0&&e.setAttribute(`gen_ai.usage.input_tokens`,t.inputTokens),t.outputTokens!==void 0&&e.setAttribute(`gen_ai.usage.output_tokens`,t.outputTokens);let n=t.inputTokenDetails;n?.cacheReadTokens!==void 0&&e.setAttribute(`gen_ai.usage.cache_read.input_tokens`,n.cacheReadTokens),n?.cacheWriteTokens!==void 0&&e.setAttribute(`gen_ai.usage.cache_write.input_tokens`,n.cacheWriteTokens)}function setAgentInvocationUsage(e,t){t!==void 0&&setGenAiUsage(e,t)}function readGatewayCost(e){let t=e.gateway;if(!isRecord(t))return;let n={},r=readUsd(t.cost);r!==void 0&&(n[`gen_ai.usage.cost`]=r);let i=readUsd(t.gatewayCost);i!==void 0&&(n[`gen_ai.usage.gateway_cost`]=i);let a=readUsd(t.inputInferenceCost);a!==void 0&&(n[`gen_ai.usage.input_cost`]=a);let o=readUsd(t.outputInferenceCost);return o!==void 0&&(n[`gen_ai.usage.output_cost`]=o),typeof t.generationId==`string`&&t.generationId.length>0&&(n[`gen_ai.generation.id`]=t.generationId),Object.keys(n).length===0?void 0:n}function readUsd(e){if(typeof e!=`string`)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{readGatewayCost,setAgentInvocationUsage,setAgentUsage,setGenAiUsage};