eve 0.83.3 → 0.84.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 (1537) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +1 -5
  3. package/dist/src/_virtual/_rolldown/runtime.js +1 -1
  4. package/dist/src/acp/adapter.d.ts +8 -5
  5. package/dist/src/acp/adapter.js +1 -1
  6. package/dist/src/ai/decide.d.ts +3 -7
  7. package/dist/src/ai/decide.js +1 -1
  8. package/dist/src/ai/decision-adapter.d.ts +7 -0
  9. package/dist/src/ai/decision-adapter.js +1 -0
  10. package/dist/src/ai/decision-types.d.ts +86 -0
  11. package/dist/src/approval/definition.d.ts +5 -12
  12. package/dist/src/approval/evaluation.d.ts +48 -0
  13. package/dist/src/approval/evaluation.js +1 -0
  14. package/dist/src/approval/status.d.ts +14 -0
  15. package/dist/src/approval/status.js +1 -0
  16. package/dist/src/channel/adapter-context.d.ts +1 -3
  17. package/dist/src/channel/adapter-context.js +1 -1
  18. package/dist/src/channel/adapter.d.ts +34 -26
  19. package/dist/src/channel/adapter.js +1 -1
  20. package/dist/src/channel/audience.d.ts +0 -3
  21. package/dist/src/channel/audience.js +1 -1
  22. package/dist/src/channel/auth/definitions.d.ts +532 -0
  23. package/dist/src/channel/auth/definitions.js +1 -0
  24. package/dist/src/channel/auth/jwt-ecdsa.js +1 -1
  25. package/dist/src/channel/auth/jwt-hmac.js +1 -1
  26. package/dist/src/channel/auth/oidc.js +1 -1
  27. package/dist/src/channel/channel-address.d.ts +12 -10
  28. package/dist/src/channel/channel-address.js +1 -1
  29. package/dist/src/channel/channel-operations.d.ts +21 -22
  30. package/dist/src/channel/channel-operations.js +1 -1
  31. package/dist/src/channel/compiled-channel.d.ts +4 -4
  32. package/dist/src/channel/conversation-context.js +1 -1
  33. package/dist/src/channel/cors.d.ts +2 -2
  34. package/dist/src/channel/cors.js +1 -1
  35. package/dist/src/channel/cross-channel-receive.d.ts +3 -3
  36. package/dist/src/channel/delivery-idempotency.d.ts +6 -0
  37. package/dist/src/channel/delivery-idempotency.js +1 -1
  38. package/dist/src/channel/delivery-metadata.d.ts +2 -2
  39. package/dist/src/channel/delivery.d.ts +8 -0
  40. package/dist/src/channel/delivery.js +1 -0
  41. package/dist/src/channel/interaction-prompts.d.ts +54 -0
  42. package/dist/src/channel/interaction-prompts.js +1 -0
  43. package/dist/src/channel/invoke-tool.d.ts +11 -18
  44. package/dist/src/channel/pending-authorization.d.ts +3 -14
  45. package/dist/src/channel/pending-authorization.js +1 -1
  46. package/dist/src/channel/prompt-queue.d.ts +11 -19
  47. package/dist/src/channel/prompt-queue.js +1 -1
  48. package/dist/src/channel/resolve-text.d.ts +11 -18
  49. package/dist/src/channel/resolve-text.js +2 -2
  50. package/dist/src/channel/resolved-prompt.d.ts +7 -5
  51. package/dist/src/channel/resolved-prompt.js +1 -1
  52. package/dist/src/channel/routes.d.ts +4 -4
  53. package/dist/src/channel/schedule.d.ts +2 -2
  54. package/dist/src/channel/schedule.js +1 -1
  55. package/dist/src/channel/send-input.d.ts +3 -3
  56. package/dist/src/channel/send-input.js +1 -1
  57. package/dist/src/channel/session-callback.js +1 -1
  58. package/dist/src/channel/session-not-active-error.d.ts +8 -12
  59. package/dist/src/channel/session-not-active-error.js +1 -1
  60. package/dist/src/channel/session.d.ts +33 -59
  61. package/dist/src/channel/session.js +1 -1
  62. package/dist/src/channel/sign-in.d.ts +61 -0
  63. package/dist/src/channel/sign-in.js +3 -0
  64. package/dist/src/channel/surface.d.ts +44 -0
  65. package/dist/src/channel/surface.js +1 -0
  66. package/dist/src/channel/task-card.d.ts +24 -114
  67. package/dist/src/channel/task-card.js +1 -1
  68. package/dist/src/channel/types.d.ts +116 -110
  69. package/dist/src/channel/types.js +1 -1
  70. package/dist/src/chunks/use-eve-agent-BbbguIdB.js +5030 -0
  71. package/dist/src/chunks/use-eve-agent-DWjyzplb.js +5077 -0
  72. package/dist/src/cli/commands/logs-events.d.ts +2 -0
  73. package/dist/src/cli/commands/logs-events.js +2 -2
  74. package/dist/src/cli/dev/command.js +1 -1
  75. package/dist/src/cli/dev/remote-print.d.ts +8 -0
  76. package/dist/src/cli/dev/remote-print.js +1 -0
  77. package/dist/src/cli/dev/tui/conversation-view.d.ts +24 -19
  78. package/dist/src/cli/dev/tui/conversation-view.js +1 -1
  79. package/dist/src/cli/dev/tui/diagnostic-presentation.d.ts +0 -10
  80. package/dist/src/cli/dev/tui/diagnostic-presentation.js +2 -3
  81. package/dist/src/cli/dev/tui/errors.d.ts +9 -65
  82. package/dist/src/cli/dev/tui/errors.js +1 -1
  83. package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
  84. package/dist/src/cli/dev/tui/runner.js +3 -3
  85. package/dist/src/cli/dev/tui/task-records.d.ts +3 -3
  86. package/dist/src/cli/dev/tui/task-records.js +1 -1
  87. package/dist/src/cli/dev/tui/terminal-renderer.js +10 -10
  88. package/dist/src/cli/dev/tui/terminal-tool-part.d.ts +2 -2
  89. package/dist/src/cli/dev/tui/terminal-tool-part.js +1 -1
  90. package/dist/src/cli/dev/tui/test/fake-eve-server.d.ts +3 -3
  91. package/dist/src/cli/dev/tui/test/fake-eve-server.js +1 -1
  92. package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
  93. package/dist/src/cli/dev/tui/transcript-parts.d.ts +16 -16
  94. package/dist/src/cli/dev/tui/transcript-parts.js +3 -3
  95. package/dist/src/cli/dev/tui/transcript.d.ts +0 -4
  96. package/dist/src/cli/dev/tui/transcript.js +1 -1
  97. package/dist/src/cli/dev/tui/tui.js +1 -1
  98. package/dist/src/cli/run.d.ts +0 -2
  99. package/dist/src/cli/run.js +1 -1
  100. package/dist/src/cli/telemetry/index.js +1 -1
  101. package/dist/src/client/agent-base-url.d.ts +4 -0
  102. package/dist/src/client/agent-base-url.js +1 -0
  103. package/dist/src/client/agent-info-schema.d.ts +1 -923
  104. package/dist/src/client/agent-info-schema.js +1 -1
  105. package/dist/src/client/agent-info-types.d.ts +281 -0
  106. package/dist/src/client/agent-session.d.ts +19 -22
  107. package/dist/src/client/agent-session.js +1 -1
  108. package/dist/src/client/agent-stream-follower.d.ts +11 -20
  109. package/dist/src/client/agent-stream-follower.js +1 -1
  110. package/dist/src/client/client-error.d.ts +2 -1
  111. package/dist/src/client/client-error.js +1 -1
  112. package/dist/src/client/client.d.ts +1 -1
  113. package/dist/src/client/client.js +1 -1
  114. package/dist/src/client/conversation-client.d.ts +37 -28
  115. package/dist/src/client/conversation-client.js +1 -1
  116. package/dist/src/client/conversation-state.d.ts +70 -73
  117. package/dist/src/client/conversation-state.js +1 -1
  118. package/dist/src/client/conversation.d.ts +51 -0
  119. package/dist/src/client/conversation.js +1 -0
  120. package/dist/src/client/delivery-events.d.ts +3 -0
  121. package/dist/src/client/delivery-events.js +1 -0
  122. package/dist/src/client/delivery.d.ts +36 -0
  123. package/dist/src/client/delivery.js +1 -0
  124. package/dist/src/client/file-parts.d.ts +9 -4
  125. package/dist/src/client/file-parts.js +1 -1
  126. package/dist/src/client/health-schema.d.ts +1 -1
  127. package/dist/src/client/health-types.d.ts +6 -0
  128. package/dist/src/client/index.d.ts +17 -23
  129. package/dist/src/client/index.js +1 -1
  130. package/dist/src/client/message-types.d.ts +92 -0
  131. package/dist/src/client/message-types.js +1 -0
  132. package/dist/src/client/messages.d.ts +30 -0
  133. package/dist/src/client/messages.js +1 -0
  134. package/dist/src/client/ndjson.d.ts +6 -11
  135. package/dist/src/client/ndjson.js +3 -3
  136. package/dist/src/client/open-stream.d.ts +47 -20
  137. package/dist/src/client/open-stream.js +1 -1
  138. package/dist/src/client/optimistic-message-submissions.d.ts +10 -18
  139. package/dist/src/client/optimistic-message-submissions.js +1 -1
  140. package/dist/src/client/session-controls.d.ts +23 -26
  141. package/dist/src/client/session-controls.js +1 -1
  142. package/dist/src/client/session-event-stream.d.ts +5 -16
  143. package/dist/src/client/session-event-stream.js +1 -1
  144. package/dist/src/client/session-store-helpers.d.ts +8 -0
  145. package/dist/src/client/session-store-helpers.js +2 -0
  146. package/dist/src/client/session-store-state.d.ts +80 -0
  147. package/dist/src/client/session-store-state.js +1 -0
  148. package/dist/src/client/session-store.d.ts +48 -0
  149. package/dist/src/client/session-store.js +1 -0
  150. package/dist/src/client/session-utils.d.ts +45 -41
  151. package/dist/src/client/session-utils.js +2 -1
  152. package/dist/src/client/session.d.ts +32 -23
  153. package/dist/src/client/session.js +1 -1
  154. package/dist/src/client/sessions.d.ts +2 -2
  155. package/dist/src/client/stream-version.d.ts +3 -1
  156. package/dist/src/client/stream-version.js +1 -1
  157. package/dist/src/client/transcript.d.ts +43 -0
  158. package/dist/src/client/transcript.js +2 -0
  159. package/dist/src/client/types.d.ts +21 -82
  160. package/dist/src/client/url.d.ts +3 -3
  161. package/dist/src/compiled/.vendor-stamp.json +1 -1
  162. package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +34 -34
  163. package/dist/src/compiled/@ai-sdk/google/index.d.ts +15 -15
  164. package/dist/src/compiled/@ai-sdk/openai/index.d.ts +38 -38
  165. package/dist/src/compiled/@chat-adapter/slack/fetch-QqNM_Ef3.d.ts +4 -0
  166. package/dist/src/compiled/@chat-adapter/twilio/types-BaIqtt65.d.ts +100 -0
  167. package/dist/src/compiled/@linqapp/chat-sdk-adapter/adapter.d.ts +129 -0
  168. package/dist/src/compiled/@linqapp/chat-sdk-adapter/message-parser.d.ts +14 -0
  169. package/dist/src/compiled/@linqapp/chat-sdk-adapter/text-decorations.d.ts +28 -0
  170. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +1 -1
  171. package/dist/src/compiled/@workflow/core/serialization/types.d.ts +1 -1
  172. package/dist/src/compiled/@workflow/core/serialization.d.ts +2 -2
  173. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +2 -2
  174. package/dist/src/compiled/semver/index.d.ts +2 -0
  175. package/dist/src/compiler/development-extensions.js +1 -1
  176. package/dist/src/compiler/extension-compatibility.d.ts +19 -290
  177. package/dist/src/compiler/extension-compatibility.js +1 -1
  178. package/dist/src/compiler/manifest.d.ts +1 -9
  179. package/dist/src/compiler/manifest.js +1 -1
  180. package/dist/src/compiler/normalize-agent-config.js +1 -1
  181. package/dist/src/compiler/normalize-connection.js +1 -1
  182. package/dist/src/compiler/normalize-hook.js +1 -1
  183. package/dist/src/compiler/normalize-instructions.js +1 -1
  184. package/dist/src/compiler/normalize-manifest.js +1 -1
  185. package/dist/src/compiler/normalize-memory.js +1 -1
  186. package/dist/src/compiler/normalize-schedule.js +1 -1
  187. package/dist/src/compiler/normalize-skill.js +1 -1
  188. package/dist/src/compiler/normalize-subagent.d.ts +0 -5
  189. package/dist/src/compiler/normalize-subagent.js +1 -1
  190. package/dist/src/compiler/normalize-tool.js +1 -1
  191. package/dist/src/compiler/remote-agent-node.d.ts +1 -6
  192. package/dist/src/compiler/source-graph.d.ts +0 -1
  193. package/dist/src/compiler/source-graph.js +1 -1
  194. package/dist/src/computer-use/extension/lib/computer-use-sandbox.js +1 -1
  195. package/dist/src/computer-use/extension/lib/sandbox.d.ts +1 -1
  196. package/dist/src/computer-use/extension/lib/sandbox.js +1 -1
  197. package/dist/src/computer-use/extension/tools/computer_use.js +1 -1
  198. package/dist/src/connections/errors.d.ts +3 -3
  199. package/dist/src/context/accessors.d.ts +0 -13
  200. package/dist/src/context/accessors.js +1 -1
  201. package/dist/src/context/container.d.ts +8 -11
  202. package/dist/src/context/container.js +1 -1
  203. package/dist/src/context/key-names.d.ts +1 -0
  204. package/dist/src/context/key-names.js +1 -1
  205. package/dist/src/context/keys.d.ts +20 -104
  206. package/dist/src/context/keys.js +1 -1
  207. package/dist/src/context/memory-tools.d.ts +4 -2
  208. package/dist/src/context/memory-tools.js +1 -1
  209. package/dist/src/context/providers/connection.js +1 -1
  210. package/dist/src/context/providers/session.js +1 -1
  211. package/dist/src/context/schedule-collection-tools.d.ts +2 -2
  212. package/dist/src/context/schedule-collection-tools.js +1 -1
  213. package/dist/src/context/session-context.d.ts +4 -2
  214. package/dist/src/discover/extensions.d.ts +2 -3
  215. package/dist/src/discover/extensions.js +1 -1
  216. package/dist/src/discover/manifest.js +1 -1
  217. package/dist/src/discover/skills.js +1 -1
  218. package/dist/src/dynamic/definition.d.ts +98 -108
  219. package/dist/src/dynamic/definition.js +1 -1
  220. package/dist/src/evals/assertions/collector.js +1 -1
  221. package/dist/src/evals/assertions/run.d.ts +12 -11
  222. package/dist/src/evals/assertions/run.js +2 -2
  223. package/dist/src/evals/assertions/scoped.js +1 -1
  224. package/dist/src/evals/cli/eval-client.js +1 -1
  225. package/dist/src/evals/cli/eval.js +2 -2
  226. package/dist/src/evals/context.js +1 -1
  227. package/dist/src/evals/expect/index.d.ts +0 -1
  228. package/dist/src/evals/index.d.ts +2 -5
  229. package/dist/src/evals/judge.js +1 -1
  230. package/dist/src/evals/match.d.ts +20 -17
  231. package/dist/src/evals/match.js +1 -1
  232. package/dist/src/evals/mock-model.d.ts +5 -1
  233. package/dist/src/evals/mock-model.js +1 -1
  234. package/dist/src/evals/output.d.ts +3 -0
  235. package/dist/src/evals/output.js +1 -0
  236. package/dist/src/evals/reported-tool-name.js +1 -1
  237. package/dist/src/evals/reporters/index.d.ts +4 -4
  238. package/dist/src/evals/reporters/index.js +1 -1
  239. package/dist/src/evals/runner/artifacts.js +1 -1
  240. package/dist/src/evals/runner/derive-run-facts.d.ts +8 -40
  241. package/dist/src/evals/runner/derive-run-facts.js +1 -1
  242. package/dist/src/evals/runner/execute-eval.js +1 -1
  243. package/dist/src/evals/runner/execute-task.d.ts +3 -1
  244. package/dist/src/evals/runner/execute-task.js +1 -1
  245. package/dist/src/evals/runner/reporters/braintrust.d.ts +1 -1
  246. package/dist/src/evals/runner/reporters/braintrust.js +2 -2
  247. package/dist/src/evals/runner/reporters/console.d.ts +1 -1
  248. package/dist/src/evals/runner/reporters/console.js +1 -1
  249. package/dist/src/evals/runner/reporters/datadog.d.ts +1 -1
  250. package/dist/src/evals/runner/reporters/datadog.js +2 -2
  251. package/dist/src/evals/runner/reporters/junit.d.ts +1 -1
  252. package/dist/src/evals/runner/reporters/junit.js +2 -2
  253. package/dist/src/evals/runner/reporters/types.d.ts +2 -2
  254. package/dist/src/evals/runner/run-evals.d.ts +1 -1
  255. package/dist/src/evals/session-cleanup.d.ts +1 -1
  256. package/dist/src/evals/session-cleanup.js +1 -1
  257. package/dist/src/evals/session-content.d.ts +2 -2
  258. package/dist/src/evals/session-content.js +2 -1
  259. package/dist/src/evals/session-manager.d.ts +3 -6
  260. package/dist/src/evals/session-manager.js +1 -1
  261. package/dist/src/evals/session.d.ts +33 -24
  262. package/dist/src/evals/session.js +2 -2
  263. package/dist/src/evals/target.js +1 -1
  264. package/dist/src/evals/types.d.ts +115 -94
  265. package/dist/src/eve-channel/create-request.d.ts +3 -5
  266. package/dist/src/eve-channel/descendant-stream.d.ts +9 -0
  267. package/dist/src/eve-channel/descendant-stream.js +1 -0
  268. package/dist/src/eve-channel/index.d.ts +2 -2
  269. package/dist/src/eve-channel/index.js +1 -1
  270. package/dist/src/eve-channel/request.d.ts +7 -6
  271. package/dist/src/eve-channel/request.js +1 -3
  272. package/dist/src/eve-channel/stream-headers.d.ts +1 -1
  273. package/dist/src/eve-channel/stream-headers.js +1 -1
  274. package/dist/src/eve-channel/support.d.ts +25 -13
  275. package/dist/src/eve-channel/support.js +2 -2
  276. package/dist/src/eve-channel/types.d.ts +7 -30
  277. package/dist/src/execution/agent-sessions/message.d.ts +4 -0
  278. package/dist/src/execution/agent-sessions/message.js +1 -0
  279. package/dist/src/execution/agent-sessions/metadata.js +1 -1
  280. package/dist/src/execution/agent-sessions/remote-credentials.d.ts +19 -0
  281. package/dist/src/execution/agent-sessions/remote-credentials.js +1 -0
  282. package/dist/src/execution/agent-sessions/remote.d.ts +35 -13
  283. package/dist/src/execution/agent-sessions/remote.js +1 -1
  284. package/dist/src/execution/agent-sessions/requests.d.ts +6 -6
  285. package/dist/src/execution/agent-sessions/requests.js +1 -1
  286. package/dist/src/execution/agent-sessions/session.js +1 -1
  287. package/dist/src/execution/agent-sessions/steps.d.ts +26 -4
  288. package/dist/src/execution/agent-sessions/steps.js +1 -1
  289. package/dist/src/execution/agent-sessions/target.d.ts +2 -1
  290. package/dist/src/execution/agent-sessions/target.js +1 -1
  291. package/dist/src/execution/agent-sessions/usage.d.ts +0 -8
  292. package/dist/src/execution/agent-sessions/usage.js +1 -1
  293. package/dist/src/execution/cancelled-model-call-batch.d.ts +4 -2
  294. package/dist/src/execution/cancelled-model-call-batch.js +1 -1
  295. package/dist/src/execution/cancelled-turn-message.d.ts +2 -2
  296. package/dist/src/execution/cancelled-turn-message.js +1 -1
  297. package/dist/src/execution/catalog/connection-entry.js +1 -1
  298. package/dist/src/execution/catalog/search.js +1 -1
  299. package/dist/src/execution/catalog/skills.js +1 -1
  300. package/dist/src/execution/catalog/step-catalog.js +1 -1
  301. package/dist/src/execution/child-binding.d.ts +19 -0
  302. package/dist/src/execution/child-binding.js +1 -0
  303. package/dist/src/execution/close-session-stream-step.d.ts +9 -0
  304. package/dist/src/execution/close-session-stream-step.js +1 -0
  305. package/dist/src/execution/coordination-dispatch-shared.d.ts +13 -3
  306. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  307. package/dist/src/execution/coordination-dispatch-step.d.ts +9 -13
  308. package/dist/src/execution/coordination-dispatch-step.js +1 -1
  309. package/dist/src/execution/deliver-payloads.js +1 -1
  310. package/dist/src/execution/durable-session-store.d.ts +2 -5
  311. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  312. package/dist/src/execution/dynamic-workflow/workflow.js +1 -1
  313. package/dist/src/execution/failure-summary.d.ts +11 -0
  314. package/dist/src/execution/failure-summary.js +1 -0
  315. package/dist/src/execution/forward-session-input.d.ts +2 -2
  316. package/dist/src/execution/forward-session-input.js +1 -1
  317. package/dist/src/execution/invoke-tool.js +1 -1
  318. package/dist/src/execution/legacy-session/snapshot.d.ts +4 -1
  319. package/dist/src/execution/legacy-session/snapshot.js +1 -1
  320. package/dist/src/execution/model-call-batching.d.ts +3 -3
  321. package/dist/src/execution/model-call-batching.js +1 -1
  322. package/dist/src/execution/ndjson-stream.d.ts +1 -1
  323. package/dist/src/execution/node-step.d.ts +2 -8
  324. package/dist/src/execution/node-step.js +1 -1
  325. package/dist/src/execution/proxied-deliver-step.d.ts +8 -3
  326. package/dist/src/execution/proxied-deliver-step.js +1 -1
  327. package/dist/src/execution/public-destination.d.ts +34 -0
  328. package/dist/src/execution/public-destination.js +1 -0
  329. package/dist/src/execution/publish-session-events.d.ts +98 -36
  330. package/dist/src/execution/publish-session-events.js +1 -1
  331. package/dist/src/execution/runtime-context.js +1 -1
  332. package/dist/src/execution/sandbox/abort-bound-session.js +1 -1
  333. package/dist/src/execution/sandbox/bash.js +1 -1
  334. package/dist/src/execution/sandbox/bindings/docker-connection.js +1 -1
  335. package/dist/src/execution/sandbox/bindings/docker.js +1 -1
  336. package/dist/src/execution/sandbox/bindings/eve-image.d.ts +0 -2
  337. package/dist/src/execution/sandbox/bindings/eve-image.js +1 -1
  338. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  339. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  340. package/dist/src/execution/sandbox/ensure.js +1 -1
  341. package/dist/src/{extensions/code/extension/lib → execution/sandbox}/grep-search.d.ts +3 -2
  342. package/dist/src/execution/sandbox/grep-search.js +6 -0
  343. package/dist/src/execution/sandbox/read-file.d.ts +1 -1
  344. package/dist/src/execution/sandbox/session.js +1 -1
  345. package/dist/src/execution/sandbox/workspace-root.d.ts +31 -0
  346. package/dist/src/execution/sandbox/workspace-root.js +1 -0
  347. package/dist/src/execution/session/active-turn.d.ts +12 -6
  348. package/dist/src/execution/session/active-turn.js +1 -1
  349. package/dist/src/execution/session/admission.d.ts +7 -2
  350. package/dist/src/execution/session/admission.js +1 -1
  351. package/dist/src/execution/session/answer-caller.d.ts +4 -4
  352. package/dist/src/execution/session/answer-caller.js +1 -1
  353. package/dist/src/execution/session/checkpoint-migrations.d.ts +4 -6
  354. package/dist/src/execution/session/checkpoint-migrations.js +1 -1
  355. package/dist/src/execution/session/control-delivery.d.ts +4 -0
  356. package/dist/src/execution/session/control-delivery.js +1 -0
  357. package/dist/src/execution/session/delivery-facts.d.ts +27 -0
  358. package/dist/src/execution/session/delivery-facts.js +1 -0
  359. package/dist/src/execution/session/end-sandbox-step.js +1 -1
  360. package/dist/src/execution/session/entry.js +1 -1
  361. package/dist/src/execution/session/finalization.d.ts +4 -0
  362. package/dist/src/execution/session/finalization.js +1 -1
  363. package/dist/src/execution/session/handoff-state.js +1 -1
  364. package/dist/src/execution/session/handoff-steps.d.ts +0 -8
  365. package/dist/src/execution/session/handoff-steps.js +1 -1
  366. package/dist/src/execution/session/handoff.d.ts +4 -3
  367. package/dist/src/execution/session/handoff.js +1 -1
  368. package/dist/src/execution/session/input-queue.d.ts +8 -2
  369. package/dist/src/execution/session/input-queue.js +1 -1
  370. package/dist/src/execution/session/interrupted-step.d.ts +64 -0
  371. package/dist/src/execution/session/interrupted-step.js +3 -0
  372. package/dist/src/execution/session/next-input.d.ts +7 -1
  373. package/dist/src/execution/session/next-input.js +1 -1
  374. package/dist/src/execution/session/pending-turn-state.d.ts +32 -12
  375. package/dist/src/execution/session/pending-turn-state.js +1 -1
  376. package/dist/src/execution/session/prewarm-step.d.ts +1 -1
  377. package/dist/src/execution/session/prewarm-step.js +1 -1
  378. package/dist/src/execution/session/program.js +1 -1
  379. package/dist/src/execution/session/settle-control-delivery-step.d.ts +8 -0
  380. package/dist/src/execution/session/settle-control-delivery-step.js +1 -0
  381. package/dist/src/execution/session/settle-duplicate-delivery-step.d.ts +8 -0
  382. package/dist/src/execution/session/settle-duplicate-delivery-step.js +1 -0
  383. package/dist/src/execution/session/state-delta.d.ts +2 -12
  384. package/dist/src/execution/session/state-delta.js +1 -1
  385. package/dist/src/execution/session/step-decision-check.d.ts +9 -0
  386. package/dist/src/execution/session/step-decision-check.js +1 -0
  387. package/dist/src/execution/session/step-state-delta.d.ts +16 -0
  388. package/dist/src/execution/session/step-state-delta.js +1 -0
  389. package/dist/src/execution/session/task-tool-tracing-step.d.ts +0 -3
  390. package/dist/src/execution/session/task-tool-tracing-step.js +1 -1
  391. package/dist/src/execution/session/turn-event-handler.d.ts +6 -16
  392. package/dist/src/execution/session/turn-event-handler.js +1 -1
  393. package/dist/src/execution/session/turn-step-result.d.ts +7 -2
  394. package/dist/src/execution/session/turn-step-result.js +1 -1
  395. package/dist/src/execution/session/turn-step-types.d.ts +35 -33
  396. package/dist/src/execution/session/turn-step.js +1 -1
  397. package/dist/src/execution/session/turn.d.ts +19 -32
  398. package/dist/src/execution/session/turn.js +1 -1
  399. package/dist/src/execution/session-callback-request.d.ts +7 -1
  400. package/dist/src/execution/session-callback-request.js +1 -1
  401. package/dist/src/execution/session-event-stream.d.ts +37 -16
  402. package/dist/src/execution/session-event-stream.js +1 -1
  403. package/dist/src/execution/session-inbox/end-stranded-session.d.ts +7 -1
  404. package/dist/src/execution/session-inbox/end-stranded-session.js +1 -1
  405. package/dist/src/execution/session-inbox/inbox.js +1 -1
  406. package/dist/src/execution/session-inbox/owner.d.ts +5 -2
  407. package/dist/src/execution/session-inbox/owner.js +1 -1
  408. package/dist/src/execution/session-inbox/pre-v27.d.ts +5 -0
  409. package/dist/src/execution/session-inbox/pre-v27.js +1 -0
  410. package/dist/src/execution/session-inbox/protocol.js +1 -1
  411. package/dist/src/execution/session-inbox/resume.js +1 -1
  412. package/dist/src/execution/session-inbox/stranded-replay-guard.js +1 -1
  413. package/dist/src/execution/session-workflow-tool-run.js +1 -1
  414. package/dist/src/execution/session.d.ts +3 -14
  415. package/dist/src/execution/session.js +2 -2
  416. package/dist/src/execution/settle-cancelled-turn-step.d.ts +3 -0
  417. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  418. package/dist/src/execution/stop-runs.d.ts +35 -0
  419. package/dist/src/execution/stop-runs.js +1 -0
  420. package/dist/src/execution/tasks/model-step.d.ts +5 -9
  421. package/dist/src/execution/tasks/model-step.js +1 -1
  422. package/dist/src/execution/tasks/render.d.ts +5 -2
  423. package/dist/src/execution/tasks/render.js +1 -1
  424. package/dist/src/execution/tasks/session.d.ts +6 -3
  425. package/dist/src/execution/tasks/session.js +1 -1
  426. package/dist/src/execution/tasks/start.d.ts +9 -6
  427. package/dist/src/execution/tasks/start.js +1 -1
  428. package/dist/src/execution/tasks/steps.d.ts +11 -6
  429. package/dist/src/execution/tasks/steps.js +1 -1
  430. package/dist/src/execution/tasks/table.d.ts +18 -5
  431. package/dist/src/execution/tasks/table.js +1 -1
  432. package/dist/src/execution/tasks/task-id-input.js +1 -1
  433. package/dist/src/execution/terminal-session-completion-step.d.ts +11 -1
  434. package/dist/src/execution/terminal-session-completion-step.js +1 -1
  435. package/dist/src/execution/terminal-session-failure-step.d.ts +6 -1
  436. package/dist/src/execution/terminal-session-failure-step.js +1 -1
  437. package/dist/src/execution/terminate-child-sessions-step.d.ts +5 -1
  438. package/dist/src/execution/terminate-child-sessions-step.js +1 -1
  439. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  440. package/dist/src/execution/tools/workflow/answer.d.ts +4 -5
  441. package/dist/src/execution/tools/workflow/answer.js +1 -1
  442. package/dist/src/execution/tools/workflow/apply-run-messages-step.d.ts +1 -1
  443. package/dist/src/execution/tools/workflow/apply-run-messages-step.js +1 -1
  444. package/dist/src/execution/tools/workflow/ask.d.ts +3 -3
  445. package/dist/src/execution/tools/workflow/body.js +1 -1
  446. package/dist/src/execution/tools/workflow/harness-definition.js +1 -1
  447. package/dist/src/execution/tools/workflow/messages.d.ts +25 -33
  448. package/dist/src/execution/tools/workflow/messages.js +1 -1
  449. package/dist/src/execution/tools/workflow/owner-inbox.d.ts +9 -5
  450. package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
  451. package/dist/src/execution/tools/workflow/owner.d.ts +3 -3
  452. package/dist/src/execution/tools/workflow/owner.js +1 -1
  453. package/dist/src/execution/tools/workflow/serve.js +1 -1
  454. package/dist/src/execution/tools/workflow/step.js +1 -1
  455. package/dist/src/execution/tools/workflow/withdraw-step.d.ts +2 -2
  456. package/dist/src/execution/tools/workflow/withdraw-step.js +1 -1
  457. package/dist/src/execution/v26-history.d.ts +28 -0
  458. package/dist/src/execution/v26-history.fixtures.d.ts +4 -0
  459. package/dist/src/execution/v26-history.fixtures.js +2 -0
  460. package/dist/src/execution/v26-history.js +1 -0
  461. package/dist/src/execution/web-fetch/request.js +1 -1
  462. package/dist/src/execution/workflow-errors.d.ts +5 -0
  463. package/dist/src/execution/workflow-errors.js +1 -1
  464. package/dist/src/execution/workflow-runtime.js +1 -1
  465. package/dist/src/extensions/code/extension/extension.d.ts +1 -11
  466. package/dist/src/extensions/code/extension/extension.js +1 -1
  467. package/dist/src/extensions/code/extension/lib/prwatch-github.d.ts +5 -1
  468. package/dist/src/extensions/code/extension/lib/prwatch-github.js +1 -1
  469. package/dist/src/extensions/code/extension/lib/repository-root.js +1 -1
  470. package/dist/src/extensions/code/extension/lib/sandbox.d.ts +0 -4
  471. package/dist/src/extensions/code/extension/lib/sandbox.js +2 -2
  472. package/dist/src/extensions/code/extension/lib/tooling.d.ts +1 -1
  473. package/dist/src/extensions/code/extension/lib/tooling.js +1 -1
  474. package/dist/src/extensions/code/extension/lib/workspace-root.d.ts +1 -31
  475. package/dist/src/extensions/code/extension/lib/workspace-root.js +1 -1
  476. package/dist/src/extensions/code/extension/subagents/worker/agent.d.ts +1 -1
  477. package/dist/src/extensions/code/extension/subagents/worker/agent.js +1 -1
  478. package/dist/src/extensions/code/extension/tools/apply_patch.js +2 -2
  479. package/dist/src/extensions/code/extension/tools/grep.d.ts +1 -28
  480. package/dist/src/extensions/code/extension/tools/grep.js +1 -1
  481. package/dist/src/extensions/code/sandbox.d.ts +1 -0
  482. package/dist/src/extensions/code/sandbox.js +1 -0
  483. package/dist/src/extensions/code/tools.d.ts +1 -5
  484. package/dist/src/extensions/code/tools.js +1 -1
  485. package/dist/src/extensions/git/extension/extension.d.ts +3 -3
  486. package/dist/src/extensions/git/extension/instructions/github.d.ts +1 -1
  487. package/dist/src/extensions/git/extension/instructions/github.js +1 -1
  488. package/dist/src/extensions/git/extension/lib/gh-tool.d.ts +2 -11
  489. package/dist/src/extensions/git/extension/lib/gh-tool.js +1 -1
  490. package/dist/src/extensions/git/extension/lib/github-shell.d.ts +13 -3
  491. package/dist/src/extensions/git/extension/lib/sandbox.d.ts +0 -4
  492. package/dist/src/extensions/git/extension/lib/sandbox.js +1 -1
  493. package/dist/src/extensions/git/extension/skills/pr.d.ts +1 -4
  494. package/dist/src/extensions/git/extension/skills/pr.js +1 -1
  495. package/dist/src/extensions/git/extension/tools/gh.d.ts +1 -26
  496. package/dist/src/extensions/git/extension/tools/gh.js +1 -1
  497. package/dist/src/framework/sources/modules/schedule-collection-wrapper.js +1 -1
  498. package/dist/src/harness/action-presentation.d.ts +3 -5
  499. package/dist/src/harness/action-presentation.js +1 -1
  500. package/dist/src/harness/action-result-helpers.d.ts +2 -8
  501. package/dist/src/harness/action-result-helpers.js +1 -1
  502. package/dist/src/harness/approval-outcome.d.ts +32 -0
  503. package/dist/src/harness/approval-outcome.js +1 -0
  504. package/dist/src/harness/attachment-staging.js +1 -1
  505. package/dist/src/harness/authorization.d.ts +2 -3
  506. package/dist/src/harness/authorization.js +1 -1
  507. package/dist/src/harness/call-executor.d.ts +118 -0
  508. package/dist/src/harness/call-executor.js +1 -0
  509. package/dist/src/harness/call-facts.d.ts +31 -0
  510. package/dist/src/harness/call-facts.js +1 -0
  511. package/dist/src/harness/call-outcome.d.ts +6 -0
  512. package/dist/src/harness/call-outcome.js +1 -0
  513. package/dist/src/harness/compaction/engine.d.ts +11 -0
  514. package/dist/src/harness/compaction/engine.js +2 -2
  515. package/dist/src/harness/compaction/step.d.ts +25 -5
  516. package/dist/src/harness/compaction/step.js +1 -1
  517. package/dist/src/harness/coordination.js +1 -1
  518. package/dist/src/harness/current-messages.d.ts +10 -0
  519. package/dist/src/harness/current-messages.js +1 -1
  520. package/dist/src/harness/emission.d.ts +9 -20
  521. package/dist/src/harness/emission.js +1 -1
  522. package/dist/src/harness/execute-call.d.ts +6 -23
  523. package/dist/src/harness/execute-call.js +1 -1
  524. package/dist/src/harness/execute-tool.d.ts +7 -3
  525. package/dist/src/harness/facts.d.ts +82 -0
  526. package/dist/src/harness/facts.js +1 -0
  527. package/dist/src/harness/finish-reason.d.ts +6 -1
  528. package/dist/src/harness/generation-steering.d.ts +4 -2
  529. package/dist/src/harness/generation-steering.js +1 -1
  530. package/dist/src/harness/hitl/approval-prompt.d.ts +3 -3
  531. package/dist/src/harness/hitl/approval-prompt.js +3 -3
  532. package/dist/src/harness/hitl/approvals.d.ts +66 -78
  533. package/dist/src/harness/hitl/approvals.js +2 -1
  534. package/dist/src/harness/hitl/approved-calls.d.ts +14 -36
  535. package/dist/src/harness/hitl/approved-calls.js +1 -1
  536. package/dist/src/harness/hitl/budget-request.d.ts +8 -46
  537. package/dist/src/harness/hitl/budget-request.js +1 -1
  538. package/dist/src/harness/hitl/budget.d.ts +9 -8
  539. package/dist/src/harness/hitl/budget.js +1 -1
  540. package/dist/src/harness/hitl/delivery.d.ts +16 -17
  541. package/dist/src/harness/hitl/delivery.js +1 -1
  542. package/dist/src/harness/hitl/index.d.ts +14 -19
  543. package/dist/src/harness/hitl/index.js +1 -1
  544. package/dist/src/harness/hitl/intake.d.ts +32 -43
  545. package/dist/src/harness/hitl/intake.js +1 -1
  546. package/dist/src/harness/hitl/relays.d.ts +7 -51
  547. package/dist/src/harness/hitl/relays.js +1 -1
  548. package/dist/src/harness/hitl/requests.d.ts +11 -53
  549. package/dist/src/harness/hitl/requests.js +1 -1
  550. package/dist/src/harness/hitl/responders.d.ts +50 -0
  551. package/dist/src/harness/hitl/responders.js +1 -0
  552. package/dist/src/harness/hitl/sign-ins.d.ts +7 -3
  553. package/dist/src/harness/hitl/sign-ins.js +1 -1
  554. package/dist/src/harness/hitl/stale-responses.d.ts +11 -11
  555. package/dist/src/harness/hitl/stale-responses.js +3 -3
  556. package/dist/src/harness/inline-tool-authorization.d.ts +8 -9
  557. package/dist/src/harness/inline-tool-authorization.js +1 -1
  558. package/dist/src/harness/interaction-facts.d.ts +36 -0
  559. package/dist/src/harness/interaction-facts.js +1 -0
  560. package/dist/src/harness/interaction-relay.d.ts +10 -0
  561. package/dist/src/harness/interaction-relay.js +1 -0
  562. package/dist/src/harness/interrupted-attempt.d.ts +19 -0
  563. package/dist/src/harness/interrupted-attempt.js +2 -0
  564. package/dist/src/harness/messages.d.ts +28 -15
  565. package/dist/src/harness/messages.js +1 -1
  566. package/dist/src/harness/model-call/call.d.ts +25 -11
  567. package/dist/src/harness/model-call/call.js +1 -1
  568. package/dist/src/harness/model-call/errors.js +1 -1
  569. package/dist/src/harness/model-call/failure.d.ts +4 -49
  570. package/dist/src/harness/model-call/failure.js +1 -1
  571. package/dist/src/harness/model-call/model.js +1 -1
  572. package/dist/src/harness/model-call/recovery.d.ts +4 -32
  573. package/dist/src/harness/model-call/recovery.js +1 -1
  574. package/dist/src/harness/model-call/request.d.ts +0 -1
  575. package/dist/src/harness/model-call/request.js +1 -1
  576. package/dist/src/harness/model-call/response.d.ts +22 -12
  577. package/dist/src/harness/model-call/response.js +1 -1
  578. package/dist/src/harness/model-call/retry.d.ts +23 -6
  579. package/dist/src/harness/model-call/retry.js +1 -1
  580. package/dist/src/harness/model-call/run.d.ts +4 -12
  581. package/dist/src/harness/model-call/run.js +1 -1
  582. package/dist/src/harness/model-call/tools.d.ts +0 -19
  583. package/dist/src/harness/model-call/tools.js +1 -1
  584. package/dist/src/harness/model-call/unique-call-ids.d.ts +13 -0
  585. package/dist/src/harness/model-call/unique-call-ids.js +1 -0
  586. package/dist/src/harness/model-call/usage.d.ts +7 -5
  587. package/dist/src/harness/model-call/usage.js +1 -1
  588. package/dist/src/harness/ordered-stream-emitter.d.ts +1 -0
  589. package/dist/src/harness/ordered-stream-emitter.js +1 -1
  590. package/dist/src/harness/provider-tool-history.js +1 -1
  591. package/dist/src/harness/publication.d.ts +4 -0
  592. package/dist/src/harness/publication.js +1 -0
  593. package/dist/src/harness/request-envelope.d.ts +0 -3
  594. package/dist/src/harness/request-envelope.js +1 -1
  595. package/dist/src/harness/running-work.d.ts +10 -0
  596. package/dist/src/harness/running-work.js +1 -0
  597. package/dist/src/harness/session-machine/cascade.d.ts +17 -0
  598. package/dist/src/harness/session-machine/cascade.js +1 -0
  599. package/dist/src/harness/session-machine/commit.d.ts +16 -16
  600. package/dist/src/harness/session-machine/commit.js +1 -1
  601. package/dist/src/harness/session-machine/current.d.ts +25 -17
  602. package/dist/src/harness/session-machine/current.js +1 -1
  603. package/dist/src/harness/session-machine/state.d.ts +43 -16
  604. package/dist/src/harness/session-machine/state.js +1 -1
  605. package/dist/src/harness/session-machine/suspended-steps.d.ts +22 -0
  606. package/dist/src/harness/session-machine/suspended-steps.js +1 -0
  607. package/dist/src/harness/session-machine/transitions.d.ts +144 -120
  608. package/dist/src/harness/session-machine/transitions.js +1 -1
  609. package/dist/src/harness/session-machine/view.d.ts +12 -8
  610. package/dist/src/harness/session-machine/view.js +1 -1
  611. package/dist/src/harness/session-machine/waiting.d.ts +16 -0
  612. package/dist/src/harness/session-machine/waiting.js +1 -0
  613. package/dist/src/harness/session-usage.d.ts +22 -0
  614. package/dist/src/harness/session-usage.js +1 -0
  615. package/dist/src/harness/step/after-model.d.ts +1 -4
  616. package/dist/src/harness/step/after-model.js +1 -1
  617. package/dist/src/harness/step/context.d.ts +21 -21
  618. package/dist/src/harness/step/context.js +1 -1
  619. package/dist/src/harness/step/intake.d.ts +7 -8
  620. package/dist/src/harness/step/intake.js +1 -1
  621. package/dist/src/harness/step/park.d.ts +19 -0
  622. package/dist/src/harness/step/park.js +1 -0
  623. package/dist/src/harness/step/prompt.d.ts +4 -5
  624. package/dist/src/harness/step/prompt.js +1 -1
  625. package/dist/src/harness/step-hooks.d.ts +24 -24
  626. package/dist/src/harness/step-hooks.js +1 -1
  627. package/dist/src/harness/stream-actions.d.ts +3 -9
  628. package/dist/src/harness/stream-actions.js +1 -1
  629. package/dist/src/harness/token-estimate.js +1 -1
  630. package/dist/src/harness/tool-history-repair.js +1 -1
  631. package/dist/src/harness/tool-loop.js +1 -1
  632. package/dist/src/harness/tools.d.ts +22 -38
  633. package/dist/src/harness/tools.js +1 -1
  634. package/dist/src/harness/types.d.ts +69 -67
  635. package/dist/src/harness/user-parts.d.ts +4 -0
  636. package/dist/src/harness/user-parts.js +1 -0
  637. package/dist/src/harness/workflow-tool-runs.d.ts +0 -1
  638. package/dist/src/harness/workflow-tool-runs.js +1 -1
  639. package/dist/src/instrumentation/ai-sdk-hook-bridge.d.ts +2 -2
  640. package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
  641. package/dist/src/instrumentation/channel-delivery.d.ts +4 -23
  642. package/dist/src/instrumentation/channel-delivery.js +1 -1
  643. package/dist/src/instrumentation/content.d.ts +1 -7
  644. package/dist/src/instrumentation/content.js +1 -1
  645. package/dist/src/instrumentation/dispatch.js +1 -1
  646. package/dist/src/instrumentation/lifecycle.d.ts +135 -198
  647. package/dist/src/instrumentation/lifecycle.js +1 -1
  648. package/dist/src/instrumentation/memory.d.ts +4 -2
  649. package/dist/src/instrumentation/memory.js +1 -1
  650. package/dist/src/instrumentation/native-events.d.ts +17 -10
  651. package/dist/src/instrumentation/native-events.js +1 -1
  652. package/dist/src/instrumentation/prepare-trace-context.d.ts +3 -3
  653. package/dist/src/instrumentation/provider.d.ts +20 -28
  654. package/dist/src/instrumentation/providers.js +1 -1
  655. package/dist/src/instrumentation/runtime-context.d.ts +1 -0
  656. package/dist/src/instrumentation/runtime-context.js +1 -1
  657. package/dist/src/instrumentation/runtime.d.ts +9 -30
  658. package/dist/src/instrumentation/runtime.js +1 -1
  659. package/dist/src/instrumentation/scope.d.ts +6 -0
  660. package/dist/src/instrumentation/scope.js +1 -0
  661. package/dist/src/instrumentation/session-context.d.ts +1 -1
  662. package/dist/src/instrumentation/session-context.js +1 -1
  663. package/dist/src/instrumentation/session-init.js +1 -1
  664. package/dist/src/instrumentation/setup-context.d.ts +2 -2
  665. package/dist/src/instrumentation/setup-context.js +1 -1
  666. package/dist/src/instrumentation/state.d.ts +0 -21
  667. package/dist/src/instrumentation/state.js +1 -1
  668. package/dist/src/internal/application/dev-environment.d.ts +8 -2
  669. package/dist/src/internal/application/dev-environment.js +1 -1
  670. package/dist/src/internal/application/optional-package-install.js +1 -1
  671. package/dist/src/internal/application/stamped-package-version.js +1 -1
  672. package/dist/src/internal/authored-definition/approval.d.ts +2 -4
  673. package/dist/src/internal/authored-definition/approval.js +1 -1
  674. package/dist/src/internal/authored-definition/connection.js +1 -1
  675. package/dist/src/internal/authored-definition/core.d.ts +1 -1
  676. package/dist/src/internal/authored-definition/core.js +1 -1
  677. package/dist/src/internal/authored-definition/memory.js +1 -1
  678. package/dist/src/internal/authored-definition/schema-backed.d.ts +0 -3
  679. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  680. package/dist/src/internal/authored-module-loader.d.ts +0 -1
  681. package/dist/src/internal/authored-module-loader.js +1 -1
  682. package/dist/src/internal/authored-package-boundary.js +1 -1
  683. package/dist/src/internal/git.d.ts +2 -0
  684. package/dist/src/internal/git.js +1 -0
  685. package/dist/src/internal/grep.d.ts +1 -0
  686. package/dist/src/internal/grep.js +1 -0
  687. package/dist/src/internal/helpers/markdown.js +1 -1
  688. package/dist/src/internal/invocation/agent-invocation.d.ts +16 -19
  689. package/dist/src/internal/invocation/metadata.d.ts +0 -2
  690. package/dist/src/internal/invocation/metadata.js +1 -1
  691. package/dist/src/internal/invocation/workflow-execution.d.ts +4 -4
  692. package/dist/src/internal/invocation/workflow-execution.js +1 -1
  693. package/dist/src/internal/legacy-events.d.ts +5 -0
  694. package/dist/src/internal/legacy-events.js +1 -0
  695. package/dist/src/internal/logging.d.ts +0 -12
  696. package/dist/src/internal/logging.js +1 -1
  697. package/dist/src/internal/mcp/protected-resource.js +1 -1
  698. package/dist/src/internal/mcp/published-tools.js +1 -1
  699. package/dist/src/internal/model-auth/api-key.js +1 -1
  700. package/dist/src/internal/model-auth/development-broker-client.js +1 -1
  701. package/dist/src/internal/model-auth/development-broker-server.js +1 -1
  702. package/dist/src/internal/model-auth/transport.js +1 -1
  703. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  704. package/dist/src/internal/nitro/dev-runtime-generation-metadata.js +1 -1
  705. package/dist/src/internal/nitro/host/build-extension.js +2 -2
  706. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  707. package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
  708. package/dist/src/internal/nitro/host/dev-server-state.js +1 -1
  709. package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -1
  710. package/dist/src/internal/nitro/host/start-development-server.js +1 -1
  711. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  712. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
  713. package/dist/src/internal/nitro/routes/channel-route-context.d.ts +8 -1
  714. package/dist/src/internal/nitro/routes/info.js +1 -1
  715. package/dist/src/internal/nitro/routes/schedule-task.js +1 -1
  716. package/dist/src/internal/scaffold.d.ts +5 -0
  717. package/dist/src/internal/scaffold.js +1 -0
  718. package/dist/src/internal/workflow/cancel-expired-development-run.js +1 -1
  719. package/dist/src/internal/workflow/development-world-client.js +1 -1
  720. package/dist/src/internal/workflow/development-world-server.js +1 -1
  721. package/dist/src/internal/workflow/local-world-data-directory.js +1 -1
  722. package/dist/src/internal/workspace.d.ts +1 -0
  723. package/dist/src/internal/workspace.js +1 -0
  724. package/dist/src/models/auto.d.ts +27 -14
  725. package/dist/src/models/auto.js +2 -2
  726. package/dist/src/protocol/delivery.d.ts +11 -0
  727. package/dist/src/protocol/delivery.js +1 -0
  728. package/dist/src/protocol/descendant-observation.d.ts +12 -0
  729. package/dist/src/protocol/descendant-observation.js +1 -0
  730. package/dist/src/protocol/interaction-json.d.ts +66 -0
  731. package/dist/src/protocol/interaction-json.js +1 -0
  732. package/dist/src/protocol/interaction-options.d.ts +4 -0
  733. package/dist/src/protocol/interaction-options.js +1 -0
  734. package/dist/src/protocol/remote-agent-protocol.d.ts +28 -1
  735. package/dist/src/protocol/remote-agent-protocol.js +1 -1
  736. package/dist/src/protocol/routes.d.ts +3 -2
  737. package/dist/src/protocol/routes.js +1 -1
  738. package/dist/src/protocol/session-event.d.ts +22 -0
  739. package/dist/src/protocol/session-event.js +1 -0
  740. package/dist/src/protocol/session-events/authoring.d.ts +2 -0
  741. package/dist/src/protocol/session-events/authoring.js +1 -0
  742. package/dist/src/protocol/session-events/catalog.d.ts +50 -0
  743. package/dist/src/protocol/session-events/catalog.js +1 -0
  744. package/dist/src/protocol/session-events/checker.d.ts +23 -0
  745. package/dist/src/protocol/session-events/checker.js +1 -0
  746. package/dist/src/protocol/session-events/common.d.ts +105 -0
  747. package/dist/src/protocol/session-events/common.js +1 -0
  748. package/dist/src/protocol/session-events/envelope.d.ts +174 -0
  749. package/dist/src/protocol/session-events/envelope.js +1 -0
  750. package/dist/src/protocol/session-events/facts.d.ts +24 -0
  751. package/dist/src/protocol/session-events/facts.js +1 -0
  752. package/dist/src/protocol/session-events/families/call.d.ts +142 -0
  753. package/dist/src/protocol/session-events/families/call.js +1 -0
  754. package/dist/src/protocol/session-events/families/child.d.ts +51 -0
  755. package/dist/src/protocol/session-events/families/child.js +1 -0
  756. package/dist/src/protocol/session-events/families/content.d.ts +56 -0
  757. package/dist/src/protocol/session-events/families/content.js +1 -0
  758. package/dist/src/protocol/session-events/families/context.d.ts +55 -0
  759. package/dist/src/protocol/session-events/families/context.js +1 -0
  760. package/dist/src/protocol/session-events/families/delivery.d.ts +86 -0
  761. package/dist/src/protocol/session-events/families/delivery.js +1 -0
  762. package/dist/src/protocol/session-events/families/interaction.d.ts +163 -0
  763. package/dist/src/protocol/session-events/families/interaction.js +1 -0
  764. package/dist/src/protocol/session-events/families/model.d.ts +88 -0
  765. package/dist/src/protocol/session-events/families/model.js +1 -0
  766. package/dist/src/protocol/session-events/families/response.d.ts +66 -0
  767. package/dist/src/protocol/session-events/families/response.js +1 -0
  768. package/dist/src/protocol/session-events/families/session.d.ts +73 -0
  769. package/dist/src/protocol/session-events/families/session.js +1 -0
  770. package/dist/src/protocol/session-events/families/task.d.ts +46 -0
  771. package/dist/src/protocol/session-events/families/task.js +1 -0
  772. package/dist/src/protocol/session-events/families/turn.d.ts +68 -0
  773. package/dist/src/protocol/session-events/families/turn.js +1 -0
  774. package/dist/src/protocol/session-events/families/usage.d.ts +30 -0
  775. package/dist/src/protocol/session-events/families/usage.js +1 -0
  776. package/dist/src/protocol/session-events/guards.d.ts +11 -0
  777. package/dist/src/protocol/session-events/guards.js +1 -0
  778. package/dist/src/protocol/session-events/index.d.ts +16 -0
  779. package/dist/src/protocol/session-events/index.js +1 -0
  780. package/dist/src/protocol/session-events/json.d.ts +20 -0
  781. package/dist/src/protocol/session-events/json.js +1 -0
  782. package/dist/src/protocol/session-events/schemas.d.ts +320 -0
  783. package/dist/src/protocol/session-events/schemas.js +1 -0
  784. package/dist/src/protocol/session-http.d.ts +7 -0
  785. package/dist/src/protocol/session-http.js +1 -0
  786. package/dist/src/protocol/session-lines.d.ts +19 -0
  787. package/dist/src/protocol/session-lines.js +1 -0
  788. package/dist/src/protocol/session-projection/fold.d.ts +75 -0
  789. package/dist/src/protocol/session-projection/fold.js +1 -0
  790. package/dist/src/protocol/session-projection/index.d.ts +4 -0
  791. package/dist/src/protocol/session-projection/index.js +1 -0
  792. package/dist/src/protocol/session-projection/observations.d.ts +150 -0
  793. package/dist/src/protocol/session-projection/observations.js +1 -0
  794. package/dist/src/protocol/session-projection/public-view.d.ts +74 -0
  795. package/dist/src/protocol/session-projection/public-view.js +1 -0
  796. package/dist/src/protocol/session-projection/reader.d.ts +62 -0
  797. package/dist/src/protocol/session-projection/reader.js +1 -0
  798. package/dist/src/protocol/session-projection/request-status.d.ts +7 -0
  799. package/dist/src/protocol/session-projection/request-status.js +1 -0
  800. package/dist/src/protocol/session-projection/selectors.d.ts +169 -0
  801. package/dist/src/protocol/session-projection/selectors.js +2 -0
  802. package/dist/src/protocol/session-projection/session-view.d.ts +18 -0
  803. package/dist/src/protocol/session-projection/session-view.js +1 -0
  804. package/dist/src/protocol/session-projection/tables.d.ts +237 -0
  805. package/dist/src/protocol/session-projection/tables.js +1 -0
  806. package/dist/src/protocol/session-projection/tree.d.ts +72 -0
  807. package/dist/src/protocol/session-projection/tree.js +1 -0
  808. package/dist/src/protocol/session-projection.d.ts +38 -157
  809. package/dist/src/protocol/session-projection.js +1 -1
  810. package/dist/src/protocol/task-tools.d.ts +8 -6
  811. package/dist/src/protocol/task-tools.js +1 -1
  812. package/dist/src/protocol/v26-interactions.d.ts +11 -0
  813. package/dist/src/protocol/v26-interactions.js +1 -0
  814. package/dist/src/protocol/v26-lines.d.ts +5 -0
  815. package/dist/src/protocol/v26-lines.js +1 -0
  816. package/dist/src/public/agents/auth.d.ts +2 -2
  817. package/dist/src/public/agents/auth.js +1 -1
  818. package/dist/src/public/ai/index.d.ts +1 -0
  819. package/dist/src/public/channels/auth.d.ts +2 -532
  820. package/dist/src/public/channels/auth.js +1 -1
  821. package/dist/src/public/channels/chat-sdk/authorization.d.ts +5 -2
  822. package/dist/src/public/channels/chat-sdk/authorization.js +1 -3
  823. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +10 -10
  824. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +1 -3
  825. package/dist/src/public/channels/chat-sdk/index.d.ts +1 -1
  826. package/dist/src/public/channels/chat-sdk/index.js +1 -1
  827. package/dist/src/public/channels/chat-sdk/input-actions.d.ts +4 -4
  828. package/dist/src/public/channels/chat-sdk/input-actions.js +3 -3
  829. package/dist/src/public/channels/chat-sdk/{messageToUserContent.d.ts → message-content.d.ts} +3 -3
  830. package/dist/src/public/channels/chat-sdk/message-content.js +1 -0
  831. package/dist/src/public/channels/discord/api.d.ts +8 -11
  832. package/dist/src/public/channels/discord/api.js +1 -1
  833. package/dist/src/public/channels/discord/attachments.d.ts +2 -2
  834. package/dist/src/public/channels/discord/authorization.d.ts +3 -13
  835. package/dist/src/public/channels/discord/authorization.js +2 -2
  836. package/dist/src/public/channels/discord/credentials.d.ts +11 -0
  837. package/dist/src/public/channels/discord/credentials.js +1 -0
  838. package/dist/src/public/channels/discord/defaults.d.ts +7 -1
  839. package/dist/src/public/channels/discord/defaults.js +1 -3
  840. package/dist/src/public/channels/discord/discordChannel.d.ts +36 -48
  841. package/dist/src/public/channels/discord/discordChannel.js +1 -1
  842. package/dist/src/public/channels/discord/hitl.d.ts +5 -4
  843. package/dist/src/public/channels/discord/hitl.js +1 -1
  844. package/dist/src/public/channels/discord/index.d.ts +4 -12
  845. package/dist/src/public/channels/discord/index.js +1 -1
  846. package/dist/src/public/channels/discord/messages.js +1 -1
  847. package/dist/src/public/channels/github/defaults.js +2 -4
  848. package/dist/src/public/channels/github/githubChannel.d.ts +23 -36
  849. package/dist/src/public/channels/github/githubChannel.js +1 -1
  850. package/dist/src/public/channels/github/index.d.ts +3 -2
  851. package/dist/src/public/channels/github/index.js +1 -1
  852. package/dist/src/public/channels/github/state.d.ts +2 -0
  853. package/dist/src/public/channels/imessage-tapbacks.d.ts +1 -1
  854. package/dist/src/public/channels/index.d.ts +16 -37
  855. package/dist/src/public/channels/index.js +1 -1
  856. package/dist/src/public/channels/linear/defaults.js +2 -4
  857. package/dist/src/public/channels/linear/hitl.d.ts +3 -3
  858. package/dist/src/public/channels/linear/hitl.js +2 -2
  859. package/dist/src/public/channels/linear/inbound-uploads.d.ts +3 -3
  860. package/dist/src/public/channels/linear/inbound-uploads.js +1 -1
  861. package/dist/src/public/channels/linear/inbound.d.ts +5 -3
  862. package/dist/src/public/channels/linear/inbound.js +1 -1
  863. package/dist/src/public/channels/linear/index.d.ts +4 -6
  864. package/dist/src/public/channels/linear/index.js +1 -1
  865. package/dist/src/public/channels/linear/linearChannel.d.ts +19 -30
  866. package/dist/src/public/channels/linear/linearChannel.js +1 -1
  867. package/dist/src/public/channels/linq/inboundContent.d.ts +2 -2
  868. package/dist/src/public/channels/linq/inboundContent.js +1 -1
  869. package/dist/src/public/channels/linq/index.d.ts +1 -1
  870. package/dist/src/public/channels/linq/linqChannel.d.ts +1 -2
  871. package/dist/src/public/channels/mcp.d.ts +2 -2
  872. package/dist/src/public/channels/mcp.js +1 -1
  873. package/dist/src/public/channels/photon/inboundContent.d.ts +2 -2
  874. package/dist/src/public/channels/photon/inboundContent.js +1 -1
  875. package/dist/src/public/channels/photon/index.d.ts +1 -1
  876. package/dist/src/public/channels/photon/photonIMessageChannel.d.ts +1 -2
  877. package/dist/src/public/channels/reply.d.ts +22 -0
  878. package/dist/src/public/channels/reply.js +3 -0
  879. package/dist/src/public/channels/slack/action-status.js +1 -1
  880. package/dist/src/public/channels/slack/{input-response.d.ts → answers.d.ts} +5 -5
  881. package/dist/src/public/channels/slack/answers.js +1 -0
  882. package/dist/src/public/channels/slack/api.d.ts +5 -2
  883. package/dist/src/public/channels/slack/api.js +1 -1
  884. package/dist/src/public/channels/slack/approval-cards.d.ts +15 -5
  885. package/dist/src/public/channels/slack/approval-cards.js +2 -2
  886. package/dist/src/public/channels/slack/attachments.d.ts +6 -6
  887. package/dist/src/public/channels/slack/attachments.js +1 -1
  888. package/dist/src/public/channels/slack/blocks.d.ts +1 -1
  889. package/dist/src/public/channels/slack/blocks.js +1 -1
  890. package/dist/src/public/channels/slack/cards.d.ts +576 -0
  891. package/dist/src/public/channels/slack/cards.js +1 -0
  892. package/dist/src/public/channels/slack/connections.d.ts +4 -22
  893. package/dist/src/public/channels/slack/connections.js +1 -1
  894. package/dist/src/public/channels/slack/defaults.d.ts +13 -2
  895. package/dist/src/public/channels/slack/defaults.js +5 -5
  896. package/dist/src/public/channels/slack/hitl.d.ts +20 -19
  897. package/dist/src/public/channels/slack/hitl.js +3 -3
  898. package/dist/src/public/channels/slack/index.d.ts +7 -16
  899. package/dist/src/public/channels/slack/index.js +1 -1
  900. package/dist/src/public/channels/slack/interaction-cards.js +1 -1
  901. package/dist/src/public/channels/slack/interactions.d.ts +2 -2
  902. package/dist/src/public/channels/slack/interactions.js +1 -1
  903. package/dist/src/public/channels/slack/limits.js +1 -1
  904. package/dist/src/public/channels/slack/private-approval-delivery.d.ts +3 -3
  905. package/dist/src/public/channels/slack/private-approval-delivery.js +1 -1
  906. package/dist/src/public/channels/slack/renderers.d.ts +21 -27
  907. package/dist/src/public/channels/slack/renderers.js +1 -1
  908. package/dist/src/public/channels/slack/reply-delivery.d.ts +4 -4
  909. package/dist/src/public/channels/slack/reply-delivery.js +1 -1
  910. package/dist/src/public/channels/slack/session-operations.d.ts +4 -4
  911. package/dist/src/public/channels/slack/sign-in-cancel.js +1 -1
  912. package/dist/src/public/channels/slack/slackChannel.d.ts +30 -37
  913. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  914. package/dist/src/public/channels/slack/task-card.d.ts +9 -9
  915. package/dist/src/public/channels/slack/task-card.js +1 -1
  916. package/dist/src/public/channels/teams/api.d.ts +3 -7
  917. package/dist/src/public/channels/teams/attachments.d.ts +4 -4
  918. package/dist/src/public/channels/teams/authorization.d.ts +5 -9
  919. package/dist/src/public/channels/teams/authorization.js +1 -1
  920. package/dist/src/public/channels/teams/credentials.d.ts +13 -0
  921. package/dist/src/public/channels/teams/credentials.js +1 -0
  922. package/dist/src/public/channels/teams/defaults.d.ts +2 -6
  923. package/dist/src/public/channels/teams/defaults.js +1 -3
  924. package/dist/src/public/channels/teams/hitl.d.ts +8 -7
  925. package/dist/src/public/channels/teams/hitl.js +1 -1
  926. package/dist/src/public/channels/teams/index.d.ts +6 -8
  927. package/dist/src/public/channels/teams/index.js +1 -1
  928. package/dist/src/public/channels/teams/teamsChannel.d.ts +25 -44
  929. package/dist/src/public/channels/teams/teamsChannel.js +1 -1
  930. package/dist/src/public/channels/telegram/api.d.ts +3 -4
  931. package/dist/src/public/channels/telegram/attachments.d.ts +5 -5
  932. package/dist/src/public/channels/telegram/authorization-callback.js +1 -1
  933. package/dist/src/public/channels/telegram/authorization.d.ts +4 -8
  934. package/dist/src/public/channels/telegram/authorization.js +2 -2
  935. package/dist/src/public/channels/telegram/credentials.d.ts +9 -0
  936. package/dist/src/public/channels/telegram/credentials.js +1 -0
  937. package/dist/src/public/channels/telegram/defaults.js +1 -3
  938. package/dist/src/public/channels/telegram/hitl.d.ts +22 -20
  939. package/dist/src/public/channels/telegram/hitl.js +2 -2
  940. package/dist/src/public/channels/telegram/index.d.ts +5 -7
  941. package/dist/src/public/channels/telegram/index.js +1 -1
  942. package/dist/src/public/channels/telegram/telegramChannel.d.ts +23 -36
  943. package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
  944. package/dist/src/public/channels/text.d.ts +4 -0
  945. package/dist/src/public/channels/text.js +1 -0
  946. package/dist/src/public/channels/twilio/api.d.ts +8 -8
  947. package/dist/src/public/channels/twilio/api.js +1 -1
  948. package/dist/src/public/channels/twilio/credentials.d.ts +7 -0
  949. package/dist/src/public/channels/twilio/credentials.js +1 -0
  950. package/dist/src/public/channels/twilio/defaults.d.ts +0 -1
  951. package/dist/src/public/channels/twilio/defaults.js +1 -5
  952. package/dist/src/public/channels/twilio/inbound.d.ts +2 -2
  953. package/dist/src/public/channels/twilio/index.d.ts +4 -4
  954. package/dist/src/public/channels/twilio/index.js +1 -1
  955. package/dist/src/public/channels/twilio/twilioChannel.d.ts +24 -37
  956. package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
  957. package/dist/src/public/channels/twilio/verify.d.ts +6 -4
  958. package/dist/src/public/channels/undelivered-reply.d.ts +2 -2
  959. package/dist/src/public/channels/upload-policy.d.ts +7 -7
  960. package/dist/src/public/connections/index.d.ts +3 -5
  961. package/dist/src/public/context/index.d.ts +3 -2
  962. package/dist/src/public/definitions/agent.d.ts +18 -18
  963. package/dist/src/public/definitions/agent.js +1 -1
  964. package/dist/src/public/definitions/approval.d.ts +1 -1
  965. package/dist/src/public/definitions/channel.d.ts +57 -60
  966. package/dist/src/public/definitions/channel.js +1 -1
  967. package/dist/src/public/definitions/connections/dynamic.d.ts +3 -15
  968. package/dist/src/public/definitions/connections/dynamic.js +1 -1
  969. package/dist/src/public/definitions/connections/events.d.ts +9 -9
  970. package/dist/src/public/definitions/connections/mcp.d.ts +5 -3
  971. package/dist/src/public/definitions/connections/openapi.d.ts +1 -1
  972. package/dist/src/public/definitions/extension.d.ts +2 -4
  973. package/dist/src/public/definitions/extension.js +1 -1
  974. package/dist/src/public/definitions/hook.d.ts +63 -85
  975. package/dist/src/public/definitions/hook.js +1 -1
  976. package/dist/src/public/definitions/instructions.d.ts +3 -10
  977. package/dist/src/public/definitions/instructions.js +1 -1
  978. package/dist/src/public/definitions/model.d.ts +21 -0
  979. package/dist/src/public/definitions/model.js +1 -0
  980. package/dist/src/public/definitions/removed-event-keys.d.ts +2 -0
  981. package/dist/src/public/definitions/removed-event-keys.js +1 -0
  982. package/dist/src/public/definitions/sandbox.d.ts +1 -1
  983. package/dist/src/public/definitions/schedule.d.ts +4 -4
  984. package/dist/src/public/definitions/skill.d.ts +5 -0
  985. package/dist/src/public/definitions/skill.js +1 -1
  986. package/dist/src/public/events/index.d.ts +27 -0
  987. package/dist/src/public/events/index.js +1 -0
  988. package/dist/src/public/experimental/connections/index.d.ts +1 -0
  989. package/dist/src/public/experimental/connections/index.js +1 -0
  990. package/dist/src/public/experimental/schedules/client.js +1 -1
  991. package/dist/src/public/hooks/index.d.ts +4 -3
  992. package/dist/src/public/index.d.ts +3 -2
  993. package/dist/src/public/instructions/index.d.ts +2 -2
  994. package/dist/src/public/instrumentation/index.d.ts +9 -28
  995. package/dist/src/public/instrumentation/index.js +1 -1
  996. package/dist/src/public/instrumentation/otel.d.ts +1 -1
  997. package/dist/src/public/instrumentation/otel.js +1 -1
  998. package/dist/src/public/instrumentation/provider.d.ts +1 -1
  999. package/dist/src/public/instrumentation/provider.js +1 -1
  1000. package/dist/src/public/local-dev.d.ts +3 -1
  1001. package/dist/src/public/memory/file/backend.d.ts +1 -1
  1002. package/dist/src/public/memory/file/backends/in-memory.js +1 -1
  1003. package/dist/src/public/memory/file/backends/vercel-blob.js +1 -1
  1004. package/dist/src/public/memory/file/provider.js +1 -1
  1005. package/dist/src/public/memory/index.d.ts +14 -20
  1006. package/dist/src/public/models/index.d.ts +3 -0
  1007. package/dist/src/public/models/index.js +1 -1
  1008. package/dist/src/public/models/openai/index.d.ts +0 -2
  1009. package/dist/src/public/models/openai/index.js +1 -1
  1010. package/dist/src/public/next/index.d.ts +5 -36
  1011. package/dist/src/public/next/index.js +1 -1
  1012. package/dist/src/public/nuxt/index.d.ts +1 -1
  1013. package/dist/src/public/nuxt/module.d.ts +5 -2
  1014. package/dist/src/public/sandbox/index.d.ts +1 -1
  1015. package/dist/src/public/sandbox/vercel-sandbox.d.ts +52 -12
  1016. package/dist/src/public/sandbox/vercel.d.ts +1 -1
  1017. package/dist/src/public/schedules/subscription.d.ts +5 -8
  1018. package/dist/src/public/server/index.d.ts +2 -14
  1019. package/dist/src/public/server/index.js +1 -1
  1020. package/dist/src/public/sessions/index.d.ts +6 -0
  1021. package/dist/src/public/sessions/index.js +1 -0
  1022. package/dist/src/public/skills/index.d.ts +2 -2
  1023. package/dist/src/public/skills/index.js +1 -1
  1024. package/dist/src/public/sveltekit/routing.d.ts +0 -4
  1025. package/dist/src/public/sveltekit/routing.js +1 -1
  1026. package/dist/src/public/tools/approval/index.d.ts +1 -1
  1027. package/dist/src/public/tools/bash.d.ts +1 -1
  1028. package/dist/src/public/tools/bash.js +1 -1
  1029. package/dist/src/public/tools/glob.d.ts +1 -1
  1030. package/dist/src/public/tools/glob.js +1 -1
  1031. package/dist/src/public/tools/grep.d.ts +1 -1
  1032. package/dist/src/public/tools/grep.js +1 -1
  1033. package/dist/src/public/tools/index.d.ts +5 -9
  1034. package/dist/src/public/tools/index.js +1 -1
  1035. package/dist/src/public/tools/read-file.d.ts +1 -1
  1036. package/dist/src/public/tools/read-file.js +1 -1
  1037. package/dist/src/public/tools/result.d.ts +17 -9
  1038. package/dist/src/public/tools/result.js +1 -1
  1039. package/dist/src/public/tools/web-fetch.d.ts +1 -1
  1040. package/dist/src/public/tools/web-fetch.js +1 -1
  1041. package/dist/src/public/tools/web-search.d.ts +1 -3
  1042. package/dist/src/public/tools/web-search.js +1 -1
  1043. package/dist/src/public/tools/write-file.d.ts +1 -1
  1044. package/dist/src/public/tools/write-file.js +1 -1
  1045. package/dist/src/public/workflow-modules.d.ts +8 -2
  1046. package/dist/src/react/index.d.ts +4 -7
  1047. package/dist/src/react/index.js +1 -1
  1048. package/dist/src/react/use-eve-agent.d.ts +68 -50
  1049. package/dist/src/react/use-eve-agent.js +1 -1
  1050. package/dist/src/reactions/bundle.d.ts +4 -0
  1051. package/dist/src/reactions/bundle.js +1 -0
  1052. package/dist/src/reactions/frame.d.ts +13 -0
  1053. package/dist/src/reactions/frame.js +1 -0
  1054. package/dist/src/reactions/intents.d.ts +22 -0
  1055. package/dist/src/reactions/intents.js +1 -0
  1056. package/dist/src/reactions/kinds/connection.d.ts +18 -0
  1057. package/dist/src/reactions/kinds/connection.js +1 -0
  1058. package/dist/src/reactions/kinds/hook.d.ts +8 -0
  1059. package/dist/src/reactions/kinds/hook.js +1 -0
  1060. package/dist/src/reactions/kinds/instructions.d.ts +21 -0
  1061. package/dist/src/reactions/kinds/instructions.js +1 -0
  1062. package/dist/src/reactions/kinds/memory.d.ts +72 -0
  1063. package/dist/src/reactions/kinds/memory.js +1 -0
  1064. package/dist/src/reactions/kinds/model.d.ts +21 -0
  1065. package/dist/src/reactions/kinds/model.js +1 -0
  1066. package/dist/src/reactions/kinds/skill.d.ts +27 -0
  1067. package/dist/src/reactions/kinds/skill.js +1 -0
  1068. package/dist/src/reactions/kinds/subagent.d.ts +16 -0
  1069. package/dist/src/reactions/kinds/subagent.js +1 -0
  1070. package/dist/src/reactions/kinds/tool.d.ts +16 -0
  1071. package/dist/src/reactions/kinds/tool.js +1 -0
  1072. package/dist/src/reactions/policy.d.ts +13 -0
  1073. package/dist/src/reactions/policy.js +1 -0
  1074. package/dist/src/reactions/reaction.d.ts +83 -0
  1075. package/dist/src/reactions/reaction.js +1 -0
  1076. package/dist/src/reactions/records.d.ts +40 -0
  1077. package/dist/src/reactions/records.js +1 -0
  1078. package/dist/src/reactions/remote.d.ts +25 -0
  1079. package/dist/src/reactions/remote.js +1 -0
  1080. package/dist/src/reactions/runner.d.ts +45 -0
  1081. package/dist/src/reactions/runner.js +1 -0
  1082. package/dist/src/reactions/state.d.ts +102 -0
  1083. package/dist/src/reactions/state.js +1 -0
  1084. package/dist/src/reactions/turn.d.ts +12 -0
  1085. package/dist/src/reactions/turn.js +2 -0
  1086. package/dist/src/runtime/agent/bootstrap.d.ts +1 -3
  1087. package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
  1088. package/dist/src/runtime/agent/resolve-model.js +1 -1
  1089. package/dist/src/runtime/connections/principal.d.ts +2 -0
  1090. package/dist/src/runtime/connections/principal.js +1 -1
  1091. package/dist/src/runtime/connections/registry.d.ts +2 -2
  1092. package/dist/src/runtime/connections/registry.js +1 -1
  1093. package/dist/src/runtime/connections/scoped-authorization.d.ts +8 -1
  1094. package/dist/src/runtime/connections/scoped-authorization.js +1 -1
  1095. package/dist/src/runtime/graph.d.ts +0 -6
  1096. package/dist/src/runtime/local-dev-capability.d.ts +2 -3
  1097. package/dist/src/runtime/local-dev-capability.js +1 -1
  1098. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  1099. package/dist/src/runtime/resolve-agent.js +1 -1
  1100. package/dist/src/runtime/resolve-connection.js +1 -1
  1101. package/dist/src/runtime/resolve-dynamic.d.ts +9 -0
  1102. package/dist/src/runtime/resolve-dynamic.js +1 -0
  1103. package/dist/src/runtime/resolve-hook.js +1 -1
  1104. package/dist/src/runtime/resolve-memory.js +1 -1
  1105. package/dist/src/runtime/resolve-tool.js +1 -1
  1106. package/dist/src/runtime/schedules/collection-client.js +1 -1
  1107. package/dist/src/runtime/schedules/dispatch-occurrence.js +1 -1
  1108. package/dist/src/runtime/sessions/compiled-agent-cache.d.ts +0 -2
  1109. package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
  1110. package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -1
  1111. package/dist/src/runtime/subagents/dynamic-remote-agent-config.d.ts +16 -3
  1112. package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -1
  1113. package/dist/src/runtime/subagents/workflow.js +1 -1
  1114. package/dist/src/runtime/types.d.ts +22 -39
  1115. package/dist/src/sandbox/provider.d.ts +3 -3
  1116. package/dist/src/sandbox/providers/default.d.ts +4 -2
  1117. package/dist/src/sandbox/providers/default.js +1 -1
  1118. package/dist/src/self-modification/agent.d.ts +3 -3
  1119. package/dist/src/self-modification/agent.js +1 -1
  1120. package/dist/src/self-modification/config.d.ts +1 -1
  1121. package/dist/src/self-modification/config.js +1 -1
  1122. package/dist/src/self-modification/deployed-sandbox.js +1 -1
  1123. package/dist/src/self-modification/extension/extension.d.ts +1 -0
  1124. package/dist/src/self-modification/extension/local-only.d.ts +1 -1
  1125. package/dist/src/self-modification/extension/local-only.js +1 -1
  1126. package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +15 -4
  1127. package/dist/src/self-modification/extension/subagents/agent/agent.js +1 -1
  1128. package/dist/src/self-modification/extension/subagents/agent/instructions.d.ts +1 -1
  1129. package/dist/src/self-modification/extension/subagents/agent/instructions.js +2 -2
  1130. package/dist/src/self-modification/extension/subagents/agent/sandbox.d.ts +2 -2
  1131. package/dist/src/self-modification/extension/subagents/agent/sandbox.js +1 -1
  1132. package/dist/src/self-modification/extension/subagents/agent/skills/trace_analysis.d.ts +3 -3
  1133. package/dist/src/self-modification/extension/subagents/agent/skills/trace_analysis.js +1 -1
  1134. package/dist/src/self-modification/extension/subagents/agent/tools/inspect_trace.d.ts +1 -1
  1135. package/dist/src/self-modification/extension/subagents/agent/tools/inspect_trace_spans.d.ts +1 -1
  1136. package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.d.ts +1 -1
  1137. package/dist/src/self-modification/extension/subagents/agent/tools/search_traces.d.ts +1 -1
  1138. package/dist/src/self-modification/mode.d.ts +8 -0
  1139. package/dist/src/self-modification/mode.js +1 -1
  1140. package/dist/src/self-modification/remote/config.d.ts +3 -6
  1141. package/dist/src/self-modification/remote/extension.d.ts +1 -0
  1142. package/dist/src/self-modification/remote/production-registry-add.js +1 -1
  1143. package/dist/src/self-modification/remote/subagents/agent/agent.d.ts +6 -3
  1144. package/dist/src/self-modification/remote/subagents/agent/agent.js +1 -1
  1145. package/dist/src/self-modification/remote/subagents/agent/instructions.d.ts +1 -1
  1146. package/dist/src/self-modification/remote/subagents/agent/instructions.js +2 -2
  1147. package/dist/src/self-modification/remote/subagents/agent/tools/publish.d.ts +1 -3
  1148. package/dist/src/self-modification/remote/subagents/agent/tools/publish.js +1 -1
  1149. package/dist/src/self-modification/remote/subagents/agent/tools/registry_add.d.ts +1 -3
  1150. package/dist/src/self-modification/remote/subagents/agent/tools/registry_add.js +1 -1
  1151. package/dist/src/self-modification/scaffold.js +1 -1
  1152. package/dist/src/self-modification/setup.js +3 -6
  1153. package/dist/src/services/dev-client/client-options.js +1 -1
  1154. package/dist/src/services/dev-client.d.ts +4 -4
  1155. package/dist/src/services/dev-client.js +1 -1
  1156. package/dist/src/setup/integrations/self-modification/setup.d.ts +1 -4
  1157. package/dist/src/setup/integrations/self-modification/setup.js +1 -1
  1158. package/dist/src/setup/scaffold/create/project.js +1 -1
  1159. package/dist/src/setup/scaffold/create/web-template.d.ts +9 -18
  1160. package/dist/src/setup/scaffold/create/web-template.js +1015 -2537
  1161. package/dist/src/setup/verified-remote-agent.js +1 -1
  1162. package/dist/src/shared/action-label.d.ts +5 -3
  1163. package/dist/src/shared/action-label.js +1 -1
  1164. package/dist/src/shared/action-types.d.ts +5 -0
  1165. package/dist/src/shared/action-types.js +1 -1
  1166. package/dist/src/shared/agent-definition.d.ts +14 -9
  1167. package/dist/src/shared/answers-delivery-id.d.ts +1 -0
  1168. package/dist/src/shared/answers-delivery-id.js +1 -0
  1169. package/dist/src/shared/channel-context.d.ts +12 -0
  1170. package/dist/src/shared/channel-context.js +1 -0
  1171. package/dist/src/shared/channel-definition.d.ts +19 -26
  1172. package/dist/src/shared/channel-delivery.d.ts +16 -0
  1173. package/dist/src/shared/channel-delivery.js +1 -0
  1174. package/dist/src/shared/connection-events.d.ts +2 -2
  1175. package/dist/src/shared/connection-types.d.ts +7 -32
  1176. package/dist/src/shared/conversation-context.d.ts +4 -13
  1177. package/dist/src/shared/delivery.d.ts +38 -0
  1178. package/dist/src/shared/delivery.js +1 -0
  1179. package/dist/src/shared/history-message.d.ts +190 -0
  1180. package/dist/src/shared/history-message.js +1 -0
  1181. package/dist/src/shared/input.d.ts +23 -97
  1182. package/dist/src/shared/input.js +1 -1
  1183. package/dist/src/shared/instructions-definition.d.ts +2 -8
  1184. package/dist/src/shared/instrumentation-channel-kind.d.ts +1 -1
  1185. package/dist/src/shared/instrumentation-channel.d.ts +12 -0
  1186. package/dist/src/shared/instrumentation-channel.js +1 -0
  1187. package/dist/src/shared/json.d.ts +2 -18
  1188. package/dist/src/shared/memory-state.d.ts +4 -40
  1189. package/dist/src/shared/memory-state.js +1 -1
  1190. package/dist/src/shared/message-content.d.ts +19 -0
  1191. package/dist/src/shared/message-content.js +1 -0
  1192. package/dist/src/shared/network-address.d.ts +9 -0
  1193. package/dist/src/shared/network-address.js +1 -1
  1194. package/dist/src/shared/sandbox-environment.d.ts +2 -2
  1195. package/dist/src/shared/sandbox-provider.d.ts +1 -1
  1196. package/dist/src/shared/sandbox-session.d.ts +60 -85
  1197. package/dist/src/shared/schedule-definition.d.ts +5 -5
  1198. package/dist/src/shared/serialized-observability-state.d.ts +0 -2
  1199. package/dist/src/shared/serialized-observability-state.js +1 -1
  1200. package/dist/src/shared/session-history.d.ts +2 -2
  1201. package/dist/src/shared/session.d.ts +22 -0
  1202. package/dist/src/shared/session.js +1 -0
  1203. package/dist/src/shared/skill-definition.d.ts +1 -1
  1204. package/dist/src/shared/skill-package.d.ts +2 -2
  1205. package/dist/src/shared/skill-package.js +1 -1
  1206. package/dist/src/shared/token-usage-math.d.ts +5 -0
  1207. package/dist/src/shared/token-usage-math.js +1 -0
  1208. package/dist/src/shared/token-usage.d.ts +0 -2
  1209. package/dist/src/shared/token-usage.js +1 -1
  1210. package/dist/src/shared/validate-authorization.js +1 -1
  1211. package/dist/src/shared/wait-with-signal.d.ts +2 -0
  1212. package/dist/src/shared/wait-with-signal.js +1 -0
  1213. package/dist/src/subagents/adapter.d.ts +3 -5
  1214. package/dist/src/subagents/adapter.js +1 -1
  1215. package/dist/src/subagents/callback-route.js +1 -1
  1216. package/dist/src/subagents/event-proxy-step.d.ts +6 -9
  1217. package/dist/src/subagents/event-proxy-step.js +1 -1
  1218. package/dist/src/subagents/hitl-proxy.d.ts +11 -23
  1219. package/dist/src/subagents/hitl-proxy.js +1 -1
  1220. package/dist/src/subagents/invocation.d.ts +8 -8
  1221. package/dist/src/subagents/invocation.js +2 -2
  1222. package/dist/src/subagents/parent-notification.d.ts +5 -0
  1223. package/dist/src/subagents/parent-notification.js +1 -1
  1224. package/dist/src/subagents/protocol-two-callback.d.ts +27 -0
  1225. package/dist/src/subagents/protocol-two-callback.js +1 -0
  1226. package/dist/src/svelte/index.d.ts +3 -6
  1227. package/dist/src/svelte/index.js +2 -39
  1228. package/dist/src/svelte/use-eve-agent.d.ts +67 -56
  1229. package/dist/src/svelte/use-eve-agent.js +1 -1
  1230. package/dist/src/tool-stubs/rules.js +1 -1
  1231. package/dist/src/tools/approval/policies.d.ts +4 -16
  1232. package/dist/src/tools/approval/policies.js +1 -1
  1233. package/dist/src/tools/auth.d.ts +3 -3
  1234. package/dist/src/tools/definition.d.ts +13 -35
  1235. package/dist/src/tools/definition.js +1 -1
  1236. package/dist/src/tools/dynamic.d.ts +13 -72
  1237. package/dist/src/tools/dynamic.js +1 -1
  1238. package/dist/src/tools/framework/agent.js +1 -1
  1239. package/dist/src/tools/provided/ask-question-workflow.d.ts +3 -3
  1240. package/dist/src/tools/provided/ask-question-workflow.js +1 -1
  1241. package/dist/src/tools/provided/ask-question.d.ts +2 -2
  1242. package/dist/src/tools/provided/ask-question.js +1 -1
  1243. package/dist/src/tools/provided/grep.d.ts +2 -15
  1244. package/dist/src/tools/provided/grep.js +1 -2
  1245. package/dist/src/tools/provided/no-reply.d.ts +2 -2
  1246. package/dist/src/tools/provided/no-reply.js +1 -1
  1247. package/dist/src/tools/provided/sleep-workflow.js +1 -1
  1248. package/dist/src/tools/provided/sleep.d.ts +2 -2
  1249. package/dist/src/tools/provided/sleep.js +1 -1
  1250. package/dist/src/tools/provided/workflow.js +1 -1
  1251. package/dist/src/tools/workflow-definition.d.ts +17 -15
  1252. package/dist/src/tracing/eve/agent-approval-instrumentation.d.ts +1 -1
  1253. package/dist/src/tracing/eve/agent-approval-instrumentation.js +1 -1
  1254. package/dist/src/tracing/eve/agent-channel-delivery-instrumentation.d.ts +2 -2
  1255. package/dist/src/tracing/eve/agent-channel-delivery-instrumentation.js +1 -1
  1256. package/dist/src/tracing/eve/agent-invocation-coordinator.d.ts +2 -2
  1257. package/dist/src/tracing/eve/agent-otel-provider.js +1 -1
  1258. package/dist/src/tracing/eve/agent-tool-instrumentation.d.ts +6 -7
  1259. package/dist/src/tracing/eve/agent-tool-instrumentation.js +1 -1
  1260. package/dist/src/tracing/eve/agent-trace-context-store.d.ts +3 -3
  1261. package/dist/src/tracing/eve/agent-trace-state.d.ts +1 -6
  1262. package/dist/src/tracing/eve/delegation.d.ts +4 -4
  1263. package/dist/src/tracing/eve/install-instrumentation-runtime.js +1 -1
  1264. package/dist/src/tracing/eve/invoke-tool-span.d.ts +3 -2
  1265. package/dist/src/tracing/eve/invoke-tool-span.js +1 -1
  1266. package/dist/src/tracing/eve/otel-declaration.d.ts +9 -10
  1267. package/dist/src/tracing/eve/otel-declaration.js +1 -1
  1268. package/dist/src/tracing/eve/policy.d.ts +2 -2
  1269. package/dist/src/tracing/eve/policy.js +1 -1
  1270. package/dist/src/tracing/eve/session.d.ts +4 -3
  1271. package/dist/src/tracing/eve/session.js +1 -1
  1272. package/dist/src/vue/index.d.ts +3 -6
  1273. package/dist/src/vue/index.js +2 -39
  1274. package/dist/src/vue/use-eve-agent.d.ts +70 -59
  1275. package/dist/src/vue/use-eve-agent.js +1 -1
  1276. package/docs/agent-config.md +40 -44
  1277. package/docs/channels/chat-sdk.mdx +19 -13
  1278. package/docs/channels/custom.mdx +106 -85
  1279. package/docs/channels/discord.mdx +12 -12
  1280. package/docs/channels/eve.mdx +48 -15
  1281. package/docs/channels/github.mdx +2 -2
  1282. package/docs/channels/linear.mdx +8 -8
  1283. package/docs/channels/linq.mdx +1 -1
  1284. package/docs/channels/mcp.mdx +2 -2
  1285. package/docs/channels/overview.mdx +11 -1
  1286. package/docs/channels/photon.mdx +1 -1
  1287. package/docs/channels/slack.mdx +64 -57
  1288. package/docs/channels/teams.mdx +4 -4
  1289. package/docs/channels/telegram.mdx +1 -1
  1290. package/docs/channels/twilio.mdx +2 -2
  1291. package/docs/code-extension.mdx +19 -7
  1292. package/docs/concepts/built-in-tools.md +21 -9
  1293. package/docs/concepts/context-control.md +5 -8
  1294. package/docs/concepts/default-harness.md +7 -8
  1295. package/docs/concepts/execution-model-and-durability.mdx +119 -12
  1296. package/docs/concepts/meta.json +1 -0
  1297. package/docs/concepts/sessions-runs-and-streaming.md +244 -138
  1298. package/docs/concepts/state.md +1 -1
  1299. package/docs/concepts/upgrade-to-v27-events.md +128 -0
  1300. package/docs/connections/mcp.mdx +38 -34
  1301. package/docs/connections/openapi.mdx +23 -2
  1302. package/docs/connections/overview.mdx +66 -57
  1303. package/docs/evals/assertions.mdx +30 -24
  1304. package/docs/evals/cases.mdx +19 -24
  1305. package/docs/evals/judge.mdx +2 -2
  1306. package/docs/evals/overview.mdx +7 -7
  1307. package/docs/evals/reporters.mdx +15 -11
  1308. package/docs/evals/targets.mdx +5 -3
  1309. package/docs/evals/tool-stubs.mdx +2 -2
  1310. package/docs/extensions.md +6 -3
  1311. package/docs/guides/client/continuations.mdx +10 -10
  1312. package/docs/guides/client/messages.mdx +50 -48
  1313. package/docs/guides/client/output-schema.mdx +13 -13
  1314. package/docs/guides/client/overview.mdx +12 -12
  1315. package/docs/guides/client/streaming.mdx +160 -123
  1316. package/docs/guides/decide.md +15 -9
  1317. package/docs/guides/deployment/self-hosting.md +5 -40
  1318. package/docs/guides/dynamic-capabilities.md +151 -406
  1319. package/docs/guides/frontend/nextjs.mdx +1 -1
  1320. package/docs/guides/frontend/nuxt.mdx +2 -2
  1321. package/docs/guides/frontend/overview.mdx +257 -181
  1322. package/docs/guides/frontend/sveltekit.mdx +4 -4
  1323. package/docs/guides/frontend/tanstack.mdx +5 -5
  1324. package/docs/guides/frontend/use-eve-agent-svelte.mdx +30 -38
  1325. package/docs/guides/frontend/use-eve-agent-vue.mdx +35 -36
  1326. package/docs/guides/hooks.md +67 -55
  1327. package/docs/guides/instrumentation/instrumentation.mdx +33 -27
  1328. package/docs/guides/instrumentation/otel.mdx +4 -2
  1329. package/docs/guides/remote-agents.md +116 -50
  1330. package/docs/guides/self-modification.md +11 -7
  1331. package/docs/instructions.mdx +4 -6
  1332. package/docs/memory/custom-provider.md +63 -56
  1333. package/docs/memory/file.md +1 -1
  1334. package/docs/memory/overview.mdx +10 -18
  1335. package/docs/patterns/durable-cross-channel-notifications.md +4 -3
  1336. package/docs/patterns/multi-tenant-approvals.md +3 -3
  1337. package/docs/patterns/multi-tenant-auth.md +3 -3
  1338. package/docs/patterns/multi-tenant-memory.md +6 -7
  1339. package/docs/patterns/voice-notes.md +1 -1
  1340. package/docs/reference/cli.md +8 -24
  1341. package/docs/reference/typescript-api.md +85 -60
  1342. package/docs/sandbox/custom-providers.mdx +13 -14
  1343. package/docs/sandbox/default.mdx +1 -1
  1344. package/docs/sandbox/docker.mdx +10 -0
  1345. package/docs/sandbox/index.mdx +4 -0
  1346. package/docs/sandbox/vercel.mdx +6 -6
  1347. package/docs/schedules.mdx +4 -4
  1348. package/docs/skills.mdx +6 -6
  1349. package/docs/subagents/index.mdx +25 -34
  1350. package/docs/tools/human-in-the-loop.md +42 -34
  1351. package/docs/tools/overview.mdx +14 -12
  1352. package/docs/tools/tasks-upgrade.md +13 -1
  1353. package/docs/tools/tasks.md +58 -89
  1354. package/docs/tools/workflows.mdx +44 -33
  1355. package/docs/tutorial/guard-the-spend.mdx +1 -1
  1356. package/docs/tutorial/run-analysis.mdx +15 -12
  1357. package/docs/tutorial/team-playbooks.mdx +19 -23
  1358. package/package.json +146 -95
  1359. package/dist/src/chunks/use-eve-agent-BE2_zd5q.js +0 -4968
  1360. package/dist/src/chunks/use-eve-agent-e8a5vcFO.js +0 -4926
  1361. package/dist/src/cli/invoke/command.d.ts +0 -19
  1362. package/dist/src/cli/invoke/command.js +0 -1
  1363. package/dist/src/cli/invoke/invoke.d.ts +0 -27
  1364. package/dist/src/cli/invoke/invoke.js +0 -1
  1365. package/dist/src/cli/invoke/result.d.ts +0 -137
  1366. package/dist/src/cli/invoke/result.js +0 -1
  1367. package/dist/src/client/agent-host.d.ts +0 -4
  1368. package/dist/src/client/agent-host.js +0 -1
  1369. package/dist/src/client/authorization-message-parts.d.ts +0 -4
  1370. package/dist/src/client/authorization-message-parts.js +0 -1
  1371. package/dist/src/client/conversation-projection.d.ts +0 -4
  1372. package/dist/src/client/conversation-projection.js +0 -1
  1373. package/dist/src/client/conversation-reducer.d.ts +0 -29
  1374. package/dist/src/client/conversation-reducer.js +0 -1
  1375. package/dist/src/client/eve-agent-projection.d.ts +0 -28
  1376. package/dist/src/client/eve-agent-projection.js +0 -1
  1377. package/dist/src/client/eve-agent-store-helpers.d.ts +0 -34
  1378. package/dist/src/client/eve-agent-store-helpers.js +0 -2
  1379. package/dist/src/client/eve-agent-store-state.d.ts +0 -96
  1380. package/dist/src/client/eve-agent-store.d.ts +0 -45
  1381. package/dist/src/client/eve-agent-store.js +0 -1
  1382. package/dist/src/client/message-action-parts.d.ts +0 -37
  1383. package/dist/src/client/message-action-parts.js +0 -1
  1384. package/dist/src/client/message-reducer-primitives.d.ts +0 -6
  1385. package/dist/src/client/message-reducer-primitives.js +0 -1
  1386. package/dist/src/client/message-reducer-types.d.ts +0 -244
  1387. package/dist/src/client/message-reducer.d.ts +0 -14
  1388. package/dist/src/client/message-reducer.js +0 -1
  1389. package/dist/src/client/message-response.d.ts +0 -74
  1390. package/dist/src/client/message-response.js +0 -1
  1391. package/dist/src/client/message-run-parts.d.ts +0 -22
  1392. package/dist/src/client/message-run-parts.js +0 -1
  1393. package/dist/src/client/output-schema.d.ts +0 -5
  1394. package/dist/src/client/output-schema.js +0 -1
  1395. package/dist/src/client/reducer.d.ts +0 -67
  1396. package/dist/src/client/session-turn-dispatch.d.ts +0 -15
  1397. package/dist/src/client/session-turn-dispatch.js +0 -1
  1398. package/dist/src/client/tool-call-state.d.ts +0 -23
  1399. package/dist/src/client/tool-call-state.js +0 -1
  1400. package/dist/src/client/tool-part-state.d.ts +0 -7
  1401. package/dist/src/client/tool-part-state.js +0 -1
  1402. package/dist/src/client/transcript-reducer.d.ts +0 -49
  1403. package/dist/src/client/transcript-reducer.js +0 -2
  1404. package/dist/src/context/build-dynamic-tools.d.ts +0 -10
  1405. package/dist/src/context/build-dynamic-tools.js +0 -1
  1406. package/dist/src/context/dynamic-connection-lifecycle.d.ts +0 -15
  1407. package/dist/src/context/dynamic-connection-lifecycle.js +0 -1
  1408. package/dist/src/context/dynamic-instruction-lifecycle.d.ts +0 -31
  1409. package/dist/src/context/dynamic-instruction-lifecycle.js +0 -1
  1410. package/dist/src/context/dynamic-model-lifecycle.d.ts +0 -19
  1411. package/dist/src/context/dynamic-model-lifecycle.js +0 -1
  1412. package/dist/src/context/dynamic-resolve-context.d.ts +0 -12
  1413. package/dist/src/context/dynamic-resolve-context.js +0 -1
  1414. package/dist/src/context/dynamic-skill-lifecycle.d.ts +0 -15
  1415. package/dist/src/context/dynamic-skill-lifecycle.js +0 -1
  1416. package/dist/src/context/dynamic-subagent-lifecycle.d.ts +0 -27
  1417. package/dist/src/context/dynamic-subagent-lifecycle.js +0 -1
  1418. package/dist/src/context/dynamic-tool-lifecycle.d.ts +0 -46
  1419. package/dist/src/context/dynamic-tool-lifecycle.js +0 -1
  1420. package/dist/src/context/dynamic-tool-metadata.d.ts +0 -47
  1421. package/dist/src/context/dynamic-tool-metadata.js +0 -1
  1422. package/dist/src/context/effective-model.d.ts +0 -5
  1423. package/dist/src/context/effective-model.js +0 -1
  1424. package/dist/src/context/hook-lifecycle.d.ts +0 -15
  1425. package/dist/src/context/hook-lifecycle.js +0 -1
  1426. package/dist/src/context/memory-event-lifecycle.d.ts +0 -15
  1427. package/dist/src/context/memory-event-lifecycle.js +0 -1
  1428. package/dist/src/context/memory-lifecycle.d.ts +0 -47
  1429. package/dist/src/context/memory-lifecycle.js +0 -1
  1430. package/dist/src/context/serialized-dynamic-model-selection.d.ts +0 -2
  1431. package/dist/src/context/serialized-dynamic-model-selection.js +0 -1
  1432. package/dist/src/execution/cancel-descendant-turns-step.d.ts +0 -6
  1433. package/dist/src/execution/cancel-descendant-turns-step.js +0 -1
  1434. package/dist/src/execution/dynamic-connection-recovery.d.ts +0 -14
  1435. package/dist/src/execution/dynamic-connection-recovery.js +0 -1
  1436. package/dist/src/execution/dynamic-connections.d.ts +0 -12
  1437. package/dist/src/execution/dynamic-connections.js +0 -1
  1438. package/dist/src/execution/history-view.d.ts +0 -10
  1439. package/dist/src/execution/history-view.js +0 -1
  1440. package/dist/src/execution/legacy-remote-agent/protocol.d.ts +0 -49
  1441. package/dist/src/execution/legacy-remote-agent/protocol.js +0 -1
  1442. package/dist/src/execution/runtime-errors.d.ts +0 -13
  1443. package/dist/src/execution/runtime-errors.js +0 -1
  1444. package/dist/src/execution/sandbox/grep-tool.d.ts +0 -26
  1445. package/dist/src/execution/sandbox/grep-tool.js +0 -3
  1446. package/dist/src/execution/session/turn-waiting-step.d.ts +0 -4
  1447. package/dist/src/execution/session/turn-waiting-step.js +0 -1
  1448. package/dist/src/execution/tools/workflow/cancel.d.ts +0 -13
  1449. package/dist/src/execution/tools/workflow/cancel.js +0 -1
  1450. package/dist/src/execution/workflow-trace-context.d.ts +0 -8
  1451. package/dist/src/execution/workflow-trace-context.js +0 -1
  1452. package/dist/src/extensions/code/extension/instructions/github.d.ts +0 -3
  1453. package/dist/src/extensions/code/extension/instructions/github.js +0 -1
  1454. package/dist/src/extensions/code/extension/lib/github-compat.d.ts +0 -28
  1455. package/dist/src/extensions/code/extension/lib/github-compat.js +0 -1
  1456. package/dist/src/extensions/code/extension/lib/grep-search.js +0 -6
  1457. package/dist/src/extensions/code/extension/skills/pr.d.ts +0 -6
  1458. package/dist/src/extensions/code/extension/skills/pr.js +0 -1
  1459. package/dist/src/extensions/code/extension/tools/gh.d.ts +0 -28
  1460. package/dist/src/extensions/code/extension/tools/gh.js +0 -1
  1461. package/dist/src/harness/approval-recheck.d.ts +0 -7
  1462. package/dist/src/harness/approval-recheck.js +0 -1
  1463. package/dist/src/harness/authorization-event-fields.d.ts +0 -16
  1464. package/dist/src/harness/authorization-event-fields.js +0 -1
  1465. package/dist/src/harness/hitl/candidates.d.ts +0 -139
  1466. package/dist/src/harness/hitl/candidates.js +0 -1
  1467. package/dist/src/harness/hitl/coordinator.d.ts +0 -35
  1468. package/dist/src/harness/hitl/coordinator.js +0 -1
  1469. package/dist/src/harness/input-extraction.d.ts +0 -13
  1470. package/dist/src/harness/input-extraction.js +0 -1
  1471. package/dist/src/harness/input-request-class.d.ts +0 -3
  1472. package/dist/src/harness/input-request-class.js +0 -1
  1473. package/dist/src/harness/input-request-resolution.d.ts +0 -39
  1474. package/dist/src/harness/input-request-resolution.js +0 -1
  1475. package/dist/src/harness/open-input-request.d.ts +0 -8
  1476. package/dist/src/harness/open-input-request.js +0 -1
  1477. package/dist/src/harness/session-machine/events.d.ts +0 -6
  1478. package/dist/src/harness/session-machine/events.js +0 -1
  1479. package/dist/src/harness/session-machine/resolver-events.d.ts +0 -12
  1480. package/dist/src/harness/session-machine/resolver-events.js +0 -1
  1481. package/dist/src/harness/tool-call-action.d.ts +0 -9
  1482. package/dist/src/harness/tool-call-action.js +0 -1
  1483. package/dist/src/harness/tool-interrupts.d.ts +0 -22
  1484. package/dist/src/harness/tool-interrupts.js +0 -1
  1485. package/dist/src/harness/tool-presentation.d.ts +0 -5
  1486. package/dist/src/harness/tool-presentation.js +0 -1
  1487. package/dist/src/harness/turn-tag-state.d.ts +0 -115
  1488. package/dist/src/harness/turn-tag-state.js +0 -1
  1489. package/dist/src/internal/dynamic-tool-rebind.d.ts +0 -3
  1490. package/dist/src/internal/dynamic-tool-rebind.js +0 -1
  1491. package/dist/src/internal/nitro/host/extension-capability-requirements.d.ts +0 -14
  1492. package/dist/src/internal/nitro/host/extension-capability-requirements.js +0 -1
  1493. package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.d.ts +0 -12
  1494. package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.js +0 -1
  1495. package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.d.ts +0 -7
  1496. package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.js +0 -3
  1497. package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.d.ts +0 -79
  1498. package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.js +0 -1
  1499. package/dist/src/internal/workflow-bundle/dynamic-tool-transform.d.ts +0 -14
  1500. package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +0 -3
  1501. package/dist/src/protocol/event-dedupe.d.ts +0 -26
  1502. package/dist/src/protocol/event-dedupe.js +0 -1
  1503. package/dist/src/protocol/event-id.d.ts +0 -10
  1504. package/dist/src/protocol/event-id.js +0 -1
  1505. package/dist/src/protocol/message-version.d.ts +0 -53
  1506. package/dist/src/protocol/message-version.js +0 -1
  1507. package/dist/src/protocol/message.d.ts +0 -1198
  1508. package/dist/src/protocol/message.js +0 -2
  1509. package/dist/src/public/channels/chat-sdk/messageToUserContent.js +0 -1
  1510. package/dist/src/public/channels/slack/input-response.js +0 -1
  1511. package/dist/src/runtime/hooks/registry.d.ts +0 -34
  1512. package/dist/src/runtime/hooks/registry.js +0 -1
  1513. package/dist/src/runtime/resolve-dynamic-connection.d.ts +0 -5
  1514. package/dist/src/runtime/resolve-dynamic-connection.js +0 -1
  1515. package/dist/src/runtime/resolve-dynamic-instructions.d.ts +0 -4
  1516. package/dist/src/runtime/resolve-dynamic-instructions.js +0 -1
  1517. package/dist/src/runtime/resolve-dynamic-skill.d.ts +0 -8
  1518. package/dist/src/runtime/resolve-dynamic-skill.js +0 -1
  1519. package/dist/src/runtime/resolve-dynamic-subagent.d.ts +0 -9
  1520. package/dist/src/runtime/resolve-dynamic-subagent.js +0 -1
  1521. package/dist/src/runtime/resolve-dynamic-tool.d.ts +0 -12
  1522. package/dist/src/runtime/resolve-dynamic-tool.js +0 -1
  1523. package/dist/src/self-modification/migration.d.ts +0 -9
  1524. package/dist/src/self-modification/migration.js +0 -28
  1525. package/dist/src/shared/history-view.d.ts +0 -22
  1526. package/dist/src/shared/history-view.js +0 -1
  1527. package/dist/src/shared/package-version.d.ts +0 -2
  1528. package/dist/src/shared/package-version.js +0 -1
  1529. package/dist/src/tools/durable-callbacks.d.ts +0 -118
  1530. package/dist/src/tools/durable-callbacks.js +0 -1
  1531. package/dist/src/tools/durable-schema.d.ts +0 -16
  1532. package/dist/src/tools/durable-schema.js +0 -1
  1533. /package/dist/src/{client/eve-agent-store-state.js → ai/decision-types.js} +0 -0
  1534. /package/dist/src/client/{message-reducer-types.js → agent-info-types.js} +0 -0
  1535. /package/dist/src/client/{reducer.js → health-types.js} +0 -0
  1536. /package/dist/src/{shared → protocol/session-projection}/display-name.d.ts +0 -0
  1537. /package/dist/src/{shared → protocol/session-projection}/display-name.js +0 -0
@@ -1 +1 @@
1
- import{attachClientContext,readClientContext}from"#internal/client-context.js";import{SESSION_INBOX_CONTEXT_KEY,sessionCommandHookToken}from"#execution/session-inbox/address.js";import{readSerializedSessionSchedule}from"#context/session-schedule.js";import{createHook,getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,isHookConflictError}from"#execution/hook-ownership.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session/timeout.js";import{sessionHookTokens}from"#execution/session/hook-tokens.js";import{createSessionInbox}from"#execution/session-inbox/inbox.js";import{failSession,runPreparedSession}from"#execution/session/program.js";import{createSessionTimeoutControl}from"#execution/session/timeout-control.js";import{prepareSuccessorStep,signalSessionOwnerActivationStep,stopUntrackedChildSessionsStep}from"#execution/session/handoff-steps.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{createTurnControl}from"#execution/session/turn-control.js";import{HANDOFF_LEASE_RETENTION,handoffLeaseToken,sendSessionHandover}from"#execution/session/handoff.js";import{resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";import{migrateSessionCheckpoint}from"#execution/session/checkpoint-migrations.js";import{abandonHandoverIfRunEnds,watchRunEnd}from"#execution/session/run-watch.js";async function workflowEntry(e){"use workflow";let t=e.kind===`initial`?await bootInitialOwner(e,getWorkflowMetadata().workflowRunId):(e.handoffVersion??0)>=3?await bootForcedHandoffOwner(e):await bootReleasedHandoffOwner(e);return t===void 0?{output:``}:{output:(await runPreparedSession(t.session,t.inbox)).output}}function stampSessionIdentity(e,t){return{...e,"eve.sessionId":t,[SESSION_INBOX_CONTEXT_KEY]:{sessionId:t}}}async function prepareInitialOwner(e,t){let n={kind:`owned`,timeoutControl:createSessionTimeoutControl({sessionId:t.sessionId,timeoutMs:t.sessionTimeoutMs}),turnControl:createTurnControl()},r={confirmAfter:t.sessionCreation},[i,a]=await Promise.allSettled([e.claimSessionHook(sessionCommandHookToken(t.sessionId),r),t.continuationToken===``?Promise.resolve():e.claimSessionHook(t.continuationToken,r)]);if(i.status===`rejected`)throw i.reason;if(a.status===`rejected`){if(isHookConflictError(a.reason))return{kind:`alias-conflict`};throw a.reason}return n}function unwrapSettled(e){if(e.status===`rejected`)throw e.reason;return e.value}async function bootInitialOwner(e,t){let n=stampSessionIdentity(e.serializedContext,t),r=getWritable(),i=createSessionInbox(t),a=e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS,o=n[`eve.continuationToken`]||``,s=n[`eve.bundle`];try{let c=createSessionStep({agentSessionRuntimeOverrides:n[`eve.agentSessionRuntimeOverrides`],compiledArtifactsSource:s.source,continuationToken:o,dynamicSubagentAgentConfig:n[`eve.dynamicSubagentAgentConfig`],history:e.input.message===void 0?e.input.history:void 0,nodeId:s.nodeId,outputSchema:e.input.outputSchema,rootSessionId:readRootSessionId(n),sessionId:t}),l=prepareInitialOwner(i,{continuationToken:o,sessionCreation:c,sessionId:t,sessionTimeoutMs:a}),u=hasDelegatedSessionContext(n)?resolveInitialTurnCallerStep({serializedContext:n}):Promise.resolve(void 0),[d,f,p]=await Promise.allSettled([c,l,u]),m=unwrapSettled(d),h=unwrapSettled(f);if(h.kind===`alias-conflict`){e.continuationConflictCommand!==void 0&&await settleContinuationConflictStep({command:e.continuationConflictCommand,continuationToken:o}),await i.dispose();return}let g=unwrapSettled(p);return{inbox:i,session:{admittedDeliveryKeys:e.idempotencyKey===void 0?[]:[e.idempotencyKey],anchor:{kind:`self`},caller:g,capabilities:n[`eve.capabilities`],deploymentId:e.ownerDeploymentId,history:m.history,start:e.input.message===void 0?{kind:`first-message`}:{input:createInitialDelivery(e,n),kind:`turn`},initialTurnControl:h.turnControl,retention:e.retention,serializedContext:n,sessionId:t,sessionState:m.state,sessionTimeoutControl:h.timeoutControl,sessionTimeoutMs:a,sessionWritable:r}}}catch(e){return await i.dispose(),await failSession({error:e,serializedContext:n,sessionId:t,sessionState:void 0,sessionWritable:r})}}async function prepareSuccessor(e,t){let{sessionId:n}=e,r=migrateSessionCheckpoint(e.checkpoint),i=await prepareSuccessorStep({handoffVersion:e.handoffVersion,migration:r,sessionId:n,...t!==void 0&&{source:t}});if(r.kind===`incompatible`||i.kind===`incompatible`){await signalSessionOwnerActivationStep({activation:{kind:`incompatible`,payloads:[],reason:`checkpoint-version`,runId:getWorkflowMetadata().workflowRunId},token:e.activationToken});return}if(i.kind===`source-gone`){await signalFailedActivation(e,Error(`The session's previous owner no longer holds all of its addresses.`),{payloads:[]});return}let{checkpoint:a,childRunIdsToStop:o}=r;return{checkpoint:a,childRunIdsToStop:o,serializedContext:stampSessionIdentity(a.serializedContext,n)}}async function signalFailedActivation(e,t,n){await signalSessionOwnerActivationStep({activation:{error:normalizeSerializableError(t),kind:`failed`,runId:getWorkflowMetadata().workflowRunId,...n},token:e.activationToken})}async function bootForcedHandoffOwner(e){let{attemptKey:t,hookTokens:n,sessionId:r,sourceRunId:i}=e;if(t===void 0||n===void 0||i===void 0){await signalFailedActivation(e,Error(`Session handoff version 3 input is missing attemptKey, hookTokens, or sourceRunId.`),{payloads:[]});return}try{let e=createHook({experimental_minRetention:HANDOFF_LEASE_RETENTION,token:handoffLeaseToken(t)});await claimHookOwnership(e)}catch(t){if(isHookConflictError(t))return;await signalFailedActivation(e,t,{payloads:[]});return}let a;try{a=await prepareSuccessor(e,{hookTokens:n,runId:i})}catch(t){await signalFailedActivation(e,t,{payloads:[]});return}if(a===void 0)return;let o=createSessionInbox(r);try{await o.claimSessionHooks(n,{force:!0,handover:t})}catch(n){let a=o.claimedTokens.length>0;await signalFailedActivation(e,n,{claimedHooks:a,payloads:[]}),a&&await handBack(o,{attemptKey:t,sessionId:r,sourceRunId:i}),await o.dispose();return}return abandonHandoverIfRunEnds(o,{attemptKey:t,sourceRunId:i}),await startSuccessor(e,o,a)}async function handBack(e,t){let n=watchRunEnd(t.sourceRunId),r=new AbortController;try{if(await Promise.race([e.whenTakenOver(r.signal).then(()=>`taken-back`),n.ended.then(()=>`source-ended`)])===`source-ended`)return}finally{n.stop(),r.abort()}await sendSessionHandover({attemptKey:t.attemptKey,payloads:e.drain(),sessionId:t.sessionId})}async function bootReleasedHandoffOwner(e){let t=createSessionInbox(e.sessionId),n;try{if(n=await prepareSuccessor(e),n===void 0)return;await t.claimSessionHooks(sessionHookTokens({serializedContext:n.serializedContext,sessionState:n.checkpoint.sessionState})),await signalSessionOwnerActivationStep({activation:{kind:`active`},token:e.activationToken})}catch(n){await signalFailedActivation(e,n,{payloads:await t.release()});return}return await startSuccessor(e,t,n)}async function startSuccessor(e,t,n){let{sessionId:r}=e,{checkpoint:i,childRunIdsToStop:a,serializedContext:o}=n;return a.length>0&&await stopUntrackedChildSessionsStep({runIds:a,sessionId:r}),{inbox:t,session:{anchor:{kind:`successor`},admittedDeliveryKeys:i.admittedDeliveryKeys,caller:e.delivery?.caller,capabilities:i.capabilities,deploymentId:e.ownerDeploymentId,history:i.history,start:e.delivery===void 0?{kind:`parked`}:{input:e.delivery,kind:`turn`},retention:i.retention,serializedContext:o,sessionId:r,sessionState:i.sessionState,sessionTimeoutControl:createSessionTimeoutControl({deadline:e.reason===`prewarm`?e.sessionTimeoutDeadline:void 0,sessionId:r,timeoutMs:i.sessionTimeoutMs}),sessionTimeoutMs:i.sessionTimeoutMs,sessionWritable:e.sessionWritable}}}function createInitialDelivery(e,t){if(e.input.message!==void 0)return{idempotencyKey:e.idempotencyKey,schedule:readSerializedSessionSchedule(t),deliveryMetadata:t[`eve.channelDelivery`]===void 0?void 0:[{...t[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[attachClientContext({message:e.input.message,context:e.input.context,history:e.input.history,outputSchema:e.input.outputSchema,state:e.input.state},readClientContext(e.input))],requestId:readChannelRequestId(t)}}workflowEntry.workflowId=`workflow//eve//workflowEntry`;export{bootInitialOwner,workflowEntry};
1
+ import{attachClientContext,readClientContext}from"#internal/client-context.js";import{SESSION_INBOX_CONTEXT_KEY,sessionCommandHookToken}from"#execution/session-inbox/address.js";import{readSerializedSessionSchedule}from"#context/session-schedule.js";import{storedProjection}from"#harness/session-machine/view.js";import{createHook,getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,isHookConflictError}from"#execution/hook-ownership.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session/timeout.js";import{sessionHookTokens}from"#execution/session/hook-tokens.js";import{createSessionInbox}from"#execution/session-inbox/inbox.js";import{failSession,runPreparedSession}from"#execution/session/program.js";import{createSessionTimeoutControl}from"#execution/session/timeout-control.js";import{prepareSuccessorStep,signalSessionOwnerActivationStep}from"#execution/session/handoff-steps.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{createTurnControl}from"#execution/session/turn-control.js";import{HANDOFF_LEASE_RETENTION,handoffLeaseToken,sendSessionHandover}from"#execution/session/handoff.js";import{resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{createSessionStep}from"#execution/create-session-step.js";import{closeSessionStreamStep}from"#execution/close-session-stream-step.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";import{migrateSessionCheckpoint}from"#execution/session/checkpoint-migrations.js";import{abandonHandoverIfRunEnds,watchRunEnd}from"#execution/session/run-watch.js";async function workflowEntry(e){"use workflow";let t=e.kind===`initial`?await bootInitialOwner(e,getWorkflowMetadata().workflowRunId):(e.handoffVersion??0)>=3?await bootForcedHandoffOwner(e):await bootReleasedHandoffOwner(e);return t===void 0?{output:``}:{output:(await runPreparedSession(t.session,t.inbox)).output}}function stampSessionIdentity(e,t){return{...e,"eve.sessionId":t,[SESSION_INBOX_CONTEXT_KEY]:{sessionId:t}}}async function prepareInitialOwner(e,t){let n={kind:`owned`,timeoutControl:createSessionTimeoutControl({sessionId:t.sessionId,timeoutMs:t.sessionTimeoutMs}),turnControl:createTurnControl()},r={confirmAfter:t.sessionCreation},[i,a]=await Promise.allSettled([e.claimSessionHook(sessionCommandHookToken(t.sessionId),r),t.continuationToken===``?Promise.resolve():e.claimSessionHook(t.continuationToken,r)]);if(i.status===`rejected`)throw i.reason;if(a.status===`rejected`){if(isHookConflictError(a.reason))return{kind:`alias-conflict`};throw a.reason}return n}function unwrapSettled(e){if(e.status===`rejected`)throw e.reason;return e.value}async function bootInitialOwner(e,t){let n=stampSessionIdentity(e.serializedContext,t),r=getWritable(),i=createSessionInbox(t),a=e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS,o=n[`eve.continuationToken`]||``,s=n[`eve.bundle`];try{let c=createSessionStep({agentSessionRuntimeOverrides:n[`eve.agentSessionRuntimeOverrides`],compiledArtifactsSource:s.source,continuationToken:o,dynamicSubagentAgentConfig:n[`eve.dynamicSubagentAgentConfig`],history:e.input.message===void 0?e.input.history:void 0,nodeId:s.nodeId,outputSchema:e.input.outputSchema,rootSessionId:readRootSessionId(n),sessionId:t}),l=prepareInitialOwner(i,{continuationToken:o,sessionCreation:c,sessionId:t,sessionTimeoutMs:a}),u=hasDelegatedSessionContext(n)?resolveInitialTurnCallerStep({serializedContext:n}):Promise.resolve(void 0),[d,f,p]=await Promise.allSettled([c,l,u]),m=unwrapSettled(d),h=unwrapSettled(f);if(h.kind===`alias-conflict`){e.continuationConflictCommand!==void 0&&await settleContinuationConflictStep({command:e.continuationConflictCommand,continuationToken:o}),await i.dispose(),await closeSessionStreamStep({sessionWritable:r});return}let g=unwrapSettled(p);return{inbox:i,session:{admittedDeliveryKeys:e.idempotencyKey===void 0?[]:[e.idempotencyKey],anchor:{kind:`self`},caller:g,capabilities:n[`eve.capabilities`],deploymentId:e.ownerDeploymentId,history:m.history,start:e.input.message===void 0?{kind:`first-message`}:{input:createInitialDelivery(e,n),kind:`turn`},initialTurnControl:h.turnControl,retention:e.retention,serializedContext:n,sessionId:t,sessionState:m.state,sessionTimeoutControl:h.timeoutControl,sessionTimeoutMs:a,sessionWritable:r}}}catch(e){return await i.dispose(),await failSession({error:e,serializedContext:n,sessionId:t,sessionState:void 0,sessionWritable:r})}}async function prepareSuccessor(e,t){let{sessionId:n}=e,r=migrateSessionCheckpoint(e.checkpoint),i=await prepareSuccessorStep({handoffVersion:e.handoffVersion,migration:r,sessionId:n,...t!==void 0&&{source:t}});if(r.kind===`incompatible`||i.kind===`incompatible`){await signalSessionOwnerActivationStep({activation:{kind:`incompatible`,payloads:[],reason:`checkpoint-version`,runId:getWorkflowMetadata().workflowRunId},token:e.activationToken});return}if(i.kind===`source-gone`){await signalFailedActivation(e,Error(`The session's previous owner no longer holds all of its addresses.`),{payloads:[]});return}let{checkpoint:a}=r;return{checkpoint:a,serializedContext:stampSessionIdentity(a.serializedContext,n)}}async function signalFailedActivation(e,t,n){await signalSessionOwnerActivationStep({activation:{error:normalizeSerializableError(t),kind:`failed`,runId:getWorkflowMetadata().workflowRunId,...n},token:e.activationToken})}async function bootForcedHandoffOwner(e){let{attemptKey:t,hookTokens:n,sessionId:r,sourceRunId:i}=e;if(t===void 0||n===void 0||i===void 0){await signalFailedActivation(e,Error(`Session handoff version 3 input is missing attemptKey, hookTokens, or sourceRunId.`),{payloads:[]});return}try{let e=createHook({experimental_minRetention:HANDOFF_LEASE_RETENTION,token:handoffLeaseToken(t)});await claimHookOwnership(e)}catch(t){if(isHookConflictError(t))return;await signalFailedActivation(e,t,{payloads:[]});return}let a;try{a=await prepareSuccessor(e,{hookTokens:n,runId:i})}catch(t){await signalFailedActivation(e,t,{payloads:[]});return}if(a===void 0)return;let o=createSessionInbox(r);try{await o.claimSessionHooks(n,{force:!0,handover:t})}catch(n){let a=o.claimedTokens.length>0;await signalFailedActivation(e,n,{claimedHooks:a,payloads:[]}),a&&await handBack(o,{attemptKey:t,sessionId:r,sourceRunId:i}),await o.dispose();return}return abandonHandoverIfRunEnds(o,{attemptKey:t,sourceRunId:i}),await startSuccessor(e,o,a)}async function handBack(e,t){let n=watchRunEnd(t.sourceRunId),r=new AbortController;try{if(await Promise.race([e.whenTakenOver(r.signal).then(()=>`taken-back`),n.ended.then(()=>`source-ended`)])===`source-ended`)return}finally{n.stop(),r.abort()}await sendSessionHandover({attemptKey:t.attemptKey,payloads:e.drain(),sessionId:t.sessionId})}async function bootReleasedHandoffOwner(e){let t=createSessionInbox(e.sessionId),n;try{if(n=await prepareSuccessor(e),n===void 0)return;await t.claimSessionHooks(sessionHookTokens({serializedContext:n.serializedContext,sessionState:n.checkpoint.sessionState})),await signalSessionOwnerActivationStep({activation:{kind:`active`},token:e.activationToken})}catch(n){await signalFailedActivation(e,n,{payloads:await t.release()});return}return await startSuccessor(e,t,n)}async function startSuccessor(e,t,n){let{sessionId:r}=e,{checkpoint:i,serializedContext:a}=n;return{inbox:t,session:{anchor:{kind:`successor`},admittedDeliveryKeys:i.admittedDeliveryKeys,caller:e.delivery?.caller,capabilities:i.capabilities,deploymentId:e.ownerDeploymentId,history:i.history,start:e.delivery===void 0?storedProjection(i.sessionState.snapshot.session.state).view.session.status===`new`?{kind:`first-message`}:{kind:`parked`}:{input:e.delivery,kind:`turn`},retention:i.retention,serializedContext:a,sessionId:r,sessionState:i.sessionState,sessionTimeoutControl:createSessionTimeoutControl({deadline:e.reason===`prewarm`?e.sessionTimeoutDeadline:void 0,sessionId:r,timeoutMs:i.sessionTimeoutMs}),sessionTimeoutMs:i.sessionTimeoutMs,sessionWritable:e.sessionWritable}}}function createInitialDelivery(e,t){if(e.input.message!==void 0)return{auth:t[`eve.auth`],idempotencyKey:e.idempotencyKey,schedule:readSerializedSessionSchedule(t),deliveryMetadata:t[`eve.channelDelivery`]===void 0?void 0:[{...t[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[attachClientContext({message:e.input.message,context:e.input.context,history:e.input.history,outputSchema:e.input.outputSchema,state:e.input.state},readClientContext(e.input))],requestId:readChannelRequestId(t)}}workflowEntry.workflowId=`workflow//eve//workflowEntry`;export{bootInitialOwner,workflowEntry};
@@ -1,3 +1,5 @@
1
+ import type { ControlDelivery } from "#harness/types.js";
2
+ import type { ControlSettlement } from "#harness/facts.js";
1
3
  import type { TurnCaller } from "#channel/types.js";
2
4
  import type { DurableSessionState } from "#execution/durable-session-store.js";
3
5
  import type { TurnOutcome } from "#execution/session/turn-step-types.js";
@@ -10,6 +12,8 @@ export type SessionTerminalOutcome = {
10
12
  };
11
13
  } | {
12
14
  readonly kind: "expired";
15
+ readonly control?: ControlDelivery;
16
+ readonly settles?: readonly ControlSettlement[];
13
17
  } | {
14
18
  readonly kind: "failed";
15
19
  readonly error: unknown;
@@ -1 +1 @@
1
- import{storedProjection}from"#harness/session-machine/view.js";import{getSessionUsage,takeSessionUsageDelta}from"#harness/turn-tag-state.js";import{liveTaskRuns,readTaskTable}from"#execution/tasks/table.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";import{notifyTurnCallerStep}from"#subagents/parent-notification.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{emitTerminalSessionCompletionStep}from"#execution/terminal-session-completion-step.js";import{endSessionSandboxStep,reportSessionSandboxCleanupFailureStep}from"#execution/session/end-sandbox-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";async function finalizeSession(e,t){let{serializedContext:n,sessionState:r}=t.cursor;if(r!==void 0&&liveTaskRuns(readTaskTable(r.snapshot?.session?.state)).length>0&&await terminateChildSessionsStep({sessionState:r}),r!==void 0)try{await endSessionSandboxStep({reason:e.kind===`done`?`completed`:e.kind,serializedContext:n,sessionState:r})}catch(t){await reportSessionSandboxCleanupFailureStep({error:normalizeSerializableError(t),outcome:e.kind,sessionId:r.sessionId}).catch(()=>void 0)}let i=r?.snapshot.session,a=i===void 0?void 0:getSessionUsage(i);e.kind===`expired`?await emitTerminalSessionCompletionStep({sessionWritable:t.sessionWritable,serializedContext:n,turn:lastPublishedTurn(i?.state),usage:a}):e.kind===`failed`&&await emitTerminalSessionFailureStep({error:normalizeSerializableError(e.error),sessionWritable:t.sessionWritable,serializedContext:n,turnId:e.turnId,usage:a});let o=settledResult(e,t);if(t.caller!==void 0){let e={output:o.output,usage:o.turnUsage};o.isError&&(e.isError=!0),await notifyTurnCallerStep({caller:t.caller,lifecycle:`terminal`,sessionId:r?.sessionId??n[`eve.sessionId`],settled:e})}return e.kind===`done`?{isError:e.action.isError,output:e.action.output,usage:e.action.usage,usageDelta:e.action.usageDelta}:{isError:o.isError,output:o.output,usage:o.sessionUsage,usageDelta:o.turnUsage}}function settledResult(e,t){let n=t.cursor.sessionState?.snapshot.session,r=n===void 0||t.caller===void 0?{}:{sessionUsage:getSessionUsage(n),turnUsage:takeSessionUsageDelta(n).delta};switch(e.kind){case`done`:return{isError:e.action.isError===!0,output:e.action.output,sessionUsage:e.action.usage,turnUsage:e.action.usageDelta};case`expired`:return t.caller===void 0?{isError:!1,output:``}:{isError:!0,output:`The session ended before the delegated task completed.`,...r};case`failed`:return{isError:!0,output:normalizeSerializableError(e.error),...r}}}function lastPublishedTurn(e){let t=Object.values(storedProjection(e).turns).reduce((e,t)=>e===void 0||t.sequence>e.sequence?t:e,void 0);return t===void 0?void 0:{id:t.turnId,sequence:t.sequence}}export{finalizeSession};
1
+ import{storedProjection}from"#harness/session-machine/view.js";import{liveRuns}from"#execution/tasks/table.js";import{reportChildSessionTeardownFailureStep,terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";import{sessionUsage,takeSessionUsageDelta}from"#harness/session-usage.js";import{latestTurnIdOf,turnCoordinatesOf}from"#protocol/session-projection.js";import{notifyTurnCallerStep}from"#subagents/parent-notification.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{closeSessionStreamStep}from"#execution/close-session-stream-step.js";import{emitTerminalSessionCompletionStep}from"#execution/terminal-session-completion-step.js";import{endSessionSandboxStep,reportSessionSandboxCleanupFailureStep}from"#execution/session/end-sandbox-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";function mayHaveLiveRuns(e){try{return liveRuns(e.snapshot?.session?.state).length>0}catch{return!0}}async function finalizeSession(e,t){let{serializedContext:n,sessionState:r}=t.cursor;if(r!==void 0&&mayHaveLiveRuns(r))try{await terminateChildSessionsStep({sessionState:r})}catch(e){await reportChildSessionTeardownFailureStep({error:normalizeSerializableError(e),parentSessionId:r.sessionId}).catch(()=>void 0)}if(r!==void 0)try{await endSessionSandboxStep({reason:e.kind===`done`?`completed`:e.kind,serializedContext:n,sessionState:r})}catch(t){await reportSessionSandboxCleanupFailureStep({error:normalizeSerializableError(t),outcome:e.kind,sessionId:r.sessionId}).catch(()=>void 0)}let i=r?.snapshot.session,a=i===void 0?void 0:sessionUsage(i),o=storedProjection(i?.state),s=latestTurnIdOf(o),c=s===void 0?void 0:turnCoordinatesOf(o,s);e.kind===`expired`?await emitTerminalSessionCompletionStep({control:e.control,settles:e.settles,projection:o,sessionState:r,sessionWritable:t.sessionWritable,serializedContext:n,turn:c&&{id:c.turnId,sequence:c.sequence},usage:a}):e.kind===`failed`?await emitTerminalSessionFailureStep({error:normalizeSerializableError(e.error),sessionState:r,projection:o,sessionWritable:t.sessionWritable,serializedContext:n,turnId:e.turnId??c?.turnId,usage:a}):await closeSessionStreamStep({sessionWritable:t.sessionWritable});let l=settledResult(e,t);if(t.caller!==void 0){let e={output:l.output,usage:l.turnUsage};l.isError&&(e.isError=!0),await notifyTurnCallerStep({caller:t.caller,lifecycle:`terminal`,sessionId:r?.sessionId??n[`eve.sessionId`],settled:e})}return e.kind===`done`?{isError:e.action.isError,output:e.action.output,usage:e.action.usage,usageDelta:e.action.usageDelta}:{isError:l.isError,output:l.output,usage:l.sessionUsage,usageDelta:l.turnUsage}}function settledResult(e,t){let n=t.cursor.sessionState?.snapshot.session,r=n===void 0||t.caller===void 0?{}:{sessionUsage:sessionUsage(n),turnUsage:takeSessionUsageDelta(n).delta};switch(e.kind){case`done`:return{isError:e.action.isError===!0,output:e.action.output,sessionUsage:e.action.usage,turnUsage:e.action.usageDelta};case`expired`:return t.caller===void 0?{isError:!1,output:``}:{isError:!0,output:`The session ended before the delegated task completed.`,...r};case`failed`:return{isError:!0,output:normalizeSerializableError(e.error),...r}}}export{finalizeSession};
@@ -1 +1 @@
1
- import{openInputs,openSignIns}from"#protocol/session-projection.js";import{queuedInput,storedProjection}from"#harness/session-machine/view.js";import{getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{readDurableSession}from"#execution/durable-session-read.js";import{holdsHitlRequests}from"#harness/hitl/view.js";function isSessionStateIdleForHandoff(e){let{state:t}=readDurableSession(e.sessionState),n=getBlockingWorkflowToolRuns(t);if(holdsHitlRequests(t)||[`eve.runtime.pendingInputBatch`,`eve.runtime.pendingCoordinationBatch`,`eve.runtime.deferredStepInput`,`eve.harness.pendingWorkflowInterrupt`].some(e=>t?.[e]!==void 0))return!1;let r=t?.[`eve.runtime.pendingInputBatches`];if(r!==void 0&&(!Array.isArray(r)||r.length>0))return!1;let i=storedProjection(t);return n.length===0&&i.activeTurnId===void 0&&openInputs(i).length===0&&openSignIns(i).length===0&&queuedInput(t)===void 0}export{isSessionStateIdleForHandoff};
1
+ import{openRequests,openSignIns}from"#protocol/session-projection/reader.js";import{queuedInput,storedProjection}from"#harness/session-machine/view.js";import{readDurableSession}from"#execution/durable-session-read.js";import{activeTurnIdOf}from"#protocol/session-projection.js";import{getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{holdsHitlRequests}from"#harness/hitl/view.js";function isSessionStateIdleForHandoff(e){let{state:t}=readDurableSession(e.sessionState),n=getBlockingWorkflowToolRuns(t);if(holdsHitlRequests(t))return!1;let r=storedProjection(t);return n.length===0&&activeTurnIdOf(r)===void 0&&openRequests(r.view).length===0&&openSignIns(r.view).length===0&&queuedInput(t)===void 0}export{isSessionStateIdleForHandoff};
@@ -60,14 +60,6 @@ export declare function prepareSuccessorStep(input: {
60
60
  readonly hookTokens: readonly string[];
61
61
  };
62
62
  }): Promise<SessionCheckpointValidation>;
63
- /**
64
- * Stops idle subagent sessions an older owner kept resumable, after this owner
65
- * activates. Best effort: a child that cannot be stopped ends at its own timeout.
66
- */
67
- export declare function stopUntrackedChildSessionsStep(input: {
68
- readonly runIds: readonly string[];
69
- readonly sessionId: string;
70
- }): Promise<void>;
71
63
  /** Records why the owner kept a session it tried to move, so a stuck handoff is visible. */
72
64
  export declare function reportSessionHandoffRetainedStep(input: {
73
65
  readonly error?: string;
@@ -1 +1 @@
1
- import{createLogger,logError}from"#internal/logging.js";import{sessionCommandHookToken,sessionInboxHookToken}from"#execution/session-inbox/address.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{getSandboxEnvironmentRuntime}from"#shared/sandbox-environment.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{cancelRun,getWorld,resumeHook}from"#internal/workflow/runtime.js";import{hasRunEnded,startWorkflowOnDeployment,workflowEntryReference}from"#execution/workflow-runtime.js";import{getResolvedRuntimeAgentNode}from"#runtime/graph.js";import{IncompatibleStateLayoutError,deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-read.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{findSessionHookHolder}from"#execution/session-inbox/owner.js";import{EVE_PREWARM_ATTRIBUTE,EVE_SESSION_ATTRIBUTE,EVE_VERSION_ATTRIBUTE}from"#execution/eve-workflow-attributes.js";import{owningSandboxDefinition}from"#runtime/sandbox/registry.js";import{isRetiredSandboxSessionState,resolvePersistedSandboxSessionState}from"#sandbox/state.js";import{SESSION_CHECKPOINT_VERSION}from"#execution/session/handoff.js";import{mapWithConcurrency}from"#shared/map-with-concurrency.js";import{isSessionStateIdleForHandoff}from"#execution/session/handoff-state.js";import{SESSION_HANDOFF_VERSION}from"#execution/session/entry-input.js";import{traceSessionHandover}from"#execution/session/handover-tracing.js";const log=createLogger(`execution.handoff`);async function startSuccessorStep(e){"use step";let{activationToken:t,anchorRunId:n,checkpoint:r,sessionWritable:i,targetDeploymentId:a,...o}=e,{capabilities:s}=await getWorld();if(s?.hookForceClaim!==!0||s.hookRetention?.active!==!0)return log.warn(`session handoff unavailable: the Workflow world cannot force-claim hooks`,{sessionId:n}),{kind:`unsupported`};if(!isSessionStateIdleForHandoff(r))return{kind:`not-idle`};let c={...o,activationToken:t,checkpoint:r,handoffVersion:SESSION_HANDOFF_VERSION,kind:`handoff`,ownerDeploymentId:a,sessionWritable:i,sessionId:n};return{kind:`started`,runId:(await startWorkflowOnDeployment(workflowEntryReference,[c],a,r.retention===void 0?void 0:{experimental_retention:r.retention})).runId}}async function hasRunEndedStep(e){"use step";return await hasRunEnded(e.runId)}async function prepareSuccessorStep(e){"use step";let{migration:t}=e,unreadable=t=>(log.warn(`session handoff refused: this deployment cannot read the checkpoint`,{detail:t,readableCheckpointVersion:SESSION_CHECKPOINT_VERSION,sessionId:e.sessionId}),{kind:`incompatible`,reason:`checkpoint-version`});if(t.kind===`incompatible`)return unreadable(t.detail);let{checkpoint:n}=t,r=n.sessionTimeoutMs;if(r!==!1&&(typeof r!=`number`||!Number.isFinite(r)||r<0))throw Error(`Session checkpoint contains an invalid timeout duration.`);let i;try{i=await deserializeContext(n.serializedContext)}catch(e){if(e instanceof IncompatibleStateLayoutError)return unreadable(e.message);throw e}let a=i.require(BundleKey),o=readDurableSession(n.sessionState).sandboxState?.session;if(o!=null&&!isRetiredSandboxSessionState(o)){let e=owningSandboxDefinition(getResolvedRuntimeAgentNode(a.graph,a.nodeId).sandboxRegistry.sandbox);if(e.kind!==`independent`)throw Error(`Session checkpoint sandbox has no resolved provider.`);let t=getSandboxEnvironmentRuntime(e.environment),n=resolvePersistedSandboxSessionState(o,t);if(n?.providerName!==t.providerName||n.stateProtocolVersion!==t.stateProtocolVersion)throw Error(`Session checkpoint sandbox provider state is incompatible.`)}if(!isSessionStateIdleForHandoff(n))throw Error(`Session checkpoint contains pending work and cannot be handed off.`);return e.source!==void 0&&!await holdsEveryAddress(e.source)?{kind:`source-gone`}:(await recordSessionOwner(e.sessionId),(e.handoffVersion??1)<SESSION_HANDOFF_VERSION&&log.info(`session moved from an owner that releases its addresses first`,{handoffVersion:e.handoffVersion??1,sessionId:e.sessionId}),{kind:`valid`})}async function holdsEveryAddress(e){return(await mapWithConcurrency(e.hookTokens,16,e=>findSessionHookHolder(sessionInboxHookToken(e)))).every(t=>t?.runId===e.runId)}async function stopUntrackedChildSessionsStep(e){"use step";let t=await getWorld();for(let n of e.runIds)if(n!==e.sessionId)try{await cancelRun(t,n,{cancelReason:`Session upgraded`})}catch(t){[...walkCauseChain(t)].some(e=>EntityConflictError.is(e)||RunExpiredError.is(e)||WorkflowRunNotFoundError.is(e))||logError(log,`could not stop a subagent session after handoff`,t,{childRunId:n,sessionId:e.sessionId})}}async function reportSessionHandoffRetainedStep(e){"use step";log.warn(`session handoff failed; the current owner keeps the session`,{...e,checkpointVersion:SESSION_CHECKPOINT_VERSION})}async function recordSessionOwnerStep(e){"use step";await recordSessionOwner(e.sessionId)}async function recordSessionOwner(e){let{setAttributes:t}=await import(`#compiled/@workflow/core/index.js`);await t({[EVE_SESSION_ATTRIBUTE]:e,[EVE_PREWARM_ATTRIBUTE]:`1`,[EVE_VERSION_ATTRIBUTE]:resolveInstalledPackageInfo().version},{allowReservedAttributes:!0})}async function signalSessionOwnerActivationStep(e){"use step";try{await resumeHook(e.token,e.activation)}catch(e){if(!HookNotFoundError.is(e))throw e}}async function reportSessionTakenOverOutsideAttemptStep(e){"use step";log.error(`session taken over with no handoff attempt open; this run leaves without finalizing`,{sessionId:e.sessionId})}async function reportHandoverPartStuckStep(e){"use step";log.warn(`session handover part keeps failing; the previous owner keeps retrying`,e)}async function sendSessionHandoverPartStep(e){"use step";let t={"eve.handoff.buffered_payload_count":e.bufferedPayloadCount,"eve.handoff.part_index":e.part.index};e.part.index===0&&traceSessionHandover(`forwarding_started`,e.sessionId,e.part.attemptKey,t);try{let n=await resumeHook(sessionInboxHookToken(sessionCommandHookToken(e.sessionId)),{...e.part,kind:`handover`});return traceSessionHandover(e.part.final===!0?`final_submitted`:`part_submitted`,e.sessionId,e.part.attemptKey,{...t,"eve.handoff.destination_run_id":n.runId}),`delivered`}catch(e){if(HookNotFoundError.is(e))return`session-ended`;throw e}}async function signalSessionAnchorStep(e){"use step";await resumeHook(e.token,e.result)}export{hasRunEndedStep,prepareSuccessorStep,recordSessionOwnerStep,reportHandoverPartStuckStep,reportSessionHandoffRetainedStep,reportSessionTakenOverOutsideAttemptStep,sendSessionHandoverPartStep,signalSessionAnchorStep,signalSessionOwnerActivationStep,startSuccessorStep,stopUntrackedChildSessionsStep};
1
+ import{createLogger}from"#internal/logging.js";import{sessionCommandHookToken,sessionInboxHookToken}from"#execution/session-inbox/address.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{getSandboxEnvironmentRuntime}from"#shared/sandbox-environment.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{getWorld,resumeHook}from"#internal/workflow/runtime.js";import{hasRunEnded,startWorkflowOnDeployment,workflowEntryReference}from"#execution/workflow-runtime.js";import{getResolvedRuntimeAgentNode}from"#runtime/graph.js";import{IncompatibleStateLayoutError,deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-read.js";import{HookNotFoundError}from"#compiled/@workflow/errors/index.js";import{findSessionHookHolder}from"#execution/session-inbox/owner.js";import{EVE_PREWARM_ATTRIBUTE,EVE_SESSION_ATTRIBUTE,EVE_VERSION_ATTRIBUTE}from"#execution/eve-workflow-attributes.js";import{owningSandboxDefinition}from"#runtime/sandbox/registry.js";import{isRetiredSandboxSessionState,resolvePersistedSandboxSessionState}from"#sandbox/state.js";import{SESSION_CHECKPOINT_VERSION}from"#execution/session/handoff.js";import{mapWithConcurrency}from"#shared/map-with-concurrency.js";import{isSessionStateIdleForHandoff}from"#execution/session/handoff-state.js";import{SESSION_HANDOFF_VERSION}from"#execution/session/entry-input.js";import{traceSessionHandover}from"#execution/session/handover-tracing.js";const log=createLogger(`execution.handoff`);async function startSuccessorStep(e){"use step";let{activationToken:t,anchorRunId:n,checkpoint:r,sessionWritable:i,targetDeploymentId:a,...o}=e,{capabilities:s}=await getWorld();if(s?.hookForceClaim!==!0||s.hookRetention?.active!==!0)return log.warn(`session handoff unavailable: the Workflow world cannot force-claim hooks`,{sessionId:n}),{kind:`unsupported`};if(!isSessionStateIdleForHandoff(r))return{kind:`not-idle`};let c={...o,activationToken:t,checkpoint:r,handoffVersion:SESSION_HANDOFF_VERSION,kind:`handoff`,ownerDeploymentId:a,sessionWritable:i,sessionId:n};return{kind:`started`,runId:(await startWorkflowOnDeployment(workflowEntryReference,[c],a,r.retention===void 0?void 0:{experimental_retention:r.retention})).runId}}async function hasRunEndedStep(e){"use step";return await hasRunEnded(e.runId)}async function prepareSuccessorStep(e){"use step";let{migration:t}=e,unreadable=t=>(log.warn(`session handoff refused: this deployment cannot read the checkpoint`,{detail:t,readableCheckpointVersion:SESSION_CHECKPOINT_VERSION,sessionId:e.sessionId}),{kind:`incompatible`,reason:`checkpoint-version`});if(t.kind===`incompatible`)return unreadable(t.detail);let{checkpoint:n}=t,r=n.sessionTimeoutMs;if(r!==!1&&(typeof r!=`number`||!Number.isFinite(r)||r<0))throw Error(`Session checkpoint contains an invalid timeout duration.`);let i;try{i=await deserializeContext(n.serializedContext)}catch(e){if(e instanceof IncompatibleStateLayoutError)return unreadable(e.message);throw e}let a=i.require(BundleKey),o=readDurableSession(n.sessionState).sandboxState?.session;if(o!=null&&!isRetiredSandboxSessionState(o)){let e=owningSandboxDefinition(getResolvedRuntimeAgentNode(a.graph,a.nodeId).sandboxRegistry.sandbox);if(e.kind!==`independent`)throw Error(`Session checkpoint sandbox has no resolved provider.`);let t=getSandboxEnvironmentRuntime(e.environment),n=resolvePersistedSandboxSessionState(o,t);if(n?.providerName!==t.providerName||n.stateProtocolVersion!==t.stateProtocolVersion)throw Error(`Session checkpoint sandbox provider state is incompatible.`)}if(!isSessionStateIdleForHandoff(n))throw Error(`Session checkpoint contains pending work and cannot be handed off.`);return e.source!==void 0&&!await holdsEveryAddress(e.source)?{kind:`source-gone`}:(await recordSessionOwner(e.sessionId),(e.handoffVersion??1)<SESSION_HANDOFF_VERSION&&log.info(`session moved from an owner that releases its addresses first`,{handoffVersion:e.handoffVersion??1,sessionId:e.sessionId}),{kind:`valid`})}async function holdsEveryAddress(e){return(await mapWithConcurrency(e.hookTokens,16,e=>findSessionHookHolder(sessionInboxHookToken(e)))).every(t=>t?.runId===e.runId)}async function reportSessionHandoffRetainedStep(e){"use step";log.warn(`session handoff failed; the current owner keeps the session`,{...e,checkpointVersion:SESSION_CHECKPOINT_VERSION})}async function recordSessionOwnerStep(e){"use step";await recordSessionOwner(e.sessionId)}async function recordSessionOwner(e){let{setAttributes:t}=await import(`#compiled/@workflow/core/index.js`);await t({[EVE_SESSION_ATTRIBUTE]:e,[EVE_PREWARM_ATTRIBUTE]:`1`,[EVE_VERSION_ATTRIBUTE]:resolveInstalledPackageInfo().version},{allowReservedAttributes:!0})}async function signalSessionOwnerActivationStep(e){"use step";try{await resumeHook(e.token,e.activation)}catch(e){if(!HookNotFoundError.is(e))throw e}}async function reportSessionTakenOverOutsideAttemptStep(e){"use step";log.error(`session taken over with no handoff attempt open; this run leaves without finalizing`,{sessionId:e.sessionId})}async function reportHandoverPartStuckStep(e){"use step";log.warn(`session handover part keeps failing; the previous owner keeps retrying`,e)}async function sendSessionHandoverPartStep(e){"use step";let t={"eve.handoff.buffered_payload_count":e.bufferedPayloadCount,"eve.handoff.part_index":e.part.index};e.part.index===0&&traceSessionHandover(`forwarding_started`,e.sessionId,e.part.attemptKey,t);try{let n=await resumeHook(sessionInboxHookToken(sessionCommandHookToken(e.sessionId)),{...e.part,kind:`handover`});return traceSessionHandover(e.part.final===!0?`final_submitted`:`part_submitted`,e.sessionId,e.part.attemptKey,{...t,"eve.handoff.destination_run_id":n.runId}),`delivered`}catch(e){if(HookNotFoundError.is(e))return`session-ended`;throw e}}async function signalSessionAnchorStep(e){"use step";await resumeHook(e.token,e.result)}export{hasRunEndedStep,prepareSuccessorStep,recordSessionOwnerStep,reportHandoverPartStuckStep,reportSessionHandoffRetainedStep,reportSessionTakenOverOutsideAttemptStep,sendSessionHandoverPartStep,signalSessionAnchorStep,signalSessionOwnerActivationStep,startSuccessorStep};
@@ -10,10 +10,11 @@ import type { AgentWorkflowRetentionDefinition } from "#shared/agent-definition.
10
10
  * build than the owner that produced it; bump when any field changes shape so
11
11
  * an older successor rejects the handoff instead of misreading state.
12
12
  *
13
- * A newer successor must always accept older checkpoints: every bump adds the
14
- * upgrade from the previous version in `checkpoint-migrations.ts`.
13
+ * A successor accepts checkpoints back to `MIN_SESSION_CHECKPOINT_VERSION` and
14
+ * refuses older ones; a bump that keeps its predecessor readable adds the upgrade
15
+ * in `checkpoint-migrations.ts`.
15
16
  */
16
- export declare const SESSION_CHECKPOINT_VERSION = 17;
17
+ export declare const SESSION_CHECKPOINT_VERSION = 18;
17
18
  /** Everything a successor needs to continue an idle session. Hooks are derived from the state. */
18
19
  export interface SessionCheckpoint {
19
20
  readonly admittedDeliveryKeys: readonly string[];
@@ -1 +1 @@
1
- import{isObject}from"#shared/guards.js";import{createHook,getWorkflowMetadata,sleep}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{hasRunEndedStep,reportHandoverPartStuckStep,reportSessionHandoffRetainedStep,reportSessionTakenOverOutsideAttemptStep,sendSessionHandoverPartStep,startSuccessorStep}from"#execution/session/handoff-steps.js";import{abandonHandoverIfRunEnds,watchRunEnd}from"#execution/session/run-watch.js";import{isSessionStateIdleForHandoff}from"#execution/session/handoff-state.js";import{readAcceptedDeploymentId}from"#execution/session/accepted-deployment.js";const SESSION_CHECKPOINT_VERSION=17;function sessionAnchorToken(e){return`${e}:anchor`}function handoffLeaseToken(e){return`eve:handoff:lease:${e}`}const HANDOFF_LEASE_RETENTION=`7d`;function verdictRunId(e){return e.kind===`verdict`&&e.verdict.kind!==`active`?e.verdict.runId:void 0}async function sendSessionHandover(e){let{attemptKey:t,sessionId:n}=e,r=e.payloads.filter(e=>e.kind!==`handover`);for(let[e,i]of r.entries())if(await sendHandoverPart({attemptKey:t,index:e,payloads:[i]},n,r.length)===`session-ended`)return;await sendHandoverPart({attemptKey:t,final:!0,index:r.length,payloads:[]},n,r.length)}async function sendHandoverPart(e,t,n){for(let r=1,i=1;;r++)try{return await sendSessionHandoverPartStep({bufferedPayloadCount:n,part:e,sessionId:t})}catch(n){r===HANDOVER_PART_FAILURES_BEFORE_REPORT&&await reportHandoverPartStuckStep({attemptKey:e.attemptKey,error:isObject(n)&&typeof n.message==`string`?n.message:void 0,failures:r,index:e.index,sessionId:t}).catch(()=>{}),await sleep(i*1e3),i=Math.min(i*2,60)}}const HANDOVER_PART_FAILURES_BEFORE_REPORT=5;var SessionHandoff=class{input;anchor;incompatibleTargetDeploymentIds=new Set;attempts=0;worldUnsupported=!1;constructor(e){this.input=e}async tryTransfer(e,t){let{delivery:n}=e,r=readAcceptedDeploymentId(n);return r===void 0?{kind:`retained`,reason:`missing-deployment`}:r===this.input.deploymentId?{kind:`retained`,reason:`same-deployment`}:this.incompatibleTargetDeploymentIds.has(r)?{kind:`retained`,reason:`known-incompatible`}:e.handoffEligible?await this.transfer(t,r,{delivery:n}):{kind:`retained`,reason:`busy`}}async tryCompactionTransfer(e){let{deploymentId:t}=this.input;return this.incompatibleTargetDeploymentIds.has(t)?{kind:`retained`,reason:`known-incompatible`}:await this.transfer(e,t,{reason:`compaction`})}async tryPrewarmTransfer(e,t,n){return t===this.input.deploymentId?{kind:`retained`,reason:`same-deployment`}:this.incompatibleTargetDeploymentIds.has(t)?{kind:`retained`,reason:`known-incompatible`}:await this.transfer(e,t,{reason:`prewarm`,sessionTimeoutDeadline:n})}async transfer(e,t,n){let{inbox:r}=this.input;if(this.worldUnsupported)return{kind:`retained`,reason:`unsupported-world`};if(r.awaitingHandover)return{kind:`retained`,reason:`busy`};if(!isSessionStateIdleForHandoff(e))return{kind:`retained`,reason:`not-idle`};let i=getWorkflowMetadata().workflowRunId,a=this.attempts++,o=`${i}:${String(a)}`,s=r.claimedTokens,c=createHook({token:`${i}:handoff:${String(a)}`});this.ensureAnchor();let l=new AbortController,u=Date.now();try{let a;try{let r=await startSuccessorStep({...n,activationToken:c.token,anchorRunId:this.input.sessionId,attemptKey:o,checkpoint:{...this.input.checkpoint,...e,version:17},hookTokens:s,sessionWritable:this.input.sessionWritable,sourceRunId:i,targetDeploymentId:t});if(r.kind===`not-idle`)return{kind:`retained`,reason:`not-idle`};if(r.kind===`unsupported`)return this.worldUnsupported=!0,{kind:`retained`,reason:`unsupported-world`};a=r.runId}catch(e){let n=await this.fenceAttempt(o);if(n.kind!==`live`)return n.kind===`done`&&await this.holdEveryToken(s),await this.reportRetained(`activation-failed`,t,e),{kind:`retained`,reason:`activation-failed`};a=n.runId}let d=r.whenTakenOver(l.signal).then(()=>({kind:`taken-over`})),f,p;for(;;){if(f===void 0&&p===void 0&&r.hasPending()){let e=u+3e5-Date.now();p=sleep(Math.max(0,e)).then(()=>({kind:`deadline`}))}let e;try{e=await Promise.race([d,c.then(e=>({kind:`verdict`,verdict:e})),f===void 0?p??r.whenArrival().then(()=>({kind:`arrival`})):f.ended.then(()=>({kind:`candidate-ended`}))])}finally{f?.stop()}if(e.kind===`taken-over`)return await this.handOver(o);if(e.kind===`arrival`)continue;let n=e.kind===`candidate-ended`?a:verdictRunId(e),i=await this.fenceAttempt(o,n);if(i.kind===`live`){a=i.runId,f=watchRunEnd(a);continue}i.kind===`done`&&i.runId!==verdictRunId(e)&&await this.holdEveryToken(s);let l=e.kind===`verdict`?await this.recover(e.verdict,{attemptKey:o,candidateRunId:a,hookTokens:s,targetDeploymentId:t}):this.recoverFromSilentCandidate(e.kind);return await this.reportRetained(l.reason,t,l.error),{kind:`retained`,reason:l.reason}}}finally{l.abort(),await disposeHook(c)}}async adoptTakeover(){return await reportSessionTakenOverOutsideAttemptStep({sessionId:this.input.sessionId}),this.ensureAnchor(),{kind:`transferred`}}async fenceAttempt(e,t){let n=createHook({experimental_minRetention:`7d`,token:handoffLeaseToken(e)});try{await claimHookOwnership(n)}catch(e){if(!isHookConflictError(e)||typeof e.conflictingRunId!=`string`)throw e;let n=e.conflictingRunId;return n===t||await hasRunEndedStep({runId:n})?{kind:`done`,runId:n}:{kind:`live`,runId:n}}return{kind:`won`}}async handOver(e){return await sendSessionHandover({attemptKey:e,payloads:this.input.inbox.drain(),sessionId:this.input.sessionId}),{kind:`transferred`}}async holdEveryToken(e){await this.input.inbox.claimSessionHooks(e,{force:!0})}recoverFromSilentCandidate(e){return{error:Error(e===`deadline`?`The successor run did not report within 5 minutes.`:`The successor run ended before the handoff settled.`),reason:`activation-failed`}}async recover(e,t){let{inbox:n}=this.input;switch(e.kind){case`active`:return{error:Error(`Successor reported active without a takeover.`),reason:`activation-failed`};case`incompatible`:return this.incompatibleTargetDeploymentIds.add(t.targetDeploymentId),e.payloads.length>0&&n.restore(e.payloads),{reason:`checkpoint-incompatible`};case`failed`:return e.claimedHooks===!0?(await n.claimSessionHooks(t.hookTokens,{force:!0,handover:t.attemptKey}),abandonHandoverIfRunEnds(n,{attemptKey:t.attemptKey,sourceRunId:e.runId??t.candidateRunId})):isHookConflictError(e.error)&&this.incompatibleTargetDeploymentIds.add(t.targetDeploymentId),e.payloads.length>0&&n.restore(e.payloads),{error:e.error,reason:`activation-failed`}}}ensureAnchor(){this.input.isInitialOwner&&this.anchor===void 0&&(this.anchor=createHook({token:sessionAnchorToken(this.input.sessionId)}))}async awaitAnchoredResult(){if(this.anchor===void 0)throw Error(`Session anchor was never claimed.`);try{return await this.anchor}finally{await this.disposeAnchor()}}async disposeAnchor(){if(this.anchor===void 0)return;let e=this.anchor;this.anchor=void 0,await disposeHook(e)}async reportRetained(e,t,n){let r=isObject(n)&&typeof n.message==`string`?n.message:void 0;await reportSessionHandoffRetainedStep({error:r,reason:e,sessionId:this.input.sessionId,sourceDeploymentId:this.input.deploymentId,targetDeploymentId:t})}};export{HANDOFF_LEASE_RETENTION,SESSION_CHECKPOINT_VERSION,SessionHandoff,handoffLeaseToken,sendSessionHandover,sessionAnchorToken};
1
+ import{isObject}from"#shared/guards.js";import{createHook,getWorkflowMetadata,sleep}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{hasRunEndedStep,reportHandoverPartStuckStep,reportSessionHandoffRetainedStep,reportSessionTakenOverOutsideAttemptStep,sendSessionHandoverPartStep,startSuccessorStep}from"#execution/session/handoff-steps.js";import{abandonHandoverIfRunEnds,watchRunEnd}from"#execution/session/run-watch.js";import{isSessionStateIdleForHandoff}from"#execution/session/handoff-state.js";import{readAcceptedDeploymentId}from"#execution/session/accepted-deployment.js";const SESSION_CHECKPOINT_VERSION=18;function sessionAnchorToken(e){return`${e}:anchor`}function handoffLeaseToken(e){return`eve:handoff:lease:${e}`}const HANDOFF_LEASE_RETENTION=`7d`;function verdictRunId(e){return e.kind===`verdict`&&e.verdict.kind!==`active`?e.verdict.runId:void 0}async function sendSessionHandover(e){let{attemptKey:t,sessionId:n}=e,r=e.payloads.filter(e=>e.kind!==`handover`);for(let[e,i]of r.entries())if(await sendHandoverPart({attemptKey:t,index:e,payloads:[i]},n,r.length)===`session-ended`)return;await sendHandoverPart({attemptKey:t,final:!0,index:r.length,payloads:[]},n,r.length)}async function sendHandoverPart(e,t,n){for(let r=1,i=1;;r++)try{return await sendSessionHandoverPartStep({bufferedPayloadCount:n,part:e,sessionId:t})}catch(n){r===HANDOVER_PART_FAILURES_BEFORE_REPORT&&await reportHandoverPartStuckStep({attemptKey:e.attemptKey,error:isObject(n)&&typeof n.message==`string`?n.message:void 0,failures:r,index:e.index,sessionId:t}).catch(()=>{}),await sleep(i*1e3),i=Math.min(i*2,60)}}const HANDOVER_PART_FAILURES_BEFORE_REPORT=5;var SessionHandoff=class{input;anchor;incompatibleTargetDeploymentIds=new Set;attempts=0;worldUnsupported=!1;constructor(e){this.input=e}async tryTransfer(e,t){let{delivery:n}=e,r=readAcceptedDeploymentId(n);return r===void 0?{kind:`retained`,reason:`missing-deployment`}:r===this.input.deploymentId?{kind:`retained`,reason:`same-deployment`}:this.incompatibleTargetDeploymentIds.has(r)?{kind:`retained`,reason:`known-incompatible`}:e.handoffEligible?await this.transfer(t,r,{delivery:n}):{kind:`retained`,reason:`busy`}}async tryCompactionTransfer(e){let{deploymentId:t}=this.input;return this.incompatibleTargetDeploymentIds.has(t)?{kind:`retained`,reason:`known-incompatible`}:await this.transfer(e,t,{reason:`compaction`})}async tryPrewarmTransfer(e,t,n){return t===this.input.deploymentId?{kind:`retained`,reason:`same-deployment`}:this.incompatibleTargetDeploymentIds.has(t)?{kind:`retained`,reason:`known-incompatible`}:await this.transfer(e,t,{reason:`prewarm`,sessionTimeoutDeadline:n})}async transfer(e,t,n){let{inbox:r}=this.input;if(this.worldUnsupported)return{kind:`retained`,reason:`unsupported-world`};if(r.awaitingHandover)return{kind:`retained`,reason:`busy`};if(!isSessionStateIdleForHandoff(e))return{kind:`retained`,reason:`not-idle`};let i=getWorkflowMetadata().workflowRunId,a=this.attempts++,o=`${i}:${String(a)}`,s=r.claimedTokens,c=createHook({token:`${i}:handoff:${String(a)}`});this.ensureAnchor();let l=new AbortController,u=Date.now();try{let a;try{let r=await startSuccessorStep({...n,activationToken:c.token,anchorRunId:this.input.sessionId,attemptKey:o,checkpoint:{...this.input.checkpoint,...e,version:18},hookTokens:s,sessionWritable:this.input.sessionWritable,sourceRunId:i,targetDeploymentId:t});if(r.kind===`not-idle`)return{kind:`retained`,reason:`not-idle`};if(r.kind===`unsupported`)return this.worldUnsupported=!0,{kind:`retained`,reason:`unsupported-world`};a=r.runId}catch(e){let n=await this.fenceAttempt(o);if(n.kind!==`live`)return n.kind===`done`&&await this.holdEveryToken(s),await this.reportRetained(`activation-failed`,t,e),{kind:`retained`,reason:`activation-failed`};a=n.runId}let d=r.whenTakenOver(l.signal).then(()=>({kind:`taken-over`})),f,p;for(;;){if(f===void 0&&p===void 0&&r.hasPending()){let e=u+3e5-Date.now();p=sleep(Math.max(0,e)).then(()=>({kind:`deadline`}))}let e;try{e=await Promise.race([d,c.then(e=>({kind:`verdict`,verdict:e})),f===void 0?p??r.whenArrival().then(()=>({kind:`arrival`})):f.ended.then(()=>({kind:`candidate-ended`}))])}finally{f?.stop()}if(e.kind===`taken-over`)return await this.handOver(o);if(e.kind===`arrival`)continue;let n=e.kind===`candidate-ended`?a:verdictRunId(e),i=await this.fenceAttempt(o,n);if(i.kind===`live`){a=i.runId,f=watchRunEnd(a);continue}i.kind===`done`&&i.runId!==verdictRunId(e)&&await this.holdEveryToken(s);let l=e.kind===`verdict`?await this.recover(e.verdict,{attemptKey:o,candidateRunId:a,hookTokens:s,targetDeploymentId:t}):this.recoverFromSilentCandidate(e.kind);return await this.reportRetained(l.reason,t,l.error),{kind:`retained`,reason:l.reason}}}finally{l.abort(),await disposeHook(c)}}async adoptTakeover(){return await reportSessionTakenOverOutsideAttemptStep({sessionId:this.input.sessionId}),this.ensureAnchor(),{kind:`transferred`}}async fenceAttempt(e,t){let n=createHook({experimental_minRetention:`7d`,token:handoffLeaseToken(e)});try{await claimHookOwnership(n)}catch(e){if(!isHookConflictError(e)||typeof e.conflictingRunId!=`string`)throw e;let n=e.conflictingRunId;return n===t||await hasRunEndedStep({runId:n})?{kind:`done`,runId:n}:{kind:`live`,runId:n}}return{kind:`won`}}async handOver(e){return await sendSessionHandover({attemptKey:e,payloads:this.input.inbox.drain(),sessionId:this.input.sessionId}),{kind:`transferred`}}async holdEveryToken(e){await this.input.inbox.claimSessionHooks(e,{force:!0})}recoverFromSilentCandidate(e){return{error:Error(e===`deadline`?`The successor run did not report within 5 minutes.`:`The successor run ended before the handoff settled.`),reason:`activation-failed`}}async recover(e,t){let{inbox:n}=this.input;switch(e.kind){case`active`:return{error:Error(`Successor reported active without a takeover.`),reason:`activation-failed`};case`incompatible`:return this.incompatibleTargetDeploymentIds.add(t.targetDeploymentId),e.payloads.length>0&&n.restore(e.payloads),{reason:`checkpoint-incompatible`};case`failed`:return e.claimedHooks===!0?(await n.claimSessionHooks(t.hookTokens,{force:!0,handover:t.attemptKey}),abandonHandoverIfRunEnds(n,{attemptKey:t.attemptKey,sourceRunId:e.runId??t.candidateRunId})):isHookConflictError(e.error)&&this.incompatibleTargetDeploymentIds.add(t.targetDeploymentId),e.payloads.length>0&&n.restore(e.payloads),{error:e.error,reason:`activation-failed`}}}ensureAnchor(){this.input.isInitialOwner&&this.anchor===void 0&&(this.anchor=createHook({token:sessionAnchorToken(this.input.sessionId)}))}async awaitAnchoredResult(){if(this.anchor===void 0)throw Error(`Session anchor was never claimed.`);try{return await this.anchor}finally{await this.disposeAnchor()}}async disposeAnchor(){if(this.anchor===void 0)return;let e=this.anchor;this.anchor=void 0,await disposeHook(e)}async reportRetained(e,t,n){let r=isObject(n)&&typeof n.message==`string`?n.message:void 0;await reportSessionHandoffRetainedStep({error:r,reason:e,sessionId:this.input.sessionId,sourceDeploymentId:this.input.deploymentId,targetDeploymentId:t})}};export{HANDOFF_LEASE_RETENTION,SESSION_CHECKPOINT_VERSION,SessionHandoff,handoffLeaseToken,sendSessionHandover,sessionAnchorToken};
@@ -1,5 +1,10 @@
1
- import type { DeliverHookPayload, DeliverPayload } from "#channel/types.js";
1
+ import type { DeliverHookPayload, DeliverPayload, SessionAuthContext } from "#channel/types.js";
2
2
  export type SessionControl = "clear" | "compact" | "expired" | "reset";
3
+ /** The delivery a control arrived as: its id, and who sent it. */
4
+ export interface ControlOrigin {
5
+ readonly deliveryId: string;
6
+ readonly auth?: SessionAuthContext | null;
7
+ }
3
8
  export interface DeliveryAdmission {
4
9
  readonly delivery: DeliverHookPayload;
5
10
  readonly sequence: number;
@@ -19,6 +24,7 @@ export interface TurnSelection {
19
24
  export type SessionInputSelection = TurnSelection | {
20
25
  readonly control: SessionControl;
21
26
  readonly kind: "control";
27
+ readonly origin?: ControlOrigin;
22
28
  };
23
29
  /**
24
30
  * Ordered, admitted session input. Entries are private; callers receive typed
@@ -39,7 +45,7 @@ export declare class SessionInputQueue {
39
45
  /** The sequence the next admission receives; every earlier admission is below it. */
40
46
  get nextAdmission(): number;
41
47
  enqueueDelivery(delivery: DeliverHookPayload): DeliveryAdmission | undefined;
42
- enqueueControl(control: SessionControl): void;
48
+ enqueueControl(control: SessionControl, origin?: ControlOrigin): void;
43
49
  /** Keeps one payload per authorization attempt; a repeated callback for the same attempt is dropped. */
44
50
  enqueueAuthorization(payloads: readonly DeliverPayload[]): void;
45
51
  /**
@@ -1 +1 @@
1
- import{DELIVERY_IDEMPOTENCY_WINDOW}from"#channel/delivery-idempotency.js";import{coalesceDeliveries}from"#harness/messages.js";import{ANONYMOUS_PRINCIPAL,principalOf}from"#execution/session/principal.js";var SessionInputQueue=class{entries=[];admittedKeys;nextSequence=0;prewarmDeploymentId;prepareOnDeployment(e){this.prewarmDeploymentId=e}takePrewarmDeployment(){let e=this.prewarmDeploymentId;return this.prewarmDeploymentId=void 0,e}constructor(e){this.admittedKeys=new Set(e)}get admittedDeliveryKeys(){return[...this.admittedKeys]}isDuplicate(e){return e.idempotencyKey!==void 0&&this.admittedKeys.has(e.idempotencyKey)}get pendingCount(){return this.entries.length}get nextAdmission(){return this.nextSequence}enqueueDelivery(e){if(this.isDuplicate(e))return;e.idempotencyKey!==void 0&&(this.admittedKeys.add(e.idempotencyKey),this.admittedKeys.size>DELIVERY_IDEMPOTENCY_WINDOW&&this.admittedKeys.delete(this.admittedKeys.values().next().value)),this.prewarmDeploymentId=void 0;let t={delivery:e,sequence:this.nextSequence++};return this.entries.push({...t,kind:`delivery`}),t}enqueueControl(e){this.entries.push({control:e,kind:`control`,sequence:this.nextSequence++})}enqueueAuthorization(e){for(let t of e){let e=authorizationAttemptId(t);e!==void 0&&(this.entries.some(t=>t.kind===`authorization`&&t.attemptId===e)||this.entries.push({attemptId:e,kind:`authorization`,payload:t,sequence:this.nextSequence++}))}}takeAuthorizations(e){let t=this.entries.filter(t=>t.kind===`authorization`&&e.has(t.attemptId));if(!(t.length===0||new Set(t.map(e=>e.attemptId)).size<e.size))return this.retain(e=>!t.includes(e)),t.map(e=>e.payload)}delivery(e){return this.entries.find(t=>t.kind===`delivery`&&t.sequence===e)?.delivery}replaceDelivery(e,t){let n=this.entries.findIndex(t=>t.kind===`delivery`&&t.sequence===e);if(!(n<0)){if(t===void 0){this.entries.splice(n,1);return}this.entries[n]={delivery:t,kind:`delivery`,sequence:e}}}takeSteering(e,t,n){let r=this.entries.filter(r=>r.kind===`delivery`&&e.has(r.sequence)&&isSteeringDelivery(r.delivery,t,{heldOnPerson:n?.heldSince!==void 0&&r.sequence>=n.heldSince}));if(r.length!==0)return this.retain(e=>e.kind!==`delivery`||!r.includes(e)),{delivery:combine(r),handoffEligible:!1,kind:`turn`,sequences:r.map(({sequence:e})=>e)}}takeNext(e){this.retain(e=>e.kind!==`authorization`);let t=this.entries.shift();if(t===void 0)return;if(t.kind===`control`)return{control:t.control,kind:`control`};let n=[t,...this.takeFollowingDeliveriesFrom(t)],r=n.map(({sequence:e})=>e),i=combine(n);return{delivery:i,handoffEligible:r.length===1&&r[0]===e?.freshSequence&&i.caller===void 0&&this.entries.length===0,kind:`turn`,sequences:r}}takeFollowingDeliveriesFrom(e){let t=principalOf(e.delivery.auth),n=[],r=e.delivery.caller?.callId;for(;;){let e=this.entries[0];if(e?.kind!==`delivery`||t===ANONYMOUS_PRINCIPAL||principalOf(e.delivery.auth)!==t||r!==void 0&&e.delivery.caller!==void 0&&e.delivery.caller.callId!==r)break;n.push(e),this.entries.shift(),r??=e.delivery.caller?.callId}return n}retain(e){let t=this.entries.filter(e);this.entries.splice(0,this.entries.length,...t)}};function isSteeringDelivery(e,t,n){return(n?.heldOnPerson===!0||(e.turnPolicy??`steer`)===`steer`)&&(e.caller===void 0||e.caller.callId===t.callerCallId)&&(e.auth===void 0||principalOf(e.auth)===t.principal)}function isSteeringMessage(e,t){return isSteeringDelivery(e,t)&&e.payloads.some(e=>e.message!==void 0&&e.inputResponses===void 0)}function combine(e){return e.length===1?e[0].delivery:coalesceDeliveries(e.map(({delivery:e})=>e))}function authorizationAttemptId(e){let t=e.authorizationCallback;return typeof t?.attemptId==`string`?t.attemptId:void 0}export{SessionInputQueue,isSteeringDelivery,isSteeringMessage};
1
+ import{DELIVERY_IDEMPOTENCY_WINDOW}from"#channel/delivery-idempotency.js";import{coalesceDeliveries}from"#harness/messages.js";import{ANONYMOUS_PRINCIPAL,principalOf}from"#execution/session/principal.js";var SessionInputQueue=class{entries=[];admittedKeys;nextSequence=0;prewarmDeploymentId;prepareOnDeployment(e){this.prewarmDeploymentId=e}takePrewarmDeployment(){let e=this.prewarmDeploymentId;return this.prewarmDeploymentId=void 0,e}constructor(e){this.admittedKeys=new Set(e)}get admittedDeliveryKeys(){return[...this.admittedKeys]}isDuplicate(e){return e.idempotencyKey!==void 0&&this.admittedKeys.has(e.idempotencyKey)}get pendingCount(){return this.entries.length}get nextAdmission(){return this.nextSequence}enqueueDelivery(e){if(this.isDuplicate(e))return;e.idempotencyKey!==void 0&&(this.admittedKeys.add(e.idempotencyKey),this.admittedKeys.size>DELIVERY_IDEMPOTENCY_WINDOW&&this.admittedKeys.delete(this.admittedKeys.values().next().value)),this.prewarmDeploymentId=void 0;let t={delivery:e,sequence:this.nextSequence++};return this.entries.push({...t,kind:`delivery`}),t}enqueueControl(e,t){let n={control:e,kind:`control`,sequence:this.nextSequence++};t!==void 0&&(n.origin=t),this.entries.push(n)}enqueueAuthorization(e){for(let t of e){let e=authorizationAttemptId(t);e!==void 0&&(this.entries.some(t=>t.kind===`authorization`&&t.attemptId===e)||this.entries.push({attemptId:e,kind:`authorization`,payload:t,sequence:this.nextSequence++}))}}takeAuthorizations(e){let t=this.entries.filter(t=>t.kind===`authorization`&&e.has(t.attemptId));if(!(t.length===0||new Set(t.map(e=>e.attemptId)).size<e.size))return this.retain(e=>!t.includes(e)),t.map(e=>e.payload)}delivery(e){return this.entries.find(t=>t.kind===`delivery`&&t.sequence===e)?.delivery}replaceDelivery(e,t){let n=this.entries.findIndex(t=>t.kind===`delivery`&&t.sequence===e);if(!(n<0)){if(t===void 0){this.entries.splice(n,1);return}this.entries[n]={delivery:t,kind:`delivery`,sequence:e}}}takeSteering(e,t,n){let r=this.entries.filter(r=>r.kind===`delivery`&&e.has(r.sequence)&&isSteeringDelivery(r.delivery,t,{heldOnPerson:n?.heldSince!==void 0&&r.sequence>=n.heldSince}));if(r.length!==0)return this.retain(e=>e.kind!==`delivery`||!r.includes(e)),{delivery:combine(r),handoffEligible:!1,kind:`turn`,sequences:r.map(({sequence:e})=>e)}}takeNext(e){this.retain(e=>e.kind!==`authorization`);let t=this.entries.shift();if(t===void 0)return;if(t.kind===`control`)return t.origin===void 0?{control:t.control,kind:`control`}:{control:t.control,kind:`control`,origin:t.origin};let n=[t,...this.takeFollowingDeliveriesFrom(t)],r=n.map(({sequence:e})=>e),i=combine(n);return{delivery:i,handoffEligible:r.length===1&&r[0]===e?.freshSequence&&i.caller===void 0&&this.entries.length===0,kind:`turn`,sequences:r}}takeFollowingDeliveriesFrom(e){let t=principalOf(e.delivery.auth),n=[],r=e.delivery.caller?.callId;for(;;){let e=this.entries[0];if(e?.kind!==`delivery`||t===ANONYMOUS_PRINCIPAL||principalOf(e.delivery.auth)!==t||r!==void 0&&e.delivery.caller!==void 0&&e.delivery.caller.callId!==r)break;n.push(e),this.entries.shift(),r??=e.delivery.caller?.callId}return n}retain(e){let t=this.entries.filter(e);this.entries.splice(0,this.entries.length,...t)}};function isSteeringDelivery(e,t,n){return(n?.heldOnPerson===!0||(e.turnPolicy??`steer`)===`steer`)&&(e.caller===void 0||e.caller.callId===t.callerCallId)&&(e.auth===void 0||principalOf(e.auth)===t.principal)}function isSteeringMessage(e,t){return isSteeringDelivery(e,t)&&e.payloads.some(e=>e.message!==void 0&&e.answers===void 0)}function combine(e){return e.length===1?e[0].delivery:coalesceDeliveries(e.map(({delivery:e})=>e))}function authorizationAttemptId(e){let t=e.authorizationCallback;return typeof t?.attemptId==`string`?t.attemptId:void 0}export{SessionInputQueue,isSteeringDelivery,isSteeringMessage};
@@ -0,0 +1,64 @@
1
+ import type { ContextContainer } from "#context/container.js";
2
+ import type { OrphanedLine } from "#execution/publish-session-events.js";
3
+ import type { DurableStepResult } from "#execution/session/turn-step-types.js";
4
+ import { type InterruptedCall } from "#harness/interrupted-attempt.js";
5
+ import type { ControlDelivery, HarnessSession, HarnessStepInput } from "#harness/types.js";
6
+ import type { SessionEvent } from "#protocol/session-event.js";
7
+ import type { SessionOutcome } from "#protocol/session-events/families/session.js";
8
+ /** What an interrupted earlier attempt of a turn step published past the step's checkpoint. */
9
+ export interface InterruptedAttempt {
10
+ /** The first line it wrote. */
11
+ readonly since: number;
12
+ readonly calls: ReadonlyMap<string, InterruptedCall>;
13
+ /** The interactions it settled, such as approvals it applied. */
14
+ readonly settledInteractions: ReadonlySet<string>;
15
+ /** It ended the session. */
16
+ readonly sessionEnded: SessionOutcome | undefined;
17
+ /** It cleared the history. */
18
+ readonly cleared: boolean;
19
+ /** It settled a turn: the last one, with the reply's text. */
20
+ readonly settledTurn?: {
21
+ readonly failed: boolean;
22
+ readonly text?: string;
23
+ };
24
+ }
25
+ export declare function readInterruptedAttempt(since: number, lines: readonly OrphanedLine[]): InterruptedAttempt;
26
+ /**
27
+ * Recovers a turn step whose earlier attempt published past the checkpoint. The orphaned lines
28
+ * are already folded into the step's projection, so what the step writes follows them.
29
+ *
30
+ * What the attempt left open closes as superseded, and the step runs again from its checkpoint:
31
+ * the calls the attempt started never run again, and the model reads which may have run. When
32
+ * the attempt ended the session or settled its turn, nothing is left to run. The ending keeps
33
+ * its outcome and recorded reply output; a settled turn keeps its input and reply in history.
34
+ * A step that failed every attempt (`failed`) fails the turn with the error its last attempt
35
+ * threw instead, and a turn interrupted too often fails too.
36
+ *
37
+ * Returns the step's result when it ends here, or the session the step runs on with. Its own
38
+ * new facts use normal reactions; facts already recorded are only adopted.
39
+ */
40
+ export declare function recoverInterruptedStep(input: {
41
+ readonly attempt: InterruptedAttempt;
42
+ readonly ctx: ContextContainer;
43
+ readonly publish: (events: SessionEvent | readonly SessionEvent[], session: HarnessSession) => Promise<HarnessSession>;
44
+ readonly session: HarnessSession;
45
+ readonly stepInput: HarnessStepInput | undefined;
46
+ /** Admission facts no attempt wrote, which a step that ends here must still write. */
47
+ readonly admission: readonly SessionEvent[];
48
+ /** The control the step applies, with the delivery it arrived as. */
49
+ readonly control?: {
50
+ readonly kind: "clear" | "compact";
51
+ readonly delivery?: ControlDelivery;
52
+ };
53
+ /** The error the step's last attempt threw, when every attempt failed. */
54
+ readonly failed?: {
55
+ readonly error: unknown;
56
+ };
57
+ }): Promise<{
58
+ readonly result: DurableStepResult;
59
+ } | {
60
+ readonly session: HarnessSession;
61
+ readonly stepInput: HarnessStepInput | undefined;
62
+ }>;
63
+ /** How many interrupted steps one turn runs again before it fails. */
64
+ export declare const MAX_TURN_INTERRUPTIONS = 3;
@@ -0,0 +1,3 @@
1
+ import{createErrorId,createLogger}from"#internal/logging.js";import{eventsOfLine}from"#protocol/session-lines.js";import{currentProjection,saveSessionProjection}from"#harness/session-machine/current.js";import{rowOf}from"#protocol/session-projection/tree.js";import{serializeContext}from"#context/serialize.js";import{createImportedHistoryMessages}from"#harness/messages.js";import{applyTransition,dropClosedRecords,saveTransition,sessionView}from"#harness/session-machine/commit.js";import{fail,receive,stopInterruptedSteps}from"#harness/session-machine/transitions.js";import{controlAdmitted,fact}from"#harness/facts.js";import{activeTurnIdOf}from"#protocol/session-projection.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{supersede}from"#harness/session-machine/cascade.js";import{preserveStoppedTurnMessage}from"#execution/cancelled-model-call-batch.js";import{resolveSessionStepResult}from"#execution/session/turn-step-result.js";import{interruptedAttemptNote}from"#harness/interrupted-attempt.js";import{replaceSessionHistory}from"#harness/compaction/step.js";import{summarizeFailure}from"#execution/failure-summary.js";const log=createLogger(`execution.interrupted-step`);function readInterruptedAttempt(e,t){let n=new Map,r=new Map,i=new Set,a,o=!1,s,call=e=>{let t=n.get(e);return t===void 0&&n.set(e,t={name:``,started:!1}),t};for(let{line:e,position:n}of t)if(`facts`in e)for(let t of eventsOfLine(e,n,e.at))switch(t.type){case`call.requested`:Object.assign(call(t.data.callId),{input:t.data.input,name:t.data.capability.name});break;case`call.started`:call(t.data.callId).started=!0;break;case`call.settled`:call(t.data.callId).outcome=t.data.outcome;break;case`interaction.settled`:i.add(t.data.interactionId);break;case`content.completed`:t.data.kind===`text`&&typeof t.data.value==`string`&&r.set(t.data.partId,t.data.value);break;case`turn.settled`:{let e=(t.data.reply??[]).flatMap(e=>r.get(e)??[]);s={failed:t.data.outcome===`failed`,...e.length>0&&{text:e.join(`
2
+
3
+ `)}};break}case`session.ended`:a=t.data.outcome;break;case`context.settled`:t.data.kind===`clear`&&t.data.outcome===`completed`&&(o=!0)}return{calls:n,cleared:o,sessionEnded:a,settledInteractions:i,settledTurn:s,since:e}}async function recoverInterruptedStep(e){let{attempt:t,ctx:n}=e,r=e.session,publish=async t=>{r=await e.publish(t,r)},view=()=>sessionView(currentProjection(n),r.state),closeAttempt=async e=>{let t=currentProjection(n).view,r=supersede(t,n=>{let r=rowOf(t,n.family,n.id);return r!==void 0&&e(n,r)},`step-interrupted`);r.length>0&&await publish(r)},introduced=e=>e.introducedAt>=t.since,finish=e=>{let t=saveSessionProjection(dropClosedRecords(reconcileSessionContinuationToken(n,e.session),currentProjection(n)),n);return{result:resolveSessionStepResult({...e,session:t},serializeContext(n))}};if(t.sessionEnded!==void 0)return finish({next:{done:!0,isError:t.sessionEnded===`failed`,output:t.settledTurn?.text??``},session:r});if(e.control!==void 0){if(await closeAttempt(({family:e},t)=>(e===`run`||e===`change`)&&introduced(t)),t.cleared){let e=saveTransition(r,{clearsHistory:!0,events:[],signIns:[],turn:{remembered:view().turn.remembered,suspended:[]}});r=replaceSessionHistory(e,[])}let{delivery:i,kind:a}=e.control,o=i===void 0?void 0:currentProjection(n).view.deliveries[i.deliveryId]?.status;return i!==void 0&&o!==`settled`&&await publish([...o===void 0?[controlAdmitted(i,a)]:[],fact(`delivery.settled`,{deliveryId:i.deliveryId,outcome:`failed`,reason:`${a}-interrupted`})]),finish({next:null,session:r})}let{settledTurn:i}=t;if(i!==void 0&&activeTurnIdOf(currentProjection(n))===void 0)return r={...r,history:[...r.history,...createImportedHistoryMessages(e.stepInput?.history??[])]},r=await preserveStoppedTurnMessage(n,r,e.stepInput),i.text!==void 0&&(r={...r,history:[...r.history,{content:i.text,role:`assistant`}]}),finish({next:null,session:r,settledTurn:{isError:i.failed,output:i.text??``}});let a=stopInterruptedSteps(view(),t),o=new Set(view().turn.suspended.filter(e=>!a.turn.suspended.includes(e)).flatMap(e=>e.requests.map(e=>e.interactionId)));await closeAttempt(({family:e,id:n},r)=>{switch(e){case`run`:case`change`:return introduced(r);case`call`:return r.taskId===void 0&&(introduced(r)||t.calls.get(n)?.started===!0);case`interaction`:return!view().relayedRequestIds.has(n)&&(introduced(r)||o.has(n));default:return!1}});let s=activeTurnIdOf(currentProjection(n)),c=s===void 0?0:turnInterruptions(r.state,s)+1;r=saveTransition(r,a);let l=interruptedAttemptNote(t.calls);if(l!==void 0&&(r={...r,history:[...r.history,l]}),e.failed===void 0&&c<=3){let{settledInteractions:n}=t,i=e.stepInput?.answers?.filter(e=>!n.has(e.interactionId));return{session:s===void 0?r:withTurnInterruptions(r,s,c),stepInput:e.stepInput===void 0?void 0:{...e.stepInput,answers:i}}}e.admission.length>0&&await publish(e.admission);let u=(e.stepInput?.deliveries??[]).filter(({deliveryId:e})=>currentProjection(n).view.deliveries[e]?.status===`admitted`);u.length>0&&await publish(receive(view(),{deliveries:u}).events);let d=activeTurnIdOf(currentProjection(n));if(d===void 0)return finish({next:null,session:r});r=await preserveStoppedTurnMessage(n,r,e.stepInput);let f=e.failed===void 0?{code:`STEP_INTERRUPTED`,details:{errorId:createErrorId()},message:`This turn was interrupted too many times to continue.`}:summarizeFailure(e.failed.error,`STEP_FAILED`);return log.error(`turn failed`,{code:f.code,errorId:f.details.errorId,sessionId:r.sessionId,turnId:d}),r=await applyTransition(r,fail(view(),f),publish),finish({next:null,session:r,settledTurn:{isError:!0,output:f.message}})}const INTERRUPTIONS_STATE_KEY=`eve.turn-interruptions`,MAX_TURN_INTERRUPTIONS=3;function turnInterruptions(e,t){let n=e?.[INTERRUPTIONS_STATE_KEY];return n?.turnId===t?n.count:0}function withTurnInterruptions(e,t,n){return{...e,state:{...e.state,[INTERRUPTIONS_STATE_KEY]:{count:n,turnId:t}}}}export{MAX_TURN_INTERRUPTIONS,readInterruptedAttempt,recoverInterruptedStep};
@@ -1,4 +1,5 @@
1
- import type { SessionControl, SessionInputQueue, TurnSelection } from "#execution/session/input-queue.js";
1
+ import type { ControlSettlement } from "#harness/facts.js";
2
+ import type { ControlOrigin, SessionControl, SessionInputQueue, TurnSelection } from "#execution/session/input-queue.js";
2
3
  import type { SessionInboxReader } from "#execution/session-inbox/inbox.js";
3
4
  import type { SessionStateCursor } from "#execution/session/state-cursor.js";
4
5
  import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.js";
@@ -10,14 +11,17 @@ export type NextTurnInstruction = {
10
11
  readonly message: WorkflowToolRunMessage;
11
12
  } | {
12
13
  readonly kind: SessionControl;
14
+ readonly origin?: ControlOrigin;
13
15
  } | {
14
16
  readonly kind: "closed";
15
17
  } | {
16
18
  readonly kind: "cancel-turn";
19
+ readonly origin?: ControlOrigin;
17
20
  }
18
21
  /** `session.cancel()` while no turn runs, but tasks are working. */
19
22
  | {
20
23
  readonly kind: "cancel-working-tasks";
24
+ readonly origin?: ControlOrigin;
21
25
  } | TurnSelection;
22
26
  /**
23
27
  * Waits for the next input the parked owner must act on. Fully routed
@@ -28,4 +32,6 @@ export declare function nextTurnDelivery(input: {
28
32
  readonly cursor: SessionStateCursor;
29
33
  readonly hasWorkingTasks: () => boolean;
30
34
  readonly queue: SessionInputQueue;
35
+ /** Settles a control that changes nothing; a session that hasn't started defers it. */
36
+ readonly ignore: (settlement: ControlSettlement) => Promise<void>;
31
37
  }): Promise<NextTurnInstruction>;
@@ -1 +1 @@
1
- import{openInputs}from"#protocol/session-projection.js";import{storedProjection}from"#harness/session-machine/view.js";import{admitSessionInboxPayload}from"#execution/session/admission.js";import{routeSelectedDelivery}from"#execution/session/route-selected-delivery.js";async function nextTurnDelivery(e){let{inbox:t,cursor:n,queue:r}=e,i;for(;;){let a=r.takeNext({freshSequence:t.hasPending()?void 0:i});if(a?.kind===`control`)return{kind:a.control};if(a?.kind===`turn`){let e=await routeSelectedDelivery(a,n);if(e.kind===`cancel-turn`)return e;if(e.kind===`consumed`)continue;return e}if(!t.hasPending()){let e=r.takePrewarmDeployment();if(e!==void 0)return{kind:`prewarm`,targetDeploymentId:e}}let o=r.pendingCount===0,s=await t.next();if(s===void 0)return{kind:`closed`};let c=await admitSessionInboxPayload(s,e);if(i=o&&c.kind===`delivery`?c.admission.sequence:void 0,c.kind===`workflow`)return{kind:`workflow`,message:c.message};if(c.kind===`cancel`&&openInputs(storedProjection(n.sessionState.snapshot.session.state)).some(e=>e.request.kind===`session-limit`))return{kind:`cancel-turn`};if(c.kind===`cancel`&&e.hasWorkingTasks())return{kind:`cancel-working-tasks`}}}export{nextTurnDelivery};
1
+ import{openRequests}from"#protocol/session-projection/reader.js";import{storedProjection}from"#harness/session-machine/view.js";import{readDurableSession}from"#execution/durable-session-read.js";import{activeTurnIdOf}from"#protocol/session-projection.js";import{controlDeliveryOf}from"#execution/session/control-delivery.js";import{admitSessionInboxPayload}from"#execution/session/admission.js";import{routeSelectedDelivery}from"#execution/session/route-selected-delivery.js";async function nextTurnDelivery(e){let{inbox:t,cursor:n,queue:r}=e,i;for(;;){let a=r.takeNext({freshSequence:t.hasPending()?void 0:i});if(a?.kind===`control`)return a.origin===void 0?{kind:a.control}:{kind:a.control,origin:a.origin};if(a?.kind===`turn`){let e=await routeSelectedDelivery(a,n);if(e.kind===`cancel-turn`)return e;if(e.kind===`consumed`)continue;return e}if(!t.hasPending()){let e=r.takePrewarmDeployment();if(e!==void 0)return{kind:`prewarm`,targetDeploymentId:e}}let o=r.pendingCount===0,s=await t.next();if(s===void 0)return{kind:`closed`};let c=await admitSessionInboxPayload(s,e);if(i=o&&c.kind===`delivery`?c.admission.sequence:void 0,c.kind===`workflow`)return{kind:`workflow`,message:c.message};if(c.kind!==`cancel`)continue;let l=storedProjection(readDurableSession(n.sessionState).state),u=l.view,d=s.kind===`cancel`&&s.turnId!==void 0&&s.turnId!==activeTurnIdOf(l);if(!d&&openRequests(u).some(e=>e.request.kind===`budget`))return{kind:`cancel-turn`,origin:c.origin};if(!d&&e.hasWorkingTasks())return{kind:`cancel-working-tasks`,origin:c.origin};c.origin!==void 0&&await e.ignore({control:controlDeliveryOf(c.origin),outcome:`ignored`,source:`cancel`})}}export{nextTurnDelivery};
@@ -1,17 +1,37 @@
1
1
  import type { TaskToolCall } from "#execution/tasks/calls.js";
2
2
  import type { HarnessSession } from "#harness/types.js";
3
- import { type SessionProjection } from "#protocol/session-projection.js";
3
+ import type { SessionProjection } from "#protocol/session-projection.js";
4
4
  /**
5
- * Derives the workflow fields used to select the next action at the park boundary. Whether the
6
- * session awaits input or a sign-in is the projection's; which callbacks resume it, and which
7
- * calls wait on the runtime, is execution state.
5
+ * What a paused turn waits on, which is one kind of thing at a time. The turn keeps it to resume;
6
+ * the stream reports the pause as `turn.paused`.
8
7
  */
9
- export declare function derivePendingState(session: HarnessSession, projection: SessionProjection): {
10
- readonly authorizationAttemptIds?: readonly string[];
11
- readonly hasPendingAuthorization: boolean;
12
- readonly hasPendingInputBatch: boolean;
13
- /** The pending batch has workflow tool runs to start; task tool calls are answered by the session. */
14
- readonly hasRunsToDispatch?: boolean;
15
- readonly pendingCoordinationCallIds?: readonly string[];
16
- readonly pendingTaskToolCalls?: readonly TaskToolCall[];
8
+ export type TurnPause =
9
+ /** Sign-ins whose callbacks resume the turn, and open questions and approvals. */
10
+ {
11
+ readonly on: "interaction";
12
+ readonly attemptIds: readonly string[];
13
+ readonly requestIds: readonly string[];
14
+ }
15
+ /** Working tasks. Any of them settling resumes the turn. */
16
+ | {
17
+ readonly on: "tasks";
18
+ readonly taskIds: readonly string[];
19
+ }
20
+ /**
21
+ * Calls whose results resume the turn, task tool calls included. `dispatch` starts their
22
+ * workflow tool runs before the wait; the session answers `taskToolCalls` itself.
23
+ */
24
+ | {
25
+ readonly on: "calls";
26
+ readonly callIds: readonly string[];
27
+ readonly dispatch: boolean;
28
+ readonly taskToolCalls: readonly TaskToolCall[];
17
29
  };
30
+ /** The turn waits on sign-ins and answers to its interactions. */
31
+ export declare function pausedOnInteraction(session: HarnessSession, projection: SessionProjection): TurnPause;
32
+ /** The model ended the turn while tasks work, so the turn waits for one of them. */
33
+ export declare function pausedOnTasks(taskIds: readonly string[]): TurnPause;
34
+ /** The turn waits on calls the runtime runs, or on none. */
35
+ export declare function pausedOnCalls(session: HarnessSession): TurnPause | undefined;
36
+ /** Whether the turn waits on a sign-in, an answer, or a call, which ends a batch of model calls. */
37
+ export declare function waitsOnAnything(session: HarnessSession, projection: SessionProjection): boolean;
@@ -1 +1 @@
1
- import{openSignIns}from"#protocol/session-projection.js";import{runtimeWait}from"#harness/session-machine/view.js";import{readHitlState}from"#harness/hitl/index.js";import{ownOpenRequestIds}from"#harness/session-machine/transitions.js";import{sessionView}from"#harness/session-machine/commit.js";function derivePendingState(e,t){let{signIns:n}=readHitlState(e.state),r={authorizationAttemptIds:n.length===0?void 0:n.flatMap(e=>e.attemptId===void 0?[]:[e.attemptId]),hasPendingAuthorization:openSignIns(t).length>0,hasPendingInputBatch:ownOpenRequestIds(sessionView(t,e.state)).size>0},i=runtimeWait(e.state);return i===void 0?r:{...r,hasRunsToDispatch:i.tasks.length>0,pendingCoordinationCallIds:i.callIds,pendingTaskToolCalls:i.taskToolCalls}}export{derivePendingState};
1
+ import{openSignIns}from"#protocol/session-projection/reader.js";import{ownOpenRequestIds,runtimeWait}from"#harness/session-machine/view.js";import{sessionView}from"#harness/session-machine/commit.js";function pausedOnInteraction(e,t){return{attemptIds:sessionView(t,e.state).signIns.flatMap(e=>e.attemptId===void 0?[]:[e.attemptId]),on:`interaction`,requestIds:[...ownOpenRequestIds(sessionView(t,e.state))]}}function pausedOnTasks(e){return{on:`tasks`,taskIds:e}}function pausedOnCalls(e){let t=runtimeWait(e.state);if(t!==void 0)return{callIds:t.callIds,dispatch:t.tasks.length>0,on:`calls`,taskToolCalls:t.taskToolCalls}}function waitsOnAnything(e,t){return openSignIns(t.view).length>0||ownOpenRequestIds(sessionView(t,e.state)).size>0||(runtimeWait(e.state)?.callIds.length??0)>0}export{pausedOnCalls,pausedOnInteraction,pausedOnTasks,waitsOnAnything};
@@ -1,5 +1,5 @@
1
1
  import { type DurableSessionState } from "#execution/durable-session-store.js";
2
- import { type SessionStateTransition } from "#execution/session/state-delta.js";
2
+ import type { SessionStateTransition } from "#execution/session/state-delta.js";
3
3
  interface SessionPrewarmInput {
4
4
  readonly serializedContext: Record<string, unknown>;
5
5
  readonly sessionState: DurableSessionState;
@@ -1 +1 @@
1
- import{createLogger}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{readDurableSession,replaceDurableSessionSnapshot}from"#execution/durable-session-store.js";import{withContextScope}from"#context/run-step.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{hydrateDurableSession,projectToDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{startSessionPrewarmers}from"#context/prewarm.js";const log=createLogger(`execution.session.prewarm`);async function prewarmSessionStep(e){"use step";return await withSessionStateDelta(e,prewarmSession)}async function prewarmSession(e){try{let t=await deserializeContext(e.serializedContext),n=resolveEffectiveAgentRuntime(t.require(BundleKey),t),r=hydrateDurableSession({compactionOverrides:{thresholdPercent:n.thresholdPercent},durable:readDurableSession(e.sessionState),turnAgent:n.turnAgent}),i=await withContextScope(t,r,async e=>(startSessionPrewarmers(t,`session`),{result:void 0,session:e}));return{serializedContext:serializeContext(t),sessionState:replaceDurableSessionSnapshot({session:projectToDurableSession(i.session),state:e.sessionState})}}catch(t){return log.warn(`session prewarm failed; the first turn does this work instead`,{error:t,sessionId:e.sessionState.sessionId}),{}}}export{prewarmSessionStep};
1
+ import{createLogger}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{withContextScope}from"#context/run-step.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{readDurableSession,replaceDurableSessionSnapshot}from"#execution/durable-session-store.js";import{hydrateDurableSession,projectToDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{withSessionStateDelta}from"#execution/session/step-state-delta.js";import{startSessionPrewarmers}from"#context/prewarm.js";const log=createLogger(`execution.session.prewarm`);async function prewarmSessionStep(e){"use step";return await withSessionStateDelta(e,prewarmSession)}async function prewarmSession(e){try{let t=await deserializeContext(e.serializedContext),n=resolveEffectiveAgentRuntime(t.require(BundleKey),t),r=hydrateDurableSession({compactionOverrides:{thresholdPercent:n.thresholdPercent},durable:readDurableSession(e.sessionState),turnAgent:n.turnAgent}),i=await withContextScope(t,r,async e=>(startSessionPrewarmers(t,`session`),{result:void 0,session:e}));return{serializedContext:serializeContext(t),sessionState:replaceDurableSessionSnapshot({session:projectToDurableSession(i.session),state:e.sessionState})}}catch(t){return log.warn(`session prewarm failed; the first turn does this work instead`,{error:t,sessionId:e.sessionState.sessionId}),{}}}export{prewarmSessionStep};
@@ -1 +1 @@
1
- import{STUB_CONTEXT_KEY}from"#tool-stubs/types.js";import{workingTasks}from"#execution/tasks/table.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import"#execution/session-inbox/inbox.js";import{signalSessionAnchorStep}from"#execution/session/handoff-steps.js";import{SessionInputQueue}from"#execution/session/input-queue.js";import{createTurnControl}from"#execution/session/turn-control.js";import{SessionHandoff,sessionAnchorToken}from"#execution/session/handoff.js";import{notifyCancelledTaskCallerStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{withStubPlayback}from"#execution/tool-stubs/playback.js";import{nextTurnDelivery}from"#execution/session/next-input.js";import{SessionExecution}from"#execution/session/turn.js";import{SessionStateCursor}from"#execution/session/state-cursor.js";import{cancelWorkingTasks,sessionTaskTable}from"#execution/tasks/session.js";import{finalizeSession}from"#execution/session/finalization.js";import{prewarmSessionStep}from"#execution/session/prewarm-step.js";function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runPreparedSession(e,t){let n=e.serializedContext[STUB_CONTEXT_KEY];n!==void 0&&n.rootSessionId===void 0&&(e.serializedContext[STUB_CONTEXT_KEY]={...n,rootSessionId:e.sessionId});let r=new SessionStateCursor({history:e.history,inbox:t,sessionWritable:e.sessionWritable,serializedContext:e.serializedContext,sessionState:e.sessionState}),i={caller:e.caller},a=new SessionHandoff({checkpoint:{capabilities:e.capabilities,retention:e.retention,sessionTimeoutMs:e.sessionTimeoutMs},deploymentId:e.deploymentId,inbox:t,isInitialOwner:e.anchor.kind===`self`,sessionId:e.sessionId,sessionWritable:e.sessionWritable}),o={output:``,isError:!0},s,c=!1;try{return o=await withStubPlayback(n,e.sessionId,async()=>{try{s=await runSessionLoop(e,{cursor:r,handoff:a,inbox:t,progress:i})}finally{await t.dispose()}return s.kind===`transferred`?e.anchor.kind===`self`?(o=await a.awaitAnchoredResult(),o):{output:``}:(c=!0,o=await finalizeSession(s.outcome,{caller:i.caller,cursor:r,sessionWritable:e.sessionWritable}),o)}),o}catch(t){throw c||await finalizeSession({error:t,kind:`failed`,turnId:i.turnId},{caller:i.caller,cursor:r,sessionWritable:e.sessionWritable}),createSafeOuterWorkflowError()}finally{await t.dispose(),await reportResultToAnchor(e,o,a,s)}}async function failSession(e){let t;try{t=await resolveInitialTurnCallerStep({serializedContext:e.serializedContext})}catch{}throw await finalizeSession({error:e.error,kind:`failed`},{caller:t,cursor:{serializedContext:e.serializedContext,sessionState:e.sessionState},sessionWritable:e.sessionWritable}),createSafeOuterWorkflowError()}async function reportResultToAnchor(e,t,n,r){switch(e.anchor.kind){case`self`:await n.disposeAnchor(),await e.anchor.notify?.(t);return;case`successor`:if(r?.kind===`transferred`)return;await signalSessionAnchorStep({result:t,token:sessionAnchorToken(e.sessionId)});return}}async function runSessionLoop(e,t){let{cursor:n,handoff:r,inbox:i,progress:a}=t,o=new SessionInputQueue(e.admittedDeliveryKeys),s=new SessionExecution({capabilities:e.capabilities,cursor:n,inbox:i,queue:o,sessionId:e.sessionId}),c=e.sessionTimeoutControl,l=Promise.resolve(),u=!0,d=!1,nextParkedActivity=async()=>{for(;;){let e=await nextTurnDelivery({cursor:n,hasWorkingTasks:()=>workingTasks(sessionTaskTable(n)).length>0,inbox:i,queue:o});if(e.kind===`prewarm`){if(u&&a.caller===void 0&&workingTasks(sessionTaskTable(n)).length===0&&o.pendingCount===0&&!i.hasPending()){let t=c?.getDeadline(),n=await r.tryPrewarmTransfer(transferState(),e.targetDeploymentId,t);if(n.kind===`transferred`)return n}continue}if(e.kind===`workflow`){await s.handleWorkflowMessage(e.message);continue}if(e.kind===`cancel-working-tasks`){await cancelWorkingTasks(n,`turn_cancelled`);continue}if(!(e.kind===`expired`&&c!==void 0&&((o.pendingCount>0||i.hasPending())&&c.recordActivity(),await c.handleTimerElapsed()===`extended`)))return e}},f=e.initialTurnControl??(e.anchor.kind===`self`?createTurnControl():void 0),p=0,m=!1,runTurn=async e=>{let t=a.caller,n=f;f=void 0,a.turnId=`turn_${String(p++)}`;let r=await s.runTurn(e,{caller:t,control:n});return c?.recordActivity(),r.caller!==void 0&&(a.caller=r.caller),r.compacted===!0&&(m=!0),r},transferState=()=>({admittedDeliveryKeys:o.admittedDeliveryKeys,history:n.history,serializedContext:n.serializedContext,sessionState:n.sessionState}),compactionHandoffReady=()=>m&&a.caller===void 0&&workingTasks(sessionTaskTable(n)).length===0,tryCompactionHandoff=async()=>{if(!compactionHandoffReady()||o.pendingCount>0||i.hasPending())return;let e=await r.tryCompactionTransfer(transferState());return e.kind===`transferred`?e:void 0},runDeliveredTurn=async e=>{let t=await r.tryTransfer(e,transferState());return t.kind===`transferred`?t:(e.delivery.caller!==void 0&&(a.caller=e.delivery.caller),{action:await runTurn({delivery:e.delivery}),kind:`action`})},settleCancelledTurn=async e=>{let t=await n.advanceWithHistory(t=>settleCancelledTurnStep({...t,reportUsage:e}));return a.caller=void 0,t},awaitPrewarmedAction=async()=>{for(;;){let e=await nextParkedActivity();switch(d=!1,e.kind){case`closed`:return i.takenOver?await r.adoptTakeover():{kind:`terminal`,outcome:{kind:`expired`}};case`transferred`:return e;case`expired`:case`reset`:return{kind:`terminal`,outcome:{kind:`expired`}};case`clear`:case`compact`:continue;case`turn`:return await runDeliveredTurn(e);case`cancel-turn`:continue}}},runInitialAction=async()=>{switch(e.start.kind){case`first-message`:return d=!0,u=!1,l=n.advanceBeside(({serializedContext:e,sessionState:t})=>prewarmSessionStep({serializedContext:e,sessionState:t}),()=>d).then(()=>void 0,()=>void 0).finally(()=>{u=!0}),await awaitPrewarmedAction();case`parked`:return{action:{kind:`park`},kind:`action`};case`turn`:{let{input:t}=e.start;return{action:await runTurn(t===void 0?void 0:{delivery:t}),kind:`action`}}}};try{let[t,n]=await Promise.allSettled([runInitialAction(),c?.start()]);if(n.status===`rejected`)throw n.reason;if(t.status===`rejected`)throw t.reason;let o=t.value;if(o.kind!==`action`)return o;let l=o.action;for(;;){if(l.kind===`done`)return{kind:`terminal`,outcome:{action:l,kind:`done`}};if(l.cancelled===!0){let{caller:t}=a,n=await settleCancelledTurn(t!==void 0);if(t!==void 0){let r={caller:t,sessionId:e.sessionId};await notifyCancelledTaskCallerStep(n.usage===void 0?r:{...r,usage:n.usage})}}else l.settled!==void 0&&(a.caller!==void 0&&await notifyTurnCallerStep({caller:a.caller,lifecycle:`parked`,sessionId:e.sessionId,settled:l.settled}),a.caller=void 0);let t=await tryCompactionHandoff();if(t!==void 0)return t;f??=createTurnControl();let n=await nextParkedActivity();switch(n.kind){case`closed`:return i.takenOver?await r.adoptTakeover():{kind:`terminal`,outcome:{kind:`expired`}};case`transferred`:return n;case`expired`:case`reset`:return{kind:`terminal`,outcome:{kind:`expired`}};case`clear`:case`compact`:l=await runTurn({control:n.kind});continue;case`cancel-turn`:await s.cancelTurnWork(),await settleCancelledTurn(!1),c?.recordActivity(),l={...l,settled:void 0};continue;case`turn`:{let e=await runDeliveredTurn(n);if(e.kind!==`action`)return e;l=e.action;continue}}}}finally{d=!1,await l,await c?.dispose()}}export{failSession,runPreparedSession};
1
+ import{STUB_CONTEXT_KEY}from"#tool-stubs/types.js";import{storedProjection}from"#harness/session-machine/view.js";import{workingTasks}from"#execution/tasks/table.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import{turnCoordinates}from"#protocol/session-projection.js";import"#execution/session-inbox/inbox.js";import{signalSessionAnchorStep}from"#execution/session/handoff-steps.js";import{controlDeliveryOf}from"#execution/session/control-delivery.js";import{settleControlDeliveryStep}from"#execution/session/settle-control-delivery-step.js";import{SessionInputQueue}from"#execution/session/input-queue.js";import{createTurnControl}from"#execution/session/turn-control.js";import{SessionHandoff,sessionAnchorToken}from"#execution/session/handoff.js";import{notifyCancelledTaskCallerStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{withStubPlayback}from"#execution/tool-stubs/playback.js";import{nextTurnDelivery}from"#execution/session/next-input.js";import{SessionExecution}from"#execution/session/turn.js";import{SessionStateCursor}from"#execution/session/state-cursor.js";import{cancelWorkingTasks,sessionTaskTable}from"#execution/tasks/session.js";import{finalizeSession}from"#execution/session/finalization.js";import{prewarmSessionStep}from"#execution/session/prewarm-step.js";function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runPreparedSession(e,t){let n=e.serializedContext[STUB_CONTEXT_KEY];n!==void 0&&n.rootSessionId===void 0&&(e.serializedContext[STUB_CONTEXT_KEY]={...n,rootSessionId:e.sessionId});let r=new SessionStateCursor({history:e.history,inbox:t,sessionWritable:e.sessionWritable,serializedContext:e.serializedContext,sessionState:e.sessionState}),i={caller:e.caller},a=new SessionHandoff({checkpoint:{capabilities:e.capabilities,retention:e.retention,sessionTimeoutMs:e.sessionTimeoutMs},deploymentId:e.deploymentId,inbox:t,isInitialOwner:e.anchor.kind===`self`,sessionId:e.sessionId,sessionWritable:e.sessionWritable}),o={output:``,isError:!0},s,c=!1;try{return o=await withStubPlayback(n,e.sessionId,async()=>{try{s=await runSessionLoop(e,{cursor:r,handoff:a,inbox:t,progress:i})}finally{await t.dispose()}return s.kind===`transferred`?e.anchor.kind===`self`?(o=await a.awaitAnchoredResult(),o):{output:``}:(c=!0,o=await finalizeSession(s.outcome,{caller:i.caller,cursor:r,sessionWritable:e.sessionWritable}),o)}),o}catch(t){throw c||await finalizeSession({error:t,kind:`failed`,turnId:i.turnId},{caller:i.caller,cursor:r,sessionWritable:e.sessionWritable}),createSafeOuterWorkflowError()}finally{await t.dispose(),await reportResultToAnchor(e,o,a,s)}}async function failSession(e){let t;try{t=await resolveInitialTurnCallerStep({serializedContext:e.serializedContext})}catch{}throw await finalizeSession({error:e.error,kind:`failed`},{caller:t,cursor:{serializedContext:e.serializedContext,sessionState:e.sessionState},sessionWritable:e.sessionWritable}),createSafeOuterWorkflowError()}async function reportResultToAnchor(e,t,n,r){switch(e.anchor.kind){case`self`:await n.disposeAnchor(),await e.anchor.notify?.(t);return;case`successor`:if(r?.kind===`transferred`)return;await signalSessionAnchorStep({result:t,token:sessionAnchorToken(e.sessionId)});return}}async function runSessionLoop(e,t){let{cursor:n,handoff:r,inbox:i,progress:a}=t,o=new SessionInputQueue(e.admittedDeliveryKeys),s=new SessionExecution({capabilities:e.capabilities,cursor:n,inbox:i,queue:o,sessionId:e.sessionId}),c=e.sessionTimeoutControl,l=Promise.resolve(),u=!0,d=!1,f=[],started=()=>storedProjection(n.sessionState.snapshot.session.state).view.session.status!==`new`,ignore=async e=>{if(!started()){f.push(e);return}await n.advance(t=>settleControlDeliveryStep({...t,settlement:e}))},settleUnstarted=async()=>{if(started())for(let e of f.splice(0))await n.advance(t=>settleControlDeliveryStep({...t,settlement:e}))},expired=e=>({kind:`expired`,...e&&{control:e},...f.length>0&&{settles:f.splice(0)}}),nextParkedActivity=async()=>{for(;;){let e=await nextTurnDelivery({cursor:n,hasWorkingTasks:()=>workingTasks(sessionTaskTable(n)).length>0,ignore,inbox:i,queue:o});if(e.kind===`prewarm`){if(u&&a.caller===void 0&&workingTasks(sessionTaskTable(n)).length===0&&o.pendingCount===0&&!i.hasPending()){let t=c?.getDeadline(),n=await r.tryPrewarmTransfer(transferState(),e.targetDeploymentId,t);if(n.kind===`transferred`)return n}continue}if(e.kind===`workflow`){await s.handleWorkflowMessage(e.message);continue}if(e.kind===`cancel-working-tasks`){if(await cancelWorkingTasks(n,`turn-cancelled`),e.origin!==void 0){let t=controlDeliveryOf(e.origin);await n.advance(e=>settleControlDeliveryStep({...e,settlement:{control:t,outcome:`applied`,source:`cancel`}}))}continue}if(!(e.kind===`expired`&&c!==void 0&&((o.pendingCount>0||i.hasPending())&&c.recordActivity(),await c.handleTimerElapsed()===`extended`)))return e}},p=e.initialTurnControl??(e.anchor.kind===`self`?createTurnControl():void 0),m=!1,runTurn=async e=>{let t=a.caller,r=p;p=void 0,a.turnId=e?.control===void 0?turnCoordinates(storedProjection(n.sessionState.snapshot.session.state)).turnId:void 0;let i=await s.runTurn(e,{caller:t,control:r});return a.turnId=void 0,c?.recordActivity(),i.caller!==void 0&&(a.caller=i.caller),i.compacted===!0&&(m=!0),i},transferState=()=>({admittedDeliveryKeys:o.admittedDeliveryKeys,history:n.history,serializedContext:n.serializedContext,sessionState:n.sessionState}),compactionHandoffReady=()=>m&&a.caller===void 0&&workingTasks(sessionTaskTable(n)).length===0,tryCompactionHandoff=async()=>{if(!compactionHandoffReady()||o.pendingCount>0||i.hasPending())return;let e=await r.tryCompactionTransfer(transferState());return e.kind===`transferred`?e:void 0},runDeliveredTurn=async e=>{let t=await r.tryTransfer(e,transferState());return t.kind===`transferred`?t:(e.delivery.caller!==void 0&&(a.caller=e.delivery.caller),{action:await runTurn({delivery:e.delivery}),kind:`action`})},settleCancelledTurn=async(e,t)=>{let r=await n.advanceWithHistory(n=>settleCancelledTurnStep({...n,control:t,reportUsage:e}));return a.caller=void 0,r},awaitPrewarmedAction=async()=>{for(;;){let e=await nextParkedActivity();switch(d=!1,e.kind){case`reset`:return{kind:`terminal`,outcome:expired(e.origin&&controlDeliveryOf(e.origin))};case`closed`:return i.takenOver?await r.adoptTakeover():{kind:`terminal`,outcome:expired()};case`transferred`:return e;case`expired`:return{kind:`terminal`,outcome:expired()};case`clear`:case`compact`:e.origin!==void 0&&await ignore({control:controlDeliveryOf(e.origin),outcome:`ignored`,source:e.kind});continue;case`turn`:return await runDeliveredTurn(e);case`cancel-turn`:continue}}},runInitialAction=async()=>{switch(e.start.kind){case`first-message`:return d=!0,u=!1,l=n.advanceBeside(({serializedContext:e,sessionState:t})=>prewarmSessionStep({serializedContext:e,sessionState:t}),()=>d).then(()=>void 0,()=>void 0).finally(()=>{u=!0}),await awaitPrewarmedAction();case`parked`:return{action:{kind:`park`},kind:`action`};case`turn`:{let{input:t}=e.start;return{action:await runTurn(t===void 0?void 0:{delivery:t}),kind:`action`}}}};try{let[t,n]=await Promise.allSettled([runInitialAction(),c?.start()]);if(n.status===`rejected`)throw n.reason;if(t.status===`rejected`)throw t.reason;let o=t.value;if(o.kind!==`action`)return o;let l=o.action;for(;;){if(l.kind===`done`)return{kind:`terminal`,outcome:{action:l,kind:`done`}};if(await settleUnstarted(),l.cancelled===!0){let{caller:t}=a,n=await settleCancelledTurn(t!==void 0,l.cancelledBy);if(t!==void 0){let r={caller:t,sessionId:e.sessionId};await notifyCancelledTaskCallerStep(n.usage===void 0?r:{...r,usage:n.usage})}}else l.settled!==void 0&&(a.caller!==void 0&&await notifyTurnCallerStep({caller:a.caller,lifecycle:`parked`,sessionId:e.sessionId,settled:l.settled}),a.caller=void 0);let t=await tryCompactionHandoff();if(t!==void 0)return t;p??=createTurnControl();let n=await nextParkedActivity();switch(n.kind){case`reset`:return{kind:`terminal`,outcome:resetOutcome(n.origin)};case`closed`:return i.takenOver?await r.adoptTakeover():{kind:`terminal`,outcome:{kind:`expired`}};case`transferred`:return n;case`expired`:return{kind:`terminal`,outcome:{kind:`expired`}};case`clear`:case`compact`:l=await runTurn(n.origin===void 0?{control:n.kind}:{control:n.kind,controlDelivery:controlDeliveryOf(n.origin)});continue;case`cancel-turn`:await s.cancelTurnWork(),await settleCancelledTurn(!1,n.origin===void 0?void 0:controlDeliveryOf(n.origin)),c?.recordActivity(),l={...l,settled:void 0};continue;case`turn`:{let e=await runDeliveredTurn(n);if(e.kind!==`action`)return e;l=e.action;continue}}}}finally{d=!1,await l,await c?.dispose()}}function resetOutcome(e){return e===void 0?{kind:`expired`}:{control:controlDeliveryOf(e),kind:`expired`}}export{failSession,runPreparedSession};
@@ -0,0 +1,8 @@
1
+ import { type SessionStepState } from "#execution/publish-session-events.js";
2
+ import { type ControlSettlement } from "#harness/facts.js";
3
+ /** Records a control that finishes without a step of its own, at an owner's committed boundary. */
4
+ export declare function settleControlDeliveryStep(input: SessionStepState & {
5
+ readonly settlement: ControlSettlement;
6
+ }): Promise<Omit<import("#execution/publish-session-events.js").PublishedSessionEvents & {
7
+ readonly cancelled: boolean;
8
+ }, keyof import("./state-delta.ts").SessionStateValues> & import("./state-delta.ts").SessionStateTransition>;
@@ -0,0 +1 @@
1
+ import{publishSessionEvents}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/step-state-delta.js";import{controlSettled}from"#harness/facts.js";async function settleControlDeliveryStep(e){"use step";return await withSessionStateDelta(e,t=>publishSessionEvents(t,controlSettled(e.settlement)))}export{settleControlDeliveryStep};
@@ -0,0 +1,8 @@
1
+ import type { DeliverHookPayload } from "#channel/types.js";
2
+ import { type SessionStepState } from "#execution/publish-session-events.js";
3
+ /** A duplicate starts no work, but its distinct receipt must still settle. */
4
+ export declare function settleDuplicateDeliveryStep(input: SessionStepState & {
5
+ readonly delivery: DeliverHookPayload;
6
+ }): Promise<Omit<import("#execution/publish-session-events.js").PublishedSessionEvents & {
7
+ readonly cancelled: boolean;
8
+ }, keyof import("./state-delta.ts").SessionStateValues> & import("./state-delta.ts").SessionStateTransition>;
@@ -0,0 +1 @@
1
+ import{storedProjection}from"#harness/session-machine/view.js";import{readDurableSession}from"#execution/durable-session-store.js";import{publishSessionEvents}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/step-state-delta.js";import{admitDeliveries}from"#execution/session/delivery-facts.js";async function settleDuplicateDeliveryStep(e){"use step";return await withSessionStateDelta(e,t=>{let n=storedProjection(readDurableSession(t.sessionState).state).view,{facts:r}=admitDeliveries({channelKind:`http`,delivery:e.delivery,payloads:e.delivery.payloads.flatMap((t,r)=>{let i=e.delivery.deliveryMetadata?.find(e=>e.payloadIndex===r);return i!==void 0&&n.deliveries[i.deliveryId]!==void 0?[]:[{payload:t,input:void 0}]})});return publishSessionEvents(t,r.map(e=>e.type===`delivery.settled`?{...e,data:{...e.data,reason:`duplicate idempotency key`}}:e))})}export{settleDuplicateDeliveryStep};
@@ -24,17 +24,7 @@ export interface SessionStateTransition {
24
24
  /** `T` with its session values replaced by the delta that produces them. */
25
25
  export type WithSessionStateDelta<T> = T extends unknown ? Omit<T, keyof SessionStateValues> & SessionStateTransition : never;
26
26
  /**
27
- * Runs a session step's work and returns its result with the session values
28
- * it produced replaced by their delta from the values the step was given.
29
- *
30
- * Workflow replay reads every step's output but no step's input, so a step
31
- * that returns only what changed keeps both replay and storage from carrying
32
- * the whole session once per step. The workflow body applies the delta to the
33
- * values it passed in; see {@link applySessionStateDelta}.
34
- *
35
- * The input is snapshotted before `work` runs because step code may edit it
36
- * in place, as a channel adapter does with its state.
27
+ * Applies a step's delta to the values that step was given. The workflow body runs this; steps
28
+ * produce the delta with `withSessionStateDelta` (`step-state-delta.ts`).
37
29
  */
38
- export declare function withSessionStateDelta<I extends Partial<SessionStateValues>, R extends Partial<SessionStateValues>>(input: I, work: (input: I) => Promise<R>): Promise<WithSessionStateDelta<R>>;
39
- /** Applies a step's delta to the values that step was given. */
40
30
  export declare function applySessionStateDelta(values: SessionStateValues, delta: SessionStateDelta): SessionStateValues;
@@ -1 +1 @@
1
- import{applyValueDelta,diffValue,snapshotValue}from"#shared/value-delta.js";const SESSION_VALUE_KEYS=[`serializedContext`,`sessionState`,`history`];async function withSessionStateDelta(e,t){let n=Object.fromEntries(SESSION_VALUE_KEYS.map(t=>[t,snapshotValue(e[t])])),{serializedContext:r,sessionState:i,history:a,...o}=await t(e),s={serializedContext:r,sessionState:i,history:a},c={};for(let e of SESSION_VALUE_KEYS){let t=s[e]===void 0?void 0:diffValue(n[e],s[e]);t!==void 0&&(c[e]=t)}return{...o,stateDelta:c}}function applySessionStateDelta(e,t){return{serializedContext:applyValueDelta(e.serializedContext,t.serializedContext),sessionState:applyValueDelta(e.sessionState,t.sessionState),history:applyValueDelta(e.history,t.history)}}export{applySessionStateDelta,withSessionStateDelta};
1
+ import{applyValueDelta}from"#shared/value-delta.js";function applySessionStateDelta(e,t){return{serializedContext:applyValueDelta(e.serializedContext,t.serializedContext),sessionState:applyValueDelta(e.sessionState,t.sessionState),history:applyValueDelta(e.history,t.history)}}export{applySessionStateDelta};
@@ -0,0 +1,9 @@
1
+ import type { DurableStepResult } from "#execution/session/turn-step-types.js";
2
+ import type { SessionView } from "#protocol/session-projection/tables.js";
3
+ /**
4
+ * How a turn step's decision disagrees with what the tables say the turn waits on, if it does. A
5
+ * step that pauses on calls only requested, which the next durable step dispatches or, for task
6
+ * tool calls, answers, is the one known disagreement, `dispatch-deferred`: the tables say the
7
+ * session has work, and it does.
8
+ */
9
+ export declare function stepDisagreement(result: DurableStepResult, view: SessionView): string | undefined;
@@ -0,0 +1 @@
1
+ import{activeTurn,waiting}from"#protocol/session-projection/selectors.js";function stepDisagreement(e,t){if(e.action===`done`||e.action===`cancelled`)return;let n=activeTurn(t)?.turnId,r=n===void 0?`no-turn`:waiting(t,n)?.on??`session`,i=e.action===`paused`?e.on===`interaction`?`interaction`:`work`:e.action;if(!(i===`interaction`&&r===`interaction`||i===`work`&&r===`work`||i===`continue`&&r===`session`||i===`parked`&&(r===`no-turn`||r===`interaction`)))return e.action===`paused`&&e.on===`calls`&&(e.dispatch||e.taskToolCalls.length>0)&&r===`session`?`dispatch-deferred`:`${i}-but-${r}`}export{stepDisagreement};
@@ -0,0 +1,16 @@
1
+ import type { SessionStateValues, WithSessionStateDelta } from "#execution/session/state-delta.js";
2
+ /**
3
+ * Runs a session step's work and returns its result with the session values
4
+ * it produced replaced by their delta from the values the step was given.
5
+ *
6
+ * Workflow replay reads every step's output but no step's input, so a step
7
+ * that returns only what changed keeps both replay and storage from carrying
8
+ * the whole session once per step. The workflow body applies the delta to the
9
+ * values it passed in; see `applySessionStateDelta`.
10
+ *
11
+ * The input is snapshotted before `work` runs because step code may edit it
12
+ * in place, as a channel adapter does with its state. A retried step's state
13
+ * follows every line its interrupted attempt wrote; see
14
+ * {@link followInterruptedAttempt}.
15
+ */
16
+ export declare function withSessionStateDelta<I extends Partial<SessionStateValues>, R extends Partial<SessionStateValues>>(input: I, work: (input: I) => Promise<R>): Promise<WithSessionStateDelta<R>>;
@@ -0,0 +1 @@
1
+ import{storedProjection}from"#harness/session-machine/view.js";import{readDurableSession}from"#execution/durable-session-store.js";import{followInterruptedAttempt,readOrphanedLines}from"#execution/publish-session-events.js";import{diffValue,snapshotValue}from"#shared/value-delta.js";const SESSION_VALUE_KEYS=[`serializedContext`,`sessionState`,`history`];async function withSessionStateDelta(e,t){let n=Object.fromEntries(SESSION_VALUE_KEYS.map(t=>[t,snapshotValue(e[t])])),{sessionWritable:r}=e;if(r!==void 0&&n.sessionState!==void 0){let e=n.sessionState,t=readDurableSession(e);await readOrphanedLines({sessionId:e.sessionId,position:storedProjection(t.state).view.position,sessionWritable:r})}let{serializedContext:i,sessionState:a,history:o,...s}=await t(e),c=a??n.sessionState,l={serializedContext:i,sessionState:c===void 0||r===void 0?a:followInterruptedAttempt(r,c),history:o},u={};for(let e of SESSION_VALUE_KEYS){let t=l[e]===void 0?void 0:diffValue(n[e],l[e]);t!==void 0&&(u[e]=t)}return{...s,stateDelta:u}}export{withSessionStateDelta};