eve 0.51.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (462) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/src/channel/session.d.ts +2 -1
  3. package/dist/src/channel/session.js +1 -1
  4. package/dist/src/channel/types.d.ts +4 -1
  5. package/dist/src/chunks/{use-eve-agent-C3vUG5g2.js → use-eve-agent-3DZuvuWE.js} +17 -6
  6. package/dist/src/chunks/{use-eve-agent-B4xN7-fK.js → use-eve-agent-D7apPojZ.js} +17 -6
  7. package/dist/src/cli/agent-command.js +1 -1
  8. package/dist/src/cli/commands/agent-instructions.d.ts +3 -1
  9. package/dist/src/cli/commands/agent-instructions.js +1 -1
  10. package/dist/src/cli/commands/build.js +1 -1
  11. package/dist/src/cli/commands/deploy.js +1 -1
  12. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  13. package/dist/src/cli/commands/init-repl.js +1 -1
  14. package/dist/src/cli/commands/init.js +1 -1
  15. package/dist/src/cli/commands/integration-connect.js +1 -1
  16. package/dist/src/cli/commands/link.js +1 -1
  17. package/dist/src/cli/commands/preconditions.js +1 -1
  18. package/dist/src/cli/commands/register-project-commands.d.ts +1 -1
  19. package/dist/src/cli/commands/register-project-commands.js +1 -1
  20. package/dist/src/cli/commands/registry.js +1 -1
  21. package/dist/src/cli/dev/boot-progress.d.ts +3 -0
  22. package/dist/src/cli/dev/boot-progress.js +1 -0
  23. package/dist/src/cli/dev/environment.js +1 -1
  24. package/dist/src/cli/dev/run-interactive-ui.js +1 -1
  25. package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
  26. package/dist/src/cli/dev/tui/setup-commands.d.ts +3 -1
  27. package/dist/src/cli/dev/tui/setup-commands.js +1 -1
  28. package/dist/src/cli/run.d.ts +4 -0
  29. package/dist/src/cli/run.js +3 -3
  30. package/dist/src/cli/telemetry/command.d.ts +9 -0
  31. package/dist/src/cli/telemetry/command.js +1 -0
  32. package/dist/src/cli/telemetry/flush.d.ts +2 -0
  33. package/dist/src/cli/telemetry/flush.js +1 -0
  34. package/dist/src/cli/telemetry/identity.d.ts +13 -0
  35. package/dist/src/cli/telemetry/identity.js +1 -0
  36. package/dist/src/cli/telemetry/index.d.ts +25 -0
  37. package/dist/src/cli/telemetry/index.js +3 -0
  38. package/dist/src/cli/telemetry/preference.d.ts +9 -0
  39. package/dist/src/cli/telemetry/preference.js +1 -0
  40. package/dist/src/client/open-stream.js +1 -1
  41. package/dist/src/client/session-controls.d.ts +3 -0
  42. package/dist/src/client/session-controls.js +1 -1
  43. package/dist/src/client/session.d.ts +4 -1
  44. package/dist/src/client/types.d.ts +3 -2
  45. package/dist/src/compiled/.vendor-stamp.json +11 -11
  46. package/dist/src/compiled/@clack/core/LICENSE +9 -0
  47. package/dist/src/compiled/@clack/core/index.d.ts +363 -0
  48. package/dist/src/compiled/@clack/core/index.js +20 -0
  49. package/dist/src/compiled/@eve/catalog/index.js +1 -1
  50. package/dist/src/compiled/@modelcontextprotocol/server/index.d.ts +1 -0
  51. package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +34 -92
  52. package/dist/src/compiled/@vercel/sandbox/api-client/base-client.d.ts +1 -1
  53. package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +1 -1
  54. package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +13 -29
  55. package/dist/src/compiled/@vercel/sandbox/constants.d.ts +11 -1
  56. package/dist/src/compiled/@vercel/sandbox/index.d.ts +3 -3
  57. package/dist/src/compiled/@vercel/sandbox/index.js +9 -9
  58. package/dist/src/compiled/@vercel/sandbox/sandbox-user.d.ts +5 -6
  59. package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +79 -67
  60. package/dist/src/compiled/@vercel/sandbox/session.d.ts +5 -3
  61. package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +9 -0
  62. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/api-client.d.ts +86 -1
  63. package/dist/src/compiled/@vercel/sandbox-drives/api-client/index.d.ts +2 -0
  64. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/validators.d.ts +26 -1
  65. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/constants.d.ts +2 -2
  66. package/dist/src/compiled/@vercel/{sandbox → sandbox-drives}/drive.d.ts +10 -0
  67. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/index.d.ts +3 -2
  68. package/dist/src/compiled/@vercel/sandbox-drives/index.js +9 -0
  69. package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/sandbox.d.ts +35 -6
  70. package/dist/src/compiled/@workflow/core/index.js +1 -1
  71. package/dist/src/compiled/@workflow/core/private.d.ts +2 -4
  72. package/dist/src/compiled/@workflow/core/private.js +1 -1
  73. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +9 -7
  74. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +13 -0
  75. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +54 -1
  76. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  77. package/dist/src/compiled/@workflow/core/serialization/types.d.ts +7 -0
  78. package/dist/src/compiled/@workflow/core/serialization.d.ts +24 -2
  79. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  80. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  81. package/dist/src/compiled/@workflow/errors/error-codes.d.ts +2 -0
  82. package/dist/src/compiled/@workflow/errors/index.d.ts +19 -0
  83. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  84. package/dist/src/compiled/@workflow/world/analytics.d.ts +46 -2
  85. package/dist/src/compiled/@workflow/world/events.d.ts +26 -1
  86. package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
  87. package/dist/src/compiled/@workflow/world/runs.d.ts +2 -2
  88. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  89. package/dist/src/compiled/@workflow/world-vercel/index.js +12 -12
  90. package/dist/src/compiled/_chunks/node/{auth-BSKyPAEP.js → auth-Bx1Aoyfo.js} +1 -1
  91. package/dist/src/compiled/_chunks/node/{auth-YpKlwhP1.js → auth-CA8ZMfB8.js} +1 -1
  92. package/dist/src/compiled/_chunks/node/esm-CE0tAvRh.js +7 -0
  93. package/dist/src/compiled/_chunks/node/version-BC6t2Txc.js +1 -0
  94. package/dist/src/compiled/_chunks/node/version-DSQqVZ5T.js +1 -0
  95. package/dist/src/compiled/_chunks/workflow/{attribute-changes-BwAadFfB.js → attribute-changes-03lzo29R.js} +1 -1
  96. package/dist/src/compiled/_chunks/workflow/dist-BIdMK5N8.js +40 -0
  97. package/dist/src/compiled/_chunks/workflow/dist-DMQ3CtWt.js +3 -0
  98. package/dist/src/compiled/_chunks/workflow/frames-Boesh7kU.js +3 -0
  99. package/dist/src/compiled/_chunks/workflow/{private-CZFMABEf.js → private-CKx3PkSS.js} +1 -1
  100. package/dist/src/compiled/_chunks/workflow/{resume-hook-BToMtPbH.js → resume-hook-C6eL-S_T.js} +1 -1
  101. package/dist/src/compiled/_chunks/workflow/run-BV0S6Zc2.js +1 -0
  102. package/dist/src/compiled/_chunks/workflow/sleep-Bh3jP9ii.js +1 -0
  103. package/dist/src/compiled/_chunks/workflow/wait-until-l-cwfJvm.js +15 -0
  104. package/dist/src/compiled/_chunks/workflow/{ws-transport-PnVVxT0R.js → ws-transport-BagXNxCE.js} +1 -1
  105. package/dist/src/compiler/compile-from-memory.d.ts +1 -0
  106. package/dist/src/compiler/extension-compatibility.d.ts +38 -20
  107. package/dist/src/compiler/extension-compatibility.js +1 -1
  108. package/dist/src/compiler/manifest.d.ts +2 -2
  109. package/dist/src/compiler/manifest.js +1 -1
  110. package/dist/src/compiler/normalize-agent-config.js +1 -1
  111. package/dist/src/compiler/normalize-channel.js +1 -1
  112. package/dist/src/compiler/normalize-schedule.js +1 -1
  113. package/dist/src/compiler/normalize-tool.js +1 -1
  114. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  115. package/dist/src/discover/extensions.d.ts +2 -0
  116. package/dist/src/discover/extensions.js +1 -1
  117. package/dist/src/discover/filesystem.d.ts +1 -0
  118. package/dist/src/discover/filesystem.js +1 -1
  119. package/dist/src/discover/project.js +1 -1
  120. package/dist/src/evals/runner/execute-task.js +1 -1
  121. package/dist/src/evals/session-cleanup.d.ts +7 -0
  122. package/dist/src/evals/session-cleanup.js +1 -0
  123. package/dist/src/evals/session.d.ts +4 -0
  124. package/dist/src/evals/session.js +1 -1
  125. package/dist/src/eve-channel/index.js +1 -1
  126. package/dist/src/eve-channel/request.d.ts +1 -0
  127. package/dist/src/eve-channel/request.js +1 -1
  128. package/dist/src/execution/activity-collector.js +1 -1
  129. package/dist/src/execution/activity-work.d.ts +8 -0
  130. package/dist/src/execution/activity-work.js +1 -1
  131. package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +6 -0
  132. package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -0
  133. package/dist/src/execution/continuation-conflict-step.js +1 -1
  134. package/dist/src/execution/coordination-dispatch-shared.d.ts +2 -2
  135. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  136. package/dist/src/execution/coordination-dispatch-step.js +1 -1
  137. package/dist/src/execution/create-session-step.js +1 -1
  138. package/dist/src/execution/durable-session-migrations/turn-workflow.d.ts +1 -1
  139. package/dist/src/execution/inline-turn.d.ts +4 -2
  140. package/dist/src/execution/inline-turn.js +1 -1
  141. package/dist/src/execution/next-driver-action.d.ts +0 -3
  142. package/dist/src/execution/parked-delivery-wait.js +1 -1
  143. package/dist/src/execution/proxied-deliver-step.js +1 -1
  144. package/dist/src/execution/run-session-limits.d.ts +5 -5
  145. package/dist/src/execution/sandbox/bindings/vercel-create-sdk.js +1 -1
  146. package/dist/src/execution/sandbox/bindings/vercel-sdk-types.d.ts +4 -4
  147. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  148. package/dist/src/execution/session-activity-projection.js +1 -1
  149. package/dist/src/execution/session-activity.js +1 -1
  150. package/dist/src/execution/session-timeout-workflow.js +1 -1
  151. package/dist/src/execution/session.d.ts +1 -0
  152. package/dist/src/execution/session.js +1 -1
  153. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  154. package/dist/src/execution/tasks/child/steps.d.ts +19 -1
  155. package/dist/src/execution/tasks/child/steps.js +1 -1
  156. package/dist/src/execution/tasks/child/workflow.d.ts +2 -0
  157. package/dist/src/execution/tasks/child/workflow.js +1 -1
  158. package/dist/src/execution/tasks/parent/control-shared.js +1 -1
  159. package/dist/src/execution/tasks/parent/delegate.d.ts +2 -0
  160. package/dist/src/execution/tasks/parent/delegate.js +1 -1
  161. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
  162. package/dist/src/execution/tasks/parent/subagent-task-projection.d.ts +26 -0
  163. package/dist/src/execution/tasks/parent/subagent-task-projection.js +1 -0
  164. package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
  165. package/dist/src/execution/terminate-child-sessions-step.js +1 -1
  166. package/dist/src/execution/tools/sleep-workflow.d.ts +3 -0
  167. package/dist/src/execution/tools/sleep-workflow.js +1 -0
  168. package/dist/src/execution/tools/sleep.d.ts +1 -5
  169. package/dist/src/execution/tools/sleep.js +1 -1
  170. package/dist/src/execution/tools/subagent/accept-event-step.js +1 -1
  171. package/dist/src/execution/tools/subagent/invoke-agent.d.ts +1 -7
  172. package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
  173. package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
  174. package/dist/src/execution/tools/workflow/ask.d.ts +1 -2
  175. package/dist/src/execution/tools/workflow/ask.js +1 -1
  176. package/dist/src/execution/tools/workflow/body.d.ts +6 -1
  177. package/dist/src/execution/tools/workflow/body.js +1 -1
  178. package/dist/src/execution/tools/workflow/cancel.js +1 -1
  179. package/dist/src/execution/tools/workflow/messages.d.ts +9 -8
  180. package/dist/src/execution/tools/workflow/messages.js +1 -1
  181. package/dist/src/execution/tools/workflow/owner-inbox.d.ts +2 -2
  182. package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
  183. package/dist/src/execution/tools/workflow/owner.d.ts +5 -11
  184. package/dist/src/execution/tools/workflow/owner.js +1 -1
  185. package/dist/src/execution/tools/workflow/run-control.d.ts +0 -4
  186. package/dist/src/execution/tools/workflow/run-control.js +1 -1
  187. package/dist/src/execution/tools/workflow/start.d.ts +5 -14
  188. package/dist/src/execution/tools/workflow/start.js +1 -1
  189. package/dist/src/execution/tools/workflow/workflow.d.ts +1 -1
  190. package/dist/src/execution/tools/workflow/workflow.js +1 -1
  191. package/dist/src/execution/turn-cancellation-control.d.ts +1 -0
  192. package/dist/src/execution/turn-cancellation-control.js +1 -1
  193. package/dist/src/execution/turn-cancellation-token.d.ts +1 -0
  194. package/dist/src/execution/turn-control-receiver.d.ts +3 -0
  195. package/dist/src/execution/turn-control-receiver.js +1 -1
  196. package/dist/src/execution/turn-dispatch.d.ts +2 -0
  197. package/dist/src/execution/turn-dispatch.js +1 -1
  198. package/dist/src/execution/turn-workflow-tool-run.d.ts +2 -8
  199. package/dist/src/execution/turn-workflow-tool-run.js +1 -1
  200. package/dist/src/execution/turn-workflow.d.ts +1 -0
  201. package/dist/src/execution/turn-workflow.js +1 -1
  202. package/dist/src/execution/wire/session-inbox-contract.d.ts +2 -2
  203. package/dist/src/execution/wire/session-inbox-contract.js +1 -1
  204. package/dist/src/execution/wire/session-inbox-encoder.d.ts +10 -2
  205. package/dist/src/execution/wire/session-inbox-encoder.js +1 -1
  206. package/dist/src/execution/wire/session-inbox-resume.js +1 -1
  207. package/dist/src/execution/wire/session-inbox-wire.js +1 -1
  208. package/dist/src/execution/wire/session-inbox-wire.v5.d.ts +341 -0
  209. package/dist/src/execution/wire/session-inbox-wire.v5.js +1 -0
  210. package/dist/src/execution/wire/session-inbox-wire.v5.migration.d.ts +3 -0
  211. package/dist/src/execution/wire/session-inbox-wire.v5.migration.js +1 -0
  212. package/dist/src/execution/wire/session-inbox-wire.v6.d.ts +341 -0
  213. package/dist/src/execution/wire/session-inbox-wire.v6.js +1 -0
  214. package/dist/src/execution/workflow-entry.js +1 -1
  215. package/dist/src/execution/workflow-runtime.js +1 -1
  216. package/dist/src/execution/workflow-steps.js +1 -1
  217. package/dist/src/harness/emission-state.js +1 -1
  218. package/dist/src/harness/session-limit-continuation.d.ts +5 -5
  219. package/dist/src/harness/session-limit-continuation.js +1 -1
  220. package/dist/src/harness/session-limit-enforcement.d.ts +4 -4
  221. package/dist/src/harness/session-limit-enforcement.js +1 -1
  222. package/dist/src/harness/session-usage-limits.d.ts +48 -0
  223. package/dist/src/harness/session-usage-limits.js +1 -0
  224. package/dist/src/harness/tool-loop.js +2 -2
  225. package/dist/src/harness/turn-client-context.d.ts +9 -0
  226. package/dist/src/harness/turn-client-context.js +1 -0
  227. package/dist/src/harness/turn-tag-state.d.ts +17 -20
  228. package/dist/src/harness/turn-tag-state.js +1 -1
  229. package/dist/src/harness/types.d.ts +5 -0
  230. package/dist/src/harness/workflow-tool-runs.d.ts +0 -1
  231. package/dist/src/harness/workflow-tool-runs.js +1 -1
  232. package/dist/src/internal/application/build-output-environment.d.ts +1 -0
  233. package/dist/src/internal/application/build-output-environment.js +1 -1
  234. package/dist/src/internal/application/package.js +1 -1
  235. package/dist/src/internal/application/paths.js +1 -1
  236. package/dist/src/internal/authored-definition/core.js +1 -1
  237. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  238. package/dist/src/internal/eve-project-root.d.ts +8 -0
  239. package/dist/src/internal/eve-project-root.js +1 -0
  240. package/dist/src/internal/invocation/workflow-execution.js +1 -1
  241. package/dist/src/internal/mcp/streamable-http-server.d.ts +29 -1
  242. package/dist/src/internal/mcp/streamable-http-server.js +1 -1
  243. package/dist/src/internal/nitro/host/build-application.js +1 -1
  244. package/dist/src/internal/nitro/host/create-application-nitro.d.ts +1 -0
  245. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  246. package/dist/src/internal/nitro/host/types.d.ts +2 -0
  247. package/dist/src/internal/nitro/host/vercel-build-output-config.d.ts +1 -0
  248. package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
  249. package/dist/src/internal/project-context.d.ts +13 -8
  250. package/dist/src/internal/project-context.js +1 -1
  251. package/dist/src/internal/vercel/build-agent-workspace.d.ts +1 -1
  252. package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
  253. package/dist/src/internal/vercel/eve-service-contribution.d.ts +1 -0
  254. package/dist/src/internal/vercel/eve-service-contribution.js +1 -1
  255. package/dist/src/internal/workflow/reference.d.ts +2 -0
  256. package/dist/src/internal/workflow/reference.js +1 -0
  257. package/dist/src/internal/workflow/runtime.d.ts +6 -0
  258. package/dist/src/internal/workflow/runtime.js +1 -1
  259. package/dist/src/internal/workflow-bundle/authored-workflow-directives.d.ts +1 -3
  260. package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
  261. package/dist/src/internal/workflow-bundle/authored-workflow-modules.d.ts +1 -11
  262. package/dist/src/internal/workflow-bundle/authored-workflow-modules.js +1 -1
  263. package/dist/src/internal/workflow-bundle/builder.js +1 -1
  264. package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +1 -1
  265. package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +1 -3
  266. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  267. package/dist/src/internal/workflow-bundle/workflow-transformer.d.ts +1 -1
  268. package/dist/src/internal/workflow-bundle/workflow-transformer.js +2 -2
  269. package/dist/src/protocol/message.d.ts +3 -2
  270. package/dist/src/public/channels/mcp.js +1 -1
  271. package/dist/src/public/channels/slack/activity-plan.d.ts +4 -0
  272. package/dist/src/public/channels/slack/activity-plan.js +1 -0
  273. package/dist/src/public/channels/slack/activity.d.ts +45 -2
  274. package/dist/src/public/channels/slack/activity.js +2 -1
  275. package/dist/src/public/channels/slack/index.d.ts +1 -1
  276. package/dist/src/public/channels/slack/index.js +1 -1
  277. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  278. package/dist/src/public/memory/index.js +1 -1
  279. package/dist/src/public/models/openai/chatgpt/model.js +2 -2
  280. package/dist/src/public/models/openai/chatgpt/transport.js +1 -1
  281. package/dist/src/public/nuxt/index.js +1 -1
  282. package/dist/src/public/nuxt/module.d.ts +3 -2
  283. package/dist/src/public/nuxt/module.js +1 -1
  284. package/dist/src/public/sandbox/vercel-sandbox.d.ts +9 -5
  285. package/dist/src/public/sandbox/vercel.d.ts +1 -1
  286. package/dist/src/public/sandbox/vercel.js +1 -1
  287. package/dist/src/public/tools/index.d.ts +3 -1
  288. package/dist/src/public/tools/index.js +1 -1
  289. package/dist/src/runtime/resolve-agent.js +1 -1
  290. package/dist/src/runtime/subagents/workflow.js +1 -1
  291. package/dist/src/self-modification/agent.d.ts +22 -0
  292. package/dist/src/self-modification/agent.js +1 -0
  293. package/dist/src/self-modification/extension/classify-registry-item.d.ts +19 -0
  294. package/dist/src/self-modification/extension/classify-registry-item.js +1 -0
  295. package/dist/src/self-modification/extension/eve-add.d.ts +56 -0
  296. package/dist/src/self-modification/extension/eve-add.js +2 -0
  297. package/dist/src/self-modification/extension/extension.d.ts +2 -0
  298. package/dist/src/self-modification/extension/extension.js +1 -0
  299. package/dist/src/self-modification/extension/instructions.d.ts +4 -0
  300. package/dist/src/self-modification/extension/instructions.js +23 -0
  301. package/dist/src/self-modification/extension/source-lock.d.ts +2 -0
  302. package/dist/src/self-modification/extension/source-lock.js +1 -0
  303. package/dist/src/self-modification/extension/tools/edit_file.d.ts +16 -0
  304. package/dist/src/self-modification/extension/tools/edit_file.js +1 -0
  305. package/dist/src/self-modification/extension/tools/registry_add.d.ts +52 -0
  306. package/dist/src/self-modification/extension/tools/registry_add.js +1 -0
  307. package/dist/src/self-modification/extension/tools/search_models.d.ts +22 -0
  308. package/dist/src/self-modification/extension/tools/search_models.js +1 -0
  309. package/dist/src/self-modification/extension/tools/search_registry.d.ts +103 -0
  310. package/dist/src/self-modification/extension/tools/search_registry.js +1 -0
  311. package/dist/src/self-modification/filesystem.d.ts +6 -0
  312. package/dist/src/self-modification/filesystem.js +1 -0
  313. package/dist/src/self-modification/sandbox.d.ts +2 -0
  314. package/dist/src/self-modification/sandbox.js +1 -0
  315. package/dist/src/services/dev-client/target.d.ts +3 -1
  316. package/dist/src/setup/boxes/select-model.d.ts +3 -21
  317. package/dist/src/setup/boxes/select-model.js +1 -1
  318. package/dist/src/setup/cli/prompt-ui.js +4 -4
  319. package/dist/src/setup/cli/select-component.d.ts +1 -1
  320. package/dist/src/setup/cli/select-component.js +1 -1
  321. package/dist/src/setup/flows/model.d.ts +3 -0
  322. package/dist/src/setup/flows/model.js +1 -1
  323. package/dist/src/setup/prompter.js +1 -1
  324. package/dist/src/setup/scaffold/create/project.js +1 -1
  325. package/dist/src/setup/scaffold/update/web-options.js +1 -1
  326. package/dist/src/shared/action-types.d.ts +35 -22
  327. package/dist/src/shared/action-types.js +1 -1
  328. package/dist/src/shared/agent-definition.d.ts +13 -0
  329. package/dist/src/shared/agent-turn-outcome.d.ts +2 -0
  330. package/dist/src/shared/agent-turn-outcome.js +1 -1
  331. package/dist/src/shared/extension-package-contract.d.ts +2 -0
  332. package/dist/src/shared/extension-package-contract.js +1 -1
  333. package/dist/src/shared/gateway-model-catalog.d.ts +21 -0
  334. package/dist/src/shared/gateway-model-catalog.js +1 -0
  335. package/dist/src/shared/sandbox-network-policy.d.ts +1 -1
  336. package/dist/src/shared/token-usage.d.ts +11 -15
  337. package/dist/src/shared/token-usage.js +1 -1
  338. package/dist/src/shared/workflow-tool-context.d.ts +2 -0
  339. package/dist/src/shared/workflow-tool-context.js +1 -0
  340. package/dist/src/subagents/callback-route.js +1 -1
  341. package/dist/src/subagents/event-proxy-step.js +1 -1
  342. package/dist/src/subagents/start-remote.js +1 -1
  343. package/dist/src/subagents/token-budget.js +1 -1
  344. package/dist/src/svelte/index.js +1 -1
  345. package/dist/src/svelte/use-eve-agent.js +1 -1
  346. package/dist/src/tasks/types.d.ts +18 -1
  347. package/dist/src/tasks/types.js +1 -1
  348. package/dist/src/tools/behavior.d.ts +5 -0
  349. package/dist/src/tools/definition.d.ts +16 -12
  350. package/dist/src/tools/definition.js +1 -1
  351. package/dist/src/tools/dynamic.d.ts +2 -2
  352. package/dist/src/tools/provided/sleep.d.ts +4 -4
  353. package/dist/src/tools/provided/sleep.js +1 -1
  354. package/dist/src/tools/task.d.ts +28 -80
  355. package/dist/src/tools/task.js +1 -1
  356. package/dist/src/tools/workflow-definition.d.ts +60 -0
  357. package/dist/src/tools/workflow-definition.js +1 -0
  358. package/dist/src/vue/index.js +1 -1
  359. package/dist/src/vue/use-eve-agent.js +1 -1
  360. package/docs/agent-config.md +24 -19
  361. package/docs/channels/eve.mdx +1 -1
  362. package/docs/channels/mcp.mdx +25 -3
  363. package/docs/concepts/built-in-tools.md +1 -1
  364. package/docs/concepts/execution-model-and-durability.mdx +13 -2
  365. package/docs/concepts/sessions-runs-and-streaming.md +9 -1
  366. package/docs/guides/client/messages.mdx +1 -1
  367. package/docs/guides/client/streaming.mdx +1 -1
  368. package/docs/guides/deployment/vercel.mdx +3 -1
  369. package/docs/guides/frontend/overview.mdx +1 -1
  370. package/docs/memory/overview.mdx +41 -12
  371. package/docs/reference/cli.md +31 -33
  372. package/docs/reference/meta.json +1 -4
  373. package/docs/reference/telemetry.md +56 -0
  374. package/docs/reference/typescript-api.md +38 -35
  375. package/docs/sandbox.mdx +1 -1
  376. package/docs/tools/overview.mdx +59 -18
  377. package/docs/tools/workflows.mdx +146 -70
  378. package/package.json +38 -19
  379. package/dist/src/compiled/@vercel/sandbox-delete/api-client/index.d.ts +0 -2
  380. package/dist/src/compiled/@vercel/sandbox-delete/index.js +0 -9
  381. package/dist/src/compiled/@vercel/sandbox-stable/LICENSE +0 -201
  382. package/dist/src/compiled/@vercel/sandbox-stable/_async-retry.d.ts +0 -8
  383. package/dist/src/compiled/@vercel/sandbox-stable/_workflow-serde.d.ts +0 -5
  384. package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-client.d.ts +0 -1456
  385. package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-error.d.ts +0 -29
  386. package/dist/src/compiled/@vercel/sandbox-stable/api-client/base-client.d.ts +0 -39
  387. package/dist/src/compiled/@vercel/sandbox-stable/api-client/file-writer.d.ts +0 -66
  388. package/dist/src/compiled/@vercel/sandbox-stable/api-client/index.d.ts +0 -2
  389. package/dist/src/compiled/@vercel/sandbox-stable/api-client/validators.d.ts +0 -899
  390. package/dist/src/compiled/@vercel/sandbox-stable/api-client/with-retry.d.ts +0 -10
  391. package/dist/src/compiled/@vercel/sandbox-stable/auth/error.d.ts +0 -15
  392. package/dist/src/compiled/@vercel/sandbox-stable/auth/file.d.ts +0 -18
  393. package/dist/src/compiled/@vercel/sandbox-stable/auth/index.d.ts +0 -6
  394. package/dist/src/compiled/@vercel/sandbox-stable/auth/oauth.d.ts +0 -111
  395. package/dist/src/compiled/@vercel/sandbox-stable/auth/poll-for-token.d.ts +0 -28
  396. package/dist/src/compiled/@vercel/sandbox-stable/auth/project.d.ts +0 -40
  397. package/dist/src/compiled/@vercel/sandbox-stable/command.d.ts +0 -292
  398. package/dist/src/compiled/@vercel/sandbox-stable/constants.d.ts +0 -5
  399. package/dist/src/compiled/@vercel/sandbox-stable/execution-context.d.ts +0 -116
  400. package/dist/src/compiled/@vercel/sandbox-stable/filesystem.d.ts +0 -258
  401. package/dist/src/compiled/@vercel/sandbox-stable/index.d.ts +0 -12
  402. package/dist/src/compiled/@vercel/sandbox-stable/index.js +0 -1
  403. package/dist/src/compiled/@vercel/sandbox-stable/network-policy.d.ts +0 -169
  404. package/dist/src/compiled/@vercel/sandbox-stable/proxy.d.ts +0 -55
  405. package/dist/src/compiled/@vercel/sandbox-stable/sandbox-user.d.ts +0 -212
  406. package/dist/src/compiled/@vercel/sandbox-stable/sandbox.d.ts +0 -1216
  407. package/dist/src/compiled/@vercel/sandbox-stable/session.d.ts +0 -433
  408. package/dist/src/compiled/@vercel/sandbox-stable/snapshot.d.ts +0 -229
  409. package/dist/src/compiled/@vercel/sandbox-stable/utils/get-credentials.d.ts +0 -21
  410. package/dist/src/compiled/@vercel/sandbox-stable/utils/paginator.d.ts +0 -16
  411. package/dist/src/compiled/@vercel/sandbox-stable/utils/resolveSignal.d.ts +0 -15
  412. package/dist/src/compiled/@vercel/sandbox-stable/utils/sandbox-snapshot.d.ts +0 -11
  413. package/dist/src/compiled/@vercel/sandbox-stable/utils/types.d.ts +0 -11
  414. package/dist/src/compiled/_chunks/node/decode_jwt-Col8JOnf.js +0 -7
  415. package/dist/src/compiled/_chunks/node/version-BYHw-SDY.js +0 -1
  416. package/dist/src/compiled/_chunks/node/version-DH6yRy-M.js +0 -1
  417. package/dist/src/compiled/_chunks/workflow/dist-CgbVZs5l.js +0 -40
  418. package/dist/src/compiled/_chunks/workflow/dist-DjojkP5e.js +0 -3
  419. package/dist/src/compiled/_chunks/workflow/frames-CZ9eHShe.js +0 -3
  420. package/dist/src/compiled/_chunks/workflow/run-DzyAoGh4.js +0 -1
  421. package/dist/src/compiled/_chunks/workflow/sleep-3_A5uOp-.js +0 -1
  422. package/dist/src/compiled/_chunks/workflow/wait-until-BtySPYD0.js +0 -15
  423. package/dist/src/harness/session-token-limits.d.ts +0 -41
  424. package/dist/src/harness/session-token-limits.js +0 -1
  425. package/dist/src/harness/turn-sleep.d.ts +0 -12
  426. package/dist/src/harness/turn-sleep.js +0 -1
  427. package/dist/src/internal/agent-workspace.d.ts +0 -15
  428. package/dist/src/internal/agent-workspace.js +0 -1
  429. package/dist/src/node_modules/.pnpm/@clack_core@1.3.1/node_modules/@clack/core/dist/index.js +0 -16
  430. package/dist/src/node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js +0 -1
  431. package/dist/src/node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js +0 -1
  432. package/dist/src/node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js +0 -1
  433. package/dist/src/node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js +0 -5
  434. package/dist/src/node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js +0 -1
  435. package/dist/src/public/workflow/index.d.ts +0 -5
  436. package/dist/src/public/workflow/index.js +0 -1
  437. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/LICENSE +0 -0
  438. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/_async-retry.d.ts +0 -0
  439. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/_workflow-serde.d.ts +0 -0
  440. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/api-error.d.ts +0 -0
  441. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/base-client.d.ts +0 -0
  442. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/file-writer.d.ts +0 -0
  443. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/with-retry.d.ts +0 -0
  444. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/error.d.ts +0 -0
  445. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/file.d.ts +0 -0
  446. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/index.d.ts +0 -0
  447. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/oauth.d.ts +0 -0
  448. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/poll-for-token.d.ts +0 -0
  449. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/project.d.ts +0 -0
  450. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/command.d.ts +0 -0
  451. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/execution-context.d.ts +0 -0
  452. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/filesystem.d.ts +0 -0
  453. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/network-policy.d.ts +0 -0
  454. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/proxy.d.ts +0 -0
  455. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/sandbox-user.d.ts +0 -0
  456. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/session.d.ts +0 -0
  457. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/snapshot.d.ts +0 -0
  458. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/get-credentials.d.ts +0 -0
  459. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/paginator.d.ts +0 -0
  460. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/resolveSignal.d.ts +0 -0
  461. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/sandbox-snapshot.d.ts +0 -0
  462. /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/types.d.ts +0 -0
@@ -0,0 +1 @@
1
+ import{z}from"#compiled/zod/index.js";import{formatValidationError}from"#runtime/validation.js";import{jsonValueSchema}from"#shared/json-schemas.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{SessionInboxWireError}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWireV3Schema}from"#execution/wire/session-inbox-wire.v3.js";import{tokenUsageWithCostSchema}from"#shared/token-usage.js";const taskMetadataSchema=z.object({agentId:z.string().optional(),kind:z.string(),mode:z.enum([`local`,`remote`]).optional(),name:z.string()}).strict(),taskViewBase={executor:z.object({binding:z.object({data:z.record(z.string(),jsonValueSchema),kind:z.string()}).strict().optional()}).strict().optional(),metadata:taskMetadataSchema,taskId:z.string(),usage:tokenUsageWithCostSchema.optional()},taskViewSchema=z.discriminatedUnion(`status`,[z.object({...taskViewBase,status:z.literal(`working`)}).strict(),z.object({...taskViewBase,inputRequests:z.array(jsonValueSchema),status:z.literal(`input_required`)}).strict(),z.object({...taskViewBase,lastOutput:z.object({data:jsonValueSchema,type:z.literal(`result`)}).strict(),status:z.literal(`completed`)}).strict(),z.object({...taskViewBase,lastOutput:z.object({data:jsonValueSchema,type:z.literal(`error`)}).strict(),status:z.literal(`failed`)}).strict(),z.object({...taskViewBase,status:z.literal(`cancelled`)}).strict()]),eventCoordinateSchema=z.number().int().nonnegative(),taskInputRequestBase={replyTo:z.string(),sequence:eventCoordinateSchema,stepIndex:eventCoordinateSchema,taskId:z.string(),turnId:z.string()},taskInputRequestSchema=z.union([z.object({...taskInputRequestBase,request:jsonValueSchema}).loose(),z.object({...taskInputRequestBase,requests:z.array(jsonValueSchema)}).loose()]),agentInvocationInputSchema=z.object({agentId:z.string().optional(),message:z.string(),outputSchema:z.record(z.string(),jsonValueSchema).optional(),target:z.string()}).strict(),agentTurnResultSchema=z.discriminatedUnion(`kind`,[z.strictObject({kind:z.literal(`succeeded`),output:jsonValueSchema}),z.strictObject({error:jsonValueSchema,kind:z.literal(`failed`)}),z.strictObject({kind:z.literal(`cancelled`)})]),agentTurnOutcomeSchema=z.discriminatedUnion(`kind`,[z.strictObject({kind:z.literal(`parked`),result:agentTurnResultSchema,usageDelta:tokenUsageWithCostSchema}),z.strictObject({kind:z.literal(`terminal`),result:agentTurnResultSchema,usageDelta:tokenUsageWithCostSchema})]),runtimeSubagentChildResultSchema=z.object({backgroundTask:z.strictObject({status:z.literal(`working`),taskId:z.string()}).optional(),callId:z.string(),isError:z.boolean().optional(),kind:z.literal(`subagent-result`),origin:z.literal(`child`),outcome:agentTurnOutcomeSchema,output:jsonValueSchema,subagentName:z.string(),usage:tokenUsageWithCostSchema.optional()}).strict(),taskAgentRequestSchema=z.object({replyTo:z.string(),request:z.discriminatedUnion(`kind`,[z.object({input:agentInvocationInputSchema,invocationId:z.string(),kind:z.literal(`agent-invoke`)}).strict(),z.object({kind:z.literal(`agent-settled`),result:runtimeSubagentChildResultSchema}).strict()]),taskId:z.string()}).strict(),subagentAuthorizationEventHookPayloadSchema=z.object({callId:z.string(),childSessionId:z.string(),event:z.custom(e=>typeof e==`object`&&!!e&&!Array.isArray(e),`Expected an object.`),kind:z.literal(`subagent-authorization-event`),subagentName:z.string()}).strict(),taskAuthorizationEventSchema=z.object({hookPayload:subagentAuthorizationEventHookPayloadSchema,taskId:z.string()}).strict(),taskPayloadV5Schema=z.object({agentRequests:z.array(taskAgentRequestSchema).optional(),authorizationEvents:z.array(taskAuthorizationEventSchema).optional(),inputRequests:z.array(taskInputRequestSchema).optional(),views:z.array(taskViewSchema).optional()}).strict(),v3=sessionInboxWireV3Schema.options,v3Deliver=v3[0],deliverPayloadV5Schema=v3Deliver.shape.payload.extend({task:taskPayloadV5Schema.optional()}),version=z.literal(5),sessionInboxWireV5Schema=z.discriminatedUnion(`kind`,[v3Deliver.extend({payload:deliverPayloadV5Schema,payloads:z.array(deliverPayloadV5Schema),version}),v3[1].extend({version}),v3[2].extend({version}),v3[3].extend({version}),v3[4].extend({version}),v3[5].extend({version})]);function encodeSessionCommandV5(e){let t=e.kind===`send`?{auth:e.auth,caller:e.caller,deliveryMetadata:e.delivery===void 0?void 0:[{...e.delivery,payloadIndex:0}],kind:`deliver`,payload:e.payload,payloads:[e.payload],requestId:e.requestId,taskDeliveryId:e.taskDeliveryId,turnPolicy:e.turnPolicy,version:5}:e.kind===`deliver`?{...e,payload:coalesceDeliverPayloads(e.payloads),version:5}:{...e,version:5},n=sessionInboxWireV5Schema.safeParse(t);if(!n.success)throw new SessionInboxWireError(`Produced a session inbox payload that does not match wire version 5: ${formatValidationError(n.error)}`);return n.data}export{encodeSessionCommandV5,sessionInboxWireV5Schema};
@@ -0,0 +1,3 @@
1
+ import type { VersionMigration } from "#execution/durable-session-migrations/chain.js";
2
+ /** Advances version-4 payloads to the additive token-cost schema. */
3
+ export declare const sessionInboxWireV4Migration: VersionMigration;
@@ -0,0 +1 @@
1
+ import{isObject}from"#shared/guards.js";const sessionInboxWireV4Migration={from:4,migrate(e){if(!isObject(e))throw Error(`session inbox wire v4 value is not an object.`);return{...e,version:5}},to:5};export{sessionInboxWireV4Migration};
@@ -0,0 +1,341 @@
1
+ import { z } from "#compiled/zod/index.js";
2
+ import type { DeliverHookPayload, SessionCommand, SessionTimeoutHookPayload } from "#channel/types.js";
3
+ /** Version 6 adds session-owned task cancellation to the cancel command. */
4
+ export declare const sessionInboxWireV6Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
5
+ auth: z.ZodOptional<z.ZodNullable<z.ZodObject<{
6
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
7
+ authenticator: z.ZodString;
8
+ issuer: z.ZodOptional<z.ZodString>;
9
+ principalId: z.ZodString;
10
+ principalType: z.ZodString;
11
+ subject: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strict>>>;
13
+ kind: z.ZodLiteral<"deliver">;
14
+ requestId: z.ZodOptional<z.ZodString>;
15
+ taskDeliveryId: z.ZodOptional<z.ZodString>;
16
+ turnPolicy: z.ZodOptional<z.ZodEnum<{
17
+ queue: "queue";
18
+ steer: "steer";
19
+ }>>;
20
+ caller: z.ZodOptional<z.ZodObject<{
21
+ callId: z.ZodString;
22
+ replyTo: z.ZodDiscriminatedUnion<[z.ZodObject<{
23
+ kind: z.ZodLiteral<"hook">;
24
+ token: z.ZodString;
25
+ }, z.core.$strict>, z.ZodObject<{
26
+ kind: z.ZodLiteral<"callback">;
27
+ token: z.ZodString;
28
+ url: z.ZodString;
29
+ }, z.core.$strict>], "kind">;
30
+ subagentName: z.ZodString;
31
+ taskId: z.ZodOptional<z.ZodString>;
32
+ activityObserver: z.ZodOptional<z.ZodObject<{
33
+ sink: z.ZodObject<{
34
+ url: z.ZodString;
35
+ version: z.ZodLiteral<1>;
36
+ }, z.core.$strict>;
37
+ workIdentity: z.ZodOptional<z.ZodObject<{
38
+ callId: z.ZodOptional<z.ZodString>;
39
+ id: z.ZodString;
40
+ kind: z.ZodEnum<{
41
+ "remote-agent": "remote-agent";
42
+ "root-turn": "root-turn";
43
+ subagent: "subagent";
44
+ task: "task";
45
+ }>;
46
+ name: z.ZodOptional<z.ZodString>;
47
+ parentId: z.ZodOptional<z.ZodString>;
48
+ rootSessionId: z.ZodString;
49
+ rootTurnId: z.ZodString;
50
+ sessionId: z.ZodOptional<z.ZodString>;
51
+ turnId: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strict>>;
53
+ }, z.core.$strict>>;
54
+ }, z.core.$strict>>;
55
+ deliveryMetadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
+ channelKind: z.ZodString;
57
+ channelName: z.ZodString;
58
+ deliveryId: z.ZodString;
59
+ payloadIndex: z.ZodNumber;
60
+ requestId: z.ZodOptional<z.ZodString>;
61
+ requestTraceContext: z.ZodOptional<z.ZodObject<{
62
+ spanId: z.ZodString;
63
+ traceFlags: z.ZodNumber;
64
+ traceId: z.ZodString;
65
+ }, z.core.$strict>>;
66
+ acceptedDeploymentId: z.ZodOptional<z.ZodString>;
67
+ }, z.core.$strict>>>;
68
+ payload: z.ZodObject<{
69
+ context: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
+ inputResponses: z.ZodOptional<z.ZodArray<z.ZodObject<{
71
+ optionId: z.ZodOptional<z.ZodString>;
72
+ requestId: z.ZodString;
73
+ text: z.ZodOptional<z.ZodString>;
74
+ }, z.core.$strict>>>;
75
+ message: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
76
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
77
+ text: z.ZodString;
78
+ type: z.ZodLiteral<"text">;
79
+ }, z.core.$strict>, z.ZodObject<{
80
+ image: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
81
+ mediaType: z.ZodOptional<z.ZodString>;
82
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
83
+ type: z.ZodLiteral<"image">;
84
+ }, z.core.$strict>, z.ZodObject<{
85
+ data: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
86
+ filename: z.ZodOptional<z.ZodString>;
87
+ mediaType: z.ZodString;
88
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
89
+ type: z.ZodLiteral<"file">;
90
+ }, z.core.$strict>], "type">>]>>;
91
+ outputSchema: z.ZodOptional<z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>;
92
+ task: z.ZodOptional<z.ZodObject<{
93
+ agentRequests: z.ZodOptional<z.ZodArray<z.ZodObject<{
94
+ replyTo: z.ZodString;
95
+ request: z.ZodDiscriminatedUnion<[z.ZodObject<{
96
+ input: z.ZodObject<{
97
+ agentId: z.ZodOptional<z.ZodString>;
98
+ message: z.ZodString;
99
+ outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>>;
100
+ target: z.ZodString;
101
+ }, z.core.$strict>;
102
+ invocationId: z.ZodString;
103
+ kind: z.ZodLiteral<"agent-invoke">;
104
+ }, z.core.$strict>, z.ZodObject<{
105
+ kind: z.ZodLiteral<"agent-settled">;
106
+ result: z.ZodObject<{
107
+ backgroundTask: z.ZodOptional<z.ZodObject<{
108
+ status: z.ZodLiteral<"working">;
109
+ taskId: z.ZodString;
110
+ }, z.core.$strict>>;
111
+ callId: z.ZodString;
112
+ isError: z.ZodOptional<z.ZodBoolean>;
113
+ kind: z.ZodLiteral<"subagent-result">;
114
+ origin: z.ZodLiteral<"child">;
115
+ outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
116
+ kind: z.ZodLiteral<"parked">;
117
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
118
+ kind: z.ZodLiteral<"succeeded">;
119
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
120
+ }, z.core.$strict>, z.ZodObject<{
121
+ error: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
122
+ kind: z.ZodLiteral<"failed">;
123
+ }, z.core.$strict>, z.ZodObject<{
124
+ kind: z.ZodLiteral<"cancelled">;
125
+ }, z.core.$strict>], "kind">;
126
+ usageDelta: z.ZodObject<{
127
+ cacheReadTokens: z.ZodNumber;
128
+ cacheWriteTokens: z.ZodNumber;
129
+ inputTokens: z.ZodNumber;
130
+ outputTokens: z.ZodNumber;
131
+ costUsd: z.ZodOptional<z.ZodNumber>;
132
+ }, z.core.$strip>;
133
+ }, z.core.$strict>, z.ZodObject<{
134
+ kind: z.ZodLiteral<"terminal">;
135
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
136
+ kind: z.ZodLiteral<"succeeded">;
137
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
138
+ }, z.core.$strict>, z.ZodObject<{
139
+ error: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
140
+ kind: z.ZodLiteral<"failed">;
141
+ }, z.core.$strict>, z.ZodObject<{
142
+ kind: z.ZodLiteral<"cancelled">;
143
+ }, z.core.$strict>], "kind">;
144
+ usageDelta: z.ZodObject<{
145
+ cacheReadTokens: z.ZodNumber;
146
+ cacheWriteTokens: z.ZodNumber;
147
+ inputTokens: z.ZodNumber;
148
+ outputTokens: z.ZodNumber;
149
+ costUsd: z.ZodOptional<z.ZodNumber>;
150
+ }, z.core.$strip>;
151
+ }, z.core.$strict>], "kind">;
152
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
153
+ subagentName: z.ZodString;
154
+ usage: z.ZodOptional<z.ZodObject<{
155
+ cacheReadTokens: z.ZodNumber;
156
+ cacheWriteTokens: z.ZodNumber;
157
+ inputTokens: z.ZodNumber;
158
+ outputTokens: z.ZodNumber;
159
+ costUsd: z.ZodOptional<z.ZodNumber>;
160
+ }, z.core.$strip>>;
161
+ }, z.core.$strict>;
162
+ }, z.core.$strict>], "kind">;
163
+ taskId: z.ZodString;
164
+ }, z.core.$strict>>>;
165
+ authorizationEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
166
+ hookPayload: z.ZodObject<{
167
+ callId: z.ZodString;
168
+ childSessionId: z.ZodString;
169
+ event: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
170
+ kind: z.ZodLiteral<"subagent-authorization-event">;
171
+ subagentName: z.ZodString;
172
+ }, z.core.$strict>;
173
+ taskId: z.ZodString;
174
+ }, z.core.$strict>>>;
175
+ inputRequests: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
176
+ replyTo: z.ZodString;
177
+ sequence: z.ZodNumber;
178
+ stepIndex: z.ZodNumber;
179
+ taskId: z.ZodString;
180
+ turnId: z.ZodString;
181
+ request: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
182
+ }, z.core.$loose>, z.ZodObject<{
183
+ replyTo: z.ZodString;
184
+ sequence: z.ZodNumber;
185
+ stepIndex: z.ZodNumber;
186
+ taskId: z.ZodString;
187
+ turnId: z.ZodString;
188
+ requests: z.ZodArray<z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>;
189
+ }, z.core.$loose>]>>>;
190
+ views: z.ZodOptional<z.ZodArray<z.ZodType<import("../../tasks/types.ts").TaskView, unknown, z.core.$ZodTypeInternals<import("../../tasks/types.ts").TaskView, unknown>>>>;
191
+ }, z.core.$strict>>;
192
+ }, z.core.$loose>;
193
+ payloads: z.ZodArray<z.ZodObject<{
194
+ context: z.ZodOptional<z.ZodArray<z.ZodString>>;
195
+ inputResponses: z.ZodOptional<z.ZodArray<z.ZodObject<{
196
+ optionId: z.ZodOptional<z.ZodString>;
197
+ requestId: z.ZodString;
198
+ text: z.ZodOptional<z.ZodString>;
199
+ }, z.core.$strict>>>;
200
+ message: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
201
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
202
+ text: z.ZodString;
203
+ type: z.ZodLiteral<"text">;
204
+ }, z.core.$strict>, z.ZodObject<{
205
+ image: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
206
+ mediaType: z.ZodOptional<z.ZodString>;
207
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
208
+ type: z.ZodLiteral<"image">;
209
+ }, z.core.$strict>, z.ZodObject<{
210
+ data: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
211
+ filename: z.ZodOptional<z.ZodString>;
212
+ mediaType: z.ZodString;
213
+ providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
214
+ type: z.ZodLiteral<"file">;
215
+ }, z.core.$strict>], "type">>]>>;
216
+ outputSchema: z.ZodOptional<z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>;
217
+ task: z.ZodOptional<z.ZodObject<{
218
+ agentRequests: z.ZodOptional<z.ZodArray<z.ZodObject<{
219
+ replyTo: z.ZodString;
220
+ request: z.ZodDiscriminatedUnion<[z.ZodObject<{
221
+ input: z.ZodObject<{
222
+ agentId: z.ZodOptional<z.ZodString>;
223
+ message: z.ZodString;
224
+ outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>>;
225
+ target: z.ZodString;
226
+ }, z.core.$strict>;
227
+ invocationId: z.ZodString;
228
+ kind: z.ZodLiteral<"agent-invoke">;
229
+ }, z.core.$strict>, z.ZodObject<{
230
+ kind: z.ZodLiteral<"agent-settled">;
231
+ result: z.ZodObject<{
232
+ backgroundTask: z.ZodOptional<z.ZodObject<{
233
+ status: z.ZodLiteral<"working">;
234
+ taskId: z.ZodString;
235
+ }, z.core.$strict>>;
236
+ callId: z.ZodString;
237
+ isError: z.ZodOptional<z.ZodBoolean>;
238
+ kind: z.ZodLiteral<"subagent-result">;
239
+ origin: z.ZodLiteral<"child">;
240
+ outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
241
+ kind: z.ZodLiteral<"parked">;
242
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
243
+ kind: z.ZodLiteral<"succeeded">;
244
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
245
+ }, z.core.$strict>, z.ZodObject<{
246
+ error: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
247
+ kind: z.ZodLiteral<"failed">;
248
+ }, z.core.$strict>, z.ZodObject<{
249
+ kind: z.ZodLiteral<"cancelled">;
250
+ }, z.core.$strict>], "kind">;
251
+ usageDelta: z.ZodObject<{
252
+ cacheReadTokens: z.ZodNumber;
253
+ cacheWriteTokens: z.ZodNumber;
254
+ inputTokens: z.ZodNumber;
255
+ outputTokens: z.ZodNumber;
256
+ costUsd: z.ZodOptional<z.ZodNumber>;
257
+ }, z.core.$strip>;
258
+ }, z.core.$strict>, z.ZodObject<{
259
+ kind: z.ZodLiteral<"terminal">;
260
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
261
+ kind: z.ZodLiteral<"succeeded">;
262
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
263
+ }, z.core.$strict>, z.ZodObject<{
264
+ error: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
265
+ kind: z.ZodLiteral<"failed">;
266
+ }, z.core.$strict>, z.ZodObject<{
267
+ kind: z.ZodLiteral<"cancelled">;
268
+ }, z.core.$strict>], "kind">;
269
+ usageDelta: z.ZodObject<{
270
+ cacheReadTokens: z.ZodNumber;
271
+ cacheWriteTokens: z.ZodNumber;
272
+ inputTokens: z.ZodNumber;
273
+ outputTokens: z.ZodNumber;
274
+ costUsd: z.ZodOptional<z.ZodNumber>;
275
+ }, z.core.$strip>;
276
+ }, z.core.$strict>], "kind">;
277
+ output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
278
+ subagentName: z.ZodString;
279
+ usage: z.ZodOptional<z.ZodObject<{
280
+ cacheReadTokens: z.ZodNumber;
281
+ cacheWriteTokens: z.ZodNumber;
282
+ inputTokens: z.ZodNumber;
283
+ outputTokens: z.ZodNumber;
284
+ costUsd: z.ZodOptional<z.ZodNumber>;
285
+ }, z.core.$strip>>;
286
+ }, z.core.$strict>;
287
+ }, z.core.$strict>], "kind">;
288
+ taskId: z.ZodString;
289
+ }, z.core.$strict>>>;
290
+ authorizationEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
291
+ hookPayload: z.ZodObject<{
292
+ callId: z.ZodString;
293
+ childSessionId: z.ZodString;
294
+ event: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
295
+ kind: z.ZodLiteral<"subagent-authorization-event">;
296
+ subagentName: z.ZodString;
297
+ }, z.core.$strict>;
298
+ taskId: z.ZodString;
299
+ }, z.core.$strict>>>;
300
+ inputRequests: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
301
+ replyTo: z.ZodString;
302
+ sequence: z.ZodNumber;
303
+ stepIndex: z.ZodNumber;
304
+ taskId: z.ZodString;
305
+ turnId: z.ZodString;
306
+ request: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
307
+ }, z.core.$loose>, z.ZodObject<{
308
+ replyTo: z.ZodString;
309
+ sequence: z.ZodNumber;
310
+ stepIndex: z.ZodNumber;
311
+ taskId: z.ZodString;
312
+ turnId: z.ZodString;
313
+ requests: z.ZodArray<z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>;
314
+ }, z.core.$loose>]>>>;
315
+ views: z.ZodOptional<z.ZodArray<z.ZodType<import("../../tasks/types.ts").TaskView, unknown, z.core.$ZodTypeInternals<import("../../tasks/types.ts").TaskView, unknown>>>>;
316
+ }, z.core.$strict>>;
317
+ }, z.core.$loose>>;
318
+ version: z.ZodLiteral<6>;
319
+ }, z.core.$strict>, z.ZodObject<{
320
+ kind: z.ZodLiteral<"session-timeout">;
321
+ version: z.ZodLiteral<6>;
322
+ }, z.core.$strict>, z.ZodObject<{
323
+ kind: z.ZodLiteral<"clear">;
324
+ version: z.ZodLiteral<6>;
325
+ }, z.core.$strict>, z.ZodObject<{
326
+ kind: z.ZodLiteral<"compact">;
327
+ version: z.ZodLiteral<6>;
328
+ }, z.core.$strict>, z.ZodObject<{
329
+ kind: z.ZodLiteral<"reset">;
330
+ reason: z.ZodOptional<z.ZodString>;
331
+ version: z.ZodLiteral<6>;
332
+ }, z.core.$strict>, z.ZodObject<{
333
+ kind: z.ZodLiteral<"cancel">;
334
+ taskId: z.ZodOptional<z.ZodString>;
335
+ turnId: z.ZodOptional<z.ZodString>;
336
+ tasks: z.ZodOptional<z.ZodBoolean>;
337
+ version: z.ZodLiteral<6>;
338
+ }, z.core.$strict>], "kind">;
339
+ export type SessionInboxWireV6 = z.infer<typeof sessionInboxWireV6Schema>;
340
+ /** Builds and validates one complete version-6 wire value. */
341
+ export declare function encodeSessionCommandV6(command: DeliverHookPayload | SessionCommand | SessionTimeoutHookPayload): SessionInboxWireV6;
@@ -0,0 +1 @@
1
+ import{z}from"#compiled/zod/index.js";import{formatValidationError}from"#runtime/validation.js";import{SessionInboxWireError}from"#execution/wire/session-inbox-contract.js";import{encodeSessionCommandV5,sessionInboxWireV5Schema}from"#execution/wire/session-inbox-wire.v5.js";const v5=sessionInboxWireV5Schema.options,v5Cancel=v5[5],version=z.literal(6),sessionInboxWireV6Schema=z.discriminatedUnion(`kind`,[v5[0].extend({version}),v5[1].extend({version}),v5[2].extend({version}),v5[3].extend({version}),v5[4].extend({version}),v5Cancel.extend({tasks:z.boolean().optional(),version})]);function encodeSessionCommandV6(e){let r={...encodeSessionCommandV5(withoutOwnedTaskCancellation(e)),version:6};e.kind===`cancel`&&(r.tasks=e.tasks);let i=sessionInboxWireV6Schema.safeParse(r);if(!i.success)throw new SessionInboxWireError(`Produced a session inbox payload that does not match wire version 6: ${formatValidationError(i.error)}`);return i.data}function withoutOwnedTaskCancellation(e){if(e.kind!==`cancel`||e.tasks===void 0)return e;let{tasks:t,...n}=e;return n}export{encodeSessionCommandV6,sessionInboxWireV6Schema};
@@ -1 +1 @@
1
- import{attachClientContext,readClientContext}from"#internal/client-context.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{fireSessionCallbackStep}from"#subagents/callback-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyDelegatedParentStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{createDelegatedSubagentErrorResult}from"#subagents/parent-result.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";import{nextTurnDelivery}from"#execution/parked-delivery-wait.js";import{rebaseTaskAgentHandleMutations}from"#subagents/handles/rebase.js";import{dispatchAndAwaitTurn}from"#execution/turn-dispatch.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";import{finalizeDone,finalizeExpiredSession}from"#execution/workflow-entry-finalization.js";import{createSessionCommandInbox}from"#execution/session-command-inbox.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session-timeout.js";import{createSessionTimeoutControl}from"#execution/session-timeout-control.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";async function workflowEntry(c){"use workflow";let{workflowRunId:d,workflowStartedAt:f}=getWorkflowMetadata(),p=c.serializedContext[`eve.continuationToken`]||``,v=c.serializedContext[`eve.mode`],y=c.serializedContext[`eve.capabilities`],b=c.serializedContext[`eve.bundle`];c.serializedContext[`eve.sessionId`]=d;let x=getWritable(),C={caller:void 0,callerResolved:!1,lastSessionState:void 0,serializedContext:c.serializedContext,terminalEmitted:!1};try{let r=readRootSessionId(c.serializedContext),i=c.serializedContext[`eve.dynamicSubagentAgentConfig`],l=createSessionCommandInbox(),u=sessionCommandHookToken(d),m=`${d}:auth`,h,g;try{let[n,s,_,S]=await Promise.allSettled([createSessionStep({compiledArtifactsSource:b.source,continuationToken:p,dynamicSubagentAgentConfig:i,inheritedLimits:c.limits,nodeId:b.nodeId,outputSchema:c.input.outputSchema,rootSessionId:r,sessionId:d,taskId:c.taskId}),l.claimStable(u),l.claimAuthorization(m),l.rekeyContinuation(p)]);if(n.status===`rejected`)throw n.reason;if(s.status===`rejected`)throw s.reason;if(_.status===`rejected`)throw _.reason;if(S.status===`rejected`){if(isHookConflictError(S.reason))return(c.activityCollectorRunId!==void 0||c.continuationConflictCommand!==void 0)&&await settleContinuationConflictStep({activityCollectorRunId:c.activityCollectorRunId,command:c.continuationConflictCommand,continuationToken:p,ownerSessionId:typeof S.reason.conflictingRunId==`string`?S.reason.conflictingRunId:void 0}),{output:``};throw S.reason}h=n.value.state,C.lastSessionState=h,C.caller=hasDelegatedCallerContext(c.serializedContext)?await resolveInitialTurnCallerStep({serializedContext:c.serializedContext}):void 0,C.callerResolved=!0,g=await runDriverLoop({capabilities:y,commandInbox:l,driverWritable:x,initialInput:{deliveryMetadata:c.serializedContext[`eve.channelDelivery`]===void 0?void 0:[{...c.serializedContext[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[attachClientContext({message:c.input.message,context:c.input.context,outputSchema:c.input.outputSchema},readClientContext(c.input))],requestId:readChannelRequestId(c.serializedContext)},crashCleanupState:C,mode:v,serializedContext:c.serializedContext,sessionState:h,sessionTimeoutDeadline:c.sessionTimeoutMs===!1?void 0:new Date(f.getTime()+(c.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS)),stableCommandToken:u})}finally{await l.dispose()}return g.kind===`result`?g.result:await finalizeExpiredSession({caller:C.caller,driverWritable:x,mode:v,serializedContext:g.serializedContext,sessionState:g.sessionState,terminalState:C})}catch(e){let t=C.terminalEmitted;throw!C.terminalEmitted&&C.lastSessionState!==void 0&&await terminateChildSessionsStep({serializedContext:C.serializedContext,sessionState:C.lastSessionState}),C.terminalEmitted||=(await emitTerminalSessionFailureStep({error:normalizeSerializableError(e),parentWritable:x,serializedContext:C.serializedContext,turnId:C.turnId}),!0),t||(v===`task`?(await fireSessionCallbackStep({error:normalizeSerializableError(e),serializedContext:C.serializedContext,status:`failed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentErrorResult(C.serializedContext,e),serializedContext:C.serializedContext})):(C.caller!==void 0||!C.callerResolved)&&await notifyTurnCallerStep({caller:await resolveCallerForCrash(C,C.serializedContext),lifecycle:`terminal`,sessionId:d,settled:{isError:!0,output:e}})),createSafeOuterWorkflowError()}}function hasDelegatedCallerContext(e){if(e[`eve.sessionCallback`]!==void 0)return!0;let t=e[`eve.channel`];return typeof t==`object`&&!!t&&Reflect.get(t,`kind`)===`subagent`}async function resolveCallerForCrash(e,t){if(e.callerResolved)return e.caller;try{return await resolveInitialTurnCallerStep({serializedContext:t})}catch{return}}function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runDriverLoop(e){let t=e.commandInbox,n=new Map,nextParkedActivity=async r=>{let c=new Set(r.expectedAttemptIds);for(let e of n.keys())c.has(e)||n.delete(e);for(;;){if(c.size>0&&[...c].every(e=>n.has(e))){let e=[...c].map(e=>n.get(e));return n.clear(),{kind:`authorization-resume`,payloads:e}}let r=await nextTurnDelivery({awaitAuthorizationCallbacks:c.size>0,bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,commandInbox:t,deferDeliveries:e.mode===`task`&&c.size>0,driverWritable:e.driverWritable,seenTaskDeliveries:s,stateCursor:l});if(r.kind!==`authorization`)return r;for(let e of r.payloads){let t=e.authorizationCallback;typeof t?.attemptId==`string`&&c.has(t.attemptId)&&!n.has(t.attemptId)&&n.set(t.attemptId,e)}if(r.closed){let e=[...n.values()];return n.clear(),{kind:`authorization-resume`,payloads:e}}}},r=0,nextTurnControlToken=()=>`${e.sessionState.sessionId}:turn-control:${String(r++)}`,i=[],a=[],o=new Set,s=new Set,l=new SessionStateCursor({serializedContext:e.serializedContext,sessionState:e.sessionState}),u=e.sessionTimeoutDeadline===void 0?void 0:createSessionTimeoutControl({deadline:e.sessionTimeoutDeadline,token:e.stableCommandToken}),m,runTurn=async n=>{let c=l.sessionState,u=e.crashCleanupState.caller;u?.taskId!==void 0&&s.add(u.taskId);let d=u===void 0?l.serializedContext:await bindTurnCallerContextStep({caller:u,serializedContext:l.serializedContext});e.crashCleanupState.turnId=`turn_${String(r)}`;let p=await dispatchAndAwaitTurn({bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,capabilities:e.capabilities,commandInbox:t,controlToken:nextTurnControlToken(),delivery:n,mode:e.mode,parentWritable:e.driverWritable,serializedContext:d,seenTaskDeliveries:s,sessionState:l.sessionState});await m?.(),m=p.dispose;let h=l.sessionState===c?p.action:rebaseTaskAgentHandleMutations(p.action,l.sessionState,c);return l.adoptState(h),e.crashCleanupState.lastSessionState=l.sessionState,e.crashCleanupState.serializedContext=l.serializedContext,h};try{await u?.start();let n=await runTurn(e.initialInput);for(;;){if(n.kind===`done`)return{kind:`result`,result:await finalizeDone({action:n,caller:e.crashCleanupState.caller,mode:e.mode,terminalState:e.crashCleanupState})};if(n.kind!==`park`)throw Error(`Driver received unexpected turn action "${n.kind}".`);if(n.cancelled===!0){let t=await settleCancelledTurnStep({parentWritable:e.driverWritable,serializedContext:l.serializedContext,sessionState:l.sessionState});l.adoptState(t),e.crashCleanupState.serializedContext=l.serializedContext;let n={caller:e.crashCleanupState.caller,sessionId:l.sessionState.sessionId};await notifyCancelledTaskCallerStep(t.usage===void 0?n:{...n,usage:t.usage}),e.crashCleanupState.lastSessionState=l.sessionState}l.sessionState.continuationToken&&await t.rekeyContinuation(l.sessionState.continuationToken);let r=n.settled;n.cancelled!==!0&&r!==void 0?(e.crashCleanupState.caller!==void 0&&await notifyTurnCallerStep({caller:e.crashCleanupState.caller,lifecycle:`parked`,sessionId:l.sessionState.sessionId,settled:r}),e.crashCleanupState.caller=void 0):n.cancelled===!0&&(e.crashCleanupState.caller=void 0);let i=await nextParkedActivity({expectedAttemptIds:n.authorizationAttemptIds??[]});if(e.crashCleanupState.lastSessionState=l.sessionState,i.kind===`authorization-resume`){n=await runTurn({kind:`deliver`,payloads:i.payloads});continue}if(i.kind===`expired`)return{kind:`expired`,serializedContext:l.serializedContext,sessionState:l.sessionState};if(i.kind===`reset`)return{kind:`result`,result:await finalizeExpiredSession({caller:e.crashCleanupState.caller,driverWritable:e.driverWritable,mode:e.mode,serializedContext:l.serializedContext,sessionState:l.sessionState,terminalState:e.crashCleanupState})};if(i.kind===`clear`||i.kind===`compact`){n=await runTurn({kind:i.kind});continue}if(i.kind===`closed`)return{kind:`result`,result:await finalizeExpiredSession({caller:e.crashCleanupState.caller,driverWritable:e.driverWritable,mode:e.mode,serializedContext:l.serializedContext,sessionState:l.sessionState,terminalState:e.crashCleanupState})};if(i.kind===`cancel-turn`){await cancelDescendantTurnsStep({serializedContext:l.serializedContext,sessionState:l.sessionState});let t=await settleCancelledTurnStep({parentWritable:e.driverWritable,serializedContext:l.serializedContext,sessionState:l.sessionState});l.adoptState(t),e.crashCleanupState.serializedContext=l.serializedContext,n={...n,settled:void 0},e.crashCleanupState.caller=void 0,e.crashCleanupState.lastSessionState=l.sessionState;continue}i.delivery.caller!==void 0&&(e.crashCleanupState.caller=i.delivery.caller),n=await runTurn(i.delivery)}}finally{await m?.(),await u?.dispose()}}export{workflowEntry};
1
+ import{attachClientContext,readClientContext}from"#internal/client-context.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{fireSessionCallbackStep}from"#subagents/callback-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyDelegatedParentStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{createDelegatedSubagentErrorResult}from"#subagents/parent-result.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";import{nextTurnDelivery}from"#execution/parked-delivery-wait.js";import{rebaseTaskAgentHandleMutations}from"#subagents/handles/rebase.js";import{dispatchAndAwaitTurn}from"#execution/turn-dispatch.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";import{finalizeDone,finalizeExpiredSession}from"#execution/workflow-entry-finalization.js";import{createSessionCommandInbox}from"#execution/session-command-inbox.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session-timeout.js";import{createSessionTimeoutControl}from"#execution/session-timeout-control.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";async function workflowEntry(c){"use workflow";let{workflowRunId:d,workflowStartedAt:f}=getWorkflowMetadata(),p=c.serializedContext[`eve.continuationToken`]||``,v=c.serializedContext[`eve.mode`],y=c.serializedContext[`eve.capabilities`],b=c.serializedContext[`eve.bundle`];c.serializedContext[`eve.sessionId`]=d;let x=getWritable(),C={caller:void 0,callerResolved:!1,lastSessionState:void 0,serializedContext:c.serializedContext,terminalEmitted:!1};try{let r=readRootSessionId(c.serializedContext),i=c.serializedContext[`eve.dynamicSubagentAgentConfig`],l=createSessionCommandInbox(),u=sessionCommandHookToken(d),m=`${d}:auth`,h,g;try{let[n,s,_,S]=await Promise.allSettled([createSessionStep({compiledArtifactsSource:b.source,continuationToken:p,dynamicSubagentAgentConfig:i,inheritedLimits:c.limits,nodeId:b.nodeId,outputSchema:c.input.outputSchema,rootSessionId:r,sessionId:d,taskId:c.taskId}),l.claimStable(u),l.claimAuthorization(m),l.rekeyContinuation(p)]);if(n.status===`rejected`)throw n.reason;if(s.status===`rejected`)throw s.reason;if(_.status===`rejected`)throw _.reason;if(S.status===`rejected`){if(isHookConflictError(S.reason))return(c.activityCollectorRunId!==void 0||c.continuationConflictCommand!==void 0)&&await settleContinuationConflictStep({activityCollectorRunId:c.activityCollectorRunId,command:c.continuationConflictCommand,continuationToken:p,ownerSessionId:typeof S.reason.conflictingRunId==`string`?S.reason.conflictingRunId:void 0}),{output:``};throw S.reason}h=n.value.state,C.lastSessionState=h,C.caller=hasDelegatedCallerContext(c.serializedContext)?await resolveInitialTurnCallerStep({serializedContext:c.serializedContext}):void 0,C.callerResolved=!0,g=await runDriverLoop({capabilities:y,commandInbox:l,driverWritable:x,initialInput:{deliveryMetadata:c.serializedContext[`eve.channelDelivery`]===void 0?void 0:[{...c.serializedContext[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[attachClientContext({message:c.input.message,context:c.input.context,outputSchema:c.input.outputSchema},readClientContext(c.input))],requestId:readChannelRequestId(c.serializedContext)},crashCleanupState:C,mode:v,serializedContext:c.serializedContext,sessionState:h,sessionTimeoutDeadline:c.sessionTimeoutMs===!1?void 0:new Date(f.getTime()+(c.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS)),stableCommandToken:u})}finally{await l.dispose()}return g.kind===`result`?g.result:await finalizeExpiredSession({caller:C.caller,driverWritable:x,mode:v,serializedContext:g.serializedContext,sessionState:g.sessionState,terminalState:C})}catch(e){let t=C.terminalEmitted;throw!C.terminalEmitted&&C.lastSessionState!==void 0&&await terminateChildSessionsStep({serializedContext:C.serializedContext,sessionState:C.lastSessionState}),C.terminalEmitted||=(await emitTerminalSessionFailureStep({error:normalizeSerializableError(e),parentWritable:x,serializedContext:C.serializedContext,turnId:C.turnId}),!0),t||(v===`task`?(await fireSessionCallbackStep({error:normalizeSerializableError(e),serializedContext:C.serializedContext,status:`failed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentErrorResult(C.serializedContext,e),serializedContext:C.serializedContext})):(C.caller!==void 0||!C.callerResolved)&&await notifyTurnCallerStep({caller:await resolveCallerForCrash(C,C.serializedContext),lifecycle:`terminal`,sessionId:d,settled:{isError:!0,output:e}})),createSafeOuterWorkflowError()}}function hasDelegatedCallerContext(e){if(e[`eve.sessionCallback`]!==void 0)return!0;let t=e[`eve.channel`];return typeof t==`object`&&!!t&&Reflect.get(t,`kind`)===`subagent`}async function resolveCallerForCrash(e,t){if(e.callerResolved)return e.caller;try{return await resolveInitialTurnCallerStep({serializedContext:t})}catch{return}}function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runDriverLoop(e){let t=e.commandInbox,n=new Map,nextParkedActivity=async r=>{let c=new Set(r.expectedAttemptIds);for(let e of n.keys())c.has(e)||n.delete(e);for(;;){if(c.size>0&&[...c].every(e=>n.has(e))){let e=[...c].map(e=>n.get(e));return n.clear(),{kind:`authorization-resume`,payloads:e}}let r=await nextTurnDelivery({awaitAuthorizationCallbacks:c.size>0,bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,commandInbox:t,deferDeliveries:e.mode===`task`&&c.size>0,driverWritable:e.driverWritable,seenTaskDeliveries:s,stateCursor:l});if(r.kind!==`authorization`)return r;for(let e of r.payloads){let t=e.authorizationCallback;typeof t?.attemptId==`string`&&c.has(t.attemptId)&&!n.has(t.attemptId)&&n.set(t.attemptId,e)}if(r.closed){let e=[...n.values()];return n.clear(),{kind:`authorization-resume`,payloads:e}}}},r=0,nextTurnControlToken=()=>`${e.sessionState.sessionId}:turn-control:${String(r++)}`,i=[],a=[],o=new Set,s=new Set,l=new SessionStateCursor({serializedContext:e.serializedContext,sessionState:e.sessionState}),u=e.sessionTimeoutDeadline===void 0?void 0:createSessionTimeoutControl({deadline:e.sessionTimeoutDeadline,token:e.stableCommandToken}),m,runTurn=async n=>{let c=l.sessionState,u=e.crashCleanupState.caller;u?.taskId!==void 0&&s.add(u.taskId);let d=u===void 0?l.serializedContext:await bindTurnCallerContextStep({caller:u,serializedContext:l.serializedContext});e.crashCleanupState.turnId=`turn_${String(r)}`;let p=await dispatchAndAwaitTurn({bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,capabilities:e.capabilities,commandInbox:t,controlToken:nextTurnControlToken(),delivery:n,mode:e.mode,parentWritable:e.driverWritable,serializedContext:d,seenTaskDeliveries:s,sessionState:l.sessionState,stateCursor:l});await m?.(),m=p.dispose;let h=l.sessionState===c?p.action:rebaseTaskAgentHandleMutations(p.action,l.sessionState,c);return l.adoptState(h),e.crashCleanupState.lastSessionState=l.sessionState,e.crashCleanupState.serializedContext=l.serializedContext,h};try{await u?.start();let n=await runTurn(e.initialInput);for(;;){if(n.kind===`done`)return{kind:`result`,result:await finalizeDone({action:n,caller:e.crashCleanupState.caller,mode:e.mode,terminalState:e.crashCleanupState})};if(n.kind!==`park`)throw Error(`Driver received unexpected turn action "${n.kind}".`);if(n.cancelled===!0){let t=await settleCancelledTurnStep({parentWritable:e.driverWritable,serializedContext:l.serializedContext,sessionState:l.sessionState});l.adoptState(t),e.crashCleanupState.serializedContext=l.serializedContext;let n={caller:e.crashCleanupState.caller,sessionId:l.sessionState.sessionId};await notifyCancelledTaskCallerStep(t.usage===void 0?n:{...n,usage:t.usage}),e.crashCleanupState.lastSessionState=l.sessionState}l.sessionState.continuationToken&&await t.rekeyContinuation(l.sessionState.continuationToken);let r=n.settled;n.cancelled!==!0&&r!==void 0?(e.crashCleanupState.caller!==void 0&&await notifyTurnCallerStep({caller:e.crashCleanupState.caller,lifecycle:`parked`,sessionId:l.sessionState.sessionId,settled:r}),e.crashCleanupState.caller=void 0):n.cancelled===!0&&(e.crashCleanupState.caller=void 0);let i=await nextParkedActivity({expectedAttemptIds:n.authorizationAttemptIds??[]});if(e.crashCleanupState.lastSessionState=l.sessionState,i.kind===`authorization-resume`){n=await runTurn({kind:`deliver`,payloads:i.payloads});continue}if(i.kind===`expired`)return{kind:`expired`,serializedContext:l.serializedContext,sessionState:l.sessionState};if(i.kind===`reset`)return{kind:`result`,result:await finalizeExpiredSession({caller:e.crashCleanupState.caller,driverWritable:e.driverWritable,mode:e.mode,serializedContext:l.serializedContext,sessionState:l.sessionState,terminalState:e.crashCleanupState})};if(i.kind===`clear`||i.kind===`compact`){n=await runTurn({kind:i.kind});continue}if(i.kind===`closed`)return{kind:`result`,result:await finalizeExpiredSession({caller:e.crashCleanupState.caller,driverWritable:e.driverWritable,mode:e.mode,serializedContext:l.serializedContext,sessionState:l.sessionState,terminalState:e.crashCleanupState})};if(i.kind===`cancel-turn`){await cancelDescendantTurnsStep({serializedContext:l.serializedContext,sessionState:l.sessionState});let t=await settleCancelledTurnStep({parentWritable:e.driverWritable,serializedContext:l.serializedContext,sessionState:l.sessionState});l.adoptState(t),e.crashCleanupState.serializedContext=l.serializedContext,n={...n,settled:void 0},e.crashCleanupState.caller=void 0,e.crashCleanupState.lastSessionState=l.sessionState;continue}i.delivery.caller!==void 0&&(e.crashCleanupState.caller=i.delivery.caller),n=await runTurn(i.delivery)}}finally{await m?.(),await u?.dispose()}}workflowEntry.workflowId=`workflow//eve//workflowEntry`;export{workflowEntry};
@@ -1 +1 @@
1
- import{randomBytes}from"node:crypto";import{createEveActivityRoutePath}from"#protocol/routes.js";import{createLogger,logError}from"#internal/logging.js";import{getChannelActivityPresentation}from"#channel/activity-renderer.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{ActivityObserverKey}from"#context/keys.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{normalizePersistedMessageStreamEvent}from"#protocol/message-version.js";import{cancelRun,getHookByToken,getRun,getWorld,start}from"#internal/workflow/runtime.js";import{serializeContext}from"#context/serialize.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{resumeSessionInbox}from"#execution/wire/session-inbox-resume.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{buildSessionAttributes,buildSubagentRootAttributes,readParentLineage}from"#execution/eve-workflow-attributes.js";import{normalizeEveAttributes}from"#runtime/attributes/normalize.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{initializeSessionInstrumentation}from"#instrumentation/runtime.js";import{createWorkflowCallbackUrl,resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{buildRunContext}from"#execution/runtime-context.js";import{parseNdjsonStream}from"#execution/ndjson-stream.js";import{buildInvocationAttributes}from"#internal/invocation/metadata.js";import{isAgentTraceContext}from"#tracing/agent-trace-context.js";import{ACTIVITY_COLLECTOR_WORKFLOW_NAME,SESSION_TIMEOUT_WORKFLOW_NAME,TASK_RUN_WORKFLOW_NAME,TURN_WORKFLOW_NAME,WORKFLOW_ENTRY_NAME,WORKFLOW_TOOL_RUN_WORKFLOW_NAME}from"#execution/stable-workflow-names.js";const EVE_PACKAGE_INFO=resolveInstalledPackageInfo(),COMMAND_HOOK_READY_TIMEOUT_MS=3e4,STABLE_ID_BASE=EVE_PACKAGE_INFO.name,log=createLogger(`execution.workflow-runtime`),workflowEntryReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_ENTRY_NAME}`},turnWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TURN_WORKFLOW_NAME}`},sessionTimeoutWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${SESSION_TIMEOUT_WORKFLOW_NAME}`},taskRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TASK_RUN_WORKFLOW_NAME}`},activityCollectorWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${ACTIVITY_COLLECTOR_WORKFLOW_NAME}`},workflowToolRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_TOOL_RUN_WORKFLOW_NAME}`};function createWorkflowRuntime(n){return{async createSession(a){let o=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:n.compiledArtifactsSource,nodeId:n.nodeId}),s=buildRunContext({bundle:o,dynamicSubagentAgentConfig:n.dynamicSubagentAgentConfig,run:a}),c=resolveEffectiveAgentRuntime(o,s);initializeSessionInstrumentation({agentName:c.turnAgent.id,ctx:s,parentTraceContext:a.parentTraceContext});let l=c.limits?.sessionTimeoutMs,u,d=a.activityObserver;if(a.parent===void 0&&d===void 0&&(getChannelActivityPresentation(a.adapter)?.renderers.length??0)>0){let n=serializeContext(s),r=randomBytes(32).toString(`base64url`),i={expiresAt:new Date(Date.now()+(typeof l==`number`?l:864e5)).toISOString(),serializedContext:n,token:r};try{u=(await startWorkflowOnCurrentDeployment(activityCollectorWorkflowReference,[i])).runId,d={sink:{url:createWorkflowCallbackUrl(resolveWorkflowCallbackBaseUrl(process.env.VERCEL_URL?`https://${process.env.VERCEL_URL}`:`http://localhost:3000`),createEveActivityRoutePath(r)),version:1}},s.set(ActivityObserverKey,d)}catch{await cancelActivityCollector(u),u=void 0,log.warn(`failed to start activity collector`)}}let f=serializeContext(s),p=readParentLineage(f),m={input:a.input,limits:a.limits,serializedContext:f},h=a.taskId??a.callback?.taskId;h!==void 0&&(m.taskId=h),u!==void 0&&(m.activityCollectorRunId=u),a.continuationConflictCommand!==void 0&&(m.continuationConflictCommand=a.continuationConflictCommand),l!==void 0&&(m.sessionTimeoutMs=l);let g={...p.sessionId===void 0?buildSessionAttributes({inputMessage:a.title??a.input.message,serializedContext:f}):buildSubagentRootAttributes({identity:{nodeId:o.nodeId??ROOT_RUNTIME_AGENT_NODE_ID},parentCallId:p.callId,parentSessionId:p.sessionId,parentTurnId:p.turnId,rootSessionId:p.rootSessionId??p.sessionId,serializedContext:f}),...a.externalInvocation===void 0?{}:buildInvocationAttributes(a.externalInvocation)},_;try{_=await startWorkflowOnCurrentDeployment(workflowEntryReference,[m],{allowReservedAttributes:!0,attributes:normalizeEveAttributes(g)})}catch(e){throw await cancelActivityCollector(u),logError(log,`failed to start workflow run`,e,{continuationToken:a.continuationToken}),e}let v,getEvents=()=>(v??=parseNdjsonStream(()=>getRun(_.runId).getReadable(),normalizePersistedEvent),v);return{get events(){return getEvents()},sessionId:_.runId}},async dispatchContinuation(e){return await dispatchWorkflowCommand(e.continuationToken,e.command)},async dispatchSession(e){return await dispatchWorkflowCommand(sessionCommandHookToken(e.sessionId),e.command)},async getEventStream(e,t){return parseNdjsonStream(()=>getRun(e).getReadable({startIndex:t?.startIndex}),normalizePersistedEvent)},async getStreamTailIndex(e){let t=getRun(e).getReadable();try{return await t.getTailIndex()}finally{await t.cancel().catch(()=>{})}},async resolveContinuation(e){try{return{sessionId:(await getHookByToken(e)).runId}}catch(t){if(HookNotFoundError.is(t))return;throw logError(log,`failed to resolve session by continuation token`,t,{continuationToken:e}),t}}}}function normalizePersistedEvent(e){return normalizePersistedMessageStreamEvent(e)}async function cancelActivityCollector(e){if(e!==void 0)try{await cancelRun(await getWorld(),e,{cancelReason:`Root session creation did not complete`})}catch{log.warn(`failed to cancel unowned activity collector`)}}async function dispatchWorkflowCommand(e,t){let n;try{n=normalizeWorkflowHook(await resumeSessionInbox(e,t))}catch(n){if(isInactiveCommandTarget(n))return inactiveCommandResult(t);throw logError(log,`failed to dispatch session command`,n,{command:t.kind,token:e}),n}return t.kind===`reset`&&await waitForCommandHookRelease(sessionCommandHookToken(n.runId),n.runId),activeCommandResult(t,n.runId)}function activeCommandResult(e,t){return e.kind===`reset`?{previousSessionId:t,status:`reset`}:(e.kind,{sessionId:t,status:`accepted`})}function inactiveCommandResult(e){return e.kind===`send`?{status:`session_not_active`}:e.kind===`cancel`?{status:`no_active_turn`}:{status:`no_active_session`}}async function requestWorkflowTurnCancellation(e){let t={kind:`cancel`};return e.taskId!==void 0&&(t.taskId=e.taskId),e.turnId!==void 0&&(t.turnId=e.turnId),await dispatchWorkflowCommand(sessionCommandHookToken(e.sessionId),t)}function isInactiveCommandTarget(e){if(HookNotFoundError.is(e))return!0;for(let t of walkCauseChain(e))if(WorkflowRunNotFoundError.is(t)||RunExpiredError.is(t)||EntityConflictError.is(t))return!0;return!1}async function waitForCommandHookOwner(e){let t=Date.now()+COMMAND_HOOK_READY_TIMEOUT_MS;for(;;)try{return normalizeWorkflowHook(await getHookByToken(e))}catch(e){if(!HookNotFoundError.is(e)||Date.now()>=t)throw e;await new Promise(e=>setTimeout(e,20))}}async function waitForCommandHookRelease(e,t){let n=Date.now()+COMMAND_HOOK_READY_TIMEOUT_MS;for(;;){try{if(normalizeWorkflowHook(await getHookByToken(e)).runId!==t)return}catch(e){if(HookNotFoundError.is(e))return;throw e}if(Date.now()>=n)throw Error(`Timed out waiting for session "${t}" to release its command inbox.`);await new Promise(e=>setTimeout(e,20))}}async function startWorkflowOnCurrentDeployment(e,t,n){return await startWorkflowOnDeployment(e,t,process.env.VERCEL_DEPLOYMENT_ID?.trim()||void 0,n)}async function startWorkflowOnAcceptedDeployment(e,t,n,r){return n===void 0?await startWorkflowOnCurrentDeployment(e,t,r):await startWorkflowOnDeployment(e,t,n,r)}async function startWorkflowOnDeployment(e,t,n,r){return await withWorkflowStartContext(async()=>n===void 0?r===void 0?await start(e,t):await start(e,t,r):await start(e,t,{...r,deploymentId:n}))}async function withWorkflowStartContext(e){let t=context.active(),n=isAgentTraceContext(t)?trace.deleteSpan(t):t;return await context.with(n,e)}function normalizeWorkflowHook(e){if(typeof e!=`object`||!e||!(`runId`in e))throw Error(`Workflow hook did not include a run id.`);let t=e.runId;if(typeof t!=`string`||t.length===0)throw Error(`Workflow hook did not include a run id.`);return{runId:t}}export{activityCollectorWorkflowReference,createWorkflowRuntime,requestWorkflowTurnCancellation,sessionTimeoutWorkflowReference,startWorkflowOnAcceptedDeployment,startWorkflowOnCurrentDeployment,taskRunWorkflowReference,turnWorkflowReference,waitForCommandHookOwner,workflowEntryReference,workflowToolRunWorkflowReference};
1
+ import{randomBytes}from"node:crypto";import{createEveActivityRoutePath}from"#protocol/routes.js";import{createLogger,logError}from"#internal/logging.js";import{getChannelActivityPresentation}from"#channel/activity-renderer.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{ActivityObserverKey}from"#context/keys.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{normalizePersistedMessageStreamEvent}from"#protocol/message-version.js";import{cancelRun,getRawHookByToken,getRun,getWorld,start}from"#internal/workflow/runtime.js";import{serializeContext}from"#context/serialize.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{resumeSessionInbox}from"#execution/wire/session-inbox-resume.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{buildSessionAttributes,buildSubagentRootAttributes,readParentLineage}from"#execution/eve-workflow-attributes.js";import{normalizeEveAttributes}from"#runtime/attributes/normalize.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{initializeSessionInstrumentation}from"#instrumentation/runtime.js";import{createWorkflowCallbackUrl,resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{buildRunContext}from"#execution/runtime-context.js";import{parseNdjsonStream}from"#execution/ndjson-stream.js";import{buildInvocationAttributes}from"#internal/invocation/metadata.js";import{isAgentTraceContext}from"#tracing/agent-trace-context.js";import{ACTIVITY_COLLECTOR_WORKFLOW_NAME,SESSION_TIMEOUT_WORKFLOW_NAME,TASK_RUN_WORKFLOW_NAME,TURN_WORKFLOW_NAME,WORKFLOW_ENTRY_NAME,WORKFLOW_TOOL_RUN_WORKFLOW_NAME}from"#execution/stable-workflow-names.js";const EVE_PACKAGE_INFO=resolveInstalledPackageInfo(),COMMAND_HOOK_READY_TIMEOUT_MS=3e4,STABLE_ID_BASE=EVE_PACKAGE_INFO.name,log=createLogger(`execution.workflow-runtime`),workflowEntryReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_ENTRY_NAME}`},turnWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TURN_WORKFLOW_NAME}`},sessionTimeoutWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${SESSION_TIMEOUT_WORKFLOW_NAME}`},taskRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TASK_RUN_WORKFLOW_NAME}`},activityCollectorWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${ACTIVITY_COLLECTOR_WORKFLOW_NAME}`},workflowToolRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_TOOL_RUN_WORKFLOW_NAME}`};function createWorkflowRuntime(n){return{async createSession(a){let o=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:n.compiledArtifactsSource,nodeId:n.nodeId}),s=buildRunContext({bundle:o,dynamicSubagentAgentConfig:n.dynamicSubagentAgentConfig,run:a}),c=resolveEffectiveAgentRuntime(o,s);initializeSessionInstrumentation({agentName:c.turnAgent.id,ctx:s,parentTraceContext:a.parentTraceContext});let l=c.limits?.sessionTimeoutMs,u,d=a.activityObserver;if(a.parent===void 0&&d===void 0&&(getChannelActivityPresentation(a.adapter)?.renderers.length??0)>0){let n=serializeContext(s),r=randomBytes(32).toString(`base64url`),i={expiresAt:new Date(Date.now()+(typeof l==`number`?l:864e5)).toISOString(),serializedContext:n,token:r};try{u=(await startWorkflowOnCurrentDeployment(activityCollectorWorkflowReference,[i])).runId,d={sink:{url:createWorkflowCallbackUrl(resolveWorkflowCallbackBaseUrl(process.env.VERCEL_URL?`https://${process.env.VERCEL_URL}`:`http://localhost:3000`),createEveActivityRoutePath(r)),version:1}},s.set(ActivityObserverKey,d)}catch{await cancelActivityCollector(u),u=void 0,log.warn(`failed to start activity collector`)}}let f=serializeContext(s),p=readParentLineage(f),m={input:a.input,limits:a.limits,serializedContext:f},h=a.taskId??a.callback?.taskId;h!==void 0&&(m.taskId=h),u!==void 0&&(m.activityCollectorRunId=u),a.continuationConflictCommand!==void 0&&(m.continuationConflictCommand=a.continuationConflictCommand),l!==void 0&&(m.sessionTimeoutMs=l);let g={...p.sessionId===void 0?buildSessionAttributes({inputMessage:a.title??a.input.message,serializedContext:f}):buildSubagentRootAttributes({identity:{nodeId:o.nodeId??ROOT_RUNTIME_AGENT_NODE_ID},parentCallId:p.callId,parentSessionId:p.sessionId,parentTurnId:p.turnId,rootSessionId:p.rootSessionId??p.sessionId,serializedContext:f}),...a.externalInvocation===void 0?{}:buildInvocationAttributes(a.externalInvocation)},_;try{_=await startWorkflowOnCurrentDeployment(workflowEntryReference,[m],{allowReservedAttributes:!0,attributes:normalizeEveAttributes(g)})}catch(e){throw await cancelActivityCollector(u),logError(log,`failed to start workflow run`,e,{continuationToken:a.continuationToken}),e}let v,getEvents=()=>(v??=parseNdjsonStream(()=>getRun(_.runId).getReadable(),normalizePersistedEvent),v);return{get events(){return getEvents()},sessionId:_.runId}},async dispatchContinuation(e){return await dispatchWorkflowCommand(e.continuationToken,e.command)},async dispatchSession(e){return await dispatchWorkflowCommand(sessionCommandHookToken(e.sessionId),e.command)},async getEventStream(e,t){return parseNdjsonStream(()=>getRun(e).getReadable({startIndex:t?.startIndex}),normalizePersistedEvent)},async getStreamTailIndex(e){let t=getRun(e).getReadable();try{return await t.getTailIndex()}finally{await t.cancel().catch(()=>{})}},async resolveContinuation(e){try{return{sessionId:(await getRawHookByToken(e)).runId}}catch(t){if(HookNotFoundError.is(t))return;throw logError(log,`failed to resolve session by continuation token`,t,{continuationToken:e}),t}}}}function normalizePersistedEvent(e){return normalizePersistedMessageStreamEvent(e)}async function cancelActivityCollector(e){if(e!==void 0)try{await cancelRun(await getWorld(),e,{cancelReason:`Root session creation did not complete`})}catch{log.warn(`failed to cancel unowned activity collector`)}}async function dispatchWorkflowCommand(e,t){let n;try{n=normalizeWorkflowHook(await resumeSessionInbox(e,t))}catch(n){if(isInactiveCommandTarget(n))return inactiveCommandResult(t);throw logError(log,`failed to dispatch session command`,n,{command:t.kind,token:e}),n}return t.kind===`reset`&&await waitForCommandHookRelease(sessionCommandHookToken(n.runId),n.runId),activeCommandResult(t,n.runId)}function activeCommandResult(e,t){return e.kind===`reset`?{previousSessionId:t,status:`reset`}:(e.kind,{sessionId:t,status:`accepted`})}function inactiveCommandResult(e){return e.kind===`send`?{status:`session_not_active`}:e.kind===`cancel`?{status:`no_active_turn`}:{status:`no_active_session`}}async function requestWorkflowTurnCancellation(e){let t={kind:`cancel`};return e.taskId!==void 0&&(t.taskId=e.taskId),e.tasks!==void 0&&(t.tasks=e.tasks),e.turnId!==void 0&&(t.turnId=e.turnId),await dispatchWorkflowCommand(sessionCommandHookToken(e.sessionId),t)}function isInactiveCommandTarget(e){if(HookNotFoundError.is(e))return!0;for(let t of walkCauseChain(e))if(WorkflowRunNotFoundError.is(t)||RunExpiredError.is(t)||EntityConflictError.is(t))return!0;return!1}async function waitForCommandHookOwner(e){let t=Date.now()+COMMAND_HOOK_READY_TIMEOUT_MS;for(;;)try{return normalizeWorkflowHook(await getRawHookByToken(e))}catch(e){if(!HookNotFoundError.is(e)||Date.now()>=t)throw e;await new Promise(e=>setTimeout(e,20))}}async function waitForCommandHookRelease(e,t){let n=Date.now()+COMMAND_HOOK_READY_TIMEOUT_MS;for(;;){try{if(normalizeWorkflowHook(await getRawHookByToken(e)).runId!==t)return}catch(e){if(HookNotFoundError.is(e))return;throw e}if(Date.now()>=n)throw Error(`Timed out waiting for session "${t}" to release its command inbox.`);await new Promise(e=>setTimeout(e,20))}}async function startWorkflowOnCurrentDeployment(e,t,n){return await startWorkflowOnDeployment(e,t,process.env.VERCEL_DEPLOYMENT_ID?.trim()||void 0,n)}async function startWorkflowOnAcceptedDeployment(e,t,n,r){return n===void 0?await startWorkflowOnCurrentDeployment(e,t,r):await startWorkflowOnDeployment(e,t,n,r)}async function startWorkflowOnDeployment(e,t,n,r){return await withWorkflowStartContext(async()=>n===void 0?r===void 0?await start(e,t):await start(e,t,r):await start(e,t,{...r,deploymentId:n}))}async function withWorkflowStartContext(e){let t=context.active(),n=isAgentTraceContext(t)?trace.deleteSpan(t):t;return await context.with(n,e)}function normalizeWorkflowHook(e){if(typeof e!=`object`||!e||!(`runId`in e))throw Error(`Workflow hook did not include a run id.`);let t=e.runId;if(typeof t!=`string`||t.length===0)throw Error(`Workflow hook did not include a run id.`);return{runId:t}}export{activityCollectorWorkflowReference,createWorkflowRuntime,requestWorkflowTurnCancellation,sessionTimeoutWorkflowReference,startWorkflowOnAcceptedDeployment,startWorkflowOnCurrentDeployment,taskRunWorkflowReference,turnWorkflowReference,waitForCommandHookOwner,workflowEntryReference,workflowToolRunWorkflowReference};
@@ -1 +1 @@
1
- import{callAdapterEventHandler,defaultDeliverResult}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,HandleEventKey,ModeKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey,TurnTaskDeliveryKey,TurnTaskStateKey}from"#context/keys.js";import{createAuthorizationCompletedEvent,createSessionStartedEvent,createTurnStartedEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{dispatchDynamicSubagentEvent,refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{coalesceTurnInputs}from"#harness/messages.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{activeTurnId}from"#harness/active-turn-id.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{preserveSerializedAgentTraceState}from"#tracing/agent-trace-context-store.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{getPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{getWorkflowTaskCallIds,isWorkflowTaskInterrupt}from"#harness/workflow-task-state.js";import{TASK_UPDATE_SESSION_INSTRUCTION}from"#tools/framework/task-update.js";import{deferMismatchedInlineTurnStep}from"#execution/accepted-delivery-deployment.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{dispatchDynamicToolEvent,rebindMissingCompiledDynamicToolCallbacks,refreshDynamicSessionToolsForRuntimeRevision}from"#context/dynamic-tool-lifecycle.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey,clearPendingAuthorization,getPendingAuthorization}from"#harness/authorization.js";import{hasPendingInputBatch}from"#harness/input-requests.js";import{setChannelContext}from"#execution/channel-context.js";import{dispatchStreamEventHooks}from"#context/hook-lifecycle.js";import{observeSessionActivity}from"#execution/session-activity-projection.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{getTurnUsageState,takeSessionUsageDelta,toUsage}from"#harness/turn-tag-state.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{readTurnSleepDurationMs}from"#harness/turn-sleep.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{dispatchDynamicInstructionEvent,drainDynamicInstructionUserMessages,prepareDynamicInstructionPreamble}from"#context/dynamic-instruction-lifecycle.js";import{dispatchDynamicSkillEvent}from"#context/dynamic-skill-lifecycle.js";import{dispatchMemoryLifecycleEvent}from"#context/memory-event-lifecycle.js";import{preserveSerializedInstrumentationState}from"#instrumentation/state.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{derivePendingState}from"#execution/pending-turn-state.js";import{forwardTaskEventToSessionCallback}from"#execution/task-event-callback.js";import{resolveEffectiveOutputSchema}from"#execution/effective-output-schema.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{resolveInitiatingTaskContext,resolveTaskDeliveryContext}from"#tasks/delivery-context.js";import{readRetainedBackgroundToolResult,runBackgroundStep}from"#execution/tasks/parent/tool-execution.js";import{prepareWorkflowPreambleTrace}from"#execution/workflow-trace-context.js";import{createExecutionHistoryView}from"#execution/history-view.js";import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";import{bindDynamicConnections}from"#execution/dynamic-connections.js";import{preserveCancelledTurnMessage}from"#execution/cancelled-turn-message.js";function channelDeliveryErrorCode(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`&&t.length>0)return t}return`CHANNEL_DELIVERY_FAILED`}async function turnStep(a){"use step";let o=deferMismatchedInlineTurnStep(a);if(o!==void 0)return o;let s=a,c=await readDurableSession(s.sessionState),l=await deserializeContext(s.serializedContext);a.input?.kind===`deliver`&&(l.set(TurnTaskDeliveryKey,`none`),l.delete(TurnTaskStateKey));let u=l.require(ChannelKey),d=l.require(BundleKey),f=resolveEffectiveAgentRuntime(d,l),p=c.taskId!==void 0&&f.turnAgent.tools.some(e=>e.kind===`authored-tool`&&e.behavior?.handling?.kind===`dispatch`&&e.behavior.handling.target.kind===`task-update`);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&l.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let m=getPendingAuthorization(c.state),h;if(m&&s.input?.kind===`deliver`){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(m,s.input.payloads);if(s={...s,input:{...s.input,payloads:t}},e.length>0){let n=e.map(e=>e.result);l.set(PendingAuthorizationResultKey,n),c={...c,state:clearPendingAuthorization(c.state,n.map(e=>e.attemptId??e.name))},h=e,t.length===0&&(s={...s,input:void 0})}}s.input?.kind===`deliver`&&s.input.auth!==void 0&&l.set(AuthKey,s.input.auth??null);let g=hydrateDurableSession({compactionOverrides:{thresholdPercent:f.thresholdPercent},durable:c,turnAgent:f.turnAgent}),_=createExecutionHistoryView(g),v=bindSessionInstrumentation({agentName:f.turnAgent.id,ctx:l,rootSessionId:g.rootSessionId??g.sessionId,sessionId:g.sessionId}),y=getHarnessEmissionState(g.state);a.input?.kind===`deliver`&&await contextStorage.run(l,()=>v?.instrumentChannelDelivery({agentName:d.turnAgent.id,ctx:l,delivery:a.input,rootSessionId:g.rootSessionId??g.sessionId,sequence:y.sequence,sessionId:g.sessionId,turnId:activeTurnId(y)}));let failChannelDeliveries=async e=>{await contextStorage.run(l,()=>v?.instrumentChannelDelivery({ctx:l,error:e,errorCode:channelDeliveryErrorCode(e),includeTurn:!1,outcome:`failed`})),await v?.flush()},b=buildAdapterContext(u,l),x;if(s.input?.kind===`deliver`){let e=[];try{for(let n of s.input.payloads){let r=u.deliver?await u.deliver(n,b):defaultDeliverResult(n);r!=null&&e.push(r)}}catch(e){throw await failChannelDeliveries(e),e}x=e.length===0?void 0:e.reduce(coalesceTurnInputs)}else s.input?.kind===`runtime-action-result`&&(s.input.acceptedAtMsByCallId!==void 0&&l.set(RuntimeActionSettlementTimesKey,s.input.acceptedAtMsByCallId),x={runtimeActionResults:s.input.results});if(x!==void 0&&a.input?.kind===`deliver`&&a.input.taskDeliveryId!==void 0){let e=resolveTaskDeliveryContext({state:c.state,taskDeliveryId:a.input.taskDeliveryId});e!==void 0&&(l.set(TurnTaskDeliveryKey,e.phase),x={...x,context:[...x.context??[],e.context]})}if(l.get(TurnTaskDeliveryKey)===`none`){let e=resolveInitiatingTaskContext({state:c.state,turnId:activeTurnId(y)});e!==void 0&&(l.set(TurnTaskDeliveryKey,e.phase),l.set(TurnTaskStateKey,e.context))}if(s.input?.kind===`deliver`&&setChannelContext(l,{...u,state:{...b.state}}),s.input?.kind===`deliver`&&x===void 0){await contextStorage.run(l,()=>v?.instrumentChannelDelivery({ctx:l,includeTurn:!1,outcome:`completed`})),await v?.flush();let e=reconcileSessionContinuationToken(l,g),t=serializeContext(l),r=e===g?s.sessionState:createDurableSessionState({session:e});return{action:`park`,...derivePendingState(e),serializedContext:t,sessionState:r}}let S=d.hookRegistry,C=bindDynamicConnections(l,d.resolvedAgent),w=d.resolvedAgent.dynamicInstructionsResolvers??[],T=d.resolvedAgent.dynamicSkillResolvers??[],E=d.subagentRegistry.dynamicResolvers??[],D=d.resolvedAgent.dynamicToolResolvers??[],O={...d.graph.root,turnAgent:f.turnAgent},k=buildRuntimeIdentity(O);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(d.compiledArtifactsSource);if(!y.sessionStarted)l.set(SessionDynamicSubagentRuntimeRevisionKey,t),l.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=createSessionStartedEvent({runtime:k});await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:l,resolvers:E,event:e,messages:_.initial.messages,runtimeRevision:t}),refreshDynamicSessionToolsForRuntimeRevision({ctx:l,resolvers:D,event:e,messages:_.initial.messages,runtimeRevision:t})]),await rebindMissingCompiledDynamicToolCallbacks({ctx:l,event:createTurnStartedEvent({sequence:y.sequence,turnId:activeTurnId(y)}),messages:_.initial.messages,resolvers:D})}}catch(e){throw await failChannelDeliveries(e),e}let A=s.parentWritable.getWriter(),emit=async t=>{let n=await callAdapterEventHandler(u,t,b);setChannelContext(l,{...u,state:{...b.state}});let r=stampMessageStreamEvent(n);return await A.write(encodeMessageStreamEvent(r)),r},handleEvent=async(e,t)=>{let n=await forwardTaskEventToSessionCallback(l,e)?stampMessageStreamEvent(e):await emit(e),r=await dispatchMemoryLifecycleEvent({abortSignal:s.abortSignal,appRoot:O.agent?.metadata?.appRoot??``,ctx:l,event:e,memories:O.agent?.memories??[],messages:t,nodeId:d.nodeId??`__root__`});observeSessionActivity({ctx:l,event:n,sessionId:g.sessionId}),await dispatchStreamEventHooks({ctx:l,registry:S,event:n}),n.type!==`step.started`&&await dispatchDynamicModelEvent({ctx:l,dynamicModel:f.turnAgent.dynamicModel,event:n,messages:r,scope:{moduleMap:d.moduleMap,nodeId:d.nodeId}}),await C.dispatch(n),await dispatchDynamicSubagentEvent({ctx:l,resolvers:E,event:n,messages:r}),await dispatchDynamicToolEvent({ctx:l,resolvers:D,event:n,messages:r}),await dispatchDynamicSkillEvent({ctx:l,resolvers:T,event:n,messages:r}),await dispatchDynamicInstructionEvent({ctx:l,resolvers:w,event:n,messages:r})},j=l.require(ModeKey),M;try{throwIfTurnAborted(s.abortSignal),M=await runBackgroundStep(l,g,async e=>{l.setVirtualContext(HandleEventKey,handleEvent);let t=resolveEffectiveOutputSchema({agentOutputSchema:f.turnAgent.outputSchema,input:x,mode:j,session:e});if(await C.rehydrate(y,k,isHarnessBetweenTurns(t)),h){let e=getHarnessEmissionState(t.state);if(isHarnessBetweenTurns(t)){prepareDynamicInstructionPreamble(l,_.messages(t));let n=[],r=await prepareWorkflowPreambleTrace({emissionState:e,instrumentation:v});try{e=await emitTurnPreamble(handleEvent,{},e,k,r)}finally{n=drainDynamicInstructionUserMessages(l),t={...t,history:[...t.history,...n]}}t=setHarnessEmissionState(t,e)}for(let{authorization:t,result:n}of h){let r=m?.challenges.find(e=>e.attemptId===n.attemptId)?.candidateId;await handleEvent(createAuthorizationCompletedEvent({attemptId:n.attemptId,authorization:t,candidateId:r,name:n.name,outcome:`authorized`,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId}))}}let n=l.get(CapabilitiesKey);return(async(e,t)=>{let r=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:f.thresholdPercent},session:e,systemPromptAdditions:p?[TASK_UPDATE_SESSION_INSTRUCTION]:void 0,turnAgent:f.turnAgent}),i=r;return createExecutionNodeStep({abortSignal:s.abortSignal,capabilities:n,clearOnly:s.input?.kind===`clear`,compactOnly:s.input?.kind===`compact`,createRuntime:createWorkflowRuntime,handleEvent,historyProjector:_.projector,historyView:_.prepare(i),instrumentation:v,mode:j,modelResolutionScope:{moduleMap:d.moduleMap,nodeId:d.nodeId},node:O,workflowMaxSubagents:r.workflowMaxSubagents})(i,t)})(t,x)})}catch(e){if(!isTurnCancellation(e))throw await failChannelDeliveries(e),e;A.releaseLock();let t=serializeContext(l),n=readRetainedBackgroundToolResult(l),r=await preserveCancelledTurnMessage(n?.backgroundTaskSession??g,x);return{action:`cancelled`,...n===void 0?{}:{backgroundTaskState:createDurableSessionState({session:r}),backgroundTasks:n.backgroundTasks},serializedContext:preserveSerializedInstrumentationState(preserveSerializedAgentTraceState(preserveSerializedSessionDynamicModelSelection(s.serializedContext,t),t),t),sessionState:createDurableSessionState({session:r})}}let N=reconcileSessionContinuationToken(l,M.session),P=serializeContext(l);M={...M,session:N};let F=createDurableSessionState({session:M.session}),I=readTurnSleepDurationMs(l),L=I===void 0?{}:{sleepDurationMs:I},R=M.backgroundTasks===void 0||M.backgroundTaskSession===void 0?{}:{backgroundTaskState:createDurableSessionState({session:M.backgroundTaskSession}),backgroundTasks:M.backgroundTasks};if(M.next!==null&&typeof M.next==`object`&&`done`in M.next){if(j===`task`&&hasPendingInputBatch(M.session.state))throw A.releaseLock(),Error(`Task mode cannot complete while input requests remain pending.`);await A.close();let e=getTurnUsageState(M.session.state)?.session;return{action:`done`,...R,output:M.next.output,isError:M.next.isError,...L,serializedContext:P,sessionState:F,usage:e===void 0?void 0:toUsage(e),usageDelta:takeSessionUsageDelta(M.session).delta}}if(M.next===null){A.releaseLock();let e=getPendingWorkflowInterrupt(M.session.state);if(e!==void 0&&isWorkflowTaskInterrupt(e.interrupt))return{action:`dispatch-workflow-tasks`,...R,pendingTaskCallIds:getWorkflowTaskCallIds(e.interrupt),...L,serializedContext:P,sessionState:F};let t=derivePendingState(M.session);if(M.settledTurn!==void 0){let{delta:e,session:n}=takeSessionUsageDelta(M.session);return{action:`park`,...R,...t,...L,serializedContext:P,sessionState:createDurableSessionState({session:n}),settled:{output:M.settledTurn.output,isError:M.settledTurn.isError,usage:e}}}return{action:`park`,...R,...t,...L,serializedContext:P,sessionState:F}}return A.releaseLock(),{action:`continue`,...R,...L,serializedContext:P,sessionState:F}}export{turnStep};
1
+ import{callAdapterEventHandler,defaultDeliverResult}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,HandleEventKey,ModeKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey,TurnTaskDeliveryKey,TurnTaskStateKey}from"#context/keys.js";import{createAuthorizationCompletedEvent,createSessionStartedEvent,createTurnStartedEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{dispatchDynamicSubagentEvent,refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{coalesceTurnInputs}from"#harness/messages.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{activeTurnId}from"#harness/active-turn-id.js";import{preserveSerializedAgentTraceState}from"#tracing/agent-trace-context-store.js";import{getPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{getWorkflowTaskCallIds,isWorkflowTaskInterrupt}from"#harness/workflow-task-state.js";import{TASK_UPDATE_SESSION_INSTRUCTION}from"#tools/framework/task-update.js";import{deferMismatchedInlineTurnStep}from"#execution/accepted-delivery-deployment.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{dispatchDynamicToolEvent,rebindMissingCompiledDynamicToolCallbacks,refreshDynamicSessionToolsForRuntimeRevision}from"#context/dynamic-tool-lifecycle.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey,clearPendingAuthorization,getPendingAuthorization}from"#harness/authorization.js";import{hasPendingInputBatch}from"#harness/input-requests.js";import{setChannelContext}from"#execution/channel-context.js";import{dispatchStreamEventHooks}from"#context/hook-lifecycle.js";import{observeSessionActivity}from"#execution/session-activity-projection.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{getTurnUsageState,takeSessionUsageDelta,toUsage}from"#harness/turn-tag-state.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{dispatchDynamicInstructionEvent,drainDynamicInstructionUserMessages,prepareDynamicInstructionPreamble}from"#context/dynamic-instruction-lifecycle.js";import{dispatchDynamicSkillEvent}from"#context/dynamic-skill-lifecycle.js";import{dispatchMemoryLifecycleEvent}from"#context/memory-event-lifecycle.js";import{preserveSerializedInstrumentationState}from"#instrumentation/state.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{derivePendingState}from"#execution/pending-turn-state.js";import{forwardTaskEventToSessionCallback}from"#execution/task-event-callback.js";import{resolveEffectiveOutputSchema}from"#execution/effective-output-schema.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{resolveInitiatingTaskContext,resolveTaskDeliveryContext}from"#tasks/delivery-context.js";import{readRetainedBackgroundToolResult,runBackgroundStep}from"#execution/tasks/parent/tool-execution.js";import{prepareWorkflowPreambleTrace}from"#execution/workflow-trace-context.js";import{createExecutionHistoryView}from"#execution/history-view.js";import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";import{bindDynamicConnections}from"#execution/dynamic-connections.js";import{preserveCancelledTurnMessage}from"#execution/cancelled-turn-message.js";function channelDeliveryErrorCode(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`&&t.length>0)return t}return`CHANNEL_DELIVERY_FAILED`}async function turnStep(a){"use step";let o=deferMismatchedInlineTurnStep(a);if(o!==void 0)return o;let s=a,c=await readDurableSession(s.sessionState),l=await deserializeContext(s.serializedContext);a.input?.kind===`deliver`&&(l.set(TurnTaskDeliveryKey,`none`),l.delete(TurnTaskStateKey));let u=l.require(ChannelKey),d=l.require(BundleKey),f=resolveEffectiveAgentRuntime(d,l),p=c.taskId!==void 0&&f.turnAgent.tools.some(e=>e.kind===`authored-tool`&&e.behavior?.handling?.kind===`dispatch`&&e.behavior.handling.target.kind===`task-update`);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&l.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let m=getPendingAuthorization(c.state),h;if(m&&s.input?.kind===`deliver`){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(m,s.input.payloads);if(s={...s,input:{...s.input,payloads:t}},e.length>0){let n=e.map(e=>e.result);l.set(PendingAuthorizationResultKey,n),c={...c,state:clearPendingAuthorization(c.state,n.map(e=>e.attemptId??e.name))},h=e,t.length===0&&(s={...s,input:void 0})}}s.input?.kind===`deliver`&&s.input.auth!==void 0&&l.set(AuthKey,s.input.auth??null);let g=hydrateDurableSession({compactionOverrides:{thresholdPercent:f.thresholdPercent},durable:c,turnAgent:f.turnAgent}),_=createExecutionHistoryView(g),v=bindSessionInstrumentation({agentName:f.turnAgent.id,ctx:l,rootSessionId:g.rootSessionId??g.sessionId,sessionId:g.sessionId}),y=getHarnessEmissionState(g.state);a.input?.kind===`deliver`&&await contextStorage.run(l,()=>v?.instrumentChannelDelivery({agentName:d.turnAgent.id,ctx:l,delivery:a.input,rootSessionId:g.rootSessionId??g.sessionId,sequence:y.sequence,sessionId:g.sessionId,turnId:activeTurnId(y)}));let failChannelDeliveries=async e=>{await contextStorage.run(l,()=>v?.instrumentChannelDelivery({ctx:l,error:e,errorCode:channelDeliveryErrorCode(e),includeTurn:!1,outcome:`failed`})),await v?.flush()},b=buildAdapterContext(u,l),x;if(s.input?.kind===`deliver`){let e=[];try{for(let n of s.input.payloads){let r=u.deliver?await u.deliver(n,b):defaultDeliverResult(n);r!=null&&e.push(r)}}catch(e){throw await failChannelDeliveries(e),e}x=e.length===0?void 0:e.reduce(coalesceTurnInputs)}else s.input?.kind===`runtime-action-result`&&(s.input.acceptedAtMsByCallId!==void 0&&l.set(RuntimeActionSettlementTimesKey,s.input.acceptedAtMsByCallId),x={runtimeActionResults:s.input.results});if(x!==void 0&&a.input?.kind===`deliver`&&a.input.taskDeliveryId!==void 0){let e=resolveTaskDeliveryContext({state:c.state,taskDeliveryId:a.input.taskDeliveryId});e!==void 0&&(l.set(TurnTaskDeliveryKey,e.phase),x={...x,context:[...x.context??[],e.context]})}if(l.get(TurnTaskDeliveryKey)===`none`){let e=resolveInitiatingTaskContext({state:c.state,turnId:activeTurnId(y)});e!==void 0&&(l.set(TurnTaskDeliveryKey,e.phase),l.set(TurnTaskStateKey,e.context))}if(s.input?.kind===`deliver`&&setChannelContext(l,{...u,state:{...b.state}}),s.input?.kind===`deliver`&&x===void 0){await contextStorage.run(l,()=>v?.instrumentChannelDelivery({ctx:l,includeTurn:!1,outcome:`completed`})),await v?.flush();let e=reconcileSessionContinuationToken(l,g),t=serializeContext(l),r=e===g?s.sessionState:createDurableSessionState({session:e});return{action:`park`,...derivePendingState(e),serializedContext:t,sessionState:r}}let S=d.hookRegistry,C=bindDynamicConnections(l,d.resolvedAgent),w=d.resolvedAgent.dynamicInstructionsResolvers??[],T=d.resolvedAgent.dynamicSkillResolvers??[],E=d.subagentRegistry.dynamicResolvers??[],D=d.resolvedAgent.dynamicToolResolvers??[],O={...d.graph.root,turnAgent:f.turnAgent},k=buildRuntimeIdentity(O);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(d.compiledArtifactsSource);if(!y.sessionStarted)l.set(SessionDynamicSubagentRuntimeRevisionKey,t),l.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=createSessionStartedEvent({runtime:k});await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:l,resolvers:E,event:e,messages:_.initial.messages,runtimeRevision:t}),refreshDynamicSessionToolsForRuntimeRevision({ctx:l,resolvers:D,event:e,messages:_.initial.messages,runtimeRevision:t})]),await rebindMissingCompiledDynamicToolCallbacks({ctx:l,event:createTurnStartedEvent({sequence:y.sequence,turnId:activeTurnId(y)}),messages:_.initial.messages,resolvers:D})}}catch(e){throw await failChannelDeliveries(e),e}let A=s.parentWritable.getWriter(),emit=async t=>{let n=await callAdapterEventHandler(u,t,b);setChannelContext(l,{...u,state:{...b.state}});let r=stampMessageStreamEvent(n);return await A.write(encodeMessageStreamEvent(r)),r},handleEvent=async(e,t)=>{let n=await forwardTaskEventToSessionCallback(l,e)?stampMessageStreamEvent(e):await emit(e),r=await dispatchMemoryLifecycleEvent({abortSignal:s.abortSignal,appRoot:O.agent?.metadata?.appRoot??``,ctx:l,event:e,memories:O.agent?.memories??[],messages:t,nodeId:d.nodeId??`__root__`});observeSessionActivity({ctx:l,event:n,sessionId:g.sessionId}),await dispatchStreamEventHooks({ctx:l,registry:S,event:n}),n.type!==`step.started`&&await dispatchDynamicModelEvent({ctx:l,dynamicModel:f.turnAgent.dynamicModel,event:n,messages:r,scope:{moduleMap:d.moduleMap,nodeId:d.nodeId}}),await C.dispatch(n),await dispatchDynamicSubagentEvent({ctx:l,resolvers:E,event:n,messages:r}),await dispatchDynamicToolEvent({ctx:l,resolvers:D,event:n,messages:r}),await dispatchDynamicSkillEvent({ctx:l,resolvers:T,event:n,messages:r}),await dispatchDynamicInstructionEvent({ctx:l,resolvers:w,event:n,messages:r})},j=l.require(ModeKey),M;try{throwIfTurnAborted(s.abortSignal),M=await runBackgroundStep(l,g,async e=>{l.setVirtualContext(HandleEventKey,handleEvent);let t=resolveEffectiveOutputSchema({agentOutputSchema:f.turnAgent.outputSchema,input:x,mode:j,session:e});if(await C.rehydrate(y,k,isHarnessBetweenTurns(t)),h){let e=getHarnessEmissionState(t.state);if(isHarnessBetweenTurns(t)){prepareDynamicInstructionPreamble(l,_.messages(t));let n=[],r=await prepareWorkflowPreambleTrace({emissionState:e,instrumentation:v});try{e=await emitTurnPreamble(handleEvent,{},e,k,r)}finally{n=drainDynamicInstructionUserMessages(l),t={...t,history:[...t.history,...n]}}t=setHarnessEmissionState(t,e)}for(let{authorization:t,result:n}of h){let r=m?.challenges.find(e=>e.attemptId===n.attemptId)?.candidateId;await handleEvent(createAuthorizationCompletedEvent({attemptId:n.attemptId,authorization:t,candidateId:r,name:n.name,outcome:`authorized`,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId}))}}let n=l.get(CapabilitiesKey);return(async(e,t)=>{let r=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:f.thresholdPercent},session:e,systemPromptAdditions:p?[TASK_UPDATE_SESSION_INSTRUCTION]:void 0,turnAgent:f.turnAgent}),i=r;return createExecutionNodeStep({abortSignal:s.abortSignal,capabilities:n,clearOnly:s.input?.kind===`clear`,compactOnly:s.input?.kind===`compact`,createRuntime:createWorkflowRuntime,handleEvent,historyProjector:_.projector,historyView:_.prepare(i),instrumentation:v,mode:j,modelResolutionScope:{moduleMap:d.moduleMap,nodeId:d.nodeId},node:O,workflowMaxSubagents:r.workflowMaxSubagents})(i,t)})(t,x)})}catch(e){if(!isTurnCancellation(e))throw await failChannelDeliveries(e),e;A.releaseLock();let t=serializeContext(l),r=readRetainedBackgroundToolResult(l),i=await contextStorage.run(l,()=>preserveCancelledTurnMessage(r?.backgroundTaskSession??g,x));return{action:`cancelled`,...r===void 0?{}:{backgroundTaskState:createDurableSessionState({session:i}),backgroundTasks:r.backgroundTasks},serializedContext:preserveSerializedInstrumentationState(preserveSerializedAgentTraceState(preserveSerializedSessionDynamicModelSelection(s.serializedContext,t),t),t),sessionState:createDurableSessionState({session:i})}}let N=reconcileSessionContinuationToken(l,M.session),P=serializeContext(l);M={...M,session:N};let F=createDurableSessionState({session:M.session}),I=M.backgroundTasks===void 0||M.backgroundTaskSession===void 0?{}:{backgroundTaskState:createDurableSessionState({session:M.backgroundTaskSession}),backgroundTasks:M.backgroundTasks};if(M.next!==null&&typeof M.next==`object`&&`done`in M.next){if(j===`task`&&hasPendingInputBatch(M.session.state))throw A.releaseLock(),Error(`Task mode cannot complete while input requests remain pending.`);await A.close();let e=getTurnUsageState(M.session.state)?.session;return{action:`done`,...I,output:M.next.output,isError:M.next.isError,serializedContext:P,sessionState:F,usage:e===void 0?void 0:toUsage(e),usageDelta:takeSessionUsageDelta(M.session).delta}}if(M.next===null){A.releaseLock();let e=getPendingWorkflowInterrupt(M.session.state);if(e!==void 0&&isWorkflowTaskInterrupt(e.interrupt))return{action:`dispatch-workflow-tasks`,...I,pendingTaskCallIds:getWorkflowTaskCallIds(e.interrupt),serializedContext:P,sessionState:F};let t=derivePendingState(M.session);if(M.settledTurn!==void 0){let{delta:e,session:n}=takeSessionUsageDelta(M.session);return{action:`park`,...I,...t,serializedContext:P,sessionState:createDurableSessionState({session:n}),settled:{output:M.settledTurn.output,isError:M.settledTurn.isError,usage:e}}}return{action:`park`,...I,...t,serializedContext:P,sessionState:F}}return A.releaseLock(),{action:`continue`,...I,serializedContext:P,sessionState:F}}export{turnStep};
@@ -1 +1 @@
1
- const HARNESS_EMISSION_STATE_KEY=`eve.harness.emission`,DEFAULT_EMISSION_STATE={sessionStarted:!1,sequence:0,stepIndex:0,turnId:``};function getHarnessEmissionState(n){return n?.[HARNESS_EMISSION_STATE_KEY]??DEFAULT_EMISSION_STATE}function isHarnessBetweenTurns(e){return getHarnessEmissionState(e.state).turnId===``}function setHarnessEmissionState(t,n){return{...t,state:{...t.state,[HARNESS_EMISSION_STATE_KEY]:n}}}export{getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState};
1
+ import{clearTurnClientContextState}from"#harness/turn-client-context.js";const HARNESS_EMISSION_STATE_KEY=`eve.harness.emission`,DEFAULT_EMISSION_STATE={sessionStarted:!1,sequence:0,stepIndex:0,turnId:``};function getHarnessEmissionState(e){return e?.[HARNESS_EMISSION_STATE_KEY]??DEFAULT_EMISSION_STATE}function isHarnessBetweenTurns(e){return getHarnessEmissionState(e.state).turnId===``}function setHarnessEmissionState(t,n){let r=n.turnId===``?clearTurnClientContextState(t):t;return{...r,state:{...r.state,[HARNESS_EMISSION_STATE_KEY]:n}}}export{getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState};
@@ -1,14 +1,14 @@
1
1
  /**
2
- * Deterministic HITL continuation prompt for session token limits.
2
+ * Deterministic HITL continuation prompt for session usage limits.
3
3
  *
4
- * When a durable session reaches its configured token budget, the harness
4
+ * When a durable session reaches its configured token or token-cost budget, the harness
5
5
  * parks on a harness-authored input request instead of failing the session.
6
6
  * The request is derived only from the session identity and violation, so
7
7
  * identical session state always produces an identical prompt — no model call
8
8
  * is involved.
9
9
  */
10
10
  import type { InputRequest, InputResponse } from "#shared/input.js";
11
- import type { SessionTokenLimitViolation } from "#harness/turn-tag-state.js";
11
+ import type { SessionUsageLimitViolation } from "#harness/turn-tag-state.js";
12
12
  /** Synthetic action tool name carried by session-limit continuation requests. */
13
13
  export declare const SESSION_LIMIT_CONTINUATION_TOOL_NAME = "session_limit_continuation";
14
14
  /** Option id that grants a fresh token budget window. */
@@ -16,12 +16,12 @@ export declare const SESSION_LIMIT_CONTINUE_OPTION_ID = "continue";
16
16
  /** Option id that declines continuation and ends the session. */
17
17
  export declare const SESSION_LIMIT_STOP_OPTION_ID = "stop";
18
18
  /**
19
- * Builds the deterministic continuation prompt for one session token limit
19
+ * Builds the deterministic continuation prompt for one session usage-limit
20
20
  * violation.
21
21
  */
22
22
  export declare function createSessionLimitContinuationRequest(input: {
23
23
  readonly sessionId: string;
24
- readonly violation: SessionTokenLimitViolation;
24
+ readonly violation: SessionUsageLimitViolation;
25
25
  }): InputRequest;
26
26
  /**
27
27
  * Returns true when a request is a harness-authored session-limit
@@ -1 +1 @@
1
- const SESSION_LIMIT_CONTINUATION_TOOL_NAME=`session_limit_continuation`,SESSION_LIMIT_CONTINUE_OPTION_ID=`continue`,SESSION_LIMIT_STOP_OPTION_ID=`stop`;function createSessionLimitContinuationRequest(r){let{sessionId:i,violation:a}=r,o=`${i}:limit:${a.kind}:${String(a.usedTokens)}`;return{action:{callId:o,input:{kind:a.kind,limit:a.limit,usedTokens:a.usedTokens},kind:`tool-call`,toolName:SESSION_LIMIT_CONTINUATION_TOOL_NAME},allowFreeform:!1,display:`confirmation`,kind:`session-limit`,options:[{description:`Grant a fresh token budget`,id:SESSION_LIMIT_CONTINUE_OPTION_ID,label:`Approve`,style:`primary`},{description:`Stop now`,id:SESSION_LIMIT_STOP_OPTION_ID,label:`Stop`,style:`danger`}],prompt:`This session has hit the ${a.kind}-token limit (${formatCompactTokenCount(a.limit)}) per session. This is a guardrail against defective long-running sessions. If session activity looks fine, just approve to keep going.`,requestId:o}}function formatCompactTokenCount(e){return e>=1e6?`${trimTrailingZero(e/1e6)}M`:e>=1e3?`${trimTrailingZero(e/1e3)}K`:String(e)}function trimTrailingZero(e){let t=e.toFixed(1);return t.endsWith(`.0`)?t.slice(0,-2):t}function isSessionLimitContinuationRequest(e){return e.kind===`session-limit`}function isSessionLimitContinuationRequestId(e){return/:limit:(?:input|output):\d+$/u.test(e)}function resolveSessionLimitContinuation(e){let t=e.requests.find(isSessionLimitContinuationRequest);if(t===void 0)return;let n=e.responses.find(e=>e.requestId===t.requestId);if(n!==void 0){if(n.optionId===`continue`)return{granted:!0};if(n.optionId===`stop`)return{granted:!1}}}export{SESSION_LIMIT_CONTINUATION_TOOL_NAME,SESSION_LIMIT_CONTINUE_OPTION_ID,SESSION_LIMIT_STOP_OPTION_ID,createSessionLimitContinuationRequest,isSessionLimitContinuationRequest,isSessionLimitContinuationRequestId,resolveSessionLimitContinuation};
1
+ const SESSION_LIMIT_CONTINUATION_TOOL_NAME=`session_limit_continuation`,SESSION_LIMIT_CONTINUE_OPTION_ID=`continue`,SESSION_LIMIT_STOP_OPTION_ID=`stop`;function createSessionLimitContinuationRequest(r){let{sessionId:i,violation:a}=r,o=a.kind===`token-cost`?a.usedCostUsd:a.usedTokens,s=`${i}:limit:${a.kind}:${String(o)}`;return{action:{callId:s,input:a.kind===`token-cost`?{kind:a.kind,limitUsd:a.limitUsd,usedCostUsd:a.usedCostUsd}:{kind:a.kind,limit:a.limit,usedTokens:a.usedTokens},kind:`tool-call`,toolName:SESSION_LIMIT_CONTINUATION_TOOL_NAME},allowFreeform:!1,display:`confirmation`,kind:`session-limit`,options:[{description:a.kind===`token-cost`?`Grant a fresh model token-cost budget`:`Grant a fresh token budget`,id:SESSION_LIMIT_CONTINUE_OPTION_ID,label:`Approve`,style:`primary`},{description:`Stop now`,id:SESSION_LIMIT_STOP_OPTION_ID,label:`Stop`,style:`danger`}],prompt:formatSessionLimitPrompt(a),requestId:s}}function formatCompactTokenCount(e){return e>=1e6?`${trimTrailingZero(e/1e6)}M`:e>=1e3?`${trimTrailingZero(e/1e3)}K`:String(e)}function trimTrailingZero(e){let t=e.toFixed(1);return t.endsWith(`.0`)?t.slice(0,-2):t}function formatSessionLimitPrompt(e){return`This session has hit the ${e.kind===`token-cost`?`${formatUsd(e.limitUsd)} model token-cost limit per session`:`${e.kind}-token limit (${formatCompactTokenCount(e.limit)}) per session`}. This is a guardrail against defective long-running sessions. If session activity looks fine, just approve to keep going.`}function formatUsd(e){return`$${(e<1e-6?String(e):e.toFixed(6)).replace(/0+$/u,``).replace(/\.$/u,``)}`}function isSessionLimitContinuationRequest(e){return e.kind===`session-limit`}function isSessionLimitContinuationRequestId(e){return/:limit:(?:input|output):\d+$/u.test(e)||/:limit:token-cost:\d+(?:\.\d+)?(?:e[+-]?\d+)?$/iu.test(e)}function resolveSessionLimitContinuation(e){let t=e.requests.find(isSessionLimitContinuationRequest);if(t===void 0)return;let n=e.responses.find(e=>e.requestId===t.requestId);if(n!==void 0){if(n.optionId===`continue`)return{granted:!0};if(n.optionId===`stop`)return{granted:!1}}}export{SESSION_LIMIT_CONTINUATION_TOOL_NAME,SESSION_LIMIT_CONTINUE_OPTION_ID,SESSION_LIMIT_STOP_OPTION_ID,createSessionLimitContinuationRequest,isSessionLimitContinuationRequest,isSessionLimitContinuationRequestId,resolveSessionLimitContinuation};