eve 0.51.0 → 0.52.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 (462) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/src/channel/session.d.ts +2 -1
  3. package/dist/src/channel/session.js +1 -1
  4. package/dist/src/channel/types.d.ts +4 -1
  5. package/dist/src/chunks/{use-eve-agent-C3vUG5g2.js → use-eve-agent-3DZuvuWE.js} +17 -6
  6. package/dist/src/chunks/{use-eve-agent-B4xN7-fK.js → use-eve-agent-D7apPojZ.js} +17 -6
  7. package/dist/src/cli/agent-command.js +1 -1
  8. package/dist/src/cli/commands/agent-instructions.d.ts +3 -1
  9. package/dist/src/cli/commands/agent-instructions.js +1 -1
  10. package/dist/src/cli/commands/build.js +1 -1
  11. package/dist/src/cli/commands/deploy.js +1 -1
  12. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  13. package/dist/src/cli/commands/init-repl.js +1 -1
  14. package/dist/src/cli/commands/init.js +1 -1
  15. package/dist/src/cli/commands/integration-connect.js +1 -1
  16. package/dist/src/cli/commands/link.js +1 -1
  17. package/dist/src/cli/commands/preconditions.js +1 -1
  18. package/dist/src/cli/commands/register-project-commands.d.ts +1 -1
  19. package/dist/src/cli/commands/register-project-commands.js +1 -1
  20. package/dist/src/cli/commands/registry.js +1 -1
  21. package/dist/src/cli/dev/boot-progress.d.ts +3 -0
  22. package/dist/src/cli/dev/boot-progress.js +1 -0
  23. package/dist/src/cli/dev/environment.js +1 -1
  24. package/dist/src/cli/dev/run-interactive-ui.js +1 -1
  25. package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
  26. package/dist/src/cli/dev/tui/setup-commands.d.ts +3 -1
  27. package/dist/src/cli/dev/tui/setup-commands.js +1 -1
  28. package/dist/src/cli/run.d.ts +4 -0
  29. package/dist/src/cli/run.js +3 -3
  30. package/dist/src/cli/telemetry/command.d.ts +9 -0
  31. package/dist/src/cli/telemetry/command.js +1 -0
  32. package/dist/src/cli/telemetry/flush.d.ts +2 -0
  33. package/dist/src/cli/telemetry/flush.js +1 -0
  34. package/dist/src/cli/telemetry/identity.d.ts +13 -0
  35. package/dist/src/cli/telemetry/identity.js +1 -0
  36. package/dist/src/cli/telemetry/index.d.ts +25 -0
  37. package/dist/src/cli/telemetry/index.js +3 -0
  38. package/dist/src/cli/telemetry/preference.d.ts +9 -0
  39. package/dist/src/cli/telemetry/preference.js +1 -0
  40. package/dist/src/client/open-stream.js +1 -1
  41. package/dist/src/client/session-controls.d.ts +3 -0
  42. package/dist/src/client/session-controls.js +1 -1
  43. package/dist/src/client/session.d.ts +4 -1
  44. package/dist/src/client/types.d.ts +3 -2
  45. package/dist/src/compiled/.vendor-stamp.json +11 -11
  46. package/dist/src/compiled/@clack/core/LICENSE +9 -0
  47. package/dist/src/compiled/@clack/core/index.d.ts +363 -0
  48. package/dist/src/compiled/@clack/core/index.js +20 -0
  49. package/dist/src/compiled/@eve/catalog/index.js +1 -1
  50. package/dist/src/compiled/@modelcontextprotocol/server/index.d.ts +1 -0
  51. package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +34 -92
  52. package/dist/src/compiled/@vercel/sandbox/api-client/base-client.d.ts +1 -1
  53. package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +1 -1
  54. package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +13 -29
  55. package/dist/src/compiled/@vercel/sandbox/constants.d.ts +11 -1
  56. package/dist/src/compiled/@vercel/sandbox/index.d.ts +3 -3
  57. package/dist/src/compiled/@vercel/sandbox/index.js +9 -9
  58. package/dist/src/compiled/@vercel/sandbox/sandbox-user.d.ts +5 -6
  59. package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +79 -67
  60. package/dist/src/compiled/@vercel/sandbox/session.d.ts +5 -3
  61. package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +9 -0
  62. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/api-client.d.ts +86 -1
  63. package/dist/src/compiled/@vercel/sandbox-drives/api-client/index.d.ts +2 -0
  64. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/validators.d.ts +26 -1
  65. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/constants.d.ts +2 -2
  66. package/dist/src/compiled/@vercel/{sandbox → sandbox-drives}/drive.d.ts +10 -0
  67. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/index.d.ts +3 -2
  68. package/dist/src/compiled/@vercel/sandbox-drives/index.js +9 -0
  69. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/sandbox.d.ts +35 -6
  70. package/dist/src/compiled/@workflow/core/index.js +1 -1
  71. package/dist/src/compiled/@workflow/core/private.d.ts +2 -4
  72. package/dist/src/compiled/@workflow/core/private.js +1 -1
  73. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +9 -7
  74. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +13 -0
  75. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +54 -1
  76. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  77. package/dist/src/compiled/@workflow/core/serialization/types.d.ts +7 -0
  78. package/dist/src/compiled/@workflow/core/serialization.d.ts +24 -2
  79. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  80. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  81. package/dist/src/compiled/@workflow/errors/error-codes.d.ts +2 -0
  82. package/dist/src/compiled/@workflow/errors/index.d.ts +19 -0
  83. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  84. package/dist/src/compiled/@workflow/world/analytics.d.ts +46 -2
  85. package/dist/src/compiled/@workflow/world/events.d.ts +26 -1
  86. package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
  87. package/dist/src/compiled/@workflow/world/runs.d.ts +2 -2
  88. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  89. package/dist/src/compiled/@workflow/world-vercel/index.js +12 -12
  90. package/dist/src/compiled/_chunks/node/{auth-BSKyPAEP.js → auth-Bx1Aoyfo.js} +1 -1
  91. package/dist/src/compiled/_chunks/node/{auth-YpKlwhP1.js → auth-CA8ZMfB8.js} +1 -1
  92. package/dist/src/compiled/_chunks/node/esm-CE0tAvRh.js +7 -0
  93. package/dist/src/compiled/_chunks/node/version-BC6t2Txc.js +1 -0
  94. package/dist/src/compiled/_chunks/node/version-DSQqVZ5T.js +1 -0
  95. package/dist/src/compiled/_chunks/workflow/{attribute-changes-BwAadFfB.js → attribute-changes-03lzo29R.js} +1 -1
  96. package/dist/src/compiled/_chunks/workflow/dist-BIdMK5N8.js +40 -0
  97. package/dist/src/compiled/_chunks/workflow/dist-DMQ3CtWt.js +3 -0
  98. package/dist/src/compiled/_chunks/workflow/frames-Boesh7kU.js +3 -0
  99. package/dist/src/compiled/_chunks/workflow/{private-CZFMABEf.js → private-CKx3PkSS.js} +1 -1
  100. package/dist/src/compiled/_chunks/workflow/{resume-hook-BToMtPbH.js → resume-hook-C6eL-S_T.js} +1 -1
  101. package/dist/src/compiled/_chunks/workflow/run-BV0S6Zc2.js +1 -0
  102. package/dist/src/compiled/_chunks/workflow/sleep-Bh3jP9ii.js +1 -0
  103. package/dist/src/compiled/_chunks/workflow/wait-until-l-cwfJvm.js +15 -0
  104. package/dist/src/compiled/_chunks/workflow/{ws-transport-PnVVxT0R.js → ws-transport-BagXNxCE.js} +1 -1
  105. package/dist/src/compiler/compile-from-memory.d.ts +1 -0
  106. package/dist/src/compiler/extension-compatibility.d.ts +38 -20
  107. package/dist/src/compiler/extension-compatibility.js +1 -1
  108. package/dist/src/compiler/manifest.d.ts +2 -2
  109. package/dist/src/compiler/manifest.js +1 -1
  110. package/dist/src/compiler/normalize-agent-config.js +1 -1
  111. package/dist/src/compiler/normalize-channel.js +1 -1
  112. package/dist/src/compiler/normalize-schedule.js +1 -1
  113. package/dist/src/compiler/normalize-tool.js +1 -1
  114. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  115. package/dist/src/discover/extensions.d.ts +2 -0
  116. package/dist/src/discover/extensions.js +1 -1
  117. package/dist/src/discover/filesystem.d.ts +1 -0
  118. package/dist/src/discover/filesystem.js +1 -1
  119. package/dist/src/discover/project.js +1 -1
  120. package/dist/src/evals/runner/execute-task.js +1 -1
  121. package/dist/src/evals/session-cleanup.d.ts +7 -0
  122. package/dist/src/evals/session-cleanup.js +1 -0
  123. package/dist/src/evals/session.d.ts +4 -0
  124. package/dist/src/evals/session.js +1 -1
  125. package/dist/src/eve-channel/index.js +1 -1
  126. package/dist/src/eve-channel/request.d.ts +1 -0
  127. package/dist/src/eve-channel/request.js +1 -1
  128. package/dist/src/execution/activity-collector.js +1 -1
  129. package/dist/src/execution/activity-work.d.ts +8 -0
  130. package/dist/src/execution/activity-work.js +1 -1
  131. package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +6 -0
  132. package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -0
  133. package/dist/src/execution/continuation-conflict-step.js +1 -1
  134. package/dist/src/execution/coordination-dispatch-shared.d.ts +2 -2
  135. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  136. package/dist/src/execution/coordination-dispatch-step.js +1 -1
  137. package/dist/src/execution/create-session-step.js +1 -1
  138. package/dist/src/execution/durable-session-migrations/turn-workflow.d.ts +1 -1
  139. package/dist/src/execution/inline-turn.d.ts +4 -2
  140. package/dist/src/execution/inline-turn.js +1 -1
  141. package/dist/src/execution/next-driver-action.d.ts +0 -3
  142. package/dist/src/execution/parked-delivery-wait.js +1 -1
  143. package/dist/src/execution/proxied-deliver-step.js +1 -1
  144. package/dist/src/execution/run-session-limits.d.ts +5 -5
  145. package/dist/src/execution/sandbox/bindings/vercel-create-sdk.js +1 -1
  146. package/dist/src/execution/sandbox/bindings/vercel-sdk-types.d.ts +4 -4
  147. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  148. package/dist/src/execution/session-activity-projection.js +1 -1
  149. package/dist/src/execution/session-activity.js +1 -1
  150. package/dist/src/execution/session-timeout-workflow.js +1 -1
  151. package/dist/src/execution/session.d.ts +1 -0
  152. package/dist/src/execution/session.js +1 -1
  153. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  154. package/dist/src/execution/tasks/child/steps.d.ts +19 -1
  155. package/dist/src/execution/tasks/child/steps.js +1 -1
  156. package/dist/src/execution/tasks/child/workflow.d.ts +2 -0
  157. package/dist/src/execution/tasks/child/workflow.js +1 -1
  158. package/dist/src/execution/tasks/parent/control-shared.js +1 -1
  159. package/dist/src/execution/tasks/parent/delegate.d.ts +2 -0
  160. package/dist/src/execution/tasks/parent/delegate.js +1 -1
  161. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
  162. package/dist/src/execution/tasks/parent/subagent-task-projection.d.ts +26 -0
  163. package/dist/src/execution/tasks/parent/subagent-task-projection.js +1 -0
  164. package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
  165. package/dist/src/execution/terminate-child-sessions-step.js +1 -1
  166. package/dist/src/execution/tools/sleep-workflow.d.ts +3 -0
  167. package/dist/src/execution/tools/sleep-workflow.js +1 -0
  168. package/dist/src/execution/tools/sleep.d.ts +1 -5
  169. package/dist/src/execution/tools/sleep.js +1 -1
  170. package/dist/src/execution/tools/subagent/accept-event-step.js +1 -1
  171. package/dist/src/execution/tools/subagent/invoke-agent.d.ts +1 -7
  172. package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
  173. package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
  174. package/dist/src/execution/tools/workflow/ask.d.ts +1 -2
  175. package/dist/src/execution/tools/workflow/ask.js +1 -1
  176. package/dist/src/execution/tools/workflow/body.d.ts +6 -1
  177. package/dist/src/execution/tools/workflow/body.js +1 -1
  178. package/dist/src/execution/tools/workflow/cancel.js +1 -1
  179. package/dist/src/execution/tools/workflow/messages.d.ts +9 -8
  180. package/dist/src/execution/tools/workflow/messages.js +1 -1
  181. package/dist/src/execution/tools/workflow/owner-inbox.d.ts +2 -2
  182. package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
  183. package/dist/src/execution/tools/workflow/owner.d.ts +5 -11
  184. package/dist/src/execution/tools/workflow/owner.js +1 -1
  185. package/dist/src/execution/tools/workflow/run-control.d.ts +0 -4
  186. package/dist/src/execution/tools/workflow/run-control.js +1 -1
  187. package/dist/src/execution/tools/workflow/start.d.ts +5 -14
  188. package/dist/src/execution/tools/workflow/start.js +1 -1
  189. package/dist/src/execution/tools/workflow/workflow.d.ts +1 -1
  190. package/dist/src/execution/tools/workflow/workflow.js +1 -1
  191. package/dist/src/execution/turn-cancellation-control.d.ts +1 -0
  192. package/dist/src/execution/turn-cancellation-control.js +1 -1
  193. package/dist/src/execution/turn-cancellation-token.d.ts +1 -0
  194. package/dist/src/execution/turn-control-receiver.d.ts +3 -0
  195. package/dist/src/execution/turn-control-receiver.js +1 -1
  196. package/dist/src/execution/turn-dispatch.d.ts +2 -0
  197. package/dist/src/execution/turn-dispatch.js +1 -1
  198. package/dist/src/execution/turn-workflow-tool-run.d.ts +2 -8
  199. package/dist/src/execution/turn-workflow-tool-run.js +1 -1
  200. package/dist/src/execution/turn-workflow.d.ts +1 -0
  201. package/dist/src/execution/turn-workflow.js +1 -1
  202. package/dist/src/execution/wire/session-inbox-contract.d.ts +2 -2
  203. package/dist/src/execution/wire/session-inbox-contract.js +1 -1
  204. package/dist/src/execution/wire/session-inbox-encoder.d.ts +10 -2
  205. package/dist/src/execution/wire/session-inbox-encoder.js +1 -1
  206. package/dist/src/execution/wire/session-inbox-resume.js +1 -1
  207. package/dist/src/execution/wire/session-inbox-wire.js +1 -1
  208. package/dist/src/execution/wire/session-inbox-wire.v5.d.ts +341 -0
  209. package/dist/src/execution/wire/session-inbox-wire.v5.js +1 -0
  210. package/dist/src/execution/wire/session-inbox-wire.v5.migration.d.ts +3 -0
  211. package/dist/src/execution/wire/session-inbox-wire.v5.migration.js +1 -0
  212. package/dist/src/execution/wire/session-inbox-wire.v6.d.ts +341 -0
  213. package/dist/src/execution/wire/session-inbox-wire.v6.js +1 -0
  214. package/dist/src/execution/workflow-entry.js +1 -1
  215. package/dist/src/execution/workflow-runtime.js +1 -1
  216. package/dist/src/execution/workflow-steps.js +1 -1
  217. package/dist/src/harness/emission-state.js +1 -1
  218. package/dist/src/harness/session-limit-continuation.d.ts +5 -5
  219. package/dist/src/harness/session-limit-continuation.js +1 -1
  220. package/dist/src/harness/session-limit-enforcement.d.ts +4 -4
  221. package/dist/src/harness/session-limit-enforcement.js +1 -1
  222. package/dist/src/harness/session-usage-limits.d.ts +48 -0
  223. package/dist/src/harness/session-usage-limits.js +1 -0
  224. package/dist/src/harness/tool-loop.js +2 -2
  225. package/dist/src/harness/turn-client-context.d.ts +9 -0
  226. package/dist/src/harness/turn-client-context.js +1 -0
  227. package/dist/src/harness/turn-tag-state.d.ts +17 -20
  228. package/dist/src/harness/turn-tag-state.js +1 -1
  229. package/dist/src/harness/types.d.ts +5 -0
  230. package/dist/src/harness/workflow-tool-runs.d.ts +0 -1
  231. package/dist/src/harness/workflow-tool-runs.js +1 -1
  232. package/dist/src/internal/application/build-output-environment.d.ts +1 -0
  233. package/dist/src/internal/application/build-output-environment.js +1 -1
  234. package/dist/src/internal/application/package.js +1 -1
  235. package/dist/src/internal/application/paths.js +1 -1
  236. package/dist/src/internal/authored-definition/core.js +1 -1
  237. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  238. package/dist/src/internal/eve-project-root.d.ts +8 -0
  239. package/dist/src/internal/eve-project-root.js +1 -0
  240. package/dist/src/internal/invocation/workflow-execution.js +1 -1
  241. package/dist/src/internal/mcp/streamable-http-server.d.ts +29 -1
  242. package/dist/src/internal/mcp/streamable-http-server.js +1 -1
  243. package/dist/src/internal/nitro/host/build-application.js +1 -1
  244. package/dist/src/internal/nitro/host/create-application-nitro.d.ts +1 -0
  245. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  246. package/dist/src/internal/nitro/host/types.d.ts +2 -0
  247. package/dist/src/internal/nitro/host/vercel-build-output-config.d.ts +1 -0
  248. package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
  249. package/dist/src/internal/project-context.d.ts +13 -8
  250. package/dist/src/internal/project-context.js +1 -1
  251. package/dist/src/internal/vercel/build-agent-workspace.d.ts +1 -1
  252. package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
  253. package/dist/src/internal/vercel/eve-service-contribution.d.ts +1 -0
  254. package/dist/src/internal/vercel/eve-service-contribution.js +1 -1
  255. package/dist/src/internal/workflow/reference.d.ts +2 -0
  256. package/dist/src/internal/workflow/reference.js +1 -0
  257. package/dist/src/internal/workflow/runtime.d.ts +6 -0
  258. package/dist/src/internal/workflow/runtime.js +1 -1
  259. package/dist/src/internal/workflow-bundle/authored-workflow-directives.d.ts +1 -3
  260. package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
  261. package/dist/src/internal/workflow-bundle/authored-workflow-modules.d.ts +1 -11
  262. package/dist/src/internal/workflow-bundle/authored-workflow-modules.js +1 -1
  263. package/dist/src/internal/workflow-bundle/builder.js +1 -1
  264. package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +1 -1
  265. package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +1 -3
  266. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  267. package/dist/src/internal/workflow-bundle/workflow-transformer.d.ts +1 -1
  268. package/dist/src/internal/workflow-bundle/workflow-transformer.js +2 -2
  269. package/dist/src/protocol/message.d.ts +3 -2
  270. package/dist/src/public/channels/mcp.js +1 -1
  271. package/dist/src/public/channels/slack/activity-plan.d.ts +4 -0
  272. package/dist/src/public/channels/slack/activity-plan.js +1 -0
  273. package/dist/src/public/channels/slack/activity.d.ts +45 -2
  274. package/dist/src/public/channels/slack/activity.js +2 -1
  275. package/dist/src/public/channels/slack/index.d.ts +1 -1
  276. package/dist/src/public/channels/slack/index.js +1 -1
  277. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  278. package/dist/src/public/memory/index.js +1 -1
  279. package/dist/src/public/models/openai/chatgpt/model.js +2 -2
  280. package/dist/src/public/models/openai/chatgpt/transport.js +1 -1
  281. package/dist/src/public/nuxt/index.js +1 -1
  282. package/dist/src/public/nuxt/module.d.ts +3 -2
  283. package/dist/src/public/nuxt/module.js +1 -1
  284. package/dist/src/public/sandbox/vercel-sandbox.d.ts +9 -5
  285. package/dist/src/public/sandbox/vercel.d.ts +1 -1
  286. package/dist/src/public/sandbox/vercel.js +1 -1
  287. package/dist/src/public/tools/index.d.ts +3 -1
  288. package/dist/src/public/tools/index.js +1 -1
  289. package/dist/src/runtime/resolve-agent.js +1 -1
  290. package/dist/src/runtime/subagents/workflow.js +1 -1
  291. package/dist/src/self-modification/agent.d.ts +22 -0
  292. package/dist/src/self-modification/agent.js +1 -0
  293. package/dist/src/self-modification/extension/classify-registry-item.d.ts +19 -0
  294. package/dist/src/self-modification/extension/classify-registry-item.js +1 -0
  295. package/dist/src/self-modification/extension/eve-add.d.ts +56 -0
  296. package/dist/src/self-modification/extension/eve-add.js +2 -0
  297. package/dist/src/self-modification/extension/extension.d.ts +2 -0
  298. package/dist/src/self-modification/extension/extension.js +1 -0
  299. package/dist/src/self-modification/extension/instructions.d.ts +4 -0
  300. package/dist/src/self-modification/extension/instructions.js +23 -0
  301. package/dist/src/self-modification/extension/source-lock.d.ts +2 -0
  302. package/dist/src/self-modification/extension/source-lock.js +1 -0
  303. package/dist/src/self-modification/extension/tools/edit_file.d.ts +16 -0
  304. package/dist/src/self-modification/extension/tools/edit_file.js +1 -0
  305. package/dist/src/self-modification/extension/tools/registry_add.d.ts +52 -0
  306. package/dist/src/self-modification/extension/tools/registry_add.js +1 -0
  307. package/dist/src/self-modification/extension/tools/search_models.d.ts +22 -0
  308. package/dist/src/self-modification/extension/tools/search_models.js +1 -0
  309. package/dist/src/self-modification/extension/tools/search_registry.d.ts +103 -0
  310. package/dist/src/self-modification/extension/tools/search_registry.js +1 -0
  311. package/dist/src/self-modification/filesystem.d.ts +6 -0
  312. package/dist/src/self-modification/filesystem.js +1 -0
  313. package/dist/src/self-modification/sandbox.d.ts +2 -0
  314. package/dist/src/self-modification/sandbox.js +1 -0
  315. package/dist/src/services/dev-client/target.d.ts +3 -1
  316. package/dist/src/setup/boxes/select-model.d.ts +3 -21
  317. package/dist/src/setup/boxes/select-model.js +1 -1
  318. package/dist/src/setup/cli/prompt-ui.js +4 -4
  319. package/dist/src/setup/cli/select-component.d.ts +1 -1
  320. package/dist/src/setup/cli/select-component.js +1 -1
  321. package/dist/src/setup/flows/model.d.ts +3 -0
  322. package/dist/src/setup/flows/model.js +1 -1
  323. package/dist/src/setup/prompter.js +1 -1
  324. package/dist/src/setup/scaffold/create/project.js +1 -1
  325. package/dist/src/setup/scaffold/update/web-options.js +1 -1
  326. package/dist/src/shared/action-types.d.ts +35 -22
  327. package/dist/src/shared/action-types.js +1 -1
  328. package/dist/src/shared/agent-definition.d.ts +13 -0
  329. package/dist/src/shared/agent-turn-outcome.d.ts +2 -0
  330. package/dist/src/shared/agent-turn-outcome.js +1 -1
  331. package/dist/src/shared/extension-package-contract.d.ts +2 -0
  332. package/dist/src/shared/extension-package-contract.js +1 -1
  333. package/dist/src/shared/gateway-model-catalog.d.ts +21 -0
  334. package/dist/src/shared/gateway-model-catalog.js +1 -0
  335. package/dist/src/shared/sandbox-network-policy.d.ts +1 -1
  336. package/dist/src/shared/token-usage.d.ts +11 -15
  337. package/dist/src/shared/token-usage.js +1 -1
  338. package/dist/src/shared/workflow-tool-context.d.ts +2 -0
  339. package/dist/src/shared/workflow-tool-context.js +1 -0
  340. package/dist/src/subagents/callback-route.js +1 -1
  341. package/dist/src/subagents/event-proxy-step.js +1 -1
  342. package/dist/src/subagents/start-remote.js +1 -1
  343. package/dist/src/subagents/token-budget.js +1 -1
  344. package/dist/src/svelte/index.js +1 -1
  345. package/dist/src/svelte/use-eve-agent.js +1 -1
  346. package/dist/src/tasks/types.d.ts +18 -1
  347. package/dist/src/tasks/types.js +1 -1
  348. package/dist/src/tools/behavior.d.ts +5 -0
  349. package/dist/src/tools/definition.d.ts +16 -12
  350. package/dist/src/tools/definition.js +1 -1
  351. package/dist/src/tools/dynamic.d.ts +2 -2
  352. package/dist/src/tools/provided/sleep.d.ts +4 -4
  353. package/dist/src/tools/provided/sleep.js +1 -1
  354. package/dist/src/tools/task.d.ts +28 -80
  355. package/dist/src/tools/task.js +1 -1
  356. package/dist/src/tools/workflow-definition.d.ts +60 -0
  357. package/dist/src/tools/workflow-definition.js +1 -0
  358. package/dist/src/vue/index.js +1 -1
  359. package/dist/src/vue/use-eve-agent.js +1 -1
  360. package/docs/agent-config.md +24 -19
  361. package/docs/channels/eve.mdx +1 -1
  362. package/docs/channels/mcp.mdx +25 -3
  363. package/docs/concepts/built-in-tools.md +1 -1
  364. package/docs/concepts/execution-model-and-durability.mdx +13 -2
  365. package/docs/concepts/sessions-runs-and-streaming.md +9 -1
  366. package/docs/guides/client/messages.mdx +1 -1
  367. package/docs/guides/client/streaming.mdx +1 -1
  368. package/docs/guides/deployment/vercel.mdx +3 -1
  369. package/docs/guides/frontend/overview.mdx +1 -1
  370. package/docs/memory/overview.mdx +41 -12
  371. package/docs/reference/cli.md +31 -33
  372. package/docs/reference/meta.json +1 -4
  373. package/docs/reference/telemetry.md +56 -0
  374. package/docs/reference/typescript-api.md +38 -35
  375. package/docs/sandbox.mdx +1 -1
  376. package/docs/tools/overview.mdx +59 -18
  377. package/docs/tools/workflows.mdx +146 -70
  378. package/package.json +38 -19
  379. package/dist/src/compiled/@vercel/sandbox-delete/api-client/index.d.ts +0 -2
  380. package/dist/src/compiled/@vercel/sandbox-delete/index.js +0 -9
  381. package/dist/src/compiled/@vercel/sandbox-stable/LICENSE +0 -201
  382. package/dist/src/compiled/@vercel/sandbox-stable/_async-retry.d.ts +0 -8
  383. package/dist/src/compiled/@vercel/sandbox-stable/_workflow-serde.d.ts +0 -5
  384. package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-client.d.ts +0 -1456
  385. package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-error.d.ts +0 -29
  386. package/dist/src/compiled/@vercel/sandbox-stable/api-client/base-client.d.ts +0 -39
  387. package/dist/src/compiled/@vercel/sandbox-stable/api-client/file-writer.d.ts +0 -66
  388. package/dist/src/compiled/@vercel/sandbox-stable/api-client/index.d.ts +0 -2
  389. package/dist/src/compiled/@vercel/sandbox-stable/api-client/validators.d.ts +0 -899
  390. package/dist/src/compiled/@vercel/sandbox-stable/api-client/with-retry.d.ts +0 -10
  391. package/dist/src/compiled/@vercel/sandbox-stable/auth/error.d.ts +0 -15
  392. package/dist/src/compiled/@vercel/sandbox-stable/auth/file.d.ts +0 -18
  393. package/dist/src/compiled/@vercel/sandbox-stable/auth/index.d.ts +0 -6
  394. package/dist/src/compiled/@vercel/sandbox-stable/auth/oauth.d.ts +0 -111
  395. package/dist/src/compiled/@vercel/sandbox-stable/auth/poll-for-token.d.ts +0 -28
  396. package/dist/src/compiled/@vercel/sandbox-stable/auth/project.d.ts +0 -40
  397. package/dist/src/compiled/@vercel/sandbox-stable/command.d.ts +0 -292
  398. package/dist/src/compiled/@vercel/sandbox-stable/constants.d.ts +0 -5
  399. package/dist/src/compiled/@vercel/sandbox-stable/execution-context.d.ts +0 -116
  400. package/dist/src/compiled/@vercel/sandbox-stable/filesystem.d.ts +0 -258
  401. package/dist/src/compiled/@vercel/sandbox-stable/index.d.ts +0 -12
  402. package/dist/src/compiled/@vercel/sandbox-stable/index.js +0 -1
  403. package/dist/src/compiled/@vercel/sandbox-stable/network-policy.d.ts +0 -169
  404. package/dist/src/compiled/@vercel/sandbox-stable/proxy.d.ts +0 -55
  405. package/dist/src/compiled/@vercel/sandbox-stable/sandbox-user.d.ts +0 -212
  406. package/dist/src/compiled/@vercel/sandbox-stable/sandbox.d.ts +0 -1216
  407. package/dist/src/compiled/@vercel/sandbox-stable/session.d.ts +0 -433
  408. package/dist/src/compiled/@vercel/sandbox-stable/snapshot.d.ts +0 -229
  409. package/dist/src/compiled/@vercel/sandbox-stable/utils/get-credentials.d.ts +0 -21
  410. package/dist/src/compiled/@vercel/sandbox-stable/utils/paginator.d.ts +0 -16
  411. package/dist/src/compiled/@vercel/sandbox-stable/utils/resolveSignal.d.ts +0 -15
  412. package/dist/src/compiled/@vercel/sandbox-stable/utils/sandbox-snapshot.d.ts +0 -11
  413. package/dist/src/compiled/@vercel/sandbox-stable/utils/types.d.ts +0 -11
  414. package/dist/src/compiled/_chunks/node/decode_jwt-Col8JOnf.js +0 -7
  415. package/dist/src/compiled/_chunks/node/version-BYHw-SDY.js +0 -1
  416. package/dist/src/compiled/_chunks/node/version-DH6yRy-M.js +0 -1
  417. package/dist/src/compiled/_chunks/workflow/dist-CgbVZs5l.js +0 -40
  418. package/dist/src/compiled/_chunks/workflow/dist-DjojkP5e.js +0 -3
  419. package/dist/src/compiled/_chunks/workflow/frames-CZ9eHShe.js +0 -3
  420. package/dist/src/compiled/_chunks/workflow/run-DzyAoGh4.js +0 -1
  421. package/dist/src/compiled/_chunks/workflow/sleep-3_A5uOp-.js +0 -1
  422. package/dist/src/compiled/_chunks/workflow/wait-until-BtySPYD0.js +0 -15
  423. package/dist/src/harness/session-token-limits.d.ts +0 -41
  424. package/dist/src/harness/session-token-limits.js +0 -1
  425. package/dist/src/harness/turn-sleep.d.ts +0 -12
  426. package/dist/src/harness/turn-sleep.js +0 -1
  427. package/dist/src/internal/agent-workspace.d.ts +0 -15
  428. package/dist/src/internal/agent-workspace.js +0 -1
  429. package/dist/src/node_modules/.pnpm/@clack_core@1.3.1/node_modules/@clack/core/dist/index.js +0 -16
  430. package/dist/src/node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js +0 -1
  431. package/dist/src/node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js +0 -1
  432. package/dist/src/node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js +0 -1
  433. package/dist/src/node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js +0 -5
  434. package/dist/src/node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js +0 -1
  435. package/dist/src/public/workflow/index.d.ts +0 -5
  436. package/dist/src/public/workflow/index.js +0 -1
  437. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/LICENSE +0 -0
  438. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/_async-retry.d.ts +0 -0
  439. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/_workflow-serde.d.ts +0 -0
  440. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/api-error.d.ts +0 -0
  441. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/base-client.d.ts +0 -0
  442. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/file-writer.d.ts +0 -0
  443. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/with-retry.d.ts +0 -0
  444. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/error.d.ts +0 -0
  445. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/file.d.ts +0 -0
  446. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/index.d.ts +0 -0
  447. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/oauth.d.ts +0 -0
  448. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/poll-for-token.d.ts +0 -0
  449. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/project.d.ts +0 -0
  450. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/command.d.ts +0 -0
  451. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/execution-context.d.ts +0 -0
  452. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/filesystem.d.ts +0 -0
  453. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/network-policy.d.ts +0 -0
  454. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/proxy.d.ts +0 -0
  455. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/sandbox-user.d.ts +0 -0
  456. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/session.d.ts +0 -0
  457. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/snapshot.d.ts +0 -0
  458. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/get-credentials.d.ts +0 -0
  459. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/paginator.d.ts +0 -0
  460. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/resolveSignal.d.ts +0 -0
  461. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/sandbox-snapshot.d.ts +0 -0
  462. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/types.d.ts +0 -0
@@ -0,0 +1,26 @@
1
+ import type { loadContext } from "#context/container.js";
2
+ import { createSubagentReceiptIdentity } from "#execution/tools/subagent/receipt-identity.js";
3
+ import type { JsonObject } from "#shared/json.js";
4
+ export interface SubagentTaskProjection {
5
+ readonly identity?: ReturnType<typeof createSubagentReceiptIdentity>;
6
+ readonly metadata: {
7
+ readonly agentId: string;
8
+ readonly kind: "subagent";
9
+ readonly mode: "local" | "remote";
10
+ readonly name: string;
11
+ };
12
+ readonly receipt: {
13
+ readonly agentId: string;
14
+ };
15
+ }
16
+ export declare function projectSubagentTask(input: {
17
+ readonly ctx: ReturnType<typeof loadContext>;
18
+ readonly input: JsonObject;
19
+ readonly name: string;
20
+ readonly nodeId: string;
21
+ readonly taskInput: {
22
+ readonly callId: string;
23
+ readonly parentSessionId: string;
24
+ readonly parentTurnId: string;
25
+ };
26
+ }): SubagentTaskProjection;
@@ -0,0 +1 @@
1
+ import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{createSubagentReceiptIdentity}from"#execution/tools/subagent/receipt-identity.js";function projectSubagentTask(e){let t=e.input.agentId;if(typeof t==`string`&&t.trim()!==``)return{metadata:{agentId:t,kind:`subagent`,mode:readSubagentTaskMode(e.ctx,e.nodeId),name:e.name},receipt:{agentId:t}};let r=createSubagentReceiptIdentity({callId:e.taskInput.callId,nodeId:e.nodeId,parentSessionId:e.taskInput.parentSessionId,parentTurnId:e.taskInput.parentTurnId,subagentName:e.name});return{identity:r,metadata:{agentId:r.identity.id,kind:`subagent`,mode:readSubagentTaskMode(e.ctx,e.nodeId),name:e.name},receipt:{agentId:r.identity.id}}}function readSubagentTaskMode(n,r){let i=getDynamicSubagentSelection(n,r);return i===void 0?(n.get(BundleKey)?.subagentRegistry.subagentsByNodeId.get(r))?.definition.kind===`remote`?`remote`:`local`:i.kind===`remote`?`remote`:`local`}export{projectSubagentTask};
@@ -1 +1 @@
1
- import{createEveCallbackRoutePath}from"#protocol/routes.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{loadContext}from"#context/container.js";import{parseJsonValue}from"#shared/json.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{parseWorkflowToolInput}from"#execution/tools/workflow/background.js";import{getHarnessEmissionState}from"#harness/emission.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{getAgentHandleStore,writeHandles}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{runStep}from"#context/run-step.js";import{activeTurnId}from"#harness/active-turn-id.js";import{AGENT_BUSY,AGENT_MISMATCH,AGENT_UNREACHABLE,formatAgentBusyMessage}from"#subagents/agent-handle-errors.js";import{isTurnCancellation}from"#harness/turn-cancellation.js";import{CallbackBaseUrlKey,isAuthorizationSignal}from"#harness/authorization.js";import{sendTaskCommand,sendTaskInboundPayload,startTaskRun,waitForTaskCommandOwner}from"#execution/tasks/parent/run-parent.js";import{recordSessionTask}from"#tasks/session-index.js";import{applyTaskAgentHandleCommand}from"#subagents/handles/transitions.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{BackgroundToolExecutorKey}from"#harness/background-tools.js";import{isAsyncIterable}from"#shared/async-iterable.js";import{createTaskDelegated,isTaskDelegated}from"#tools/task.js";import{beginBackgroundTask,prepareBackgroundTask,rejectDelegatedDispatch}from"#execution/tasks/parent/delegate.js";import{createSubagentReceiptIdentity}from"#execution/tools/subagent/receipt-identity.js";const IN_PROCESS_WORKFLOW_EXECUTOR={data:{},kind:`workflow-task`};function runBackgroundStep(e,t,n){return runStep(e,t,n,[backgroundToolExecutionProvider])}const backgroundToolExecutionProvider={key:BackgroundToolExecutorKey,create(e,t){return{value:new BackgroundToolExecutionScope(t)}},async commit(e,t){return await requireExecutionScope(e).commit(t)},async rollback(e,t){await requireExecutionScope(e).rollback(t)},decorateStepResult(e,t){return requireExecutionScope(e).decorate(t)}};function readRetainedBackgroundToolResult(e){let t=e.get(BackgroundToolExecutorKey);return t instanceof BackgroundToolExecutionScope?t.retainedResult():void 0}var BackgroundToolExecutionScope=class{executions=new Map;records=[];agentHandleSession;agentHandlesChanged=!1;retained=!1;initialSession;constructor(e){this.initialSession=e,this.agentHandleSession=e}execute(e){let t=this.executions.get(e.options.toolCallId);if(t!==void 0)return t;if(!e.batch.calls.some(t=>t.callId===e.options.toolCallId))throw Error(`Background tool call "${e.options.toolCallId}" was not registered before execution.`);let n=this.start(e);return this.executions.set(e.options.toolCallId,n),n}async readAgentViews(){return(getAgentHandleStore(this.agentHandleSession.state)?.handles??[]).flatMap(e=>e.phase===`reserved`?[]:e.phase===`available`?[{availability:`available`,id:e.identity.id,name:e.identity.name}]:e.phase===`claimed`?[{availability:`busy`,id:e.identity.id,name:e.identity.name,taskId:e.ownerId,taskStatus:`working`}]:[])}async commit(e){let t=this.records.filter(e=>!e.settled);return t.length>0&&await this.compensate(t,Error(`Background tool execution did not delegate or complete its task.`)),this.apply(e)}decorate(e){let t=this.resultFields();return t===void 0?e:{...e,...t}}async rollback(e){let t=this.records.filter(e=>e.settled),n=this.records.filter(e=>!e.settled);if(n.length>0&&await this.compensate(n,e),t.length!==0){if(isTurnCancellation(e)){this.retained=!0;return}await this.compensate(t,e)}}retainedResult(){return this.retained?this.resultFields():void 0}apply(e){let t=e;for(let e of this.records)!e.settled||e.task===void 0||(t=recordSessionTask(t,e.task));return this.agentHandlesChanged&&(t=writeHandles(t,getAgentHandleStore(this.agentHandleSession.state)?.handles??[])),t}resultFields(){let e=this.records.flatMap(e=>e.settled&&e.task!==void 0?[e.task]:[]);if(e.length!==0)return{backgroundTaskSession:this.apply(this.initialSession),backgroundTasks:e.map(({taskInboxToken:e,taskId:t,taskRunId:n})=>({taskInboxToken:e,taskId:t,taskRunId:n}))}}async start(t){let i={settled:!1};this.records.push(i);let a=getHarnessEmissionState(this.initialSession.state),o=loadContext(),c=await this.startTask({ctx:o,emission:a,input:t,record:i}),l=c.task;i.task=l;let u=o.get(CallbackBaseUrlKey),d={taskId:l.taskId,token:l.taskInboxToken,...u===void 0?{}:{url:createWorkflowCallbackUrl(u,createEveCallbackRoutePath(l.taskInboxToken))}},f={batch:t.batch.calls,binding:d,delegated:({executor:e,receipt:t})=>createTaskDelegated({binding:d,executor:e,receipt:t}),send:createTaskSender(l,t.options.toolCallId),session:this.initialSession,task:l};if(t.definition.workflowId!==void 0)return i.settled=!0,{...c.receipt,status:`working`,taskId:l.taskId};let p=t.definition.execute(t.toolInput,t.options,f);if(isAsyncIterable(p))throw Error(`Background tools cannot return AsyncIterable output.`);let m=await p;return isAuthorizationSignal(m)?m:isTaskDelegated(m)?(m.executor!==void 0&&(await deliverTaskCommand(l,{executor:m.executor,kind:`bind`}),i.task={...l,executor:m.executor}),i.settled=!0,c.receipt===void 0?m.receipt:{...m.receipt,...c.receipt}):(await deliverTaskCommand(l,{data:parseJsonValue(m),kind:`complete`}),i.settled=!0,m)}async startTask(e){let n=e.input.definition.workflowId===void 0?void 0:{...e.input.definition,workflowId:e.input.definition.workflowId},r=n===void 0?void 0:parseWorkflowToolInput(e.input.toolInput,e.input.definition.name),a=activeTurnId(e.emission),s=n?.resultKind===`subagent`&&r!==void 0?projectSubagentTask({ctx:e.ctx,input:r,name:e.input.definition.name,nodeId:n.nodeId??e.input.definition.name,taskInput:{callId:e.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:a}}):void 0;if(s!==void 0&&s.identity===void 0&&!hasAgentHandle(this.agentHandleSession,s.metadata.agentId)){let{agentId:t,...i}=r;r=i,s=projectSubagentTask({ctx:e.ctx,input:i,name:e.input.definition.name,nodeId:n.nodeId??e.input.definition.name,taskInput:{callId:e.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:a}})}let l={callId:e.input.options.toolCallId,metadata:s?.metadata??{kind:`tool`,name:e.input.definition.name},parentSessionId:this.initialSession.sessionId,parentStepIndex:e.emission.stepIndex,parentTurnId:a,session:this.initialSession};if(n===void 0)return{task:await beginBackgroundTask({callId:l.callId,metadata:l.metadata,parentSessionId:l.parentSessionId,parentStepIndex:l.parentStepIndex,parentTurnId:l.parentTurnId,session:l.session})};if(r===void 0)throw Error(`Background workflow tool "${e.input.definition.name}" has no input.`);let u=prepareBackgroundTask(l);if(n.resultKind===`subagent`&&s!==void 0&&s.identity!==void 0){let t=s.identity;if(this.applyAgentHandleCommand({identity:t.identity,callId:l.callId,kind:`reserve`,operationId:t.operation.id,ownerId:u.taskId}).kind!==`ready`)throw Error(`Agent handle store rejected start operation "${t.operation.id}".`);e.record.reservation={agentId:t.identity.id,operationId:t.operation.id}}if(n.resultKind===`subagent`&&s!==void 0&&s.identity===void 0){let t=deriveAgentOperationId({callId:l.callId,parentSessionId:l.parentSessionId,parentTurnId:a}),n=this.applyAgentHandleCommand({agentId:s.metadata.agentId,callId:l.callId,expectedTarget:s.metadata.mode,invokedName:s.metadata.name,kind:`claim`,operationId:t,ownerId:u.taskId});readClaimedHandle(n)?e.record.claim={operationId:t,taskId:u.taskId}:throwAgentClaimError(s.metadata.agentId,n)}await startTaskRun({initialView:{metadata:u.metadata,status:`working`,taskId:u.taskId},parentContinuationToken:sessionCommandHookToken(this.initialSession.sessionId),taskInboxToken:u.taskInboxToken,workflow:{callId:l.callId,executeInput:n.executeInput?.(r),input:r,resultKind:n.resultKind,session:buildCallbackContext().session,stepIndex:e.emission.stepIndex,toolName:e.input.definition.name,workflowId:n.workflowId}});let d=await waitForTaskCommandOwner({taskInboxToken:u.taskInboxToken}),f={...u,executor:IN_PROCESS_WORKFLOW_EXECUTOR,taskRunId:d.runId};return e.record.task=f,n.resultKind!==`subagent`||s===void 0?{task:f}:(s.identity,{receipt:s.receipt,task:f})}applyAgentHandleCommand(e){let t=applyTaskAgentHandleCommand(this.agentHandleSession,e);return t.session!==this.agentHandleSession&&(this.agentHandleSession=t.session,this.agentHandlesChanged=!0),t.result}async compensate(e,t){let n=[];for(let r of e.toReversed()){if(r.task!==void 0)try{await rejectDelegatedDispatch({error:{code:`PARENT_STEP_FAILED`,message:t instanceof Error?t.message:String(t)},task:r.task})}catch(e){n.push(e)}r.claim!==void 0&&this.applyAgentHandleCommand({kind:`release-owner`,ownerId:r.claim.taskId}),r.reservation!==void 0&&r.task!==void 0&&this.applyAgentHandleCommand({agentId:r.reservation.agentId,kind:`remove`,ownerId:r.task.taskId})}if(n.length>0)throw AggregateError([t,...n],`Background tool execution failed and its tasks could not all be rejected.`,{cause:t})}};function hasAgentHandle(e,t){return getAgentHandleStore(e.state)?.handles.some(e=>e.identity.id===t)===!0}function projectSubagentTask(e){let t=e.input.agentId;if(typeof t==`string`&&t.trim()!==``)return{metadata:{agentId:t,kind:`subagent`,mode:readSubagentTaskMode(e.ctx,e.nodeId),name:e.name},receipt:{agentId:t}};let n=createSubagentReceiptIdentity({callId:e.taskInput.callId,nodeId:e.nodeId,parentSessionId:e.taskInput.parentSessionId,parentTurnId:e.taskInput.parentTurnId,subagentName:e.name});return{identity:n,metadata:{agentId:n.identity.id,kind:`subagent`,mode:readSubagentTaskMode(e.ctx,e.nodeId),name:e.name},receipt:{agentId:n.identity.id}}}function readSubagentTaskMode(e,t){let n=getDynamicSubagentSelection(e,t);return n===void 0?(e.get(BundleKey)?.subagentRegistry.subagentsByNodeId.get(t))?.definition.kind===`remote`?`remote`:`local`:n.kind===`remote`?`remote`:`local`}function requireExecutionScope(e){if(!(e instanceof BackgroundToolExecutionScope))throw Error(`The background tool executor is not owned by the task runtime.`);return e}async function deliverTaskCommand(e,t){if(await sendTaskCommand({command:t,taskInboxToken:e.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.taskId}" did not accept "${t.kind}".`)}function createTaskSender(e,t){let n=0;return async r=>{if(r.kind!==`update`){await deliverTaskCommand(e,r);return}if(await sendTaskInboundPayload({payload:{callId:t,kind:`task-update`,message:r.message,updateEpoch:e.taskId,updateIndex:n++},taskInboxToken:e.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.taskId}" did not accept "${r.kind}".`)}}function readClaimedHandle(e){return e.kind===`ready`&&e.handle?.phase===`claimed`}function throwAgentClaimError(e,t){throw t.kind===`mismatch`?Error(JSON.stringify({code:AGENT_MISMATCH,message:`Agent "${e}" no longer matches this subagent definition. Start a new agent instead.`})):t.kind===`busy`?Error(JSON.stringify({code:AGENT_BUSY,message:formatAgentBusyMessage({agentId:e,agentName:t.handle.identity.name,ownerId:`ownerId`in t.handle?t.handle.ownerId:void 0})})):Error(JSON.stringify({code:AGENT_UNREACHABLE,message:`Agent with id "${e}" is no longer reachable.`}))}export{backgroundToolExecutionProvider,readRetainedBackgroundToolResult,runBackgroundStep};
1
+ import{sessionCommandHookToken}from"#execution/session-command-token.js";import{loadContext}from"#context/container.js";import{ActivityObserverKey}from"#context/keys.js";import{parseJsonValue}from"#shared/json.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{parseWorkflowToolInput}from"#execution/tools/workflow/background.js";import{getHarnessEmissionState}from"#harness/emission.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{getAgentHandleStore,writeHandles}from"#subagents/handles/store.js";import{recordSessionTask}from"#tasks/session-index.js";import{runStep}from"#context/run-step.js";import{activeTurnId}from"#harness/active-turn-id.js";import{AGENT_BUSY,AGENT_MISMATCH,AGENT_UNREACHABLE,formatAgentBusyMessage}from"#subagents/agent-handle-errors.js";import{isTurnCancellation}from"#harness/turn-cancellation.js";import{isAuthorizationSignal}from"#harness/authorization.js";import{sendTaskCommand,sendTaskInboundPayload,startTaskRun,waitForTaskCommandOwner}from"#execution/tasks/parent/run-parent.js";import{applyTaskAgentHandleCommand}from"#subagents/handles/transitions.js";import{BackgroundToolExecutorKey}from"#harness/background-tools.js";import{deriveBackgroundTaskActivityObserver}from"#execution/activity-work.js";import{isAsyncIterable}from"#shared/async-iterable.js";import{createTaskMessage,isTaskMessage}from"#tools/task.js";import{beginBackgroundTask,prepareBackgroundTask,rejectDelegatedDispatch}from"#execution/tasks/parent/delegate.js";import{projectSubagentTask}from"#execution/tasks/parent/subagent-task-projection.js";const IN_PROCESS_WORKFLOW_EXECUTOR={data:{},kind:`workflow-task`};function runBackgroundStep(e,t,n){return runStep(e,t,n,[backgroundToolExecutionProvider])}const backgroundToolExecutionProvider={key:BackgroundToolExecutorKey,create(e,t){return{value:new BackgroundToolExecutionScope(t)}},async commit(e,t){return await requireExecutionScope(e).commit(t)},async rollback(e,t){await requireExecutionScope(e).rollback(t)},decorateStepResult(e,t){return requireExecutionScope(e).decorate(t)}};function readRetainedBackgroundToolResult(e){let t=e.get(BackgroundToolExecutorKey);return t instanceof BackgroundToolExecutionScope?t.retainedResult():void 0}var BackgroundToolExecutionScope=class{executions=new Map;records=[];agentHandleSession;agentHandlesChanged=!1;retained=!1;initialSession;constructor(e){this.initialSession=e,this.agentHandleSession=e}execute(e){let t=this.executions.get(e.options.toolCallId);if(t!==void 0)return t;if(!e.batch.calls.some(t=>t.callId===e.options.toolCallId))throw Error(`Background tool call "${e.options.toolCallId}" was not registered before execution.`);let n=this.start(e);return this.executions.set(e.options.toolCallId,n),n}async readAgentViews(){return(getAgentHandleStore(this.agentHandleSession.state)?.handles??[]).flatMap(e=>e.phase===`reserved`?[]:e.phase===`available`?[{availability:`available`,id:e.identity.id,name:e.identity.name}]:e.phase===`claimed`?[{availability:`busy`,id:e.identity.id,name:e.identity.name,taskId:e.ownerId,taskStatus:`working`}]:[])}async commit(e){let t=this.records.filter(e=>!e.settled);return t.length>0&&await this.compensate(t,Error(`Background tool execution did not delegate or complete its task.`)),this.apply(e)}decorate(e){let t=this.resultFields();return t===void 0?e:{...e,...t}}async rollback(e){let t=this.records.filter(e=>e.settled),n=this.records.filter(e=>!e.settled);if(n.length>0&&await this.compensate(n,e),t.length!==0){if(isTurnCancellation(e)){this.retained=!0;return}await this.compensate(t,e)}}retainedResult(){return this.retained?this.resultFields():void 0}apply(e){let t=e;for(let e of this.records)!e.settled||e.task===void 0||(t=recordSessionTask(t,e.task));return this.agentHandlesChanged&&(t=writeHandles(t,getAgentHandleStore(this.agentHandleSession.state)?.handles??[])),t}resultFields(){let e=this.records.flatMap(e=>e.settled&&e.task!==void 0?[e.task]:[]);if(e.length!==0)return{backgroundTaskSession:this.apply(this.initialSession),backgroundTasks:e.map(({taskInboxToken:e,taskId:t,taskRunId:n})=>({taskInboxToken:e,taskId:t,taskRunId:n}))}}async start(e){let n={settled:!1};this.records.push(n);let i=getHarnessEmissionState(this.initialSession.state),a=loadContext(),s=await this.startTask({ctx:a,emission:i,input:e,record:n}),c=s.task;n.task=c;let l={binding:{taskId:c.taskId,token:c.taskInboxToken},postMessage:createTaskMessage,send(){throw Error(`task.send() was replaced by yielded task descriptors.`)},session:this.initialSession,task:c,taskId:c.taskId};if(e.definition.workflowId!==void 0)return n.settled=!0,{...s.receipt,status:`working`,taskId:c.taskId};let u=e.definition.execute(e.toolInput,e.options,l),d=isAsyncIterable(u)?await executeBackgroundIterable({callId:e.options.toolCallId,output:u,task:c}):await u;return isAuthorizationSignal(d)?d:(await deliverTaskCommand(c,{data:parseJsonValue(d),kind:`complete`}),n.settled=!0,{status:`working`,taskId:c.taskId})}async startTask(t){let r=t.input.definition.workflowId===void 0?void 0:{...t.input.definition,workflowId:t.input.definition.workflowId},o=r===void 0?void 0:parseWorkflowToolInput(t.input.toolInput,t.input.definition.name),c=activeTurnId(t.emission),l=r?.resultKind===`subagent`&&o!==void 0?projectSubagentTask({ctx:t.ctx,input:o,name:t.input.definition.name,nodeId:r.nodeId??t.input.definition.name,taskInput:{callId:t.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:c}}):void 0;if(l!==void 0&&l.identity===void 0&&!hasAgentHandle(this.agentHandleSession,l.metadata.agentId)){let{agentId:e,...n}=o;o=n,l=projectSubagentTask({ctx:t.ctx,input:n,name:t.input.definition.name,nodeId:r.nodeId??t.input.definition.name,taskInput:{callId:t.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:c}})}let u=l?.metadata??{kind:`tool`,name:t.input.definition.name},d={activityObserver:deriveBackgroundTaskActivityObserver({activityObserver:t.ctx.get(ActivityObserverKey),callId:t.input.options.toolCallId,name:u.name,parentSessionId:this.initialSession.sessionId,parentTurnId:c,rootSessionId:this.initialSession.rootSessionId??this.initialSession.sessionId}),callId:t.input.options.toolCallId,metadata:u,parentSessionId:this.initialSession.sessionId,parentStepIndex:t.emission.stepIndex,parentTurnId:c,session:this.initialSession};if(r===void 0)return{task:await beginBackgroundTask({activityObserver:d.activityObserver,callId:d.callId,metadata:d.metadata,parentSessionId:d.parentSessionId,parentStepIndex:d.parentStepIndex,parentTurnId:d.parentTurnId,session:d.session})};if(o===void 0)throw Error(`Background workflow tool "${t.input.definition.name}" has no input.`);let f=prepareBackgroundTask(d);if(r.resultKind===`subagent`&&l!==void 0&&l.identity!==void 0){let e=l.identity;if(this.applyAgentHandleCommand({identity:e.identity,callId:d.callId,kind:`reserve`,operationId:e.operation.id,ownerId:f.taskId}).kind!==`ready`)throw Error(`Agent handle store rejected start operation "${e.operation.id}".`);t.record.reservation={agentId:e.identity.id,operationId:e.operation.id}}if(r.resultKind===`subagent`&&l!==void 0&&l.identity===void 0){let e=deriveAgentOperationId({callId:d.callId,parentSessionId:d.parentSessionId,parentTurnId:c}),n=this.applyAgentHandleCommand({agentId:l.metadata.agentId,callId:d.callId,expectedTarget:l.metadata.mode,invokedName:l.metadata.name,kind:`claim`,operationId:e,ownerId:f.taskId});readClaimedHandle(n)?t.record.claim={operationId:e,taskId:f.taskId}:throwAgentClaimError(l.metadata.agentId,n)}await startTaskRun({activityObserver:d.activityObserver,initialView:{metadata:f.metadata,status:`working`,taskId:f.taskId},parentContinuationToken:sessionCommandHookToken(this.initialSession.sessionId),taskInboxToken:f.taskInboxToken,workflow:{callId:d.callId,executeInput:r.executeInput?.(o),input:o,resultKind:r.resultKind,session:buildCallbackContext().session,stepIndex:t.emission.stepIndex,toolName:t.input.definition.name,taskId:f.taskId,workflowId:r.workflowId}});let p=await waitForTaskCommandOwner({taskInboxToken:f.taskInboxToken}),m={...f,executor:IN_PROCESS_WORKFLOW_EXECUTOR,taskRunId:p.runId};return t.record.task=m,r.resultKind!==`subagent`||l===void 0?{task:m}:(l.identity,{receipt:l.receipt,task:m})}applyAgentHandleCommand(e){let t=applyTaskAgentHandleCommand(this.agentHandleSession,e);return t.session!==this.agentHandleSession&&(this.agentHandleSession=t.session,this.agentHandlesChanged=!0),t.result}async compensate(e,t){let n=[];for(let r of e.toReversed()){if(r.task!==void 0)try{await rejectDelegatedDispatch({error:{code:`PARENT_STEP_FAILED`,message:t instanceof Error?t.message:String(t)},task:r.task})}catch(e){n.push(e)}r.claim!==void 0&&this.applyAgentHandleCommand({kind:`release-owner`,ownerId:r.claim.taskId}),r.reservation!==void 0&&r.task!==void 0&&this.applyAgentHandleCommand({agentId:r.reservation.agentId,kind:`remove`,ownerId:r.task.taskId})}if(n.length>0)throw AggregateError([t,...n],`Background tool execution failed and its tasks could not all be rejected.`,{cause:t})}};async function executeBackgroundIterable(e){let t=e.output[Symbol.asyncIterator](),n=0,r=await t.next();for(;!r.done;){let i=isTaskMessage(r.value)?{callId:e.callId,kind:`task-message`,message:r.value.message,messageEpoch:e.task.taskId,messageIndex:n++}:{callId:e.callId,kind:`task-update`,message:typeof r.value==`string`?r.value:JSON.stringify(r.value),updateEpoch:e.task.taskId,updateIndex:n++};if(await sendTaskInboundPayload({payload:i,taskInboxToken:e.task.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.task.taskId}" did not accept "${i.kind}".`);r=await t.next()}return r.value??null}function hasAgentHandle(e,t){return getAgentHandleStore(e.state)?.handles.some(e=>e.identity.id===t)===!0}function requireExecutionScope(e){if(!(e instanceof BackgroundToolExecutionScope))throw Error(`The background tool executor is not owned by the task runtime.`);return e}async function deliverTaskCommand(e,t){if(await sendTaskCommand({command:t,taskInboxToken:e.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.taskId}" did not accept "${t.kind}".`)}function readClaimedHandle(e){return e.kind===`ready`&&e.handle?.phase===`claimed`}function throwAgentClaimError(e,t){throw t.kind===`mismatch`?Error(JSON.stringify({code:AGENT_MISMATCH,message:`Agent "${e}" no longer matches this subagent definition. Start a new agent instead.`})):t.kind===`busy`?Error(JSON.stringify({code:AGENT_BUSY,message:formatAgentBusyMessage({agentId:e,agentName:t.handle.identity.name,ownerId:`ownerId`in t.handle?t.handle.ownerId:void 0})})):Error(JSON.stringify({code:AGENT_UNREACHABLE,message:`Agent with id "${e}" is no longer reachable.`}))}export{backgroundToolExecutionProvider,readRetainedBackgroundToolResult,runBackgroundStep};
@@ -1 +1 @@
1
- import{createLogger,logError}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{cancelRun,getWorld}from"#internal/workflow/runtime.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{resetRemoteAgentSession,resolveRemoteAgentForAction,resolveRemoteAgentStreamHeaders}from"#subagents/remote-dispatch.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{cancelOwnedTask}from"#execution/tasks/parent/dispatch.js";import{cancelBackgroundAgentTask}from"#execution/tools/subagent/task-cancel.js";import{getSessionTaskIndex}from"#tasks/session-index.js";const log=createLogger(`execution.terminate-child-sessions`);async function terminateChildSessionsStep(e){"use step";let o;try{o=await readDurableSession(e.sessionState)}catch(n){logError(log,`failed to read child sessions for termination`,n,{parentSessionId:e.sessionState.sessionId});return}let s=readSessionTaskIndex(o.state,o.sessionId),c=getAgentHandleStore(o.state)?.handles??[],l=c.some(e=>`address`in e&&e.address.kind===`agent/remote`),u;if(s.length>0||l){if(e.serializedContext===void 0)throw Error(`Child finalization requires serialized runtime context.`);let t=await deserializeContext(e.serializedContext);u={bundle:t.require(BundleKey),ctx:t}}if(s.length>0){let{bundle:n,ctx:r}=u,i=resolveEffectiveAgentRuntime(n,r),a=hydrateDurableSession({durable:o,turnAgent:i.turnAgent});for(let n of s)try{await cancelOwnedTask({cancelOwnedWork:cancelBackgroundAgentTask,entry:n,serializedContext:e.serializedContext,session:a})}catch(e){logError(log,`failed to cancel task during parent finalization`,e,{parentSessionId:o.sessionId,taskId:n.taskId})}}if(c.length!==0)for(let e of c){if(!(`address`in e)){log.debug(`skipping unaddressed child`,{agentId:e.identity.id,parentSessionId:o.sessionId});continue}try{if(e.address.kind===`agent/remote`)if(e.address.credentialResolver!==void 0){let t=e.address.credentialResolver.resolverId;await resetRemoteAgentSession({headers:t===void 0?{}:await resolveRemoteAgentStreamHeaders({bundle:u.bundle,name:e.identity.name,resolverId:t,url:e.address.url}),remote:{name:e.identity.name,url:e.address.url},sessionId:e.address.sessionId})}else{let t=getDynamicSubagentSelection(u.ctx,e.identity.nodeId),n=resolveRemoteAgentForAction({dynamicRemoteAgent:t?.kind===`remote`?t.remoteAgent:void 0,nodeId:e.identity.nodeId,registry:u.bundle.subagentRegistry.subagentsByNodeId,remoteAgentName:e.identity.name});n.url===e.address.url?await resetRemoteAgentSession({remote:n,sessionId:e.address.sessionId}):await resetRemoteAgentSession({headers:{},remote:{name:e.identity.name,url:e.address.url},sessionId:e.address.sessionId})}else await cancelRun(await getWorld(),e.address.sessionId,{cancelReason:`Parent session ended`})}catch(n){logError(log,`failed to terminate child session`,n,{agentId:e.identity.id,childSessionId:e.address.sessionId,kind:e.address.kind,parentSessionId:o.sessionId})}}}function readSessionTaskIndex(e,n){try{return getSessionTaskIndex(e)}catch(e){return logError(log,`failed to read the task index during parent finalization`,e,{parentSessionId:n}),[]}}export{terminateChildSessionsStep};
1
+ import{createLogger,logError}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{cancelRun,getWorld}from"#internal/workflow/runtime.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{resetRemoteAgentSession,resolveRemoteAgentForAction,resolveRemoteAgentStreamHeaders}from"#subagents/remote-dispatch.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{cancelAllIndexedSessionTasksStep}from"#execution/cancel-indexed-session-tasks-step.js";const log=createLogger(`execution.terminate-child-sessions`);async function terminateChildSessionsStep(e){"use step";let r;try{r=await readDurableSession(e.sessionState)}catch(n){logError(log,`failed to read child sessions for termination`,n,{parentSessionId:e.sessionState.sessionId});return}let i=getAgentHandleStore(r.state)?.handles??[],a=i.some(e=>`address`in e&&e.address.kind===`agent/remote`),o;if(await cancelAllIndexedSessionTasksStep({serializedContext:e.serializedContext,sessionState:e.sessionState}),a){if(e.serializedContext===void 0)throw Error(`Child finalization requires serialized runtime context.`);let t=await deserializeContext(e.serializedContext);o={bundle:t.require(BundleKey),ctx:t}}if(i.length!==0)for(let e of i){if(!(`address`in e)){log.debug(`skipping unaddressed child`,{agentId:e.identity.id,parentSessionId:r.sessionId});continue}try{if(e.address.kind===`agent/remote`)if(e.address.credentialResolver!==void 0){let t=e.address.credentialResolver.resolverId;await resetRemoteAgentSession({headers:t===void 0?{}:await resolveRemoteAgentStreamHeaders({bundle:o.bundle,name:e.identity.name,resolverId:t,url:e.address.url}),remote:{name:e.identity.name,url:e.address.url},sessionId:e.address.sessionId})}else{let t=getDynamicSubagentSelection(o.ctx,e.identity.nodeId),n=resolveRemoteAgentForAction({dynamicRemoteAgent:t?.kind===`remote`?t.remoteAgent:void 0,nodeId:e.identity.nodeId,registry:o.bundle.subagentRegistry.subagentsByNodeId,remoteAgentName:e.identity.name});n.url===e.address.url?await resetRemoteAgentSession({remote:n,sessionId:e.address.sessionId}):await resetRemoteAgentSession({headers:{},remote:{name:e.identity.name,url:e.address.url},sessionId:e.address.sessionId})}else await cancelRun(await getWorld(),e.address.sessionId,{cancelReason:`Parent session ended`})}catch(n){logError(log,`failed to terminate child session`,n,{agentId:e.identity.id,childSessionId:e.address.sessionId,kind:e.address.kind,parentSessionId:r.sessionId})}}}export{terminateChildSessionsStep};
@@ -0,0 +1,3 @@
1
+ import type { SleepToolInput, SleepToolOutput } from "#execution/tools/sleep.js";
2
+ /** Waits durably in a workflow dedicated to this tool call. */
3
+ export declare function executeSleepTool(input: SleepToolInput): Promise<SleepToolOutput>;
@@ -0,0 +1 @@
1
+ import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e){"use workflow";return await sleep(Math.ceil(e.seconds*1e3)),{waitedSeconds:e.seconds}}executeSleepTool.workflowId=`workflow//eve@0.52.0//executeSleepTool`;export{executeSleepTool};
@@ -1,4 +1,5 @@
1
1
  import { z } from "#compiled/zod/index.js";
2
+ export { executeSleepTool } from "#execution/tools/sleep-workflow.js";
2
3
  export declare const SLEEP_TOOL_DESCRIPTION = "Wait for a specified amount of time before continuing. Use this when a process or condition needs time to change before it is useful to check its progress or status again.";
3
4
  export declare const SLEEP_INPUT_SCHEMA: z.ZodObject<{
4
5
  seconds: z.ZodNumber;
@@ -8,8 +9,3 @@ export declare const SLEEP_OUTPUT_SCHEMA: z.ZodObject<{
8
9
  }, z.core.$strict>;
9
10
  export type SleepToolInput = z.infer<typeof SLEEP_INPUT_SCHEMA>;
10
11
  export type SleepToolOutput = z.infer<typeof SLEEP_OUTPUT_SCHEMA>;
11
- /**
12
- * Records a durable wait for the owning turn workflow to fulfill after the
13
- * current atomic step finishes.
14
- */
15
- export declare function executeSleepTool(input: SleepToolInput): SleepToolOutput;
@@ -1 +1 @@
1
- import{z}from"#compiled/zod/index.js";import{requestTurnSleep}from"#harness/turn-sleep.js";const MAX_SLEEP_SECONDS=Math.floor((2**53-1)/1e3),SLEEP_TOOL_DESCRIPTION=`Wait for a specified amount of time before continuing. Use this when a process or condition needs time to change before it is useful to check its progress or status again.`,SLEEP_INPUT_SCHEMA=z.strictObject({seconds:z.number().positive().max(MAX_SLEEP_SECONDS).describe(`How long to wait, in seconds.`)}),SLEEP_OUTPUT_SCHEMA=z.strictObject({waitedSeconds:z.number().positive()});function executeSleepTool(e){return requestTurnSleep(Math.ceil(e.seconds*1e3)),{waitedSeconds:e.seconds}}export{SLEEP_INPUT_SCHEMA,SLEEP_OUTPUT_SCHEMA,SLEEP_TOOL_DESCRIPTION,executeSleepTool};
1
+ import{z}from"#compiled/zod/index.js";import{executeSleepTool}from"#execution/tools/sleep-workflow.js";const MAX_SLEEP_SECONDS=Math.floor((2**53-1)/1e3),SLEEP_TOOL_DESCRIPTION=`Wait for a specified amount of time before continuing. Use this when a process or condition needs time to change before it is useful to check its progress or status again.`,SLEEP_INPUT_SCHEMA=z.strictObject({seconds:z.number().positive().max(MAX_SLEEP_SECONDS).describe(`How long to wait, in seconds.`)}),SLEEP_OUTPUT_SCHEMA=z.strictObject({waitedSeconds:z.number().positive()});export{SLEEP_INPUT_SCHEMA,SLEEP_OUTPUT_SCHEMA,SLEEP_TOOL_DESCRIPTION,executeSleepTool};
@@ -1 +1 @@
1
- import{readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{readLatestTaskView}from"#execution/tasks/parent/run-parent.js";import{findSessionTaskEntry}from"#tasks/session-index.js";import{isTerminalTaskStatus}from"#tasks/types.js";async function acceptTaskAuthorizationEventStep(t){"use step";let{hookPayload:n,taskId:r}=t.delivery,i=await readDurableSession(t.sessionState),a=findSessionTaskEntry(i.state,r);if(a===void 0)return!1;let o=getAgentHandleStore(i.state)?.handles??[],s=o.find(e=>e.phase===`claimed`&&e.ownerId===r&&e.identity.name===n.subagentName&&e.address.sessionId===n.childSessionId),c=o.filter(e=>e.phase===`reserved`&&e.ownerId===r&&e.identity.name===n.subagentName);if(s===void 0&&c.length!==1)return!1;let l=await readLatestTaskView({taskRunId:a.taskRunId});return l!==void 0&&!isTerminalTaskStatus(l.status)}export{acceptTaskAuthorizationEventStep};
1
+ import{readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{findSessionTaskEntry}from"#tasks/session-index.js";import{readLatestTaskView}from"#execution/tasks/parent/run-parent.js";import{isTerminalTaskStatus}from"#tasks/types.js";async function acceptTaskAuthorizationEventStep(t){"use step";let{hookPayload:n,taskId:r}=t.delivery,i=await readDurableSession(t.sessionState),a=findSessionTaskEntry(i.state,r);if(a===void 0)return!1;let o=getAgentHandleStore(i.state)?.handles??[],s=o.find(e=>e.phase===`claimed`&&e.ownerId===r&&e.identity.name===n.subagentName&&e.address.sessionId===n.childSessionId),c=o.filter(e=>e.phase===`reserved`&&e.ownerId===r&&e.identity.name===n.subagentName);if(s===void 0&&c.length!==1)return!1;let l=await readLatestTaskView({taskRunId:a.taskRunId});return l!==void 0&&!isTerminalTaskStatus(l.status)}export{acceptTaskAuthorizationEventStep};
@@ -2,6 +2,7 @@ import type { RuntimeActionResultHookPayload, SubagentAuthorizationEventHookPayl
2
2
  import type { RuntimeSubagentChildResult, RuntimeSubagentResult } from "#shared/action-types.js";
3
3
  import type { JsonValue } from "#shared/json.js";
4
4
  import type { JsonObject } from "#shared/json.js";
5
+ import type { AgentInput } from "#tools/workflow-definition.js";
5
6
  import type { ToolContext } from "#tools/definition.js";
6
7
  import type { TaskInboundUpdate } from "#tasks/types.js";
7
8
  export type InternalAgentInput = {
@@ -10,13 +11,6 @@ export type InternalAgentInput = {
10
11
  readonly outputSchema?: JsonObject;
11
12
  readonly target: string;
12
13
  };
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
14
  /**
21
15
  * Asks the owning session to spawn an agent for a workflow tool run. Spawning
22
16
  * needs owner-held material (auth, capabilities, admission, the agent handle
@@ -1 +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};
1
+ import{createHook}from"#compiled/@workflow/core/index.js";import{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),readWorkflowToolRunRef(e),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);if(claimInvocationId(i,o.invocationId),l!==void 0){let e=await l;if(e.status===`rejected`)throw Error(e.reason)}let u=createHook();try{await resumeHookStep(c.inbox,{kind:`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.inbox,{kind:`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.inbox,{kind:`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.inbox,{kind:`report`,from:s,update:n.message});continue}await resumeHookStep(c.inbox,{kind:`request`,from:s,replyTo:u.token,request:{event:n,kind:`authorization-request`}})}}finally{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};
@@ -1 +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};
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{findSessionTaskEntry}from"#tasks/session-index.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{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};
@@ -9,11 +9,10 @@ interface WorkflowToolRunContext {
9
9
  readonly status: "rejected";
10
10
  readonly reason: string;
11
11
  }>;
12
- answerSeq: number;
13
12
  readonly from: WorkflowToolRunRef;
14
13
  readonly owner: WorkflowToolRunOwner;
15
14
  }
16
- export declare function attachWorkflowToolRunContext(ctx: ToolContext, context: Omit<WorkflowToolRunContext, "answerSeq">): void;
15
+ export declare function attachWorkflowToolRunContext(ctx: ToolContext, context: WorkflowToolRunContext): void;
17
16
  export declare function readWorkflowToolRunRef(ctx: ToolContext): WorkflowToolRunRef;
18
17
  export declare function readWorkflowToolRunOwner(ctx: ToolContext): WorkflowToolRunOwner;
19
18
  export declare function readWorkflowToolRunAdmission(ctx: ToolContext): WorkflowToolRunContext["admission"];
@@ -1 +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};
1
+ import{workflowToolContextErrorMessage}from"#shared/workflow-tool-context.js";import{createHook}from"#compiled/@workflow/core/index.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})}function readWorkflowToolRunContext(t,n){let i=t?.[WORKFLOW_TOOL_RUN_CONTEXT];if(i===void 0)throw Error(workflowToolContextErrorMessage(n));return i}function readWorkflowToolRunRef(e){return readWorkflowToolRunContext(e,`agent`).from}function readWorkflowToolRunOwner(e){return readWorkflowToolRunContext(e,`agent`).owner}function readWorkflowToolRunAdmission(e){return readWorkflowToolRunContext(e,`agent`).admission}function ask(e,r){let i=readWorkflowToolRunContext(e,`ask`),a=createHook();return resumeHookStep(i.owner.inbox,{kind:`request`,from:i.from,replyTo:a.token,request:{kind:`ask`,request:r}}),a}export{ask,attachWorkflowToolRunContext,readWorkflowToolRunAdmission,readWorkflowToolRunOwner,readWorkflowToolRunRef};
@@ -8,17 +8,22 @@ export interface WorkflowBodyDefinition {
8
8
  readonly resultKind?: "subagent" | "tool";
9
9
  readonly session: SessionContext["session"];
10
10
  readonly stepIndex: number;
11
+ readonly taskId?: string;
11
12
  readonly toolName: string;
12
13
  readonly workflowId: string;
13
14
  }
14
15
  export interface WorkflowBodyInput extends WorkflowBodyDefinition {
15
16
  readonly owner: WorkflowToolRunOwner;
16
17
  }
18
+ export interface WorkflowBodyResult {
19
+ readonly outcome: WorkflowToolRunOutcome;
20
+ readonly reportCount: number;
21
+ }
17
22
  /** Executes one registered workflow body and reports progress to its owner. */
18
23
  export declare function executeWorkflowBody(input: WorkflowBodyInput & {
19
24
  readonly execution: "background" | "blocking";
20
25
  readonly runId?: string;
21
- }, signal: AbortSignal): Promise<WorkflowToolRunOutcome>;
26
+ }, signal: AbortSignal): Promise<WorkflowBodyResult>;
22
27
  export declare function createWorkflowBodyRef(input: WorkflowBodyDefinition & {
23
28
  readonly execution: "background" | "blocking";
24
29
  readonly runId?: string;
@@ -1 +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};
1
+ import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{createTaskMessage}from"#tools/task.js";import{ask,attachWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{agent}from"#execution/tools/subagent/invoke-agent.js";import"#execution/tools/workflow/messages.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{readRegisteredWorkflow}from"#execution/workflow-registry.js";async function executeWorkflowBody(e,t){let n=createWorkflowBodyRef(e),i=createWorkflowBodyContext(e,t);attachWorkflowToolRunContext(i,{from:n,owner:e.owner});let o=0;try{let t=resolveWorkflowToolExecute(e),r=e.execution===`background`?createWorkflowTaskExec(e):void 0,a=t(e.executeInput??e.input,i,r),s;if(!isAsyncIterable(a))s=await a;else{let t=a[Symbol.asyncIterator](),r,i=await t.next();for(;i.done!==!0;){r=i.value;let a={from:n,update:i.value};await resumeHookStep(e.owner.inbox,{kind:`report`,...a}),o+=1,i=await t.next()}s=i.value??(e.execution===`blocking`?r:void 0)??null}return{outcome:{output:s,status:`completed`},reportCount:o}}catch(e){return t.aborted?{outcome:{reason:t.reason instanceof Error?t.reason.message:String(t.reason??``),status:`cancelled`},reportCount:o}:{outcome:{error:normalizeSerializableError(e),status:`failed`},reportCount:o}}}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.`)},r={agent:e=>agent(r,e),ask:e=>ask(r,e),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};return r}function createWorkflowTaskExec(e){if(e.taskId===void 0)throw Error(`Background workflow tool "${e.toolName}" has no task id.`);return{binding:{taskId:e.taskId,token:e.taskId},postMessage:createTaskMessage,send(){throw Error(`task.send() was replaced by yielded task descriptors.`)},session:void 0,task:void 0,taskId:e.taskId}}function isAsyncIterable(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}export{createWorkflowBodyRef,executeWorkflowBody};
@@ -1 +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};
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){isTaskWorkflowTargetGone(t)||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};
@@ -4,10 +4,7 @@ import type { InputRequest } from "#shared/input.js";
4
4
  import type { JsonObject, JsonValue } from "#shared/json.js";
5
5
  import type { ToolInputRequest } from "#tools/definition.js";
6
6
  export interface WorkflowToolRunOwner {
7
- readonly admission: string;
8
- readonly outcome: string;
9
- readonly report: string;
10
- readonly request: string;
7
+ readonly inbox: string;
11
8
  }
12
9
  /**
13
10
  * Requests the owner must apply on the run's behalf because they touch
@@ -77,10 +74,14 @@ export interface WorkflowToolRunOutcomeMessage {
77
74
  readonly from: WorkflowToolRunRef;
78
75
  readonly result: WorkflowToolRunOutcome;
79
76
  }
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;
77
+ export type WorkflowToolRunMessage = ({
78
+ readonly kind: "report";
79
+ } & WorkflowToolRunReport) | ({
80
+ readonly kind: "request";
81
+ } & WorkflowToolRunRequestMessage) | ({
82
+ readonly kind: "outcome";
83
+ } & WorkflowToolRunOutcomeMessage);
84
+ export declare const workflowToolRunHook: import("#compiled/@workflow/core/index.js").TypedHook<WorkflowToolRunMessage, WorkflowToolRunMessage>;
84
85
  export type WorkflowToolRunControlMessage = {
85
86
  readonly kind: "cancel";
86
87
  readonly reason: string;
@@ -1 +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};
1
+ import{defineHook}from"#compiled/@workflow/core/index.js";const workflowToolRunHook=defineHook();function isWorkflowToolRunControlMessage(e){if(typeof e!=`object`||!e)return!1;let{kind:t,reason:n}=e;return t===`cancel`&&typeof n==`string`}export{isWorkflowToolRunControlMessage,workflowToolRunHook};
@@ -3,11 +3,11 @@ import type { WorkflowToolRunOutcomeMessage, WorkflowToolRunReport, WorkflowTool
3
3
  import type { RuntimeToolResultActionResult } from "#shared/action-types.js";
4
4
  import type { RuntimeSubagentResult } from "#shared/action-types.js";
5
5
  import type { WorkflowToolRunTaskInputRequest } from "#execution/tasks/child/workflow.js";
6
- import type { TaskCommand, TaskInboundUpdate } from "#tasks/types.js";
6
+ import type { TaskCommand, TaskInboundMessage, TaskInboundUpdate } from "#tasks/types.js";
7
7
  export declare function workflowToolRunOutcomeToToolResult(message: WorkflowToolRunOutcomeMessage): RuntimeToolResultActionResult;
8
8
  /** Reads a blocking agent result returned through an ordinary run outcome. */
9
9
  export declare function workflowToolRunOutcomeToSubagentResult(message: WorkflowToolRunOutcomeMessage): RuntimeSubagentResult;
10
10
  export declare function workflowToolRunOutcomeToTaskCommand(message: WorkflowToolRunOutcomeMessage): TaskCommand;
11
- export declare function workflowToolRunReportToTaskUpdate(report: WorkflowToolRunReport, taskId: string, updateIndex: number): TaskInboundUpdate;
11
+ export declare function workflowToolRunReportToTaskPayload(report: WorkflowToolRunReport, taskId: string, updateIndex: number): TaskInboundMessage | TaskInboundUpdate;
12
12
  export declare function workflowToolRunRequestToInputRequestPayload(message: WorkflowToolRunRequestMessage): SubagentInputRequestHookPayload;
13
13
  export declare function workflowToolRunRequestToTaskInputRequest(message: WorkflowToolRunRequestMessage): WorkflowToolRunTaskInputRequest;
@@ -1 +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};
1
+ import{parseJsonValue}from"#shared/json.js";import{SUBAGENT_EXECUTION_FAILED}from"#subagents/agent-handle-errors.js";import{isTaskMessage}from"#tools/task.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 workflowToolRunReportToTaskPayload(e,t,r){return isTaskMessage(e.update)?{callId:e.from.callId,kind:`task-message`,message:e.update.message,messageEpoch:t,messageIndex:r}:{callId:e.from.callId,kind:`task-update`,message:typeof e.update==`string`?e.update:JSON.stringify(e.update),updateEpoch:t,updateIndex:r}}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,workflowToolRunReportToTaskPayload,workflowToolRunRequestToInputRequestPayload,workflowToolRunRequestToTaskInputRequest};
@@ -1,13 +1,7 @@
1
- import { type WorkflowToolRunOutcomeMessage, type WorkflowToolRunReport, type WorkflowToolRunRequestMessage } from "#execution/tools/workflow/messages.js";
1
+ import { type WorkflowToolRunMessage, type WorkflowToolRunOwner } from "#execution/tools/workflow/messages.js";
2
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>;
3
+ export interface WorkflowToolRunOwnerInbox {
4
+ readonly owner: WorkflowToolRunOwner;
5
+ readonly reader: ChannelReader<"workflow", WorkflowToolRunMessage>;
12
6
  }
13
- export declare function openWorkflowToolRunOwnerChannels(inboxToken: string): WorkflowToolRunOwnerChannels;
7
+ export declare function openWorkflowToolRunOwnerInbox(): WorkflowToolRunOwnerInbox;
@@ -1 +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};
1
+ import{createChannelReader}from"#execution/tools/workflow/owner-channels.js";import{workflowToolRunHook}from"#execution/tools/workflow/messages.js";function openWorkflowToolRunOwnerInbox(){let e=workflowToolRunHook.create();return{owner:{inbox:e.token},reader:createChannelReader(`workflow`,e)}}export{openWorkflowToolRunOwnerInbox};
@@ -1,17 +1,13 @@
1
- import { type Hook } from "#compiled/@workflow/core/index.js";
2
- import { type WorkflowToolRunControlMessage } from "#execution/tools/workflow/messages.js";
3
1
  /**
4
2
  * The run's control inbox. An unawaited hook read is not scheduled under
5
3
  * replay, so `cancelled` must be raced for a cancel to be observed at all.
6
4
  */
7
5
  export interface WorkflowToolRunControlInbox {
8
- readonly hook: Hook<WorkflowToolRunControlMessage>;
9
6
  readonly signal: AbortSignal;
10
7
  /** Rejects with {@link WorkflowToolRunCancelledError} when a cancel message arrives; never resolves. */
11
8
  readonly cancelled: Promise<never>;
12
9
  reason(): string | undefined;
13
10
  }
14
- /** Opens without claiming, so a losing duplicate start never trips the signal. */
15
11
  export declare function openWorkflowToolRunControlInbox(hookToken: string): WorkflowToolRunControlInbox;
16
12
  export declare class WorkflowToolRunCancelledError extends Error {
17
13
  constructor(reason: string);
@@ -1 +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};
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})[Symbol.asyncIterator](),r=new AbortController,i,a=consumeCancel(n,e=>{i=e,r.abort(new WorkflowToolRunCancelledError(e))});return a.catch(()=>{}),{cancelled:a,reason:()=>i,signal:r.signal}}async function consumeCancel(e,n){for(;;){let r=await e.next();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};
@@ -1,19 +1,10 @@
1
1
  import type { SessionAuth, SessionParent } from "#context/session-context.js";
2
2
  import type { RuntimeSession } from "#subagents/handle-dispatch.js";
3
3
  import type { RuntimeToolResultActionResult, RuntimeWorkflowTaskRequest } from "#shared/action-types.js";
4
- import type { WorkflowToolRunInput } from "#execution/tools/workflow/types.js";
5
- export declare function deriveWorkflowToolRunHookToken(input: {
6
- readonly callId: string;
7
- readonly parentSessionId: string;
8
- readonly parentTurnId: string;
9
- }): string;
10
- /** Resolves once the workflow tool run owns its hook. Call from a `"use step"` body. */
11
- export declare function startWorkflowToolRun(input: Omit<WorkflowToolRunInput, "hookToken"> & {
12
- readonly hookToken?: string;
13
- }): Promise<{
14
- readonly hookToken: string;
15
- readonly runId: string;
16
- }>;
4
+ import type { WorkflowToolRunAddress, WorkflowToolRunInput } from "#execution/tools/workflow/types.js";
5
+ import type { WorkflowToolRunOwner } from "#execution/tools/workflow/messages.js";
6
+ /** Starts a new run for each dispatch attempt. Call from a `"use step"` body. */
7
+ export declare function startWorkflowToolRun(input: Omit<WorkflowToolRunInput, "hookToken">): Promise<WorkflowToolRunAddress>;
17
8
  /** Starts one durable workflow task and records it on the owning session. */
18
9
  export declare function startWorkflowTask(input: {
19
10
  readonly auth: SessionAuth["current"];
@@ -23,7 +14,7 @@ export declare function startWorkflowTask(input: {
23
14
  readonly turnId: string;
24
15
  };
25
16
  readonly initiatorAuth: SessionAuth["initiator"];
26
- readonly parentContinuationToken: string;
17
+ readonly owner: WorkflowToolRunOwner;
27
18
  readonly parentSession: SessionParent | undefined;
28
19
  readonly session: RuntimeSession;
29
20
  readonly task: RuntimeWorkflowTaskRequest;
@@ -1 +1 @@
1
- import{createLogger,logError}from"#internal/logging.js";import{toError}from"#shared/errors.js";import{startWorkflowOnCurrentDeployment,waitForCommandHookOwner,workflowToolRunWorkflowReference}from"#execution/workflow-runtime.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{recordWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{deriveWorkflowToolRunOwner}from"#execution/tools/workflow/messages.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";const log=createLogger(`execution.workflow-tool-run`);function deriveWorkflowToolRunHookToken(e){return`eve:workflow-tool-run:${deriveAgentOperationId(e)}`}async function startWorkflowToolRun(e){let t=e.hookToken??deriveWorkflowToolRunHookToken({callId:e.callId,parentSessionId:e.session.id,parentTurnId:e.session.turn.id});return await startWorkflowOnCurrentDeployment(workflowToolRunWorkflowReference,[{...e,hookToken:t}]),{hookToken:t,runId:(await waitForCommandHookOwner(t)).runId}}async function startWorkflowTask(e){let{task:n,batchEvent:r,session:i}=e;try{let t=await startWorkflowToolRun({callId:n.callId,executeInput:n.executeInput,input:n.input,owner:deriveWorkflowToolRunOwner(e.parentContinuationToken),resultKind:n.resultKind,session:{auth:{current:e.auth,initiator:e.initiatorAuth},id:i.sessionId,parent:e.parentSession,turn:{id:r.turnId,sequence:r.sequence}},stepIndex:r.stepIndex,toolName:n.toolName,workflowId:n.workflowId});return{session:recordWorkflowToolRun(i,{callId:n.callId,hookToken:t.hookToken,resultKind:n.resultKind??`tool`,runId:t.runId,toolName:n.toolName})}}catch(e){return logError(log,`workflow tool run failed to start`,e,{callId:n.callId,toolName:n.toolName}),{result:createRuntimeToolResultFromValue({callId:n.callId,isError:!0,output:toError(e),toolName:n.toolName}),session:i}}}export{deriveWorkflowToolRunHookToken,startWorkflowTask,startWorkflowToolRun};
1
+ import{createLogger,logError}from"#internal/logging.js";import{toError}from"#shared/errors.js";import{startWorkflowOnCurrentDeployment,workflowToolRunWorkflowReference}from"#execution/workflow-runtime.js";import{recordWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";const log=createLogger(`execution.workflow-tool-run`);async function startWorkflowToolRun(e){let t=crypto.randomUUID();return{hookToken:t,runId:(await startWorkflowOnCurrentDeployment(workflowToolRunWorkflowReference,[{...e,hookToken:t}])).runId}}async function startWorkflowTask(e){let{task:n,batchEvent:r,session:i}=e;try{let t=await startWorkflowToolRun({callId:n.callId,executeInput:n.executeInput,input:n.input,owner:e.owner,resultKind:n.resultKind,session:{auth:{current:e.auth,initiator:e.initiatorAuth},id:i.sessionId,parent:e.parentSession,turn:{id:r.turnId,sequence:r.sequence}},stepIndex:r.stepIndex,toolName:n.toolName,workflowId:n.workflowId});return{session:recordWorkflowToolRun(i,{callId:n.callId,hookToken:t.hookToken,resultKind:n.resultKind??`tool`,runId:t.runId,toolName:n.toolName})}}catch(e){return logError(log,`workflow tool run failed to start`,e,{callId:n.callId,toolName:n.toolName}),{result:createRuntimeToolResultFromValue({callId:n.callId,isError:!0,output:toError(e),toolName:n.toolName}),session:i}}}export{startWorkflowTask,startWorkflowToolRun};
@@ -1,3 +1,3 @@
1
1
  import type { WorkflowToolRunInput } from "#execution/tools/workflow/types.js";
2
- /** Runs one authored workflow tool call and reports to its declared owner hooks. */
2
+ /** Runs one authored workflow tool call and reports to its declared owner hook. */
3
3
  export declare function workflowToolRunWorkflow(input: WorkflowToolRunInput): Promise<void>;
@@ -1 +1 @@
1
- import{sleep}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{createWorkflowBodyRef,executeWorkflowBody}from"#execution/tools/workflow/body.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{openWorkflowToolRunControlInbox}from"#execution/tools/workflow/run-control.js";async function workflowToolRunWorkflow(i){"use workflow";let a=openWorkflowToolRunControlInbox(i.hookToken),o=!1;try{try{await claimHookOwnership(a.hook),o=!0}catch(e){if(isHookConflictError(e))return;throw e}let n={...i,execution:i.execution??`blocking`},r=createWorkflowBodyRef(n),s=executeWorkflowBody(n,a.signal).then(e=>{if(e.status===`completed`)return e.output;throw e.status===`failed`?e.error:a.signal.reason??Error(e.reason??`Workflow tool run cancelled.`)}),c=s.catch(()=>{}),l;try{l={output:await Promise.race([s,a.cancelled]),status:`completed`}}catch(t){a.signal.aborted?(await Promise.race([c,sleep(`30s`)]),l={reason:a.reason(),status:`cancelled`}):l={error:normalizeSerializableError(t),status:`failed`}}let u={from:r,result:l};await resumeHookStep(i.owner.outcome,u,{ifPresent:l.status===`cancelled`})}finally{o&&await disposeHook(a.hook)}}export{workflowToolRunWorkflow};
1
+ import{sleep}from"#compiled/@workflow/core/index.js";import{createWorkflowBodyRef,executeWorkflowBody}from"#execution/tools/workflow/body.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{openWorkflowToolRunControlInbox}from"#execution/tools/workflow/run-control.js";async function workflowToolRunWorkflow(n){"use workflow";let r=openWorkflowToolRunControlInbox(n.hookToken),i={...n,execution:n.execution??`blocking`},a=createWorkflowBodyRef(i),o=executeWorkflowBody(i,r.signal).then(({outcome:e})=>{if(e.status===`completed`)return e.output;throw e.status===`failed`?e.error:r.signal.reason??Error(e.reason??`Workflow tool run cancelled.`)}),s=o.catch(()=>{}),c;try{c={output:await Promise.race([o,r.cancelled]),status:`completed`}}catch(t){r.signal.aborted?(await Promise.race([s,sleep(`30s`)]),c={reason:r.reason(),status:`cancelled`}):c={error:normalizeSerializableError(t),status:`failed`}}let l={from:a,result:c};await resumeHookStep(n.owner.inbox,{kind:`outcome`,...l},{ifPresent:c.status===`cancelled`})}workflowToolRunWorkflow.workflowId=`workflow//eve//workflowToolRunWorkflow`;export{workflowToolRunWorkflow};
@@ -13,6 +13,7 @@ export interface TurnCancellationControl {
13
13
  * the signal aborted. Race it against turn-owned awaits — never
14
14
  * `await` it alone.
15
15
  */
16
+ readonly payload: Promise<TurnCancelPayload>;
16
17
  readonly requested: Promise<"cancel">;
17
18
  /** Disposes the hook, abandoning any outstanding read. Idempotent. */
18
19
  dispose(): Promise<void>;
@@ -1 +1 @@
1
- import{createHook}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{TurnCancelledError}from"#harness/turn-cancellation.js";import{turnCancellationHookToken}from"#execution/turn-cancellation-token.js";async function createTurnCancellationControl(i){let a=createHook({token:turnCancellationHookToken(i.controlToken)}),o=a[Symbol.asyncIterator]();try{await claimHookOwnership(a)}catch(e){if(isHookConflictError(e))return;throw e}let s=new AbortController,abort=()=>s.abort(new TurnCancelledError),c=i.initialPayload!==void 0&&matchesActiveTurn(i.initialPayload,i.expectedTurnId);c&&abort();let l=c?Promise.resolve(`cancel`):consumeMatchingCancel(o,i.expectedTurnId,abort).then(()=>`cancel`),u=!1;return{signal:s.signal,requested:l,async dispose(){u||(u=!0,await disposeHook(a))}}}async function consumeMatchingCancel(e,t,n){for(;;){let r=await e.next();if(r.done)return await new Promise(()=>{});if(matchesActiveTurn(r.value,t)){n();return}}}function matchesActiveTurn(e,t){if(typeof e!=`object`||!e)return!0;let n=e.turnId;return n===void 0||n===t}export{createTurnCancellationControl};
1
+ import{createHook}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{TurnCancelledError}from"#harness/turn-cancellation.js";import{turnCancellationHookToken}from"#execution/turn-cancellation-token.js";async function createTurnCancellationControl(i){let a=createHook({token:turnCancellationHookToken(i.controlToken)}),o=a[Symbol.asyncIterator]();try{await claimHookOwnership(a)}catch(e){if(isHookConflictError(e))return;throw e}let s=new AbortController,abort=()=>s.abort(new TurnCancelledError),c=i.initialPayload!==void 0&&matchesActiveTurn(i.initialPayload,i.expectedTurnId);c&&abort();let l=c?Promise.resolve(i.initialPayload):consumeMatchingCancel(o,i.expectedTurnId,abort),u=!1;return{payload:l,signal:s.signal,requested:l.then(()=>`cancel`),async dispose(){u||(u=!0,await disposeHook(a))}}}async function consumeMatchingCancel(e,t,n){for(;;){let r=await e.next();if(r.done)return await new Promise(()=>{});if(matchesActiveTurn(r.value,t))return n(),r.value}}function matchesActiveTurn(e,t){if(typeof e!=`object`||!e)return!0;let n=e.turnId;return n===void 0||n===t}export{createTurnCancellationControl};
@@ -5,5 +5,6 @@ export declare function turnCancellationHookToken(controlToken: string): string;
5
5
  * benign no-op; omitting it targets whichever turn owns the hook.
6
6
  */
7
7
  export interface TurnCancelPayload {
8
+ readonly tasks?: boolean;
8
9
  readonly turnId?: string;
9
10
  }
@@ -1,6 +1,7 @@
1
1
  import type { DeliverHookPayload } from "#channel/types.js";
2
2
  import type { NextDriverAction } from "#execution/next-driver-action.js";
3
3
  import type { SessionCommandInbox } from "#execution/session-command-inbox.js";
4
+ import type { SessionStateCursor } from "#execution/session-state-cursor.js";
4
5
  export type TurnDriverAction = NextDriverAction;
5
6
  /** Owns one turn's driver-side control hook and public-delivery relay state. */
6
7
  export declare class TurnControlReceiver {
@@ -12,6 +13,7 @@ export declare class TurnControlReceiver {
12
13
  private readonly expectedTurnId;
13
14
  private readonly cancelledTaskIds;
14
15
  private readonly seenTaskDeliveries;
16
+ private readonly stateCursor;
15
17
  private pendingControl;
16
18
  constructor(input: {
17
19
  readonly bufferedDeliveries: DeliverHookPayload[];
@@ -20,6 +22,7 @@ export declare class TurnControlReceiver {
20
22
  readonly commandInbox: SessionCommandInbox;
21
23
  readonly expectedTurnId: string;
22
24
  readonly seenTaskDeliveries?: Set<string>;
25
+ readonly stateCursor: SessionStateCursor;
23
26
  readonly token: string;
24
27
  });
25
28
  /** Token passed to the turn workflow so it can publish control messages. */