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
@@ -1 +1 @@
1
- import{createHook}from"#compiled/@workflow/core/index.js";import{closeHookIterator,disposeHook}from"#execution/hook-ownership.js";import{reportDroppedWirePayloadStep}from"#execution/report-dropped-wire-payload-step.js";import{SessionInboxWireError,sessionInboxWire}from"#execution/wire/session-inbox-wire.js";import{rebuildSerializableError}from"#execution/workflow-errors.js";import{turnCancellationHookToken}from"#execution/turn-cancellation-token.js";import{forwardTurnCancellationStep}from"#execution/forward-turn-cancellation-step.js";import{forwardTurnDeliveryStep}from"#execution/forward-turn-delivery-step.js";var TurnControlReceiver=class{bufferedDeliveries;bufferedSessionControls;commandInbox;control;controlIterator;expectedTurnId;cancelledTaskIds;seenTaskDeliveries;pendingControl=null;constructor(t){this.bufferedDeliveries=t.bufferedDeliveries,this.bufferedSessionControls=t.bufferedSessionControls,this.cancelledTaskIds=t.cancelledTaskIds??new Set,this.commandInbox=t.commandInbox,this.seenTaskDeliveries=t.seenTaskDeliveries??new Set,this.control=createHook({token:t.token}),this.controlIterator=this.control[Symbol.asyncIterator](),this.expectedTurnId=t.expectedTurnId}get token(){return this.control.token}async dispose(){await closeHookIterator(this.controlIterator),await disposeHook(this.control)}async waitForAction(){for(;;){let e=await this.nextControlOrCommand();if(e.kind===`command`){let t=await this.handleSessionCommand(e.command);if(t!==void 0)return t;continue}let t=e.payload,n=this.readTerminalControl(t);if(n!==void 0)return n;if(t.kind===`turn-delivery-request`){let e=await this.serviceDeliveryRequest(t);if(e!==void 0)return e}}}async handleSessionCommand(e){if(e.kind===`deliver`){if(!this.acceptTaskDelivery(e))return;await this.bufferDelivery(e);return}if(e.kind===`clear`||e.kind===`compact`){this.bufferedSessionControls.push(e.kind);return}if(e.kind===`session-timeout`){this.bufferedSessionControls.push(`expired`);return}if(e.kind===`cancel`){e.taskId!==void 0&&this.discardTaskDeliveries(e.taskId);let t=e.taskId!==void 0&&e.turnId!==void 0&&e.turnId!==this.expectedTurnId?void 0:e.turnId;await forwardTurnCancellationStep({payload:t===void 0?{}:{turnId:t},token:turnCancellationHookToken(this.control.token)});return}if(e.kind===`reset`){await forwardTurnCancellationStep({payload:{},token:turnCancellationHookToken(this.control.token)}),this.bufferedSessionControls.push(`reset`);return}return unsupportedSessionCommand(e)}async bufferDelivery(e){this.bufferedDeliveries.push(e),!(e.turnPolicy!==`steer`||!deliveryHasMessage(e))&&await forwardTurnCancellationStep({payload:{},token:turnCancellationHookToken(this.control.token)})}bufferTurnDeliveries(e){e.bufferedDeliveries!==void 0&&this.bufferedDeliveries.unshift(...e.bufferedDeliveries.filter(e=>!this.shouldDiscard(e)))}consumeControl(){this.pendingControl=null}getControlPromise(){return this.pendingControl??=this.controlIterator.next(),this.pendingControl}async nextControlOrCommand(){let e=await Promise.race([this.getControlPromise().then(e=>({kind:`control`,value:e})),this.commandInbox.next().then(e=>({kind:`command`,value:e}))]);if(e.kind===`command`){if(e.value.done)throw Error(`Session command inbox closed before the active turn settled.`);if(this.commandInbox.consumeNext(),e.value.value.kind===`runtime-action-result`)return await this.nextControlOrCommand();try{return{command:sessionInboxWire.decode(e.value.value),kind:`command`}}catch(e){if(!(e instanceof SessionInboxWireError))throw e;return await reportDroppedWirePayloadStep({detail:e.message,family:`session-inbox`}),await this.nextControlOrCommand()}}if(this.consumeControl(),e.value.done)throw Error(`Turn control hook closed before delivering a result.`);let t=e.value.value;if(t.kind===`turn-error`)throw rebuildSerializableError(t.error);return t.kind===`turn-continuation-token`?(await this.commandInbox.rekeyContinuation(t.continuationToken),await this.nextControlOrCommand()):{kind:`control`,payload:t}}readTerminalControl(e){if(e.kind===`turn-error`)throw rebuildSerializableError(e.error);if(e.kind===`turn-result`)return this.bufferTurnDeliveries(e),e.action}async serviceDeliveryRequest(e){await this.commandInbox.rekeyContinuation(e.continuationToken);let t=this.takeInputResponseDelivery();for(;t===void 0;){let n=await Promise.race([this.getControlPromise().then(e=>({kind:`control`,value:e})),this.commandInbox.next().then(e=>({kind:`command`,value:e}))]);if(n.kind===`control`){if(this.consumeControl(),n.value.done)throw Error(`Turn control hook closed during a delivery request.`);if(n.value.value.kind===`turn-continuation-token`){await this.commandInbox.rekeyContinuation(n.value.value.continuationToken);continue}let t=this.readTerminalControl(n.value.value);if(t!==void 0)return t;if(n.value.value.kind===`turn-delivery-cancelled`&&n.value.value.requestId===e.requestId)return;continue}if(n.value.done)throw Error(`Session command inbox closed during a turn delivery request.`);if(this.commandInbox.consumeNext(),n.value.value.kind===`runtime-action-result`)continue;let a;try{a=sessionInboxWire.decode(n.value.value)}catch(e){if(!(e instanceof SessionInboxWireError))throw e;await reportDroppedWirePayloadStep({detail:e.message,family:`session-inbox`});continue}if(a.kind===`deliver`){if(!this.acceptTaskDelivery(a))continue;deliveryHasMessage(a)?await this.bufferDelivery(a):t=a;continue}let o=await this.handleSessionCommand(a);if(o!==void 0)return o}try{await forwardTurnDeliveryStep({inboxToken:e.inboxToken,payload:{delivery:t,kind:`driver-delivery`,requestId:e.requestId}})}catch(e){if(!(e instanceof Error&&e.name===`HookNotFoundError`))throw e}return await this.awaitForwardedDelivery(e.requestId,t)}takeInputResponseDelivery(){let e=this.bufferedDeliveries.findIndex(e=>!deliveryHasMessage(e));if(e!==-1)return this.bufferedDeliveries.splice(e,1)[0]}async awaitForwardedDelivery(e,t){for(;;){let n=await this.nextControlOrCommand();if(n.kind===`command`){let e=await this.handleSessionCommand(n.command);if(e!==void 0)return this.shouldDiscard(t)||this.bufferedDeliveries.unshift(t),e;continue}let r=n.payload;if(r.kind===`turn-delivery-accepted`){if(r.requestId===e)return;continue}if(r.kind===`turn-delivery-cancelled`&&r.requestId===e){this.shouldDiscard(t)||this.bufferedDeliveries.unshift(t);return}r.kind===`turn-result`&&(this.shouldDiscard(t)||this.bufferedDeliveries.unshift(t));let i=this.readTerminalControl(r);if(i!==void 0)return i}}acceptTaskDelivery(e){let t=e.taskDeliveryId??e.caller?.taskId;return t===void 0?!0:this.originatesFromCancelledTask(t)||this.seenTaskDeliveries.has(t)?!1:(this.seenTaskDeliveries.add(t),!0)}discardTaskDeliveries(e){this.cancelledTaskIds.add(e);let t=this.bufferedDeliveries.filter(e=>!this.shouldDiscard(e));this.bufferedDeliveries.splice(0,this.bufferedDeliveries.length,...t)}originatesFromCancelledTask(e){return[...this.cancelledTaskIds].some(t=>deliveryOriginatesFromTask(e,t))}shouldDiscard(e){let t=e.taskDeliveryId??e.caller?.taskId;return t!==void 0&&this.originatesFromCancelledTask(t)}};function deliveryOriginatesFromTask(e,t){return e===t||e.startsWith(`${t}:`)}function deliveryHasMessage(e){return e.payloads.some(e=>e.message!==void 0)}function unsupportedSessionCommand(e){throw Error(`Unsupported session command: ${JSON.stringify(e)}`)}export{TurnControlReceiver};
1
+ import{createHook}from"#compiled/@workflow/core/index.js";import{closeHookIterator,disposeHook}from"#execution/hook-ownership.js";import{cancelAllIndexedSessionTasksStep}from"#execution/cancel-indexed-session-tasks-step.js";import{reportDroppedWirePayloadStep}from"#execution/report-dropped-wire-payload-step.js";import{SessionInboxWireError,sessionInboxWire}from"#execution/wire/session-inbox-wire.js";import{rebuildSerializableError}from"#execution/workflow-errors.js";import{turnCancellationHookToken}from"#execution/turn-cancellation-token.js";import{forwardTurnCancellationStep}from"#execution/forward-turn-cancellation-step.js";import{forwardTurnDeliveryStep}from"#execution/forward-turn-delivery-step.js";var TurnControlReceiver=class{bufferedDeliveries;bufferedSessionControls;commandInbox;control;controlIterator;expectedTurnId;cancelledTaskIds;seenTaskDeliveries;stateCursor;pendingControl=null;constructor(t){this.bufferedDeliveries=t.bufferedDeliveries,this.bufferedSessionControls=t.bufferedSessionControls,this.cancelledTaskIds=t.cancelledTaskIds??new Set,this.commandInbox=t.commandInbox,this.seenTaskDeliveries=t.seenTaskDeliveries??new Set,this.stateCursor=t.stateCursor,this.control=createHook({token:t.token}),this.controlIterator=this.control[Symbol.asyncIterator](),this.expectedTurnId=t.expectedTurnId}get token(){return this.control.token}async dispose(){await closeHookIterator(this.controlIterator),await disposeHook(this.control)}async waitForAction(){for(;;){let e=await this.nextControlOrCommand();if(e.kind===`command`){let t=await this.handleSessionCommand(e.command);if(t!==void 0)return t;continue}let t=e.payload,n=this.readTerminalControl(t);if(n!==void 0)return n;if(t.kind===`turn-delivery-request`){let e=await this.serviceDeliveryRequest(t);if(e!==void 0)return e}}}async handleSessionCommand(e){if(e.kind===`deliver`){if(!this.acceptTaskDelivery(e))return;await this.bufferDelivery(e);return}if(e.kind===`clear`||e.kind===`compact`){this.bufferedSessionControls.push(e.kind);return}if(e.kind===`session-timeout`){this.bufferedSessionControls.push(`expired`);return}if(e.kind===`cancel`){`tasks`in e&&e.tasks===!0&&await cancelAllIndexedSessionTasksStep({serializedContext:this.stateCursor.serializedContext,sessionState:this.stateCursor.sessionState}),e.taskId!==void 0&&this.discardTaskDeliveries(e.taskId);let t=e.taskId!==void 0&&e.turnId!==void 0&&e.turnId!==this.expectedTurnId?void 0:e.turnId,n={tasks:e.tasks};t!==void 0&&(n.turnId=t),await forwardTurnCancellationStep({payload:n,token:turnCancellationHookToken(this.control.token)});return}if(e.kind===`reset`){await forwardTurnCancellationStep({payload:{},token:turnCancellationHookToken(this.control.token)}),this.bufferedSessionControls.push(`reset`);return}return unsupportedSessionCommand(e)}async bufferDelivery(e){this.bufferedDeliveries.push(e),!(e.turnPolicy!==`steer`||!deliveryHasMessage(e))&&await forwardTurnCancellationStep({payload:{},token:turnCancellationHookToken(this.control.token)})}bufferTurnDeliveries(e){e.bufferedDeliveries!==void 0&&this.bufferedDeliveries.unshift(...e.bufferedDeliveries.filter(e=>!this.shouldDiscard(e)))}consumeControl(){this.pendingControl=null}getControlPromise(){return this.pendingControl??=this.controlIterator.next(),this.pendingControl}async nextControlOrCommand(){let e=await Promise.race([this.getControlPromise().then(e=>({kind:`control`,value:e})),this.commandInbox.next().then(e=>({kind:`command`,value:e}))]);if(e.kind===`command`){if(e.value.done)throw Error(`Session command inbox closed before the active turn settled.`);if(this.commandInbox.consumeNext(),e.value.value.kind===`runtime-action-result`)return await this.nextControlOrCommand();try{return{command:sessionInboxWire.decode(e.value.value),kind:`command`}}catch(e){if(!(e instanceof SessionInboxWireError))throw e;return await reportDroppedWirePayloadStep({detail:e.message,family:`session-inbox`}),await this.nextControlOrCommand()}}if(this.consumeControl(),e.value.done)throw Error(`Turn control hook closed before delivering a result.`);let t=e.value.value;if(t.kind===`turn-error`)throw rebuildSerializableError(t.error);return t.kind===`turn-continuation-token`?(await this.commandInbox.rekeyContinuation(t.continuationToken),await this.nextControlOrCommand()):{kind:`control`,payload:t}}readTerminalControl(e){if(e.kind===`turn-error`)throw rebuildSerializableError(e.error);if(e.kind===`turn-result`)return this.bufferTurnDeliveries(e),e.action}async serviceDeliveryRequest(e){await this.commandInbox.rekeyContinuation(e.continuationToken);let t=this.takeInputResponseDelivery();for(;t===void 0;){let n=await Promise.race([this.getControlPromise().then(e=>({kind:`control`,value:e})),this.commandInbox.next().then(e=>({kind:`command`,value:e}))]);if(n.kind===`control`){if(this.consumeControl(),n.value.done)throw Error(`Turn control hook closed during a delivery request.`);if(n.value.value.kind===`turn-continuation-token`){await this.commandInbox.rekeyContinuation(n.value.value.continuationToken);continue}let t=this.readTerminalControl(n.value.value);if(t!==void 0)return t;if(n.value.value.kind===`turn-delivery-cancelled`&&n.value.value.requestId===e.requestId)return;continue}if(n.value.done)throw Error(`Session command inbox closed during a turn delivery request.`);if(this.commandInbox.consumeNext(),n.value.value.kind===`runtime-action-result`)continue;let r;try{r=sessionInboxWire.decode(n.value.value)}catch(e){if(!(e instanceof SessionInboxWireError))throw e;await reportDroppedWirePayloadStep({detail:e.message,family:`session-inbox`});continue}if(r.kind===`deliver`){if(!this.acceptTaskDelivery(r))continue;deliveryHasMessage(r)?await this.bufferDelivery(r):t=r;continue}let a=await this.handleSessionCommand(r);if(a!==void 0)return a}try{await forwardTurnDeliveryStep({inboxToken:e.inboxToken,payload:{delivery:t,kind:`driver-delivery`,requestId:e.requestId}})}catch(e){if(!(e instanceof Error&&e.name===`HookNotFoundError`))throw e}return await this.awaitForwardedDelivery(e.requestId,t)}takeInputResponseDelivery(){let e=this.bufferedDeliveries.findIndex(e=>!deliveryHasMessage(e));if(e!==-1)return this.bufferedDeliveries.splice(e,1)[0]}async awaitForwardedDelivery(e,t){for(;;){let n=await this.nextControlOrCommand();if(n.kind===`command`){let e=await this.handleSessionCommand(n.command);if(e!==void 0)return this.shouldDiscard(t)||this.bufferedDeliveries.unshift(t),e;continue}let r=n.payload;if(r.kind===`turn-delivery-accepted`){if(r.requestId===e)return;continue}if(r.kind===`turn-delivery-cancelled`&&r.requestId===e){this.shouldDiscard(t)||this.bufferedDeliveries.unshift(t);return}r.kind===`turn-result`&&(this.shouldDiscard(t)||this.bufferedDeliveries.unshift(t));let i=this.readTerminalControl(r);if(i!==void 0)return i}}acceptTaskDelivery(e){let t=e.taskDeliveryId??e.caller?.taskId;return t===void 0?!0:this.originatesFromCancelledTask(t)||this.seenTaskDeliveries.has(t)?!1:(this.seenTaskDeliveries.add(t),!0)}discardTaskDeliveries(e){this.cancelledTaskIds.add(e);let t=this.bufferedDeliveries.filter(e=>!this.shouldDiscard(e));this.bufferedDeliveries.splice(0,this.bufferedDeliveries.length,...t)}originatesFromCancelledTask(e){return[...this.cancelledTaskIds].some(t=>deliveryOriginatesFromTask(e,t))}shouldDiscard(e){let t=e.taskDeliveryId??e.caller?.taskId;return t!==void 0&&this.originatesFromCancelledTask(t)}};function deliveryOriginatesFromTask(e,t){return e===t||e.startsWith(`${t}:`)}function deliveryHasMessage(e){return e.payloads.some(e=>e.message!==void 0)}function unsupportedSessionCommand(e){throw Error(`Unsupported session command: ${JSON.stringify(e)}`)}export{TurnControlReceiver};
@@ -1,6 +1,7 @@
1
1
  import type { DeliverHookPayload, HookPayload, SessionCapabilities } from "#channel/types.js";
2
2
  import type { DurableSessionState } from "#execution/durable-session-store.js";
3
3
  import type { SessionCommandInbox } from "#execution/session-command-inbox.js";
4
+ import { SessionStateCursor } from "#execution/session-state-cursor.js";
4
5
  import type { TurnDriverAction } from "#execution/turn-control-receiver.js";
5
6
  import type { RunMode } from "#shared/run-mode.js";
6
7
  /** One settled turn: its terminal driver action plus deferred hook cleanup. */
@@ -30,6 +31,7 @@ interface TurnDispatchInput {
30
31
  readonly serializedContext: Record<string, unknown>;
31
32
  readonly seenTaskDeliveries?: Set<string>;
32
33
  readonly sessionState: DurableSessionState;
34
+ readonly stateCursor?: SessionStateCursor;
33
35
  }
34
36
  export declare function dispatchAndAwaitTurn(input: TurnDispatchInput): Promise<DispatchedTurn>;
35
37
  export {};
@@ -1 +1 @@
1
- import{activeTurnId}from"#harness/active-turn-id.js";import{dispatchTurnStep}from"#execution/dispatch-turn-step.js";import{TurnControlReceiver}from"#execution/turn-control-receiver.js";import{runInlineTurn}from"#execution/inline-turn.js";async function dispatchAndAwaitTurn(e){let t=await runInlineTurn(e);return t.kind===`result`?{action:t.action,async dispose(){}}:await dispatchAndAwaitChildTurn({...e,initialCancellation:t.initialCancellation,initialStep:t.initialStep})}async function dispatchAndAwaitChildTurn(n){let r=new TurnControlReceiver({bufferedDeliveries:n.bufferedDeliveries,bufferedSessionControls:n.bufferedSessionControls,cancelledTaskIds:n.cancelledTaskIds,commandInbox:n.commandInbox,expectedTurnId:activeTurnId(n.sessionState.emissionState),seenTaskDeliveries:n.seenTaskDeliveries??new Set,token:n.controlToken});try{return await dispatchTurnStep({capabilities:n.capabilities,completionToken:r.token,delivery:n.delivery,initialCancellation:n.initialCancellation,initialStep:n.initialStep,mode:n.mode,parentWritable:n.parentWritable,serializedContext:n.serializedContext,sessionState:n.sessionState}),{action:await r.waitForAction(),dispose:()=>r.dispose()}}catch(e){throw await r.dispose(),e}}export{dispatchAndAwaitTurn};
1
+ import{activeTurnId}from"#harness/active-turn-id.js";import{createTurnWorkflowInput}from"#execution/durable-session-migrations/turn-workflow.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{dispatchTurnStep}from"#execution/dispatch-turn-step.js";import{TurnControlReceiver}from"#execution/turn-control-receiver.js";import{runInlineTurn}from"#execution/inline-turn.js";import{runTurnOwnedWorkflow}from"#execution/turn-workflow.js";async function dispatchAndAwaitTurn(e){let t=e.stateCursor??new SessionStateCursor({serializedContext:e.serializedContext,sessionState:e.sessionState}),r=await runInlineTurn({...e,stateCursor:t});return r.kind===`result`?{action:r.action,async dispose(){}}:await runAndAwaitTurn({...e,inline:r.kind===`continue`,initialCancellation:r.initialCancellation,stateCursor:t,initialStep:r.initialStep})}async function runAndAwaitTurn(n){let a=new TurnControlReceiver({bufferedDeliveries:n.bufferedDeliveries,bufferedSessionControls:n.bufferedSessionControls,cancelledTaskIds:n.cancelledTaskIds,commandInbox:n.commandInbox,expectedTurnId:activeTurnId(n.sessionState.emissionState),seenTaskDeliveries:n.seenTaskDeliveries??new Set,stateCursor:n.stateCursor,token:n.controlToken});try{let e={capabilities:n.capabilities,completionToken:a.token,delivery:n.delivery,initialCancellation:n.initialCancellation,initialStep:n.initialStep,mode:n.mode,parentWritable:n.parentWritable,serializedContext:n.serializedContext,sessionState:n.sessionState},i;if(n.inline){let n=Promise.withResolvers();[i]=await Promise.all([n.promise.then(()=>a.waitForAction()),runTurnOwnedWorkflow(createTurnWorkflowInput(e),n.resolve)])}else await dispatchTurnStep(e),i=await a.waitForAction();return{action:i,dispose:()=>a.dispose()}}catch(e){throw await a.dispose(),e}}export{dispatchAndAwaitTurn};
@@ -1,4 +1,4 @@
1
- import type { WorkflowToolRunOutcomeMessage, WorkflowToolRunRequestMessage } from "#execution/tools/workflow/messages.js";
1
+ import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.js";
2
2
  import type { TurnExecutionCursor } from "#execution/turn-execution-cursor.js";
3
3
  import type { RuntimeActionResult } from "#shared/action-types.js";
4
4
  interface HandlerInput<T> {
@@ -6,11 +6,5 @@ interface HandlerInput<T> {
6
6
  readonly cursor: TurnExecutionCursor;
7
7
  readonly message: T;
8
8
  }
9
- /**
10
- * Settles a workflow tool run outcome against the turn's recorded runs and
11
- * returns the runtime action result the turn should accept, or `undefined`
12
- * when the outcome does not bind to a run this turn owns.
13
- */
14
- export declare function handleWorkflowToolRunOutcome(input: HandlerInput<WorkflowToolRunOutcomeMessage>): Promise<RuntimeActionResult | undefined>;
15
- export declare function handleWorkflowToolRunRequest(input: HandlerInput<WorkflowToolRunRequestMessage>): Promise<void>;
9
+ export declare function handleWorkflowToolRunMessage(input: HandlerInput<WorkflowToolRunMessage>): Promise<RuntimeActionResult | undefined>;
16
10
  export {};
@@ -1 +1 @@
1
- import{findWorkflowToolRun,isInboxSubagentResultFromRecordedWorkflowToolRun,isInboxToolResultFromRecordedWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{cancelAgentInvocationOwnerStep}from"#execution/tools/subagent/task-cancel.js";import{runProxySubagentEventStep}from"#subagents/event-proxy-step.js";import{applyTaskAgentRequest}from"#execution/tools/subagent/task-agent-requests.js";import{workflowToolRunOutcomeToSubagentResult,workflowToolRunOutcomeToToolResult,workflowToolRunRequestToInputRequestPayload}from"#execution/tools/workflow/owner-inbox.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{releaseAgentInvocationOwnerStep}from"#execution/tools/subagent/invoke-step.js";async function handleWorkflowToolRunOutcome(i){let{cursor:a,message:o}=i,s=findWorkflowToolRun(a.sessionState.snapshot?.session.state,o.from.callId);if(s?.runId!==o.from.runId)return;let c=s.resultKind===`subagent`?await settleSubagentOutcome(i):workflowToolRunOutcomeToToolResult(o);await cancelAgentInvocationOwnerStep({ownerId:o.from.runId,serializedContext:a.serializedContext,sessionState:a.sessionState});let l=await releaseAgentInvocationOwnerStep({cancelled:o.result.status===`cancelled`,ownerId:o.from.runId,sessionState:a.sessionState});await a.adopt({serializedContext:a.serializedContext,sessionState:l.sessionState});let u=a.sessionState.snapshot?.session.state;return(c.kind===`subagent-result`?c.callId===o.from.callId&&isInboxSubagentResultFromRecordedWorkflowToolRun(u,c):isInboxToolResultFromRecordedWorkflowToolRun(u,c))?c:void 0}async function settleSubagentOutcome(e){let{cursor:t,message:n}=e,r=workflowToolRunOutcomeToSubagentResult(n);return r.origin===`child`&&await t.adopt(await applyTaskAgentRequest({accumulateUsage:!1,ownerId:n.from.runId,replyTo:n.from.runId,request:{kind:`agent-settled`,result:r}},requestContext(e))),r}async function handleWorkflowToolRunRequest(t){let{cursor:n,message:r}=t;if(r.request.kind===`agent-invoke`||r.request.kind===`agent-settled`){if(findWorkflowToolRun(n.sessionState.snapshot?.session.state,r.from.callId)?.runId!==r.from.runId){r.request.kind===`agent-invoke`&&await resumeHookStep(r.replyTo,{kind:`runtime-action-result`,results:[{callId:r.request.invocationId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:`AGENT_INVOCATION_NOT_ADMITTED`,message:`The workflow tool run no longer owns this agent invocation.`},subagentName:r.request.input.target}]});return}await n.adopt(await applyTaskAgentRequest({accumulateUsage:r.from.resultKind!==`subagent`,ownerId:r.from.runId,replyTo:r.replyTo,request:r.request},requestContext(t)));return}if(r.request.kind===`authorization-request`){await n.adopt(await runProxySubagentEventStep({hookPayload:r.request.event,parentWritable:n.parentWritable,serializedContext:n.serializedContext,sessionState:n.sessionState}));return}await n.adopt(await runProxySubagentEventStep({...r.requestCoordinates===void 0?{answerHook:{runId:r.from.runId}}:{},hookPayload:workflowToolRunRequestToInputRequestPayload(r),parentWritable:n.parentWritable,serializedContext:n.serializedContext,sessionState:n.sessionState}))}function requestContext(e){return{callbackBaseUrl:resolveWorkflowCallbackBaseUrl(e.callbackMetadataUrl),parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState}}export{handleWorkflowToolRunOutcome,handleWorkflowToolRunRequest};
1
+ import{findWorkflowToolRun,isInboxSubagentResultFromRecordedWorkflowToolRun,isInboxToolResultFromRecordedWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{cancelAgentInvocationOwnerStep}from"#execution/tools/subagent/task-cancel.js";import{runProxySubagentEventStep}from"#subagents/event-proxy-step.js";import{applyTaskAgentRequest}from"#execution/tools/subagent/task-agent-requests.js";import{workflowToolRunOutcomeToSubagentResult,workflowToolRunOutcomeToToolResult,workflowToolRunRequestToInputRequestPayload}from"#execution/tools/workflow/owner-inbox.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{releaseAgentInvocationOwnerStep}from"#execution/tools/subagent/invoke-step.js";import{emitWorkflowToolRunReportStep}from"#execution/tools/workflow/emit-workflow-tool-run-report-step.js";async function handleWorkflowToolRunMessage(e){let{message:t}=e;switch(t.kind){case`outcome`:return await handleWorkflowToolRunOutcome({...e,message:t});case`request`:await handleWorkflowToolRunRequest({...e,message:t});return;case`report`:await emitWorkflowToolRunReportStep({from:t.from,parentWritable:e.cursor.parentWritable,update:t.update});return}}async function handleWorkflowToolRunOutcome(i){let{cursor:a,message:o}=i,s=findWorkflowToolRun(a.sessionState.snapshot?.session.state,o.from.callId);if(s?.runId!==o.from.runId)return;let c=s.resultKind===`subagent`?await settleSubagentOutcome(i):workflowToolRunOutcomeToToolResult(o);await cancelAgentInvocationOwnerStep({ownerId:o.from.runId,serializedContext:a.serializedContext,sessionState:a.sessionState});let l=await releaseAgentInvocationOwnerStep({cancelled:o.result.status===`cancelled`,ownerId:o.from.runId,sessionState:a.sessionState});await a.adopt({serializedContext:a.serializedContext,sessionState:l.sessionState});let u=a.sessionState.snapshot?.session.state;return(c.kind===`subagent-result`?c.callId===o.from.callId&&isInboxSubagentResultFromRecordedWorkflowToolRun(u,c):isInboxToolResultFromRecordedWorkflowToolRun(u,c))?c:void 0}async function settleSubagentOutcome(e){let{cursor:t,message:n}=e,r=workflowToolRunOutcomeToSubagentResult(n);return r.origin===`child`&&await t.adopt(await applyTaskAgentRequest({accumulateUsage:!1,ownerId:n.from.runId,replyTo:n.from.runId,request:{kind:`agent-settled`,result:r}},requestContext(e))),r}async function handleWorkflowToolRunRequest(t){let{cursor:n,message:r}=t;if(r.request.kind===`agent-invoke`||r.request.kind===`agent-settled`){if(findWorkflowToolRun(n.sessionState.snapshot?.session.state,r.from.callId)?.runId!==r.from.runId){r.request.kind===`agent-invoke`&&await resumeHookStep(r.replyTo,{kind:`runtime-action-result`,results:[{callId:r.request.invocationId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:`AGENT_INVOCATION_NOT_ADMITTED`,message:`The workflow tool run no longer owns this agent invocation.`},subagentName:r.request.input.target}]});return}await n.adopt(await applyTaskAgentRequest({accumulateUsage:r.from.resultKind!==`subagent`,ownerId:r.from.runId,replyTo:r.replyTo,request:r.request},requestContext(t)));return}if(r.request.kind===`authorization-request`){await n.adopt(await runProxySubagentEventStep({hookPayload:r.request.event,parentWritable:n.parentWritable,serializedContext:n.serializedContext,sessionState:n.sessionState}));return}await n.adopt(await runProxySubagentEventStep({...r.requestCoordinates===void 0?{answerHook:{runId:r.from.runId}}:{},hookPayload:workflowToolRunRequestToInputRequestPayload(r),parentWritable:n.parentWritable,serializedContext:n.serializedContext,sessionState:n.sessionState}))}function requestContext(e){return{callbackBaseUrl:resolveWorkflowCallbackBaseUrl(e.callbackMetadataUrl),parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState}}export{handleWorkflowToolRunMessage};
@@ -10,3 +10,4 @@ export type { TurnWorkflowInput };
10
10
  * guard-mismatched cancel is a benign no-op.
11
11
  */
12
12
  export declare function turnWorkflow(rawInput: unknown): Promise<void>;
13
+ export declare function runTurnOwnedWorkflow(input: TurnWorkflowInput, onReady?: () => void): Promise<void>;
@@ -1 +1 @@
1
- import{createHook,getWorkflowMetadata,sleep}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{isInboxSubagentResultFromRecordedWorkflowToolRun,isInboxToolResultFromRecordedWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{activeTurnId}from"#harness/active-turn-id.js";import{migrateTurnWorkflowInput}from"#execution/durable-session-migrations/turn-workflow.js";import{turnStep}from"#execution/workflow-steps.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{runProxySubagentEventStep}from"#subagents/event-proxy-step.js";import{createChannelReader,raceChannelReads}from"#execution/tools/workflow/owner-channels.js";import{openWorkflowToolRunOwnerChannels}from"#execution/tools/workflow/owner.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{acknowledgeDelegatedTasksStep}from"#execution/tasks/parent/delegate.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{sendTurnControlStep}from"#execution/turn-control-protocol.js";import{findRunningAgentHandle,isInboxSubagentResultFromRunningHandle}from"#subagents/handles/query.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{dispatchCoordinationStep}from"#execution/coordination-dispatch-step.js";import{emitWorkflowToolRunReportStep}from"#execution/tools/workflow/emit-workflow-tool-run-report-step.js";import{createTurnCancellationControl}from"#execution/turn-cancellation-control.js";import{TurnExecutionCursor}from"#execution/turn-execution-cursor.js";import{resolveRuntimeActionResultsForCallIds}from"#runtime/actions/results.js";import{handleWorkflowToolRunOutcome,handleWorkflowToolRunRequest}from"#execution/turn-workflow-tool-run.js";const TASK_MODE_WAIT_ERROR_MESSAGE="Task mode cannot wait for follow-up input (`next: null`).";async function turnWorkflow(e){"use workflow";let t=migrateTurnWorkflowInput(e);return t.driverCapabilities?.turnInbox===!0?runTurnOwnedWorkflow(t):runLegacyTurnWorkflow(t)}async function runTurnOwnedWorkflow(n){let o=createHook({token:`${n.completionToken}:inbox`}),s=createChannelReader(`inbox`,o),l=n.initialStep,u=new TurnExecutionCursor({controlToken:n.completionToken,parentWritable:n.stepInput.parentWritable,serializedContext:l?.beforeStep.serializedContext??n.stepInput.serializedContext,sessionState:l?.beforeStep.sessionState??n.stepInput.sessionState}),d=0,nextDeliveryRequestId=()=>`${o.token}:delivery:${String(d++)}`,f=[],p=n.stepInput.input,m=!1,h,g;try{try{await claimHookOwnership(o),m=!0}catch(e){if(isHookConflictError(e))return;throw e}h=openWorkflowToolRunOwnerChannels(o.token);let e=[...h.readers,s];for(n.driverCapabilities?.cancelledTurnSettle===!0&&(g=await createTurnCancellationControl({controlToken:n.completionToken,expectedTurnId:activeTurnId(u.sessionState.emissionState),initialPayload:n.initialCancellation}));;){let r=l?.beforeStep??{serializedContext:u.serializedContext,sessionState:u.sessionState},i=l?.result??await turnStep(u.createStepInput(p,g?.signal));l=void 0;let a=i.action===`dispatch-workflow-tasks`?i.pendingTaskCallIds:i.action===`park`?i.pendingCoordinationCallIds:void 0,s=(i.backgroundTasks?.length??0)>0;if(s){if(i.backgroundTaskState===void 0)throw Error(`Background tasks were returned without their committed session state.`);await u.adopt({serializedContext:r.serializedContext,sessionState:i.backgroundTaskState}),await acknowledgeDelegatedTasksStep({tasks:i.backgroundTasks??[]})}if(i.action===`cancelled`){await u.adopt({serializedContext:i.serializedContext,sessionState:i.backgroundTaskState??i.sessionState}),await finishCancelledTurn({bufferedDeliveries:f,cancellation:g,cursor:u});return}if(g?.signal.aborted===!0&&(a===void 0||s)){await u.adopt({serializedContext:preserveSerializedSessionDynamicModelSelection(r.serializedContext,i.serializedContext),sessionState:u.sessionState}),await finishCancelledTurn({bufferedDeliveries:f,cancellation:g,cursor:u});return}if(i.sleepDurationMs!==void 0&&await waitForTurnSleep(i.sleepDurationMs,g)===`cancel`){await finishCancelledTurn({bufferedDeliveries:f,cancellation:g,cursor:u});return}if(i.action===`done`){await g?.dispose(),await u.finish(i,{kind:`done`,output:i.output??``,isError:i.isError,usage:i.usage,usageDelta:i.usageDelta},f);return}if(a!==void 0&&(i.action===`park`||i.action===`dispatch-workflow-tasks`)){await u.adopt(i);let n=await dispatchCoordinationStep({action:i.action,callbackBaseUrl:resolveWorkflowCallbackBaseUrl(getWorkflowMetadata().url),parentContinuationToken:o.token,parentWritable:u.parentWritable,serializedContext:u.serializedContext,sessionState:u.sessionState}),r=n.results.length===0?void 0:Date.now();await u.adopt(n),await acknowledgeDelegatedTasksStep({tasks:n.pendingTasks});let s=await waitForRuntimeActionResults({bufferedDeliveries:f,cancellation:g,cursor:u,inboxToken:o.token,initialAcceptedAtMs:r,initialResults:n.results,nextDeliveryRequestId,readers:e,pendingCallIds:a});if(s===`cancelled`){p=void 0;continue}if(s===`cancel-turn`){await finishCancelledTurn({bufferedDeliveries:f,cancellation:g,cursor:u});return}p={kind:`runtime-action-result`,...s};continue}if(i.action===`park`){if(!(i.hasPendingAuthorization||i.hasPendingInputBatch&&n.capabilities?.requestInput===!0||n.mode===`conversation`))throw Error(TASK_MODE_WAIT_ERROR_MESSAGE);await g?.dispose(),await u.finish(i,{authorizationAttemptIds:i.authorizationAttemptIds,authorizationNames:i.authorizationNames,kind:`park`,settled:i.settled},f);return}await u.adopt(i),p=void 0}}catch(e){throw await u.send({error:normalizeSerializableError(e),kind:`turn-error`}),e}finally{g!==void 0&&await g.dispose(),h!==void 0&&await h.dispose(),m&&await disposeHook(o)}}async function finishCancelledTurn(e){await cancelDescendantTurnsStep({serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState}),await e.cancellation?.dispose(),await e.cursor.finish({sessionState:e.cursor.sessionState},{cancelled:!0,kind:`park`},e.bufferedDeliveries)}async function waitForTurnSleep(e,t){if(t?.signal.aborted===!0)return`cancel`;let r=sleep(e).then(()=>`slept`);return t===void 0?r:Promise.race([r,t.requested])}async function waitForRuntimeActionResults(e){let n,r=[...e.initialResults],i=new Map;if(e.initialAcceptedAtMs!==void 0)for(let t of e.initialResults)i.set(t.callId,e.initialAcceptedAtMs);for(;;){let a=resolveRuntimeActionResultsForCallIds({pendingCallIds:e.pendingCallIds,results:r});if(a!==void 0)return n!==void 0&&await e.cursor.send({kind:`turn-delivery-cancelled`,requestId:n}),{acceptedAtMsByCallId:Object.fromEntries(a.map(e=>[e.callId,i.get(e.callId)])),results:a};e.cursor.sessionState.hasProxyInputRequests&&n===void 0&&(n=e.nextDeliveryRequestId(),await e.cursor.send({continuationToken:e.cursor.sessionState.continuationToken,inboxToken:e.inboxToken,kind:`turn-delivery-request`,requestId:n}));let c=await raceChannelReads(e.readers,e.cancellation?.requested);if(c===`cancel`)return n!==void 0&&await e.cursor.send({kind:`turn-delivery-cancelled`,requestId:n}),`cancelled`;if(c.next.done)throw Error(`Turn inbox closed before runtime actions completed.`);if(c.channel===`outcome`){let n=await handleWorkflowToolRunOutcome({callbackMetadataUrl:getWorkflowMetadata().url,cursor:e.cursor,message:c.next.value});n!==void 0&&(r.push(n),i.set(n.callId,Date.now()));continue}if(c.channel===`request`){await handleWorkflowToolRunRequest({callbackMetadataUrl:getWorkflowMetadata().url,cursor:e.cursor,message:c.next.value});continue}if(c.channel===`report`){await emitWorkflowToolRunReportStep({from:c.next.value.from,parentWritable:e.cursor.parentWritable,update:c.next.value.update});continue}let l=c.next.value;if(l.kind===`runtime-action-result`){let t=e.cursor.sessionState.snapshot?.session.state,n=l.results.filter(e=>e.kind===`tool-result`?isInboxToolResultFromRecordedWorkflowToolRun(t,e):e.origin===`child`&&isInboxSubagentResultFromRunningHandle(t,e)||isInboxSubagentResultFromRecordedWorkflowToolRun(t,e));if(n.length>0){let e=Date.now();r.push(...n);for(let t of n)i.set(t.callId,e)}continue}if(l.kind===`subagent-input-request`||l.kind===`subagent-authorization-event`){let t=findRunningAgentHandle(e.cursor.sessionState.snapshot?.session.state,{callId:l.callId});if(t?.identity.name!==l.subagentName||t.address.sessionId!==l.childSessionId)continue;let n=await runProxySubagentEventStep({hookPayload:l,parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState});await e.cursor.adopt(n);continue}if(l.kind===`driver-delivery`&&l.requestId===n){await e.cursor.send({kind:`turn-delivery-accepted`,requestId:l.requestId}),n=void 0;let t=await routeDeliverToChildren({delivery:l.delivery,parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState});if(await e.cursor.adopt({serializedContext:t.serializedContext??e.cursor.serializedContext,sessionState:t.sessionState??e.cursor.sessionState}),t.kind===`cancel-turn`)return t.kind;t.remainder!==void 0&&e.bufferedDeliveries.push(t.remainder)}}}async function runLegacyTurnWorkflow(e){let t=e.stepInput;try{for(;;){let r=await turnStep(t);if(r.action!==`cancelled`&&r.sleepDurationMs!==void 0&&await sleep(r.sleepDurationMs),r.action===`done`){await sendTurnControlStep({controlToken:e.completionToken,payload:{action:{kind:`done`,output:r.output??``,isError:r.isError,serializedContext:r.serializedContext,sessionState:r.sessionState,usage:r.usage,usageDelta:r.usageDelta},kind:`turn-result`}});return}if(r.action===`dispatch-workflow-tasks`){await sendTurnControlStep({controlToken:e.completionToken,payload:{action:{kind:`dispatch-workflow-tasks`,pendingCallIds:r.pendingTaskCallIds,serializedContext:r.serializedContext,sessionState:r.sessionState},kind:`turn-result`}});return}if(r.action===`park`){let t=r.pendingCoordinationCallIds;if(!(t!==void 0||r.hasPendingAuthorization||r.hasPendingInputBatch&&e.capabilities?.requestInput===!0||e.mode===`conversation`))throw Error(TASK_MODE_WAIT_ERROR_MESSAGE);let n=t===void 0?{kind:`park`,serializedContext:r.serializedContext,sessionState:r.sessionState,authorizationAttemptIds:r.authorizationAttemptIds,authorizationNames:r.authorizationNames,settled:r.settled}:{kind:`dispatch-coordination`,pendingCallIds:t,serializedContext:r.serializedContext,sessionState:r.sessionState};await sendTurnControlStep({controlToken:e.completionToken,payload:{action:n,kind:`turn-result`}});return}t={input:void 0,parentWritable:t.parentWritable,serializedContext:r.serializedContext,sessionState:r.sessionState}}}catch(t){throw await sendTurnControlStep({controlToken:e.completionToken,payload:{error:normalizeSerializableError(t),kind:`turn-error`}}),t}}export{turnWorkflow};
1
+ import{createHook,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{isInboxSubagentResultFromRecordedWorkflowToolRun,isInboxToolResultFromRecordedWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{activeTurnId}from"#harness/active-turn-id.js";import{migrateTurnWorkflowInput}from"#execution/durable-session-migrations/turn-workflow.js";import{cancelAllIndexedSessionTasksStep}from"#execution/cancel-indexed-session-tasks-step.js";import{turnStep}from"#execution/workflow-steps.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{runProxySubagentEventStep}from"#subagents/event-proxy-step.js";import{createChannelReader,raceChannelReads}from"#execution/tools/workflow/owner-channels.js";import{openWorkflowToolRunOwnerInbox}from"#execution/tools/workflow/owner.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{acknowledgeDelegatedTasksStep}from"#execution/tasks/parent/delegate.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{sendTurnControlStep}from"#execution/turn-control-protocol.js";import{findRunningAgentHandle,isInboxSubagentResultFromRunningHandle}from"#subagents/handles/query.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{dispatchCoordinationStep}from"#execution/coordination-dispatch-step.js";import{createTurnCancellationControl}from"#execution/turn-cancellation-control.js";import{TurnExecutionCursor}from"#execution/turn-execution-cursor.js";import{resolveRuntimeActionResultsForCallIds}from"#runtime/actions/results.js";import{handleWorkflowToolRunMessage}from"#execution/turn-workflow-tool-run.js";const TASK_MODE_WAIT_ERROR_MESSAGE="Task mode cannot wait for follow-up input (`next: null`).";async function turnWorkflow(e){"use workflow";let t=migrateTurnWorkflowInput(e);return t.driverCapabilities?.turnInbox===!0?runTurnOwnedWorkflow(t):runLegacyTurnWorkflow(t)}async function runTurnOwnedWorkflow(a,o){let c=createHook({token:`${a.completionToken}:inbox`}),l=createChannelReader(`inbox`,c),u=a.initialStep,d=new TurnExecutionCursor({controlToken:a.completionToken,parentWritable:a.stepInput.parentWritable,serializedContext:u?.beforeStep.serializedContext??a.stepInput.serializedContext,sessionState:u?.beforeStep.sessionState??a.stepInput.sessionState}),f=0,nextDeliveryRequestId=()=>`${c.token}:delivery:${String(f++)}`,p=[],m=a.stepInput.input,h=!1,g;try{try{await claimHookOwnership(c),h=!0}catch(e){if(isHookConflictError(e))return;throw e}let e=openWorkflowToolRunOwnerInbox(),r=[e.reader,l];for(a.driverCapabilities?.cancelledTurnSettle===!0&&(g=await createTurnCancellationControl({controlToken:a.completionToken,expectedTurnId:activeTurnId(d.sessionState.emissionState),initialPayload:a.initialCancellation})),o?.();;){let n=u?.beforeStep??{serializedContext:d.serializedContext,sessionState:d.sessionState},i=u?.result??await turnStep(d.createStepInput(m,g?.signal));u=void 0;let o=i.action===`dispatch-workflow-tasks`?i.pendingTaskCallIds:i.action===`park`?i.pendingCoordinationCallIds:void 0,s=(i.backgroundTasks?.length??0)>0;if(s){if(i.backgroundTaskState===void 0)throw Error(`Background tasks were returned without their committed session state.`);await d.adopt({serializedContext:n.serializedContext,sessionState:i.backgroundTaskState}),await acknowledgeDelegatedTasksStep({tasks:i.backgroundTasks??[]})}if(i.action===`cancelled`){await d.adopt({serializedContext:i.serializedContext,sessionState:i.backgroundTaskState??i.sessionState}),await finishCancelledTurn({bufferedDeliveries:p,cancellation:g,cursor:d});return}if(g?.signal.aborted===!0&&(o===void 0||s)){await d.adopt({serializedContext:preserveSerializedSessionDynamicModelSelection(n.serializedContext,i.serializedContext),sessionState:d.sessionState}),await finishCancelledTurn({bufferedDeliveries:p,cancellation:g,cursor:d});return}if(i.action===`done`){await g?.dispose(),await d.finish(i,{kind:`done`,output:i.output??``,isError:i.isError,usage:i.usage,usageDelta:i.usageDelta},p);return}if(o!==void 0&&(i.action===`park`||i.action===`dispatch-workflow-tasks`)){await d.adopt(i);let n=await dispatchCoordinationStep({action:i.action,callbackBaseUrl:resolveWorkflowCallbackBaseUrl(getWorkflowMetadata().url),workflowToolRunOwner:e.owner,parentWritable:d.parentWritable,serializedContext:d.serializedContext,sessionState:d.sessionState}),a=n.results.length===0?void 0:Date.now();await d.adopt(n),await acknowledgeDelegatedTasksStep({tasks:n.pendingTasks});let s=await waitForRuntimeActionResults({bufferedDeliveries:p,cancellation:g,cursor:d,inboxToken:c.token,initialAcceptedAtMs:a,initialResults:n.results,nextDeliveryRequestId,readers:r,pendingCallIds:o});if(s===`cancelled`){m=void 0;continue}if(s===`cancel-turn`){await finishCancelledTurn({bufferedDeliveries:p,cancellation:g,cursor:d});return}m={kind:`runtime-action-result`,...s};continue}if(i.action===`park`){if(!(i.hasPendingAuthorization||i.hasPendingInputBatch&&a.capabilities?.requestInput===!0||a.mode===`conversation`))throw Error(TASK_MODE_WAIT_ERROR_MESSAGE);await g?.dispose(),await d.finish(i,{authorizationAttemptIds:i.authorizationAttemptIds,authorizationNames:i.authorizationNames,kind:`park`,settled:i.settled},p);return}await d.adopt(i),m=void 0}}catch(e){throw await d.send({error:normalizeSerializableError(e),kind:`turn-error`}),e}finally{g!==void 0&&await g.dispose(),h&&await disposeHook(c)}}async function finishCancelledTurn(e){(e.cancellation?.signal.aborted===!0?await e.cancellation.payload:void 0)?.tasks===!0&&await cancelAllIndexedSessionTasksStep({serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState}),await cancelDescendantTurnsStep({serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState}),await e.cancellation?.dispose(),await e.cursor.finish({sessionState:e.cursor.sessionState},{cancelled:!0,kind:`park`},e.bufferedDeliveries)}async function waitForRuntimeActionResults(e){let n,r=[...e.initialResults],i=new Map;if(e.initialAcceptedAtMs!==void 0)for(let t of e.initialResults)i.set(t.callId,e.initialAcceptedAtMs);for(;;){let s=resolveRuntimeActionResultsForCallIds({pendingCallIds:e.pendingCallIds,results:r});if(s!==void 0)return n!==void 0&&await e.cursor.send({kind:`turn-delivery-cancelled`,requestId:n}),{acceptedAtMsByCallId:Object.fromEntries(s.map(e=>[e.callId,i.get(e.callId)])),results:s};e.cursor.sessionState.hasProxyInputRequests&&n===void 0&&(n=e.nextDeliveryRequestId(),await e.cursor.send({continuationToken:e.cursor.sessionState.continuationToken,inboxToken:e.inboxToken,kind:`turn-delivery-request`,requestId:n}));let c=await raceChannelReads(e.readers,e.cancellation?.requested);if(c===`cancel`)return n!==void 0&&await e.cursor.send({kind:`turn-delivery-cancelled`,requestId:n}),`cancelled`;if(c.next.done)throw Error(`Turn inbox closed before runtime actions completed.`);if(c.channel===`workflow`){let n=await handleWorkflowToolRunMessage({callbackMetadataUrl:getWorkflowMetadata().url,cursor:e.cursor,message:c.next.value});n!==void 0&&(r.push(n),i.set(n.callId,Date.now()));continue}let l=c.next.value;if(l.kind===`runtime-action-result`){let t=e.cursor.sessionState.snapshot?.session.state,n=l.results.filter(e=>e.kind===`tool-result`?isInboxToolResultFromRecordedWorkflowToolRun(t,e):e.origin===`child`&&isInboxSubagentResultFromRunningHandle(t,e)||isInboxSubagentResultFromRecordedWorkflowToolRun(t,e));if(n.length>0){let e=Date.now();r.push(...n);for(let t of n)i.set(t.callId,e)}continue}if(l.kind===`subagent-input-request`||l.kind===`subagent-authorization-event`){let t=findRunningAgentHandle(e.cursor.sessionState.snapshot?.session.state,{callId:l.callId});if(t?.identity.name!==l.subagentName||t.address.sessionId!==l.childSessionId)continue;let n=await runProxySubagentEventStep({hookPayload:l,parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState});await e.cursor.adopt(n);continue}if(l.kind===`driver-delivery`&&l.requestId===n){await e.cursor.send({kind:`turn-delivery-accepted`,requestId:l.requestId}),n=void 0;let t=await routeDeliverToChildren({delivery:l.delivery,parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState});if(await e.cursor.adopt({serializedContext:t.serializedContext??e.cursor.serializedContext,sessionState:t.sessionState??e.cursor.sessionState}),t.kind===`cancel-turn`)return t.kind;t.remainder!==void 0&&e.bufferedDeliveries.push(t.remainder)}}}async function runLegacyTurnWorkflow(e){let t=e.stepInput;try{for(;;){let n=await turnStep(t);if(n.action===`done`){await sendTurnControlStep({controlToken:e.completionToken,payload:{action:{kind:`done`,output:n.output??``,isError:n.isError,serializedContext:n.serializedContext,sessionState:n.sessionState,usage:n.usage,usageDelta:n.usageDelta},kind:`turn-result`}});return}if(n.action===`dispatch-workflow-tasks`){await sendTurnControlStep({controlToken:e.completionToken,payload:{action:{kind:`dispatch-workflow-tasks`,pendingCallIds:n.pendingTaskCallIds,serializedContext:n.serializedContext,sessionState:n.sessionState},kind:`turn-result`}});return}if(n.action===`park`){let t=n.pendingCoordinationCallIds;if(!(t!==void 0||n.hasPendingAuthorization||n.hasPendingInputBatch&&e.capabilities?.requestInput===!0||e.mode===`conversation`))throw Error(TASK_MODE_WAIT_ERROR_MESSAGE);let r=t===void 0?{kind:`park`,serializedContext:n.serializedContext,sessionState:n.sessionState,authorizationAttemptIds:n.authorizationAttemptIds,authorizationNames:n.authorizationNames,settled:n.settled}:{kind:`dispatch-coordination`,pendingCallIds:t,serializedContext:n.serializedContext,sessionState:n.sessionState};await sendTurnControlStep({controlToken:e.completionToken,payload:{action:r,kind:`turn-result`}});return}t={input:void 0,parentWritable:t.parentWritable,serializedContext:n.serializedContext,sessionState:n.sessionState}}}catch(t){throw await sendTurnControlStep({controlToken:e.completionToken,payload:{error:normalizeSerializableError(t),kind:`turn-error`}}),t}}turnWorkflow.workflowId=`workflow//eve//turnWorkflow`;export{runTurnOwnedWorkflow,turnWorkflow};
@@ -1,8 +1,8 @@
1
1
  /** Every explicit session-inbox wire version still supported by producers. */
2
- export declare const SESSION_INBOX_WIRE_VERSIONS: readonly [1, 2, 3, 4];
2
+ export declare const SESSION_INBOX_WIRE_VERSIONS: readonly [1, 2, 3, 4, 5, 6];
3
3
  export type SessionInboxWireVersion = (typeof SESSION_INBOX_WIRE_VERSIONS)[number];
4
4
  /** Current persisted session-inbox wire version. */
5
- export declare const SESSION_INBOX_WIRE_VERSION: 1 | 2 | 3 | 4;
5
+ export declare const SESSION_INBOX_WIRE_VERSION: 1 | 2 | 3 | 4 | 5 | 6;
6
6
  /** Hook metadata field advertising the consumer's inbox wire capability. */
7
7
  export declare const SESSION_INBOX_WIRE_VERSION_METADATA_KEY = "sessionInboxWireVersion";
8
8
  /**
@@ -1 +1 @@
1
- const SESSION_INBOX_WIRE_VERSIONS=[1,2,3,4],SESSION_INBOX_WIRE_VERSION=SESSION_INBOX_WIRE_VERSIONS[SESSION_INBOX_WIRE_VERSIONS.length-1],SESSION_INBOX_WIRE_VERSION_METADATA_KEY=`sessionInboxWireVersion`;function isSessionInboxWireVersion(t){return SESSION_INBOX_WIRE_VERSIONS.some(e=>e===t)}var SessionInboxWireError=class extends Error{constructor(e){super(e),this.name=`SessionInboxWireError`}};export{SESSION_INBOX_WIRE_VERSION,SESSION_INBOX_WIRE_VERSIONS,SESSION_INBOX_WIRE_VERSION_METADATA_KEY,SessionInboxWireError,isSessionInboxWireVersion};
1
+ const SESSION_INBOX_WIRE_VERSIONS=[1,2,3,4,5,6],SESSION_INBOX_WIRE_VERSION=SESSION_INBOX_WIRE_VERSIONS[SESSION_INBOX_WIRE_VERSIONS.length-1],SESSION_INBOX_WIRE_VERSION_METADATA_KEY=`sessionInboxWireVersion`;function isSessionInboxWireVersion(t){return SESSION_INBOX_WIRE_VERSIONS.some(e=>e===t)}var SessionInboxWireError=class extends Error{constructor(e){super(e),this.name=`SessionInboxWireError`}};export{SESSION_INBOX_WIRE_VERSION,SESSION_INBOX_WIRE_VERSIONS,SESSION_INBOX_WIRE_VERSION_METADATA_KEY,SessionInboxWireError,isSessionInboxWireVersion};
@@ -4,9 +4,11 @@ import { type SessionInboxWireV2 } from "#execution/wire/session-inbox-wire.v2.j
4
4
  import { type SessionInboxWireV3 } from "#execution/wire/session-inbox-wire.v3.js";
5
5
  import { type SessionInboxWireTarget, type SessionInboxWireVersion } from "#execution/wire/session-inbox-contract.js";
6
6
  import { type SessionInboxWireV4 } from "#execution/wire/session-inbox-wire.v4.js";
7
+ import { type SessionInboxWireV5 } from "#execution/wire/session-inbox-wire.v5.js";
8
+ import { type SessionInboxWireV6 } from "#execution/wire/session-inbox-wire.v6.js";
7
9
  type SessionInboxCommand = DeliverHookPayload | SessionCommand | SessionTimeoutHookPayload;
8
10
  /** Current wire type consumed after migration. */
9
- export type SessionInboxWire = SessionInboxWireV4;
11
+ export type SessionInboxWire = SessionInboxWireV6;
10
12
  type LegacySessionInboxWireTarget = Extract<SessionInboxWireTarget, {
11
13
  readonly version: 0;
12
14
  }>;
@@ -23,11 +25,17 @@ declare function encode(command: SessionInboxCommand, target: {
23
25
  declare function encode(command: SessionInboxCommand, target: {
24
26
  readonly version: 4;
25
27
  }): SessionInboxWireV4;
28
+ declare function encode(command: SessionInboxCommand, target: {
29
+ readonly version: 5;
30
+ }): SessionInboxWireV5;
31
+ declare function encode(command: SessionInboxCommand, target: {
32
+ readonly version: 6;
33
+ }): SessionInboxWireV6;
26
34
  declare function encode(command: SessionInboxCommand, target: {
27
35
  readonly version: SessionInboxWireVersion;
28
36
  }): unknown;
29
37
  declare function encode(command: SessionInboxCommand, target: LegacySessionInboxWireTarget): Record<string, unknown>;
30
- declare function encode(command: SessionInboxCommand, target: SessionInboxWireTarget): SessionInboxWireV1 | SessionInboxWireV2 | SessionInboxWireV3 | SessionInboxWireV4 | Record<string, unknown>;
38
+ declare function encode(command: SessionInboxCommand, target: SessionInboxWireTarget): SessionInboxWireV1 | SessionInboxWireV2 | SessionInboxWireV3 | SessionInboxWireV4 | SessionInboxWireV5 | SessionInboxWireV6 | Record<string, unknown>;
31
39
  /** Server/step-safe producer facade. */
32
40
  export declare const sessionInboxWire: {
33
41
  readonly encode: typeof encode;
@@ -1 +1 @@
1
- import{SessionInboxWireError,isSessionInboxWireVersion}from"#execution/wire/session-inbox-contract.js";import{encodeSessionCommandV1}from"#execution/wire/session-inbox-wire.v1.js";import{encodeSessionCommandV2}from"#execution/wire/session-inbox-wire.v2.js";import{encodeSessionCommandV3}from"#execution/wire/session-inbox-wire.v3.js";import{encodeSessionCommandV0}from"#execution/wire/session-inbox-wire.v0.js";import{encodeSessionCommandV4}from"#execution/wire/session-inbox-wire.v4.js";const versionedEncoders={1:e=>encodeSessionCommandV1(withoutAcceptedDeployment(e)),2:e=>encodeSessionCommandV2(withoutAcceptedDeployment(e)),3:encodeSessionCommandV3,4:encodeSessionCommandV4};function encode(r,i){if(i.version===0){let e=i.variant===`send`&&r.kind===`send`&&r.payload.task!==void 0?encodeSessionCommandV4(r):void 0,t=encodeSessionCommandV0(encodeSessionCommandV1(withoutCurrentTaskMessages(withoutAcceptedDeployment(r))),i.variant);e?.kind===`deliver`&&(t={...t,payload:e.payload});let a=t,o=a.delivery,s=readAcceptedDeploymentId(r);return i.variant!==`send`||s===void 0||a.kind!==`send`||typeof o!=`object`||!o?t:{...t,delivery:{...o,acceptedDeploymentId:s}}}if(isSessionInboxWireVersion(i.version))return versionedEncoders[i.version](r);throw new SessionInboxWireError(`Cannot encode session inbox payload for unknown wire version ${JSON.stringify(i.version)}.`)}function withoutCurrentTaskMessages(e){if(e.kind!==`send`||e.payload.task===void 0)return e;let{agentRequests:t,inputRequests:n,...r}=e.payload.task;return{...e,payload:{...e.payload,task:r}}}function withoutAcceptedDeployment(e){if(e.kind===`send`&&e.delivery?.acceptedDeploymentId!==void 0){let{acceptedDeploymentId:t,...n}=e.delivery;return{...e,delivery:n}}return e.kind!==`deliver`||e.deliveryMetadata===void 0?e:{...e,deliveryMetadata:e.deliveryMetadata.map(e=>{let{acceptedDeploymentId:t,...n}=e;return n})}}function readAcceptedDeploymentId(e){if(e.kind===`send`)return e.delivery?.acceptedDeploymentId;if(e.kind===`deliver`)return e.deliveryMetadata?.find(e=>e.payloadIndex===0)?.acceptedDeploymentId}const sessionInboxWire={encode};export{sessionInboxWire};
1
+ import{SessionInboxWireError,isSessionInboxWireVersion}from"#execution/wire/session-inbox-contract.js";import{encodeSessionCommandV1}from"#execution/wire/session-inbox-wire.v1.js";import{encodeSessionCommandV2}from"#execution/wire/session-inbox-wire.v2.js";import{encodeSessionCommandV3}from"#execution/wire/session-inbox-wire.v3.js";import{encodeSessionCommandV0}from"#execution/wire/session-inbox-wire.v0.js";import{encodeSessionCommandV4}from"#execution/wire/session-inbox-wire.v4.js";import{encodeSessionCommandV5}from"#execution/wire/session-inbox-wire.v5.js";import{encodeSessionCommandV6}from"#execution/wire/session-inbox-wire.v6.js";const versionedEncoders={1:e=>encodeSessionCommandV1(withoutAcceptedDeployment(withoutOwnedTaskCancellation(e))),2:e=>encodeSessionCommandV2(withoutAcceptedDeployment(withoutOwnedTaskCancellation(e))),3:e=>encodeSessionCommandV3(withoutOwnedTaskCancellation(e)),4:e=>encodeSessionCommandV4(withoutOwnedTaskCancellation(e)),5:e=>encodeSessionCommandV5(withoutOwnedTaskCancellation(e)),6:encodeSessionCommandV6};function encode(r,i){if(r.kind===`cancel`&&r.tasks===!0&&i.version<6)throw new SessionInboxWireError(`Cannot encode session-owned task cancellation for wire version ${i.version}.`);if(i.version===0){let e=i.variant===`send`&&r.kind===`send`&&r.payload.task!==void 0?encodeSessionCommandV5(r):void 0,t=encodeSessionCommandV0(encodeSessionCommandV1(withoutCurrentTaskMessages(withoutAcceptedDeployment(withoutOwnedTaskCancellation(r)))),i.variant);e?.kind===`deliver`&&(t={...t,payload:e.payload});let a=t,o=a.delivery,s=readAcceptedDeploymentId(r);return i.variant!==`send`||s===void 0||a.kind!==`send`||typeof o!=`object`||!o?t:{...t,delivery:{...o,acceptedDeploymentId:s}}}if(isSessionInboxWireVersion(i.version))return versionedEncoders[i.version](r);throw new SessionInboxWireError(`Cannot encode session inbox payload for unknown wire version ${JSON.stringify(i.version)}.`)}function withoutOwnedTaskCancellation(e){if(e.kind!==`cancel`||e.tasks===void 0)return e;let{tasks:t,...n}=e;return n}function withoutCurrentTaskMessages(e){if(e.kind!==`send`||e.payload.task===void 0)return e;let{agentRequests:t,inputRequests:n,...r}=e.payload.task;return{...e,payload:{...e.payload,task:r}}}function withoutAcceptedDeployment(e){if(e.kind===`send`&&e.delivery?.acceptedDeploymentId!==void 0){let{acceptedDeploymentId:t,...n}=e.delivery;return{...e,delivery:n}}return e.kind!==`deliver`||e.deliveryMetadata===void 0?e:{...e,deliveryMetadata:e.deliveryMetadata.map(e=>{let{acceptedDeploymentId:t,...n}=e;return n})}}function readAcceptedDeploymentId(e){if(e.kind===`send`)return e.delivery?.acceptedDeploymentId;if(e.kind===`deliver`)return e.deliveryMetadata?.find(e=>e.payloadIndex===0)?.acceptedDeploymentId}const sessionInboxWire={encode};export{sessionInboxWire};
@@ -1 +1 @@
1
- import{isSessionCommandHookToken,sessionCommandHookToken}from"#execution/session-command-token.js";import{isObject}from"#shared/guards.js";import{getHookByToken,resumeHook}from"#internal/workflow/runtime.js";import{HookNotFoundError}from"#compiled/@workflow/errors/index.js";import{SESSION_INBOX_WIRE_VERSION_METADATA_KEY,SessionInboxWireError,isSessionInboxWireVersion}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWire}from"#execution/wire/session-inbox-encoder.js";async function resumeSessionInbox(e,t){if(isStableInboxFastPathCompatible(e,t))return await resumeHook(e,sessionInboxWire.encode(t,{variant:`send`,version:0}));let n=await getHookByToken(e),i=await resolveSessionInboxWireTarget(n);return await resumeHook(n,sessionInboxWire.encode(t,i))}function isStableInboxFastPathCompatible(t,n){return isSessionCommandHookToken(t)?!(`caller`in n&&n.caller?.activityObserver!==void 0):!1}async function resolveSessionInboxWireTarget(e){let r=isObject(e.metadata)?e.metadata:void 0;if(r!==void 0&&SESSION_INBOX_WIRE_VERSION_METADATA_KEY in r){let e=r[SESSION_INBOX_WIRE_VERSION_METADATA_KEY];if(isSessionInboxWireVersion(e))return{version:e};throw new SessionInboxWireError(`Session inbox target declares unsupported wire version ${JSON.stringify(e)}.`)}let a=sessionCommandHookToken(e.runId);if(e.token===a)return{variant:`send`,version:0};try{let t=await getHookByToken(a);if(t.runId!==e.runId)throw new SessionInboxWireError(`Stable session inbox ${JSON.stringify(a)} belongs to run ${JSON.stringify(t.runId)}, expected ${JSON.stringify(e.runId)}.`);return{variant:`send`,version:0}}catch(e){if(HookNotFoundError.is(e))return{variant:`deliver`,version:0};throw e}}export{resolveSessionInboxWireTarget,resumeSessionInbox};
1
+ import{isSessionCommandHookToken,sessionCommandHookToken}from"#execution/session-command-token.js";import{isObject}from"#shared/guards.js";import{getHookByToken,getRawHookByToken,resumeHook}from"#internal/workflow/runtime.js";import{HookNotFoundError}from"#compiled/@workflow/errors/index.js";import{SESSION_INBOX_WIRE_VERSION_METADATA_KEY,SessionInboxWireError,isSessionInboxWireVersion}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWire}from"#execution/wire/session-inbox-encoder.js";async function resumeSessionInbox(e,t){if(isStableInboxFastPathCompatible(e,t))return await resumeHook(e,sessionInboxWire.encode(t,{variant:`send`,version:0}));let n=await getHookByToken(e),i=await resolveSessionInboxWireTarget(n);return await resumeHook(n,sessionInboxWire.encode(t,i))}function isStableInboxFastPathCompatible(t,n){return!isSessionCommandHookToken(t)||n.kind===`cancel`&&n.tasks===!0?!1:!(`caller`in n&&n.caller?.activityObserver!==void 0)}async function resolveSessionInboxWireTarget(e){let r=isObject(e.metadata)?e.metadata:void 0;if(r!==void 0&&SESSION_INBOX_WIRE_VERSION_METADATA_KEY in r){let e=r[SESSION_INBOX_WIRE_VERSION_METADATA_KEY];if(isSessionInboxWireVersion(e))return{version:e};throw new SessionInboxWireError(`Session inbox target declares unsupported wire version ${JSON.stringify(e)}.`)}let a=sessionCommandHookToken(e.runId);if(e.token===a)return{variant:`send`,version:0};try{let t=await getRawHookByToken(a);if(t.runId!==e.runId)throw new SessionInboxWireError(`Stable session inbox ${JSON.stringify(a)} belongs to run ${JSON.stringify(t.runId)}, expected ${JSON.stringify(e.runId)}.`);return{variant:`send`,version:0}}catch(e){if(HookNotFoundError.is(e))return{variant:`deliver`,version:0};throw e}}export{resolveSessionInboxWireTarget,resumeSessionInbox};
@@ -1 +1 @@
1
- import{isObject}from"#shared/guards.js";import{SESSION_INBOX_WIRE_VERSION,SessionInboxWireError,SessionInboxWireError as SessionInboxWireError$1}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWireV0Migration}from"#execution/wire/session-inbox-wire.v0.js";import{runMigrationChain}from"#execution/durable-session-migrations/chain.js";import{normalizeSessionInboxWireV2}from"#execution/wire/session-inbox-wire.v2-migration.js";import{sessionInboxWireV1Migration}from"#execution/wire/session-inbox-wire.v2.migration.js";import{sessionInboxWireV2Migration}from"#execution/wire/session-inbox-wire.v3.migration.js";import{sessionInboxWireV3Migration}from"#execution/wire/session-inbox-wire.v4.migration.js";const WIRE_LABEL=`session inbox payload`,sessionInboxMigrations=[sessionInboxWireV0Migration,sessionInboxWireV1Migration,sessionInboxWireV2Migration,sessionInboxWireV3Migration];function decode(e){let n=typeof e==`object`&&e&&`version`in e?e.version:void 0;if(typeof e==`object`&&e&&`version`in e&&typeof n!=`number`)throw new SessionInboxWireError$1(`${WIRE_LABEL}: value has no numeric "version" field.`);let r=normalizeSessionInboxWireV2(e);if((n===1||n===2||n===3)&&containsCurrentTaskMessages(r))throw new SessionInboxWireError$1(`${WIRE_LABEL} does not match wire version ${n}.`);let i;try{i=runMigrationChain({initialVersion:0,label:WIRE_LABEL,migrations:sessionInboxMigrations,targetVersion:SESSION_INBOX_WIRE_VERSION,value:r})}catch(e){throw new SessionInboxWireError$1(e instanceof Error?e.message:String(e))}let a=normalizeSessionInboxWireV2(i);if(a.version!==SESSION_INBOX_WIRE_VERSION)throw new SessionInboxWireError$1(`${WIRE_LABEL} declares version ${JSON.stringify(a.version)}, expected ${SESSION_INBOX_WIRE_VERSION}.`);if(typeof n==`number`&&n>=2&&a.kind===`deliver`&&!(`payload`in a))throw new SessionInboxWireError$1(`${WIRE_LABEL} does not match wire version ${n}.`);return normalizeWire(a)}const sessionInboxWire={decode};function containsCurrentTaskMessages(t){return!isObject(t)||t.kind!==`deliver`?!1:(Array.isArray(t.payloads)?t.payloads:[]).some(t=>{if(!isObject(t)||!isObject(t.task))return!1;if(Object.hasOwn(t.task,`agentRequests`))return!0;let n=t.task.inputRequests;return Array.isArray(n)&&n.some(t=>isObject(t)&&(`request`in t||`requests`in t))})}function normalizeWire(e){switch(e.kind){case`deliver`:return{auth:e.auth,caller:e.caller,deliveryMetadata:e.deliveryMetadata,kind:`deliver`,payloads:e.payloads,requestId:e.requestId,taskDeliveryId:e.taskDeliveryId,turnPolicy:e.turnPolicy};case`session-timeout`:return{kind:`session-timeout`};case`clear`:return{kind:`clear`};case`compact`:return{kind:`compact`};case`reset`:return{kind:`reset`,reason:e.reason};case`cancel`:return{kind:`cancel`,taskId:e.taskId,turnId:e.turnId};default:throw new SessionInboxWireError$1(`${WIRE_LABEL} has an unrecognized kind ${JSON.stringify(e.kind)}.`)}}export{SessionInboxWireError,sessionInboxWire};
1
+ import{isObject}from"#shared/guards.js";import{SESSION_INBOX_WIRE_VERSION,SessionInboxWireError,SessionInboxWireError as SessionInboxWireError$1}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWireV0Migration}from"#execution/wire/session-inbox-wire.v0.js";import{runMigrationChain}from"#execution/durable-session-migrations/chain.js";import{normalizeSessionInboxWireV2}from"#execution/wire/session-inbox-wire.v2-migration.js";import{sessionInboxWireV1Migration}from"#execution/wire/session-inbox-wire.v2.migration.js";import{sessionInboxWireV2Migration}from"#execution/wire/session-inbox-wire.v3.migration.js";import{sessionInboxWireV3Migration}from"#execution/wire/session-inbox-wire.v4.migration.js";import{sessionInboxWireV4Migration}from"#execution/wire/session-inbox-wire.v5.migration.js";const WIRE_LABEL=`session inbox payload`,sessionInboxMigrations=[sessionInboxWireV0Migration,sessionInboxWireV1Migration,sessionInboxWireV2Migration,sessionInboxWireV3Migration,sessionInboxWireV4Migration,{from:5,migrate(t){if(!isObject(t))throw Error(`session inbox wire v5 value is not an object.`);return{...t,version:6}},to:6}];function decode(e){let n=typeof e==`object`&&e&&`version`in e?e.version:void 0;if(typeof e==`object`&&e&&`version`in e&&typeof n!=`number`)throw new SessionInboxWireError$1(`${WIRE_LABEL}: value has no numeric "version" field.`);let r=normalizeSessionInboxWireV2(e);if((n===1||n===2||n===3)&&containsCurrentTaskMessages(r))throw new SessionInboxWireError$1(`${WIRE_LABEL} does not match wire version ${n}.`);let i;try{i=runMigrationChain({initialVersion:0,label:WIRE_LABEL,migrations:sessionInboxMigrations,targetVersion:SESSION_INBOX_WIRE_VERSION,value:r})}catch(e){throw new SessionInboxWireError$1(e instanceof Error?e.message:String(e))}let a=normalizeSessionInboxWireV2(i);if(a.version!==SESSION_INBOX_WIRE_VERSION)throw new SessionInboxWireError$1(`${WIRE_LABEL} declares version ${JSON.stringify(a.version)}, expected ${SESSION_INBOX_WIRE_VERSION}.`);if(typeof n==`number`&&n>=2&&a.kind===`deliver`&&!(`payload`in a))throw new SessionInboxWireError$1(`${WIRE_LABEL} does not match wire version ${n}.`);return normalizeWire(a)}const sessionInboxWire={decode};function containsCurrentTaskMessages(t){return!isObject(t)||t.kind!==`deliver`?!1:(Array.isArray(t.payloads)?t.payloads:[]).some(t=>{if(!isObject(t)||!isObject(t.task))return!1;if(Object.hasOwn(t.task,`agentRequests`))return!0;let n=t.task.inputRequests;return Array.isArray(n)&&n.some(t=>isObject(t)&&(`request`in t||`requests`in t))})}function normalizeWire(e){switch(e.kind){case`deliver`:return{auth:e.auth,caller:e.caller,deliveryMetadata:e.deliveryMetadata,kind:`deliver`,payloads:e.payloads,requestId:e.requestId,taskDeliveryId:e.taskDeliveryId,turnPolicy:e.turnPolicy};case`session-timeout`:return{kind:`session-timeout`};case`clear`:return{kind:`clear`};case`compact`:return{kind:`compact`};case`reset`:return{kind:`reset`,reason:e.reason};case`cancel`:return{kind:`cancel`,taskId:e.taskId,tasks:e.tasks,turnId:e.turnId};default:throw new SessionInboxWireError$1(`${WIRE_LABEL} has an unrecognized kind ${JSON.stringify(e.kind)}.`)}}export{SessionInboxWireError,sessionInboxWire};
@@ -0,0 +1,341 @@
1
+ import { z } from "#compiled/zod/index.js";
2
+ import type { DeliverHookPayload, SessionCommand, SessionTimeoutHookPayload } from "#channel/types.js";
3
+ import type { TaskView } from "#tasks/types.js";
4
+ /** Version 5 adds model token cost to delegated usage reports. */
5
+ export declare const sessionInboxWireV5Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
+ auth: z.ZodOptional<z.ZodNullable<z.ZodObject<{
7
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
8
+ authenticator: z.ZodString;
9
+ issuer: z.ZodOptional<z.ZodString>;
10
+ principalId: z.ZodString;
11
+ principalType: z.ZodString;
12
+ subject: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strict>>>;
14
+ kind: z.ZodLiteral<"deliver">;
15
+ requestId: z.ZodOptional<z.ZodString>;
16
+ taskDeliveryId: z.ZodOptional<z.ZodString>;
17
+ turnPolicy: z.ZodOptional<z.ZodEnum<{
18
+ queue: "queue";
19
+ steer: "steer";
20
+ }>>;
21
+ caller: z.ZodOptional<z.ZodObject<{
22
+ callId: z.ZodString;
23
+ replyTo: z.ZodDiscriminatedUnion<[z.ZodObject<{
24
+ kind: z.ZodLiteral<"hook">;
25
+ token: z.ZodString;
26
+ }, z.core.$strict>, z.ZodObject<{
27
+ kind: z.ZodLiteral<"callback">;
28
+ token: z.ZodString;
29
+ url: z.ZodString;
30
+ }, z.core.$strict>], "kind">;
31
+ subagentName: z.ZodString;
32
+ taskId: z.ZodOptional<z.ZodString>;
33
+ activityObserver: z.ZodOptional<z.ZodObject<{
34
+ sink: z.ZodObject<{
35
+ url: z.ZodString;
36
+ version: z.ZodLiteral<1>;
37
+ }, z.core.$strict>;
38
+ workIdentity: z.ZodOptional<z.ZodObject<{
39
+ callId: z.ZodOptional<z.ZodString>;
40
+ id: z.ZodString;
41
+ kind: z.ZodEnum<{
42
+ "remote-agent": "remote-agent";
43
+ "root-turn": "root-turn";
44
+ subagent: "subagent";
45
+ task: "task";
46
+ }>;
47
+ name: z.ZodOptional<z.ZodString>;
48
+ parentId: z.ZodOptional<z.ZodString>;
49
+ rootSessionId: z.ZodString;
50
+ rootTurnId: z.ZodString;
51
+ sessionId: z.ZodOptional<z.ZodString>;
52
+ turnId: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$strict>>;
54
+ }, z.core.$strict>>;
55
+ }, z.core.$strict>>;
56
+ deliveryMetadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
57
+ channelKind: z.ZodString;
58
+ channelName: z.ZodString;
59
+ deliveryId: z.ZodString;
60
+ payloadIndex: z.ZodNumber;
61
+ requestId: z.ZodOptional<z.ZodString>;
62
+ requestTraceContext: z.ZodOptional<z.ZodObject<{
63
+ spanId: z.ZodString;
64
+ traceFlags: z.ZodNumber;
65
+ traceId: z.ZodString;
66
+ }, z.core.$strict>>;
67
+ acceptedDeploymentId: z.ZodOptional<z.ZodString>;
68
+ }, z.core.$strict>>>;
69
+ payload: z.ZodObject<{
70
+ context: z.ZodOptional<z.ZodArray<z.ZodString>>;
71
+ inputResponses: z.ZodOptional<z.ZodArray<z.ZodObject<{
72
+ optionId: z.ZodOptional<z.ZodString>;
73
+ requestId: z.ZodString;
74
+ text: z.ZodOptional<z.ZodString>;
75
+ }, z.core.$strict>>>;
76
+ message: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
77
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
78
+ text: z.ZodString;
79
+ type: z.ZodLiteral<"text">;
80
+ }, z.core.$strict>, z.ZodObject<{
81
+ image: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
82
+ mediaType: z.ZodOptional<z.ZodString>;
83
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
84
+ type: z.ZodLiteral<"image">;
85
+ }, z.core.$strict>, z.ZodObject<{
86
+ data: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
87
+ filename: z.ZodOptional<z.ZodString>;
88
+ mediaType: z.ZodString;
89
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
90
+ type: z.ZodLiteral<"file">;
91
+ }, z.core.$strict>], "type">>]>>;
92
+ outputSchema: z.ZodOptional<z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>;
93
+ task: z.ZodOptional<z.ZodObject<{
94
+ agentRequests: z.ZodOptional<z.ZodArray<z.ZodObject<{
95
+ replyTo: z.ZodString;
96
+ request: z.ZodDiscriminatedUnion<[z.ZodObject<{
97
+ input: z.ZodObject<{
98
+ agentId: z.ZodOptional<z.ZodString>;
99
+ message: z.ZodString;
100
+ outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>>;
101
+ target: z.ZodString;
102
+ }, z.core.$strict>;
103
+ invocationId: z.ZodString;
104
+ kind: z.ZodLiteral<"agent-invoke">;
105
+ }, z.core.$strict>, z.ZodObject<{
106
+ kind: z.ZodLiteral<"agent-settled">;
107
+ result: z.ZodObject<{
108
+ backgroundTask: z.ZodOptional<z.ZodObject<{
109
+ status: z.ZodLiteral<"working">;
110
+ taskId: z.ZodString;
111
+ }, z.core.$strict>>;
112
+ callId: z.ZodString;
113
+ isError: z.ZodOptional<z.ZodBoolean>;
114
+ kind: z.ZodLiteral<"subagent-result">;
115
+ origin: z.ZodLiteral<"child">;
116
+ outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
117
+ kind: z.ZodLiteral<"parked">;
118
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
119
+ kind: z.ZodLiteral<"succeeded">;
120
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
121
+ }, z.core.$strict>, z.ZodObject<{
122
+ error: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
123
+ kind: z.ZodLiteral<"failed">;
124
+ }, z.core.$strict>, z.ZodObject<{
125
+ kind: z.ZodLiteral<"cancelled">;
126
+ }, z.core.$strict>], "kind">;
127
+ usageDelta: z.ZodObject<{
128
+ cacheReadTokens: z.ZodNumber;
129
+ cacheWriteTokens: z.ZodNumber;
130
+ inputTokens: z.ZodNumber;
131
+ outputTokens: z.ZodNumber;
132
+ costUsd: z.ZodOptional<z.ZodNumber>;
133
+ }, z.core.$strip>;
134
+ }, z.core.$strict>, z.ZodObject<{
135
+ kind: z.ZodLiteral<"terminal">;
136
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
137
+ kind: z.ZodLiteral<"succeeded">;
138
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
139
+ }, z.core.$strict>, z.ZodObject<{
140
+ error: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
141
+ kind: z.ZodLiteral<"failed">;
142
+ }, z.core.$strict>, z.ZodObject<{
143
+ kind: z.ZodLiteral<"cancelled">;
144
+ }, z.core.$strict>], "kind">;
145
+ usageDelta: z.ZodObject<{
146
+ cacheReadTokens: z.ZodNumber;
147
+ cacheWriteTokens: z.ZodNumber;
148
+ inputTokens: z.ZodNumber;
149
+ outputTokens: z.ZodNumber;
150
+ costUsd: z.ZodOptional<z.ZodNumber>;
151
+ }, z.core.$strip>;
152
+ }, z.core.$strict>], "kind">;
153
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
154
+ subagentName: z.ZodString;
155
+ usage: z.ZodOptional<z.ZodObject<{
156
+ cacheReadTokens: z.ZodNumber;
157
+ cacheWriteTokens: z.ZodNumber;
158
+ inputTokens: z.ZodNumber;
159
+ outputTokens: z.ZodNumber;
160
+ costUsd: z.ZodOptional<z.ZodNumber>;
161
+ }, z.core.$strip>>;
162
+ }, z.core.$strict>;
163
+ }, z.core.$strict>], "kind">;
164
+ taskId: z.ZodString;
165
+ }, z.core.$strict>>>;
166
+ authorizationEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
167
+ hookPayload: z.ZodObject<{
168
+ callId: z.ZodString;
169
+ childSessionId: z.ZodString;
170
+ event: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
171
+ kind: z.ZodLiteral<"subagent-authorization-event">;
172
+ subagentName: z.ZodString;
173
+ }, z.core.$strict>;
174
+ taskId: z.ZodString;
175
+ }, z.core.$strict>>>;
176
+ inputRequests: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
177
+ replyTo: z.ZodString;
178
+ sequence: z.ZodNumber;
179
+ stepIndex: z.ZodNumber;
180
+ taskId: z.ZodString;
181
+ turnId: z.ZodString;
182
+ request: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
183
+ }, z.core.$loose>, z.ZodObject<{
184
+ replyTo: z.ZodString;
185
+ sequence: z.ZodNumber;
186
+ stepIndex: z.ZodNumber;
187
+ taskId: z.ZodString;
188
+ turnId: z.ZodString;
189
+ requests: z.ZodArray<z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>;
190
+ }, z.core.$loose>]>>>;
191
+ views: z.ZodOptional<z.ZodArray<z.ZodType<TaskView, unknown, z.core.$ZodTypeInternals<TaskView, unknown>>>>;
192
+ }, z.core.$strict>>;
193
+ }, z.core.$loose>;
194
+ payloads: z.ZodArray<z.ZodObject<{
195
+ context: z.ZodOptional<z.ZodArray<z.ZodString>>;
196
+ inputResponses: z.ZodOptional<z.ZodArray<z.ZodObject<{
197
+ optionId: z.ZodOptional<z.ZodString>;
198
+ requestId: z.ZodString;
199
+ text: z.ZodOptional<z.ZodString>;
200
+ }, z.core.$strict>>>;
201
+ message: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
202
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
203
+ text: z.ZodString;
204
+ type: z.ZodLiteral<"text">;
205
+ }, z.core.$strict>, z.ZodObject<{
206
+ image: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
207
+ mediaType: z.ZodOptional<z.ZodString>;
208
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
209
+ type: z.ZodLiteral<"image">;
210
+ }, z.core.$strict>, z.ZodObject<{
211
+ data: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
212
+ filename: z.ZodOptional<z.ZodString>;
213
+ mediaType: z.ZodString;
214
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
215
+ type: z.ZodLiteral<"file">;
216
+ }, z.core.$strict>], "type">>]>>;
217
+ outputSchema: z.ZodOptional<z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>;
218
+ task: z.ZodOptional<z.ZodObject<{
219
+ agentRequests: z.ZodOptional<z.ZodArray<z.ZodObject<{
220
+ replyTo: z.ZodString;
221
+ request: z.ZodDiscriminatedUnion<[z.ZodObject<{
222
+ input: z.ZodObject<{
223
+ agentId: z.ZodOptional<z.ZodString>;
224
+ message: z.ZodString;
225
+ outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>>;
226
+ target: z.ZodString;
227
+ }, z.core.$strict>;
228
+ invocationId: z.ZodString;
229
+ kind: z.ZodLiteral<"agent-invoke">;
230
+ }, z.core.$strict>, z.ZodObject<{
231
+ kind: z.ZodLiteral<"agent-settled">;
232
+ result: z.ZodObject<{
233
+ backgroundTask: z.ZodOptional<z.ZodObject<{
234
+ status: z.ZodLiteral<"working">;
235
+ taskId: z.ZodString;
236
+ }, z.core.$strict>>;
237
+ callId: z.ZodString;
238
+ isError: z.ZodOptional<z.ZodBoolean>;
239
+ kind: z.ZodLiteral<"subagent-result">;
240
+ origin: z.ZodLiteral<"child">;
241
+ outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
242
+ kind: z.ZodLiteral<"parked">;
243
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
244
+ kind: z.ZodLiteral<"succeeded">;
245
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
246
+ }, z.core.$strict>, z.ZodObject<{
247
+ error: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
248
+ kind: z.ZodLiteral<"failed">;
249
+ }, z.core.$strict>, z.ZodObject<{
250
+ kind: z.ZodLiteral<"cancelled">;
251
+ }, z.core.$strict>], "kind">;
252
+ usageDelta: z.ZodObject<{
253
+ cacheReadTokens: z.ZodNumber;
254
+ cacheWriteTokens: z.ZodNumber;
255
+ inputTokens: z.ZodNumber;
256
+ outputTokens: z.ZodNumber;
257
+ costUsd: z.ZodOptional<z.ZodNumber>;
258
+ }, z.core.$strip>;
259
+ }, z.core.$strict>, z.ZodObject<{
260
+ kind: z.ZodLiteral<"terminal">;
261
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
262
+ kind: z.ZodLiteral<"succeeded">;
263
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
264
+ }, z.core.$strict>, z.ZodObject<{
265
+ error: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
266
+ kind: z.ZodLiteral<"failed">;
267
+ }, z.core.$strict>, z.ZodObject<{
268
+ kind: z.ZodLiteral<"cancelled">;
269
+ }, z.core.$strict>], "kind">;
270
+ usageDelta: z.ZodObject<{
271
+ cacheReadTokens: z.ZodNumber;
272
+ cacheWriteTokens: z.ZodNumber;
273
+ inputTokens: z.ZodNumber;
274
+ outputTokens: z.ZodNumber;
275
+ costUsd: z.ZodOptional<z.ZodNumber>;
276
+ }, z.core.$strip>;
277
+ }, z.core.$strict>], "kind">;
278
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
279
+ subagentName: z.ZodString;
280
+ usage: z.ZodOptional<z.ZodObject<{
281
+ cacheReadTokens: z.ZodNumber;
282
+ cacheWriteTokens: z.ZodNumber;
283
+ inputTokens: z.ZodNumber;
284
+ outputTokens: z.ZodNumber;
285
+ costUsd: z.ZodOptional<z.ZodNumber>;
286
+ }, z.core.$strip>>;
287
+ }, z.core.$strict>;
288
+ }, z.core.$strict>], "kind">;
289
+ taskId: z.ZodString;
290
+ }, z.core.$strict>>>;
291
+ authorizationEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
292
+ hookPayload: z.ZodObject<{
293
+ callId: z.ZodString;
294
+ childSessionId: z.ZodString;
295
+ event: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
296
+ kind: z.ZodLiteral<"subagent-authorization-event">;
297
+ subagentName: z.ZodString;
298
+ }, z.core.$strict>;
299
+ taskId: z.ZodString;
300
+ }, z.core.$strict>>>;
301
+ inputRequests: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
302
+ replyTo: z.ZodString;
303
+ sequence: z.ZodNumber;
304
+ stepIndex: z.ZodNumber;
305
+ taskId: z.ZodString;
306
+ turnId: z.ZodString;
307
+ request: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
308
+ }, z.core.$loose>, z.ZodObject<{
309
+ replyTo: z.ZodString;
310
+ sequence: z.ZodNumber;
311
+ stepIndex: z.ZodNumber;
312
+ taskId: z.ZodString;
313
+ turnId: z.ZodString;
314
+ requests: z.ZodArray<z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>;
315
+ }, z.core.$loose>]>>>;
316
+ views: z.ZodOptional<z.ZodArray<z.ZodType<TaskView, unknown, z.core.$ZodTypeInternals<TaskView, unknown>>>>;
317
+ }, z.core.$strict>>;
318
+ }, z.core.$loose>>;
319
+ version: z.ZodLiteral<5>;
320
+ }, z.core.$strict>, z.ZodObject<{
321
+ kind: z.ZodLiteral<"session-timeout">;
322
+ version: z.ZodLiteral<5>;
323
+ }, z.core.$strict>, z.ZodObject<{
324
+ kind: z.ZodLiteral<"clear">;
325
+ version: z.ZodLiteral<5>;
326
+ }, z.core.$strict>, z.ZodObject<{
327
+ kind: z.ZodLiteral<"compact">;
328
+ version: z.ZodLiteral<5>;
329
+ }, z.core.$strict>, z.ZodObject<{
330
+ kind: z.ZodLiteral<"reset">;
331
+ reason: z.ZodOptional<z.ZodString>;
332
+ version: z.ZodLiteral<5>;
333
+ }, z.core.$strict>, z.ZodObject<{
334
+ kind: z.ZodLiteral<"cancel">;
335
+ taskId: z.ZodOptional<z.ZodString>;
336
+ turnId: z.ZodOptional<z.ZodString>;
337
+ version: z.ZodLiteral<5>;
338
+ }, z.core.$strict>], "kind">;
339
+ export type SessionInboxWireV5 = z.infer<typeof sessionInboxWireV5Schema>;
340
+ /** Builds and validates one complete version-5 wire value. */
341
+ export declare function encodeSessionCommandV5(command: DeliverHookPayload | SessionCommand | SessionTimeoutHookPayload): SessionInboxWireV5;