eve 0.50.0 → 0.51.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 (450) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/src/acp/adapter.js +1 -1
  3. package/dist/src/channel/types.d.ts +12 -19
  4. package/dist/src/chunks/{use-eve-agent-DUMU6dap.js → use-eve-agent-B4xN7-fK.js} +4 -4
  5. package/dist/src/chunks/{use-eve-agent-B5I-k6Ek.js → use-eve-agent-C3vUG5g2.js} +4 -4
  6. package/dist/src/cli/acp/command.d.ts +1 -1
  7. package/dist/src/cli/acp/command.js +2 -2
  8. package/dist/src/cli/agent-command.d.ts +5 -0
  9. package/dist/src/cli/agent-command.js +1 -0
  10. package/dist/src/cli/application-command.d.ts +2 -0
  11. package/dist/src/cli/commands/build.d.ts +1 -1
  12. package/dist/src/cli/commands/build.js +1 -1
  13. package/dist/src/cli/commands/deploy.d.ts +2 -0
  14. package/dist/src/cli/commands/deploy.js +1 -1
  15. package/dist/src/cli/commands/init-agent-workspace.d.ts +14 -0
  16. package/dist/src/cli/commands/init-agent-workspace.js +1 -0
  17. package/dist/src/cli/commands/init-repl.js +1 -1
  18. package/dist/src/cli/commands/init.d.ts +2 -13
  19. package/dist/src/cli/commands/init.js +1 -1
  20. package/dist/src/cli/commands/integration-connect.js +1 -1
  21. package/dist/src/cli/commands/link.d.ts +2 -0
  22. package/dist/src/cli/commands/link.js +1 -1
  23. package/dist/src/cli/commands/preconditions.d.ts +15 -0
  24. package/dist/src/cli/commands/preconditions.js +1 -1
  25. package/dist/src/cli/commands/register-integration-commands.d.ts +1 -1
  26. package/dist/src/cli/commands/register-integration-commands.js +1 -1
  27. package/dist/src/cli/commands/register-registry-commands.js +2 -2
  28. package/dist/src/cli/commands/registry.js +1 -1
  29. package/dist/src/cli/dev/environment.d.ts +1 -1
  30. package/dist/src/cli/dev/environment.js +1 -1
  31. package/dist/src/cli/dev/local-server-process.js +1 -1
  32. package/dist/src/cli/dev/tui/runner.js +1 -1
  33. package/dist/src/cli/invoke/command.d.ts +1 -1
  34. package/dist/src/cli/invoke/command.js +1 -1
  35. package/dist/src/cli/option-parsers.d.ts +1 -0
  36. package/dist/src/cli/option-parsers.js +1 -1
  37. package/dist/src/cli/run.js +3 -3
  38. package/dist/src/client/agent-info-schema.d.ts +0 -1
  39. package/dist/src/client/agent-info-schema.js +1 -1
  40. package/dist/src/client/message-action-parts.js +1 -1
  41. package/dist/src/compiled/.vendor-stamp.json +1 -1
  42. package/dist/src/compiler/extension-compatibility.d.ts +18 -18
  43. package/dist/src/compiler/extension-compatibility.js +1 -1
  44. package/dist/src/compiler/manifest.js +1 -1
  45. package/dist/src/compiler/normalize-agent-config.js +1 -1
  46. package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
  47. package/dist/src/compiler/normalize-manifest.js +1 -1
  48. package/dist/src/context/build-dynamic-tools.js +1 -1
  49. package/dist/src/context/dynamic-subagent-lifecycle.js +1 -1
  50. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  51. package/dist/src/context/dynamic-tool-metadata.d.ts +1 -0
  52. package/dist/src/context/keys.d.ts +0 -3
  53. package/dist/src/context/keys.js +1 -1
  54. package/dist/src/discover/project.js +1 -1
  55. package/dist/src/evals/cli/eval.js +1 -1
  56. package/dist/src/evals/mock-model.js +1 -1
  57. package/dist/src/eve-channel/index.js +1 -1
  58. package/dist/src/execution/activity-work-id.js +1 -1
  59. package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
  60. package/dist/src/execution/channel-context.js +1 -1
  61. package/dist/src/execution/coordination-dispatch-shared.d.ts +103 -0
  62. package/dist/src/execution/coordination-dispatch-shared.js +1 -0
  63. package/dist/src/execution/coordination-dispatch-step.d.ts +7 -0
  64. package/dist/src/execution/coordination-dispatch-step.js +1 -0
  65. package/dist/src/execution/create-session-step.d.ts +1 -2
  66. package/dist/src/execution/create-session-step.js +1 -1
  67. package/dist/src/execution/deliver-payloads.js +1 -1
  68. package/dist/src/execution/dispatch-action-failures.d.ts +5 -5
  69. package/dist/src/execution/dispatch-action-failures.js +1 -1
  70. package/dist/src/execution/dispatch-start-operation.d.ts +1 -1
  71. package/dist/src/execution/dispatch-start-operation.js +1 -1
  72. package/dist/src/execution/durable-session-store.d.ts +1 -1
  73. package/dist/src/execution/eve-workflow-attributes.d.ts +1 -1
  74. package/dist/src/execution/inline-turn.js +1 -1
  75. package/dist/src/execution/next-driver-action.d.ts +7 -10
  76. package/dist/src/execution/node-step.d.ts +1 -2
  77. package/dist/src/execution/node-step.js +1 -1
  78. package/dist/src/execution/pending-turn-state.d.ts +1 -2
  79. package/dist/src/execution/pending-turn-state.js +1 -1
  80. package/dist/src/execution/proxied-deliver-step.js +1 -1
  81. package/dist/src/execution/route-child-delivery.js +1 -1
  82. package/dist/src/execution/runtime-context.js +1 -1
  83. package/dist/src/execution/session-command-inbox.d.ts +2 -3
  84. package/dist/src/execution/session.d.ts +1 -1
  85. package/dist/src/execution/session.js +2 -2
  86. package/dist/src/execution/settle-cancelled-turn-step.d.ts +1 -1
  87. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  88. package/dist/src/execution/stable-workflow-names.d.ts +1 -1
  89. package/dist/src/execution/stable-workflow-names.js +1 -1
  90. package/dist/src/execution/task-event-callback.js +1 -1
  91. package/dist/src/execution/tasks/child/steps.d.ts +18 -18
  92. package/dist/src/execution/tasks/child/steps.js +1 -1
  93. package/dist/src/execution/tasks/child/update-step.d.ts +6 -0
  94. package/dist/src/execution/tasks/child/update-step.js +1 -0
  95. package/dist/src/execution/tasks/child/update.d.ts +7 -10
  96. package/dist/src/execution/tasks/child/update.js +1 -1
  97. package/dist/src/execution/tasks/child/workflow.d.ts +21 -29
  98. package/dist/src/execution/tasks/child/workflow.js +1 -1
  99. package/dist/src/execution/tasks/parent/control-shared.d.ts +6 -17
  100. package/dist/src/execution/tasks/parent/control-shared.js +1 -1
  101. package/dist/src/execution/tasks/parent/delegate.d.ts +15 -50
  102. package/dist/src/execution/tasks/parent/delegate.js +1 -1
  103. package/dist/src/execution/tasks/parent/dispatch.d.ts +19 -34
  104. package/dist/src/execution/tasks/parent/dispatch.js +1 -1
  105. package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +5 -15
  106. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
  107. package/dist/src/execution/tasks/parent/run-parent.d.ts +2 -2
  108. package/dist/src/execution/tasks/parent/task-cancel.d.ts +11 -0
  109. package/dist/src/execution/tasks/parent/task-cancel.js +1 -0
  110. package/dist/src/execution/tasks/parent/tool-execution.d.ts +2 -3
  111. package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
  112. package/dist/src/execution/terminate-child-sessions-step.js +1 -1
  113. package/dist/src/execution/tools/subagent/accept-event-step.d.ts +7 -0
  114. package/dist/src/execution/tools/subagent/accept-event-step.js +1 -0
  115. package/dist/src/execution/tools/subagent/emit-called-step.d.ts +9 -0
  116. package/dist/src/execution/tools/subagent/emit-called-step.js +1 -0
  117. package/dist/src/execution/tools/subagent/invoke-agent.d.ts +51 -0
  118. package/dist/src/execution/tools/subagent/invoke-agent.js +1 -0
  119. package/dist/src/execution/tools/subagent/invoke-preparation.d.ts +37 -0
  120. package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -0
  121. package/dist/src/execution/tools/subagent/invoke-step.d.ts +55 -0
  122. package/dist/src/execution/tools/subagent/invoke-step.js +1 -0
  123. package/dist/src/execution/tools/subagent/receipt-identity.d.ts +11 -0
  124. package/dist/src/execution/tools/subagent/receipt-identity.js +1 -0
  125. package/dist/src/execution/{dispatch-runtime-actions-start.d.ts → tools/subagent/start.d.ts} +17 -5
  126. package/dist/src/execution/tools/subagent/start.js +1 -0
  127. package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +24 -0
  128. package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -0
  129. package/dist/src/execution/tools/subagent/task-cancel.d.ts +10 -0
  130. package/dist/src/execution/tools/subagent/task-cancel.js +1 -0
  131. package/dist/src/execution/tools/tasks.d.ts +10 -0
  132. package/dist/src/execution/tools/tasks.js +1 -0
  133. package/dist/src/execution/{tool-run → tools/workflow}/answer.d.ts +1 -1
  134. package/dist/src/execution/tools/workflow/answer.js +1 -0
  135. package/dist/src/execution/tools/workflow/ask.d.ts +22 -0
  136. package/dist/src/execution/tools/workflow/ask.js +1 -0
  137. package/dist/src/execution/tools/workflow/background.d.ts +18 -0
  138. package/dist/src/execution/tools/workflow/background.js +1 -0
  139. package/dist/src/execution/tools/workflow/body.d.ts +25 -0
  140. package/dist/src/execution/tools/workflow/body.js +1 -0
  141. package/dist/src/execution/tools/workflow/cancel.d.ts +11 -0
  142. package/dist/src/execution/tools/workflow/cancel.js +1 -0
  143. package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +7 -0
  144. package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +1 -0
  145. package/dist/src/execution/tools/workflow/messages.d.ts +88 -0
  146. package/dist/src/execution/tools/workflow/messages.js +1 -0
  147. package/dist/src/execution/tools/workflow/owner-inbox.d.ts +13 -0
  148. package/dist/src/execution/tools/workflow/owner-inbox.js +1 -0
  149. package/dist/src/execution/tools/workflow/owner.d.ts +13 -0
  150. package/dist/src/execution/tools/workflow/owner.js +1 -0
  151. package/dist/src/execution/tools/workflow/run-control.d.ts +18 -0
  152. package/dist/src/execution/tools/workflow/run-control.js +1 -0
  153. package/dist/src/execution/tools/workflow/start.d.ts +33 -0
  154. package/dist/src/execution/tools/workflow/start.js +1 -0
  155. package/dist/src/execution/tools/workflow/types.d.ts +26 -0
  156. package/dist/src/execution/tools/workflow/types.js +1 -0
  157. package/dist/src/execution/tools/workflow/workflow.d.ts +3 -0
  158. package/dist/src/execution/tools/workflow/workflow.js +1 -0
  159. package/dist/src/execution/turn-workflow-tool-run.d.ts +16 -0
  160. package/dist/src/execution/turn-workflow-tool-run.js +1 -0
  161. package/dist/src/execution/turn-workflow.js +1 -1
  162. package/dist/src/execution/wire/session-inbox-contract.d.ts +2 -2
  163. package/dist/src/execution/wire/session-inbox-contract.js +1 -1
  164. package/dist/src/execution/wire/session-inbox-encoder.d.ts +6 -2
  165. package/dist/src/execution/wire/session-inbox-encoder.js +1 -1
  166. package/dist/src/execution/wire/session-inbox-wire.d.ts +3 -3
  167. package/dist/src/execution/wire/session-inbox-wire.js +1 -1
  168. package/dist/src/execution/wire/session-inbox-wire.v1.js +1 -1
  169. package/dist/src/execution/wire/session-inbox-wire.v4.d.ts +267 -0
  170. package/dist/src/execution/wire/session-inbox-wire.v4.js +1 -0
  171. package/dist/src/execution/wire/session-inbox-wire.v4.migration.d.ts +3 -0
  172. package/dist/src/execution/wire/session-inbox-wire.v4.migration.js +1 -0
  173. package/dist/src/execution/workflow-entry-finalization.d.ts +6 -0
  174. package/dist/src/execution/workflow-entry-finalization.js +1 -1
  175. package/dist/src/execution/workflow-entry.d.ts +2 -1
  176. package/dist/src/execution/workflow-entry.js +1 -1
  177. package/dist/src/execution/workflow-runtime.d.ts +1 -1
  178. package/dist/src/execution/workflow-runtime.js +1 -1
  179. package/dist/src/execution/workflow-steps.js +1 -1
  180. package/dist/src/framework/sources/registry.js +1 -1
  181. package/dist/src/harness/advertised-tools.d.ts +1 -7
  182. package/dist/src/harness/advertised-tools.js +1 -1
  183. package/dist/src/harness/background-tools.d.ts +8 -2
  184. package/dist/src/harness/{runtime-actions.d.ts → coordination.d.ts} +40 -27
  185. package/dist/src/harness/coordination.js +1 -0
  186. package/dist/src/harness/emission.d.ts +9 -2
  187. package/dist/src/harness/emission.js +1 -1
  188. package/dist/src/harness/execute-tool.d.ts +52 -0
  189. package/dist/src/harness/hitl/session-limit-input-requests.js +1 -1
  190. package/dist/src/harness/input-requests.js +1 -1
  191. package/dist/src/harness/proxy-input-requests.d.ts +6 -2
  192. package/dist/src/harness/stale-input-responses.js +1 -1
  193. package/dist/src/harness/step-hooks.d.ts +1 -2
  194. package/dist/src/harness/step-hooks.js +1 -1
  195. package/dist/src/harness/tool-call-action.js +1 -1
  196. package/dist/src/harness/tool-call-input-errors.js +1 -1
  197. package/dist/src/harness/tool-loop.js +2 -2
  198. package/dist/src/harness/tools.js +1 -1
  199. package/dist/src/harness/turn-tag-state.d.ts +3 -1
  200. package/dist/src/harness/types.d.ts +4 -7
  201. package/dist/src/harness/workflow-interrupt-state.js +1 -1
  202. package/dist/src/harness/workflow-lifecycle.d.ts +10 -0
  203. package/dist/src/harness/workflow-lifecycle.js +1 -1
  204. package/dist/src/harness/workflow-sandbox.d.ts +1 -1
  205. package/dist/src/harness/workflow-sandbox.js +2 -2
  206. package/dist/src/harness/workflow-subagent-limit.d.ts +7 -7
  207. package/dist/src/harness/workflow-subagent-limit.js +1 -1
  208. package/dist/src/harness/workflow-task-state.d.ts +9 -0
  209. package/dist/src/harness/workflow-task-state.js +1 -0
  210. package/dist/src/harness/workflow-tool-runs.d.ts +27 -0
  211. package/dist/src/harness/workflow-tool-runs.js +1 -0
  212. package/dist/src/instrumentation/native-events.js +1 -1
  213. package/dist/src/instrumentation/parent-lineage.js +1 -1
  214. package/dist/src/internal/agent-name.d.ts +4 -0
  215. package/dist/src/internal/agent-name.js +1 -0
  216. package/dist/src/internal/agent-workspace.d.ts +15 -0
  217. package/dist/src/internal/agent-workspace.js +1 -0
  218. package/dist/src/internal/application/package.js +1 -1
  219. package/dist/src/internal/authored-definition/core.js +1 -1
  220. package/dist/src/internal/nitro/host/build-application.js +1 -1
  221. package/dist/src/internal/nitro/host/start-development-server.js +1 -1
  222. package/dist/src/internal/nitro/host/start-production-server.js +3 -3
  223. package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
  224. package/dist/src/internal/project-context.d.ts +26 -0
  225. package/dist/src/internal/project-context.js +1 -0
  226. package/dist/src/internal/vercel/assemble-eve-services.d.ts +17 -0
  227. package/dist/src/internal/vercel/assemble-eve-services.js +1 -0
  228. package/dist/src/internal/vercel/build-agent-workspace.d.ts +3 -0
  229. package/dist/src/internal/vercel/build-agent-workspace.js +1 -0
  230. package/dist/src/internal/vercel/build-command.d.ts +4 -0
  231. package/dist/src/internal/vercel/build-command.js +1 -0
  232. package/dist/src/internal/vercel/eve-service-contribution.d.ts +27 -0
  233. package/dist/src/internal/vercel/eve-service-contribution.js +1 -0
  234. package/dist/src/internal/vercel/vercel-service-config-operations.d.ts +18 -0
  235. package/dist/src/internal/vercel/vercel-service-config-operations.js +1 -0
  236. package/dist/src/internal/vercel/vercel-service-name.d.ts +6 -0
  237. package/dist/src/internal/vercel/vercel-service-name.js +1 -0
  238. package/dist/src/internal/vercel/vercel-services-config.d.ts +53 -0
  239. package/dist/src/internal/vercel/vercel-services-config.js +1 -0
  240. package/dist/src/internal/workflow-bundle/builder.js +1 -1
  241. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  242. package/dist/src/protocol/message.d.ts +2 -0
  243. package/dist/src/protocol/message.js +1 -1
  244. package/dist/src/public/channels/slack/action-status.js +1 -1
  245. package/dist/src/public/memory/file/backends/vercel-blob.js +1 -1
  246. package/dist/src/public/next/index.js +1 -1
  247. package/dist/src/public/next/vercel-output-config.js +1 -1
  248. package/dist/src/public/workflow/index.d.ts +3 -1
  249. package/dist/src/public/workflow/index.js +1 -1
  250. package/dist/src/runtime/actions/results.d.ts +3 -3
  251. package/dist/src/runtime/actions/results.js +1 -1
  252. package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -1
  253. package/dist/src/runtime/agent/bootstrap.d.ts +1 -0
  254. package/dist/src/runtime/agent/bootstrap.js +1 -1
  255. package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
  256. package/dist/src/runtime/channels/registry.js +1 -1
  257. package/dist/src/runtime/prompt/compose.d.ts +0 -1
  258. package/dist/src/runtime/prompt/compose.js +1 -1
  259. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  260. package/dist/src/runtime/resolve-agent.js +1 -1
  261. package/dist/src/runtime/sessions/turn.d.ts +16 -1
  262. package/dist/src/runtime/subagents/registry.js +1 -1
  263. package/dist/src/runtime/subagents/workflow-reference.d.ts +5 -0
  264. package/dist/src/runtime/subagents/workflow-reference.js +1 -0
  265. package/dist/src/runtime/subagents/workflow.d.ts +8 -0
  266. package/dist/src/runtime/subagents/workflow.js +1 -0
  267. package/dist/src/runtime/tools/registry.js +1 -1
  268. package/dist/src/setup/integrations/discord/setup.js +1 -1
  269. package/dist/src/setup/integrations/file-memory/vercel.js +1 -1
  270. package/dist/src/setup/integrations/linear/setup.js +1 -1
  271. package/dist/src/setup/integrations/linq/setup.js +3 -3
  272. package/dist/src/setup/integrations/shopify/setup.js +1 -1
  273. package/dist/src/setup/scaffold/create/project.js +1 -1
  274. package/dist/src/setup/scaffold/update/channels.d.ts +4 -12
  275. package/dist/src/setup/scaffold/update/channels.js +1 -1
  276. package/dist/src/shared/action-types.d.ts +74 -14
  277. package/dist/src/shared/action-types.js +1 -1
  278. package/dist/src/shared/json.js +1 -1
  279. package/dist/src/shared/workflow-sandbox.d.ts +1 -1
  280. package/dist/src/{execution/subagent-adapter-state.d.ts → subagents/adapter-state.d.ts} +2 -0
  281. package/dist/src/{execution/subagent-adapter-state.js → subagents/adapter-state.js} +1 -1
  282. package/dist/src/subagents/adapter.js +1 -0
  283. package/dist/src/{harness → subagents}/agent-handle-errors.d.ts +6 -0
  284. package/dist/src/subagents/agent-handle-errors.js +1 -0
  285. package/dist/src/subagents/callback-route.js +1 -0
  286. package/dist/src/subagents/callback-step.js +1 -0
  287. package/dist/src/{execution/agent-continuation-bundle.d.ts → subagents/continuation-bundle.d.ts} +1 -1
  288. package/dist/src/subagents/continuation-bundle.js +1 -0
  289. package/dist/src/{execution/subagent-event-proxy-step.d.ts → subagents/event-proxy-step.d.ts} +2 -8
  290. package/dist/src/subagents/event-proxy-step.js +1 -0
  291. package/dist/src/subagents/handle-dispatch.d.ts +54 -0
  292. package/dist/src/subagents/handle-dispatch.js +1 -0
  293. package/dist/src/{harness → subagents}/handles/prompt.d.ts +4 -4
  294. package/dist/src/{harness → subagents}/handles/prompt.js +1 -1
  295. package/dist/src/{harness → subagents}/handles/query.d.ts +8 -2
  296. package/dist/src/subagents/handles/query.js +1 -0
  297. package/dist/src/subagents/handles/rebase.d.ts +4 -0
  298. package/dist/src/subagents/handles/rebase.js +1 -0
  299. package/dist/src/{harness → subagents}/handles/store.d.ts +90 -15
  300. package/dist/src/subagents/handles/store.js +1 -0
  301. package/dist/src/subagents/handles/transitions.d.ts +103 -0
  302. package/dist/src/subagents/handles/transitions.js +1 -0
  303. package/dist/src/{execution/delegated-parent-notification.d.ts → subagents/parent-notification.d.ts} +1 -7
  304. package/dist/src/subagents/parent-notification.js +1 -0
  305. package/dist/src/subagents/parent-result.js +1 -0
  306. package/dist/src/{execution/remote-agent-dispatch.d.ts → subagents/remote-dispatch.d.ts} +3 -2
  307. package/dist/src/subagents/remote-dispatch.js +1 -0
  308. package/dist/src/{execution/subagent-start-local.d.ts → subagents/start-local.d.ts} +5 -6
  309. package/dist/src/subagents/start-local.js +1 -0
  310. package/dist/src/{execution/subagent-start-remote.d.ts → subagents/start-remote.d.ts} +5 -5
  311. package/dist/src/subagents/start-remote.js +1 -0
  312. package/dist/src/{execution/subagent-tool.d.ts → subagents/tool.d.ts} +5 -3
  313. package/dist/src/subagents/tool.js +1 -0
  314. package/dist/src/svelte/index.js +1 -1
  315. package/dist/src/svelte/use-eve-agent.js +1 -1
  316. package/dist/src/tasks/json.js +1 -1
  317. package/dist/src/tasks/session-index.d.ts +2 -3
  318. package/dist/src/tasks/session-index.js +1 -1
  319. package/dist/src/tasks/task-id.d.ts +3 -4
  320. package/dist/src/tasks/task-id.js +1 -1
  321. package/dist/src/tasks/transitions.d.ts +3 -47
  322. package/dist/src/tasks/transitions.js +1 -1
  323. package/dist/src/tasks/types.d.ts +69 -247
  324. package/dist/src/tasks/types.js +1 -1
  325. package/dist/src/tools/dynamic.d.ts +3 -1
  326. package/dist/src/tools/framework/agent.d.ts +18 -2
  327. package/dist/src/tools/framework/agent.js +1 -1
  328. package/dist/src/tools/framework/task-cancel.d.ts +2 -6
  329. package/dist/src/tools/framework/task-contract.d.ts +44 -65
  330. package/dist/src/tools/framework/task-contract.js +1 -1
  331. package/dist/src/tools/framework/task-update.d.ts +1 -0
  332. package/dist/src/tools/framework/task-update.js +1 -1
  333. package/dist/src/vue/index.js +1 -1
  334. package/dist/src/vue/use-eve-agent.js +1 -1
  335. package/docs/concepts/built-in-tools.md +9 -90
  336. package/docs/concepts/context-control.md +2 -2
  337. package/docs/concepts/execution-model-and-durability.mdx +1 -1
  338. package/docs/concepts/sessions-runs-and-streaming.md +3 -3
  339. package/docs/guides/deployment/vercel.mdx +20 -2
  340. package/docs/guides/dynamic-capabilities.md +2 -2
  341. package/docs/guides/frontend/overview.mdx +1 -1
  342. package/docs/guides/instrumentation-providers.md +242 -0
  343. package/docs/guides/instrumentation.md +2 -0
  344. package/docs/guides/meta.json +1 -0
  345. package/docs/guides/remote-agents.md +8 -9
  346. package/docs/reference/cli.md +5 -2
  347. package/docs/sandbox.mdx +2 -0
  348. package/docs/subagents/index.mdx +9 -8
  349. package/docs/tools/overview.mdx +11 -10
  350. package/docs/tools/workflows.mdx +52 -18
  351. package/package.json +1 -1
  352. package/dist/src/execution/agent-continuation-bundle.js +0 -1
  353. package/dist/src/execution/agent-handle-dispatch.d.ts +0 -79
  354. package/dist/src/execution/agent-handle-dispatch.js +0 -1
  355. package/dist/src/execution/delegated-parent-notification.js +0 -1
  356. package/dist/src/execution/delegated-parent-result.js +0 -1
  357. package/dist/src/execution/delegation-tool.d.ts +0 -10
  358. package/dist/src/execution/delegation-tool.js +0 -1
  359. package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +0 -165
  360. package/dist/src/execution/dispatch-runtime-actions-shared.js +0 -1
  361. package/dist/src/execution/dispatch-runtime-actions-start.js +0 -1
  362. package/dist/src/execution/dispatch-runtime-actions-step.d.ts +0 -18
  363. package/dist/src/execution/dispatch-runtime-actions-step.js +0 -1
  364. package/dist/src/execution/dispatch-workflow-runtime-actions-step.d.ts +0 -18
  365. package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +0 -1
  366. package/dist/src/execution/finalize-terminal-session.d.ts +0 -17
  367. package/dist/src/execution/finalize-terminal-session.js +0 -1
  368. package/dist/src/execution/prepared-agent-action.d.ts +0 -7
  369. package/dist/src/execution/prepared-agent-action.js +0 -1
  370. package/dist/src/execution/remote-agent-dispatch.js +0 -1
  371. package/dist/src/execution/session-callback-route.js +0 -1
  372. package/dist/src/execution/session-callback-step.js +0 -1
  373. package/dist/src/execution/subagent-adapter.js +0 -1
  374. package/dist/src/execution/subagent-event-proxy-step.js +0 -1
  375. package/dist/src/execution/subagent-start-local.js +0 -1
  376. package/dist/src/execution/subagent-start-remote.js +0 -1
  377. package/dist/src/execution/subagent-tool.js +0 -1
  378. package/dist/src/execution/tasks/child/instructions.d.ts +0 -3
  379. package/dist/src/execution/tasks/child/instructions.js +0 -1
  380. package/dist/src/execution/tasks/parent/agent-identity.d.ts +0 -13
  381. package/dist/src/execution/tasks/parent/agent-identity.js +0 -1
  382. package/dist/src/execution/tasks/parent/agent-views.d.ts +0 -7
  383. package/dist/src/execution/tasks/parent/agent-views.js +0 -1
  384. package/dist/src/execution/tasks/parent/continuation-dispatch.d.ts +0 -43
  385. package/dist/src/execution/tasks/parent/continuation-dispatch.js +0 -1
  386. package/dist/src/execution/tasks/parent/dispatch-task-step.d.ts +0 -19
  387. package/dist/src/execution/tasks/parent/dispatch-task-step.js +0 -1
  388. package/dist/src/execution/tool-run/answer.js +0 -1
  389. package/dist/src/execution/tool-run/background.d.ts +0 -14
  390. package/dist/src/execution/tool-run/background.js +0 -1
  391. package/dist/src/execution/tool-run/cancel.d.ts +0 -7
  392. package/dist/src/execution/tool-run/cancel.js +0 -1
  393. package/dist/src/execution/tool-run/dispatch.d.ts +0 -24
  394. package/dist/src/execution/tool-run/dispatch.js +0 -1
  395. package/dist/src/execution/tool-run/emit-run-report-step.d.ts +0 -7
  396. package/dist/src/execution/tool-run/emit-run-report-step.js +0 -1
  397. package/dist/src/execution/tool-run/messages.d.ts +0 -70
  398. package/dist/src/execution/tool-run/messages.js +0 -1
  399. package/dist/src/execution/tool-run/owner-inbox.d.ts +0 -11
  400. package/dist/src/execution/tool-run/owner-inbox.js +0 -1
  401. package/dist/src/execution/tool-run/owner.d.ts +0 -13
  402. package/dist/src/execution/tool-run/owner.js +0 -1
  403. package/dist/src/execution/tool-run/run-control.d.ts +0 -18
  404. package/dist/src/execution/tool-run/run-control.js +0 -1
  405. package/dist/src/execution/tool-run/start.d.ts +0 -11
  406. package/dist/src/execution/tool-run/start.js +0 -1
  407. package/dist/src/execution/tool-run/types.d.ts +0 -21
  408. package/dist/src/execution/tool-run/types.js +0 -1
  409. package/dist/src/execution/tool-run/workflow.d.ts +0 -9
  410. package/dist/src/execution/tool-run/workflow.js +0 -1
  411. package/dist/src/execution/tools/subagent/local.d.ts +0 -40
  412. package/dist/src/execution/tools/subagent/local.js +0 -1
  413. package/dist/src/execution/tools/subagent/remote.d.ts +0 -26
  414. package/dist/src/execution/tools/subagent/remote.js +0 -1
  415. package/dist/src/harness/agent-handle-errors.js +0 -1
  416. package/dist/src/harness/handles/query.js +0 -1
  417. package/dist/src/harness/handles/store.js +0 -1
  418. package/dist/src/harness/handles/transitions.d.ts +0 -167
  419. package/dist/src/harness/handles/transitions.js +0 -1
  420. package/dist/src/harness/runtime-actions.js +0 -1
  421. package/dist/src/harness/subagent-depth.d.ts +0 -10
  422. package/dist/src/harness/subagent-depth.js +0 -1
  423. package/dist/src/harness/tool-runs.d.ts +0 -21
  424. package/dist/src/harness/tool-runs.js +0 -1
  425. package/dist/src/harness/workflow-runtime-action-state.d.ts +0 -9
  426. package/dist/src/harness/workflow-runtime-action-state.js +0 -1
  427. package/dist/src/runtime/actions/keys.d.ts +0 -14
  428. package/dist/src/runtime/actions/keys.js +0 -1
  429. package/dist/src/tasks/wire.d.ts +0 -25
  430. package/dist/src/tasks/wire.js +0 -1
  431. /package/dist/src/execution/{tool-run → tools/workflow}/owner-channels.d.ts +0 -0
  432. /package/dist/src/execution/{tool-run → tools/workflow}/owner-channels.js +0 -0
  433. /package/dist/src/execution/{tool-run → tools/workflow}/resume-hook-step.d.ts +0 -0
  434. /package/dist/src/execution/{tool-run → tools/workflow}/resume-hook-step.js +0 -0
  435. /package/dist/src/{execution/subagent-adapter.d.ts → subagents/adapter.d.ts} +0 -0
  436. /package/dist/src/{execution/session-callback-route.d.ts → subagents/callback-route.d.ts} +0 -0
  437. /package/dist/src/{execution/session-callback-step.d.ts → subagents/callback-step.d.ts} +0 -0
  438. /package/dist/src/{harness → subagents}/handles/operation-id.d.ts +0 -0
  439. /package/dist/src/{harness → subagents}/handles/operation-id.js +0 -0
  440. /package/dist/src/{harness → subagents}/handles/state-key.d.ts +0 -0
  441. /package/dist/src/{harness → subagents}/handles/state-key.js +0 -0
  442. /package/dist/src/{execution/subagent-hitl-proxy.d.ts → subagents/hitl-proxy.d.ts} +0 -0
  443. /package/dist/src/{execution/subagent-hitl-proxy.js → subagents/hitl-proxy.js} +0 -0
  444. /package/dist/src/{execution/subagent-invocation.d.ts → subagents/invocation.d.ts} +0 -0
  445. /package/dist/src/{execution/subagent-invocation.js → subagents/invocation.js} +0 -0
  446. /package/dist/src/{execution/delegated-parent-result.d.ts → subagents/parent-result.d.ts} +0 -0
  447. /package/dist/src/{execution/remote-agent-route-url.d.ts → subagents/remote-route-url.d.ts} +0 -0
  448. /package/dist/src/{execution/remote-agent-route-url.js → subagents/remote-route-url.js} +0 -0
  449. /package/dist/src/{harness/subagent-token-budget.d.ts → subagents/token-budget.d.ts} +0 -0
  450. /package/dist/src/{harness/subagent-token-budget.js → subagents/token-budget.js} +0 -0
@@ -0,0 +1,51 @@
1
+ import type { RuntimeActionResultHookPayload, SubagentAuthorizationEventHookPayload, SubagentInputRequestHookPayload } from "#channel/types.js";
2
+ import type { RuntimeSubagentChildResult, RuntimeSubagentResult } from "#shared/action-types.js";
3
+ import type { JsonValue } from "#shared/json.js";
4
+ import type { JsonObject } from "#shared/json.js";
5
+ import type { ToolContext } from "#tools/definition.js";
6
+ import type { TaskInboundUpdate } from "#tasks/types.js";
7
+ export type InternalAgentInput = {
8
+ readonly agentId?: string;
9
+ readonly message: string;
10
+ readonly outputSchema?: JsonObject;
11
+ readonly target: string;
12
+ };
13
+ export interface AgentInput {
14
+ readonly agentId?: string;
15
+ readonly key: string;
16
+ readonly message: string;
17
+ readonly outputSchema?: JsonObject;
18
+ readonly target: string;
19
+ }
20
+ /**
21
+ * Asks the owning session to spawn an agent for a workflow tool run. Spawning
22
+ * needs owner-held material (auth, capabilities, admission, the agent handle
23
+ * store) that a workflow tool body never has.
24
+ */
25
+ export interface AgentInvocationRequest {
26
+ readonly input: InternalAgentInput;
27
+ readonly invocationId: string;
28
+ readonly kind: "agent-invoke";
29
+ }
30
+ /**
31
+ * Tells the owning session that an owner-spawned agent replied to the run, so
32
+ * the owner can release the handle it reserved for `agent-invoke`.
33
+ */
34
+ export interface AgentSettlementRequest {
35
+ readonly kind: "agent-settled";
36
+ readonly result: RuntimeSubagentChildResult;
37
+ }
38
+ export type AgentInvocationEvent = SubagentAuthorizationEventHookPayload | SubagentInputRequestHookPayload;
39
+ export type AgentInvocationReply = AgentInvocationEvent | RuntimeActionResultHookPayload | TaskInboundUpdate;
40
+ /** Invokes an agent from a task-owned background workflow tool. */
41
+ export declare function agent(ctx: ToolContext, input: AgentInput): Promise<JsonValue>;
42
+ /** Invokes an agent with a framework-selected replay-stable invocation id. */
43
+ export declare function invokeAgent(ctx: ToolContext, input: InternalAgentInput, options: {
44
+ readonly invocationId: string;
45
+ readonly returnResult: true;
46
+ }): Promise<JsonValue | RuntimeSubagentResult>;
47
+ export declare function invokeAgent(ctx: ToolContext, input: InternalAgentInput, options: {
48
+ readonly invocationId: string;
49
+ readonly returnResult?: false;
50
+ }): Promise<JsonValue>;
51
+ export declare function validateAgentInput(input: InternalAgentInput | AgentInput, requireKey: boolean): void;
@@ -0,0 +1 @@
1
+ import{createHook}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook}from"#execution/hook-ownership.js";import{readWorkflowToolRunAdmission,readWorkflowToolRunOwner,readWorkflowToolRunRef}from"#execution/tools/workflow/ask.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";const AGENT_INVOCATION_IDS=Symbol.for(`eve.workflow-tool-run.agent-invocation-ids`);async function agent(e,t){return validateAgentInput(t,!0),await invokeAgent(e,{agentId:t.agentId,message:t.message,outputSchema:t.outputSchema,target:t.target},{invocationId:`${e.callId}:${t.key}`})}async function invokeAgent(i,a,o){validateAgentInput(a,!1);let s=readWorkflowToolRunRef(i),c=readWorkflowToolRunOwner(i),l=readWorkflowToolRunAdmission(i);claimInvocationId(i,o.invocationId);let u=createHook(),d=!1;try{if(await claimHookOwnership(u),d=!0,l!==void 0){let e=await l;if(e.status===`rejected`)throw Error(e.reason)}await resumeHookStep(c.request,{from:s,replyTo:u.token,request:{input:a,invocationId:o.invocationId,kind:`agent-invoke`}});let e=u[Symbol.asyncIterator]();for(;;){let t=await nextAgentReply(e,i.abortSignal);if(t.done)break;let n=t.value;if(n.kind===`runtime-action-result`){let e=n.results.find(e=>e.kind===`subagent-result`&&e.callId===o.invocationId);if(e!==void 0){if(e.origin===`child`&&await resumeHookStep(c.request,{from:s,replyTo:u.token,request:{kind:`agent-settled`,result:e}}),o.returnResult===!0&&s.execution===`blocking`)return e;if(e.isError===!0)throw e.output;return e.output}continue}if(n.kind===`subagent-input-request`){await resumeHookStep(c.request,{from:s,replyTo:n.childContinuationToken,request:{kind:`input-batch`,requests:n.event.requests},requestCoordinates:{sequence:n.event.sequence,stepIndex:n.event.stepIndex,turnId:n.event.turnId}});continue}if(n.kind===`task-update`){await resumeHookStep(c.report,{from:s,update:n.message});continue}await resumeHookStep(c.request,{from:s,replyTo:u.token,request:{event:n,kind:`authorization-request`}})}}finally{if(d)try{await disposeHook(u)}catch{}}throw Error(`Agent "${a.target}" closed without a result.`)}async function nextAgentReply(e,t){if(t===void 0)return await e.next();if(t.aborted)throw t.reason;let n,r=new Promise((e,t)=>{n=t}),abort=()=>n?.(t.reason);t.addEventListener(`abort`,abort,{once:!0});try{return await Promise.race([e.next(),r])}finally{t.removeEventListener(`abort`,abort)}}function validateAgentInput(e,t){if(t&&(typeof e.key!=`string`||e.key.trim()===``))throw TypeError("agent() requires a non-empty `key`.");if(typeof e.target!=`string`||e.target.trim()===``)throw TypeError("agent() requires a non-empty `target`.");if(typeof e.message!=`string`||e.message.trim()===``)throw TypeError("agent() requires a non-empty `message`.")}function claimInvocationId(e,t){let n=e,r=n[AGENT_INVOCATION_IDS]??new Set;if(r.has(t)){let e=t.lastIndexOf(`:`),n=e<0?t:t.slice(e+1);throw TypeError(`agent() invocation key "${n}" was already used in this run; keys must be unique per run.`)}r.add(t),n[AGENT_INVOCATION_IDS]===void 0&&Object.defineProperty(n,AGENT_INVOCATION_IDS,{enumerable:!1,value:r})}export{agent,invokeAgent,validateAgentInput};
@@ -0,0 +1,37 @@
1
+ import type { ContextReader } from "#context/key.js";
2
+ import { type PreparedCoordinationDispatch } from "#execution/coordination-dispatch-shared.js";
3
+ import { type DurableSessionState } from "#execution/durable-session-store.js";
4
+ import type { RuntimeAgentDispatchRequest } from "#shared/action-types.js";
5
+ import type { RuntimeSubagentDispatchFailure } from "#shared/action-types.js";
6
+ import type { AgentInvocationRequest } from "#execution/tools/subagent/invoke-agent.js";
7
+ import { type CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
8
+ import type { DynamicRemoteAgentConfig } from "#runtime/subagents/dynamic-remote-agent-config.js";
9
+ import { type RuntimeAgentHandleAction, type RuntimeSession } from "#subagents/handle-dispatch.js";
10
+ import type { SubagentStartTarget } from "#execution/tools/subagent/start.js";
11
+ export type OwnerAgentDispatchPlanEntry = {
12
+ readonly kind: "resume";
13
+ readonly action: RuntimeAgentHandleAction;
14
+ readonly agentId: string;
15
+ readonly dynamicRemoteAgent?: DynamicRemoteAgentConfig;
16
+ } | {
17
+ readonly kind: "reject";
18
+ readonly result: RuntimeSubagentDispatchFailure;
19
+ } | {
20
+ readonly kind: "start";
21
+ readonly target: SubagentStartTarget;
22
+ };
23
+ /** Prepares one workflow-owner agent invocation from durable inputs. */
24
+ export declare function prepareOwnerAgentInvocation(input: {
25
+ readonly invocation: AgentInvocationRequest["input"];
26
+ readonly invocationId: string;
27
+ readonly knownAgentIds?: readonly string[];
28
+ readonly serializedContext: Record<string, unknown>;
29
+ readonly sessionState: DurableSessionState;
30
+ }): Promise<Omit<PreparedCoordinationDispatch<OwnerAgentDispatchPlanEntry>, "sessionState">>;
31
+ export declare function planAgentDispatch(input: {
32
+ readonly action: RuntimeAgentDispatchRequest;
33
+ readonly bundle: CompiledBundle;
34
+ readonly ctx: ContextReader;
35
+ readonly knownAgentIds?: readonly string[];
36
+ readonly session: RuntimeSession;
37
+ }): OwnerAgentDispatchPlanEntry;
@@ -0,0 +1 @@
1
+ import{createLogger}from"#internal/logging.js";import{SessionDynamicSubagentSelectionsKey,TurnDynamicSubagentSelectionsKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState}from"#harness/emission.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{activeTurnId}from"#harness/active-turn-id.js";import{prepareActionDispatch}from"#execution/coordination-dispatch-shared.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{AGENT_TOOL_DESCRIPTION,AGENT_TOOL_NAME}from"#tools/framework/agent-contract.js";import{isAgentHandleAction}from"#subagents/handle-dispatch.js";import{createRecursiveAgentRootOnlyResult,createUnavailableDynamicSubagentResult,getSubagentName}from"#execution/dispatch-action-failures.js";const log=createLogger(`execution.agent-invocation`);async function prepareOwnerAgentInvocation(e){let t=await readDurableSession(e.sessionState),n=await deserializeContext(e.serializedContext),r=getHarnessEmissionState(t.state),s=resolveAgentInvocationAction({ctx:n,input:e.invocation,invocationId:e.invocationId});return await prepareActionDispatch({batch:{requests:[s],event:{...r,turnId:activeTurnId(r)}},ctx:n,durableSession:t,fanoutSize:1,plan:({bundle:t,ctx:n,session:r})=>[planAgentDispatch({action:s,bundle:t,ctx:n,knownAgentIds:e.knownAgentIds,session:r})],planSharesSandbox:({bundle:e,plan:t})=>ownerPlanSharesSandbox({bundle:e,plan:t}),serializedContext:e.serializedContext})}function planAgentDispatch(e){let t=new Set(e.knownAgentIds??(getAgentHandleStore(e.session.state)?.handles??[]).map(e=>e.identity.id)),n=e.action.input.agentId,r=typeof n==`string`&&n.trim()!==``?n:void 0;if(r!==void 0&&isAgentHandleAction(e.action)){if(t.has(r)){let t=e.bundle.subagentRegistry.dynamicNodeIds?.has(e.action.nodeId)===!0?getDynamicSubagentSelection(e.ctx,e.action.nodeId):void 0;return{action:e.action,agentId:r,dynamicRemoteAgent:e.action.kind===`remote-agent-call`&&t?.kind===`remote`?t.remoteAgent:void 0,kind:`resume`}}log.warn(`unknown agentId on subagent call; starting a new agent`,{agentId:r,callId:e.action.callId})}return classifyFreshStart(e)}function classifyFreshStart(e){let{action:t}=e,n=e.bundle.subagentRegistry.subagentsByNodeId,r=e.bundle.subagentRegistry.dynamicNodeIds?.has(t.nodeId)===!0,i=r?getDynamicSubagentSelection(e.ctx,t.nodeId):void 0;if(r&&(i===void 0||t.kind===`subagent-call`&&i.kind!==`subagent`||t.kind===`remote-agent-call`&&i.kind!==`remote`))return log.warn(`dynamic subagent call blocked after availability changed`,{callId:t.callId,nodeId:t.nodeId,subagentName:getSubagentName(t)}),{kind:`reject`,result:createUnavailableDynamicSubagentResult(t)};if(isRecursiveAgentAction(t,n)&&e.session.rootSessionId!==void 0)return log.warn(`recursive agent call blocked outside the root session`,{callId:t.callId,nodeId:t.nodeId,rootSessionId:e.session.rootSessionId,subagentName:t.subagentName}),{kind:`reject`,result:createRecursiveAgentRootOnlyResult(t)};if(t.kind===`remote-agent-call`)return{kind:`start`,target:{action:t,dynamicRemoteAgent:i?.kind===`remote`?i.remoteAgent:void 0,kind:`remote`}};let a=i?.kind===`subagent`?i.agentConfig:void 0,o=n.get(t.nodeId),s=a?.description??(o?.definition.kind===`subagent`?o.definition.description:void 0);return{kind:`start`,target:{action:t,dynamicSubagentAgentConfig:a,kind:`local`,source:s===void 0?{outputSchema:e.bundle.turnAgent.outputSchema,type:`runtime`}:{description:s,outputSchema:a?.outputSchema??e.bundle.graph?.nodesByNodeId.get(t.nodeId)?.turnAgent?.outputSchema,type:`local`}}}}function ownerPlanSharesSandbox(e){return e.plan.some(t=>{if(t.kind!==`start`||t.target.kind!==`local`)return!1;let n=t.target.action;return n.subagentName===`agent`&&!e.bundle.subagentRegistry.subagentsByNodeId.has(n.nodeId)||e.bundle.graph?.nodesByNodeId.get(n.nodeId)?.sandboxRegistry.sandbox.definition.inheritsParent===!0})}function isRecursiveAgentAction(e,t){return e.kind===`subagent-call`&&e.subagentName===`agent`&&!t.has(e.nodeId)}function resolveAgentInvocationAction(e){let i=e.ctx.require(BundleKey),a=i.subagentRegistry.subagentsByName.get(e.input.target),o=a===void 0?Object.values({...e.ctx.get(SessionDynamicSubagentSelectionsKey),...e.ctx.get(TurnDynamicSubagentSelectionsKey)}).find(t=>t!==null&&t.prepared?.name===e.input.target):void 0,s=a?.definition??o?.prepared??(e.input.target===AGENT_TOOL_NAME&&i.nodeId===void 0?{description:AGENT_TOOL_DESCRIPTION,kind:`subagent`,name:AGENT_TOOL_NAME,nodeId:ROOT_RUNTIME_AGENT_NODE_ID}:void 0);if(s===void 0)throw Error(`Agent target "${e.input.target}" is not available to this agent.`);let c={message:e.input.message};e.input.agentId!==void 0&&(c.agentId=e.input.agentId),e.input.outputSchema!==void 0&&(c.outputSchema=e.input.outputSchema);let l={callId:e.invocationId,description:s.description??``,input:c,name:s.name,nodeId:s.nodeId};return s.kind===`remote`?{...l,kind:`remote-agent-call`,remoteAgentName:s.name}:{...l,kind:`subagent-call`,subagentName:s.name}}export{planAgentDispatch,prepareOwnerAgentInvocation};
@@ -0,0 +1,55 @@
1
+ import type { AgentInvocationRequest } from "#execution/tools/subagent/invoke-agent.js";
2
+ import type { RuntimeSubagentResult } from "#shared/action-types.js";
3
+ import type { HandleEventFn } from "#harness/types.js";
4
+ import { type SubagentCalledStreamEvent } from "#protocol/message.js";
5
+ import { type DurableSessionState } from "#execution/durable-session-store.js";
6
+ import type { RuntimeSubagentChildResult } from "#shared/action-types.js";
7
+ export type AgentInvocationDispatchResult = {
8
+ readonly kind: "dispatched";
9
+ readonly agentId: string;
10
+ readonly event: SubagentCalledStreamEvent;
11
+ readonly sessionState: DurableSessionState;
12
+ } | {
13
+ readonly kind: "failed";
14
+ readonly result: RuntimeSubagentResult;
15
+ readonly sessionState: DurableSessionState;
16
+ };
17
+ export type TaskAgentInvocationDispatchResult = {
18
+ readonly kind: "not-admitted";
19
+ readonly sessionState: DurableSessionState;
20
+ } | AgentInvocationDispatchResult;
21
+ /** Dispatches one owner-scoped local or remote agent invocation. */
22
+ export declare function dispatchAgentInvocation(input: {
23
+ readonly callbackBaseUrl: string;
24
+ readonly emit?: HandleEventFn;
25
+ readonly replyTo: string;
26
+ readonly request: AgentInvocationRequest;
27
+ readonly serializedContext: Record<string, unknown>;
28
+ readonly sessionState: DurableSessionState;
29
+ readonly ownerId: string;
30
+ readonly taskId?: string | undefined;
31
+ }): Promise<AgentInvocationDispatchResult>;
32
+ /**
33
+ * Dispatches one agent request after any task-owned invocation is admitted.
34
+ * The callback origin is parent-owned, so it is derived from this workflow's
35
+ * own metadata rather than accepted from the inbound request.
36
+ */
37
+ export declare function dispatchTaskAgentInvocationStep(input: Omit<Parameters<typeof dispatchAgentInvocation>[0], "callbackBaseUrl" | "emit">): Promise<TaskAgentInvocationDispatchResult>;
38
+ /** Applies an owner-scoped child settlement to the parent session's canonical state. */
39
+ export declare function settleTaskAgentInvocationStep(input: {
40
+ readonly accumulateUsage?: boolean;
41
+ readonly ownerId: string;
42
+ readonly result: RuntimeSubagentChildResult;
43
+ readonly sessionState: DurableSessionState;
44
+ readonly taskId?: string | undefined;
45
+ }): Promise<{
46
+ readonly sessionState: DurableSessionState;
47
+ }>;
48
+ /** Releases any child leases still owned by a completed workflow-tool run. */
49
+ export declare function releaseAgentInvocationOwnerStep(input: {
50
+ readonly cancelled?: boolean;
51
+ readonly ownerId: string;
52
+ readonly sessionState: DurableSessionState;
53
+ }): Promise<{
54
+ readonly sessionState: DurableSessionState;
55
+ }>;
@@ -0,0 +1 @@
1
+ import{createSubagentCalledEvent}from"#protocol/message.js";import{workflowEntryReference}from"#execution/workflow-runtime.js";import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{readDurableSession,replaceDurableSessionSnapshot}from"#execution/durable-session-store.js";import{getAgentHandleStore,writeHandles}from"#subagents/handles/store.js";import{projectToDurableSession}from"#execution/session.js";import{AGENT_BUSY,AGENT_MISMATCH,AGENT_UNREACHABLE,formatAgentBusyMessage}from"#subagents/agent-handle-errors.js";import{clearProxyInputRequestsForChild,clearProxyInputRequestsForTask}from"#harness/proxy-input-requests.js";import{readLatestTaskView}from"#execution/tasks/parent/run-parent.js";import{findSessionTaskEntry}from"#tasks/session-index.js";import{abandonAgentInvocationOwners,applyTaskAgentHandleCommand}from"#subagents/handles/transitions.js";import{accumulateSessionUsage,getTurnUsageState,setTurnUsageState}from"#harness/turn-tag-state.js";import{isTerminalTaskStatus}from"#tasks/types.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{createSubagentReceiptIdentity}from"#execution/tools/subagent/receipt-identity.js";import{createAgentErrorResult,dispatchToClaimedAgentAddress}from"#subagents/handle-dispatch.js";import{createAgentContinuationBundle}from"#subagents/continuation-bundle.js";import{startSubagent}from"#execution/tools/subagent/start.js";import{prepareOwnerAgentInvocation}from"#execution/tools/subagent/invoke-preparation.js";async function dispatchAgentInvocation(n){let a=getAgentHandleStore((await readDurableSession(n.sessionState)).state)?.handles??[],s=await prepareOwnerAgentInvocation({invocation:n.request.input,invocationId:n.request.invocationId,knownAgentIds:a.map(e=>e.identity.id),serializedContext:n.serializedContext,sessionState:n.sessionState}),c=s.plan[0];if(c===void 0)throw Error(`Agent invocation produced no executable plan entry.`);let l=s.session,currentAgentHandles=()=>getAgentHandleStore(l.state)?.handles??[],sessionState=()=>replaceDurableSessionSnapshot({session:projectToDurableSession(l),state:n.sessionState}),applyHandleCommand=e=>{let t=applyTaskAgentHandleCommand(l,e);return l=t.session,t.result};if(c.kind===`reject`)return{kind:`failed`,result:c.result,sessionState:sessionState()};let u,d;if(c.kind===`resume`){let e=currentAgentHandles().filter(e=>e.phase===`claimed`&&e.ownerId===n.ownerId&&e.callId===c.action.callId&&e.identity.id===c.agentId);if(e.length>1)throw Error(`Invocation owner "${n.ownerId}" has multiple claims for "${c.action.callId}".`);let t=e[0];if(t===void 0){let e=deriveAgentOperationId({callId:c.action.callId,parentSessionId:s.session.sessionId,parentTurnId:s.batch.event.turnId}),i=applyHandleCommand({agentId:c.agentId,callId:c.action.callId,expectedTarget:c.action.kind===`remote-agent-call`?`remote`:`local`,invokedName:c.action.kind===`remote-agent-call`?c.action.remoteAgentName:c.action.subagentName,kind:`claim`,operationId:e,ownerId:n.ownerId});if(t=readClaimedHandle(i),t===void 0)return{kind:`failed`,result:createTaskClaimError(c.action,c.agentId,i),sessionState:sessionState()}}let i=createAgentContinuationBundle({action:c.action,bundle:s.bundle,dynamicRemoteAgent:c.dynamicRemoteAgent});u=await dispatchToClaimedAgentAddress({action:c.action,auth:s.auth,bundle:i,currentSession:l,parentToken:n.replyTo,handle:t,taskId:n.taskId}),u.kind===`error`&&u.deliveryPermanent===!0&&applyHandleCommand({agentId:c.agentId,kind:`remove`,ownerId:n.ownerId}),d=t.identity.id}else{let e=c.target.action,t=currentAgentHandles().filter(t=>t.phase===`reserved`&&t.ownerId===n.ownerId&&t.callId===e.callId&&t.identity.name===e.name&&t.identity.nodeId===e.nodeId),r=t.length===1?{identity:t[0].identity,operation:{id:t[0].operationId}}:createSubagentReceiptIdentity({callId:e.callId,subagentName:e.kind===`remote-agent-call`?e.remoteAgentName:e.subagentName,nodeId:e.nodeId,parentSessionId:s.session.sessionId,parentTurnId:s.batch.event.turnId});if(t.length>1)throw Error(`Invocation owner "${n.ownerId}" has multiple reservations for "${e.callId}".`);if(t.length===0&&applyHandleCommand({identity:r.identity,callId:e.callId,kind:`reserve`,operationId:r.operation.id,ownerId:n.ownerId}).kind!==`ready`)throw Error(`Agent handle store rejected start operation "${r.operation.id}".`);if(u=await startSubagent({auth:s.auth,batchEvent:s.batch.event,bundle:s.bundle,callbackBaseUrl:n.callbackBaseUrl,capabilities:s.capabilities,channelMetadata:s.channelMetadata,currentSession:l,fanoutSize:s.fanoutSize,initiatorAuth:s.initiatorAuth,localDevRequest:s.localDevRequest,parentContinuationToken:n.replyTo,parentTraceContext:s.parentTraceContext,sandboxSessionId:s.sandboxSessionId,serializedContext:s.serializedContext,session:l,taskId:n.taskId,target:c.target}),d=r.identity.id,u.kind===`error`)applyHandleCommand({agentId:d,kind:`remove`,ownerId:n.ownerId});else if(readClaimedHandle(applyHandleCommand({address:u.address,kind:`confirm`,operationId:r.operation.id,ownerId:n.ownerId}))===void 0)throw Error(`Agent handle store could not confirm start operation "${r.operation.id}".`)}if(u.kind===`error`)return{kind:`failed`,result:u.result,sessionState:sessionState()};let f=c.kind===`resume`?c.action:c.target.action,p=c.kind===`resume`?c.dynamicRemoteAgent:c.target.kind===`remote`?c.target.dynamicRemoteAgent:void 0,m=createSubagentCalledEvent({agentId:d,callId:u.callId,childSessionId:u.address.sessionId,name:u.name,remote:u.address.kind===`agent/remote`?{resolverId:p===void 0?f.nodeId:p.credentialsStepId,url:u.address.url}:void 0,sequence:s.batch.event.sequence,sessionId:s.session.sessionId,toolName:u.toolName,turnId:s.batch.event.turnId,workflowId:workflowEntryReference.workflowId});return n.emit!==void 0&&await n.emit(m),{kind:`dispatched`,agentId:d,event:m,sessionState:sessionState()}}async function dispatchTaskAgentInvocationStep(e){"use step";if(e.taskId!==void 0){let t=findSessionTaskEntry((await readDurableSession(e.sessionState)).state,e.taskId);if(t===void 0)return{kind:`not-admitted`,sessionState:e.sessionState};let n=await readLatestTaskView({taskRunId:t.taskRunId});if(n===void 0||isTerminalTaskStatus(n.status))return{kind:`not-admitted`,sessionState:e.sessionState}}return await dispatchAgentInvocation({...e,callbackBaseUrl:resolveWorkflowCallbackBaseUrl(getWorkflowMetadata().url)})}async function settleTaskAgentInvocationStep(e){"use step";let t=await readDurableSession(e.sessionState),n=getAgentHandleStore(t.state)?.handles??[],r=n.filter(t=>t.phase===`claimed`&&t.ownerId===e.ownerId),o=r.find(t=>t.phase===`claimed`&&t.callId===e.result.callId)??(r.length===1?r[0]:void 0);if(o?.phase!==`claimed`)return{sessionState:e.sessionState};let s=writeHandles(t,e.result.outcome.kind===`terminal`?n.filter(e=>e!==o):n.map(t=>t===o?e.result.outcome.result.kind===`cancelled`?{address:o.address,identity:o.identity,lastStatus:`(cancelled)`,phase:`parked`}:{address:o.address,identity:o.identity,phase:`available`}:t));return e.result.outcome.kind===`terminal`&&(s=e.taskId===void 0?`continuationToken`in o.address?clearProxyInputRequestsForChild(s,o.address.continuationToken):s:clearProxyInputRequestsForTask(s,e.taskId)),e.accumulateUsage!==!1&&(s=setTurnUsageState(s,accumulateSessionUsage({previous:getTurnUsageState(s.state),usage:e.result.outcome.usageDelta}))),{sessionState:replaceDurableSessionSnapshot({session:s,state:e.sessionState})}}async function releaseAgentInvocationOwnerStep(e){"use step";let t=await readDurableSession(e.sessionState),n=e.cancelled?abandonAgentInvocationOwners(t,new Set([e.ownerId])):applyTaskAgentHandleCommand(t,{kind:`release-owner`,ownerId:e.ownerId}).session;return{sessionState:n===t?e.sessionState:replaceDurableSessionSnapshot({session:n,state:e.sessionState})}}function readClaimedHandle(e){let t=e.kind===`ready`?e.handle:void 0;return t?.phase===`claimed`?t:void 0}function createTaskClaimError(e,t,n){return n.kind===`mismatch`?createAgentErrorResult({action:e,code:AGENT_MISMATCH,message:`Agent "${t}" no longer matches this subagent definition. Start a new agent instead.`}):n.kind===`busy`?createAgentErrorResult({action:e,code:AGENT_BUSY,message:formatAgentBusyMessage({agentId:t,agentName:n.handle.identity.name,ownerId:`ownerId`in n.handle?n.handle.ownerId:void 0})}):createAgentErrorResult({action:e,code:AGENT_UNREACHABLE,message:`Agent with id "${t}" is no longer reachable.`})}export{dispatchAgentInvocation,dispatchTaskAgentInvocationStep,releaseAgentInvocationOwnerStep,settleTaskAgentInvocationStep};
@@ -0,0 +1,11 @@
1
+ /** Derives the one deterministic identity shared by subagent receipts and dispatch. */
2
+ export declare function createSubagentReceiptIdentity(input: {
3
+ readonly callId: string;
4
+ readonly parentSessionId: string;
5
+ readonly parentTurnId: string;
6
+ readonly subagentName: string;
7
+ readonly nodeId: string;
8
+ }): {
9
+ readonly identity: import("../../../subagents/handles/store.ts").AgentIdentity;
10
+ readonly operation: import("../../../subagents/handles/store.ts").StartOperation;
11
+ };
@@ -0,0 +1 @@
1
+ import{mintStartOperation}from"#execution/dispatch-start-operation.js";function createSubagentReceiptIdentity(e){return mintStartOperation({callId:e.callId,name:e.subagentName,nodeId:e.nodeId,parentSessionId:e.parentSessionId,parentTurnId:e.parentTurnId})}export{createSubagentReceiptIdentity};
@@ -1,10 +1,22 @@
1
1
  import type { ActivityObserverConfig } from "#channel/types.js";
2
2
  import type { LocalDevRequestProvenance } from "#context/keys.js";
3
- import type { DispatchOutcome, RuntimeSession } from "#execution/agent-handle-dispatch.js";
4
- import type { DispatchStartTarget } from "#execution/dispatch-runtime-actions-shared.js";
5
- import { buildSubagentRunInput } from "#execution/subagent-tool.js";
6
3
  import type { ActivityWorkIdentityV1 } from "#protocol/activity.js";
4
+ import type { DynamicSubagentAgentConfig } from "#runtime/subagents/dynamic-agent-config.js";
5
+ import type { DynamicRemoteAgentConfig } from "#runtime/subagents/dynamic-remote-agent-config.js";
7
6
  import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
7
+ import type { RuntimeRemoteAgentDispatchRequest, RuntimeSubagentDispatchRequest } from "#shared/action-types.js";
8
+ import type { DispatchOutcome, RuntimeSession } from "#subagents/handle-dispatch.js";
9
+ import { buildSubagentRunInput, type SubagentInputSource } from "#subagents/tool.js";
10
+ export type SubagentStartTarget = {
11
+ readonly kind: "local";
12
+ readonly action: RuntimeSubagentDispatchRequest;
13
+ readonly dynamicSubagentAgentConfig?: DynamicSubagentAgentConfig;
14
+ readonly source: SubagentInputSource;
15
+ } | {
16
+ readonly kind: "remote";
17
+ readonly action: RuntimeRemoteAgentDispatchRequest;
18
+ readonly dynamicRemoteAgent?: DynamicRemoteAgentConfig;
19
+ };
8
20
  /** Starts one planned fresh child against its local or remote target. */
9
21
  export declare function startSubagent(input: {
10
22
  readonly auth: Parameters<typeof buildSubagentRunInput>[0]["auth"];
@@ -28,6 +40,6 @@ export declare function startSubagent(input: {
28
40
  readonly sandboxSessionId: string;
29
41
  readonly serializedContext: Record<string, unknown>;
30
42
  readonly session: RuntimeSession;
31
- readonly taskOwned: boolean;
32
- readonly target: DispatchStartTarget;
43
+ readonly taskId?: string;
44
+ readonly target: SubagentStartTarget;
33
45
  }): Promise<DispatchOutcome>;
@@ -0,0 +1 @@
1
+ import{normalizeChannelAudience}from"#shared/channel-audience.js";import{applyLiveDeliveryAudienceCeiling,readForwardedTraceAssertion}from"#shared/forwarded-trace-policy.js";import"#subagents/tool.js";import{readActionTraceContext}from"#tracing/agent-trace-context-store.js";import{startLocalSubagent}from"#subagents/start-local.js";import{startRemoteSubagent}from"#subagents/start-remote.js";async function startSubagent(e){let t=readActionTraceContext(e.serializedContext,e.session.sessionId,e.batchEvent.turnId,e.target.action.callId)??e.parentTraceContext,n=readForwardedTraceAssertion(t?.forwardedTracePolicy),r=normalizeChannelAudience(e.channelMetadata?.metadata.audience),i=t?.decision===void 0?t:{...t,decision:applyLiveDeliveryAudienceCeiling(t.decision,r,n)};switch(e.target.kind){case`local`:return startLocalSubagent({action:e.target.action,auth:e.auth,batchEvent:e.batchEvent,bundle:e.bundle,capabilities:e.capabilities,channelMetadata:e.channelMetadata,currentSession:e.currentSession,dynamicSubagentAgentConfig:e.target.dynamicSubagentAgentConfig,fanoutSize:e.fanoutSize,initiatorAuth:e.initiatorAuth,localDevRequest:e.localDevRequest,parentContinuationToken:e.parentContinuationToken,parentTraceContext:i,activityObserver:e.activityObserver,sandboxSessionId:e.sandboxSessionId,session:e.session,source:e.target.source,taskId:e.taskId});case`remote`:return startRemoteSubagent({action:e.target.action,auth:e.auth,batchEvent:e.batchEvent,bundle:e.bundle,callbackBaseUrl:e.callbackBaseUrl,originAudience:n?.originAudience??r,currentSession:e.currentSession,dynamicRemoteAgent:e.target.dynamicRemoteAgent,initiatorAuth:e.initiatorAuth,parentContinuationToken:e.parentContinuationToken,parentTraceContext:i,activityObserver:e.activityObserver,session:e.session,taskId:e.taskId});default:return e.target}}export{startSubagent};
@@ -0,0 +1,24 @@
1
+ import type { DurableSessionState } from "#execution/durable-session-store.js";
2
+ import type { TaskAgentRequestDelivery } from "#tasks/types.js";
3
+ export interface AgentRequestDelivery {
4
+ readonly accumulateUsage?: boolean;
5
+ readonly ownerId: string;
6
+ readonly replyTo: TaskAgentRequestDelivery["replyTo"];
7
+ readonly request: TaskAgentRequestDelivery["request"];
8
+ readonly taskId?: string;
9
+ }
10
+ export interface TaskAgentRequestContext {
11
+ readonly parentWritable: WritableStream<Uint8Array>;
12
+ readonly serializedContext: Record<string, unknown>;
13
+ readonly sessionState: DurableSessionState;
14
+ }
15
+ export interface AppliedTaskAgentRequest {
16
+ readonly serializedContext: Record<string, unknown>;
17
+ readonly sessionState: DurableSessionState;
18
+ }
19
+ /**
20
+ * Applies one workflow-owned agent request to the parent session: `agent-invoke`
21
+ * spawns the child with parent-owned material and `agent-settled` releases the
22
+ * handle. Child authorization and HITL ride their own task envelope arms.
23
+ */
24
+ export declare function applyTaskAgentRequest(delivery: AgentRequestDelivery, ctx: TaskAgentRequestContext): Promise<AppliedTaskAgentRequest>;
@@ -0,0 +1 @@
1
+ import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{emitTaskSubagentCalledStep}from"#execution/tools/subagent/emit-called-step.js";import{dispatchTaskAgentInvocationStep,settleTaskAgentInvocationStep}from"#execution/tools/subagent/invoke-step.js";async function applyTaskAgentRequest(n,r){let{request:i}=n;switch(i.kind){case`agent-settled`:{let e=await settleTaskAgentInvocationStep({accumulateUsage:n.accumulateUsage,ownerId:n.ownerId,result:i.result,sessionState:r.sessionState,taskId:n.taskId});return{serializedContext:r.serializedContext,sessionState:e.sessionState}}case`agent-invoke`:{let t=await dispatchTaskAgentInvocationStep({ownerId:n.ownerId,replyTo:n.replyTo,request:i,serializedContext:r.serializedContext,sessionState:r.sessionState,taskId:n.taskId});switch(t.kind){case`dispatched`:return{serializedContext:(await emitTaskSubagentCalledStep({event:t.event,parentWritable:r.parentWritable,serializedContext:r.serializedContext})).serializedContext,sessionState:t.sessionState};case`failed`:return await resumeHookStep(n.replyTo,{kind:`runtime-action-result`,results:[t.result]}),{serializedContext:r.serializedContext,sessionState:t.sessionState};case`not-admitted`:return{serializedContext:r.serializedContext,sessionState:t.sessionState}}}}}export{applyTaskAgentRequest};
@@ -0,0 +1,10 @@
1
+ import type { TaskExecutorCancel } from "#execution/tasks/parent/task-cancel.js";
2
+ import { type DurableSessionState } from "#execution/durable-session-store.js";
3
+ /** Cancels the active child turn owned by a background subagent task. */
4
+ export declare const cancelBackgroundAgentTask: TaskExecutorCancel;
5
+ /** Cancels a child turn still claimed by a completed workflow-tool run. */
6
+ export declare function cancelAgentInvocationOwnerStep(input: {
7
+ readonly ownerId: string;
8
+ readonly serializedContext: Record<string, unknown>;
9
+ readonly sessionState: DurableSessionState;
10
+ }): Promise<void>;
@@ -0,0 +1 @@
1
+ import{createLogger,logError}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{requestWorkflowTurnCancellation}from"#execution/workflow-runtime.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{cancelRemoteAgentTurn,resolveRemoteAgentForAction}from"#subagents/remote-dispatch.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";const log=createLogger(`execution.agent-invocation-cancel`),cancelBackgroundAgentTask=async e=>{if(e.session===void 0||e.serializedContext===void 0)return;let t=e.session,i=getAgentHandleStore(t.state)?.handles.find(t=>t.phase===`claimed`&&t.ownerId===e.entry.taskId);if(i===void 0||i.phase!==`claimed`)return;if(i.address.kind!==`agent/remote`){await requestWorkflowTurnCancellation({sessionId:i.address.sessionId});return}let a=await deserializeContext(e.serializedContext),o=a.require(BundleKey),s=getDynamicSubagentSelection(a,i.identity.nodeId);await cancelRemoteAgentTurn({remote:{...resolveRemoteAgentForAction({dynamicRemoteAgent:s?.kind===`remote`?s.remoteAgent:void 0,nodeId:i.identity.nodeId,registry:o.subagentRegistry.subagentsByNodeId,remoteAgentName:i.identity.name}),url:i.address.url},sessionId:i.address.sessionId})};async function cancelAgentInvocationOwnerStep(e){"use step";let o=(getAgentHandleStore((await readDurableSession(e.sessionState)).state)?.handles??[]).filter(t=>t.phase===`claimed`&&t.ownerId===e.ownerId);if(o.length===0)return;let s=o.some(e=>e.address.kind===`agent/remote`)?await deserializeContext(e.serializedContext):void 0;await Promise.all(o.map(async r=>{try{if(r.address.kind!==`agent/remote`){await requestWorkflowTurnCancellation({sessionId:r.address.sessionId});return}let e=s.require(BundleKey),t=getDynamicSubagentSelection(s,r.identity.nodeId);await cancelRemoteAgentTurn({remote:{...resolveRemoteAgentForAction({dynamicRemoteAgent:t?.kind===`remote`?t.remoteAgent:void 0,nodeId:r.identity.nodeId,registry:e.subagentRegistry.subagentsByNodeId,remoteAgentName:r.identity.name}),url:r.address.url},sessionId:r.address.sessionId})}catch(n){logError(log,`failed to cancel workflow-owned agent turn`,n,{agentId:r.identity.id,childSessionId:r.address.sessionId,ownerId:e.ownerId})}}))}export{cancelAgentInvocationOwnerStep,cancelBackgroundAgentTask};
@@ -0,0 +1,10 @@
1
+ import type { HarnessToolDefinition } from "#harness/execute-tool.js";
2
+ /**
3
+ * Builds harness definitions for the compiled framework task tools.
4
+ */
5
+ export declare function createTaskToolHarnessDefinitions(): readonly HarnessToolDefinition[];
6
+ /**
7
+ * Authored tools with the same name shadow these framework definitions,
8
+ * and `disableTool(name)` removes individual controls. advertised-tools
9
+ * evaluates their selected availability against persisted session metadata.
10
+ */
@@ -0,0 +1 @@
1
+ import{TASK_CANCEL_INPUT_SCHEMA,TASK_CANCEL_TOOL_NAME,TASK_UPDATE_INPUT_SCHEMA,TASK_UPDATE_TOOL_NAME,TASK_VIEWS_OUTPUT_SCHEMA}from"#tools/framework/task-contract.js";function createTaskToolHarnessDefinitions(){return[{description:`Request cooperative cancellation of one or more background tasks. Cancellation is final: a task that finishes after you cancel it stays cancelled. Cancelling an already-finished task changes nothing.`,inputSchema:TASK_CANCEL_INPUT_SCHEMA,name:TASK_CANCEL_TOOL_NAME,outputSchema:TASK_VIEWS_OUTPUT_SCHEMA,runtimeAction:{kind:`task-control`}},{description:`Briefly tell the parent agent what this background task is currently doing. Report activity, not preliminary findings or results.`,inputSchema:TASK_UPDATE_INPUT_SCHEMA,name:TASK_UPDATE_TOOL_NAME,runtimeAction:{kind:`task-control`}}]}export{createTaskToolHarnessDefinitions};
@@ -1,3 +1,3 @@
1
1
  import type { InputResponse } from "#shared/input.js";
2
2
  /** Resumed with the bare response, not a session-inbox delivery, so the body can race the hook. */
3
- export declare function resumeToolRunAnswers(answerToken: string, responses: readonly InputResponse[] | undefined): Promise<void>;
3
+ export declare function resumeWorkflowToolRunAnswers(answerToken: string, responses: readonly InputResponse[] | undefined): Promise<void>;
@@ -0,0 +1 @@
1
+ import{resumeHook}from"#internal/workflow/runtime.js";async function resumeWorkflowToolRunAnswers(e,t){for(let n of t??[])await resumeHook(e,{optionId:n.optionId,text:n.text})}export{resumeWorkflowToolRunAnswers};
@@ -0,0 +1,22 @@
1
+ import { type Hook } from "#compiled/@workflow/core/index.js";
2
+ import type { WorkflowToolRunOwner, WorkflowToolRunRef } from "#execution/tools/workflow/messages.js";
3
+ import type { ToolContext, ToolInputRequest, ToolInputResponse } from "#tools/definition.js";
4
+ interface WorkflowToolRunContext {
5
+ /** Compatibility for already-started two-run background workflows. */
6
+ readonly admission?: Promise<{
7
+ readonly status: "accepted";
8
+ } | {
9
+ readonly status: "rejected";
10
+ readonly reason: string;
11
+ }>;
12
+ answerSeq: number;
13
+ readonly from: WorkflowToolRunRef;
14
+ readonly owner: WorkflowToolRunOwner;
15
+ }
16
+ export declare function attachWorkflowToolRunContext(ctx: ToolContext, context: Omit<WorkflowToolRunContext, "answerSeq">): void;
17
+ export declare function readWorkflowToolRunRef(ctx: ToolContext): WorkflowToolRunRef;
18
+ export declare function readWorkflowToolRunOwner(ctx: ToolContext): WorkflowToolRunOwner;
19
+ export declare function readWorkflowToolRunAdmission(ctx: ToolContext): WorkflowToolRunContext["admission"];
20
+ /** Returns an answer hook which may be awaited or raced with another workflow operation. */
21
+ export declare function ask(ctx: ToolContext, request: ToolInputRequest): Hook<ToolInputResponse>;
22
+ export {};
@@ -0,0 +1 @@
1
+ import{createHook}from"#compiled/@workflow/core/index.js";import{workflowToolRunAnswerToken}from"#harness/workflow-tool-runs.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";const WORKFLOW_TOOL_RUN_CONTEXT=Symbol.for(`eve.workflow-tool-run.context`);function attachWorkflowToolRunContext(e,t){Object.defineProperty(e,WORKFLOW_TOOL_RUN_CONTEXT,{enumerable:!1,value:{...t,answerSeq:0}})}function readWorkflowToolRunContext(e){let t=e[WORKFLOW_TOOL_RUN_CONTEXT];if(t===void 0)throw Error(`This function must be called with the context of a workflow tool body ("use workflow").`);return t}function readWorkflowToolRunRef(e){return readWorkflowToolRunContext(e).from}function readWorkflowToolRunOwner(e){return readWorkflowToolRunContext(e).owner}function readWorkflowToolRunAdmission(e){return readWorkflowToolRunContext(e).admission}function ask(n,r){let i=readWorkflowToolRunContext(n),a=createHook({token:workflowToolRunAnswerToken(i.from.runId,i.answerSeq++)});return resumeHookStep(i.owner.request,{from:i.from,replyTo:a.token,request:{kind:`ask`,request:r}}),a}export{ask,attachWorkflowToolRunContext,readWorkflowToolRunAdmission,readWorkflowToolRunOwner,readWorkflowToolRunRef};
@@ -0,0 +1,18 @@
1
+ import type { HarnessToolDefinition } from "#harness/execute-tool.js";
2
+ import type { PreparedRuntimeTool } from "#runtime/sessions/turn.js";
3
+ import { parseJsonObject, type JsonValue } from "#shared/json.js";
4
+ export interface WorkflowToolHarnessDefinitionInput {
5
+ readonly definition: HarnessToolDefinition;
6
+ readonly executeInput?: (input: unknown) => JsonValue;
7
+ readonly nodeId?: string;
8
+ readonly resultKind?: "subagent" | "tool";
9
+ readonly workflowId: string;
10
+ }
11
+ export declare function createWorkflowToolHarnessDefinition(input: WorkflowToolHarnessDefinitionInput): HarnessToolDefinition;
12
+ export declare function createPreparedWorkflowToolHarnessDefinition(tool: PreparedRuntimeTool): HarnessToolDefinition;
13
+ /** Returns a task receipt after the background scope starts the owning run. */
14
+ export declare function createWorkflowToolBackgroundExecute(input: {
15
+ readonly toolName: string;
16
+ readonly workflowId: string;
17
+ }): NonNullable<HarnessToolDefinition["execute"]>;
18
+ export declare function parseWorkflowToolInput(toolInput: unknown, toolName: string): ReturnType<typeof parseJsonObject>;
@@ -0,0 +1 @@
1
+ import{UNSPECIFIED_INPUT_SCHEMA,toInputSchema,toOutputSchema}from"#tools/schema.js";import{parseJsonObject}from"#shared/json.js";function createWorkflowToolHarnessDefinition(e){let t=e.definition,n={executeInput:e.executeInput,nodeId:e.nodeId,resultKind:e.resultKind,workflowId:e.workflowId};return t.execution===`background`?{...t,...n,execute:createWorkflowToolBackgroundExecute({toolName:t.name,workflowId:e.workflowId})}:{...t,...n,execute:void 0}}function createPreparedWorkflowToolHarnessDefinition(r){if(r.task===void 0)throw Error(`Prepared tool "${r.name}" is not backed by a workflow task.`);return createWorkflowToolHarnessDefinition({definition:{behavior:r.behavior,description:r.description,execution:r.execution,inputSchema:toInputSchema(r.inputSchema)??UNSPECIFIED_INPUT_SCHEMA,name:r.name,outputSchema:toOutputSchema(r.outputSchema),rootOnly:r.rootOnly},nodeId:r.task.nodeId,resultKind:r.task.resultKind,workflowId:r.task.workflowId})}function createWorkflowToolBackgroundExecute(e){return(t,n,r)=>{throw Error(`Background workflow tool "${e.toolName}" must be started by the task runtime (${e.workflowId}).`)}}function parseWorkflowToolInput(e,t){try{return parseJsonObject(e)}catch(e){throw TypeError(`Tool "${t}" is a workflow, so its parsed input must be a JSON object.`,{cause:e})}}export{createPreparedWorkflowToolHarnessDefinition,createWorkflowToolBackgroundExecute,createWorkflowToolHarnessDefinition,parseWorkflowToolInput};
@@ -0,0 +1,25 @@
1
+ import type { SessionContext } from "#context/session-context.js";
2
+ import { type WorkflowToolRunOutcome, type WorkflowToolRunOwner, type WorkflowToolRunRef } from "#execution/tools/workflow/messages.js";
3
+ import type { JsonObject, JsonValue } from "#shared/json.js";
4
+ export interface WorkflowBodyDefinition {
5
+ readonly callId: string;
6
+ readonly executeInput?: JsonValue;
7
+ readonly input: JsonObject;
8
+ readonly resultKind?: "subagent" | "tool";
9
+ readonly session: SessionContext["session"];
10
+ readonly stepIndex: number;
11
+ readonly toolName: string;
12
+ readonly workflowId: string;
13
+ }
14
+ export interface WorkflowBodyInput extends WorkflowBodyDefinition {
15
+ readonly owner: WorkflowToolRunOwner;
16
+ }
17
+ /** Executes one registered workflow body and reports progress to its owner. */
18
+ export declare function executeWorkflowBody(input: WorkflowBodyInput & {
19
+ readonly execution: "background" | "blocking";
20
+ readonly runId?: string;
21
+ }, signal: AbortSignal): Promise<WorkflowToolRunOutcome>;
22
+ export declare function createWorkflowBodyRef(input: WorkflowBodyDefinition & {
23
+ readonly execution: "background" | "blocking";
24
+ readonly runId?: string;
25
+ }): WorkflowToolRunRef;
@@ -0,0 +1 @@
1
+ import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import"#execution/tools/workflow/messages.js";import{attachWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{readRegisteredWorkflow}from"#execution/workflow-registry.js";async function executeWorkflowBody(e,i){let a=createWorkflowBodyRef(e),o=createWorkflowBodyContext(e,i);attachWorkflowToolRunContext(o,{from:a,owner:e.owner});try{let t=resolveWorkflowToolExecute(e)(e.executeInput??e.input,o),r;if(!isAsyncIterable(t))r=await t;else{let i=t[Symbol.asyncIterator](),o,s=await i.next();for(;s.done!==!0;){o=s.value;let t={from:a,update:s.value};await resumeHookStep(e.owner.report,t),s=await i.next()}r=s.value??o??null}return{output:r,status:`completed`}}catch(e){return i.aborted?{reason:i.reason instanceof Error?i.reason.message:String(i.reason??``),status:`cancelled`}:{error:normalizeSerializableError(e),status:`failed`}}}function createWorkflowBodyRef(t){return{callId:t.callId,execution:t.execution,input:t.input,resultKind:t.resultKind,runId:t.runId??getWorkflowMetadata().workflowRunId,sequence:t.session.turn.sequence,stepIndex:t.stepIndex,toolName:t.toolName,turnId:t.session.turn.id}}function resolveWorkflowToolExecute(e){let t=readRegisteredWorkflow(e.workflowId);if(typeof t!=`function`)throw Error(`Tool "${e.toolName}" is not registered as a workflow in this deployment (${e.workflowId}). The tool was renamed or removed after this run started.`);return t}function createWorkflowBodyContext(e,t){let unavailable=(t,n)=>{throw Error(`ctx.${t} is not available inside a workflow tool; ${n}. Tool "${e.toolName}" runs as a durable workflow body, which only replays deterministic code.`)};return{abortSignal:t,callId:e.callId,getSandbox:()=>unavailable(`getSandbox()`,`the session sandbox belongs to the turn`),getSkill:()=>unavailable(`getSkill()`,`skills are read through the session sandbox`),getToken:()=>unavailable(`getToken()`,`read credentials from the environment inside a "use step" helper`),requireAuth:()=>unavailable(`requireAuth()`,`a workflow body cannot park on authorization`),session:e.session,toolName:e.toolName}}function isAsyncIterable(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}export{createWorkflowBodyRef,executeWorkflowBody};
@@ -0,0 +1,11 @@
1
+ import type { WorkflowToolRunAddress } from "#execution/tools/workflow/types.js";
2
+ /**
3
+ * Asks the run to cancel itself; cancels it outright only if the message cannot
4
+ * be delivered. Failures are logged, not thrown: the caller has already
5
+ * committed the cancellation the run was serving.
6
+ */
7
+ export declare function cancelWorkflowToolRun(run: WorkflowToolRunAddress, reason: string): Promise<void>;
8
+ export declare function cancelWorkflowToolRunStep(input: {
9
+ readonly reason: string;
10
+ readonly run: WorkflowToolRunAddress;
11
+ }): Promise<void>;
@@ -0,0 +1 @@
1
+ import{createLogger,logError}from"#internal/logging.js";import{cancelRun,getWorld,resumeHook}from"#internal/workflow/runtime.js";import{isTaskWorkflowTargetGone}from"#execution/tasks/workflow-target.js";const log=createLogger(`execution.workflow-tool-run`);async function cancelWorkflowToolRun(e,n){let r={kind:`cancel`,reason:n};try{await resumeHook(e.hookToken,r);return}catch(t){if(isTaskWorkflowTargetGone(t))return;logError(log,`failed to signal a workflow tool run to cancel; cancelling it outright`,t,{runId:e.runId})}try{await cancelRun(await getWorld(),e.runId,{cancelReason:n})}catch(t){if(isTaskWorkflowTargetGone(t))return;logError(log,`failed to cancel workflow tool run; it may run to completion`,t,{runId:e.runId})}}async function cancelWorkflowToolRunStep(e){"use step";await cancelWorkflowToolRun(e.run,e.reason)}export{cancelWorkflowToolRun,cancelWorkflowToolRunStep};
@@ -0,0 +1,7 @@
1
+ import type { WorkflowToolRunRef } from "#execution/tools/workflow/messages.js";
2
+ import type { JsonValue } from "#shared/json.js";
3
+ export declare function emitWorkflowToolRunReportStep(input: {
4
+ readonly from: WorkflowToolRunRef;
5
+ readonly parentWritable: WritableStream<Uint8Array>;
6
+ readonly update: JsonValue;
7
+ }): Promise<void>;
@@ -0,0 +1 @@
1
+ import{createActionPartialEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";async function emitWorkflowToolRunReportStep(e){"use step";let t=createActionPartialEvent({result:createRuntimeToolResultFromValue({callId:e.from.callId,output:e.update,toolName:e.from.toolName}),sequence:e.from.sequence,stepIndex:e.from.stepIndex,turnId:e.from.turnId}),n=e.parentWritable.getWriter();try{await n.write(encodeMessageStreamEvent(stampMessageStreamEvent(t)))}finally{n.releaseLock()}}export{emitWorkflowToolRunReportStep};
@@ -0,0 +1,88 @@
1
+ import type { SubagentAuthorizationEventHookPayload } from "#channel/types.js";
2
+ import type { AgentInvocationRequest, AgentSettlementRequest } from "#execution/tools/subagent/invoke-agent.js";
3
+ import type { InputRequest } from "#shared/input.js";
4
+ import type { JsonObject, JsonValue } from "#shared/json.js";
5
+ import type { ToolInputRequest } from "#tools/definition.js";
6
+ export interface WorkflowToolRunOwner {
7
+ readonly admission: string;
8
+ readonly outcome: string;
9
+ readonly report: string;
10
+ readonly request: string;
11
+ }
12
+ /**
13
+ * Requests the owner must apply on the run's behalf because they touch
14
+ * owner-held state: spawning an agent and releasing its handle afterwards.
15
+ */
16
+ export type WorkflowToolAgentRequest = AgentInvocationRequest | AgentSettlementRequest;
17
+ /**
18
+ * A child authorization event the owner should display. Unlike input requests
19
+ * it has no answer: the authorization callback completes against the child
20
+ * directly, so the owner only re-emits it.
21
+ */
22
+ export interface WorkflowToolAuthorizationRequest {
23
+ readonly event: SubagentAuthorizationEventHookPayload;
24
+ readonly kind: "authorization-request";
25
+ }
26
+ /** A question authored with `ask()` from `eve/workflow`, before owner normalization. */
27
+ export interface WorkflowToolAskRequest {
28
+ readonly kind: "ask";
29
+ readonly request: ToolInputRequest;
30
+ }
31
+ /**
32
+ * A child subagent's pending input requests for one step, forwarded as a unit
33
+ * so the owner resolves them against the same child step they came from.
34
+ */
35
+ export interface WorkflowToolInputRequestBatch {
36
+ readonly kind: "input-batch";
37
+ readonly requests: readonly InputRequest[];
38
+ }
39
+ export type WorkflowToolRequest = WorkflowToolAgentRequest | WorkflowToolAuthorizationRequest | WorkflowToolAskRequest | InputRequest | WorkflowToolInputRequestBatch;
40
+ /** Identifies the sending workflow tool run to an owner shared by many runs. */
41
+ export interface WorkflowToolRunRef {
42
+ readonly callId: string;
43
+ readonly execution: "background" | "blocking";
44
+ readonly input: JsonObject;
45
+ readonly resultKind?: "subagent" | "tool";
46
+ readonly runId: string;
47
+ readonly sequence: number;
48
+ readonly stepIndex: number;
49
+ readonly toolName: string;
50
+ readonly turnId: string;
51
+ }
52
+ export type WorkflowToolRunOutcome = {
53
+ readonly status: "completed";
54
+ readonly output: JsonValue;
55
+ } | {
56
+ readonly status: "failed";
57
+ readonly error: unknown;
58
+ } | {
59
+ readonly status: "cancelled";
60
+ readonly reason?: string;
61
+ };
62
+ export interface WorkflowToolRunReport {
63
+ readonly from: WorkflowToolRunRef;
64
+ readonly update: JsonValue;
65
+ }
66
+ export interface WorkflowToolRunRequestMessage {
67
+ readonly from: WorkflowToolRunRef;
68
+ readonly replyTo: string;
69
+ readonly request: WorkflowToolRequest;
70
+ readonly requestCoordinates?: {
71
+ readonly sequence: number;
72
+ readonly stepIndex: number;
73
+ readonly turnId: string;
74
+ };
75
+ }
76
+ export interface WorkflowToolRunOutcomeMessage {
77
+ readonly from: WorkflowToolRunRef;
78
+ readonly result: WorkflowToolRunOutcome;
79
+ }
80
+ export declare const workflowToolRunReportHook: import("#compiled/@workflow/core/index.js").TypedHook<WorkflowToolRunReport, WorkflowToolRunReport>;
81
+ export declare const workflowToolRunRequestHook: import("#compiled/@workflow/core/index.js").TypedHook<WorkflowToolRunRequestMessage, WorkflowToolRunRequestMessage>;
82
+ export declare const workflowToolRunOutcomeHook: import("#compiled/@workflow/core/index.js").TypedHook<WorkflowToolRunOutcomeMessage, WorkflowToolRunOutcomeMessage>;
83
+ export declare function deriveWorkflowToolRunOwner(inboxToken: string): WorkflowToolRunOwner;
84
+ export type WorkflowToolRunControlMessage = {
85
+ readonly kind: "cancel";
86
+ readonly reason: string;
87
+ };
88
+ export declare function isWorkflowToolRunControlMessage(value: unknown): value is WorkflowToolRunControlMessage;
@@ -0,0 +1 @@
1
+ import{defineHook}from"#compiled/@workflow/core/index.js";const workflowToolRunReportHook=defineHook(),workflowToolRunRequestHook=defineHook(),workflowToolRunOutcomeHook=defineHook();function deriveWorkflowToolRunOwner(e){return{admission:`${e}:admission`,outcome:`${e}:outcome`,report:`${e}:report`,request:`${e}:request`}}function isWorkflowToolRunControlMessage(e){if(typeof e!=`object`||!e)return!1;let{kind:t,reason:n}=e;return t===`cancel`&&typeof n==`string`}export{deriveWorkflowToolRunOwner,isWorkflowToolRunControlMessage,workflowToolRunOutcomeHook,workflowToolRunReportHook,workflowToolRunRequestHook};
@@ -0,0 +1,13 @@
1
+ import type { SubagentInputRequestHookPayload } from "#channel/types.js";
2
+ import type { WorkflowToolRunOutcomeMessage, WorkflowToolRunReport, WorkflowToolRunRequestMessage } from "#execution/tools/workflow/messages.js";
3
+ import type { RuntimeToolResultActionResult } from "#shared/action-types.js";
4
+ import type { RuntimeSubagentResult } from "#shared/action-types.js";
5
+ import type { WorkflowToolRunTaskInputRequest } from "#execution/tasks/child/workflow.js";
6
+ import type { TaskCommand, TaskInboundUpdate } from "#tasks/types.js";
7
+ export declare function workflowToolRunOutcomeToToolResult(message: WorkflowToolRunOutcomeMessage): RuntimeToolResultActionResult;
8
+ /** Reads a blocking agent result returned through an ordinary run outcome. */
9
+ export declare function workflowToolRunOutcomeToSubagentResult(message: WorkflowToolRunOutcomeMessage): RuntimeSubagentResult;
10
+ export declare function workflowToolRunOutcomeToTaskCommand(message: WorkflowToolRunOutcomeMessage): TaskCommand;
11
+ export declare function workflowToolRunReportToTaskUpdate(report: WorkflowToolRunReport, taskId: string, updateIndex: number): TaskInboundUpdate;
12
+ export declare function workflowToolRunRequestToInputRequestPayload(message: WorkflowToolRunRequestMessage): SubagentInputRequestHookPayload;
13
+ export declare function workflowToolRunRequestToTaskInputRequest(message: WorkflowToolRunRequestMessage): WorkflowToolRunTaskInputRequest;
@@ -0,0 +1 @@
1
+ import{parseJsonValue}from"#shared/json.js";import{SUBAGENT_EXECUTION_FAILED}from"#subagents/agent-handle-errors.js";function workflowToolRunOutcomeToToolResult(e){let{from:t,result:n}=e;return n.status===`completed`?{callId:t.callId,kind:`tool-result`,output:n.output,toolName:t.toolName}:{callId:t.callId,isError:!0,kind:`tool-result`,output:n.status===`failed`?errorMessage(n.error):n.reason??`The workflow tool run was cancelled.`,toolName:t.toolName}}function workflowToolRunOutcomeToSubagentResult(e){if(e.result.status===`completed`&&isRuntimeSubagentResult(e.result.output))return e.result.output;let t=e.result.status===`failed`?errorMessage(e.result.error):e.result.status===`cancelled`?e.result.reason??`The agent invocation was cancelled.`:`The agent invocation returned an invalid result.`;return{callId:e.from.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:t,subagentName:e.from.toolName}}function workflowToolRunOutcomeToTaskCommand(e){return e.result.status===`completed`?{data:e.result.output,kind:`complete`}:e.result.status===`failed`?{data:e.from.resultKind===`subagent`?subagentFailureOutput(e.result.error):errorMessage(e.result.error),kind:`fail`}:{kind:`cancel`}}function subagentFailureOutput(e){let n=parseJsonValueOrUndefined(e);return n!==void 0&&typeof n==`object`&&n&&!Array.isArray(n)&&typeof Reflect.get(n,`code`)==`string`?n:{code:SUBAGENT_EXECUTION_FAILED,message:errorMessage(e)}}function workflowToolRunReportToTaskUpdate(e,t,n){return{callId:e.from.callId,kind:`task-update`,message:typeof e.update==`string`?e.update:JSON.stringify(e.update),updateEpoch:t,updateIndex:n}}function isRuntimeSubagentResult(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`origin`);return Reflect.get(e,`kind`)===`subagent-result`&&(t===`child`||t===`dispatch`)}function errorMessage(e){if(typeof e==`object`&&e&&`message`in e){let t=e.message;if(typeof t==`string`)return t}return String(e)}function parseJsonValueOrUndefined(t){try{return parseJsonValue(t)}catch{return}}function workflowToolRunRequestToInputRequestPayload(e){let{from:t,replyTo:n,request:r,requestCoordinates:i}=e;return{callId:t.callId,childContinuationToken:n,childSessionId:t.runId,event:{requests:r.kind===`input-batch`?r.requests:[normalizeInputRequest(r,t,n)],sequence:i?.sequence??t.sequence,stepIndex:i?.stepIndex??t.stepIndex,turnId:i?.turnId??t.turnId},kind:`subagent-input-request`,subagentName:t.toolName}}function workflowToolRunRequestToTaskInputRequest(e){let{from:t,replyTo:n,request:r,requestCoordinates:i}=e,a={kind:`task-input-request`,replyTo:n,sequence:i?.sequence??t.sequence,stepIndex:i?.stepIndex??t.stepIndex,turnId:i?.turnId??t.turnId};return r.kind===`input-batch`?{...a,requests:r.requests}:{...a,request:normalizeInputRequest(r,t,n)}}function normalizeInputRequest(e,t,n){switch(e.kind){case`agent-invoke`:case`agent-settled`:throw TypeError(`A workflow agent request cannot be normalized as human input.`);case`authorization-request`:throw TypeError(`A workflow authorization event cannot be normalized as human input.`);case`ask`:return normalizeAskRequest(e.request,t,n);default:return e}}function normalizeAskRequest(e,t,n){if(typeof e.prompt!=`string`||e.prompt.length===0)throw TypeError("A workflow tool run request needs a non-empty `prompt`.");let r={action:{callId:t.callId,input:t.input,kind:`tool-call`,toolName:t.toolName},kind:`question`,prompt:e.prompt,requestId:n};return e.allowFreeform!==void 0&&(r.allowFreeform=e.allowFreeform),e.display!==void 0&&(r.display=e.display),e.options!==void 0&&(r.options=[...e.options]),r}export{workflowToolRunOutcomeToSubagentResult,workflowToolRunOutcomeToTaskCommand,workflowToolRunOutcomeToToolResult,workflowToolRunReportToTaskUpdate,workflowToolRunRequestToInputRequestPayload,workflowToolRunRequestToTaskInputRequest};
@@ -0,0 +1,13 @@
1
+ import { type WorkflowToolRunOutcomeMessage, type WorkflowToolRunReport, type WorkflowToolRunRequestMessage } from "#execution/tools/workflow/messages.js";
2
+ import { type ChannelReader } from "#execution/tools/workflow/owner-channels.js";
3
+ /** In read priority: what a workflow tool run said before its outcome lands first. */
4
+ export type WorkflowToolRunOwnerReaders = readonly [
5
+ ChannelReader<"report", WorkflowToolRunReport>,
6
+ ChannelReader<"request", WorkflowToolRunRequestMessage>,
7
+ ChannelReader<"outcome", WorkflowToolRunOutcomeMessage>
8
+ ];
9
+ export interface WorkflowToolRunOwnerChannels {
10
+ readonly readers: WorkflowToolRunOwnerReaders;
11
+ dispose(): Promise<void>;
12
+ }
13
+ export declare function openWorkflowToolRunOwnerChannels(inboxToken: string): WorkflowToolRunOwnerChannels;
@@ -0,0 +1 @@
1
+ import{disposeHook}from"#execution/hook-ownership.js";import{deriveWorkflowToolRunOwner,workflowToolRunOutcomeHook,workflowToolRunReportHook,workflowToolRunRequestHook}from"#execution/tools/workflow/messages.js";import{createChannelReader}from"#execution/tools/workflow/owner-channels.js";function openWorkflowToolRunOwnerChannels(e){let t=deriveWorkflowToolRunOwner(e),n=workflowToolRunReportHook.create({token:t.report}),r=workflowToolRunRequestHook.create({token:t.request}),i=workflowToolRunOutcomeHook.create({token:t.outcome});return{readers:[createChannelReader(`report`,n),createChannelReader(`request`,r),createChannelReader(`outcome`,i)],async dispose(){await disposeHook(n),await disposeHook(r),await disposeHook(i)}}}export{openWorkflowToolRunOwnerChannels};
@@ -0,0 +1,18 @@
1
+ import { type Hook } from "#compiled/@workflow/core/index.js";
2
+ import { type WorkflowToolRunControlMessage } from "#execution/tools/workflow/messages.js";
3
+ /**
4
+ * The run's control inbox. An unawaited hook read is not scheduled under
5
+ * replay, so `cancelled` must be raced for a cancel to be observed at all.
6
+ */
7
+ export interface WorkflowToolRunControlInbox {
8
+ readonly hook: Hook<WorkflowToolRunControlMessage>;
9
+ readonly signal: AbortSignal;
10
+ /** Rejects with {@link WorkflowToolRunCancelledError} when a cancel message arrives; never resolves. */
11
+ readonly cancelled: Promise<never>;
12
+ reason(): string | undefined;
13
+ }
14
+ /** Opens without claiming, so a losing duplicate start never trips the signal. */
15
+ export declare function openWorkflowToolRunControlInbox(hookToken: string): WorkflowToolRunControlInbox;
16
+ export declare class WorkflowToolRunCancelledError extends Error {
17
+ constructor(reason: string);
18
+ }
@@ -0,0 +1 @@
1
+ import{createHook}from"#compiled/@workflow/core/index.js";import{isWorkflowToolRunControlMessage}from"#execution/tools/workflow/messages.js";function openWorkflowToolRunControlInbox(t){let n=createHook({token:t}),r=n[Symbol.asyncIterator](),i=new AbortController,a,o=consumeCancel(r,e=>{a=e,i.abort(new WorkflowToolRunCancelledError(e))});return o.catch(()=>{}),{cancelled:o,hook:n,reason:()=>a,signal:i.signal}}async function consumeCancel(e,n){for(;;){let r;try{r=await e.next()}catch{return await new Promise(()=>{})}if(r.done===!0)return await new Promise(()=>{});if(isWorkflowToolRunControlMessage(r.value))throw n(r.value.reason),new WorkflowToolRunCancelledError(r.value.reason)}}var WorkflowToolRunCancelledError=class extends Error{constructor(e){super(e),this.name=`WorkflowToolRunCancelledError`}};export{WorkflowToolRunCancelledError,openWorkflowToolRunControlInbox};